akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int>* adj;
typedef long long int ll;
ll dp[100005][2];
int mod=int(1e9)+7;
ll dfs(int i, int p , int col){
    // if(adj[i].size()==1) {
    //     if(col==0) return 2;
    //     return 1;
    // }
    if(dp[i][col]!=-1) return dp[i][col];
 ll ans=1;
 ll temp;
    for(auto itr:adj[i]){
        if(itr!=p){
            temp=dfs(itr,i,0);
            if(col==0) temp=(temp+dfs(itr,i,1))%mod;
            ans=(ans*temp)%mod;
        }
    }
    return dp[i][col]=ans%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
        int n;
        memset(dp,-1,sizeof(dp));
        cin>>n;
        adj=new vector<int>[n];
        int a,b;
        for(int i=0;i<n-1;i++){
            cin>>a>>b;
            a--;
            b--;
            adj[a].push_back(b);
            adj[b].push_back(a);
        }
        ll ans=(dfs(0,-1,0)+dfs(0,-1,1))%mod;
        cout<<ans<<"\n";
}

Measured memory_bytes: 15616
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
d = 0
for i in range(n):
    a = list(map(int,input().split()))
    e = []
    for j in range(m):
        e.append(a[j]*b[j])
    if sum(e)+c > 0:
        d += 1
print(d)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

vector<vector<LL>>res;
LL calc(){
    vector<LL>vec;
    REP(i,50)vec.PB(50);
    while(vec.back()>=50){
        REP(i,49)vec[i]++;
        vec[49]-=50;
        SORT(vec);
        res.PB(vec);
    }
    //cout<<SZ(res)<<endl;
}

