akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

class UnionFind {
public:
  vector<int> par, rank;
  // if par is negative, it is a root, of which tree size is the abs-value.
  // rank represents depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) 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(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> c(n);
  rep(i,n) cin>>c[i];

  vector<pair<int,pair<int,int>>> v;
  rep(i,m){
    int s,t,u;
    cin>>s>>t>>u;
    s--;t--;
    v.pb(mp(u,mp(s,t)));
  }

  sort(all(v));
  if(k==1){
    cout << 0 << endl;
    return 0;
  }

  UnionFind uf(k+n);
  long ans = 0;
  int cnt = 0;
  for(auto &pp : v){
    int s = pp.se.fi, t = pp.se.se;
    int cs = c[s], ct = c[t];

    if(cs==0) cs = k+s;
    else cs--;

    if(ct==0) ct = k+t;
    else ct--;

    if(uf.same(cs,ct)) continue;
    uf.unite(cs,ct);

    ans += pp.fi;
    cnt++;

    if(cnt == k-1){
      cout << ans << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


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

bool comp(pair<int ,pair<string,int>> &a,pair<int ,pair<string,int>> &b)
{
  if(((a.second).first)==((b.second).first))
    return ((a.second).second)>((b.second).second);
  else 
    return ((a.second).first)<((b.second).first);
}
int main()
{
  int n;
  cin>>n;
  vector<pair<int ,pair<string,int>>> v;
  
  for(int i=0;i<n;i++)
  {
    string s;
    int a;
    cin>>s>>a;
    v.push_back(make_pair(i+1,make_pair(s,a)));
  }
  
  sort(v.begin(),v.end(),comp);
  
  for(int i=0;i<n;i++)
  {
    cout<<v[i].first<<endl;
    
  }
  
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

string quest(vector<int> vec){
    cout<<"? ";
    for(auto v:vec) cout<<v+1<<" ";
    cout<<endl;
    string res;
    cin>>res;
    return res;
}
string query(int x,int y,int a=0,int b=0,int plus=-1){
    vector<int> vec;
    for(int i=x;i<y;i++) vec.push_back(i);
    for(int i=a;i<b;i++) vec.push_back(i);
    if(plus!=-1) vec.push_back(plus);
    return quest(vec);
}

string query3(int x,int y,int plus,int minus){
    vector<int> vec;
    for(int i=x;i<y;i++) if(i!=minus) vec.push_back(i);
    vec.push_back(plus);
    return quest(vec);
}
int main(){
    int N;
    cin>>N;

    vector<string> ans(2*N);

    string prev=query(0,N);
    int lb=0;
    int ub=N;
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        if(query(0,N-mid,2*N-mid,2*N)==prev) lb=mid;
        else ub=mid;
    }
    int i=ub;
    
    int tar=-1;
    for(int j=N-i;j<2*N-i;j++){
        ans[j]=query(0,N-i,2*N-i+1,2*N,j);
        if(ans[j]==prev){
            tar=j;
        }
    }
            
    for(int j=0;j<N-i;j++){
        ans[j]=query3(N-i,2*N-i,j,tar);
    }
    for(int j=2*N-i;j<2*N;j++){
        ans[j]=query3(N-i,2*N-i,j,tar);
    }
    cout<<"! ";
    for(int i=0;i<2*N;i++){
        cout<<ans[i][0];
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
vector<pair<long long, long long> > vec;

int main(){
	cin >> N;
	rep(i, N) {
		long long a;
		cin >> a;
		vec.push_back(make_pair(a, i));
	}

	sort(vec.begin(), vec.end());


	rep(i, N) {
		cout << vec[i].second + 1;
		if(i != N-1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

Measured memory_bytes: 5260
#include <iostream>
#include <complex>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
vector<L> ls;
D eps=1e-10;
inline D cro(P a,P b){ return imag(conj(a)*b);}
inline int ccw(P a,P b,P c){
	if(cro(b-a,c-a)>eps) return 1;
	if(cro(b-a,c-a)<-eps) return -1;
	if(abs(abs(a-c)+abs(c-b)-abs(a-b))<eps) return 0;
	if(abs(abs(a-b)+abs(b-c)-abs(a-c))<eps) return -2;
	if(abs(abs(a-c)+abs(a-b)-abs(c-b))<eps) return 2;
}
inline bool iSS(L a,L b){
	return ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<0 && ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<0;
}
inline P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
int main(){
	while(true){
		int n,ans=1;
		cin >> n;
		if(n==0) break;
		ls.clear();
		rep(i,n){
			int sx,sy,tx,ty;
			cin >> sx >> sy >> tx >> ty;
			L l=L(P(sx,sy),P(tx,ty));
			vector<P> ps;
			rep(j,i){
				if(!iSS(l,ls[j])) continue;
				ps.pb(intLL(l,ls[j]));
			}
			bool id[100]={};
			rep(j,ps.size()){
				id[j]=true;
				rep(k,j) if(abs(ps[k]-ps[j])<eps) id[j]=false;
				if(id[j]) ans++;
			}
			ans++;
			ls.pb(l);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1228
s = input()

frommap = []
for d in range(10):
    frommap.append([0] * 13)
    for m in range(13):
        m2 = (m * 10 + d) % 13
        frommap[d][m2] = m
transmap = list(zip(*frommap))

dp = [1] + [0] * 12
for c in s:
    if c == '?':
        dp = [sum(dp[f] for f in fromlist) % 1000000007 for fromlist in transmap]
    else:
        dp = [dp[f] for f in frommap[int(c)]]

print(dp[5])

Measured memory_bytes: 44396
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    map<char,LL> m;
    rep(i,S.size()){
        m[S[i]]++;
    }

    if(m.size() == 1){
        int ct = 0;
        for(auto t : m){
            if(t.S == 1)ct = 1;
        }
        if(ct == 1)cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else if(m.size() == 2){
        LL ct = 0;
        for(auto t : m){
            ct += t.S;
        }
        if(ct == 2)cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else{
        LL mi = 10000000;
        bool ok = true;
        for(auto t : m){
            mi = min(mi,t.S);
        }
        for(auto t : m){
            if(t.S - mi > 1)ok = false;
        }

        if(ok)cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

using namespace std;
using ll = long long;

const int mx = 2e5 + 9;
const ll MOD = 998244353;

inline void normal(ll &a) { if (a >= MOD) a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) {normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) {normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) {normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } //if MOD is prime, modPow(b, p % (MOD-1))
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fact[mx];

ll C(ll n, ll r) {
    return modDiv(fact[n], modMul(fact[r], fact[n - r]));
}

int main() {
    fact[0] = 1;
    for (int i = 1; i < mx; i++) fact[i] = modMul(i, fact[i - 1]);
    ll ans = 0;
    ll N, M, K; scanf("%lld %lld %lld", &N, &M, &K);
    for (int k = 0; k <= K; k++) {
        ll temp = M;
        temp = modMul(temp, modPow(M - 1, N - k - 1));
        temp = modMul(temp, C(N - 1, k));
        ans = modAdd(ans, temp);
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 5240
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>

int main()
{
int n;
std::cin >> n;
for(int i = 0; i < 26; i++){
    for(int j = 0; j < 15; j++){
        if(4 * i + j * 7 == n){
            std::cout << "Yes";
            return 0;
        }
    }
}
std::cout << "No";

return 0;
}

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

// 
int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int num = 1;
    int skipCount = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == num) num++;
        else skipCount++;
    }
    if (num == 1) {
        cout << -1;
        return 0;
    }
    cout << skipCount;
}


Measured memory_bytes: 4372
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int u = 0;
  while (u < n && g[u].size() <= 2) ++u;
  if (u == n) {
    cout << 1;
  } else {
    vector<int> branches(n);
    int ans = 0;
    for (int i = 0; i < n; ++i)
      if (g[i].size() == 1) {
        u = i;
        int lst = -1;
        while (g[u].size() <= 2) {
          for (int v : g[u])
            if (v != lst) {
              lst = u;
              u = v;
              break;
            }
        }
        if (++branches[u] > 1)
          ++ans;
      }
    cout << ans;
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 6656
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    N = ii()
    ans = 0
    for a in range(1, N):
        if a*a + 1 <= N:
            ans += 1
        maxb = (N-1)//a
        if a < maxb:
            ans += (maxb - a)*2
    print(ans)










main()



Measured memory_bytes: 9992
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    cout<<(n+1)*n/2-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
char S[200002];
int dp[2][200002];
int main(){
  int i, res;
  N = rd(S);
  dp[0][1] = 1;
  dp[1][1] = -1073709056;
  for(i=(1);i<(N);i++){
    if(S[i]!=S[i-1]){
      dp[0][i+1] = dp[0][i] + 1;
    }
    chmax(dp[0][i+1], dp[1][i] + 1);
    chmax(dp[1][i+1], dp[0][i-1] + 1);
    chmax(dp[1][i+1], dp[1][i-1] + 1);
  }
  res =max_L(dp[0][N], dp[1][N]);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N;
// char S[200002];
// 
// int dp[2][200002];
// 
// {
//   int i, res;
//   rd(S@N);
// 
//   dp[0][1] = 1;
//   dp[1][1] = -int_inf;
//   rep(i,1,N){
//     if(S[i]!=S[i-1]) dp[0][i+1] = dp[0][i] + 1;
//     dp[0][i+1] >?= dp[1][i] + 1;
//     dp[1][i+1] >?= dp[0][i-1] + 1;
//     dp[1][i+1] >?= dp[1][i-1] + 1;
//   }
// 
//   res = max(dp[0][N], dp[1][N]);
//   wt(res);
// }


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x;
    if(n>=b-1) x = b-1;
    else x = n;
    ll ans = (a*x)/b - a*(x/b);
    cout << ans << endl;
}
    




Measured memory_bytes: 3596
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
       	int n=ni();
       	long h[]=new long[n+1],dp[]=new long[n+1];

       	for(int i=1;i<=n;i++) h[i]=nl();
       		
       	for(int i=2;i<=n;i++){
       		dp[i]=Math.min((i-2>=1)? dp[i-2]+Math.abs(h[i]-h[i-2]): Integer.MAX_VALUE,
       				 (i-1>=1)?Math.abs(h[i]-h[i-1])+dp[i-1]:Integer.MAX_VALUE);
       	} 

       	pn(dp[n]);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 33784
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;
Node *treeMinimum(Node *x) {
	while (x->left != NIL)x = x->left;
	return x;
}
Node *find(Node *u, int k) {
	while (u != NIL&&k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
Node *treeSuccessor(Node *x) {
	if (x->right != NIL)return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL&&x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}
void treeDelete(Node *z) {
	Node *y;
	Node *x;
	if (z->left == NIL || z->right == NIL)y = z;
	else y = treeSuccessor(z);
	if (y->left != NIL) {
		x = y->left;
	}
	else {
		x = y->right;
	}
	if (x != NIL) {
		x->parent = y->parent;
	}
	if (y->parent == NIL) {
		root = x;
	}
	else {
		if (y == y->parent->left) {
			y->parent->left = x;
		}
		else {
			y->parent->right = x;
		}
	}
	if (y != z)z->key = y->key;
	free(y);
}
void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else {
		if (z->key < y->key)y->left = z;
		else y->right = z;
	}
	return;
}
void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}
void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}

int main() {
	int n, i, x;
	string com;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL)puts("yes");
			else puts("no");
		}
		else if (com == "insert") {
			cin >> x;
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com == "delete") {
			cin >> x;
			treeDelete(find(root, x));
		}
	}
	return 0;
}

Measured memory_bytes: 21912
#!/usr/bin/env python3
_, *a = map(int, open(0).read().split())
a.sort()
m = 1
for i in a:
    if i > 10**18 and a[0]:
        exit(print(-1))
    m *= i
    if m > 10**18:
        exit(print(-1))
print(m)

Measured memory_bytes: 21792
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));

    lli sum = 0;
    for(int i=0; i<n-k; i++) sum += h[i];
    cout << sum << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    c = A + B
    d = N // c
    ans = d * A
    e = N % c
    if e >= A:
        ans += A
    else:
        ans += e
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61908
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val sp = (0 until n).map {
       Triple(it + 1, sc.next().toString(), sc.nextInt())
    }

    abc128b(sp)
}

fun abc128b(sp: List<Triple<Int, String, Int>>) {
    sp.sortedByDescending { it.third }.sortedBy { it.second }.map { it.first }.forEach { println(it) }
}


Measured memory_bytes: 34164
//============================================================================
// Name        : abc144_c_new.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 C - Walk on Multiplication Table

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 300 点

 問題文
 高橋君は無限に広い掛け算表の上にいます。
 掛け算表のマス (i, j) には整数 i × j が書かれており、高橋君は最初 (1, 1) にいます。
 高橋君は 1 回の移動で (i, j) から (i+1, j) か (i, j+1) のどちらかにのみ移ることができます。
 整数 N が与えられるので、N が書かれているマスに到達するまでに必要な移動回数の最小値を求めてください。

 制約

 ・2 <= N <= 10^{12}
 ・N は整数である。
 */

#pragma GCC optimize ("Ofast")
#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 ull = unsigned long long;

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

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll n;
	cin >> n;

	ll sqrtn = sqrt(n);
	ll score = (n - 1);
	for (ll i = sqrtn; i > 0; --i) {
		if (n % i == 0) {
			score = (i - 1) + (n / i - 1);
			break;
		}
	}

	cout << score << endl;
	return 0;
}


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

a = A - 1
b = B - 1
c = C - 1
d = D - 1
n = N - 1

is_able = False

while True:
  if a != c and (a+1) <= n and S[a+1] == "." and (a+1) != b:
    a += 1
  elif a != c and (a+2) <= n and S[a+2] == "." and (a+2) != b:
    a += 2
  elif b != d and (b+1) <= n and S[b+1] == "." and (b+1) != a:
    b += 1
  elif b != d and (b+2) <= n and S[b+2] == "." and (b+2) != a:
    b += 2
  else:
    is_able = False
    break
    
  if a == c and b == d:
    is_able = True
    break
    
if is_able:
  print("Yes")
else:
  print("No")


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vl a(x),b(y),c(z);

    VIN(a);
    VIN(b);
    VIN(c);
    
    vl ab;
    REP(i,x){
        REP(j,y){
            ab.emplace_back(a[i]+b[j]);
        }
    }

    //DEBUG_VEC(ab);
    sort(ALL(ab),greater<ll>());
    int xy = ab.size();
    if(xy > k)
        ab.erase(ab.begin()+k, ab.end());
    
    sort(ALL(c),greater<ll>());

    vl abc;
    REP(i,xy){
        REP(j,z){
            if( (i+1)*(j+1) <= k)
                abc.emplace_back(ab[i]+c[j]);
            else
                break;
        }
    }

    sort(ALL(abc),greater<ll>());

    REP(i,k)
        cout << abc[i] << endl;

    return 0;
}

Measured memory_bytes: 11616
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
if((a>=1&&a<=8)&&(b>=1&&b<=8)){
    cout << "Yay!"<<endl;
}
else{
    cout << ":("<<endl;
}
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A != B && (A+B)%2 == 0) {
			System.out.println((A+B)/2);
		}
		else {
			System.out.println("IMPOSSIBLE");
		}


	}

}

Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int x = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);

