akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<queue>
#include<cstdio>

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

using namespace std;

const int V_MAX=6000;
const int CAPA_INF=1<<29;
const int COST_INF=1<<29;

template<class T,class U>
struct edge{
	int v,rev;
	T capa;
	U cost;
	T flow;
};

template<class T,class U>
void add_directed_edge(vector< edge<T,U> > *G,int u,int v,T capa,U cost){
	G[u].push_back((edge<T,U>){v,G[v].size()  ,capa, cost,0});
	G[v].push_back((edge<T,U>){u,G[u].size()-1,   0,-cost,0});
}

template<class T,class U>
pair<T,U> augment(int n,vector< edge<T,U> > *G,int s,int t,U *pot){
	static int pre[V_MAX];
	static U d[V_MAX];
	rep(u,n) d[u]=(u==s?0:COST_INF);

	bool ok=false;
	priority_queue< pair<U,int> > Q; Q.push(make_pair(0,s));
	while(!Q.empty()){
		int u=Q.top().second;
		U cost=-Q.top().first; Q.pop();

		if(cost<d[u]) continue;
		if(u==t) ok=true;

		rep(i,G[u].size()){
			edge<T,U> &e=G[u][i];
			U cost2=cost+e.cost+pot[u]-pot[e.v];
			if(e.capa-e.flow>0 && cost2<d[e.v]){
				d[e.v]=cost2;
				pre[e.v]=e.rev;
				Q.push(make_pair(-cost2,e.v));
			}
		}
	}

	if(!ok) return make_pair(0,0);

	T water=CAPA_INF;
	for(int v=t;v!=s;){
		edge<T,U> &e1=G[v][pre[v]];
		edge<T,U> &e2=G[e1.v][e1.rev];
		water=min(water,e2.capa-e2.flow);
		v=e1.v;
	}

	U cost=0;
	for(int v=t;v!=s;){
		edge<T,U> &e1=G[v][pre[v]];
		edge<T,U> &e2=G[e1.v][e1.rev];
		e1.flow-=water;
		e2.flow+=water;
		cost+=water*e2.cost;
		v=e1.v;
	}

	rep(u,n) pot[u]+=d[u];

	return make_pair(water,cost);
}

template<class T,class U>
pair<T,U> primal_dual(int n,vector< edge<T,U> > *G,int s,int t){
	T ans1=0;
	U ans2=0;
	static U pot[V_MAX];
	while(1){
		pair<T,U> tmp=augment(n,G,s,t,pot);
		if(tmp.first==0) break;
		ans1+=tmp.first;
		ans2+=tmp.second;
	}
	return make_pair(ans1,ans2);
}

struct train{
	int t1,t2,cost;
};

int main(){
	for(int n;scanf("%d",&n),n;){
		vector<train> T[99];
		rep(i,n-1){
			int m; scanf("%d",&m);
			T[i].resize(m);
			rep(j,m) scanf("%d%d%d",&T[i][j].t1,&T[i][j].t2,&T[i][j].cost);
		}
		int n_class; scanf("%d",&n_class);

		int V=0;
		map<int,int> f[100][2];
		map<int,int>::iterator it,jt;
		rep(i,n-1) rep(j,T[i].size()) {
			int t1=T[i][j].t1,t2=T[i][j].t2;
			if(f[ i ][0].count(t1)==0) f[ i ][0].insert(make_pair(t1,V++));
			if(f[i+1][0].count(t2)==0) f[i+1][0].insert(make_pair(t2,V++));
			if(f[i+1][1].count(t2)==0) f[i+1][1].insert(make_pair(t2,V++));
		}

		int s=V++;
		int t=V++;
		static vector< edge<int,int> > G[V_MAX];
		rep(u,V) G[u].clear();

		add_directed_edge(G,s,f[0][0].begin()->second,n_class,0);
		add_directed_edge(G,f[n-1][0].rbegin()->second,t,n_class,0);
		rep(i,n){
			for(it=f[i][0].begin();it!=f[i][0].end();++it){
				jt=it;
				++jt;
				if(jt!=f[i][0].end()){
					add_directed_edge(G,it->second,jt->second,n_class,0);
				}
			}
		}
		rep(i,n) for(it=f[i][1].begin();it!=f[i][1].end();++it){
			int t=it->first;
			add_directed_edge(G,it->second,f[i][0][t],1,0);
		}
		rep(i,n-1) rep(j,T[i].size()) {
			add_directed_edge(G,f[i][0][T[i][j].t1],f[i+1][1][T[i][j].t2],1,T[i][j].cost);
		}

		pair<int,int> ans=primal_dual(V,G,s,t);
		printf("%d %d\n",ans.first,ans.second);
	}

	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<ll> ans(N+1);
  ans[0] = 2;
  ans[1] = 1;
  rep(i, N-1) {
    ans[i+2] = ans[i+1] + ans[i];
  }
  cout << ans[N] << endl;
}


