akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;

vector<ll> groups;
vector<ll> dp;

void rec(int i, const vi& not_taken, int mask, int group, ll score) {
    
    if(i == (int) not_taken.size()) {
        dp[mask] = max(dp[mask], groups[group] + score);
        debug() << imie(mask) imie(dp[mask]);
        return; 
    }
    
    rec(i+1, not_taken, mask, group, score);
    rec(i+1, not_taken, (mask ^ (1 << not_taken[i])), (group ^ (1 << not_taken[i])), score);
}

int main() {
    
    int n;
    scanf("%d",&n);
    
    dp.assign((1 << n), -oo);
    groups.assign((1 << n), 0);
    vector<vector<ll>> in(n, vector<ll>(n));
    
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%lld",&in[i][j]);
        }
    }
    
    //preprocesar score que tendria un grupo
    //representado por un subset
    
    for(int mask = 0; mask < (1 << n); ++mask) {
        for(int i = 0; i < n; ++i) {
            if(!(mask & (1 << i))) {
                continue;
            }
            for(int j = i+1; j < n; ++j) {
                if(mask & (1 << j)) {
                    groups[mask] += in[i][j];
                }
            }
        }
    }
    
    dp[0] = 0;
    
    for(int mask = 0; mask < (1 << n); ++mask) {
        vi not_taken; //subset of take / skip
        for(int i = 0; i < n; ++i) {
            if(!(mask & (1 << i))) {
                not_taken.push_back(i);
            }
        }
        debug() << imie(mask) imie(dp[mask]);
        //(int i, const vi& not_taken, int mask, int group, ll score)
        rec(0, not_taken, mask, 0, dp[mask]);
    }
    
    printf("%lld\n", dp[((1 << n)-1)]);
    
    return 0;
}




Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	 int n, m, x, y;
	 cin >> n >> m >> x >> y; 
	 int a[n+10];
	 int b[m+10];
	 for ( int i = 1 ; i <= n ; i++ ){
	 	cin >> a[i]; 
	 }
	 for ( int i = 1 ; i <= m ; i++ ){
	 	cin >> b[i]; 
	 }
	 sort ( a + 1 , a + n + 1);
	 sort ( b + 1 , b + m + 1);
	if ( a[n] < b[1] && a[n] < y && b[1] > x)
		cout << "No War";
	else
		cout << "War"; 
} 

Measured memory_bytes: 256
function main()
    a,v,b,w,t = reads(Int,Int,Int,Int,Int)
    ans = abs(b-a) / (v-w)
    if ans < 0 || ans > t
        println("NO")
    else
        println("YES")
    end
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 196452
#include <iostream>


using namespace std;



int main()
{
 	int n;
  	cin >> n;
  	
  	while ( n != 0 )
    {
      if ((n % 10) == 7)
      {
		
       cout << "Yes"; 
       return 0;
      }
      else {
       n /= 10;
      }
    }
    cout << "No";
  return 0 ;
}


Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>A(N);
	int maxnum = -1;
	int next = -1;
	int cnt = 0;
	int place;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		maxnum = max(maxnum, A[i]);
	}
	for (int i = 0; i < N; i++)
	{
		if (A[i] == maxnum)
		{
			cnt++;
			place = i;
		}
		else
		{
			next = max(next, A[i]);
		}
	}
	if (cnt >= 2)
	{
		for (int i = 0; i < N; i++)cout << maxnum << " ";
	}
	else
	{
		for (int i = 0; i < N; i++)
		{
			if (i == place)cout << next << " ";
			else cout << maxnum << " ";
		}
	}
}

Measured memory_bytes: 3200
import bisect
def resolve():
    A, B, Q = list(map(int, input().split()))
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    X = [int(input()) for _ in range(Q)]
    #print("#####")
    for x in X:
        ans = float("inf")
        for Ary1, Ary2 in [[S, T], [T, S]]:
            ar1_nearests = get_nearest_pos(Ary1, x)
            for p in ar1_nearests:
                ar2_nearests = get_nearest_pos(Ary2, p)
                for p2 in ar2_nearests:
                    ans = min(ans, abs(x-p)+abs(p-p2))
        print(ans)

