akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    BinaryIndexedTree(int n){ // コンストラクタ
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k番目の要素にxを加算する
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // 区間[0,k]の総和を返す
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // 区間[a,b]の総和を返す
        return sum(b) - sum(a-1);
    }
};

int inversionNumber(const vector<int>& v)
{
    int n = v.size();
    vector<pair<int, int> > p(n);
    for(int i=0; i<n; ++i)
        p[i] = make_pair(v[i], i);
    sort(p.rbegin(), p.rend());

    BinaryIndexedTree bit(n);
    int ans = 0;
    for(int i=0; i<n; ++i){
        ans += bit.sum(p[i].second);
        bit.add(p[i].second, 1);
    }
    return ans;
}


double solve(vector<pair<double, double> > v)
{
    int n = v.size();
    int m = n * (n - 1) / 2;
    sort(v.rbegin(), v.rend());

    double left = -1.0e10;
    double right = 1.0e10;
    for(int t=0; t<200; ++t){
        double x = (left + right) / 2.0;
        vector<pair<double, int> > y(n);
        for(int i=0; i<n; ++i){
            y[i].first = v[i].first * x + v[i].second;
            y[i].second = i;
        }
        sort(y.begin(), y.end());

        vector<int> a(n);
        for(int i=0; i<n; ++i)
            a[i] = y[i].second;
        int b = inversionNumber(a);

        if(b < (m + 1) / 2)
            left = x;
        else
            right = x;
    }

    return left;
}

int main()
{
    int n;
    cin >> n;
    vector<double> a(n), b(n), c(n);
    for(int i=0; i<n; ++i)
        cin >> a[i] >> b[i] >> c[i];

    vector<pair<double, double> > v1(n), v2(n);
    for(int i=0; i<n; ++i){
        v1[i] = make_pair(-a[i] / b[i], c[i] / b[i]);
        v2[i] = make_pair(-b[i] / a[i], c[i] / a[i]);
    }
    printf("%.10f %.10f\n", solve(v1), solve(v2));

    return 0;
}


Measured memory_bytes: 4980
#include <string>
#include <iostream>

using namespace std;

