akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n,t,j,max;
  
  //N列（１以上１００以下の整数）
  cin>> n;
  //a[i][j](1以上１００以下の整数)
  int a[2][n];
  for(j=0;j<n;j++){
    cin>> a[0][j];
  }
  for(j=0;j<n;j++){
    cin>> a[1][j];
  }
    
  int x;
  max=1;
    
 for(t=0;t<n;t++){
    x=0;
  	for(j=0;j<=t;j++){
      x+=a[0][j];
    }
    for(j=t;j<n;j++){
      x+=a[1][j];
    }
    if(max<=x)
      max=x;
  }

  cout<< max <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const int MOD = 1e9 + 7;

int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
    return a;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

int binpow(int a, ll n) {
    if (n < 0)
        a = binpow(a, MOD - 2), n *= -1;
    
    int res = 1;
    while (n) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n /= 2;
    }
    return res;
}

int inv(int x) {
    return binpow(x, MOD - 2);
}

void solve() {
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    vector<int> dp(k + 1);
    for (int i = k; i >= 1; --i) {
        dp[i] = binpow(k / i, n);
        for (int j = 2 * i; j <= k; j += i)
            dp[i] = add(dp[i], -dp[j]);
        ans = add(ans, mul(dp[i], i));
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n;
	rl(n);
	VL arr(n),tmp;
	fr(i,0,n)
		rl(arr[i]);
	ll ct=0,mx=inf;

	fr(i,0,n)
	{
		mx=min(mx,arr[i]);
		if(mx==arr[i])
			ct++;
	}
	wl(ct);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;

int main(){
	std::vector<int> a(3);
	rep(i,3)std::cin >> a[i];
	sort(all(a));
	std::cout << a[0]+a[1] << std::endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
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;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c + 9 * (max(max(a, b), c)) << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, t = MAP()
a = LIST()
get = 0
ans = 0
b = [a[0]]
for i in range(1, n - 1):
    if a[i - 1] < a[i] < a[i + 1]:
        continue
    b.append(a[i])
b.append(a[-1])
d = [0 for i in range(len(b) - 1)]
mn = inf
for i in range(len(b) - 1):
    if mn > b[i]:
        mn = b[i]
    d[i] = b[i + 1] - mn
mx = max(d)
print(d.count(mx))


Measured memory_bytes: 85484
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
const int MAX = 200010;

typedef int W;
typedef pair<int, int> Pii;
const W INF = 1LL << 25;

struct edge {
	int to;
	W cost;
};

typedef vector<vector<edge>> Graph;

void dijkstra(int s, const Graph& G, vector<W>& d) {
	priority_queue<Pii, vector<Pii>, greater<Pii>> que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(Pii(0, s));
	while (!que.empty()) {
		Pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(Pii(d[e.to], e.to));
			}
		}
	}
}

int P[MAX];
int Q[MAX];
int C[MAX];
map<int, set<int>> vc_map;
map<Pii, int> vn_map;

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

	int N, M;
	cin >> N >> M;

	set<Pii> vset;
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> Q[i] >> C[i];
		vset.insert(Pii(P[i], C[i]));
		vset.insert(Pii(Q[i], C[i]));
		vc_map[P[i]].insert(C[i]);
		vc_map[Q[i]].insert(C[i]);
	}
	for (int i = 1; i <= N; i++) {
		vset.insert(Pii(i, -1));
	}
	int cnt = 0;
	for (Pii p : vset) {
		vn_map[p] = cnt++;
	}

	Graph graph(cnt);
	for (int i = 0; i < M; i++) {
		int n1 = vn_map[Pii(P[i], C[i])], n2 = vn_map[Pii(Q[i], C[i])];
		graph[n1].push_back(edge{n2, 0});
		graph[n2].push_back(edge{n1, 0});
	}

	for (int i = 1; i <= N; i++) {
		for (int c : vc_map[i]) {
			if (c == -1) continue;
			int n1 = vn_map[Pii(i, -1)], n2 = vn_map[Pii(i, c)];
			graph[n1].push_back(edge{n2, 1});
			graph[n2].push_back(edge{n1, 0});
		}
	}

	int s = vn_map[Pii(1, -1)], g = vn_map[Pii(N, -1)];
	vector<W> d(cnt);
	dijkstra(s, graph, d);

	if (d[g] == INF) d[g] = -1;
	cout << d[g] << endl;
}


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