def get_nearest_pos(array, pos):
    res = []
    idx = bisect.bisect_left(array, pos)
    if idx == 0:
        res.append(array[idx])
    elif idx == len(array):
        res.append(array[idx-1])
    else:
        res.append(array[idx])
        res.append(array[idx-1])
    return res


if '__main__' == __name__:
    resolve()

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

typedef unsigned long long int ULONG;

int main(void){
  char buf[64] = { 0 };
  ULONG a,b,x;
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%ld %ld %ld", &a, &b, &x);
  
  ULONG ans = b/x - a/x;
  if(a % x == 0) ans++;
  
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b<=c)return 0*printf("0\n");
    int x=max(a,c);
    int y=min(b,d);
    if(x>y)return 0*printf("0\n");
    cout<<y-x<<endl;
}


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

int main(){
    const double PI = 4.0 * atan(1.0);
    double a, b, angle;
    scanf("%lf %lf %lf", &a, &b, &angle);
    
    double rad = (angle/180) * PI;
    double area = a*b*sin(rad)/2;
    printf("%.8lf\n", area);
    
    double length_c = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(rad));
    printf("%.8lf\n", a + b + length_c);

    double hight = b * sin(((180-angle)/180) * PI);
    printf("%.8lf\n", hight);
}



Measured memory_bytes: 2112
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=55;
char s[N];int n;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	s[n-7]='\0',printf("%s\n",s+1);
	return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
count = [int(input()) - 1 for _ in range(q)]
score = [0 for _ in range(n)]
for i in count:
    score[i] += 1
for i in score:
    if i <= q-k:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 8592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;
const int MOD = 1e9+7;

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i, 0, n) cin >> a[i];

    set<ll> s;
    rep(i, 0, n) s.insert(a[i]);

    if(n == s.size()) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(1000000007);
const ll MAXV = (ll)(1e5 - 100);
const ll MAXE = (ll)(1e6 + 10);


int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	ll a, b, c;

	cin >> a >> b >> c;

	ll dif = a - b;

	cout << c - min(dif, c) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

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