Measured memory_bytes: 256
# B
# 2020/3/9  17:57-
n = int(input())
l = []
for i in range(n):
    ss, pp = map(str, input().split())
    l.append([ss, int(pp), i])
    
l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0])

for v in l:
    print(v[2]+1)

Measured memory_bytes: 3060
a,b,k = map(int, input().split())
count = 0
while count < k:
    if a+count <= b:
        print(a+count)
    count += 1
count = 0
while count < k:
    if b-k+1+count >= a+k:
        print(b - k + 1 + count)
    count += 1


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;++i)
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll k; string s;
    cin>>k>>s;
    if(s.length() <=k ) cout<<s;
    else
    {
        for(ll i=0;i<k;++i)
            cout<<s[i];
        cout<<"...";
    }
    return 0;
}
/**pair<ll,ll>fib(ll n)
{
    if(n==0) return {0,1};
    pair<ll , ll >p=fib(n/2);
    ll c=p.first*(2*p.second - p.first) ;
    ll d=p.second*p.second + p.first*p.first;
    if(n&1) return {d,c+d};
    else return {c,d};
}**/
/**ll biexp(ll a,ll n)
{
    if(n==0) return 1;
    ll res=1;
    while(n>0)
    {
        if(n%2!=0) res*=a;
        a=a*a;
        n=n/2;
    }
    return res;
}**/
/** sieve implementation**/
/**    ll N=100000;
    vector<ll>lp(N+1,0);
    vector<ll>pr;
    for(ll i=2;i<=N;++i)
    {
        if(lp[i]==0)
        {
            lp[i]=i;
            pr.push_back(i);
        }
        for(ll j=0;j<pr.size() and i*pr[j]<=N ;++j)
        {
            lp[i*pr[j]]=pr[j];
        }
    }
    **/
/**bool isprime(ll n)
{
    if(n<2) return false;
    for(ll i=2;i*i<=n;++i)
    {
        if(n%i==0) return false;
    }
    return true;
}**/
/**factors in sqrt(n);
    ll N=100000;
    vector<vector<ll> >factors(N+1);
    for(ll j=1;j<=N;++j)
    {
        for(ll x=1;x*x<=j;++x)
         {
            if(j%x==0)
            {
                factors[j].push_back(x);
                if(j/x != x) factors[j].push_back(j/x);
            }
         }
    }
**/
/**
vector<pair<ll,ll>>primefactors(ll n)
{
    vector<pair<ll,ll> >res; ll ct=0;
    if(!(n&1))
    {
        while(!(n&1))
        {
            ct++; n/=2;
        }
        res.push_back({2,ct});
    }
    ct=0;
    for(ll i=3;i*i<=n;i+=2)
    {
        while(n%i==0)
        {
            ct++; n/=i;
        }
        if(ct>0) res.push_back({i,ct});
        ct=0;
    }
    if(n!=1) res.push_back({n,1});
    return res;
}**/


Measured memory_bytes: 3640
fun main(args: Array<String>) = abc155c()
private inline fun printAnswer(function: StringBuilder.() -> StringBuilder) = print(StringBuilder().let(function))

fun abc155c() = printAnswer {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second

     map.filter { it.second == max }.map { it.first }.sorted().
         forEach { appendln(it) }

    return@printAnswer this
}


Measured memory_bytes: 112444
N, A, B = map(int, input().split())

Xs = list(map(int, input().split()))

rlt = 0
for i in range(1,N):
  if A*(Xs[i]-Xs[i-1]) >= B:
    rlt += B
  else:
    rlt += A*(Xs[i]-Xs[i-1])
    
print(rlt)

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

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

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int maxN = 100;
int x[maxN + 1];
int y[maxN + 1];
int h[maxN + 1];