    int count = 0;
    long sum = 0;
    for (int i = 0; i < N - 1; i++) {
      sum += a[i];
      if (sum <= x) count++;
    }
    sum += a[N - 1];
    if (sum == x) count++;
    System.out.println(count);
  }
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<unsigned long, unsigned long>> LR(N);
    for(auto& i : LR){
        cin >> i.first >> i.second;
        i.second++;
    }
    nth_element(LR.rbegin(), LR.rend() - 1, LR.rend());
    nth_element(LR.begin() + 1, LR.begin() + 2, LR.end(), [](auto i, auto j){return i.second == j.second ? i.first < j.first : i.second < j.second;});
    if(LR[0].second <= LR[1].second){
        sort(LR.begin() + 1, LR.end(), [](auto i, auto j){return i.first + i.second < j.first + j.second;});
        cout << LR[0].second - LR[0].first + LR.back().second - LR.back().first << endl;
        return 0;
    }

    unsigned long ans{0};
    for(unsigned long i = 2; i < N; ++i){
        ans = max(ans, LR[i].second - LR[i].first);
    }
    ans += LR[1].second - min(LR[0].first, LR[1].second);

    sort(LR.begin() + 2, LR.end(), [](auto i, auto j){return i.second == j.second ? i.first < j.first : i.second > j.second;});
    auto L1 = LR[1].first, R1 = LR[1].second, L2 = LR[0].first, R2 = LR[0].second;
    reverse(LR.begin(), LR.end());
    LR.pop_back();LR.pop_back();

    unsigned long mx{L1};
    for(unsigned long i = 0; i + 2 < N; ++i){
        ans = max(ans, R1 - min(R1, mx) + LR[i].second - min(LR[i].second, L2));
        mx = max(mx, LR[i].first);
    }
    cout << max(ans, R1 - min(R1, mx) + R2 - L2) << endl;

    return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n, k;
  cin >> n >> k;
  int ret = n - k;
  if (k == 1) ret = 0;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,j,n,no,trump[4][14];
  char shurui;

  for(i=0;i<4;i++)
    for(j=1;j<=13;j++)trump[i][j]=j;

  scanf("%d",&n);