int main(int argc, char *argv[])
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> negative_work_count(N), positive_work_count(N);
  negative_work_count[0] = 1;
  stack<int> neg_pos, pos_pos;

  REP2(i, 1, N) {
    negative_work_count[i] = 1 + negative_work_count[i - 1];
    ll num0 = A[i - 1];
    ll num1 = A[i];

    if (num0 < num1) {
      while (num0 < num1) {
        num0 *= 4;
        if (neg_pos.empty()) {
          negative_work_count[i] += i * 2;
        } else {
          negative_work_count[i] += (i - neg_pos.top()) * 2;
          neg_pos.pop();
        }
      }
    } else {
      while (num0 >= num1 * 4) {
        num1 *= 4;
        neg_pos.push(i);
      }
    }
  }
  positive_work_count[N - 1] = 0;
  REPD(i, N - 1) {
    positive_work_count[i] = positive_work_count[i + 1];
    ll num0 = A[i];
    ll num1 = A[i + 1];
    if (num0 > num1) {
      while (num0 > num1) {
        num1 *= 4;
        if (pos_pos.empty()) {
          positive_work_count[i] += (N - i - 1) * 2;
        } else {
          positive_work_count[i] += (pos_pos.top() - i) * 2;
          pos_pos.pop();
        }
      }
    } else {
      while (num1 >= num0 * 4) {
        num0 *= 4;
        pos_pos.push(i);
      }
    }
  }

  ll res = 1e18;
  REP(i, N + 1) {
    ll neg = i > 0 ? negative_work_count[i - 1] : 0;
    ll pos = i < N ? positive_work_count[i] : 0;
    // cout << neg << " " << pos << endl;
    res = min(res, neg + pos);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=52,P=1000000007;
int n,m,F[N][N][N*N];
int main() {
	scanf("%d%d",&n,&m);
	F[0][0][0]=1;
	For(i,1,n)
		For(j,0,i) {
			For(k,0,m) {
				if(k>=2*(j+1)) F[i][j][k]=(F[i][j][k]+1LL*(j+1)*(j+1)*F[i-1][j+1][k-2*(j+1)])%P;
				if(j&&k>=2*(j-1)) F[i][j][k]=(F[i][j][k]+F[i-1][j-1][k-2*(j-1)])%P;
				if(k>=2*j) F[i][j][k]=(F[i][j][k]+1LL*(j+j+1)*F[i-1][j][k-2*j])%P;
			}
		}
	printf("%d",F[n][0][m]); 
	return 0;
}

Measured memory_bytes: 26240
#include<stdio.h>
int main()
{
    int i,j,k,l,t,N,a[100];
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&a[i]);
    for(j=0;j<N;j++)
    {
        t=a[j];
        l=j-1;
        while(l>=0&&a[l]>t)
        {
            a[l+1]=a[l];
            l--;
        }
        a[l+1]=t;
        for(k=0;k<N;k++)
        {
            if(k==N-1)
                printf("%d\n",a[k]);
            else printf("%d ",a[k]);
        }
    }
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

int main()
{
    FAST_IO;

    int a, b, t;
    scanf("%d %d %d", &a, &b, &t);
    printf("%d\n", (t/a) * b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        #define endl "\n"
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> d(M);
    vector<int> id(N, -1);
    cin >> d;
    REP(i, M) id[d[i] - 1] = i;
    int mask = (1 << M) - 1;
    vector<vector<int>> g(N, vector<int>(K));
    cin >> g;
    vector<int> dist(1 << M, INF);
    dist[mask] = 0;
    queue<int> q;
    q.push(mask);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        REP(i, K) {
            int w = 0;
            REP(j, M) {
                if (v >> j & 1) {
                    int idx = id[g[d[j] - 1][i] - 1];
                    if (idx == -1) continue;
                    w or_eq 1 << idx;
                }
            }
            if (chmin(dist[w], dist[v] + 1)) {
                q.push(w);
            }
        }
    }
    cout << dist[0] << endl;
    return 0;
}




Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;main(){int n,x,a[101],ans=0;cin>>n>>x;for(int i=0;i<n;i++){cin>>a[i];}sort(a,a+n);for(int i=0;i<n-1;i++){if(a[i]>x)break;x-=a[i];ans++;}cout<<(x-a[n-1]?ans:ans+1);}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    while(1){
        double n;
        vector<double> s(1000, 0);
        cin >> n;
        if(n==0) break;
        double sum = 0;
        FOR(i, 0, n){
            cin >> s[i];
            sum += s[i];
        }
        double m = sum / n;
        double sigma = 0;
        FOR(i, 0, n) sigma += pow((s[i] - m), 2);
        sigma /= n;
        sigma = sqrt(sigma);
        printf("%.05lf\n", sigma);
    }
}

Measured memory_bytes: 3212
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String n = reader.next();
		long total = 0;
		for (int i = 0; i < n.length(); i++) {
			total += Integer.parseInt("" + n.charAt(i));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		reader.close();
	}
	
}


Measured memory_bytes: 52764
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
  int n,ans=0; cin>>n;
  vector<ll> a(n);
  for(int i=0; i<n; i++) cin>>a[i];
  int res = a[0];
  for(int i=0; i<n; i++) {
    ans++;
    if(res==2) {
      cout<<ans;
      return 0;
    }
    res = a[res-1];
  }
  cout<<-1;
}

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

int MAXI = 100000 * 12 + 1;

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		cin >> c.at(i);
		for (int j = 0; j < m; j++) {
			cin >> a.at(i).at(j);
		}
	}

	int ans = MAXI;
	for (int cnt = 0; cnt < (1 << n); cnt++) {
		bitset<12> s(cnt);

		int money = 0;
		vector<int> a_temp = vector<int>(m);
		for (int i = 0; i < n; i++) {
			if (s.test(i)) {
				money += c.at(i);
				for (int j = 0; j < m; j++) {
					a_temp.at(j) += a.at(i).at(j);
				}
			}
		}
		
		bool flag = true;
		for (auto a_temp_ele : a_temp) {
			if (a_temp_ele < x) {
				flag = false;
			}
		}
		if (flag == true) {
			ans = min(ans, money);
		}
	}

	if (ans == MAXI) {
		ans = -1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long int
using namespace std;

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		map<int, int> mp;
		for (int i = 0; i < 2 * k; i++) {
			int d;
			cin >> d;
			for (int j = 0; j < d; j++) {
				int a;
				cin >> a;
				mp[a]++;
			}
		}
		cout << n - mp.size() << endl;
	}
	return 0;
}

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