signed main() {
  int n = read(), px, py, ph;
  REP(i, n) {
    x[i] = read();
    y[i] = read();
    h[i] = read();
    if (h[i] != 0)
      px = x[i], py = y[i], ph = h[i];
  }
  REP(tx, 101) REP(ty, 101) {
    bool ok = true;
    int th = ph + abs(px - tx) + abs(py - ty);
    REP(i, n) {
      int H = th - abs(tx - x[i]) - abs(ty - y[i]);
      chmax(H, 0);
      if (H != h[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      print(tx, 2);
      print(ty, 2);
      print(th);
      return 0;
    }
  }
}


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

typedef struct aml{
  int height;
  int a;
  int b;
  struct aml *next;
  struct aml *yoko;
  struct aml *yl;
}aml;

aml *top;
void add(int h,int a,int b){
  aml *i,*j,*n;
  if(top){
    for(i=top,j=i;i&&i->height>h;i=i->next)
      j=i;
    if(i&&i->height==h){
      if(i->yoko){
	i->yl->yoko=(aml *)malloc(sizeof(aml));
	i->yl=i->yl->yoko;
	i->yl->a=a;
	i->yl->b=b;
	i->yl->yoko=NULL;
      }else{
	i->yoko=(aml *)malloc(sizeof(aml));
	i->yoko->a=a;
	i->yoko->b=b;
	i->yoko->next=NULL;
	i->yoko->yoko=NULL;
	i->yl=i->yoko;
      }
    }else{
      n=(aml *)malloc(sizeof(aml));
      n->a=a;
      n->b=b;
      n->height=h;
      n->yoko=NULL;
      n->next=NULL;
      if(i==j){
	n->next=i;
	n->yl=n->yoko;
	top=n;
      }else if(i){
	n->next=i;
	j->next=n;
      }else{
	j->next=n;
      }
    }
  }else{
    top=(aml *)malloc(sizeof(aml));
    top->height=h;
    top->a=a;
    top->b=b;
    top->next=NULL;
    top->yoko=NULL;
    top->yl=NULL;
  }
}
int main(){
  int n,m,a,h,q,p,i;
  aml *j,*k;
  do{
    scanf("%d %d %d",&n,&m,&a);
    if(n==0&&m==0&&a==0) break;
    for(i=0;i<m;i++){
      scanf("%d %d %d",&h,&p,&q);
      add(h,p,q);
    }
    for(i=a,j=top;j;j=j->next){
      for(k=j;k;k=k->yoko){
	if(k->a==i){
	  i=k->b;
	}else if(k->b==i){
	  i=k->a;
	}
      }
    }
    printf("%d\n",i);
    top=NULL;
  }while(1);
  return 0;
}

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

bool is_prime[1100001];
int cav[2000][2000];
P mem[2000][2000];
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};

P dfs(int i,int j,int maxp){
  if(cav[i][j]>maxp)return P(0,0);
  if(mem[i][j]!=P(-1,-1))return mem[i][j];
  P res=P(0,0);
  if(i+1<2000){
    res=max(res,dfs(i+1,j,maxp));
    if(j-1>=0)res=max(res,dfs(i+1,j-1,maxp));
    if(j+1<2000)res=max(res,dfs(i+1,j+1,maxp));
  }
  if(is_prime[cav[i][j]]){
    if(res.first==0)res.second=cav[i][j];
    res.first++;
  }
  return mem[i][j]=res;
}

int main(void) {
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=1100000;i++)is_prime[i]=true;
  for(int i=2;i<=1100000;i++){
    if(is_prime[i]){
      for(int j=i*2;j<=1100000;j+=i)is_prime[j]=false;
    }
  }
  rep(i,2000)rep(j,2000)cav[i][j]=INF;
  int si=1000,sj=1000,len=1,num=1,dir=0;
  while(num<=1000000){
    rep(i,len){
      cav[si][sj]=num++;
      si+=dy[dir];
      sj+=dx[dir];
    }
    dir=(dir+1)%4;
    if(dir==0||dir==2)len++;
  }
  while(1) {
    int n,s;
    cin>>n>>s;
    if(n==0&&s==0)break;
    rep(i,2000)rep(j,2000)mem[i][j]=P(-1,-1);
    P res=P(0,0);
    rep(i,2000)rep(j,2000){
      if(cav[i][j]==s){
        res=dfs(i,j,n);
        break;
      }
    }
    printf("%d %d\n", res.first,res.second);
  }
  return 0;
}

Measured memory_bytes: 51104
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    int n,k;
    string s;
    cin >> n >> s >> k;
    char a = s[k-1];
    for (int i=0;i<n;i++){
        if(s[i] != a){
            cout << "*";
        }else{
            cout << s[i];
        }
    }
    cout << endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll n;
	cin >> n;
	if (n % 2 == 0)cout << 0.5 << endl;
	else {
		cout << setprecision(10) << (double)(n + 1) / 2 / n << endl;
	}
	ggr
}



Measured memory_bytes: 256
n, w = map(int, input().split())
e = tuple(map(int, input().split()) for _ in range(n))
wt, vt = zip(*e)

dp = tuple([0] * (w + 1) for _ in range(n + 1))

