akhauriyash/Code-Regression huggingface dataset:
S=list(input())
N=len(S)
S_int_1=list(S)
S_int_2=list(S)
for i in range(N):
    S_int_1[i]=int(S[i])
    S_int_2[i]=int(S[i])
cnt_1=0
cnt_2=0
for i in range(N):
    if i%2==0 and S_int_1[i]==0:
        S_int_1[i]=1
        cnt_1+=1
    elif i%2==1 and S_int_1[i]==1:
        S_int_1[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int_2[i]==1:
        S_int_2[i]=0
        cnt_2+=1
    elif i%2==1 and S_int_2[i]==0:
        S_int_2[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))

Measured memory_bytes: 5544
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int a, b;
	char s[11];
	scanf("%d %d\n%s", &a, &b, s);
	for(int i = 0; i < a; i++)	
	{
		if(!(s[i] >= '0' && s[i] <= '9'))
		{
			printf("No\n");
			return 0;
		}
	}
	if(s[a] != '-')
	{
		printf("No\n");
		return 0;	
	}
	for(int i = a + 1; i < a + b + 1; i++)	
	{
		if(!(s[i] >= '0' && s[i] <= '9'))
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int r;
int main(void){
    cin >> r;
    cout << r * r << endl;
    return 0;
}



Measured memory_bytes: 256
from collections import Counter
N = int(input())
D = list(map(int, input().split()))

cnt = Counter(D)
lst = []
for key in sorted(cnt.keys()):
    lst.append([key, cnt[key]])

ans = 0
tmp = 0
for i, kv in enumerate(lst):
    key, value = kv
    tmp += value
    if tmp == N - tmp:
        if i + 1 < len(lst):
            ans = lst[i+1][0] - key
            break
        else:
            break
print(ans)

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

struct Line{
    int h, p, q;
    bool operator<(const Line& obj)const{
        if(h > obj.h)return true;
        else return false;
    }
};

int vert[102];

int main(){
    int n, m, a;
    while(scanf("%d %d %d",&n, &m, &a), n != 0){
        for(int i=1;i<=n;++i) vert[i] = i;
        priority_queue<Line> que;
        for(int i=0;i<m;++i){
            int h, p, q;
            cin >> h >> p >> q;
            que.push((Line){h, p, q});
        }
        for(int i=0;i<m;++i){
            Line ln = que.top(); que.pop();
            swap(vert[ln.p], vert[ln.q]);
        }
        cout << vert[a] << endl;
    }

    return 0;
}


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

n = int(input())
T, a = map(int, input().split())
h = [int(x) for x in input().split()]

i = 0
x = 65536

for t in [T - height * 6 / 1000 for height in h]:
  i += 1
  if abs(t-a) < x:
    x = abs(t-a)
    ans = i

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	if (n % 2) {
		cout << 0;
		return 0;
	}
	ll res = 0;
	while (n) {
		res += n / 10;
		n /= 5;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;



int main(){
#ifdef LOCAL
	freopen("A_input.txt", "r", stdin);
	//freopen("A_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	if (abs(b - a) % 2 == 0) {
		cout << abs(b - a) / 2 << "\n";
		return 0;
	}
	ll res = a + (b - a) / 2;
	res = min(res, n - b + 1 + (b - a) / 2);
	cout << res << "\n";
}


Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
c4,c2,c1=0,0,0
a.each do |b|
  if b%4==0
    c4+=1
  elsif b%2==0
    c2+=1
  else
    c1+=1
  end
end
if c4>=c1 || c1-c4==1 && c2==0
  puts :Yes
else
  puts :No
end


Measured memory_bytes: 8452
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll sum = A + B;
    if(sum & 1) cout << "IMPOSSIBLE";
    else cout << sum / 2;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $r);
fscanf(STDIN, "%s", $string);

if ($r % 2) {
  echo "No"; exit;
}

$halfed_r = $r / 2;
$halfed_string = substr($string, 0, $halfed_r);
if (strcmp($string, $halfed_string.$halfed_string) == 0) {
  echo "Yes"; exit;
} else {
  echo "No"; exit;
}

Measured memory_bytes: 4732
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int n;
int a[100005],b[100005],c[100005];
typedef long long L;
L ans;
L sum[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)cin>>b[i];
	for(int i=1;i<=n;++i)cin>>c[i];
	sort(a+1,a+n+1);sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;++i)//{
		sum[i]=sum[i-1]+lower_bound(a+1,a+n+1,b[i])-a-1;
