akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cassert>
#include<iomanip>

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

double cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

double dist(const Point &p1, const Point &p2)
{
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

int main()
{
    int i, n;
    double *X, *Y;
    scanf("%d", &n);
    assert(n >= 3);

    X = new double [n + 1];
    Y = new double [n + 1];
    for(i = 0; i < n; i++){
        scanf("%lf %lf", &X[i], &Y[i]);
    }
    X[n] = X[0], Y[n] = Y[0];
    Point *Plg;
    Plg = new Point [n + 1];
    for(i = 0; i < n; i++){
        Plg[i] = set_p(X[i], Y[i]);
    }
    Plg[n] = Plg[0];

    int top = 0;
    double diam = 0;

    for(i = 0; i < n; i++){
        while(cross(set_v(Plg[i], Plg[i + 1]), set_v(Plg[top], Plg[top + 1])) >= 0){
            top++; if(top > n - 1) top -= n;
        };
		// printf("%d\n", top);
        diam = max(diam, max(dist(Plg[i], Plg[top]), dist(Plg[i + 1], Plg[top])));
    }
    // cout << fixed << setprecision(14) << diam << endl;
    printf("%.12f\n", diam);
	// cin >> n;

    return 0;
}

Measured memory_bytes: 3760
l=input().split()
n=int(l[0])
k=int(l[1])
l=input().split()
li=[int(i) for i in l]
dp=[0 for i in range(n)]
dp[0]=0
for i in range(1,n):
	lfi=[]
	for j in range(max(0,i-k),i):
		lfi.append(dp[j]+abs(li[j]-li[i]))
	dp[i]=min(lfi)
print(dp[-1])


Measured memory_bytes: 56544
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 100005;
const int logN = 18;
struct edge{
	int color, adj, weight;
	edge(){color = adj = weight = 0;}
	edge( int _adj, int _color,int _weight){
		color = _color;
		adj = _adj;
		weight = _weight;
	}
};
int par[N][logN], level[N];
int sumColor[N], numColor[N];
int ans[N];
pr remark[N];
vector< edge > G[N];
vector< pr > query[N];
int n,q, totalSum = 0;

int lca(int u,int v){
	if (level[u] < level[v]) swap(u,v);
	for(int i=logN-1;i>=0;--i) if (level[u] - (1 << i) >= level[v]) u = par[u][i];
	if (u == v) return u;
	for(int i=logN-1;i>=0;--i) if (par[u][i] != -1 && par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
	return par[u][0];
}
void prep(int u,int preU){
	par[u][0] = preU;
	if (preU != -1) level[u] = level[preU] + 1;
	for (auto node : G[u]){ 
		if (node.adj == preU) continue;
		prep(node.adj, u);
	}
}
void solve(int u){
	for(auto cur : query[u]){
		int id = cur.first, w = cur.second;
		ans[id] += w * (totalSum - sumColor[remark[id].first] + numColor[remark[id].first] * remark[id].second);
	}
	for(auto node : G[u]){
		if (node.adj == par[u][0]) continue;
		sumColor[node.color]+= node.weight;
		numColor[node.color]++;
		totalSum += node.weight;
		solve(node.adj);
		sumColor[node.color]-= node.weight;
		numColor[node.color]--;
		totalSum -= node.weight;

	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> q;
	for (int i=1;i<n;++i){
		int u,v,c,d; cin >> u >> v >> c >> d;
		G[u].push_back(edge(v, c, d));
		G[v].push_back(edge(u, c, d));
	}
	// LCA prep
	memset(par, -1, sizeof(par));
	prep(1, -1);
	for(int j=1;j<logN;++j){
		for(int i=1;i<=n;++i){
			if (par[i][j-1] != -1)	par[i][j] = par[par[i][j-1]][j-1];
		}
	}

	for(int i=1;i<=q;++i){
		int u,v, c, d; cin >> c >> d >> u >> v;
		remark[i] = {c, d};
		query[u].push_back({i, 1});
		query[v].push_back({i, 1});
		query[lca(u,v)].push_back({i, -2});
		// cout << u << ' ' << v << ' ' << lca(u, v) << '\n';
	}
	solve(1);
	for(int i=1;i<=q;++i) cout << ans[i] << '\n';
}

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

using namespace std;

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


#define se second
#define fi first
#define pb push_back
#define mp make_pair
 
int main() {
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin>>N>>A>>B;
    int arr[100100];
    for(int i = 0; i < N; i++) {
    	cin>>arr[i];
    }
    ll ans = 0;
    for(int i = 1; i < N; i++) {
    	if((arr[i]-arr[i-1]) * A < B) {
    		ans += (arr[i]-arr[i-1]) * A;
    	} else {
    		ans +=B;
    	}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    abc000X()
}

fun abc000X() {
    val s = readLine()!!
    val t = readLine()!!
    val hm = HashMap<Char, Char>()
    for (i in s.indices) {
        if (hm.containsKey(s[i])){
            if (hm[s[i]] != t[i]){
                println("No")
                return
            }
        }
        else{
            hm[s[i]] = t[i]
        }
    }
    hm.clear()
    for(i in s.indices){
        if (hm.containsKey(t[i])){
            if (hm[t[i]] != s[i]){
                println("No")
                return
            }
        }
        else{
            hm[t[i]] = s[i]
        }
    }
    println("Yes")
}


Measured memory_bytes: 36956
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
def resolve():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    ans = 'NO'

    if V > W:
        if A > B:
            t = (B-A)/(W-V)
        else:
            t = (B - A) / (V - W)

        if t <= T:
            ans = 'YES'

    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9220
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int q; cin >> q;
    ll cnt[2] = {};
    while (q--) {
        ll p, n;
        char c;
        cin >> p >> c >> n;
        cnt[c-'('] += n;
        if (cnt[0] == cnt[1]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3116
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 524288
#define P 200003

constexpr ulli PRIME = 0xffffffffff000001;
constexpr ulli ntt_add(ulli a, ulli b)
{
    ulli res = 0;
    if(__builtin_uaddll_overflow(a,b,&res))
        res -= PRIME;
    return res;
}
constexpr ulli ntt_sub(ulli a, ulli b)
{
    ulli res = 0;
    if(__builtin_usubll_overflow(a,b,&res))
        res += PRIME;
    return res;
}
constexpr ulli ntt_mul(ulli a, ulli b)
{
    constexpr ulli magic = -PRIME;
    unsigned __int128 k = (unsigned __int128)a*b;
    k = (k>>64<<24) + (ulli)k - (k>>64);
    ulli res = 0;
    if(__builtin_uaddll_overflow((k>>64)*magic,(ulli)k,&res))
        res += magic;
    return res;
}
constexpr ulli ntt_pow(ulli a, ulli b)
{
    ulli r = 1;
    while(b)
    {
        if(b&1) r = ntt_mul(r,a);
        a = ntt_mul(a,a);
        b >>= 1;
    }
    return r;
}
constexpr ulli ntt_find()
{
    ulli res = 2;
    while(ntt_pow(res,PRIME/2) != PRIME-1) ++res;
    return res;
}
constexpr ulli OMEGA = (ntt_pow(ntt_find(),PRIME/N));
static_assert(__builtin_popcount(N) == 1);
static_assert(PRIME%N == 1);
static_assert(ntt_pow(OMEGA,N/2) == PRIME-1);
uint ricr(uint k)
{
    k ^= (N-1);
    k ^= -1u >> 1 >> __builtin_clz(k);
    return k;
}
void ntt(ulli *a, ulli ow=OMEGA)
{
    for(int i=0,ii=0;i<N;++i,ii=ricr(ii))
        if(i<ii) std::swap(a[i],a[ii]);
    for(int n2=1,n=2;n2<N;n2=n,n*=2)
    {
        ulli w = ntt_pow(ow,N/n);
        for(ulli *p=a; p!=a+N; p+=n)
        {
            ulli k = 1;
            for(int i=0,j=n2;i<n2;++i,++j)
            {
                ulli e = p[i], o = p[j];
                ulli ok = ntt_mul(o,k);
                p[i] = ntt_add(e,ok);
                p[j] = ntt_sub(e,ok);
                k = ntt_mul(k,w);
            }
        }
    }
}
void ntt_inv(ulli *a)
{
    ntt(a,ntt_pow(OMEGA,PRIME-2));
    for(int i=0;i<N;++i) a[i] = ntt_mul(a[i],ntt_pow(N,PRIME-2));
}

int cnt[N];
ulli a[N];

int main()
{
    int n;
    lli ans = 0;
    scanf("%d", &n);
    for(int i=0;i<n;++i)
    {
        int k;
        scanf("%d", &k);
        ++cnt[k];
    }
    for(int i=0, k=1; i<P-1; ++i, k=k*2<P?k*2:k*2-P) a[i] = cnt[k];
    for(int i=0; i<P-1; ++i) cnt[i] = a[i];
    ntt(a);
    for(int i=0;i<N;++i) a[i] = ntt_mul(a[i],a[i]);
    ntt_inv(a);
    for(int i=0; i<P-1; ++i) a[i*2] -= cnt[i];
    for(int i=0,k=1; i<N; ++i, k=k*2<P?k*2:k*2-P)
    {
        if(a[i] >= PRIME) a[i] -= PRIME;
        ans += k * a[i];
    }
    assert(ans%2==0);
    ans /= 2;
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int a,b;cin>>a>>b;
    
    if(a<=2*b)cout<<0<<endl;
    else cout<<a-2*b<<endl;

    return 0;
}

Measured memory_bytes: 256
'use strict';

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var minvs = input.trim().split('\n');
var minv;
while (minv = minvs.shift()) {
	var t = minv / 9.8;
	var y = 4.9 * t * t;
	var f = Math.ceil((y + 5)/5);
	console.log(f);
}

Measured memory_bytes: 15516
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = []
for i in range(N):
    L.append(S[i]-1)

from collections import Counter
M = Counter(L)
out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += M[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Measured memory_bytes: 155288
#include <stdio.h>
double r;
double a1,b1;

double pai=3.141592653589;

main(){
  scanf("%lf",&r);
  a1=2*r*pai;
  b1=(r*r*pai);
  
  
   
  printf("%f %f\n",b1,a1);
  return 0;
}

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

int main() {
	int total_shot;
	while(cin>>total_shot,total_shot){
		int total_hit,n;
		int max = total_shot/4;
		for(int i = 0; i < max ; i++){
			cin >> n;
			total_hit += n;
		}
		cout << total_hit << endl;
		total_hit = 0;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const int mod=1000000007;
    int n,k;
    cin >> n >> k;
    vector<int> now(k+1,0);
    now[0]=1;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin >> a;
        vector<int> sum(k+1,0);
        sum[0]=now[0];
        for(int j=1;j<=k;j++) sum[j]=(sum[j-1]+now[j])%mod;
        auto s=[&](int l,int r)->int
        {
            l=max(l,0);
            int res=sum[r];
            if(l>0) res=(res-sum[l-1]+mod)%mod;
            return res;
        };
        for(int j=0;j<=k;j++) now[j]=s(j-a,j);
    }
    cout << now[k] << "\n";
    return 0;
}


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

using namespace std;

using int64 = long long;

template <typename T>
class SegmentTree {
 private:
  function<T(T, T)> merge;
  T empty_value;
  vector<T> nodes;
  int num_nodes;

  // Returns the fold of overwrap between [node_l, node_r) and [l, r).
  // nodes[node_index] needs to correspond to [node_l, node_r).
  T getRangeInternal(int node_index, int node_l, int node_r, int l, int r) {
    if (node_r <= l || r <= node_l) return empty_value;
    if (l <= node_l && node_r <= r) return nodes[node_index];
    int node_m = (node_l + node_r) / 2;
    return merge(
        getRangeInternal(2 * node_index, node_l, node_m, l, r),
        getRangeInternal(2 * node_index + 1, node_m, node_r, l, r));
  }

 public:
  SegmentTree(
      function<T(T, T)> in_merge, T in_empty_value, const vector<T>& xs) :
          merge(in_merge), empty_value(in_empty_value) {
    int n = xs.size();
    num_nodes = 1;
    while (num_nodes < n) num_nodes *= 2;
    num_nodes *= 2;
    nodes = vector<T>(num_nodes, empty_value);
    for (int i = 0; i < xs.size(); ++i) {
      nodes[num_nodes / 2 + i] = xs[i];
    }
    for (int i = num_nodes / 2 - 1; i >= 1; i--) {
      nodes[i] = merge(nodes[2 * i], nodes[2 * i + 1]);
    }
  }

  // Updates the i-th element to x.
  void update(int i, T x) {
    nodes[num_nodes / 2 + i] = x;
    for (int cur = (num_nodes / 2 + i) / 2; cur > 0; cur /= 2) {
      nodes[cur] = merge(nodes[2 * cur], nodes[2 * cur + 1]);
    }
  }

  // Returns the fold of the range [l, r) by the merge function.
  T getRange(int l, int r) {
    return getRangeInternal(1, 0, num_nodes / 2, l, r);
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<int> xs(n, INT_MAX);

  auto min_function =
      function<int(int, int)>([] (int x, int y) { return min(x, y); });
  SegmentTree<int> tree(min_function, INT_MAX, xs);
  for (int i = 0; i < q; i++) {
    int c, v1, v2;
    cin >> c >> v1 >> v2;
    if (c == 0) {
      tree.update(v1, v2);
    } else {
      cout << tree.getRange(v1, v2 + 1) << endl;
    }
  }
}



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

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

	vector<int> a(n);
	vector<int> count(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i]%2==0){
			count[i] = 2;
		}else{
			count[i] = 1;
		}
	}
	
	long long int t=1;
	long long int p=1;

	for(int i=0; i<n; i++){
		t *= count[i];
		p *= 3;
	}

	

	cout << p-t << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> b(n, false);
    rep(i, n) cin >> a[i], --a[i];

    int p = 0;
    b[0] = true;
    int ans = 0;
    while (1)
    {
        ++ans;
        p = a[p];
        if (p == 1)
        {
            cout << ans << endl;
            return 0;
        }
        if (b[p])
        {
            cout << -1 << endl;
            return 0;
        }
        b[p] = true;
    }
}

Measured memory_bytes: 3788
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
A = [0 for i in range(26)]
ans = 0
for i in range(D):
  K = []
  for k in range(26):
    c = 0
    for j in range(26):
      if j != k:
        c += C[j] * (i+1-A[j])
    an = S[i][k]-c
    K.append([an, k+1])
  K.sort()
  a = K[-1][1]
  print(a)
  A[a-1] = i+1
  ans += K[-1][0]
  

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define int long long

using namespace std;

int cnt[100][2];
int n=0;
int a[300001];
__int128_t sum=0;

signed main()
{
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> a[i];		
		int aa = a[i];
		for (int j=0; j<62; j++)
		{
			cnt[j][aa%2]++;
			aa/=2;
		}	
	}
	for (int i=0; i<n; i++)
	{
		__int128_t x = 1;
		for (int j=0; j<62; j++)
		{
			sum+=x*(cnt[j][1-(a[i]%2)]);
			a[i]/=2;
			x*=2;
		}
	}
	cout << (int) ((sum/2)%1000000007);
	return 0;
}


Measured memory_bytes: 2560
# coding: utf-8
# Your code here!
N, M = map(int, input().split())
HList = list(map(int, input().split()))
AList = [list(map(int, input().split())) for i in range(M)]

anslist = [0] * N
#print(AList[0])
i=0    
while i<M:
    checkA = AList[i][0]
    checkB = AList[i][1]
    #print(HList[checkA-1])
    if HList[checkA-1] < HList[checkB-1]:
        anslist[checkA-1]="x"
    elif HList[checkA-1] > HList[checkB-1]:
        anslist[checkB-1]="x"
    else:
        anslist[checkA-1]="x"
        anslist[checkB-1]="x"
        
    i+=1
print(anslist.count(0))

Measured memory_bytes: 31868
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<vector<int>> d(N,vector<int>(60));
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < 60;j++) {
            if(vec.at(i) & (1ll << j)) {
                d.at(i).at(j) = 1;
            }
            else {
                d.at(i).at(j) = 0;
            }
        }
    }
    vector<int> cnt(60);
    for(int i = 0;i < 60;i++) {
        int zero = 0;
        int one = 0;
        for(int j = 0;j < N;j++) {
            if(d.at(j).at(i) == 0) {
                zero++;
            }
            else {
                one++;
            }
        }
        cnt.at(i) = zero * one % MOD;
    }
    int ret = 0;
    for(int i = 0;i < 60;i++) {
        int a = (1ll << i) % MOD;
        a *= cnt.at(i);
        ret += a;
        ret = ret % MOD;
    }
    cout << ret << endl;
}


Measured memory_bytes: 154880
#include<bits/stdc++.h>
using namespace std;
vector<int> ord;
int main(){
    int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        int ci,ti;
        cin>>ci>>ti;
        if(ti<=t)
            ord.push_back(ci);
    }
    sort(ord.begin(),ord.end());
    if(ord.size()==0)
        cout<<"TLE"<<endl;
    else
        cout<<ord[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
from math import floor,ceil
import fractions
import collections
import itertools
from collections import deque
A,B,N=map(int,input().split())

piv=B/A  #基本数

#for i in range(0,30):
#    print(A,i,B,floor(A*i/B)-A*floor(i/B))

#A<=Bなら
#0,0,.. 1,1,.. ... (A-1),(A-1),...が
#先頭から(B%A)の数字まではceil(piv)こ、あとはfloor(piv)こ
#→これより、この答えはmod(B)の空間で単調増加とわかる
#よって、f(min(B-1,N))が答え

#A>Bでも同じくmod(B)にて単調増加なのを調べてたはずなので

#いずれにせよf(min(B-1,N))が答え
cnt=0
#print(ceil(piv)*(B%A))
"""
if A<=B:
    if N>=B-1:
        print(A-1)
    else:
        if ceil(piv)*(B%A)>N:
            print(floor(N/ceil(piv)))
        else:
            N=N-ceil(piv)*(B%A)
            #print(N,N//floor(piv))
            cnt=(B%A)
            print(cnt+N//floor(piv))
else:  #A>B
    l=[0]
    for i in range(1,B):
        l.append(max(l[i-1],floor(A*i/B)-A*floor(i/B)))
    #print(l)
    if N>=len(l):
        print(l[len(l)-1])
    else:
        print(l[N])
"""
def f(A,B,N):
    return floor(A*N/B)-A*floor(N/B)
print(f(A,B,min(B-1,N)))



Measured memory_bytes: 72728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 100000000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

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

int V,E;
ll d[MAX][MAX];

bool floyd(){
    for(int k=0;k<V;k++){
        for(int i=0;i<V;i++){
            if(d[i][k]==inf) continue;
            for(int j=0;j<V;j++){
                if(d[k][j]==inf) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    for(int i=0;i<V;i++){
        if(d[i][i]<0) return true;;
    }
    return false;
}


int main() {
   int s,t,c;
   cin>>V>>E;
   for(int i=0;i<V;i++){
       for(int j=0;j<V;j++){
           d[i][j]=((i==j) ? 0 : inf);
       }
   }
   for(int i=0;i<E;i++){
       cin>>s>>t>>c;
       d[s][t]=c;
   }
   
   if(floyd()){
       cout<<"NEGATIVE CYCLE"<<endl;
       return 0;
   }

   for(int i=0;i<V;i++){
       for(int j=0;j<V;j++){
           if(j) cout<<" ";
           if(d[i][j]==inf){
               cout<<"INF";
            }else{
                cout<<d[i][j];
            }
        }
        cout<<endl;
   }
    return 0;
}






Measured memory_bytes: 3160
from typing import List


def answer(h: int, w: int, c: List[str]) -> str:
    result = []
    for i in c:
        for _ in range(2):
            result.append(i)

    return '\n'.join(result)


def main():
    h, w = map(int, input().split())
    c = [input() for _ in range(h)]
    print(answer(h, w, c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10244
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  string s;
  int q;
  cin >> s >> q;

  string pre,post;
  bool order = true;
  rep(i,q){
    int t;
    cin >> t;
    if (t==1){
      order = !order;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (order) {
          pre.insert(pre.end(),c);
        } else {
          post.insert(post.end(),c);
        }
      }else{
        if (order) {
          post.insert(post.end(),c);
        } else {
          pre.insert(pre.end(),c);
        }
      }
    }
  }
  string ans;
  if (order) {
    reverse(pre.begin(),pre.end());
    ans = pre + s + post;
  } else {
    reverse(post.begin(),post.end());
    reverse(s.begin(),s.end());
    ans = post + s + pre;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1320
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
S = LIST()
S.insert(0, 0)

ans = 0
for i in range(1, max(S)+1):
	for j in range(1, len(S)):
		if S[j-1] < i and i <= S[j]:
			ans += 1

print(ans)


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

using namespace std;

int main() {
  int N, K, d = 0, c = 0; cin >> N >> K;
  vector<int> a(N, 0);
  for(int i = 0; i < K; i++) {
    cin >> d;
    for(int j = 0; j < d; j++) {
      int input; cin >> input;
      a[input - 1]++;
    }
  }
  for(int i = 0; i < a.size(); i++) if(a[i] == 0) c++;
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

//#include <bits/stdc++.h>
using namespace std;


int main() {

	int a;
    cin >> a;
	int num = 0;
	string str;
	vector<string> b(a);
	vector<int> c(a);
	for (int i = 0; i < a; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	string t = "testtesttest";
	int max_num = 1;
	string test = b[0];
	vector<string> d{};


	num = 1;
	for (int i = 0; i < a; i++) {
		if (b[i] == t) {
			num += 1;
		}
		else {
			num = 1;
		}

		t = b[i];
		if (num > max_num) {
			max_num=num;
			d = { b[i] };
		}
		else if (num == max_num) {
			d.insert(d.end(), b[i]);
		}
	}

	for (int i = 0; i < d.size(); i++) {
		cout << d[i] << endl;
	}

	return 0;

}

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

int main() {
  int a, b, c; cin >>a >>b >>c;
  bool ans = false;
  // A*x = B*y + C
  for (int i=1; i<b+1; i++){
    if (a*i%b == c){
      ans = true;
      break;
    }
  }
  if (ans){
    cout <<"YES";
  }else{
    cout <<"NO";
  }
  cout <<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int s = sc.nextInt();
		if (s == 2 || s == 1) {
			System.out.println(4);
			return;
		}
		for (int i = 1;;i++) {
			if (s == 4) {
				System.out.println(i+3);
				return;
			} else if (s % 2 == 0) {
				s /= 2;
			} else {
				s = s * 3 + 1;
			}
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 20564
#include <stdio.h>

#define MAX 25

typedef struct{
  int l,r,par;
} node;

node N[MAX];

void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int n,i,id,l,r;
  int p;
  
  scanf("%d" ,&n); 
  init(n);  

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);

    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
      p = i;
      break;
    }
  }
 
  puts("Preorder");
  Preorder(p);
  puts("");

  puts("Inorder");
  Inorder(p);
  puts("");

  puts("Postorder");
  Postorder(p);
  puts("");

  return 0;
}

void init(int n){
  int i;

  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}

void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}

void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}

void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(std::string s, std::string t){

    vector<lli> pos[26];
    REP(i,0,s.size()){
        pos[s[i]-'a'].push_back(i);
    }

    lli now=0;
    REP(i,0,t.size()){
        LOG3(i,t[i],now);
        lli al = t[i]-'a';
        if(pos[al].size()==0){
            cout<<-1<<endl;
            return;
        }
        auto itr = lower_bound(pos[al].begin(),pos[al].end(),now%s.size());
        if(itr == pos[al].end()){
            now = (now/s.size() + 1)*s.size();
            itr = lower_bound(pos[al].begin(),pos[al].end(),now%s.size());
        }
        now = now/s.size()*s.size() + (*itr) + 1;
    }

    cout<<now<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    func(s, t);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   pii;
typedef vector<int>     vi;
typedef long double     ld;
#define MOD         1000000007
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        '\n'
#define PI          3.14159265359d
#define sz(x)       (int)x.size()
map<int,int> mp;
int main()
{
    //std::ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,i,x,maxi=1;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
        mp[x-1]++;
        mp[x+1]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
        maxi=max(maxi,it->S);
    cout<<maxi;
    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  if(h%3==0 || w%3==0){
    printf("0\n");
    return;
  }
  int min=MIN(h,w);
  int i;
  for(i=1;i<=w-1;i++){
    int64 a=(int64)i*h;
    int64 b=(int64)(w-i)*(h/2);
    int64 c=(int64)(w-i)*(h-h/2);
    min=MIN(min,MAX(a,MAX(b,c))-MIN(a,MIN(b,c)));
  }
  int swap=h;
  h=w;w=swap;
  for(i=1;i<=w-1;i++){
    int64 a=(int64)i*h;
    int64 b=(int64)(w-i)*(h/2);
    int64 c=(int64)(w-i)*(h-h/2);
    min=MIN(min,MAX(a,MAX(b,c))-MIN(a,MIN(b,c)));
  }
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}

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

typedef long long int ll;

#define endl '\n'
ll n;
vector <ll> vec[100005];
ll mod = 1e9+7;
map <ll,ll> mp;
ll dp[100005][2];

ll solve(ll u,ll color, ll par)
{
    if(vec[u].size()==0){
        return 1;
    }
    if(vec[u].size()==1 and u!=1){
        return 1;
    }
    //cout<<u<<endl;
    ll val = 1;
    if(dp[u][color]==-1){
    for(ll i=0;i<vec[u].size();++i){
        ll v = vec[u][i];
        if(v!=par){
            if(color==0){
               val = (mod+(val*(solve(v,0,u)+solve(v,1,u))%mod)%mod)%mod;
            }
            else{
                val = (mod+(val*solve(v,0,u))%mod)%mod;
            }
        }
    }
    dp[u][color] = val;
    }
    return dp[u][color];


}

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(ll i=0;i<n-1;i++){
        ll x,y;
        cin>>x>>y;
        vec[x].push_back(y);
        vec[y].push_back(x);
    }

    cout<<(mod+solve(1,0,-1)+solve(1,1,-1))%mod<<endl;

}


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

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> a(n);
  int sum = 0;
  for(int &x : a) scanf("%d", &x), sum += x;
  
  int ans = 0;
  for(int x : a) {
    if(x * 4 * m >= sum)
      ans++;
  }

  printf("%s\n", ans >= m ? "Yes" : "No");
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val A = map(N)(_ => sc.nextInt())
    val ans = (A.groupBy(identity) mapValues (_.length) map { case (num, cnt) =>
      if (cnt >= num) cnt - num
      else cnt
    }).sum

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) {
      f(i)
      i += 1
    }
  }

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    var i = 0
    while(i < n) {
      res(i) = f(i)
      i += 1
    }
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }
  }
}