for i in range(n):
    dp[i + 1][:wt[i]] = dp[i][:wt[i]]
    for j in range(wt[i], w + 1):
        dp[i + 1][j] = max(dp[i][j], dp[i][j - wt[i]] + vt[i])
print(dp[n][w])


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

int mypow(int m, int n){
    int ans=1;
    for(int i=0;i<n;i++)
        ans*=m;
    return ans;
}

int64_t xx(int64_t num,int64_t ans,int n,int m){
    num %=mypow(10,n);
    ans+=num*mypow(2,m);
    n--;
    m++;
    if(num%10==0|n==0)
        return ans;
    else
        xx(num,ans,n, m);
}


int main(){

    int64_t s;
    int64_t ans=0;
    int n=0;
    
    cin>>s;
    int64_t keep=s;
    ans +=s;
    
    while(s!=0){
        s/=10;
        n++;
    }
    
    ans=xx(keep,ans,n-1,0);


    for(int i=0;i<n-1;i++){
        keep/=10;
        ans+=keep*mypow(2,i);
        if(i!=n-2)
        ans =xx(keep,ans,n-2-i,i);
    }

    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define rep(i,s,e)  for(int i=s;i<e;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set

const int mxn=100+13;
const int INF=1e18;
const int MXN=1e5+13;
int n,W;
int w[mxn],v[mxn];

int dp[mxn][MXN];

int func(int idx,int weight){
	if(idx==n || weight<=0) return 0;

	if(dp[idx][weight]!=-1) return dp[idx][weight];

	int ans=-INF;
	if(w[idx]<=weight)
		ans=max({ans,v[idx]+func(idx+1,weight-w[idx]),func(idx+1,weight)});
	else 
		ans=max({ans,func(idx+1,weight)});

	return dp[idx][weight]=ans;
}

void solve(){
	cin>>n>>W;

	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}

	memset(dp,-1,sizeof(dp));

	int ans=func(0,W);

	cout<<ans<<endl;

}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
// #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 88576
#include<iostream>
#include<set>
#include<tuple>
using namespace std;

int main()
{
  int N;
  cin>>N;
  set<tuple<string, int,int>> st;
  for(int i=0;i<N;i++){
    string tmp_string;
    int tmp_num;
    
    cin>>tmp_string>>tmp_num;
    st.insert(make_tuple(tmp_string,(100-tmp_num),i+1));
  }
  for(auto itr=st.begin();itr!=st.end();++itr){
    //int &i=get<2>(*itr);
    cout<<get<2>(*itr)<<endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int n; cin >> n;
	int cop = n;
	int sum = 0;
	while (cop) {
		sum += cop % 10; cop /= 10;
	}
	if (n%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int larger(int a,int b)
{
  if(a>b)
    return a;
  else
    return b;
}

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d\n",larger(larger(a+b,a-b),a*b));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
 #include <math.h>
using namespace std;
int main() {
  long N, M,ans;
  cin >> N >> M ;
  long tmp1,tmp2;
  if((M- N*2)<0){
    ans=M/2;
  }else{
  tmp1 = N;
  tmp2 = (M - N*2)/4;
  ans = tmp1 + tmp2;
  }
  std::cout << ans;
}

Measured memory_bytes: 256
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re


N = int(input())
X = list(map(int,input().split()))

ans = 1000000
for i in range(1,100+1):
    sum = 0
    for j in range(len(X)):
        sum += ( X[j] - i ) ** 2

    if sum < ans:
        ans = sum

print(ans)

Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
int64_t dp[105][100005];

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  dp[0][0] = 1;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= K; j++)
    {
      (dp[i + 1][j] += dp[i][j]) %= MOD;
      if (j + A.at(i) + 1 <= K)
      {
        dp[i + 1][j + A.at(i) + 1] -= dp[i][j];
        dp[i + 1][j + A.at(i) + 1] += MOD;
        dp[i + 1][j + A.at(i) + 1] %= MOD;
      }
    }
    for (int j = 1; j <= K; j++)
    {
      (dp[i + 1][j] += dp[i + 1][j - 1]) %= MOD;
    }
  }
  cout << dp[N][K] << endl;
}


Measured memory_bytes: 81676
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  for(int i=0; i<vec.size(); i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size()-1) << endl;
}

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int n = N/max(H,W);
  if(N%max(H,W)!=0) n++;
  cout << n << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem106b(n))
}