int main(){
    LL K;
    cin>>K;
    LL d =K/50LL;
    int d2=K%50;
    calc();
    cout<<50<<endl;
    REP(i,50){
        if(d2!=0)cout<<d+res[49-d2][i]<<" ";
        else cout<<49LL+d<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

int main(){
    double x,a,b;
    cin >> a >> b;
    int ans = -1 * INF;
    rrep(i,10000){
        if(int(i*0.08)==a && int(i*0.1)==b)ans =min(ans,i);
    }
    if(ans == -1*INF)ans = -1;
    cout << ans << endl;
    return 0;
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k,x,ans = 0;
    cin >> n >> k;
    for(int i = 1;i <= n; ++i){
        cin >> x;
        if(x >= k) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Measured memory_bytes: 23348
"""
Writer: SPD_9X2
https://atcoder.jp/contests/arc063/tasks/arc063_c

数字が置かれている頂点は範囲指定の制約になる
→制約をすべての点に伝播させれば、後はその範囲内から適当に選んで実装すればよい

一度根方向に制約を集め、それを全方位に伝播させればよい？
→それっぽさそう

偶奇に関してはちゃんと考えてね
→条件の両端の偶奇で判断可能
"""

import sys
sys.setrecursionlimit(5*10**5)

N = int(input())

lis = [ [] for i in range(N) ]

for i in range(N-1):

    a,b = map(int,input().split())
    a -= 1
    b -= 1

    lis[a].append(b)
    lis[b].append(a)


l = [float("-inf")] * N
r = [float("inf")]  * N

K = int(input())

for i in range(K):

    V,P = map(int,input().split())
    V -= 1
    l[V] = P
    r[V] = P

#dfsで条件を根方向に集める
def dfs(v,p):

    for nex in lis[v]:

        if nex != p:
            nl,nr = dfs(nex,v)

            if l[v] != float("-inf") and nl != float("-inf") and l[v] % 2 != nl % 2:
                print ("No")
                sys.exit()

            l[v] = max(l[v] , nl)
            r[v] = min(r[v] , nr)

            if l[v] > r[v]:
                print ("No")
                sys.exit()

    return l[v] - 1 , r[v] + 1

dfs(0,0)

#bfsで条件を配る
from collections import deque
q = deque([0])
unvisit = [True] * N
ans = [None] * N
ans[0] = l[0]

while len(q) > 0:
    
    v = q.popleft()
    unvisit[v] = False

    if l[v] > r[v]:
        print ("No")
        sys.exit()
    
    for nex in lis[v]:

        if unvisit[nex]:

            if l[nex] != float("-inf") and l[v] != float("-inf") and l[v] % 2 == l[nex] % 2:
                print ("No")
                sys.exit()

            l[nex] = max(l[nex] , l[v]-1)
            r[nex] = min(r[nex] , r[v]+1)
            ans[nex] = l[nex]

            q.append(nex)

print ("Yes")
for i in ans:
    print (i)
    

Measured memory_bytes: 113936
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

typedef unsigned long long ull;



int main()
{
  string s;
  int K;
  set<string> S;

  cin>>s>>K;

  int size = s.length();

  for (int i = 0; i < size; i++) {
    string tmp;
    for (int j = 0; j < 5 && j + i < size; j++) {
      tmp = s.substr(i, j+1);
      S.insert(tmp);
      //cout<<tmp<<S.size()<<endl;
    }
  }


  set<string>::iterator itr = S.begin();
  for (int i = 0; i < K - 1; i++) itr++;

  cout<<(*itr)<<endl;

  return 0;
}


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

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

  int n, m; cin >> n >> m;
  int T[n+1] = {0};
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    T[a]++;
    T[b]++;
  }

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

  return 0;
}

Measured memory_bytes: 256
from collections import Counter

class Solver(object):
    def __init__(self):
        self.s = input()

    def solve(self):
        if self.s[0].upper() != "A":
            print("WA")
            return

        counter = Counter(self.s)
        subset_counter = Counter(self.s[2:-1])

        if counter['A'] != 1:
            print("WA")
            return

        if subset_counter['C'] != 1:
            print("WA")
            return
        
        counter.pop('A')
        counter.pop('C')

        for char in counter:
            if char != char.lower():
                print("WA")
                return

        print("AC")

if __name__ == "__main__":
    s = Solver()
    s.solve()

Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val sc = System.`in`.bufferedReader()
    val n = Integer.parseInt(sc.readLine())
    val list = MyLinkedList<Int>()
    repeat(n) {
        val command = sc.readLine().split(" ")
        when (command[0]) {
            "insert" -> {
                list.insert(Integer.parseInt(command[1]))
            }
            "delete" -> {
                list.delete(Integer.parseInt(command[1]))
            }
            "deleteFirst" -> {
                list.deleteFirst()
            }
            "deleteLast" -> {
                list.deleteLast()
            }
        }
    }
    println(list)
}

class MyLinkedList<T> {
    private val nil: Element = Element(null)
    init {
        nil.next = nil
        nil.prev = nil
    }

    fun insert(value: T) {
        val element = Element(value)
        element.next = nil.next
        nil.next?.prev = element
        nil.next = element
        element.prev = nil
    }

    fun delete(value: T) {
        var element = nil.next
        while (element != nil) {
            if (element?.value == value) {
                element?.prev?.next = element?.next
                element?.next?.prev = element?.prev
                return
            }
            element = element?.next
        }
    }

    fun deleteFirst() {
        val element = nil.next
        nil.next = element?.next
        element?.next?.prev = nil
    }

    fun deleteLast() {
        val element = nil.prev
        nil.prev = element?.prev
        element?.prev?.next = nil
    }

    override fun toString(): String {
        var element = nil.next
        val strBuilder = StringBuilder()
        while (element != nil) {
            strBuilder.append(element?.value)
            strBuilder.append(" ")
            element = element?.next
        }
        strBuilder.deleteCharAt(strBuilder.lastIndex)
        return strBuilder.toString()
    }

    inner class Element(val value: T?) {
        var prev: Element? = null
        var next: Element? = null
    }
}



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

int main(){
  ll N; cin >> N;
  vector<vector<pair<ll, ll> > > p(N, vector<pair<ll, ll> >());
  
  ll ans = 0;
  
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    for(ll j = 0; j < a; j++){
      ll x, y; cin >> x >> y;
      x--;
      p[i].push_back(make_pair(x, y));
    }
  }
  
  for(ll bits = 0; bits < (1 << N); bits++){
    bool succ = true;
    for(ll i = 0; i < N; i++){
      if((bits >> i) & 1){
	    for(auto e: p[i]){
	      if((e.second != ((bits >> e.first) & 1))){
            succ = false;
          }
        }
      }
    }
    
    if(succ){
      ll tmp = 0;
      for(ll i = 0; i < N; i++){
        tmp += ((bits >> i) & 1);
      }
      ans = max(ans, tmp);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = Integer.parseInt(sc.next());
        }
        
        double min = 10000;
        int ans = 0;
        for(int i = 0; i < n; i++){
            double j = t - h[i]*0.006;
            if(Math.abs(a-j) < min){
                min = Math.abs(a-j);
                ans = i+1;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l,sum=0,ans=1;
  int a[205];
  cin>>n>>l;

  for(int i=1; i<=n; i++){
    a[i]=l+i-1;
    sum+=a[i];
  }
  int mi=abs(0-a[1]);

  for(int i=2; i<=n; i++){
    if(mi>abs(0-a[i])){
      mi=abs(0-a[i]);
      ans=i;
    }
  }

  cout<<sum-a[ans]<<'\n';
  return 0;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append(y)
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(np.array(P_Y[i]).argsort().argsort())

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]])+1)
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])
    
    


Measured memory_bytes: 59400
#include <bits/stdc++.h>
 
using ll = long long;
 
const int max_N = 1e5 + 21;

const ll inf = 2e10 + 1;
 
int n,ans;
 
bool vis[max_N];

int pri_tot,pri[max_N];
 
ll Norm[max_N],Pair[max_N];

int N_tot,P_tot,N_siz[max_N],P_siz[max_N];

inline void jzp(int n){
	for(int x=2;x<=n;++x){
		if(!vis[x])pri[++pri_tot]=x;
		for(int i=1;i<=pri_tot;++i){
			int y=pri[i];
			if((ll)x*y>n)break;
			vis[x*y]=1;
			if(!(x%y))break;
		}
	}
}
 