//  for(i=1;i<=n;i++) scanf("%d %d",&no,&no);
  for(i=1;i<=n;i++){
    scanf(" %c %d",&shurui,&no);
// printf("p=%d %c %d\n",i,shurui,no);
    if(shurui=='S')trump[0][no]=0;
    else if(shurui=='H')trump[1][no]=0;
    else if(shurui=='C')trump[2][no]=0;
    else if(shurui=='D')trump[3][no]=0;
  }

  for(i=1;i<=13;i++)if(trump[0][i]!=0)printf("S %d\n",trump[0][i]);
  for(i=1;i<=13;i++)if(trump[1][i]!=0)printf("H %d\n",trump[1][i]);
  for(i=1;i<=13;i++)if(trump[2][i]!=0)printf("C %d\n",trump[2][i]);
  for(i=1;i<=13;i++)if(trump[3][i]!=0)printf("D %d\n",trump[3][i]);

  return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
const ll M = 1000000007;
int n;
pii A[200002];
int main()
{
	cin>>n;
	loop(i,0,n)cin>>A[i].fi>>A[i].se;
	long int a=INT_MIN,b=INT_MIN,c=INT_MAX,d=INT_MAX;
	loop(i,0,n)
	{
		long int sum=A[i].fi+A[i].se;
		long int sub=A[i].fi-A[i].se;
		a=max(sum,a);
		b=max(sub,b);
		c=min(c,sum);
		d=min(d,sub);
	}
	cout<< max(a-c,b-d);
}