fun problem106b(n: Int): Int {
    fun countDivisor(n: Long): Long {
        var count = 0L
        for (i in 1..n) {
            if (n % i == 0L) count++
        }
        return count
    }
    var count = 0
    for (i in 1..n) {
        if (i % 2 != 0 && countDivisor(i.toLong()) == 8L) count++
    }
    return count
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int a,b;cin>>a>>b;
    string s;cin>>s;
    bool flag=true;
    rep(i,a+b+1){
        if(i==a){
            if(s[i]!='-')flag=false;
        }
        else if(s[i]=='-')flag=false;
    }
    cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = INT()
print(S[K-1])


Measured memory_bytes: 5712
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
ans = max(a+a-1,a+b,b+b-1)
print(ans)

Measured memory_bytes: 38384
k = int(input())
ans = 0
def gcd(a,b):
    if a % b == 0:
        return b
    c = a % b
    return gcd(b,c)

for l in range(1,k+1):
    for m in range(l,k+1):
        for n in range(m,k+1):
            tmp1 = gcd(l,n)
            tmp2= gcd(tmp1,m)
            if (l==m==n):
                ans+=tmp2
            elif(l==m or m==n):
                ans+= 3*tmp2
            else:
                ans += 6*tmp2


print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
const long long maxn=(1e5+10);
long long n,a[maxn],sm1=0,sm2=0;
int main()
{
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>a[i];
		if(i%2)
			sm1+=a[i];
		else
			sm2+=a[i];
		a[i]*=2;
	}
	vector<long long> ans;
	ans.push_back(sm2-sm1);
	cout<<sm2-sm1<<" ";
	for(long long i=0;i<n-1;i++)
	{
		ans.push_back(a[i]-ans[ans.size()-1]);
		cout<<ans[ans.size()-1]<<" ";
	}
	cout<<endl; 
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<ll> as(n);
  for(auto &a : as)
  {
	cin >> a;
  }
  sort(as.begin(), as.end());

  ll sum = 0;
  ll counter = 0;
  for(int i = 1; i < n; i++)
  {
	sum += as[i - 1];
	if(sum * 2 < as[i])
	{
	  counter = 0;
	}
	else
	{
	  counter++;
	}	
  }
  counter++;
  cout << counter << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    long long N,K;
    long long q=0;
    long long t=0;
    cin >> N >> K;

    if(K % 2 != 0){
        q=N / K;
        cout << q*q*q << endl; 
    }else{
        q = N/K;
        t = N/(K/2);
        cout << q*q*q + (t-q)*(t-q)*(t-q) << endl; 
    }

}


Measured memory_bytes: 256
#include<stdio.h>
int b[27*27*27*27*27]={0};
int main(){
  int n,i,j,a,m,r;
  char s[6];
  scanf("%d",&n);
  while(n--){
    scanf("%s %d",s,&a);
    for(i=m=0;s[i];i++){
      m*=27;
      m+=s[i]-'A'+1;
    }
    b[m]+=a;
  }//printf("%d\n",27*27*27*27*27);
  for(i=0;i<27*27*27*27*27;i++){
    if(b[i]==0)continue;
    r=0;
    for(j=i;j;j/=27)s[r++]=j%27+'A'-1;
    for(r--;r>-1;r--)printf("%c",s[r]);
    printf(" %d\n",b[i]);
  }
  return 0;
}

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


int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cout << fixed << setprecision(20);
   
   int n,ans=0; cin >> n;
   ans=n*n*n;
   cout << ans << endl;
}