inline ll get_norm(ll x){
	for(int i=1;i<=pri_tot;++i){
		int y=pri[i];
		ll z=1ll*y*y*y;
		if(z>x)break;
		while(!(x%z))x/=z;
	}
	return x;
}
 
inline ll get_pair(ll x){
	ll res=1;
	for(int i=1;i<=pri_tot;++i){
		int y=pri[i];
		ll z=(ll)y*y*y;
		if(z<=x){
			while(!(x%z))x/=z;
			if(!(x%(y*y))){
				res*=y,x/=(y*y);
				if(res>=inf)return inf;
			}
			else if(!(x%y)){
				res*=(y*y),x/=y;
				if(res>=inf)return inf;
			}
		}
		else{
			break;
			/*
			ll w=(ll)y*y;
			if(w>x){
				if(inf/x/x<res)return inf;
				return res*x*x;
			}
			else if(!(x%y)){
				if(x==w){
					res*=y;
					return res>=inf?inf:res;
					
				}
				else{
					if(inf/x/x<res)return inf;
					return res*x*x;
				}
			}
			*/
		}
	}
	ll y=std::sqrt(x);
	if(y*y==x){
		res*=y;
		return res>=inf?inf:res;
	}
	if(inf/x/x<res)return inf;
	return res*x*x;
}
 
int main(){
	jzp(1e5);
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		ll s; scanf("%lld",&s);
		Norm[i]=get_norm(s);
		Pair[i]=get_pair(s);
	}
	std::sort(Norm+1,Norm+1+n);
	std::sort(Pair+1,Pair+1+n);
	for(int i=1;i<=n;++i){
		if(Norm[i]!=Norm[i-1])Norm[++N_tot]=Norm[i];
		++N_siz[N_tot];
		if(Pair[i]!=Pair[i-1])Pair[++P_tot]=Pair[i];
		++P_siz[P_tot];
	}
	int i=1,j=1;
	while(i<=N_tot||j<=P_tot){
		if(i<=N_tot&&j<=P_tot&&Norm[i]==Pair[j]){
			if(Norm[i]!=1)ans+=std::max(N_siz[i],P_siz[j]);
			++i,++j;
		}
		else if(i>N_tot||(j<=P_tot&&Norm[i]>Pair[j]))
			ans+=P_siz[j++];
		else
			ans+=N_siz[i++];
	}
	ans>>=1;
	if(Norm[1]==1)++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline void rd(int&x)
{
	x=0;char k=getchar();
	while(k>'9'||k<'0')k=getchar();
	while(k>='0'&&k<='9')x=x*10+k-48,k=getchar();
}
const int N=(1<<21),mod=1e9+7;
int s[N],dp[N],n,a[N],b[N],la[N+N],ans,cnt1[N],cnt2[N];
int gao()
{
	int ret=1;
	for(int i=1;i<n;i++)if(!b[i])ret=(ret*2)%mod;return ret;
}
main()
{
	rd(n);
	for(int i=1;i<=n;i++)rd(a[i]),b[i]=a[i]^b[i-1],s[i]=s[i-1]+(b[i]==0);
	//for(int i=1;i<=n;i++)cout<<b[i]<<" ";cout<<endl;
	for(int i=1;i<=n;i++)
	{//cout<<b[i]<<" ";
		//if(!b[i])continue;
		if(!la[b[i]])
		{//cout<<1<<" ";
			la[b[i]]=i;cnt1[b[i]]++,cnt2[b[i]]=(cnt2[b[i]]+s[i])%mod;
			dp[i]=1;if(b[i])ans++;continue;
		}
		int j=la[b[i]],sum=s[i]-s[j];
		dp[i]=(cnt1[b[i]]*s[i]-cnt2[b[i]]+1)%mod,dp[i]=(dp[i]+mod)%mod;la[b[i]]=i;
		if(b[i])
		ans=(ans+dp[i])%mod;//cout<<ans<<endl;
		cnt1[b[i]]+=dp[i],cnt1[b[i]]%=mod,cnt2[b[i]]+=dp[i]*s[i],cnt2[b[i]]%=mod;
		//cout<<dp[i]<<" ";
	}//cout<<endl;cout<<ans<<endl;
	if(b[n])
	printf("%lld\n",dp[n]);
	else printf("%lld\n",(ans+gao())%mod);
	return 0;
}

Measured memory_bytes: 47360
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

struct Edge { int to, cost; };

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef long long ll;
typedef pair<ll, ll> Pll;

int N;
int p[810]; // p[0] no use
ll allcost, delcost;

Graph G;
set<int> leaves;

Pll visit(int prev, int curr) {
  
  Pll r(0, curr);
  
  for(int i=0; i<G[curr].size(); i++) {
    const Edge& e = G[curr][i];
    if(e.to != prev) {
      if(leaves.count(e.to)) continue;
      Pll t = visit(curr, e.to);
      t.first += e.cost;
      if(r.first < t.first) r = t;
    }
  }
  return r;
}