Measured memory_bytes: 85820
import java.io.IOException;
import java.util.Scanner;

// どうやって空白で区切られた入力値を二つのデータとして認識する？
// Scannerというものを使う
public class Main {
	public static void main(String[] args) throws IOException{

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();

		System.out.println(a*b+ " "+(a*2+b*2));

	}
}



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

int main(){
  string s; cin >> s;
  int blue=0,red=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0') red++;
    else blue++;
  }
  cout << 2*min(red,blue) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#define mod 1000000007
using namespace std; 

int main(){
    long long n,a,b;
	cin >> n >> a >> b;
	if (n<=a+b){
		if (n<=a) cout << n << "\n";
		else cout << a << "\n";
	}
	else{
		if (n%(a+b)==0){
			cout << a*(n/(a+b)) << "\n";
		}
		else{
			long long ans=a*(n/(a+b));
			if (n%(a+b)<=a) cout << ans+n%(a+b) << "\n";
			else cout << ans+a << "\n";
		}
	}
}


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

int main() {
    int N, C;
    cin >> N >> C;
    using P = pair<int, int>;
    using PI = pair<int, P>;
    priority_queue<PI, vector<PI>, greater<PI>> pq;
    rep(i, 0, N) {
        int s, t, c;
        cin >> s >> t >> c;
        pq.push({s, {0, c}});
        pq.push({t, {1, c}});
    }
    int ans = 0, cnt = 0;
    vector<int> used(C + 1);
    while(!pq.empty()) {
        P t = pq.top().second; pq.pop();
        int type = t.first;
        int ch = t.second;
        if(type == 0) {
            if(used[ch] == 0) cnt++;
            used[ch]++;
        } else {
            used[ch]--;
            if(used[ch] == 0) cnt--;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4724
#include<stdio.h>
void main()
{
  int a,b,s,k;
  scanf("%d %d",&a,&b);
  s=a+b;
  k=s/2;
  if((a%2==1&&b%2==1)||(a%2==0&&b%2==0))
   printf("%d",k);
   else
   printf("IMPOSSIBLE");
}


Measured memory_bytes: 1692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> dp(n+1);
  dp[0] = 1;
  dp[1] = 1;
  rep(i,n-1) {
    dp[i+2] = dp[i+1] + dp[i];
  }
  cout << dp[n] << endl;
}



Measured memory_bytes: 3096
#include<iostream>
#include<math.h>

using namespace std;

int main() {
  int e, x, y, z, y_max, z_max, ans;
  while(true) {
    cin >> e;
    if(e == 0) break;
    ans = e;
    z_max = (int) (pow(e, 1.0/3.0)+1);
    for(z = 0; z <= z_max; z++) {
      y_max = (int) (sqrt(e-z*z*z)+1);
      for(y = 0; y <= y_max; y++) {
	x = e - y*y - z*z*z;
	if(ans > x+y+z && x >= 0) ans = x+y+z;
      }
      if(z == z_max) cout << ans << endl;
    }
  }

  return 0;
}

  

Measured memory_bytes: 3320
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n >= (p ** e) and n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n >= p and n % p == 0:
      n //= p
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)

Measured memory_bytes: 9196
n = int(input())
l = [int(x) for x in input().split()]
k = [0]*n
for i in range(n):
  k[l[i] - 1] = k[l[i] - 1] + 1
def motomeru(i):
  return int((k[i-1])*(k[i-1]-1)/2)
def herasu(i):
  if k[i-1] == 0 or k[i-1] == 1:
    return 0
  else:
    return int((k[i-1]-1)*(k[i-1]-2)/2)
zenbu = 0
for i in range(n):
  zenbu = zenbu + motomeru(i+1)
for i in range(n):
  a = zenbu - motomeru(l[i]) + herasu(l[i])
  print(a)

Measured memory_bytes: 26140
# -*- coding: utf-8 -*-

# 3つの数字をリストから数値の変数に
input_list = input().split()
start_num = int(input_list[0])
end_num = int(input_list[1])
range_num = int(input_list[2])

result_list = []
for i in range(start_num, end_num + 1):
	# 前半の条件に当てはまるものを抽出
	if i < start_num + range_num:
		result_list.append(i)
	else:
		break

for i in range(end_num, start_num -1, -1):
	# 後半の条件に当てはまるものを抽出
	if i > end_num - range_num:
		result_list.append(i)
	else:
		break

# 重複削除
result_list = list(set(result_list))
# 昇順ソート
result_list.sort()

for num in result_list:
	print(num)


Measured memory_bytes: 3064
def func(i,x,op):
    #ベースケース
    if i == 4:
        if x == 7: return op
        else: return ""

    #足す場合
    opP = func(i+1, x + int(S[i]),op+"+")
    if opP != "": return opP

    #引く場合
    opM = func(i+1, x - int(S[i]),op+"-")
    if opM != "": return opM

    return ""

S = input()
#S[0]は必ず+扱いなのでi = 1, x = int(S[0])からスタートする
op = func(1,int(S[0]),"")
if len(op) == 3:
    print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+"=7")