Measured memory_bytes: 256
//kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,k,m,n,q;
	double x,y,z,r;
	for(;scanf("%d",&n),n;){
		vector<vector<double> >v;
		for(i=0;i<n;i++)scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v.push_back({x,y,z,r});
		for(i=0;i<n;i++)parent[i]=i;
		for(q=m=i=0;i<n;i++)for(j=i+1;j<n;j++){
			for(x=k=0;k<3;k++)x+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
			x=sqrt(x)-v[i][3]-v[j][3];
			if(x<=0){if(unite(i,j))q++;}
			else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
		}
		sort(node,node+m);
		for(x=i=0;i<m&&q<n-1;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first,q++;
		printf("%.3f\n",x);
	}
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<"\n";
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC101
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int K = input[1];

            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int n = 0;
            int res = 1;
            while (true)
            {
                if (N <= (K + n * K - n)) break;
                n++;
                res++;
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 18016
// ABC167 - B
function main(input) {
  var inputs = input.split('\n');
  var line1 = inputs[0].split(' ');
  var a = parseInt(line1[0], 10);
  var b = parseInt(line1[1], 10);
  var c = parseInt(line1[2], 10);
  var k = parseInt(line1[3], 10);

  var maxVal = 0;
  maxVal += k >= a ? a : k;
  if (k - a - b > 0) maxVal -= k - a - b;

  console.log(maxVal);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29796
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define head(xs) *(xs).begin()
#define last(xs) *(xs).rbegin()
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, l, t;
i64 x[100000], w[100000];

i32 main()
{
    cin >> n >> l >> t;
    l *= 2; t *= 2;
    times(n, i) {
        cin >> x[i] >> w[i];
        x[i] *= 2;
        w[i] = w[i] == 1 ? 1 : -1;
    }
    vec<pair<i64, i32>> ans(n);
    times(n, i) {
        i64 p = x[i] + t*w[i];
        p %= l;
        if (p < 0) p += l;
        if (w[i] < 0) p++;
        ans[i] = make_pair(p, i);
    }
    sortall(ans);
    i64 o = 0;
    upto(1, n - 1, i) {
        if (w[0] == w[i]) continue;
        i64 d;
        if (w[0] == 1) {
            d = (x[i] - x[0]) / 2;
        }
        else {
            d = (l - x[i] + x[0]) / 2;
        }
        i64 cnt = d < t ? 1 : 0;
        if (t > d) {
            cnt += (t - d) / (l / 2);
            if (((t - d) % (l / 2)) == 0) cnt--;
        }
        o += w[0] == 1 ? cnt : -cnt;
    }
    o = o % n;
    if (o < 0) o += n;
    i32 oi = 0;
    times(n, i) {
        if (ans[i].second == 0) {
            oi = i;
            break;
        }
    }
    oi = (oi + n - o) % n;

    upto(oi, n - 1, i) {
        cout << ans[i].first / 2 << endl;
    }
    upto(0, oi - 1, i) {
        cout << ans[i].first / 2 << endl;
    }
    return 0;
}

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

int main() {
    ll a[3000], n;
    ll sum = 0;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++){
        sum += (a[i] - 1);
        sum %= ll(pow (10, 9) + 7);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(m)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False
        self.ds_memo = {}
        self.ds_memo[1] = set([1])

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d


def M(n): return ModInt(n)
def MI(): return M(I())

class ModInt():
    def __init__(self, n):
        self.n = n

    def __add__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n+x) % mod)

    def __sub__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n-x) % mod)

    def __mul__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n*x) % mod)

    def __truediv__(self, x):
        x = ModInt.xn(x)
        return ModInt(self.n * pow(x, mod-2, mod) % mod)

    @classmethod
    def xn(cls, x):
        if isinstance(x, ModInt):
            return x.n
        return x

    def __str__(self):
        return str(self.n)

def main():
    n = I()
    a = LI()
    pr = Prime(10**12)
    ad = collections.defaultdict(int)
    da = []
    for c in a:
        d = pr.division(c)
        for k,v in d.items():
            if ad[k] < v:
                ad[k] = v
        da.append(d)
    ai = M(1)
    for k,v in ad.items():
        ai *= pow(k, v, mod)

    r = M(0)
    for c in a:
        r += ai / c

    return r


print(main())





Measured memory_bytes: 17548
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s =sc.next();
    System.out.println(solve(s));
  }

  private static int solve(String s) {
    int ret = 0;
    for(int i=0; i<s.length(); i++) {
      for(int j=i+1; j<=s.length(); j++) {
        ret = Math.max(ret, solve2(s.substring(i, j)));
      }
    }
    return ret;
  }
  
  private static int solve2(String s) {
    for(char c: s.toCharArray()) {
      if(c!='A' && c!='C' && c!='G' && c!='T') return 0;
    }
    return s.length();
  }
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int a,b,c;
    cin >> a >> b >> c;

    cout << min(b/a,c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,j,n) for(int i=j;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,sum,mn=inf;
signed main(){
	cin>>N;
	rep(i,N){
		int A;cin>>A;
		sum+=A;
		if(A%10)chmin(mn,A);
	}
	if(sum%10)cout<<sum<<"\n";
	else cout<<max(sum-mn,0ll)<<"\n";
}

Measured memory_bytes: 3620
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  s+=B[A[i]-1]
  if i!=0 and A[i-1]+1==A[i]:
    s+=C[A[i]-2]
print(s)

Measured memory_bytes: 9100
package main

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

const n = "\n"

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(scans())
	scans()
	for i := 0; i < h; i++ {
		b := scan()
		os.Stdout.Write(b)
		os.Stdout.WriteString(n)
		os.Stdout.Write(b)
		os.Stdout.WriteString(n)
	}
}

func scans() string {
	sc.Scan()
	return sc.Text()
}