Measured memory_bytes: 5176
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn check(v: usize, c: bool, edges: &[Vec<usize>], col: &mut [bool],
         vis: &mut [bool], conn: &mut Vec<usize>) -> bool {
    if vis[v] {
        return c == col[v];
    }
    vis[v] = true;
    col[v] = c;
    conn.push(v);
    let mut bip = true;
    for &w in edges[v].iter() {
        bip &= check(w, !c, edges, col, vis, conn);
    }
    bip
}


fn bipartite(edges: &[Vec<usize>]) -> (usize, usize, usize) {
    let n = edges.len();
    let mut col = vec![false; n];
    let mut vis = vec![false; n];
    let mut bip = 0;
    let mut odd = 0;
    let mut single = 0;
    for i in 0 .. n {
        if vis[i] { continue; }
        let mut conn = Vec::new();
        let is_b = check(i, false, edges, &mut col, &mut vis, &mut conn);
        if !is_b || conn.len() == 1 {
            if conn.len() == 1 {
                single += 1;
            } else {
                odd += 1;
            }
        } else {
            bip += 1;
        }
    }
    (bip, odd, single)
}

fn solve() {
    let n = get();
    let m = get();
    let mut edges = vec![Vec::new(); n];
    for _ in 0 .. m {
        let u = get::<usize>() - 1;
        let v = get::<usize>() - 1;
        edges[u].push(v);
        edges[v].push(u);
    }
    let (bip, odd, single) = bipartite(&edges);
    let bip = bip as i64;
    let odd = odd as i64;
    let single = single as i64;
    let n = n as i64;
    println!("{}", 2 * bip * (bip + odd) + odd * odd
             + n * n - (n - single) * (n - single));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 24956
#include "bits/stdc++.h"
#include <random>
#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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  bool ok = true;
  REP(i, s.size()) {
    if (i & 1) {
      if (s[i] != 'i')ok = false;
    }
    else {
      if (s[i] != 'h')ok = false;
    }
  }
  if (s.size() % 2 == 1)ok = false;
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];