//		cout<<i<<' '<<sum[i]<<endl;
//	}
	for(int i=1;i<=n;++i)
		ans+=sum[lower_bound(b+1,b+n+1,c[i])-b-1];
	printf("%lld",ans);
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	vector<int> a(n+1),b(n);
	rep(i,n+1) cin>>a[i];
	rep(i,n) cin>>b[i];

	long long ans=0;
	rep(i,n){
		int x=min(a[i],b[i]);
		b[i]-=x;
		ans+=x;
		int y=min(a[i+1],b[i]);
		a[i+1]-=y;
		ans+=y;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  string S; cin >> S;
  
  string T = "ATCG";
  
  int ans = 0;
  int now = 0;
  for (int i = 0; i < S.size(); ++i) 
  {
    bool isATCG = false;
    for (int j = 0; j < T.size(); j++) {
      if (S[i] == T[j]) isATCG = true;
    }
    
    if (!isATCG) {
      now = 0;
    }
    else {
      now++;
      ans = max(now, ans);
    }
  }
  
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;
const int MAX = 200000 + 10;

long double A[MAX] = { 0 };//累積和

int main() {
    int N, K;
    cin >> N >> K;
    A[0] = 0;
    for (int i = 1; i < N+1; i++)
    {
        long double pi;
        cin >> pi;
        A[i] = pi * (1 + pi) / 2/pi + A[i - 1];
    }
    long double maxv = 0;
    for (int i = K; i < N + 1; i++)
    {
        maxv = (A[i] - A[i - K] > maxv) ? A[i] - A[i - K] : maxv;
    }
    cout <<fixed<<setprecision(8)<< maxv << endl;
}

Measured memory_bytes: 3328
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let mut a: Vec<u64> = Vec::with_capacity(n);
    let mut b: Vec<u64> = Vec::with_capacity(n);
    for _ in 0..n {
        a.push(read());
        b.push(read());
    }
    a.sort();
    b.sort();

    if n % 2 == 0 {
        let x_min = a[n / 2] + a[n / 2 - 1];
        let x_max = b[n / 2] + b[n / 2 - 1];
        println!("{}", x_max - x_min + 1);
    } else {
        let x_min = a[n / 2];
        let x_max = b[n / 2];
        println!("{}", x_max - x_min + 1);
    }
}


Measured memory_bytes: 5820
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 int n,m; cin>>n>>m;
 bool check=false;
 vector<vector<int>> v(n,vector<int>(0));

 REP(i,m){
     int a,b;
     cin>>a>>b;
     v[a].push_back(b);
 }
 REP(i,v[1].size()){
     int s=v[1][i];
     REP(j,v[s].size())if(v[s][j]==n){
         check=true;
        break;
     }
 }

cout<<(check?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 8576
// 2006à\IB ñÔÌÒ¬p[gII
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

inline string reverse(string s){
	reverse(s.begin(), s.end());
	return s;
}

int main(){
	int t; cin >> t;
	while(t--){
		string s; cin >> s;
		set<string> S;
		S.insert(s);
		S.insert(reverse(s));
		int n = s.size();
		for(int i=1;i<n;i++){
			string a = s.substr(0,i);
			string b = s.substr(i);
			string ra = reverse(a);
			string rb = reverse(b);
			S.insert( a +rb);
			S.insert(ra + b);
			S.insert(ra +rb);
			S.insert( b + a);
			S.insert( b +ra);
			S.insert(rb + a);
		}
		cout << S.size() << endl;
	}
}

Measured memory_bytes: 1004
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 string s,t,u ;
 int a, b;
 cin >> s >> t >> a >> b >> u;
 if(s==u) cout << a-1 <<" "<< b;
 if(t==u) cout << a <<" " << b-1;
  return 0;
}

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

using namespace std;
using namespace atcoder;

int main(){
    int N,M;
    cin>>N>>M;
    scc_graph ss(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        ss.add_edge(a,b);
    }
    vector<vector<int>> ans=ss.scc();

    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i].size()<<" ";
        for(int j=0;j<ans[i].size();j++){
            cout<<ans[i][j];
            if(j==ans[i].size()-1) cout<<endl;
            else cout<<" ";
        }
    }
}