vector<ll> divisor(ll n){
	vector<ll> ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n)ret.push_back(n/i);
		}
	}
	sort(ret.begin(),ret.end());
	return(ret);
}

int main(){
	ll n,k; cin >> n >> k;
	vector<ll> a(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	vector<ll> b(n);
	vector<ll> v=divisor(sum);
	for(int i=v.size()-1;i>=0;i--){
		b=a;
		ll zz=0;
		for(int j=0;j<n;j++){
			b[j]=b[j]%v[i];
			zz+=b[j];
		}
		int zzz=zz/v[i];
		sort(b.begin(),b.end());
		ll mx=0;
		for(int j=n-1;j>=n-zzz;j--){
			mx+=(v[i]-b[j]);
		}
		if(mx<=k){
			cout << v[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

out = 0
t = 1
while(n >= t*2+1):
    for i in range(n-2*t):

        #print(i,i+t,i+2*t)
        #print(s[i],s[i+t],s[i+2*t])

        if s[i] != s[i+t]:
            if s[i+t] != s[i+2*t]:
                if s[i] != s[i+2*t]:
                    ans -= 1
    t+=1

print(ans)


Measured memory_bytes: 9216
#include <iostream>
#include<string>
#include<math.h>
#include<stdio.h>
#include <algorithm>
using namespace std;
int main(void){
    // Here your code !

int a[10],n;
cin>>n;
for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
    cin>>a[j];
    }
    sort(a,a+3);
    if(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}



return 0;
}

Measured memory_bytes: 1168
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7

H,W = map(int,input().split())

S = [list(input()) for i in range(H)]

dx = [1,-1,0,0]
dy = [0,0,1,-1]

start = []
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            start.append((i,j))

not_visited = [[-1]*W for i in range(H)]
def distance(i,j):
    not_visited[i][j] = 0
    stack = deque()
    stack.append((i,j,"#"))

    b,w = 1,0

    while stack != deque([]):
        y,x,mark = stack.popleft()
        for i in range(4):
            if 0<= x+dx[i] <W and 0<= y+dy[i] <H and mark != S[y+dy[i]][x+dx[i]]  and not_visited[y+dy[i]][x+dx[i]] == -1:
                not_visited[y+dy[i]][x+dx[i]] =  not_visited[y][x] + 1
                if mark == "#":
                    stack.append((y+dy[i],x+dx[i],"."))
                    w += 1
                else:
                    stack.append((y+dy[i],x+dx[i],"#"))
                    b += 1
    
    return b*w

ans = 0
for i in range(H):
    for j in range(W):
        if not_visited[i][j] == -1 and S[i][j] == "#":
            ans += distance(i,j)
print(ans)

Measured memory_bytes: 94084
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=410;
const int inf=0x3f3f3f3f;

int n,m,f[Maxn*Maxn],c[Maxn*Maxn];
ll cnt[2][Maxn*Maxn],ans;
char a[Maxn][Maxn];

int find(int x) {
	if(f[x]!=x) f[x]=find(f[x]);
	return f[x];
}

void merge(int x,int y) {
	if(find(x)!=find(y))
		f[f[x]]=f[y];
}

signed main() {
//	freopen("test.in","r",stdin);
	read(n,m);
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]);
	for(int i=1;i<=n*m;i++) f[i]=i;
	for(int i=1,temp=1;i<=n;i++)
		for(int j=0;j<m;j++,temp++) {
			c[temp]=a[i][j]=='#';
			if(i!=1&&a[i][j]!=a[i-1][j])
				merge(temp,temp-m);
			if(j!=0&&a[i][j]!=a[i][j-1])
				merge(temp,temp-1);
		}
	for(int i=1;i<=n*m;i++)
		cnt[c[i]][find(i)]++;
	for(int i=1;i<=n*m;i++)
		ans+=cnt[0][i]*cnt[1][i];
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,tm;
    cin>>a>>b>>c;
    tm=a;
    a=b;
    b=tm;
    tm=a;
    a=c;
    c=tm;
    cout<<a<<" "<<b<<" "<<c<<endl;
}


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

int main() {
  int n,a,k=0,ans=1000000000;
  cin>>n;
  for (int i = 0; i < n; i++)
  {
      cin>>a;
      while(a%2==0){
          a/=2;
          k++;
      }
      ans=min(ans,k);
      k=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//created by pyoxiao on 2020/04/04
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int a, b, c;
void solve() {
    scanf("%d %d %d", &a, &b, &c);
    swap(a, b);
    swap(a, c);
    printf("%d %d %d", a, b, c);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i, 0, a) cin >> p[i];
  rep(i, 0, b) cin >> q[i];
  rep(i, 0, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());

  priority_queue<int> pq;
  rep(i, 0, x) pq.push(p[i]);
  rep(i, 0, y) pq.push(q[i]);
  rep(i, 0, c) pq.push(r[i]);

  ll ans = 0;
  rep(i, 0, x + y) {
    int t = pq.top();
    pq.pop();
    ans += t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6460
# coding: utf-8
# Your code here!
A, B = map(int, input().rstrip().split())
S = input()
n = [str(n) for n in range(10)]
fulfill = 1
for s in S[:A]:
    if s not in n:
        print("No")
        fulfill = 0
        break
if fulfill:
    if S[A] != "-":
        print("No")
        fulfill = 0
if fulfill:
    for s in S[A + 1:]:
        if s not in n:
            print("No")
            fulfill = 0
            break
if fulfill:
    print("Yes")
    

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

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

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

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

    if(n == 1){
        cout << t[0] << endl;
    }else{
        ll ans = lcm(t[0], t[1]);
        for(int i = 2; i < n; i++){
            ans = lcm(ans, t[i]);
        }

        cout << ans << endl;
    }
    
}

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

typedef long long lli;

int main() {
  lli z;
  while(cin >> z && z) {
    lli maxi = 0;
    for(lli x = 1; x*x*x <= z*z*z; ++x) {
      for(lli y = x; x*x*x + y*y*y <= z*z*z; ++y) {
        maxi = max(maxi, x*x*x + y*y*y);
      }
    }
    cout << z*z*z-maxi << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
N, M = gets.split(" ").map(&:to_i)
adress = []
prf = Array.new(N) {Array.new}
M.times do |i|
    a, b = gets.chomp.split(" ")
    prf[a.to_i - 1] << [i, b.to_i]
    while a.length < 6 do
        a = "0" + a
    end
    adress[i] = a 
end

prf.each do |p|
    next if p == []
    p = p.sort{|a, b| a[1] <=> b[1]}
    p.each_with_index do |a, i|
        i += 1
        i = i.to_s
        while i.length < 6 do
            i = "0" + i
        end
        adress[a[0]] += i
    end
end

puts adress


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

int N,Q;
string s;
vector<char> td;

bool vanish_l(int x){
	int pos=x;
	for(int i=0;i<Q;i++){
		char t=td[2*i],d=td[2*i+1];
		if(s[pos]==t){
			if(d=='L')pos--;
			else pos++;
		}
		if(pos==-1)return true;
		if(pos==N)return false;
	}
	return false;
}

bool vanish_r(int x){
	int pos=x;
	for(int i=0;i<Q;i++){
		char t=td[2*i],d=td[2*i+1];
		if(s[pos]==t){
			if(d=='L')pos--;
			else pos++;
		}
		if(pos==-1)return false;
		if(pos==N)return true;
	}
	return false;
}

int main(){
	cin >> N >> Q >> s;
	for(int i=0;i<2*Q;i++){
		char tmp;
		cin >> tmp;
		td.push_back(tmp);
	}
	
	int left,right;
	
	int ok,ng;
	
	ok=-1;
	ng=N;
	while(abs(ng-ok)>1){
		int mid=(ok+ng)/2;
		if(vanish_l(mid))ok=mid;
		else ng=mid;
	}
	left=ok;
	
	ok=N;
	ng=-1;
	while(abs(ng-ok)>1){
		int mid=(ok+ng)/2;
		if(vanish_r(mid))ok=mid;
		else ng=mid;
	}
	right=ok;
	
	cout << right-left-1 << endl;
	
	return 0;
}

Measured memory_bytes: 1024
S = input()
N = len(S)

def check(s):
    result = True
    for i in range(len(s)//2):
        if s[i]!=s[-(1+i)]:
            result = False
            break
            
    return result


Result = check(S)
if Result:
    Result = check(S[:N//2])
if Result:
    Result = check(S[(N+3)//2-1:])
    
print('Yes' if Result else ('No'))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>

int n,q,v[500001],w[500001];
int f[512][100001];
int getf(int v,int L){
	if(v<512)return f[v][L];
	if(L>=w[v])return std::max(getf(v>>1,L),getf(v>>1,L-w[v])+::v[v]);
	else return getf(v>>1,L);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",v+i,w+i);
	scanf("%d",&q);
	for(int i=1;i<512;i++){
		memcpy(f[i],f[i>>1],sizeof f[i>>1]);
		for(int j=100000;j>=w[i];--j)
			f[i][j]=std::max(f[i][j],f[i][j-w[i]]+v[i]);
	}
	for(int i=1,v,L;i<=q;i++){
		scanf("%d%d",&v,&L);
		printf("%d\n",getf(v,L));
	}
}

Measured memory_bytes: 204892
//
// Created by kinok on 2020/04/19.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>

using namespace std;


#define ll long long
#define rep(t) for(int i=0;i<t;i++)
#define deb(a) cout<<#a<<" : "<<a<<endl
#define debv(v) do{cout<<#v<<" : ";for(auto a:v){cout << a <<" ";} cout<<endl;}while(0);
#define PI 3.141592653589793



void a(){
    int a;
    cin>>a;
    cout<<fixed<<setprecision(8)<<a*2*PI<<endl;
}

void b(){
    ll n,m,total=0,k;
    cin>>n>>m;
    rep(m){
        cin>>k;
        total+=k;
    }
    cout<<(n<total?-1:n-total)<<endl;
}
void c(){

}

void d(){

}

void e(){

}

void f(){

}


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


Measured memory_bytes: 3640
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int N = S.length();
    ArrayList<Character> al = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      al.add(S.charAt(i));
    }
    int ans = 0;
    int i = 0;
    while (i < al.size() - 1) {
      if (al.get(i) != al.get(i + 1)) {
        al.remove(i);
        al.remove(i);
        ans += 2;
        i = 0;
      } else {
        i++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26568
let ss = Array.init 3 @@ fun _ -> read_line ()
let i_s = Array.make 3 0
let rec f c = String.(let j = index "abc" c in if i_s.(j) >= length ss.(j) then (Printf.printf "%c\n" "ABC".[j]; exit 0); i_s.(j) <- i_s.(j) + 1; f ss.(j).[i_s.(j) - 1])
let _ = i_s.(0) <- 1; f ss.(0).[0]

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    int nmax, nmin;
    if(a>b){
        nmax = b;
    }
    else{
        nmax = a;
    }
    nmin = a+b-n;
    if(nmin<0) nmin = 0;
    cout << nmax << ' ' << nmin << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

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

	string s1,s2; cin >> s1 >> s2;
	int res = 0;
	for(int i = 0; i < s1.size(); i++)
		if(s1[i] != s2[i]) res++;
	cout << res;

















	
}

Measured memory_bytes: 3796
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;
const LL Mod=1e9+7;
int main()
{
    int n,a[3006];
    while(scanf("%d",&n)!=EOF)
    {
        int ma=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            ma=ma+a[i]-1;
        }
        printf("%d\n",ma);
    }
    return 0;
}


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

int main()
{
  char s[100000];int i,a;
  scanf("%s",s);
  int n= strlen(s);

  for(i=0;i<n;i+=2)
    {
      if(s[i]=='0')
	a++;
      if(i<n&&s[i+1]=='1')
	a++;
    }
  if(n-a<a)
  printf("%d\n",n-a);
  else
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 256
def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

n,m,k = map(int,input().split())

mod = 998244353
fact = [1, 1]
factinv = [1, 1]
inv = [0,1]
rui = [1,m-1]

for i in range(2,n+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((inv[mod % i] * (mod - (mod // i))) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)
    rui.append(rui[-1]*(m-1) % mod)

ans = 0
for i in range(k+1):
    ans += cmb(n-1,i,mod)*m*rui[n-1-i]
    ans %= mod
print(ans)

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

       
   
   int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[n-1]=='s'){
      s=s+"es";
  }
  else
  s=s+"s";
  cout<<s<<endl;
return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

//Discounts of Buckwheat
public class Main{

	static int[] m = {200,300,500};
	static int[] p = {380,550,850};
	static int[] d = {5,4,3};
	static double[] r = {0.8,0.85,0.88};
	
	static int min;
	
	static void dfs(int k, int rest, double x){
		if(rest==0){
			min = (int) Math.min(min, x);
			return;
		}
		if(k==3||rest<0)return;
		for(int i=0;i<=40;i++){
			dfs(k+1, rest-m[k]*i, x + p[k]*(i-i%d[k])*r[k] + p[k]*(i%d[k]));
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			min = Integer.MAX_VALUE;
			dfs(0,n,0);
			System.out.println(min);
		}
	}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int a[N][M];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      a[i][j] = 0;
    }
  }
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      a[x-1][i] = 1;
    }
  }

  int p[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }

  int ans = 0;
  
  for (int bit = 0; bit < (1 << N); bit++) {
    bool flag = true;
    
    for (int i = 0; i < M; i++) {
      int switch_num = 0;
      
      for (int j = 0; j < N; j++) {
        if (bit & (1 << j)) {
          switch_num += a[j][i];
        }
      }

      if (switch_num % 2 != p[i]) {
        flag = false;
        break;
      }
    } 
    if (flag) ans++;   
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}




int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

  
 

/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif
*/
   ll n,i,x=0;
   cin>>n;

   ll a[n];

   for(i=0;i<n;i++){
      cin>>a[i];
      x^=a[i];
   }

   for(i=0;i<n;i++){
    cout<<(x^a[i])<<" ";
   }





  auto end = chrono::high_resolution_clock::now();

 /* #ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  vector<int>a(n);
  string ans="Yes";
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int sum=accumulate(a.begin(),a.end(),0);
  if(h>sum){
    ans="No";
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 640
# coding: utf-8

N = input()
N_list = list(N)
N_count = N_list.count("1")

if N_count == 0:
	print("0")
elif N_count == 1:
	print("1")
elif N_count == 2:
	print("2")
elif N_count == 3:
	print("3")

Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  int n,i,j,u,k,v;
  int A[100][100];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = 0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u-=1;
    
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v-=1;
      A[u][v] = 1;
     
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[i][j]);
    }
    printf("%d",A[i][n-1]);
    printf("\n");
  }

  return 0;
}
  



Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    H,W=mi()
    G = [[] for _ in range(H)]
    for i in range(H):
        S = input()
        G[i] = list(S)
    
    # print(G)
    for h in range(H):
        for w in range(W):
            if G[h][w] == "#": continue
            res = 0
            for dh in [-1,0,1]:
                for dw in [-1,0,1]:
                    if dh == dw == 0: continue
                    if 0 <= h+dh < H and 0<= w+dw < W:
                        if G[h+dh][w+dw] == "#":
                            res += 1
            
            G[h][w] = str(res)

    # print(G)
    for h in range(H):
        print("".join(G[h]))



if __name__ == "__main__":
    main()

Measured memory_bytes: 74064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n; cin >> n;
  ll ans = 0;
  for (int i=1; i<=n; i++) {
    ll t = n/i;
    ans += t*(i + i*t)/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
from sys import stdin

class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k

dlist = DList()

n = int(stdin.readline())
for i in range(n):
    cmd = stdin.readline()
    if   cmd.startswith('insert'):
        dlist.insert(cmd[7:-1])
    elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
    elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
    elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1])

print(' '.join(dlist))




Measured memory_bytes: 227796
n = int(input())
a = list(map(int,input().split()))

c1 = 0
c2 = 0
c4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        c4 += 1
    elif a[i] % 2 == 0:
        c2 += 1
    elif a[i] == 1:
        c1 += 1
if c2 == n:
    print('Yes')
    quit()

n -= c2
c2 %= 2
n += c2
f = n // 2

if c4 >= f:
    print('Yes')
    quit()
else:
    print('No')

Measured memory_bytes: 62576
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c))
	{
		if(a+b==c||a+c==b||b+c==a) cout<<"Yes";
		else cout<<"No";	
	}
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n,k,s=map(int,input().split())
	if s!=10**9:
		A=[s]*k+[s+1]*(n-k)
	else:
		A=[s]*k+[s-1]*(n-k)
	print(*A)
	


if __name__ == "__main__":
	main()


Measured memory_bytes: 46148
from itertools import accumulate
def main():
    n=int(input())
    a=list(map(int,input().split()))
    aa=list(accumulate(a))
    mod=10**9+7
    ans=0
    for i in range(n):
        ans += a[i]*(aa[-1]-aa[i])%mod
    print(ans%mod)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 31564
#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{
    cout << "Sunny" << endl;
  }
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, K;
vec a;
bool dp[5010][5010];

bool C(const int &m) {
  m0(dp);
  dp[0][0] = true;
  vector<int> b;

  for (int i = 0; i < N; i++) {
    if (i != m) b.push_back(a[i]);
  }

  for (int i = 0; i < N - 1; i++) {
    for (int k = 0; k <= K; k++) {
      if (!dp[i][k]) continue;
      dp[i + 1][k] = true;
      if (k + b[i] <= K) dp[i + 1][k + b[i]] = true;
    }
  }

  int tmp = 0;
  for (int i = 0; i <= K; i++) {
    if (dp[N - 1][i]) {
      tmp = a[m] + i;
      if (tmp >= K) break;
    }
  }
  return (tmp < K) || (K <= tmp - a[m]);
}

signed main() {
  cin >> N >> K;
  a.resize(N);

  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a[i] = min(tmp, K);
  }

  sort(ALL(a));

  int ok = -1, ng = N + 1;
  for (int i = 0; i < 50; i++) {
    int mid = (ok + ng) / 2;
    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << min(ng, N) << endl;
  return 0;
}


Measured memory_bytes: 24960
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
# N-1辺表示をグラフ表示に
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
S, T = map(lambda x:int(x)-1, input().split())


q = {S}
checked = [False]*N
checked[S] = True

ok = False
c = 0
while q:
    c += 1
    qq = set()
    if c % 3 == 0:
        for p in q:
            for np in graph[p]:
                if np == T:
                    ok = True
                    break
                if not checked[np]:
                    qq.add(np)
                    checked[np] = True
    else:
        for p in q:
            for np in graph[p]:
                qq.add(np)
    if ok:
        break
    q = qq

if ok:
    print(c//3)
else:
    print(-1)

Measured memory_bytes: 57468
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

int main(){
	rrep(i,9)rrep(j,9)printf("%dx%d=%d\n",i,j,i*j);
	return 0;
}

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

#define int long long

int32_t main()
{
    int n ;
    cin >> n ;
    int ans = 0 ;
    int cur = 10 ;
    int var = 50 ;
    if(n % 2 == 0)
    {
        while(cur <= n)
        {
            ans += (n / cur) ;
            cur *= 5 ;
        }

    }
    else
    {
        ans = 0 ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
  long long int n,u=0;
  cin >> n;
  vector<pair<long int,long int>> AB(n);
  for(int i=0;i<n;i++){
    cin >> AB[i].second >> AB[i].first;
  } 
  sort(AB.begin(), AB.end());
  for(int i=0;i<n;i++){
    u += AB[i].second;
    if(u>AB[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3328
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(4100000)

#MOD
P = 10**9 + 7
N = 200001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2, N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b): return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P

#全方位木dp
#-------------------------------------------------------------------
#扱うクラス
class T:
    num = 1
    child = 0

    def __init__(self, a, b):
        self.num = a
        self.child = b

#零元
zero = T(1, 0)
#一個上に遷移した時の変化
def step(x):
    return T(x.num, x.child+1)
#マージ
def merge(x, y):
    return T((x.num*y.num*comb(x.child+y.child, x.child))%P, x.child+y.child)

G = [[] for _ in range(N)]
down_data = [zero for _ in range(N)]
dat = [zero for _ in range(N)]
rev_data = [zero for _ in range(N)]


class p:
    num = -1
    parent = -1

    def __init__(self, x, y):
        self.num = x
        self.parent = y
node_list = []
def makeNodeList(root):
    #dfsでの探索順の作成
    stack = []
    stack.append(p(root, -1))
    while len(stack) != 0:
        now = stack.pop()
        node_list.append(now)
        for to in G[now.num]:
            if to == now.parent: continue
            stack.append(p(to, now.num))

def dfs(root):
    for i in range(len(node_list)):
        now = node_list[len(node_list)-1-i]
        for to in G[now.num]:
            if to == now.parent: continue
            down_data[now.num] = merge(down_data[now.num], step(down_data[to]))

def dfs_rev(root):
    for now in node_list:
        #累積
        rev = rev_data[now.num]
        left = []
        right = []
        cnt = 0
        for to in G[now.num]:
            if to==now.parent: continue
            if len(left)==0: left.append(step(down_data[to]))
            else: left.append(merge(left[cnt-1], step(down_data[to])))
            cnt += 1
        cnt = 0
        for to in reversed(G[now.num]):
            if to==now.parent: continue
            if len(right)==0: right.append(step(down_data[to]))
            else: right.append(merge(right[cnt-1], step(down_data[to])))
            cnt += 1
        dat[now.num] = merge(rev, down_data[now.num])
        cnt = 0
        for to in G[now.num]:
            if to==now.parent: continue
            x = zero if cnt==0 else left[cnt-1]
            y = zero if cnt==len(right)-1 else right[len(right)-2-cnt]
            rev_data[to] = step(merge(rev, merge(x, y)))
            cnt += 1

def calc(data_num):
    root = -1
    for i in range(1, data_num+1):
        if len(G[i]) == 1:
            root = i
            break
    makeNodeList(root)
    dfs(root)
    dfs_rev(root)
#-------------------------------------------------------------------
def main():
    n = int(input())
    for i in range(n-1):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)
    calc(n)
    for i in range(1, n+1): print(dat[i].num)

if __name__ == "__main__": main()


Measured memory_bytes: 179436
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

struct UnionFind
{
    vector<int> par, sz;
    int n_cc;

    UnionFind(int N){
        par = vector<int>(N);
        REP(i, N) par[i] = i;
        sz = vector<int>(N, 1);
        n_cc = N;
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(sz[x] < sz[y]) swap(x, y);

        par[y] = x;
        sz[x] += sz[y];
        n_cc--;
    }

    bool is_union(int x, int y){
        x = find(x);
        y = find(y);
        return x == y;
    }

    int union_size(int x){
        return sz[find(x)];
    }

};


signed main(){

    int N, M; cin >> N >> M;
    UnionFind UF(N);
    REP(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        UF.unite(a, b);
    }
    int ans = 0;
    REP(i, N) chmax(ans, UF.union_size(i));
    Out(ans);

    return 0;
}


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

int main(){
  int w,a,b;
  cin>>w>>a>>b;
  int ans = b-a-w;
  if(a<=b){
    if(ans<0){
      cout<<0<<endl;
    }else{
    cout<<ans<<endl;
  }
}else{
  ans=a-b-w;
  //cout<<ans<<endl;
  if(ans<0){
    cout<<0<<endl;
  }else{
  cout<<ans<<endl;
}
  return 0;

}}


Measured memory_bytes: 256
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n = Ii()
i = 0;
s = [chr(ord('a') + i) for i in range(26)]
a = []
while n >= 1:
	a.append(s[n%26-1])
	n = (n-1) // 26
    
print(''.join(a)[::-1])


Measured memory_bytes: 9160
#include <string.h>
#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <iostream>
using namespace std;

int main() {
  int X;
  int min_p;
  bool prime = true;
  cin >> X;

  for (int n = X; n <= 10000000; n++) {
    prime = true;
    for (int i = 2; i <= n - 1; i++) {
      if (n % i == 0) {
        prime = false;
      }
    }

    if (prime == true) {
      min_p = n;
      break;
    }
  }

  cout << min_p << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char ans[100050];
char in[100050];
int n;
int check(char x,char y){
    memset(ans,'!',sizeof(ans));
    ans[0] = x;
    ans[1] = y;
    for(int i = 1;i <= n;i ++){
        if(ans[i] == 'S'){
            if(in[i] == 'x'){
                if(ans[i - 1] == 'S'){ans[i + 1] = 'W';}
                else{ans[i + 1] = 'S';}
            }
            else{
                if(ans[i - 1] == 'S'){ans[i + 1] = 'S';}
                else{ans[i + 1] = 'W';}
            }
        }
        else{
            if(in[i] == 'x'){
                if(ans[i - 1] == 'S'){ans[i + 1] = 'S';}
                else{ans[i + 1] = 'W';}
            }
            else{
                if(ans[i - 1] == 'S'){ans[i + 1] = 'W';}
                else{ans[i + 1] = 'S';}
            }
        }
    }
    //for(int i = 0;i < n + 2;i ++){printf("%c",ans[i]);}printf("\n");
    if(ans[0] == ans[n] && ans[1] == ans[n + 1]){return 1;}
    return 0;
}

int main(){
    scanf("%d",&n);
    scanf("%s",in);
    in[n] = in[0];
    in[n + 1] = in[1];
    in[n + 2] = '\0';
    //printf("%s\n",in);
    if(check('W','W') == 1){
        for(int i = 0;i < n;i ++){
            printf("%c",ans[i]);
        }printf("\n");
    }
    else if(check('W','S') == 1){
        for(int i = 0;i < n;i ++){
            printf("%c",ans[i]);
        }printf("\n");
    }
    else if(check('S','S') == 1){
        for(int i = 0;i < n;i ++){
            printf("%c",ans[i]);
        }printf("\n");
    }
    else if(check('S','W') == 1){
        for(int i = 0;i < n;i ++){
            printf("%c",ans[i]);
        }printf("\n");
    }
    else{
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>

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

using namespace std;

typedef long long ll;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n; cin >> n;
  int ans = 0;

  for (int a = 1; a < n; a++) {
    int b = n-a;
    if (a != b) { ans++; }
  }

  cout << ans/2 << endl;

  return 0;
}


Measured memory_bytes: 256