void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}


ll nCr(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll nHr(ll n, ll r) { if (n == 0 && r == 0) return 1; else return nCr(n + r - 1, r); }
ll nPr(ll n, ll r) { if (r < 0 || n < r) return 0; else return (fac[n] * finv[n-r]) % MOD; }


int main(){
    COMinit();
    ll s; cin >> s;
    if(s < 3){
        cout << 0 << endl;
        return 0;
    }
    ll ma = s/3, ans = 0;
    Rep(i, 1, ma+1){
        ADD(ans, nHr(i, s-3*i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 15580
<?php

function checkSimilar($words)
{
    $a = str_split($words);
    if($a[2] === $a[3] && $a[4] === $a[5]) {
        return 'Yes';
    } else {
        return 'No';
    }
}

$stdin = (string)trim(fgets(STDIN));
echo checkSimilar($stdin);

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <stack>
#define int long long
using namespace std;
stack<int> stk;
signed main(){
    string word;
    while(cin >> word){
        if(word == "*"){
            int a = stk.top(); stk.pop();
            int b = stk.top(); stk.pop();
            stk.push(a*b);
        }else if(word == "+"){
            int a = stk.top(); stk.pop();
            int b = stk.top(); stk.pop();
            stk.push(a+b);
        }else if(word == "-"){
            int a = stk.top(); stk.pop();
            int b = stk.top(); stk.pop();
            stk.push(b-a);
        }else{
            stk.push(stoi(word));
        }
    }
    cout << stk.top() << endl;
}


Measured memory_bytes: 3156
function Main(input) {
    const lines = input.split("\n");
    const ps = lines[1].split(' ').map(v => +v);
    let count = 0;
  	let min = ps[0];
  
    for (let i = 0; i < ps.length; i++) {
      if (ps[i] <= min) {
        count++;
        min = ps[i];
      }
    }
    
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M;
  cin >> N >> M;
  VI ws(N);
  REP(i,N) cin >> ws[i];
  vector<set<int>> G(N);
  VI in(N);
  REP(i,M){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].insert(v);
	G[v].insert(u);
	in[u]++;
	in[v]++;
  }

  VI dp(N);
  vector<bool> vis(N);
  queue<int> q;
  REP(i,N) if(i && in[i] == 1) q.push(i);
  while(!q.empty()){
	int crt = q.front();
	int to = *begin(G[crt]);
	q.pop();
	G[to].erase(crt);
	maxi(dp[to], dp[crt] + ws[crt]);
	vis[crt] = true;
	if(to != 0 && SZ(G[to]) == 1)
	  q.push(to);
  }

  int mx = 0;
  int ans = 0;
  REP(i,N) if(!vis[i]){
	ans += ws[i];
	maxi(mx, dp[i]);
  }
  cout << ans + mx << endl;

  return 0;
}

Measured memory_bytes: 18604
# 初期入力
K =int(input())

# 最大公約数(mathは3.5以降) 
from functools import reduce
import math #(2020-0405  fractions→math)
def lcm_base(x, y):
    return  math.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm_list(numbers):
    return reduce(lcm_base, numbers)
def lcm_fukusu(*numbers):
    return reduce(lcm_base, numbers)


saisyou_koyakusu =[]

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i ==j and j==k:
                saisyou_koyakusu.append(lcm_fukusu(i,j,k))
            elif i==j or j==k:
                saisyou_koyakusu.append( (lcm_fukusu(i,j,k))*3 )
            else:
                saisyou_koyakusu.append( (lcm_fukusu(i,j,k)) *6)

            #print(i,j,k)   
print(sum(saisyou_koyakusu))

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

using namespace std;

int main()
{
	int n, k; cin >> n >> k;
	
	int h[n];
	
	for (int i = 0; i < n; ++i) cin >> h[i];
	
	int dp[n];
	
	dp[0] = 0;
	
	for (int i = 1; i < n; ++i)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		
		for (int j = i - 2; j >= 0 && (abs(i - j) <= k); --j)
		{
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	
	cout << dp[n - 1] << endl;
	
	return 0;
}

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

string n;

int main(){

    cin>>n;

    if(n[0]==n[1]&&n[1]==n[2]||n[1]==n[2]&&n[2]==n[3]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair

int main() {
    int a;
    string x;
    cin>>a>>x;
    if(a<3200)
        cout<<"red";
    else
        cout<<x;
    return 0;
}
// ABAB
//

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define sort(v)	sort(v.begin(),v.end());
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
/*
vector<bool> is_prime(10000005,true);
void sieve()
{
	long long int i,j;
	is_prime[0]=false;
	is_prime[1]=false;
	for(i=2;i<=10000004;i++){
		if(is_prime[i]){
			for(j=i*i;j<=10000004;j+=i){
				is_prime[j]=false;
			}
		}
	}
}
*/





int main()
{
	char ch,ch1,ch2;
	string s1,s2,s3;
    lli i,j,k,a,b,c,n,m,sum=0,ans=0,temp;
    cin >> n >> m;
    if(m==n)	cout << "Yes" << endl;
    else cout << "No" << endl;
	
	
    
    
    return 0;
}





















/* UJJWAL KESHRI */

Measured memory_bytes: 256
N = int(input())

L = [i for i in range(10**5+1)]

for i in range(len(L)):
    for j in range(1,7):
        try: L[i + 6**j] = min(L[i + 6**j],L[i]+1)
        except: pass
    for j in range(1,6):
        try: L[i + 9**j] = min(L[i + 9**j],L[i]+1)
        except: pass
    try: L[i+1] = min(L[i+1],L[i]+1)
    except: pass
print(L[N])

Measured memory_bytes: 7064
//https://atcoder.jp/contests/abc124/tasks/abc124_a
#include <iostream>
using namespace std;

int main() {
    int A,B;

    cin >> A >> B;

    int Max;
    if(A>=B+1){
        Max=2*A-1;
    }else if(B>=A+1){
        Max=2*B-1;
    }else{
        Max=A*2;
    }

    cout<<Max<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s,t;
  cin >> s>>t;
  reverse(ALL(t));

  puts(s==t ? "YES" : "NO");

  return 0;
}



Measured memory_bytes: 256
import math
a,b = [float(i) for i in input().split()]
ans = 1000000000
flag = False

for i in range(1,1005):
    ans8 = int(math.floor(i*0.08))
    ans10 = int(math.floor(i*0.1))
#     print(ans8,ans10)
    if ans8 == a and ans10 == b:
        ans = min(ans, i) # 更新する必要がある．
        flag = True

if flag is True:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9068