Measured memory_bytes: 40092
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int l,a,b,c,d;
  int day;
  cin>>l>>a>>b>>c>>d;
  if(a%c==0&&b%d==0) day=l-max(a/c,b/d);
  else if(a%c==0&&b%d!=0) day=l-max(a/c,b/d+1);
  else if(a%c!=0&&b%d==0) day=l-max(a/c+1,b/d);
  else day=l-max(a/c+1,b/d+1);
  cout<<day<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n+1);
  FOR(i, 1, n) {
    cin >> a[i];
  }
  for (int i = k + 1; i <= n; i++) {
    if (a[i] > a[i - k]) COUT("Yes");
    else COUT("No");
  }

  return 0;
}


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

typedef long long ll;

ll N;
vector<vector<ll>> Cap;
const ll INF = 1ll << 60;
ll Src, Tgt;
ll Res;

int main() {
  cin >> N;
  Src = N;
  Tgt = N + 1;
  Cap.resize(N + 2);
  for (auto &cap : Cap) cap.resize(N + 2);
  for (ll v = 0; v < N; ++v) {
    ll a;
    cin >> a;
    if (a < 0)
      Cap[Src][v] = -a;
    else {
      Res += a;
      Cap[v][Tgt] = a;
    }
  }
  for (ll i = 1; i <= N; ++i)
    for (ll j = 2 * i; j <= N; j += i) Cap[i - 1][j - 1] = INF;
  while (true) {
    ll flow = -1;
    vector<ll> parent;
    {
      queue<pair<ll, ll>> que;
      vector<bool> visited;
      visited.resize(N + 2);
      visited[Src] = true;
      parent.resize(N + 2, -1);
      que.push(make_pair(Src, INF));
      while (!que.empty()) {
        ll v, cap;
        tie(v, cap) = que.front();
        que.pop();
        if (v == Tgt) {
          flow = cap;
          break;
        }
        for (ll w = 0; w < N + 2; ++w) {
          if (visited[w] || Cap[v][w] <= 0) continue;
          visited[w] = true;
          parent[w] = v;
          que.push(make_pair(w, min(cap, Cap[v][w])));
        }
      }
    }
    if (flow == -1) break;
    for (ll v = Tgt; v != Src; v = parent[v]) {
      ll u = parent[v];
      Cap[u][v] -= flow;
      Cap[v][u] += flow;
    }
    Res -= flow;
  }
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 384
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T>
vector<int> MP(const T& s){
  int n=s.size();
  vector<int> res(n+1,-1);
  for(int i=0,j=-1;i<n;++i){
    while(j>=0 && s[j]!=s[i])j=res[j];
    ++j;
    res[i+1]=j;    
  }
  return res;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  V<ll> a(n),b(n),c(n),d(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];

  rep(i,0,n){
    c[i]=a[i]^a[(i+1)%n];
    d[i]=b[i]^b[(i+1)%n];
  }

  V<int> res=MP(d);

  c.insert(c.end(),all(c));
  int now=0;
  rep(i,0,2*n-1){
    while(c[i]!=d[now] && now>0){
      now=res[now];
    }

    if(c[i]==d[now])now++;

    if(now==n){
      cout<<i-n+1<<" "<<(a[i-n+1]^b[0])<<ENDL;
      now=res[now];
    }
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?


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

using namespace std;

using dijkstra_cost = long long;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex
{
	T cost;
	Vertex(T v1) : cost(v1) {}
	Vertex() {}
	inline bool operator<(const Vertex r) const {
		return cost < r.cost;
	}
	inline bool operator>(const Vertex r) const {
		return r < *this;
	}
	inline bool operator>=(const Vertex r) const {
		return !(*this < r);
	}
	inline bool operator<=(const Vertex r) const {
		return !(r < *this);
	}
	inline bool operator==(const Vertex r) const {
		return !(r < *this) && !(*this < r);
	}
	inline bool operator!=(const Vertex r) const {
		return (r < *this) || (*this < r);
	}
};
using vertex = Vertex<dijkstra_cost>;

template<class T>
struct Edge
{
	int to;
	T cost;
	Edge(int t, T c) : to(t), cost(c) {}
	Edge() {}
	inline bool operator<(const Edge rhs) const {
		return cost < rhs.cost;
	}
	inline bool operator>(const Edge rhs) const {
		return rhs < *this;
	}
	inline bool operator>=(const Edge rhs) const {
		return !(*this < rhs);
	}
	inline bool operator<=(const Edge rhs) const {
		return !(*this > rhs);
	}
	inline bool operator==(const Edge rhs) const {
		return *this <= rhs && *this >= rhs;
	}
	inline bool operator!=(const Edge rhs) const {
		return !(*this == rhs);
	}
};
using edge = Edge<dijkstra_cost>;
using graph = Graph<vertex, edge>;

template<class T, class V, class E>
void Dijkstra(Graph<V, E>& G, int s, T INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST;
	priority_queue<E, vector<E>, greater<E>> q;
	q.emplace(s, 0);
	while (!q.empty()) {
		auto a = q.top();
		q.pop();
		if (a.cost >= v[a.to].cost) continue;
		v[a.to].cost = a.cost;
		for (auto& p : e[a.to]) {
			if (p.cost == INF_COST) continue;
			if (a.cost + p.cost < v[p.to].cost) q.emplace(p.to, a.cost + p.cost);
		}
	}
}

int main() {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--;t--;
	graph g1(n);
	graph g2(n);
	for (int i = 0; i < m; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		g1.add_edge(a-1, b-1, c);
		g1.add_edge(b-1, a-1, c);
		g2.add_edge(a-1, b-1, d);
		g2.add_edge(b-1, a-1, d);
	}
	Dijkstra(g1, s, LLONG_MAX);
	Dijkstra(g2, t, LLONG_MAX);
	auto& v1 = g1.v;
	auto& v2 = g2.v;
	vector<long long> res(n, 0);
	for (int i = 0; i < n; i++) {
		res[i] = (long long) 1e15 - v1[i].cost - v2[i].cost;
	}
	for (int i = n-2; i >= 0; i--) {
		res[i] = max(res[i+1], res[i]);
	}

	for (int i = 0; i < n; i++) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 19000
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,k;

int main(){
    int a , b;
    cin >> k >> a >> b;
    for(i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3560
H, W, D = map(int, input().split())
p = {}
for i in range(H):
    inp = list(map(int, input().split()))
    for j, value in enumerate(inp):
        p[value] = (i, j)

cost = {}
for i in range(1, W * H + 1):
    cost[i] = cost[i - D] + abs(p[i][0] - p[i - D][0]) + abs(p[i][1] - p[i - D][1]) if i > D else 0

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(cost[R] - cost[L])


Measured memory_bytes: 35980
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace tree { namespace diameter {

  using Weight  = ll;
  using Edge    = pair<int, Weight>;
  using Graph   = vector<vector<Edge>>;

  namespace detail {
  using Result = pair<Weight, int>;

  Result visit(int parent, int curr, Graph const& G) {
    Result ret(0, curr);
    for(auto && e: G[curr]) {
      int to; Weight weight; tie(to, weight) = e;
      if(to == parent) { continue; }
      auto t = visit(curr, to, G);
      t.first += weight;
      if(ret.first < t.first) { ret = t; }
    }
    return ret;
  }}

  using Result = tuple<Weight, int, int>;

  Result diameter(Graph const& G) {
    auto r = detail::visit(-1, 0, G);
    auto t = detail::visit(-1, r.second, G);
    return Result{t.first, r.second, t.second};
  }

#define USE_TREE_DIAMETER   \
  using tree::diameter::Weight; \
  using tree::diameter::Edge;   \
  using tree::diameter::Graph;  \
  using tree::diameter::diameter;
}}

USE_TREE_DIAMETER

int main() {

  int N; cin >> N;
  Graph g(N);
  rep(i, N-1) {
    int s, t, w; cin >> s >> t >> w;
    g[s].emplace_back(t, w);
    g[t].emplace_back(s, w);
  }

  Weight w; int _; tie(w, _, _) = diameter(g);
  cout << w << endl;

  return 0;
}

Measured memory_bytes: 17492
S = input()
a = [int(S[:2]), int(S[2:])]
b = [1<=c and c<=12 for c in a]

if b[0] and b[1]:
    print('AMBIGUOUS')
if b[0] and not b[1]:
    print('MMYY')
if not b[0] and b[1]:
    print('YYMM')
if not b[0] and not b[1]:
    print('NA')

    


Measured memory_bytes: 3064
use proconio::input;

fn main(){
    input!(x:i128);
    for i in -120i128..120i128 {
        for j in -120i128..120i128{
            if i*i*i*i*i - j*j*j*j*j == x {
                println!("{} {}",i,j);
                return;
            }
        }
    }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    k++;

    if (b - a <= 2 || k < a) {
        cout << k << endl;
        return 0;
    } else {
        ll ans = a;
        k -= a;
        ans += (b - a) * (k / 2);
        if (k % 2 == 1) ans++;
        cout << ans << endl;
    }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i < n + 1; i++)
    {
        int x;
        cin >> x;
        a[x] = i;
    }
    for (int i = 1; i < n + 1; i++)
    {
        if (i > 1)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int c;
	while(scanf("%d",&c)!=EOF){
		if(c>=40){
			c=c%39;
			if(c==0){
				printf("3C39\n");
			}
			else if(c>0 && c<10){
				printf("3C0%d\n",c);
			}
			else{
				printf("3C%d\n",c);
			}
		}
		else if(c>0 && c<10){
			printf("3C0%d\n",c);
		}
		else {
			printf("3C%d\n",c);
		}
	}
	return 0;
}

Measured memory_bytes: 1036
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    tmp1 = max(0, n//i * (i-k))
    tmp2 = max(n%i+1-k, 0)
    ans += tmp1 + tmp2

if k != 0:  
    print(ans)
else:
    print(n**2)


Measured memory_bytes: 2940
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = float('inf')
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,x = LI()
    a = LI()

    N0 = 2**(N.bit_length())
    st = [INF] * (2*N0)

    def update(i,x):
        i += N0-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = min(st[i*2+1],st[i*2+2])

    def query(l,r):
        l += N0; r += N0
        ret = INF
        while l < r:
            if l % 2:
                ret = min(ret,st[l-1])
                l += 1
            if r % 2:
                r -= 1
                ret = min(ret,st[r-1])
            l >>= 1; r >>= 1
        return ret

    for i,j in enumerate(a):
        update(i,j)

    ans = INF
    for i in range(N):
        tmp = i * x
        for j in range(N):
            l = j - i
            if l < 0:
                l += N
                tmp += min(query(0,j+1),query(l,N))
            else:
                tmp += query(l,j+1)
        ans = min(ans,tmp)
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 72672
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i],t[i] = map(str,input().split())
x = str(input())

counter = 0
switch = 0
for i in range(n):
    if switch == 1:
        counter += int(t[i])
    if s[i] == x:
        switch = 1

print(counter)


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

type pair struct{ a, b int }

func convert(x int) pair {
	a, b := x, x%10
	for {
		if a < 10 {
			break
		}
		a /= 10
	}
	return pair{a, b}
}

func main() {
	var n int
	fmt.Scan(&n)

	m := make(map[pair]int)
	for i := 1; i <= n; i++ {
		m[convert(i)]++
	}
	ans := 0
	for i := 1; i <= n; i++ {
		p := convert(i)
		ans += m[pair{p.b, p.a}]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>

struct Node {
  int key;
  Node *next;
  Node *prev;
};

class DoublyLinkedList {
  private:
    Node *root;
  public:
    DoublyLinkedList() {
      root = (Node *)std::malloc(sizeof(Node));
      root->next = root;
      root->prev = root;
    }

    void insertNode(int x) {
      Node *node = (Node *)std::malloc(sizeof(Node));
      node->key = x;
      node->next = root->next;
      node->prev = root;
      root->next->prev = node;
      root->next = node;
    }

    void deleteNode(int x) {
      Node *node = root->next;
      while (node != root && node->key != x)
        node = node->next;
      if (node == root) return;
      node->prev->next = node->next;
      node->next->prev = node->prev;
      std::free(node);
    }

    void deleteFirstNode() {
      Node *node = root->next;
      if (node == root) return;
      root->next = node->next;
      node->next->prev = root;
      std::free(node);
    }

    void deleteLastNode() {
      Node *node = root->prev;
      if (node == root) return;
      root->prev = node->prev;
      node->prev->next = root;
      std::free(node);
    }

    void display() {
      Node *node = root->next;
      while (node != root) {
        std::printf("%d%s", node->key, node->next == root ? "\n" : " ");
        node = node->next;
      }
    }
};

int main() {
  DoublyLinkedList dl;
  int n;
  char command[20];
  int x;

  std::scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    std::scanf("%s%d", command, &x);
    if (command[0] == 'i') dl.insertNode(x);
    else if (command[6] == 'F') dl.deleteFirstNode();
    else if (command[6] == 'L') dl.deleteLastNode();
    else if (command[0] == 'd') dl.deleteNode(x);
  }
  dl.display();
}



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

int main() {
    int x, y, z, ans;
    cin >> x >> y >> z;
    x -= z;
    ans = x / (y + z);
    cout << ans << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N;
int E[200001], n[200001], H[100001];
int kyori, kotae;
int dfs(int p, int mae, int d) {
	int kazu = 1;
	if (p == N) {
		kazu += 1 << 20;
		kyori = (d + 1) / 2;
	}
	for (int i = H[p]; i; i = n[i]) if (E[i] != mae) kazu += dfs(E[i], p, d + 1);
	if (kazu > (1 << 20) && d == kyori + 1) kotae = kazu - (1 << 20);
	return kazu;
}

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


	N = getint();
	int kari = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[kari] = b;
		n[kari] = H[a];
		H[a] = kari++;
		E[kari] = a;
		n[kari] = H[b];
		H[b] = kari++;
	}

	dfs(1, 0, 1);

	if (N - kotae > kotae) printf("Fennec");
	else printf("Snuke");

	Would you please return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
long long dif(long long a, long long b)
{
    long long ans=a-b;
    if(ans<0) ans*=-1;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long N, h[100005],i,ll,K,temp,mini,j;
    long long f1,f2;
    cin>>N>>K;
    for(i=0;i<N;i++)
        cin>>h[i];
    long long M[100005]={0};
    M[N-2]=dif(h[N-1],h[N-2]);
    for(i=N-3;i>=0;i--)
    {
        mini=2000000000000;
        temp=K;
        for(ll=i+1;ll<N&&temp--;ll++)
        {

        f1=dif(h[ll],h[i])+M[ll];
        M[i]=min(mini,f1);
        mini=M[i];
        }
    }
    cout<<M[0]<<endl;
    return 0;
}



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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


struct cumsum1d{
    int n;
    vector<int> arr;

    cumsum1d(int len){
        n = len;
        rep(i,0,n) arr.push_back(0);
    }

    void init(vector<int> vec){
        arr = vec;
        n = arr.size();
    }

    void add(int a, int b, int val = 1){
        arr[a] += val;
        if(b + 1 < n) arr[b + 1] -= val;
    }

    void build(){
        rep(i,1,n) arr[i] += arr[i-1];
    }

    int query(int from, int to){
        int ret = arr[to];
        if(from) ret -= arr[from - 1];
        return ret;
    }

};
/* main */

string s;

signed main(){


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

    int n = input();

    vi a; rep(i,0,n) a.push_back(input());
    vi b; rep(i,0,n) b.push_back(input());


    int need = 0;
    int ans = 0;

    vi plus;

    rep(i,0,n){
        if(a[i] < b[i]){
            need += b[i] - a[i];
            ans++;
        }
        if(a[i] > b[i]) plus.push_back(a[i] - b[i]);
    }
    if(need == 0){
        print(0);
        return 0;
    }


    if(sum(plus) < need){
        print(-1);
        return 0;
    }

    sort(all(plus)); reverse(all(plus));

    cumsum1d cs = cumsum1d(1);
    cs.init(plus);
    cs.build();

    ans += lower_bound(all(cs.arr), need) - cs.arr.begin() + 1
    ;

    print(ans);


    


    


    

}



Measured memory_bytes: 3188
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int n, m;
	int[] mem;
	ArrayList<E>[] g;
	@SuppressWarnings("unchecked")
	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); m = sc.nextInt();
		mem = new int[n]; fill(mem, -1);
		g = new ArrayList[n];
		for(int i=0;i<n;i++) g[i] = new ArrayList<E>();
		for(int i=0;i<m;i++) {
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
			g[a].add(new E(b, c));
		}
		
		System.out.println(dfs(0));
	}
	
	int dfs(int p) {
		if( mem[p] >= 0 ) return mem[p];
		if( p == n-1 ) return mem[p] = 0;
		int max = 0;
		for(E e: g[p]) {
			max = max(max, dfs(e.to) + e.val);
		}
		return mem[p] = max;
	}
	
	class E{
		int to, val;
		E(int to, int val) {
			this.to = to;
			this.val = val;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 25156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;cin>>N>>L;
  int R=L+N-1;
  int eat=0;
  if(L<0&&R>0)eat=0;
  else if(R<0)eat=R;
  else if(L>0)eat=L;
  cout<< N*(L+L+N-1)/2-eat <<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
s = int(input())
L = set()
L.add(s)
n = 1
while True:
    n += 1
    if s % 2 == 0:
        s //= 2
        if s in L:
            print(n)
            sys.exit()
        L.add(s)
    else:
        s = 3 * s + 1
        if s in L:
            print(n)
            sys.exit()
        L.add(s)

Measured memory_bytes: 12500
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    long n, l, r;
    cin >> n;

    long ans = 0;
    for (long i = 0; i < n; i++) {
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;

    return 0;
}

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

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

    int N, D, X;
    cin >> N >> D >> X;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        int day = 1;
        while (day <= D) {
            X++;
            day += A;
        }
    }
    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	s := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		s[i] = s[i-1] + readInt64()
	}
	sum := func(i, j int) int64 {
		return s[j] - s[i]
	}
	var min int64
	min = int64(math.MaxInt64)
	for i := 1; i < n; i++ {
		min = minInt64(min, absInt64(sum(0, i)-sum(i, n)))
	}
	println(min)
}


Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS

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

#define LOOP(i,s,e) for(int i=s;i<e;i++)
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MAX3(a,b,c) (a>b)?MAX(a,c):MAX(b,c)
#define MIN3(a,b,c) (a>b)?MIN(b,c):MIN(a,c)

int intcmp(const int *a,const int *b) {return (*a - *b);}

int intrcmp(const int *a,const int *b) {return (*b - *a);}

int dblcmp(const double *a,const double *b) { return (*a < *b) ? -1 : (*a == *b) ? 0 : 1; }

int stcmp(const char *a[],const char *b[]) { return(strcmp(*a, *b)); }

int main() {
	/*char S[4]="";
	scanf("%s",&S);
	if(strcmp("SUN",&S)==0) printf("7\n");
	if(strcmp("MON",&S)==0) printf("6\n");
	if(strcmp("TUE",&S)==0) printf("5\n");
	if(strcmp("WED",&S)==0) printf("4\n");
	if(strcmp("THU",&S)==0) printf("3\n");
	if(strcmp("FRI",&S)==0) printf("2\n");
	if(strcmp("SAT",&S)==0) printf("1\n");*/
	int N=0;
	char S[10000]="";
	scanf("%d",&N);
	scanf("%s",&S);
	for(int i=0;S[i]!='\0';i++){
		if((S[i]+N)<=90){
			S[i]+=N;
		}else{
			S[i]=(S[i]+N)-26;
		}
	}
	printf("%s\n",&S);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<int> dp(100100, -1);
vector<int> G[100100];

int dfs(int v = 0) {
  if (dp[v] != -1) return dp[v];
  if (G[v].empty()) return dp[v] = 0;
  vector<int> vs;
  for (int u: G[v]) {
    vs.push_back(dfs(u));
  }
  sort(vs.begin(), vs.end(), greater<int>());
  int ans = 0;
  rep(i, vs.size()) chmax(ans, vs[i] + i + 1);
  return dp[v] = ans;
}

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

  int n;
  cin >> n;
  vector<int> a(n, 0);
  FOR(i, 1, n) {
    cin >> a[i];
    a[i]--;
  }

  FOR(i, 1, n) {
    G[a[i]].push_back(i);
  }
  cout << dfs() << '\n';






  
  return 0;
}

Measured memory_bytes: 15872
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//入力
ll llin() {ll x; cin >> x; return x;}
string stin() {string s; cin >> s; return s;}
vl vlin(ll n) {vl a(n); rep(i,n){cin >> a[i];} return a;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
    string s; cin >> s;

    rep(tmp, 1<<3){
        bitset<3> op(tmp);
        ll sum = s[0] - '0';
        string ans = "";
        ans += s[0];
        rep(i,3){
            if(op.test(i)) {
                sum += s[i + 1] - '0';
                ans += "+";
                ans += s[i + 1];
            }
            else {
                sum -= s[i + 1] - '0';
                ans += "-";
                ans += s[i + 1];
            }
        }
        if(sum == 7){
            ans += "=7";
            cout << ans << endl;
            return 0;
        }
    }
}



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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << "\n";
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
int main(void){
    int x,y;
    // Your code here!
    while(true)
    {
        std::cin >> x >> y;
        if(x==0&&y==0)break;
        if(x<y) std::cout << x << " " << y << std::endl;
        else if(y<x) std::cout << y << " " << x << std::endl;
        else std::cout << x << " " << y << std::endl;
    }
}


Measured memory_bytes: 3068
import sys
from math import*
for e in sys.stdin:
 a,b,c,d,x,y=map(float,e.split(','))
 g=2*atan2(d-b,c-a);s,t=sin(g),cos(g);x-=a;y-=b
 print(f'{t*x+s*y+a:.6f} {s*x-t*y+b:.6f}')


Measured memory_bytes: 5752
N, M = list(map(int, input().split()))
ab = {i:[] for i in range(N)}
for _ in range(M):
    a, b = list(map(int, input().split()))
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
    
cand = [[0]+[one] for one in ab[0]]
while len(cand)>0 and len(cand[0])<N:
    tmp_cand = []
    for c in cand:
        last = c[-1]
        n = []
        for nc in ab[last]:
            if nc not in c:
                n.append(c+[nc])
        tmp_cand.extend(n)
    cand = tmp_cand
print(len(cand))

Measured memory_bytes: 40816
N = int(input())
L = list(map(int, input().split())) 

L.sort()
res1 = L[-1]

tmp = res1 / 2

res2 = 10 ** 10
for i in range(N-1):
    if abs(tmp - L[i]) < abs(tmp - res2):
        res2 = L[i]

    
print(res1, res2)

Measured memory_bytes: 14428
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf (1<<30)

string S;
int chi[100002] = {};

int main() {
	cin >> S;
	int ecnt = 0, ocnt = 0, r = 0, l = S.size() - 1;
	for (int i = 0; i < S.size(); i++) {//>>>>>
		if (S[i] == 'R') {
			if((i - r) % 2)ocnt++;
			else ecnt++;
		}
		else {
			if ((i - r) % 2) {
				chi[i] += ocnt;
				chi[i - 1] += ecnt;
			}
			else {
				chi[i] += ecnt;
				chi[i - 1] += ocnt;
			}
			ocnt = ecnt = 0;
			r = i + 1;
		}
	}
	for (int i = S.size() - 1; i >= 0; i--) {//<<<<<
		if (S[i] == 'L') {
			if ((l - i) % 2) ocnt++;
			else ecnt++;
		}
		else {
			if ((l - i) % 2) {
				chi[i] += ocnt;
				chi[i + 1] += ecnt;
			}
			else {
				chi[i] += ecnt;
				chi[i + 1] += ocnt;
			}
			ocnt = ecnt = 0;
			l = i - 1;
		}
	}
	for (int i = 0; i < S.size(); i++) cout << (i ? " " : "") << chi[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 1024
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int X,t;
inline void solve(){
  IN2(X,t);
  OUT(max(X-t,0));
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
import numpy as np
N,M = map(int,input().split())
AC = np.zeros(N,np.int32)
WA = np.zeros(N,np.int32)
for j in range(M):
    p,S = input().split()
    i = int(p) - 1
    if AC[i] == 1:
        continue
    if S =='AC':
        AC[i] = 1
    else:
        WA[i] += 1
        
print(len(AC[AC == 1]),np.sum(WA[AC==1]))

Measured memory_bytes: 15272
import sys
S,T = input(),input()
N,M = len(S),len(T)

found = []
for i in range(N-M+1):
    for j in range(M):
        c1 = S[i+j]
        c2 = T[j]
        if c1 != '?' and c1 != c2: break
    else:
        found.append(i)

if len(found) == 0:
    print('UNRESTORABLE')
    sys.exit()

anss = []
for f in found:
    ans = []
    for i in range(N):
        if f <= i < f + M:
            ans.append(T[i - f])
        elif S[i] == '?':
            ans.append('a')
        else:
            ans.append(S[i])
    anss.append(''.join(ans))

print(min(anss))


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%d %d", $A, $B);
$P = explode(" ", trim(fgets(STDIN)));
$sum = array_pad([], 3, 0);
foreach ($P as $v) {
    if ($v <= $A) {
        $sum[0]++;
    } else if ($v > $B) {
        $sum[2]++;
    } else {
        $sum[1]++;
    }
}
echo min($sum);


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int gcd(int x, int y) {
    if(y==0) return x;
    else return gcd(y , x%y);
}




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

    int n;
    cin  >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans = 0;
    rep(i,n){
        ans += (a[i]-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256