func scan() []byte {
	sc.Scan()
	return sc.Bytes()
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int X){
	int i,k=sqrt(X);
    for(i=2;i<=k;i++)
    	if(X%i==0)
        	break;
    bool f=(i>k);
    return f;
}
int main(){
	int X,p1,p2;
    cin>>X;
    p1=p2=X;
    while(!isPrime(p1))
    p1--;
    while(!isPrime(p2))
    p2++;
    if(p1==p2)
    	cout<<p2<<endl;
    else if(p2-X==X-p1)
    	cout<<p2<<endl;
    else if(p2-X<X-p1)
    	cout<<p2<<endl;
    else
    	cout<<p2<<endl;
    return 0;
}
    

Measured memory_bytes: 256
let counting_sort a n k =
  let b = Array.make n 0 in
  let c = Array.make (k + 1) 0 in
  Array.iter (fun e -> c.(e) <- c.(e) + 1) a;
  for i = 1 to k do c.(i) <- c.(i) + c.(i-1) done;
  for i = n - 1 downto 0 do
    c.(a.(i)) <- c.(a.(i)) - 1;
    b.(c.(a.(i))) <- a.(i);
  done;
  b

let () =
  let n = read_int () in
  let a = Array.make n 0 in
  for i = 0 to n - 1 do
    a.(i) <- Scanf.scanf "%d " (fun i -> i);
  done;
  counting_sort a n 10000
  |> Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e);
  print_newline ()

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef sweety_candy
	freopen("input.txt","rt",stdin);
	freopen("ouput.txt","w",stdout);
#endif	
	int n, x, ans = 0;
	cin >> n;
	int MAX = -10000;
	for (int i = 0; i < n ; ++i){
		cin >> x;
		ans+=x;
	        MAX=max(MAX,x);
	}
	cout << (( ans - MAX <= MAX ) ? "No":"Yes");