Measured memory_bytes: 3064
($n,$a,$b,$c,$d)=split/ /,<>;
$s=<>;
if(substr($s,$a,($d-2)-($a-1))=~/##/){ #a~(d-2)
    $r='No';
}elsif($c<$d||substr($s,$b-2,$d-($b-3))=~/\.{3}/){ #b-2~d
    $r='Yes';
}else {
    $r='No';
}
print "$r\n";


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        p[i].first = x + l;
        p[i].second = x - l;
    }
    sort(p.begin(), p.end());
    int right = -1e9 - 10000;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (p[i].second >= right) {
            right = p[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A>B && B!=1) cout << "Alice" << endl;
  if (B>A && A!=1) cout << "Bob" << endl;
  if (A==B) cout << "Draw" << endl;
  else if (A==1) cout << "Alice" << endl;
  else if (B==1) cout << "Bob" << endl;
}

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

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

int dp[9][(1<<8)]={};
vector<int> v;
int n,m,s;
int d[201][201];
int r[201]={};


//int calc(int s1,int d1){
//	if(dp[s1][d1]>0)return dp[s1][d1];
//	if(d1==(1<<s1))return 0;
//	int d2=d1-(1<<s1);
//	dp[s1][d1]=200000001;
//	for(int i=0;i<s;++i){
//		int k=(1<<i);
//		if((d2&k)==k)dp[s1][d1]=min(dp[s1][d1],d[r[s1]][r[i]]+calc(i,d2));
//	}
//	return dp[s1][d1];
//}
int main() {
	string s;
	cin>>s;
	int ls=s.length();
	for(int i=0;i<ls;i+=2){
		cout<<s[i];
	}
	cout<<endl;
//
//	for(int i=0;i<201;++i){
//		for(int j=0;j<201;++j){
//			d[i][j]=200000001;
//		}
//	}
//	cin>>n>>m>>s;
//	bool flg=true;
//	int a,b,c;
//	int ct=0;;
//	for(int i=0;i<s;++i){
//		cin>>r[i];
//		ct+=(1<<i);
//	}
//	for(int i=0;i<m;++i){
//		cin>>a>>b>>c;
//		d[a][b]=c;
//		d[b][a]=c;
//	}
//	while(flg){
//		flg=false;
//		for(int i=1;i<n+1;++i){
//			for(int j=1;j<n+1;++j){
//				for(int k=1;k<n+1;++k){
//					if(d[i][j]>(d[i][k]+d[k][j])){
//						flg=true;
//						d[i][j]=d[i][k]+d[k][j];
//					}
//				}
//			}
//		}
//	}
//
//	int t=200000001;
//
//	for(int i=0;i<s;++i){
//		t=min(t,calc(i,ct));
//	}

//	cout<<max(x-t,0)<<endl;

	return 0;
}