int main(void){
  int X, A, B;
  cin >> X >> A >> B;
  if(A >= B)
    cout << "delicious" << "\n";
  else if(B - A <= X)
    cout << "safe" << "\n";
  else if(B - A > X)
    cout << "dangerous" << "\n";
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String num1 = br.readLine();
		String num2 = br.readLine();

		String[] str = num2.split(" ");

		int result = Integer.parseInt(num1);
		int[] list = new int[result];

		for (int i = 0; i < result; i++) {

			list[i] = Integer.parseInt(str[i]);
		}
		for (int i = result - 1; i >= 0 ; i--){
			System.out.print(list[i]);

			if (i == 0) {
				break;
			}
			System.out.print(" ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 24200
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}


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

const int MAXN = 1e6;
bitset<MAXN> mark;
vector<int> primes;

void crivo(void){
	mark.set();
	mark[0] = mark[1] = 0;
	for (int i = 2; i <= MAXN; i++){
		if (!mark[i]) continue;
		for (int j = i + i; j <= MAXN; j+=i){
			mark[j] = 0;
		}
		primes.push_back(i);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	crivo();
	int x;
	cin >> x;
	cout << *lower_bound(primes.begin(), primes.end(), x) << "\n"; 
	return 0;
}

Measured memory_bytes: 3928
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a;
		cin >> a;
		n -= a;
	}
	if (n >= 0) {
		cout << n << endl;
		return 0;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    cout << fixed << setprecision(6);
    int N;
    cin >> N;
    vector<double>v(N);
    rep(i,N)cin >> v.at(i);
    sort(v.begin(),v.end());
    double sum=v.at(0);
    rep(i,N-1){
        sum=(sum+v.at(i+1))/2;        
    }
    cout << sum << endl;
}

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

int main() {
  int N;
  int64_t K;
  int Q;
  int correct = 0;
  cin >> N >> K >> Q;
  vector<int> Score(N);
  for (int i = 0; i < N; i++){
    Score[i] = K - Q;
  }
  for (int i = 0; i < Q; i++){
    cin >> correct;
    Score[(correct - 1)]++;
  }
  for (int i = 0; i < N; i++){
    if (Score[i] > 0)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
  }
}


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

#define y1 hasjdnasd
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define t top()
#define pb push_back
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 1e2 + 5;
const int VAL  = 1e5 + 5;
int n , W , res;
int w[N] , v[N];
int dp[N][VAL];

main()
{
    //freopen("D.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    FOR(i , 1 , n)
        cin >> w[i] >> v[i];
    FOR(i , 1 , n)
        FOR(j , 0 , 1e5)
            dp[i][j] = 1e16;
    dp[1][0] = 0;
    dp[1][v[1]] = w[1];
    FOR(i , 2 , n)
        FOR(j , 0 , 1e5)
        {
            dp[i][j] = dp[i - 1][j];
            if(j >= v[i])
                dp[i][j] = min(dp[i][j] , dp[i - 1][j - v[i]] + w[i]);
        }
    FORD(j , 1e5 , 0)
        if(dp[n][j] <= W)
        {
            cout << j << "\n";
            exit(0);
        }
}


Measured memory_bytes: 79360
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    xy = LIR(n)
    f0 = [x - y for x, y in xy]
    f0.sort()
    f1 = [x + y for x, y in xy]
    f1.sort()
    print(max(f0[-1] - f0[0], f1[-1] - f1[0]))

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 124624
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {{typeid(int), "%d"},
                                                      {typeid(ll), "%lld"},
                                                      {typeid(double), "%lf"},
                                                      {typeid(char), "%c"}};

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	string s;
	cin >> s;

	for (const auto& c : "abcdefghijklmnopqrstuvwxyz") {
		if (count(ALL(s), c) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  auto tFormat = scanType[typeid(T)];
  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    a = (s == u) ? a - 1 : a;
    b = (t == u) ? b - 1 : b;

    cout << a << " " << b << "\n";
    return 0;
}



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    for (int i = 1; i < n - 1; i++){
        vector<int> b(3);
        b[0] = a[i - 1];
        b[1] = a[i];
        b[2] = a[i + 1];
        sort(b.begin(), b.end());
        if (a[i] == b[1])
            cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}



int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif



  double r;
  cin >> r;
  cout << fixed << setprecision(20) << (2 * 3.141592653589793238462643383279 * r) << endl;
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<bitset<60>> bit(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  for (int i=0; i<N; i++) {
    bitset<60> a(A[i]);
    bit[i] = a;
  }
  vector<ll> count1(60, 0);
  vector<ll> count0(60, 0);
  for (int i=0; i<60; i++) {
    for (int j=0; j<N; j++) {
      if (bit[j][i]) count1[i]++;
      else count0[i]++;
    }
  }
  ll mod = 1000000007;
  ll sum = 0;
  for (ll i=0; i<60; i++) {
    ll b = (1LL << i);
    sum += (((count0[i]*count1[i])%mod)*(b%mod))%mod;
    sum %= mod;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4992
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n;
	cin >> n;
	double ans = 0.0;
	for (int i = 0; i < n; i++)
	{
		double x;
		cin >> x;
		ans += (1 / x);
	}
	cout << 1/ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    x, n = map(int, input().split())
    p = set([int(v) for v in input().split()])
    ans = 0
    for i in range(1, 102):
        if i in p:
            continue
        if abs(x - i) < abs(x - ans):
            ans = i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61920
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  long long int q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;
  if(q * 2 < h) h = q * 2;
  if(h * 2 < s) s = h * 2;
  if(s * 2 < d) d = s * 2;
  long long int ans = 0;
  if(n % 2 == 1) {
    ans += d * (n / 2) + s;
  } else {
    ans += d * (n / 2);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
	static final long C =  1000000007;
	static final int CY = 1000000000;
	StringBuilder sb;
	public void calc() {
		sb = new StringBuilder();


		FastScanner sc = new FastScanner();

		String s = sc.next();


		long ans = 0;

		for (int i=0; i < s.length(); i++) {

			long num = Long.parseLong(s.charAt(i)+ "");
			long sum = 0;
			for (int t=0; t < s.length()-i; t++) {
				long n = (long)Math.pow(2, s.length()-t-1);
				if (i+t!=s.length()-1) {
					n/=2;
				}//System.out.println(num * Math.pow(10, t)*n);
				sum += num * Math.pow(10, t)*n;
			}
			ans += sum;
		}

		System.out.println(ans);
	}



	public static void main(String[] args) {
		Main main = new Main();
		main.calc();

	}
	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			}else{
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
		private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> like(m,0);
    for(int i = 0; i < n; i++)
    {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++)
        {
            int a;
            cin >> a;
            like.at(a-1)++;
        }
    }

    int ans = 0;
    for(int i = 0; i < m; i++)
    {
        if (like.at(i) == n) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

double dp[3005][3005];
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    int n; cin >> n;
    vec<double> p(n); rep(i,n) cin >> p[i];
    dp[0][0] = 1.0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= n; ++j) {
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }
    double ans = 0;
    for(int j = (n+1)/2; j <= n; ++j) {
        ans += dp[n][j];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> hs(n, 0);

    rep(i, n) {
        if (i == 0) {
            char c = s[i];
            int j = c - 'a';
            int next = 1 << j;
            hs[0] = next;
        } else {
            char c = s[i];
            int j = c - 'a';
            int next = hs[i - 1] ^(1 << j);
            hs[i] = next;
        }
    }


    vector<int> dp(n, -1);

    map<int, int> cache;
    cache[0] = -1;
    rep(i, n) if (cache.find(hs[i]) == cache.end()) cache[hs[i]] = i;


    auto set = [&](int i, int k) {
        if (dp[i] == -1) dp[i] = k;
        else
            cmin(dp[i], k);
    };


    auto get = [&](int i) {
        if (i == -1) return 0;
        return dp[i];
    };

    for (int i = 0; i < n; i++) {

        {
            dp[i] = get(i - 1) + 1;
            int current = hs[i];

            int j = cache[current];
            set(i, get(j) + 1);
        }

        rep(a, 26) {
            int current = (1 << a) ^hs[i];
            if (cache.find(current) == cache.end() || cache[current] >= i) continue;
            int j = cache[current];
            set(i, get(j) + 1);
        }

        if (dp[i] < dp[cache[hs[i]]]) {
            cache[hs[i]] = i;
        }

    }

    cout << dp[n - 1] << endl;

}


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

enum State{Carrot, End};

typedef struct Event{
    int x;
    State state;
    
    bool operator<( const Event& right ) const {
        return x>right.x;
    }
}Event;

int N, K, T, U, V, L;
vector<int> D;

int main(){
    cout.precision(16);
    cout.setf(ios::fixed);
    
    cin >> N >> K >> T >> U >> V >> L;
    D.resize(N);
    for(auto &v: D) cin >> v;
    
    priority_queue<Event> que;
    for(auto v: D)
        que.push(Event({v, Carrot}));
    
    vector<bool> zone(L);
    int count = 0;
    while(!que.empty()){
        auto event = que.top(); que.pop();
        if(event.state == Carrot){
            if(zone[event.x]){
                if(count < K){
                    count++;
                }else{
                    que.push({event.x + T*V, End});
                    for(int x=min(L, event.x+T*V)-1; event.x<=x && !zone[x]; x--)
                        zone[x] = true;
                }
            }else{
                que.push({event.x + T*V, End});
                for(int x=min(L, event.x+T*V)-1; event.x<=x && !zone[x]; x--)
                    zone[x] = true;
            }
        }else{
            if(count && event.x<L && !zone[event.x]){
                count--;
                que.push({event.x + T*V, End});
                for(int x=min(L, event.x+T*V)-1; event.x<=x && !zone[x]; x--)
                    zone[x] = true;
            }
        }
    }
    
    double span = 0;
    for(int i=0; i<L; i++)
        span += zone[i];
    
    cout << (L-span)/U + span/V << endl;
    
    return 0;
}

Measured memory_bytes: 3272
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=2e5+5;
ll n,q;
vector<ll> g[N];
int visited[N];

ll v[N];
void solve()
{
	cin>>n>>q;
	ll i,x,y;
	rep(i,0,n-1){
	cin>>x>>y;
	g[x].pb(y);
	g[y].pb(x);
	}
	
	while(q--)
	{
		cin>>x>>y;
		v[x]+=y;
	}
	queue<ll> q;
	q.push(1);
	while(!q.empty()){
		ll cur=q.front();
		q.pop();
		visited[cur]=1;
		for(auto j:g[cur]){
			if(!visited[j]){
				v[j]+=v[cur];
				q.push(j);
			}
		}
	}
	
	for(int i=1;i<=n;i++)
	cout<<v[i]<<" ";
}
 
int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 18672
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
ll a[105000];
ll b[105000];
ll c[105000];
ll fm[105000];
ll bmin[105000];

int main(){

	cin >> n;

	priority_queue<ll> bque;
	priority_queue<ll,vector<ll>,greater<ll>> fque;

	ll fsum = 0, msum = 0, bsum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		fsum += a[i];
		fque.push(a[i]);
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		msum += b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		bsum += c[i];
		bque.push(c[i]);
	}

	sort(a, a + n);
	sort(c, c + n);

	ll fa = fsum, ba = bsum;
	fm[0] = fa; bmin[n] = ba;
	//前半からi+1個取り除く
	//中間から取り除くこと考えてない
	for (int i = 0; i < n; i++) {
		fque.push(b[i]);
		ll fmin = fque.top();
		fque.pop();
		fa = fa + b[i] - fmin;
		fm[i+1] = fa;

		bque.push(b[n - 1 - i]);
		ll bmax = bque.top();
		bque.pop();
		ba = ba + b[n - 1 - i] - bmax;
		bmin[n-1-i] = ba;
	}
	
	//cout << fm[0] << " " << bmin[0] << endl;

	ll max = fm[0] - bmin[0];
	for (int i = 1; i <= n; i++) {

		//cout << fm[i] << " " << bmin[i] << endl;

		ll cur = fm[i] - bmin[i];
		if (max < cur)max = cur;
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 6004
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

ll opt[100010];

int main() {
	int n, w; scanf("%d %d", &n, &w);
	for (int i = 0; i < n; ++i) {
		ll iw, iv; scanf("%lld %lld", &iw, &iv);
		for (int cw = w; cw >= iw; --cw) opt[cw] = max(opt[cw], opt[cw-iw] + iv);
	}
	printf("%lld\n", opt[w]);
	return 0;
}

Measured memory_bytes: 896
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const string ds = "RDLU";
const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { 1, 0, -1, 0 };
struct state {
	int x, y, ban, len;
};
int dist[53][53][13][13];
int main() {
	int H, W, P;
	while (cin >> H >> W, H) {
		vector<string> S(H);
		int sx = -1, sy = -1, gx = -1, gy = -1;
		for (int i = 0; i < H; ++i) {
			cin >> S[i];
			if (S[i].find('S') != string::npos) sx = i, sy = S[i].find('S');
			if (S[i].find('G') != string::npos) gx = i, gy = S[i].find('G');
		}
		cin >> P;
		vector<string> ban(P);
		for (int i = 0; i < P; ++i) {
			cin >> ban[i];
		}
		sort(ban.begin(), ban.end());
		vector<string> rban;
		for (int i = 0; i < P; ++i) {
			bool flag = true;
			for (int j = 0; j < P; ++j) {
				if (ban[i] != ban[j] && ban[i].find(ban[j]) != string::npos) {
					flag = false;
				}
				if (ban[i] == ban[j] && i > j) {
					flag = false;
				}
			}
			if (flag) rban.push_back(ban[i]);
		}
		ban = rban;
		P = ban.size();
		memset(dist, -1, sizeof(dist));
		queue<state> que;
		que.push(state{ sx, sy, P, 0 });
		dist[sx][sy][P][0] = 0;
		int ans = -1;
		while (!que.empty()) {
			state s = que.front(); que.pop();
			int di = dist[s.x][s.y][s.ban][s.len];
			if (s.x == gx && s.y == gy) {
				if (ans == -1) ans = di;
				else ans = min(ans, di);
			}
			for (int i = 0; i < 4; ++i) {
				int tx = s.x + dx[i], ty = s.y + dy[i];
				if (0 <= tx && tx < H && 0 <= ty && ty < W && S[tx][ty] != '#') {
					bool incr = (s.ban != P && ban[s.ban][s.len] == ds[i]);
					int nxt_ban = s.ban, nxt_len = s.len;
					if (incr) {
						++nxt_len;
					}
					else {
						string recent = (s.ban == P ? "" : ban[s.ban].substr(0, s.len)) + ds[i];
						nxt_ban = P; nxt_len = 0;
						for (int j = s.len + 1; j > 0; --j) {
							int ptr = -1;
							for (int k = 0; k < P; ++k) {
								if (recent.substr(s.len - j + 1) == ban[k].substr(0, j)) {
									ptr = k;
								}
							}
							if (ptr != -1) {
								nxt_ban = ptr;
								nxt_len = j;
								break;
							}
						}
					}
					if (nxt_ban != P && nxt_len == ban[nxt_ban].length()) continue;
					if (dist[tx][ty][nxt_ban][nxt_len] == -1) {
						dist[tx][ty][nxt_ban][nxt_len] = di + 1;
						que.push(state{ tx, ty, nxt_ban, nxt_len });
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5056
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cnt = 0;
        if (n % 3 == 0) {
            cnt = n / 3;
        } else {
            while (true) {
                if (n < 3) break;
                if (n - 3 >= 3) {
                    n -= 3;
                    cnt++;   
                } else {
                    cnt++;
                    break;
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21972
H, N = map(int, input().split())
ATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N)))
MAX_ATK = max(ATK)
table = [0] * (H + MAX_ATK)
for damage in range(1, H + 1):
    table[damage] = min(table[damage - ATK[magic]] + MP[magic] for magic in range(N))
print(table[H])


Measured memory_bytes: 42588
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<vector>
using namespace std;
int flag[11];
int main()
{
	int N,K,m,flagg=0;
	scanf("%d%d",&N,&K);
	for(int i=0;i<K;i++)
	{
		scanf("%d",&m);
		flag[m]=1;
	}
	int n=N;
	while(n)
	{
		if(flag[n%10]==1)
		flagg=1;
		n/=10;
	}
	if(flagg==0)
	printf("%d\n",N);
	else
	{
		int ans=0;
		for(int i=N+1;;i++)
		{
			n=i;
			flagg=1;
			while(n)
			{
				if(flag[n%10]==1)
				{
					flagg=0;
					break;
				}
				n/=10;
			}
			if(flagg==1)
			{
				ans=i;
				break;
		    }
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 256