#ifdef sweety_candy
	cout << " Time elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s;
  cin>>t;

	string ans;
	for (int i = 0; i < n; i++) {
		ans += s[i];
       ans+= t[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from itertools import permutations

def dist(P, Q):
    return ((P[0] - Q[0]) ** 2 + (P[1] - Q[1]) ** 2) ** 0.5

def main():
    N = int(input())
    points = tuple(tuple(map(int, input().split())) for _ in range(N))
    paths = list(permutations(list(range(N))))

    ans = 0
    for path in paths:
        for i in range(N-1):
            ans += dist(points[path[i]], points[path[i+1]])

    ans /= len(paths)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8052
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

s = 0
for i in range(N):
    s += B[A[i] - 1]
    if i < N - 1:
        if A[i] + 1 == A[i + 1]:
            s += C[A[i] - 1]

print(s)

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353 ;
const double PI = acos(-1);

int n,i,j,k,t;
int h[100002];
int dp[100002];

int main(){
    scanf("%d %d", &n, &k);
    for(i=0;i<n;++i)
        scanf("%d", h+i);
    dp[0] = 0;
    for(i=1;i<n;++i){
        dp[i] = abs(h[i] - h[i-1]) + dp[i-1];
        for(j=2;j<=min(i, k);++j){
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    printf("%d\n", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll A; cin >> A;
    double B; cin >> B;
    B *= 100;
    ll b = B+0.1;
    cout << A*b/100 << ln;
}

Measured memory_bytes: 3740
import sys

n,k=map(int,input().split())

if k==0:
    print(n*n)
    sys.exit()

s=0
for b in range(k+1,n+1):
    sb=0
    sb+=(n//b)*(b-k)
    c=n%b
    if c>=k:
        sb+=c-k+1
    s+=sb

print(s)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		int mod = (int) 1E9 + 7;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inputs = "";
		inputs = br.readLine();
		
		// Scanner in = new Scanner(System.in);
		char[] s = inputs.toCharArray(); // in.next().toCharArray();

		// i文字目までを13で割った余りがｊであるものの個数を格納する
		long dp[][] = new long[s.length][13];

		// 初期値
		if ( s[0] == '?' ) {
			for ( int n = 0; n < 10; n++ ) {
				dp[0][n] = 1;
			}
		} else {
			dp[0][s[0] - '0'] = 1;
		}

		// 1文字づつ見る
		for ( int i = 1; i < s.length; i++ ) {
			// 前回の余りrごとに見る
			for ( int r = 0; r < 13; r++ ) {
				
				if ( s[i] == '?' ) {
					for ( int now = 0; now < 10; now++ ) {
						dp[i][(r * 10 + now) % 13] += dp[i - 1][r];
					}

				} else {
					int now = s[i] - '0';
					dp[i][(r * 10 + now) % 13] += dp[i - 1][r];
				}
			}
			// %mod
			for ( int t = 0; t < 13; t++ ) {
				dp[i][t] %= mod;
			}
		}

		System.out.println(dp[s.length - 1][5]);
		// in.close();
		br.close();
	}
}


Measured memory_bytes: 36800
#include <fstream>
#include <iostream>

using namespace std;

int main(){
    string s, t;
    cin >> s>>t;
    int m, num, sum_num;
    num=0;
    sum_num=10000;
    m = s.size() -t.size()+1;
    for(int i =0;i<m ;i++){
        for(int j = 0;j<t.size();j++){
            if(s[i+j]!=t[j]) num++;
        }
        if(sum_num>num) sum_num = num;
        num=0;
    }
    cout << sum_num;
}

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

int main()
{
  int n;
  cin >> n;
  double a[n];
  string s[n];
  double ans = 0;
  rep(i,n){
    cin >> a[i];
    cin >> s[i];
    if(s[i] == "JPY") {
      ans += a[i];
    }
    else {
      ans += 380000 * a[i];
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  if(abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }
  long long ans=1;
  for(long long i=1ll;i<=n;i++)
    ans=ans*i%1000000007ll;
  for(long long i=1ll;i<=m;i++)
    ans=ans*i%1000000007ll;
  if(n==m)
    ans=ans*2%1000000007ll;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint d[300][300]; // MAX_V
void warshallfloyd(int v){ // N
  rep(i,v) rep(j,v) rep(k,v) d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
  return;
}

int main(void){
    int N;
    cin >> N;
    lint sum=0,after=0;
    rep(i,N) rep(j,N) cin >> d[i][j],sum+=d[i][j];
    warshallfloyd(N);
    rep(i,N) rep(j,N) after+=d[i][j];
    if(sum!=after){
        cout << -1 << endl;
        return 0;
    }
    lint ans=0;
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
        bool check=true;
        rep(k,N) if(k!=i && k!=j) if(d[i][k]+d[k][j]==d[i][j]) check=false;
        if(check) ans+=d[i][j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4312
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int sum=0,i,maxn=0;
    for(i=0;i<s.length();i++)
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        sum++;
        else
        {
            if(sum>maxn)
                maxn=sum;
            sum=0;
        }
        if(sum>maxn)
                maxn=sum;
    cout<<maxn;
    return 0;
}

Measured memory_bytes: 256
N, A, B = io.read("*n", "*n", "*n")
sumsum = 0
for i = 1, N do
    i = "0"..tostring(i)
    sum = 0
    for j = 1, #i do
        sum = sum + tonumber(i:sub(j,j))
    end
    if A <= sum and sum <= B then
        sumsum = sumsum + i
    end
end
print(string.format("%d", sumsum))

Measured memory_bytes: 376
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>  
 int a[2];
 int c;
 int main()
{
	while (~scanf("%d%d",&a[1],&a[2]))
	{
		c=2*a[2]-a[1];
	printf("%d\n",c);
	}
	return 0;
}

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

int n, cnt[26], mn[26]; 

int main() {
    cin >> n;
    memset(mn, 0x3f, sizeof(mn));
    while (n--) {
        string s;
        cin >> s;
        memset(cnt, 0, sizeof(cnt));
        for (auto c : s) cnt[c - 'a']++;
        for (int i = 0; i < 26; i++) mn[i] = min(mn[i], cnt[i]);
    }
    for (int i = 0; i < 26; i++) cout << string(mn[i], i + 'a');
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d,i,t,n;
	while(scanf("%d",&n)!=EOF){
		t=0;
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if(a+b+c+d==n){
							t++;
						}
					}
				}
			}
		}
		printf("%d\n",t);
	}
	return 0;
}


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


static const long long MAX = 100000000000000;


int main() {
  long long h, n;
  cin >> h >> n;

  vector<pair<long long,long long>> v(n);
  long long maxA=0;
  for (int i=0; i<n; i++) {
    cin >> v.at(i).first >> v.at(i).second;
    maxA = max(maxA, v.at(i).first);
  }

  vector<long long> dp(h+1+maxA,MAX);
  dp[0] = 0;
  for (int i=1; i<=h+maxA; i++) {
    for (auto e:v) {
      if (i - e.first >= 0 && dp.at(i-e.first) != MAX ) {
        dp.at(i) = min(dp.at(i), dp.at(i-e.first) + e.second);
      }
    }
  } 

  long long ans = MAX+1;
  for (int i=h; i<h+maxA; i++) {
    ans = min(ans, dp.at(i));
  }


  cout << ans << endl;
}

Measured memory_bytes: 512