int main() {
    string A, B, C;
    cin >> A >> B >> C;

    if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#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, m;
	cin >> n >> m;
	vector<int> a(n), b(n), c(n), d(m), e(m), f(m);
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	rep(i, m) cin >> d[i] >> e[i] >> f[i];
	
	vector<int> xs;
	xs.push_back(0);
	for(int x: a) xs.push_back(x);
	for(int x: b) xs.push_back(x);
	for(int x: d) xs.push_back(x);
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	map<int, int> xm;
	rep(i, xs.size()) xm[xs[i]] = i;

	vector<int> ys;
	ys.push_back(0);
	for(int y: c) ys.push_back(y);
	for(int y: e) ys.push_back(y);
	for(int y: f) ys.push_back(y);
	sort(ys.begin(), ys.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	map<int, int> ym;
	rep(i, ys.size()) ym[ys[i]] = i;

	vector<vector<bool>> visited(xs.size() * 2, vector<bool>(ys.size() * 2, false));
	vector<ll> xd(xs.size() * 2, 0);
	rep(i, xs.size() - 1) xd[i * 2 + 1] = xs[i + 1] - xs[i];
	vector<ll> yd(ys.size() * 2, 0);
	rep(i, ys.size() - 1) yd[i * 2 + 1] = ys[i + 1] - ys[i];

	rep(i, n) {
		int y = ym[c[i]] * 2;
		for(int x = xm[a[i]] * 2; x < xm[b[i]] * 2; x++)
			visited[x][y] = true;
	}
	rep(i, m) {
		int x = xm[d[i]] * 2;
		for(int y = ym[e[i]] * 2; y < ym[f[i]] * 2; y++)
			visited[x][y] = true;
	}
	queue<P> q;
	q.emplace(xm[0] * 2, ym[0] * 2);
	int dx[] = {1, 0, -1, 0};
	int dy[] = {0, 1, 0, -1};
	ll ans = 0;
	while(!q.empty()) {
		auto p = q.front(); q.pop();
		int x = p.first, y = p.second;
		if (x < 0 || x >= xs.size() * 2 || y < 0 || y >= ys.size() * 2) {
			cout << "INF" << endl;
			return 0;
		}
		if (visited[x][y]) continue;
		visited[x][y] = true;
		ans += xd[x] * yd[y];
		rep(i, 4) q.emplace(x + dx[i], y + dy[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 8524
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, p string
	fmt.Scan(&s)
	fmt.Scan(&p)
	s = strings.Repeat(s, 2)
	// fmt.Println(p)
	if strings.Index(s, p) == -1 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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

using LL = long long;

const int MOD = 1e9+7;
const int N = 2000005;

LL fac[N], inv[N], fnv[N], pre[N];

LL powmod (LL a, LL b, LL MOD) {
        LL ans = 1;
        while (b) {
                if (b % 2) ans = ans * a % MOD;
                b /= 2;
                a = a * a % MOD;
        }
        return ans % MOD;
}
LL comb (LL a, LL b) {
        if (a < b) return 0;
        if (a == b || b == 0) return 1;
        return fac[a] * fnv[b] % MOD * fnv[a-b] % MOD;
}
LL f (LL a, LL b) {
        return comb (a+b, a);
}
LL calc (LL m, LL n) {
        if (n < m) swap (n, m);
        LL ans = 0;
        for (int i = 0; i <= n; ++i) 
                ans = (ans + f(i+1,m)) % MOD;
        //printf ("g(%lld,%lld) = %lld\n",m,n,ans);
        return ans;
}
int main () {
        fac[0] = inv[0] = fnv[0] = 1;
        fac[1] = inv[1] = fnv[1] = 1;
        for (int i = 2; i < N; ++i)
                fac[i] = fac[i-1] * i % MOD, inv[i] = inv[MOD%i] * (MOD-MOD/i) % MOD, fnv[i] = fnv[i-1] * inv[i] % MOD;
        int xa, ya, xb, yb;
        cin >> xa >> ya >> xb >> yb;
        //cout << calc (xb,yb) << " " << calc (xa-1, yb) << " " << calc (xb,ya-1) << " " << calc (xa-1,ya-1) << endl;
        LL ans = calc (xb,yb)-calc(xa-1,yb)-calc(xb,ya-1)+calc(xa-1,ya-1);
        ans = (ans%MOD+MOD)%MOD;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 48384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y = 0;ll z, w, h, sum = 0, ans = 0;
int main(void) {
	cin >> x >> n; vector<int> a(110,0);
	rep(i, n) {
		cin >> m;
		a[m] = 1;
	}
	for (int i = x;; i++) {
		if (!a[i]) {
			y = abs(i - x);
			ans = i;
			break;
		}
	}
	for (int i = x; i >= 0; i--) {
		if (!a[i]) {
			if (abs(i - x) <= y) {
			ans = i;
			break; 
			}
		}
	}cout << ans << endl;
}

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

#define    ll     long long int

int main( )
{
    ll i, n, ans = 1, t;
    cin >> n;
    n--;
    cin >> ans;
    while (n--) {
        cin >> t;
        ll g = __gcd(ans, t);
        ans = (ans / g) * t;
    }
    cout << ans << '\n';
    return 0;
}



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

// # DEFINES # //
#define ll long long
#define M (ll)(1e9+7)
#define EPS 1e-9

using namespace std;

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


    ll k;

    cin >> k;

    int even = k/2;
    int odd = k - k/2;

    cout << even * odd << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int A,B;
  cin>>A>>B;
  int K = 50;
  vector<vector<int> > vv (K*2,vector<int>(K*2,0));
  for (int i = 0; i < K; i++)
  {
    for (int j = 0; j < 2*K; j++)
    {
      vv[i][j] = 1;
    }
  }
  int cntA = 0, cntB = 0;
  for (int i = 0; i < K; i++)
  {
    for (int j = 0; j < 2*K; j++)
    {
      if(i%2 == 0 && j%2 == 0 && cntA < A-1)
      {
        vv[i][j] ^=1;
        cntA++;
      } 
    }
  }
  
  for (int i = K; i < 2*K; i++)
  {
    for (int j = 0; j < 2*K; j++)
    {
      if(i%2 == 1 && j%2 == 0 && cntB < B-1)
      {
        vv[i][j] ^=1;
        cntB++;
      } 
    }
  }
  cout<<2*K <<" "<<2*K<<endl;
  for (int i = 0; i < 2*K; i++)
  {
    for (int j = 0; j < 2*K; j++)
    {
      if(vv[i][j] == 1)
      {
        cout<<"#";
      }
      else
      {
        cout<<".";
      }
      
    }
    cout<<endl;
    
  }
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> adj[100001];
bool visited[100001];
ll distanc[100001];
ll indegree[100001];
void dfs(ll i)
{
    visited[i]=true;
    for(auto j:adj[i])
    {
        indegree[j]--;
        distanc[j]=max(distanc[j],distanc[i]+1);
        if(indegree[j]==0)
        {
            dfs(j);
        }
    }
}
int main(){
    // Your code here!
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].push_back(b);
    }
    for(ll i=1;i<=n;i++)
    {
        visited[i]=false;
        distanc[i]=INT_MIN;
        indegree[i]=0;
    }
    for(ll i=1;i<=n;i++)
    {
        for(auto j:adj[i])
        {
            indegree[j]++;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        if(!visited[i]&&indegree[i]==0)
        {
            distanc[i]=0;
            dfs(i);
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans=max(ans,distanc[i]);
    }
    cout<<ans;
    return 0;
    
}


Measured memory_bytes: 10496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0305
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            int cnt = 0;
            while (cnt < n)
            {
                Console.WriteLine(WAr(GetPos(RArInt())));
                cnt++;
            }
        }

        private static IEnumerable<int> GetPos(int[] v)
        {
            const int R_SPAN = 100;
            const int T_SPAN = 30;

            int r = v[0], t = v[1];

            bool isOnArc = r % R_SPAN == 0;
            bool isOnLineSeg = t % T_SPAN == 0;

            int i = t / T_SPAN;
            int j = r / R_SPAN - 1;

            if (isOnArc && isOnLineSeg)
            {
                yield return GetNum(i, j);
            }
            else if (isOnArc)
            {
                yield return GetNum(i, j);
                yield return GetNum(i + 1, j);
            }
            else if (isOnLineSeg)
            {
                yield return GetNum(i, j);
                yield return GetNum(i, j + 1);
            }
            else
            {
                yield return GetNum(i, j);
                yield return GetNum(i, j + 1);
                yield return GetNum(i + 1, j);
                yield return GetNum(i + 1, j + 1);
            }
        }

        private static int GetNum(int i, int j)
        {
            return (5 * i + j) + 1;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

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

using namespace std;

vector<vector<int>> G;
vector<int> color;
bool ng;

pair<int,int> dfs(int u,int c){
	color[u]=c;

	pair<int,int> res;
	(c==0?res.first:res.second)++;
	for(int v:G[u]){
		if(color[v]==c){
			ng=true;
			return {0,0};
		}
		else if(color[v]==-1){
			auto tmp=dfs(v,1-c);
			res.first+=tmp.first;
			res.second+=tmp.second;
		}
	}
	return res;
}

int main(){
	int n,m; cin>>n>>m;
	static bool A[700][700];
	rep(i,m){
		int u,v; cin>>u>>v; u--; v--;
		A[u][v]=A[v][u]=true;
	}

	G.assign(n,vector<int>());
	rep(u,n) rep(v,n) if(u!=v && !A[u][v]) G[u].emplace_back(v);

	vector<pair<int,int>> P;
	color.assign(n,-1);
	rep(u,n) if(color[u]==-1) P.emplace_back(dfs(u,0));
	if(ng){ cout<<-1<<endl; return 0; }

	bool dp[701]={true};
	for(auto p:P){
		bool next[701]={};
		auto update=[&](int a){ for(int w=n;w>=a;w--) next[w]|=dp[w-a]; };
		update(p.first);
		update(p.second);
		rep(w,n+1) dp[w]=next[w];
	}

	int ans=n*n;
	rep(w,n+1) if(dp[w]) ans=min(ans,w*(w-1)/2+(n-w)*(n-w-1)/2);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<long long int> b;
	if (n % 2 == 0) {
		for (long long int i = n - 1; i > 0; i -= 2) {
			b.push_back(a[i]);
		}
		for (long long int i = 0; i < n; i += 2) {
			b.push_back(a[i]);
		}
	}
	else {
		for (long long int i = n - 1; i >= 0; i -= 2) {
			b.push_back(a[i]);
		}
		for (long long int i = 1; i < n; i += 2) {
			b.push_back(a[i]);
		}
	}
	cout << b[0];
	for (long long int i = 1; i < n; i++) {
		cout << ' ' << b[i];
	}
	cout << endl;
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int d, n; std::cin >> d >> n;
  if (d == 0 && n == 100) std::cout << 101 << "\n";
  else if (d == 1 && n == 100) std::cout << 10100 << "\n";
  else if (d == 2 && n == 100) std::cout << 1010'000 << "\n";
  else std::cout << (d == 0 ? 1 : pow(100, d)) * n << "\n";
}


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

int main(){
  int A[100][100],b[100],c[100];
  int i,j;
  int n,m;
  cin >> n >> m;

  for(i = 0;i < n;i++){
    for(j = 0;j < m;j++){

      cin >> A[i][j];
    }
  }

  for(i = 0;i < m;i++){

    cin >> b[i];
  }
  for(i = 0;i < n;i++){
    c[i] = 0;
    for(j = 0;j < m;j++){

      c[i] += A[i][j]*b[j];
    }
    cout << c[i] << "\n";
  }
}

Measured memory_bytes: 1200
import numpy as np

N = 10
H, W = input().split()
H = int(H)
W = int(W)
C = np.zeros((N, N), dtype=np.int)
for i in range(N):
    line = input().split()
    C[i, :] = list(map(int, line))

A = np.zeros((H, W), dtype=np.int)
for h in range(H):
    w = input().split()
    A[h, :] = list(map(int, w))

for k in range(N):
    for i in range(N):
        for j in range(N):
            C[i, j] = min(C[i, j], C[i, k] + C[k, j])

s = 0
for a in A.reshape(-1):
    if a >= 0:
        s += C[a, 1]
print(s)


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

int main(){
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=0;i<n;i++){
        int d;
        cin>>d;
        m[d]++;
    }
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        int t;
        cin>>t;
        if(m[t]>0) m[t]--;
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 12956
function Main(input) {
 var N = input.split("");
  var num = 0;
    if(N[0]==="R"){
     if(N[1]==="R"){
       if(N[2]==="R"){
         num = 3;
       }else{
         num = 2;
       }
     }else{
       num = 1;
     }
   }else{
     if(N[1]==="R"){
       if(N[2]==="R"){
         num = 2;
       }else{
         num = 1;
       }
     }else{
       if(N[2]==="R"){
         num = 1;
       }else{
         num = 0;
       }
     }
   }
  console.log(num);
} 

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

Measured memory_bytes: 29612
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char str[21];
    int i;
    gets(str);
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]==',')
        {
            str[i]=' ';
        }
    }
    puts(str);

    return 0;
}



Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
ans = 0
D = {}

for j in range(N):
  if j-A[j] in D:
    ans += D[j-A[j]]
  if j+A[j] in D:
    D[j+A[j]] += 1
  else:
    D[j+A[j]] = 1
    
print(ans)

Measured memory_bytes: 40504
(defn create-data [s]
  (map #(Long/parseLong %) (.split s " ")))

(defn sum [xs]
  (reduce + xs))

(defn zipWith [xs ys]
  (map vector xs ys))

(defn candies3 [n ys1 ys2]
  (apply max
         (map sum
              (zipWith
               (reductions + ys1)
               (reductions - (sum ys2) ys2)))))

(println (candies3 (Long/parseLong (read-line)) (create-data (read-line)) (create-data (read-line))))


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

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      char c;
      cin >> c;
      S.at(i).at(j) = c;
    }
  }

  int max = 0;

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      
      if(S.at(i).at(j)=='#') continue;
  

      vector<vector<int>> A(H, vector<int>(W,-1));
      A.at(i).at(j) = 0;

      queue<pair<int, int>> que;
      que.push(make_pair(i,j));

      

      while(que.size()){
        pair<int, int> tugi = que.front();
        que.pop();
        int thisx = tugi.first;
        int thisy = tugi.second; 
        if(thisx-1>=0){
          if(A.at(thisx-1).at(thisy) == -1 && S.at(thisx-1).at(thisy) != '#'){
            A.at(thisx-1).at(thisy) = A.at(thisx).at(thisy) + 1;
            if(max<=A.at(thisx).at(thisy) + 1) max = A.at(thisx).at(thisy) + 1;
            que.push(make_pair(thisx-1, thisy));
          }
        }
        if(thisx+1<S.size()){
          if(A.at(thisx+1).at(thisy) == -1 && S.at(thisx+1).at(thisy) != '#'){
            A.at(thisx+1).at(thisy) = A.at(thisx).at(thisy) + 1;
            if(max<=A.at(thisx).at(thisy) + 1) max = A.at(thisx).at(thisy) + 1;
            que.push(make_pair(thisx+1, thisy));
          }
        }
        if(thisy-1>=0){
          if(A.at(thisx).at(thisy-1) == -1 && S.at(thisx).at(thisy-1) != '#'){
            A.at(thisx).at(thisy-1) = A.at(thisx).at(thisy) + 1;
            if(max<=A.at(thisx).at(thisy) + 1) max = A.at(thisx).at(thisy) + 1;
            que.push(make_pair(thisx, thisy-1));
          }
        }
        if(thisy+1<S.at(0).size()){
          if(A.at(thisx).at(thisy+1) == -1 && S.at(thisx).at(thisy+1) != '#'){
            A.at(thisx).at(thisy+1) = A.at(thisx).at(thisy) + 1;
            if(max<=A.at(thisx).at(thisy) + 1) max = A.at(thisx).at(thisy) + 1;
            que.push(make_pair(thisx, thisy+1));
          }
        }
      }
    }
  }

  cout << max;

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;