Measured memory_bytes: 512
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())

    i = int(n ** 0.5)

    while i >= 1:
        if n % i == 0:
            j = n // i
            print(i + n // i - 2)
            exit()
        i -= 1


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000

int main(){
  ll K;
  cin>>K;
  ll left=0,right=100000000000000;
  while(left+1<right){
    ll x=(left+right)/2;
    ll y=x;
    ll n=0;
    vector<ll> a;
    while(y>0){
      a.push_back(y%10);
      n++;
      y/=10;
    }
    reverse(a.begin(),a.end());
    vector<vector<vector<ll>>> dp(n,vector<vector<ll>>(2,vector<ll>(10,0)));
    dp.at(0).at(0).at(a.at(0))=1;
    for(int i=1;i<a.at(0);i++){
      dp.at(0).at(1).at(i)=1;
    }
    for(int i=1;i<n;i++){
      dp.at(i).at(1).at(0)+=dp.at(i-1).at(1).at(0)+dp.at(i-1).at(1).at(1);
      dp.at(i).at(1).at(9)+=dp.at(i-1).at(1).at(8)+dp.at(i-1).at(1).at(9)+1;
      for(int j=1;j<9;j++){
        dp.at(i).at(1).at(j)+=dp.at(i-1).at(1).at(j-1)+dp.at(i-1).at(1).at(j)+dp.at(i-1).at(1).at(j+1)+1;
      }
      for(int j=1;j<a.at(i);j++){
        dp.at(i).at(1).at(j)+=dp.at(i-1).at(0).at(j-1)+dp.at(i-1).at(0).at(j)+dp.at(i-1).at(0).at(j+1);
      }
      if(a.at(i)==0){
        dp.at(i).at(0).at(0)+=dp.at(i-1).at(0).at(0)+dp.at(i-1).at(0).at(1);
      }else if(a.at(i)==9){
        dp.at(i).at(1).at(0)+=dp.at(i-1).at(0).at(0)+dp.at(i-1).at(0).at(1);
        dp.at(i).at(0).at(9)+=dp.at(i-1).at(0).at(8)+dp.at(i-1).at(0).at(9);
      }else{
        dp.at(i).at(1).at(0)+=dp.at(i-1).at(0).at(0)+dp.at(i-1).at(0).at(1);
        dp.at(i).at(0).at(a.at(i))+=dp.at(i-1).at(0).at(a.at(i)-1)+dp.at(i-1).at(0).at(a.at(i))+dp.at(i-1).at(0).at(a.at(i)+1);
      }
    }
    ll count=0;
    for(int i=0;i<10;i++){
      count+=dp.at(n-1).at(0).at(i)+dp.at(n-1).at(1).at(i);
    }
    if(count<K){
      left=x;
    }else{
      right=x;
    }
  }
  cout<<right<<endl;
}


Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#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>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
int main()
{
 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
     //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,mx = 0;
    cin >> n;
    vector<int>g[n];
    vector<pair<int,int>>vp;
    vector<int>c(n,0);
    map<pair<int,int>,int>m;
    queue <int>q;
    for (int i = 0; i < n-1; ++i)
    {
      int a,b;
      cin >> a >> b;
      a--;b--;
      g[a].pb(b);
      g[b].pb(a);
      vp.pb({a,b});
    }
    int k = 0;
    vector<int>u(n,0);
    u[0] = 1;
    q.emplace(0);
    while(!q.empty())
    {
      int v = q.front();q.pop();
      if(k < (int)g[v].size())
        k = g[v].size();
      int cr = 1;
      for( auto i : g[v])
      {
        if(u[i])
          continue;
        if(cr == c[v])cr++;
        c[i] = m[make_pair(i,v)] = m[make_pair(v,i)] = cr++;
        u[i] = 1;
        q.emplace(i);
      }
    }
    cout << k << endl;
    for (auto i : vp)
    {
      cout << m[i] << endl;
    }
    return 0;
} 

Measured memory_bytes: 20084
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	ll a,b;
	cin >> a >> b;
	cout << a*b;
}

int main() {
    FAST;
    ll t=1;
    //cin>>t;
    while(t--) solve();	
    return 0;
}



Measured memory_bytes: 3688
#include <stdio.h>

int main(void) {
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<n/4+1;i++){
		for(j=0;j<n/7+1;j++){
			if((i*4+j*7)==n){
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 128