ll diameter(int s) {
  Pll r = visit(-1, s);
  Pll t = visit(-1, r.second);
  return t.first;
}

void setLeaves() {
  delcost = allcost;
  for(int i=0; i<G.size(); i++) {
    if(G[i].size() == 1) {
      leaves.insert(i);
      delcost -= G[i][0].cost;
    }
  }
}

void init() {
  G.clear();
  G.resize(N);
  leaves.clear();
  allcost = 0;
  delcost = 0;
}

int main() {
  
  while(cin >> N && N) {
    
    init();
    
    for(int i=1; i<N; i++) {
      cin >> p[i]; p[i] --;
    }
    
    for(int i=1; i<N; i++) {
      int x; cin >> x;
      G[i].push_back((Edge){p[i], x});
      G[p[i]].push_back((Edge){i, x});
      allcost += x;
    }
    setLeaves();
    for(int i=0; i<N; i++) {
      if(leaves.count(i)) continue;
      cout << 2*delcost+allcost-diameter(i) << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n,q;
vector<ll> x;
ll l,h;
ll mmin = 10e9 + 1;

/* add your algorithm here */

ll gcd(ll m, ll n);

ll gcd (ll m, ll n) {
  if (m < n) return gcd(n,m);
  if (n == 0) return m;

  return gcd(n, (m%n));
}

int main() {
  cin >> n >> q;
  if (n == 1) {
    ll a;
    cin >> a;
    cout << abs(a - q) << endl;
    return 0;
  }
  rep(i,n) {
    ll t;
    cin >> t;
    x.pb(abs(t-q));
  }

  ll d;

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

  d = x[0];
  for (int i = 1; i < n; ++i) {
    d = gcd(x[i], d);
  }

  cout << d << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

const ll inf = LONG_LONG_MAX / 2 - 1;

void dfs(const vector<vector<ll>> &t, vector<ll> &dp, ll bit, ll v) {
    if (dp[bit] <= v) return;
    dp[bit] = v;
    ll n = sz(t);
    rep(i, n) {
        ll plus = t[i][0];
        rep(j, n) {
            if ((bit & (1 << j)) != 0) {
                plus = min(plus, t[i][j + 1]);
            }
        }
        dfs(t, dp, bit | (1 << i), v + plus);
    }
}

void solve(ll n) {
    vector<vector<ll>> t(n, vector<ll>(n + 1));
    rep(i, n) rep(j, n + 1) cin >> t[i][j];
    vector<ll> dp(1 << n, inf);
    dfs(t, dp, 0, 0);
    cout << dp[(1 << n) - 1] << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    while(true) {
        ll n;
        cin >> n;
        if (n == 0) break;
        solve(n);
    }
    return 0;
}



Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MAX_N = (int) 1e5 + 10;

int A[MAX_N], B[MAX_N], C[MAX_N];
ll sum[MAX_N];
int N;

int main(void){
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < N; i++) cin >> B[i];
	for(int i = 0; i < N; i++) cin >> C[i];

	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);

	for(int i = 0; i < N; i++){
		sum[i] = (C + N) - upper_bound(C, C + N, B[i]);
		// printf("sum[%d] = %lld\n", i, sum[i]);
	}

	for(int i = N - 2; i >= 0; i--){
		sum[i] += sum[i+1];
		// printf("sum[%d] = %lld\n", i, sum[i]);
	}

	// for(int i = 0; i < N; i++) debug(B[i]);

	ll res = 0;
	for(int i = 0; i < N; i++){
		// debug((B + N) - upper_bound(B, B + N, A[i]));
		// debug(A[i]);
		res += sum[upper_bound(B, B + N, A[i]) - B];
		// debug(res);
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 2176
import itertools
import numpy as np

N = int(input())
l = []
for i in range(N):
	l.append(list(map(int,input().split())))
    
r = 0
for i,j in itertools.product(l,l):
	r += np.sqrt((i[0]-j[0])**2 + (i[1]-j[1])**2)

print(r/N)   

Measured memory_bytes: 20404
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

bool area[101][101];

int main()
{
	memset(area, false, sizeof(area));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int W, H, N; cin >> W >> H >> N;
	rep (i, N){
		int x, y, a; cin >> x >> y >> a;
		if (a == 1){
			for (int i = 0; i <= H; ++i){
				for (int j = 0; j < x; ++j){
					area[i][j] |= true; 	
				} // end for
			} // end for
		}else
		if (a == 2){
			for (int i = 0; i <= H; ++i){
				for (int j = x; j <= W; ++j){
					area[i][j] |= true;
				} // end for
			} // end for
		}else
		if (a == 3){
			for (int i = 0; i < y; ++i){
				for (int j = 0; j <= W; ++j){
					area[i][j] |= true;
				} // end for
			} // end for
		}else{ // if (a == 4)
			for (int i = y; i <= H; ++i){
				for (int j = 0; j <= W; ++j){
					area[i][j] |= true;
				} // end for
			} // end for
		} // end if
	} // end rep

	int res = 0;
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			res += (area[i][j]);
		} // end for
	} // end for

/*
	for (int i = 0; i <= H; ++i){
		for (int j = 0; j <= W; ++j){
			cerr << ' ' << area[i][j]; 
		} // end for
		cerr << endl;
	} // end for
*/
	cout << H * W - res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;
//高橋君が食品をおいしく感じた場合 delicious を、おいしくは感じなかったがお腹は壊さなかった場合 safe を、お腹を壊した場合 dangerous を
int main(void) {
    int X, A, B;
    cin >> X >> A >> B;
    if (A >= B)
        cout << "delicious\n";
    else if (X >= (B - A))
        cout << "safe\n";
    else
        cout << "dangerous\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  vector<ll> p(n);
  vector<ll> q(n);
  vector<ll> r={};
  ll sump=0;
  ll sumq=0;
  ll ans=0;
  ll sumhelp=0;
  rep(i,n){
    cin>>p[i];
    sump+=p[i];
  }
  rep(i,n){
    cin>>q[i];
    sumq+=q[i];
    if(p[i]<q[i]) {
      ans++;
      sumhelp+=q[i]-p[i];
    }
    if(p[i]>q[i]) r.pb(p[i]-q[i]);
  }

  if(sump<sumq) {
    cout << -1 << endl;
    return 0;
  }

  if(sumhelp==0) {
    cout << 0 << endl;
    return 0;
  }

  sort(all(r));
  reverse(all(r));

  rep(i,r.size()){
    sumhelp-=r[i];
    ans++;
    if(sumhelp<=0) {
      cout << ans << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 2428
#include <stdio.h>

int main(void)
{
    int a,b;

    //??\???
    scanf("%d %d", &a, &b);

    //??????
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<numeric>
using namespace std;
const int PRIME = 10000;
const int BUF = 10000001;


int nPrime, prime[PRIME];

void makePrime() {
    bool isPrime[PRIME];
    for (int i = 0; i < PRIME; ++i) isPrime[i] = true;
    for (int i = 2; i * i <= PRIME; ++i)
        if (isPrime[i])
            for (int j = i * 2; j < PRIME; j += i)
                isPrime[j] = false;
    nPrime = 0;
    for (int i = 2; i < PRIME; ++i)
        if (isPrime[i])
            prime[nPrime++] = i;
}

long long table[BUF];

int calcNumDivisor(int n) {
    int ret = 1;
    for (int i = 0; prime[i] * prime[i] <= n; ++i) {
        if (n % prime[i] == 0) {
            int cnt = 0;
            while (n % prime[i] == 0) {
                ++cnt;
                n /= prime[i];
            }
            ret *= cnt + 1;
        }
    }
    if (n > 1) ret *= 2;
    return ret;
}

void makeTable() {
    for (int i = 1; i < BUF; ++i)
        table[i] = 1LL * i * calcNumDivisor(i);
}

int N;

void read() {
    cin >> N;
}


void work() {
    cout << accumulate(table + 1, table + N + 1, 0LL) << endl;
}


int main() {
    makePrime();
    makeTable();
    read();
    work();
    return 0;
}


Measured memory_bytes: 81792
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll

vector<pair<ll,ll> > pq;
ll dp[2001][2001];

ll recur(ll l,ll r,ll index)
{
    if(l > r)
    return 0;
    else if(l == r)
    {
        pair<ll,ll> temp = pq[index-1];
        dp[l][r] = abs(l-temp.S)*temp.F;
        return abs(l-temp.S)*temp.F;
    }
    else
    {
        pair<ll,ll> temp = pq[index-1];
        // pq.pop();
        if(dp[l+1][r] == -1)
        dp[l+1][r] = recur(l+1,r,index+1);
        if(dp[l][r-1] == -1)
        dp[l][r-1] = recur(l,r-1,index+1);
        return max(abs(l-temp.S)*temp.F + dp[l+1][r],abs(r-temp.S)*temp.F + dp[l][r-1]);
    }
}


void solve()
{
    ll n;
    cin>>n;
    ll l = 1;
    ll r = n;
    ll ans = 0;
    for(int i = 1 ; i <= 2000 ; i++)
    {
        for(int j = 1 ; j <= 2000 ; j++)
        dp[i][j] = -1;
    }
    for(ll i = 1 ; i <= n ; i++)
    {
        ll temp;
        cin>>temp;
        pq.push_back(mp(temp,i));
    }
    sort(pq.rbegin(),pq.rend());
    ans = recur(l,r,1);
    cout<<ans<<endl;
}




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 35152
from math import sqrt
def main():
    n = int(input().rstrip("\n"))
    
    s = int(sqrt(n))
    for number in range(s, 0, -1):
        if n % number == 0:
            print(number + (n // number) - 2)
            break
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std ;

int main()
{
  int N,K ;
  cin>>N>>K ;
  vector<int>h(N) ;
  for(int i=0;i<N;i++) cin>>h.at(i) ;
  
  sort(h.begin(),h.end()) ;
  int min=1e9 ;
  for(int i=0;i<=N-K;i++){
    int temp=h.at(K-1+i)-h.at(i) ;
    if(temp<min) min=temp ;
  }
  cout<<min<<endl ;
  return 0 ;
}

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

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
void Add(ll &pos,ll val){pos=mod(pos+val);}
void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
*/

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

typedef long double dd;
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second

#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;


//using mint = modint998244353;
using mint = modint1000000007;
//////////////////////////


ll OP(ll a,ll b){return max(a,b);}
ll E(){return -inf;}
ll target;
bool F(ll x){
    if(target>x)return true;
    return false;
}

int main(){fastio
    ll n,q;cin>>n>>q;
    vl a(n+1);rep(i,1,n)cin>>a[i];
    segtree<ll,OP,E>seg(a);
    while(q--){
        ll t,x,y;cin>>t>>x>>y;
        if(t==1){
            seg.set(x,y);
        }else if(t==2){
            cout<<seg.prod(x,y+1)<<endl;
        }else{
            target=y;
            cout<<seg.max_right<F>(x)<<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 9048
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    ll n;
    cin >> n;
    map<string,ll> c;
    ll ans = 0;
    rep(i,n) {
        string s;
        cin >> s;
        sort(all(s));
        if(c.count(s)){
            ans += c[s];
            c[s]++;
        }
        else c[s] = 1;
    }
        
    cout << ans << endl;
    cout << endl;
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it,con) for (auto it = con.begin(); it!=con.end(); ++it)
using namespace std;
using ll = long long;
using P = pair<int,int>;

array<int, 2> lot90(array<int, 2> po){
	array<int, 2> npo;
	npo[0]= -po[1];
	npo[1]=po[0];
	return npo;
}

int main() {
	int n;
	cin>>n;
	vector<array<int, 2>> ap[4];
	map<char, int> ma={{'U', 0}, {'R', 1}, {'D', 2}, {'L', 3}};
	rep(i, n){
		int x, y;
		char u;
		cin>>x>>y>>u;
		ap[ma[u]].push_back({x, y});
	}

	map<int, set<int>> ona;
	int mn=INT_MAX;
	rep(_, 4){
		ona.clear();
		for(auto po : ap[1]){
			ona[po[0]+po[1]].insert(po[1]);
		}
		for(auto po : ap[0]){
			int lin=po[0]+po[1];
			auto but=ona[lin].lower_bound(po[1]);
			if(but!=ona[lin].end()) mn=min(mn, 10*(*but-po[1]));
		}
		ona.clear();
		for(auto po : ap[2]){
			ona[po[0]].insert(po[1]);
		}
		for(auto po : ap[0]){
			int lin=po[0];
			auto but=ona[lin].lower_bound(po[1]);
			if(but!=ona[lin].end()) mn=min(mn, 5*(*but-po[1]));
		}
		rep(i, 4) rep(j, ap[i].size()) ap[i][j]=lot90(ap[i][j]);
		auto tmp=ap[0];
		rep(i, 4-1) ap[i]=ap[i+1];
		ap[4-1]=tmp;
	}

	if(mn==INT_MAX) cout<<"SAFE"<<endl;
	else cout<<mn<<endl;

	return 0;
}


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

int main()
{
  unsigned long X;
  cin >> X;
  
  unsigned long money = 100;
  int year = 0;
  while(true)
  {
    year++;
    
    money += money / 100;
    if(money >= X)
    {
      break;
    }
  }
  
  cout << year << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans[ohara],a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s;
    ans[0]=0;
    rep(i,Size(s)){
        if(s[i]=='<')ans[i+1]=ans[i]+1;
    }
    rrrep(i,Size(s)-1,0){
        if(s[i]=='>')ans[i]=max(ans[i],ans[i+1]+1);
    }
    rep(i,Size(s)+1)cnt+=ans[i];
    Cout(cnt);
    return 0;
}

Measured memory_bytes: 5020
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
g = [[] for _ in range(n)]
cost = dict()
for i in range(n-1):
    a,b,c = inpl()
    a -= 1; b -= 1
    g[a].append(b); g[b].append(a)
    cost[(a,b)] = c; cost[(b,a)] = c
Q,k = inpl()
k -= 1
q = deque()
q.append(k)
dist = [-1] * n
dist[k] = 0
while q:
    v = q.popleft()
    for nv in g[v]:
        if dist[nv] != -1:
            continue
        dist[nv] = dist[v] + cost[(nv,v)]
        q.append(nv)
for _ in range(Q):
    a,b = inpl()
    print(dist[a-1] + dist[b-1])



Measured memory_bytes: 123548
#include<stdio.h>
int main(void)
{
    int n,work;
    int k=0;
    int count=0;
    int flag=1;
    int S[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    while(flag){
        flag=0;
        for(int i=n-1;i>=k+1;i--){
            if(S[i]<S[i-1]){
                work=S[i];
                S[i]=S[i-1];
                S[i-1]=work;
                count++;
                flag=1;
            }
        }
        k++;
    }
    for(int i=0;i<n-1;i++){
        printf("%d ",S[i]);
    }
    printf("%d\n",S[n-1]);
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2104
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;

int h , a ; 

int main()
{
	migmig ;
	cin>>h>>a ; 
	if(h % a == 0) cout<<h/a ; 
	else cout<<h/ a + 1 ; 

}
//////
////////
///////////




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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int x,a,b;
	cin >> x >> a >> b;	
	if(abs(x-a) > abs(x-b))
		cout << "B\n";
	else cout << "A\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	
	Scanner cin = new Scanner(System.in);
	
	public static void main(String[] args) {
		new Main().run(); 
	}
	
	public void run() {		
		
		/*input*/
		
		int n = cin.nextInt();
		int k = cin.nextInt();
		int x = cin.nextInt();
		int y = cin.nextInt();
		
		/*start*/
		
		int total = 0;
		
		if (n <= k) {
			
			total = n * x;		
		} else {
			
			total = k * x;
			total += (n-k) *y;
		}
		
		/*finish*/
		System.out.println(total);
	}
}



Measured memory_bytes: 23764
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = n* -1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll inf = (1LL << 60);
const int MOD = 1000000007;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int x,d[100],sum = 0;
int main() {
    cin >> x; ll n, m, k;
    req(a, 1000) {
        n = x - pow(a, 5);
        if (n < 0) {
            n *= -1;
            m = floor(pow(n, 0.2));
            if (pow(a, 5) - pow(m, 5) == x) {
                cout << a << " " << m << endl;
                return 0;
            }
        }
        else {
            m = floor(pow(n, 0.2));
            if (pow(a, 5) + pow(m, 5) == x) {
                cout << a << " -" << m << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4072
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=[[] for i in range(k)]
for i in range(n):
    ans[i%k]+=[t[i]]
cnt=0
#print(ans)
for i in range(k):
    if ans[i][0]=="r":
        cnt+=p
        ans[i][0]="R"
    elif ans[i][0]=="s":
        cnt+=r
        ans[i][0]="S"
    elif ans[i][0]=="p":
        cnt+=s
        ans[i][0]="P"
    for j in range(1,len(ans[i])):
        if ans[i][j]=="r" and ans[i][j-1]!="R":
            cnt+=p
            ans[i][j]="R"
        elif ans[i][j]=="s" and ans[i][j-1]!="S":
            cnt+=r
            ans[i][j]="S"
        elif ans[i][j]=="p" and ans[i][j-1]!="P":
            cnt+=s 
            ans[i][j]="P"
#print(ans)
print(cnt)

Measured memory_bytes: 13440
import sys
from collections import deque,defaultdict

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))

def mi():
	return map(int,I().strip().split())


def main():
	n=ii()
	if n>=400 and n<=599:
		print(8)
	elif n>=600 and n<=799:
		print(7)
	elif n>=800 and n<=999:
		print(6)
	elif n>=1000 and n<=1199:
		print(5)
	elif n>=1200 and n<=1399:
		print(4)
	elif n>=1400 and n<=1599:
		print(3)
	elif n>=1600 and n<=1799:
		print(2)
	else:
		print(1)







		


		










		






if __name__ == '__main__':
	main()

Measured memory_bytes: 9484
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main() {
  int k; string  s;
  cin >> k >> s;
  string res;
  if (s.size() > k) {
    string str(s.begin(), s.begin()+k);
    str += "...";
    res = str;
  } else {
    res = s;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	map<string, int> m;
	char last;
	vector<string> W(N);
	for(int i=0; i<N; ++i) cin >> W[i];
	for(int i=0; i<N; ++i){
		++m[W[i]];
		if(m[W[i]]!=1){
			cout << "No" << endl;
			return 0;
		}
		if(i!=0 && W[i][0]!=last){
			cout << "No" << endl;
			return 0;
		}
		last = W[i][W[i].length()-1];
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3604
strin = [input(), input(), input()]

l = ['a','b','c']
cnt, nxt = [0, 0, 0], 0
while True:
    lttr = strin[nxt][cnt[nxt]]
    cnt[nxt] += 1
    nxt = l.index(lttr)
    if cnt[nxt] >= len(strin[nxt]):
        print(l[nxt].upper())
        break


Measured memory_bytes: 2940
#include <climits>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

int main()
{
	int N;
	string s;
	cin >> N >> s;
	int cl = 0, cr = 0;
	int dl = 0, dr = 0;
	FO(i, s.size())
	{
		if (s[i] == '(')
			++cl;
		else
			++cr;
		dl = max(dl, cr - cl);
	}
	cl = 0, cr = 0;
	RFO(i, s.size())
	{
		if (s[i] == ')')
			++cr;
		else
			++cl;
		dr = max(dr, cl - cr);
	}
	string res = string(dl, '(') + s + string(dr, ')');
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			int left = a + b, right = c + d;
			System.out.println((left == right) ? "Balanced" : (left > right) ? "Left" : "Right");
		}
	}
}


Measured memory_bytes: 23764
a, b, k = list(map(int, input().split()))

for i in range(k):
    x = a + i
    if x <= b:
        print(a + i)
    
for i in range(k):
    x = b - k + i + 1
    if x <= a + k - 1 or x < a:
        pass
    else:
        print(x)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n, K;
int a[MAX], b[MAX];

bool check(){
    For(i, 1, n+1)if(a[i] != b[i]) return false;
    return true;
}

int main(){
    scanf("%d%d", &n, &K);
    For(i, 1, n+1) scanf("%d", &a[i]);
    a[0] = a[n+1] = 0;

    while(K){
        --K;
        fill(b, b+n+2, 0);
        For(i, 1, n+1){
            ++b[max(0, i-a[i])];
            --b[min(n+1, i+a[i]+1)];
        }
        partial_sum(b, b+n+2, b);
        if(check()) break;
        rep(i, n+2) a[i] = b[i];
    }
    For(i, 1, n+1) printf("%d ", a[i]);
    printf("\n");
}


Measured memory_bytes: 5292
fun main(args: Array<String>) {
    val mod = 1000000007L

    val (n, k) = readInputLine().split(" ").map { it.toInt() }

    val factorial = LongArray(n + 1)
    val inverse = LongArray(n + 1)
    val factorialInverse = LongArray(n + 1)
    factorial[0] = 1L
    factorial[1] = 1L
    inverse[0] = 1L
    inverse[1] = 1L
    factorialInverse[0] = 1L
    factorialInverse[1] = 1L
    for (i in 2..n) {
        factorial[i] = (factorial[i - 1] * i.toLong() % mod)
        inverse[i] = (mod - inverse[mod.toInt() % i] * (mod / i.toLong()) % mod)
        factorialInverse[i] = (factorialInverse[i - 1] * inverse[i] % mod)
    }

    fun nCm(n: Int, m: Int): Long {
        return factorial[n] * (factorialInverse[m] * factorialInverse[n - m] % mod) % mod
    }

    fun nHm(n: Int, m: Int): Long {
        return nCm(n + m - 1, m)
    }

    var ans = 0L

    for (i in 0..Math.min(n - 1, k)) {
        ans += nCm(n, i) * nHm(n - i, i) % mod
        ans %= mod
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 40552
# 2019/06/08
# AtCoder Beginner Contest 114 - C

def makeval(in_sn):
    div = int(in_sn / 4)
    rem = in_sn % 4
    if div == 0:
        if rem == 0:
            return "X"
        elif rem == 1:
            return "3"
        elif rem == 2:
            return "5"
        elif rem == 3:
            return "7"
    else:
        ret = makeval(div)
        if rem == 0:
            return ret + "3"
        elif rem == 1:
            return ret + "5"
        elif rem == 2:
            return ret + "7"
        elif rem == 3:
            return "X"
# Input
n = int(input())

wval = 1
cnt = 0
idx = 1

while(wval <= n):
    wstr = makeval(idx)
    if ("X" in wstr) == False:
        if ("3" in wstr) == True and ("5" in wstr) == True and ("7" in wstr) == True :
            wval = int(wstr)
            cnt += 1
    
    idx += 1

cnt -= 1

# Output
print(cnt)


Measured memory_bytes: 3188
N, D = map(int, input().split())
X = []
for n in range(N):
    X.append(list(map(int, input().split())))

import numpy as np
X = np.array(X)

count = 0
for n in range(N-1):
    d = np.sqrt(np.sum((X[n] - X[n+1:])**2, axis=1))
    count += np.sum(d == np.round(d))

print(count)

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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if(a+b > c*2){
    int z = min(x,y);
    ans += z * c * 2;
    x -= z;
    y -= z;
  }
  //cout << ans << endl;
  if(a > c*2){
    ans += x * c * 2;
  }else{
    ans += x * a;
  }
  //cout << ans << endl;
  if(b > c*2){
    ans += y * c * 2;
  }else{
    ans += y * b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
      int b=sc.nextInt();
        System.out.println(a+b/2);
    }
}

Measured memory_bytes: 23252
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i] >> B[i]; }

    vector<ll> dp(H + 1, INF);
    dp[H] = 0;
    // モンスターの体力がiの時のトキの体力の最小値
    for (int i = H; i >= 0; i--) {
        rep(j, N) {
            if (i - A[j] > 0)
                dp[i - A[j]] = min(dp[i - A[j]], dp[i] + B[j]);
            else
                dp[0] = min(dp[0], dp[i] + B[j]);
        }
    }

    cout << dp[0] << endl;
}

Measured memory_bytes: 384
import sys
import math
import numpy as np

stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m, v, p = na()
a = na()
a.sort(reverse=True)
a = np.array(a)
left = p - 1
right = n
def check(i):
    c = a[i] + m
    s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m))
    if i+1 <= p:
        return True
    elif a[i] + m < a[p-1]:
        return False
    elif s >= m * v:
        return True
    else:
        return False
while left + 1 < right:
    x = (left + right) // 2
    if check(x):
        left = x
    else:
        right = x
print(left + 1)

Measured memory_bytes: 23132
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
    }


Measured memory_bytes: 256