int pw(int x){
	return x*x*x*x*x;
}

void solve(){
	int x;
	cin>>x;
	rep(i,0,124){
		rep(j,-124,124){
			if(pw(i)-pw(j) == x){
				cout<<i<<" "<<j;
				return;
			}
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)
#define N_MAX (100000+10)

using namespace std;

typedef long long int Int;

int N,K;
vector<int> G[N_MAX];
int GC[N_MAX];
Int inv[N_MAX];
Int fact[N_MAX];
Int invfact[N_MAX];
bool used[N_MAX];

Int dfs(int now, int from) {
    Int color;
    Int x = 1;
    if(now == 1) {
        color = K-1;
    } else {
        color = K-2;
    }

    if(G[now].size() > K)
        return 0;

    for(auto e: G[now]) {
        if(e == from)
            continue;
        x *=color;
        x %= MOD;
        color--;
    }

    for(auto e: G[now]) {
        if(e == from)
            continue;
        x *= dfs(e,now);
        x %= MOD;
    }

    return x;
}

Int solve(void) {
    Int ans = 0;
    ans =  K*dfs(1,-1);

    return ans % MOD;
}

int main(void) {
    cin>>N>>K;

    for(int i = 0;i < N-1;i++) {
        int a,b;
        cin>>a>>b;

        G[a].push_back(b);
        G[b].push_back(a);      
    }

    cout<<solve()<<endl;

    return 0;
}




Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

int main(){

    int n;
    cin >> n;

    int biggest = 0;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin >> a;
        chmax(biggest, a);
        mp[a]++;
    }

    bool answer = true;
    auto itr = mp.begin();
    int now = (*itr).first;
    if(biggest % 2 == 0){
        if((*itr).second != 1)answer = false;
        if(now * 2 != biggest)answer = false;
    } else {
        if((*itr).second != 2)answer = false;
        if(now * 2 - 1 != biggest)answer = false;
    }
    for(itr++; itr != mp.end(); itr++){
        if(now + 1 != (*itr).first)answer = false;
        now = (*itr).first;
    }
    
    cout << (answer ? "Possible\n" : "Impossible\n");
    return 0;

}

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

int main(void) {
    int N;
    cin >> N;
    int max = -1;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int n = i;
        int num = 0;
        for (;;) {
            if (n % 2 == 1) {
                break;
            }
            n /= 2;
            ++num;
        }
        if (num > max) {
            max = num;
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int h, w;
	cin >> h >> w;

	vector<string> s;
	for(int i=0; i<w+2; i++){
		printf("#");
	}
	puts("");
	for(int i=0; i<h; i++){
		string t;
		cin >> t;
		t = '#' + t + '#';
		cout << t << endl;
	}
	for(int i=0; i<w+2; i++){
		printf("#");
	}
	puts("");

	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200000,maxm=200000;

int n,m,a[maxn+5],b[maxm+5];

int main()
{
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	scanf("%d",&n);for (int i=1;i<=n;i++) scanf("%d",&a[i]);sort(a+1,a+1+n);
	scanf("%d",&m);for (int i=1;i<=m;i++) scanf("%d",&b[i]);sort(b+1,b+1+m);
	for (int j=1,i=1;j<=m;j++)
	{
		while (i<=n&&a[i]!=b[j]) i++;
		if (i>n) return printf("NO\n"),0;i++;
	}
	return printf("YES\n"),0;
}

Measured memory_bytes: 1664
package main

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

func main() {
	S := nextBytes()
	K := len(S)

	prev := string(S[0])
	i := 1

	for i < len(S) {
		n := 1
		curr := string(S[i : i+n])

		for prev == curr {
			n++
			curr = string(S[i : i+n])
		}
		// fmt.Println(i, n, prev, curr)
		i += n
		K -= (n - 1)
		prev = curr
	}

	fmt.Println(K)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>


int main() {
  int N, K;

  std::cin >> N;
  std::cin >> K;
  
  if ((N-1)%(K-1) == 0) {
    std::cout << (N-1)/(K-1);
  } else {
    std::cout << (N-1)/(K-1) + 1;
  }

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

N = int(input())
# S = input()
# N, M = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
A = [[i, int(input())] for i in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

A = sorted(A, key=lambda x : x[1], reverse=True)

for i in range(N) :
    for a in A :
        if a[0] != i :
            print(a[1])
            break


Measured memory_bytes: 85980
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string t = "";
    // string t2 = "";
    // S += '$';
    ll N = S.size();
    // print(N);
    ll ans = 0;
    string now = "";
    rep(i,0,N){
        string s = S.substr(i,1);
        now += s;
        // print(now);
        if(now == t){
            // now += s;
        }else{
            t = now;
            now = "";
            ans++;
            // print(i);
        }
        // print2(i,t);
    }
    // if(t.size() != 1) ans++;
    print(ans);

    
}

Measured memory_bytes: 720
// 26
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e) cerr << "\033[48;5;196m\033[38;5;15m" << e << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  rep(i, (int)v.size()) os << setw(7) << left << v[i];
  return os << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &os, const map<A, B> &m) {
  for (auto &kv : m) os << kv;
  return os;
}
// 3
const li inf = 1e18;
void _main(int tc) {
  int n;
  cin >> n;
  vector<li> v(n);
  rep(i, n) cin >> v[i];

  // /************* Recursive *************
  // vector<vector<li>> mem(n, vector<li>(n, -inf));
  // function<li(int, int)> f = [&](int l, int r) -> li {
  //   if (r == l) return mem[l][r] = v[l];
  //   if (mem[l][r] != -inf) return mem[l][r];
  //   return mem[l][r] = max(v[l] - f(l + 1, r), v[r] - f(l, r - 1));
  // };
  // cout << f(0, n - 1) << endl;
  // *********** End Recursive ***********/

  vector<vector<li>> mem(n, vector<li>(n));

  rrep(l, n) {
    mem[l][l] = v[l];
    forn(r, l + 1, n) {
      mem[l][r] = max(v[l] - mem[l + 1][r], v[r] - mem[l][r - 1]);
    }
  }
  cout << mem[0][n - 1] << endl;

#ifdef LOCAL
  debug(mem);
  int i = 0, l = 0, r = n - 1;
  while (i < n) {
    if (l == r) {
      debug(setw(15) << ((i % 2 == 0) ? left : right) << v[l] << endl);
    } else if (v[l] - mem[l + 1][r] > v[r] - mem[l][r - 1]) {
      debug(setw(15) << ((i % 2 == 0) ? left : right) << v[l] << endl);
      l++;
    } else {
      debug(setw(15) << ((i % 2 == 0) ? left : right) << v[r] << endl);
      r--;
    }
    i++;
  }
#endif
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 70784
#include<cstdio>

using namespace std;

int main(){
	int f = 0, s = 0;
	for(int i = 0; i < 3; i++){
		int a; scanf("%d", &a);
		if(a == 5) f++;
		if(a == 7) s++;
	}
	if(f == 2 && s == 1) puts("YES");
	else puts("NO");
	return 0;
}

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

int main(){
int p;
  cin >>p;
  if(p==111){
  cout <<3<<endl;
  }else if(p==110||p==101||p==11){
  cout <<2<<endl;
  }else if(p==100||p==1||p==10){
  cout <<1<<endl;
  }else{
  cout <<0<<endl;
  }
}

Measured memory_bytes: 3580
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n,a;
    cin>>n>>a;
    
    n=n%500;
    if(n==0||n<=a){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
    }
   


return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1], v[2])
}

fn main() {
    let mut n: Vec<i32> = read_vec();
    n.sort();
    let mut ans = 0;
    if n[0] % 2 != n[1] % 2 && n[0] % 2 != n[2] % 2 {
        n[0] -= 1;
        ans += 1;
    } else if n[1] % 2 != n[0] % 2 && n[1] % 2 != n[2] % 2 {
        n[1] -= 1;
        ans += 1;
    } else if n[2] % 2 != n[0] % 2 && n[2] % 2 != n[1] % 2 {
        n[2] -= 1;
        ans += 1;
    }
    ans += (n[2] * 2 - n[0] - n[1]) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int H, W, N, sy, sx;
	string T, A;
	cin >> H >> W >> N >> sy >> sx >> T >> A;
	--sy; --sx;
	bool win_aoki = true;
	//holizon
	int l = 0, r = W-1;
	for(int i = N-1; i >= 0; --i){
		if(A[i] == 'L'){
			r = min(W-1, r + 1);
		}else if(A[i] == 'R'){
			l = max(0, l - 1);
		}
		if(T[i] == 'L'){
			++l;
		}else if(T[i] == 'R'){
			--r;
		}
		if(l > r){
			win_aoki = false;
			break;
		}
	}
	if(!(l <= sx && sx <= r))win_aoki = false;
	l = 0; r = H - 1;
	//vertex
	for(int i = N-1; i >= 0; --i){
		if(A[i] == 'U'){
			r = min(H-1, r + 1);
		}else if(A[i] == 'D'){
			l = max(0, l - 1);
		}
		if(T[i] == 'U'){
			++l;
		}else if(T[i] == 'D'){
			--r;
		}
		if(l > r){
			win_aoki = false;
			break;
		}
	}
	if(!(l <= sy && sy <= r))win_aoki = false;
	cout << ((win_aoki) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

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

int N,Q;
int X[100010];

struct Event {
	int t;
	int type;
	int x;
	Event(int t, int type, int x) : t(t), type(type), x(x) {}
	bool operator<(Event &b) {
		if (t == b.t) {
			return type < b.type;
		}
		return t < b.t;
	}
};

signed main()
{
	scanf("%lld%lld", &N, &Q);

	vector<Event> events;

	rep(i, N) {
		int s, t, x;
		scanf("%lld%lld%lld", &s, &t, &x);
		events.push_back(Event(s - x, 1, x));
		events.push_back(Event(t - x, -1, x));
	}

	sort(begin(events), end(events));

	multiset<int> se;
	vector<int> ans(Q);

	int cur = 0;
	rep(i, Q) {
		int d;
		scanf("%lld", &d);
		while (cur < events.size() and events[cur].t <= d) {
			if (events[cur].type == 1) {
				se.insert(events[cur].x);
			} else {
				auto itr = se.find(events[cur].x);
				se.erase(itr);
			}
			cur++;
		}

		if (se.empty()) {
			ans[i] = -1;
		} else {
			ans[i] = *se.begin();
		}
	}

	rep(i, Q) {
		printf("%lld\n", ans[i]);
	}
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  int n; cin >> n;
  vector <int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,a.size()) {
    rep(k,a.size()) {
      cout << a[k];
      if (k != a.size()-1) cout << " ";
    }
    cout << endl;
    int v = a[i+1];
    int j = i;
    while(j>=0 && a[j]>v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    
  }
}



Measured memory_bytes: 3080
<?php

$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$m = (int)$input[1];

$v_list = [];
for ($i=1; $i <=$n ; $i++) { 
	$v_list[$i]['visited'] = false;
}

$e_list = [];
for ($i=0; $i < $m; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$e_list[] = [(int)$input[0],(int)$input[1]];
	$v_list[(int)$input[0]]['to'][] = (int)$input[1];
	$v_list[(int)$input[1]]['to'][] = (int)$input[0];
}

$cnt = 0;
foreach ($e_list as $e) {
	dfs(1, $e);
	$count_flg = false;
	foreach ($v_list as &$v) {
		if ($v['visited'] === false) {
			$count_flg = true;
		}
		$v['visited'] = false;
	}
	if ($count_flg) {
		++$cnt;
	}
}
echo $cnt;


function dfs($start, $cut_edge){
	global $v_list;
	$v_list[$start]['visited'] = true;
	$tos = $v_list[$start]['to'];
	foreach ($tos as $to) {
		if ($start == $cut_edge[0] && $to == $cut_edge[1] ||
			$to == $cut_edge[0] && $start == $cut_edge[1]
		) {
			continue;
		}
		if ($v_list[$to]['visited'] === false) {
			dfs($to, $cut_edge);
		}
	}
}

Measured memory_bytes: 4728
N,M=map(int,input().split())
a=list(map(int,input().split()))
lst=[]
for i in range(M):
  b=list(map(int,input().split()))
  if a[b[0]-1]>a[b[1]-1]:
    lst.append(b[1])
  elif a[b[0]-1]==a[b[1]-1]:
    lst.append(b[0])
    lst.append(b[1])
  else:
    lst.append(b[0])
print(N-len(set(lst)))

Measured memory_bytes: 20052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005],b[100005];
int main(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll num=0;
	for(int i=1;i<=n;i++){
		if(i%2==1) num+=a[i];
		else num-=a[i];
	}
	b[1]=num;
	for(int i=2;i<=n;i++){
		b[i]=2*(a[i-1]-b[i-1]/2);
	}
	for(int i=1;i<=n;i++){
		cout<<b[i]<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 2816
def solve():
    a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
    a = a.split(", ")
    k = int(input())

    print(a[k - 1])

if __name__ == "__main__":
    solve()

Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), M = in.nextInt(), R = in.nextInt();
        int[] r = new int[R];
        int[][] dist = new int[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(dist[i], Integer.MAX_VALUE/2);
        }
        for (int i = 0; i < R; i++) {
            r[i] = in.nextInt() - 1;
        }
        for (int i = 0; i < M; i++) {
            int a = in.nextInt() - 1, b = in.nextInt() - 1, c = in.nextInt();
            dist[a][b] = dist[b][a] = Math.min(dist[a][b], c);
        }
        in.close();
        for(int k = 0; k < N; k++){
            for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++){
                    dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        int min = Integer.MAX_VALUE;
        boolean[] visited = new boolean[R];
        for(int i = 0; i < R; i++){
            visited[i] = true;
            min = Math.min(min, dfs(0, i, visited, r, dist));
            visited[i] = false;
        }
        System.out.println(min);
    }
    public static int dfs(int cost, int pos, boolean[] visited, int[] r, int[][] dist){
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < visited.length; i++){
            if(i == pos) continue;
            if(!visited[i]){
                visited[i] = true;
                min = Math.min(min, dfs(cost + dist[r[pos]][r[i]], i, visited, r, dist));
                visited[i] = false;
            }
        }
        return min == Integer.MAX_VALUE ? cost : min;
    }
}

Measured memory_bytes: 48152
#include <iostream>
#include <queue>
using namespace std;
typedef struct Node{
    int a,b,c,s;
    Node(int aa,int bb,int cc,int nn): a(aa),b(bb),c(cc),s(nn){};
}Node;
queue<Node> vec;
bool G[500][500][500]={0};
int A,B,C;
int f[6][3]={2,0,0, 0,2,0, 0,0,2,
             1,1,0, 1,0,1, 0,1,1};

inline int Min(int i,int j,int k){
    return ((i<j)?(i<k?i:k):(j<k?j:k));
}
bool check(Node &t){
    if(t.a==t.b&&t.a==t.c&&t.b==t.c) return true;
    else return false;
}

int bfs(){
    int t=Min(A,B,C);
    vec.push(Node(A-t,B-t,C-t,0));
    while(!vec.empty()){
        Node &t=vec.front();
        if(check(t)) return t.s;
 //       cout<<t.a<<" "<<t.b<<" "<<t.c<<" "<<t.s<<endl;
        if(!G[t.a][t.b][t.c]){
            for(int i=0;i<6;i++){
                int m=Min(t.a,t.b,t.c);
                vec.push(Node( t.a+f[i][0]-m,t.b+f[i][1]-m,t.c+f[i][2]-m,t.s+1 ));
            }
            G[t.a][t.b][t.c]=true;
        }
        vec.pop();
    }
    return 0;
}


int main(){
    cin>>A>>B>>C;
    cout<<bfs()<<endl;
    return 0;
}


Measured memory_bytes: 23168
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	vector<int> ps;

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

	int ans = 0;

	for(int i = 1; i < n - 1; i++) {
		int a = ps[i - 1];
		int b = ps[i];
		int c = ps[i + 1];
		if((a < b && b < c) || (a > b && b > c)) {
			ans += 1;
		}
	}

	printf("%d\n", ans);

	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,k;cin >> n>>k;
    vector<lint> v(n);
    REP(i, n)
        cin >> v[i];
    sort(ALL(v));

    lint ans = 0;
    REP(i,k){
        ans += v[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	int a, b;
	cin>>a>>b;

	int ans = int(ceil(double(b - 1) / double(a - 1)));
	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

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

int main(){
  int n,k; cin >>n >>k;
  vector<int> a(n);
  vector<int> cnt(200005);
  rep(i,n) {
    cin >>a[i];
    cnt[a[i]]++;
  }
  sort(cnt.begin(), cnt.end());
  reverse(cnt.begin(), cnt.end());
  if(cnt[k]==0){
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for(int i = k;;i++){
    ans += cnt[i];
    if(cnt[i]==0){
      cout << ans << endl;
      return 0;
    }
  }
  return 0; 
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
void judge(int N,int A[]){
  int flag = 1;
  for(int i=0;i<N;i++){
    if((A[i]%2 == 0)&&(A[i]%3 != 0)&&(A[i]%5 != 0)){
      flag = 0;
    }
  }
  if(flag ==1){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }

}


int main(){
  int N;
  cin >> N;
  int A[N];
  for(int j=0;j<N;j++){
    cin >> A[j];
  }
  judge(N,A);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr int MOD = 1'000'000'007;

void dfs(VVI &dp, VVI &es, int par, int index) {
    if (es[index].size() == 1 && es[index][0] == par) return;
    for (auto &&dst: es[index]) {
        if (dst == par) continue;
        dfs(dp,es,index,dst);
        dp[index][1] = (1LL * dp[index][1] * (dp[dst][0] + dp[dst][1])) % MOD;
        dp[index][0] = (1LL * dp[index][0] *  dp[dst][1]) % MOD;
    }
}

void solve() {
    int n;
    cin >> n;
    int x,y;
    VVI es(n);
    REP(i,0,n-1) {
        cin >> x >> y;
        --x; --y;
        es[x].push_back(y);
        es[y].push_back(x);
    }
    VVI dp(n,VI(2,1));
    dfs(dp,es,-1,0);
    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}

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

Measured memory_bytes: 18176