akhauriyash/Code-Regression huggingface dataset:
H, W = gets.split.map(&:to_i)

counter = Hash.new(0)

H.times do
  row = gets.chomp

  row.each_char do |a|
    counter[a] += 1
  end
end

parts_counter = Hash.new(0)

counter.each do |_, cnt|
  d, remain = cnt.divmod(4)
  parts_counter[4] += d

  e, m = remain.divmod(2)
  parts_counter[2] += e
  parts_counter[1] += m
end

need_parts = Hash.new(0)

visited = Array.new(H) { Array.new(W, false) }

H.times do |y|
  W.times do |x|
    next if visited[y][x]

    ny = H - y - 1
    nx = W - x - 1

    list = [[y, x], [y, nx], [ny, x], [ny, nx]]

    list.each do |cy, cx|
      visited[cy][cx] = true
    end

    cnt = list.uniq.size
    need_parts[cnt] += 1
  end
end

[4, 2, 1].each do |v|
  cnt = need_parts[v]

  if parts_counter[v] < cnt
    puts 'No'
    exit
  end

  parts_counter[v] -= cnt

  if v == 4
    parts_counter[2] += 2 * parts_counter[4]
  end
end

puts 'Yes'


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int h, w; cin >> h >> w;
  char a[w][h];
  int cnt = 0;
  for(int y = 0; y < h; y++) {
    for(int x = 0; x < w; x++) {
      cin >> a[x][y];
      if(a[x][y] == '#') cnt++;
    }
  }
  if(cnt == h+w-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<stack>

using namespace std;

int main(){
    int N;
    vector<int> T;
    int sum=0;

    cin>>N;
    for(int i=0;i<N;i++){
        int TT;
        cin>>TT;
        sum+=TT;
        T.push_back(TT);
    }

    int X;
    cin>>X;
    for(int i=0;i<X;i++){
        int P,X;
        cin>>P>>X;
        cout<<sum-T[P-1]+X<<endl;
    }


}


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

int main(){
  string s;
  cin >> s;
  int i=0;
  bool ans = true;
  while(s[i] && ans){
    if((i+1) % 2 == 1){
      if(s[i] == 'L'){
	ans = false;
      }
    }else{
      if(s[i] == 'R'){
	ans = false;
      }
    }
    i++;
  }
  if(ans){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}


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

template<typename T> class SegmentTree {
  private:
  int n, sz, h;
  vector<T> node, lazy;
  void eval(int k) {
    if (lazy.at(k)) {
      node.at(k) += lazy.at(k);
      if (k < n) lazy.at(k * 2) += lazy.at(k) / 2, lazy.at(k * 2 + 1) += lazy.at(k) / 2;
      lazy.at(k) = 0;
    }
  }
  public:
  SegmentTree(const vector<T> &v) : sz((int) v.size()), h(0) {
    n = 1;
    while (n < sz) n *= 2, h++;
    node.resize(2 * n, 0), lazy.resize(2 * n, 0);
    for (int i = 0; i < sz; i++) node.at(i + n) = v.at(i);
    for (int i = n - 1; i >= 1; i--) node.at(i) = node.at(2 * i) + node.at(2 * i + 1);
  }
  void range(int a, int b, T x) {
    a += n, b += n - 1;
    for (int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
    int ta = a, tb = b++, length = 1;
    while (a < b) {
      if (a & 1) lazy.at(a++) += length * x;
      if (b & 1) lazy.at(--b) += length * x;
      a >>= 1, b >>= 1, length <<= 1;
    }
    while (ta >>= 1, tb >>= 1, ta) {
      if (!lazy.at(ta)) {
        eval(2 * ta), eval(2 * ta + 1), node.at(ta) = node.at(2 * ta) + node.at(2 * ta + 1);
      }
      if (!lazy.at(tb)) {
        eval(2 * tb), eval(2 * tb + 1), node.at(tb) = node.at(2 * tb) + node.at(2 * tb + 1);
      }
    }
  }
  T query(int a, int b) {
    a += n, b += n - 1;
    for (int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
    b++;
    T res1 = 0, res2 = 0;
    while (a < b) {
      if (a & 1) eval(a), res1 += node.at(a++);
      if (b & 1) eval(--b), res2 += node.at(b);
      a >>= 1, b >>= 1;
    }
    return res1 + res2;
  }
};

int main() {
  long N, D, A;
  cin >> N >> D >> A;
  vector<pair<long, long>> V(N);
  for (long i = 0, x, h; cin >> x >> h; i++) V.at(i) = {x, h};
  sort(V.begin(), V.end());
  vector<long> X(N), H(N);
  for (long i = 0; i < N; i++) {
    X.at(i) = V.at(i).first;
    H.at(i) = V.at(i).second;
  }
  SegmentTree<long> ST(H);
  long ans = 0;
  for (long i = 0; i < N; i++) {
    int hp = ST.query(i, i + 1);
    if (hp <= 0) continue;
    int cnt = (hp + A - 1) / A;
    ans += cnt;
    long range = X.at(i) + D + D;
    auto it = upper_bound(X.begin(), X.end(), range) - X.begin();
    ST.range(i, it, -(cnt * A));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 17740
#include<iostream>
#include<string>
#include<set>
#define r(s) string(s.rbegin(),s.rend())
using namespace std;main(){int n,i;string s,h,t;for(cin>>n;cin>>s;){set<string> l;for(i=0;++i<s.size();)for(h=s.substr(0,i),t=s.substr(i),n=0;n++<2;swap(h,t)){l.insert(h+t);l.insert(r(h)+t);l.insert(h+r(t));l.insert(r(h)+r(t));}cout<<l.size()<<endl;}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int h[N];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h + n);
    ll ans = 0;
    for(int i = 0; i < n-k; i++) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <bits/stdc++.h>
using namespace std;
long long int dp[3001][3001][2];
int l;
long long int solve(long long int *arr,int i,int j,int turn)
{
    if(i>j || i>l || j<0)
    {
        return 0;
    }
    if(dp[i][j][turn]!= -1)
    {
        return dp[i][j][turn];
    }
    if(turn==1)
    {
        dp[i][j][turn] = max(arr[i]+solve(arr,i+1,j,0),arr[j]+solve(arr,i,j-1,0));
    }
    else
    {
        dp[i][j][turn] = min(solve(arr,i+1,j,1),solve(arr,i,j-1,1));
    }
    return dp[i][j][turn];
}
int main()
{
    int n;
    cin>>n;
    memset (dp,-1,sizeof(dp));
    long long int arr[3001];
    long long int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    l=n;
    long long int X = solve(arr,1,n,0);
    long long int Y = sum-X;
    cout<<Y-X<<endl;
    return 0;
}


Measured memory_bytes: 144552
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

bool prime(int n) {
    if (n == 2) return true;
    else if (n % 2 == 0) return false;
    for (int i = 3; i <= sqrt(n); i+=2) {
        if (n % i == 0) return false;
    }
    return true;
}

vector<int> primeList;

void findPrimes(int k) {
    int smallestIndex = 0;
    REP(i,primeList.size()) {
        if (k <= primeList[i]) {
            smallestIndex = i - 1;
            break;
        }
    }
    cout <<primeList[smallestIndex] << " ";
    if (primeList[smallestIndex + 1] == k) {
        cout << primeList[smallestIndex + 2] << endl;
    }else {
        cout << primeList[smallestIndex + 1] << endl;
    }
}

int main() {
    FOR(i,2,51000) {
        if (prime(i)) primeList.push_back(i);
    }
    int k;
    while(cin >> k) {
        findPrimes(k);
    }
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
main(){string s,t,u;cin>>s>>t;long a=0,i=0;for(u=s;a+1&&i<t.size();i++){int x=u.find_first_of(t[i]);u.erase(u.begin(),u.begin()+x+1);if(u.size()<s.size())u+=s;a=x<0?-1:a+x+1;}cout<<a;}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;


vector<ll> a(0);
vector<ll> b(0);
vector<pair<ll,ll>> res(0);
bool cmp(ll p1, ll p2) {return p2<p1;}
bool ok(ll m, ull k, ll n){
    ull summ=0;
    for(int i=0;i<n;i++){
        if(res[i].first>m){
            summ+=(res[i].first-m+res[i].second-1)/res[i].second;
        }
    }
    return summ<=k;
}
vector<vector<int>> vect(602, vector<int>(0));
vector<double > dp(603);
int inf =1e7;
int main() {
    int n;
    int m;
    cin>>n>>m;
    dp[n]=0;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        vect[a].push_back(b);
    }
    for(int i=n-1;i>=1;i--){
        double si=vect[i].size();
        dp[i]=0;
        for(int son:vect[i]){
            dp[i]+=dp[son];
        }
        if(si!=0){
            dp[i]/=si;
            dp[i]+=1.;
        }
        else dp[i]=inf;
    }
    cout.precision(10);
    double ans=dp[1];
    for(int i=n-1;i>=1;i--){
        if(vect[i].size()<=1) continue;
        vector<double> dp_new(dp.size(), 0);
        for(int j=n;j>i;j--) dp_new[j]=dp[j];
        double mi=-1.;
        int ind=-1;
        for(int j:vect[i]){
            if(mi<dp[j]){
                mi=dp[j];
                ind=j;
            }
        }
        if(ind==-1) continue;
        dp_new[i]=0;
        for(int j:vect[i]){
            if(j==ind) continue;
            dp_new[i]+=dp_new[j];
        }
        dp_new[i]/=(vect[i].size()-1.);
        dp_new[i]+=1.;
        for(int j=i-1;j>=1;j--){
            double si=vect[j].size();
            dp_new[j]=0;
            for(int son:vect[j]){
                dp_new[j]+=dp_new[son];
            }
            if(si!=0){
                dp_new[j]/=si;
                dp_new[j]+=1.;
            }
            else dp_new[j]=inf;
        }
        ans=min(ans, dp_new[1]);
    }
    cout<<fixed<<ans;
    return 0;
}

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

def main():

    N, X = map(int, input().split())
    m = []
    for i in range(N):
        m.append(int(input()))

    sumM = 0
    ans = 0

    flag = False

    for i in m:
        sumM += i
        ans += 1

    remain = X - sumM

    minM = min(m)

    remainNum = remain // minM

    ans += remainNum

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    string s;
    cin >> s;
    sort(All(s));
    puts(s == "abc" ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))


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

    long long p[N];
    for(long long i=0;i<N;i++){
        cin >> p[i];
    }
    
    sort(p,p+SIZE_OF_ARRAY(p));
   
   for(long long i=0;i<K;i++){
       ans += p[i];
   }
   
   cout << ans << endl;

}

Measured memory_bytes: 3640
local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end

local edge = {}
local asked = {}
local cpos = {}
local len = {}
local stpos = {}
for i = 1, n do
  edge[i] = {}
  asked[i] = false
  cpos[i] = 0
  len[i] = 0
  stpos[i] = 0
end
len[n + 1] = 1000000007
for i = 1, n - 1 do
  local x, y = io.read("*n", "*n")
  table.insert(edge[x], y)
  table.insert(edge[y], x)
end

local lis = {}
for i = 1, n + 1 do
  lis[i] = 1000000007
end
local ret = {}
for i = 1, n do ret[i] = 1 end
local tasks = {1}
local undotask = {}
local sti = 1
while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  -- print(src)
  if src == -1 then
    local ubpos, v, z = undotask[#undotask][1], undotask[#undotask][2], undotask[#undotask][3]
    table.remove(undotask)
    lis[ubpos] = v
    -- print("UNDO", z, ubpos, v)
  else
    if not asked[src] then
      asked[src] = true
      local ubpos = lower_bound(lis, t[src])
      table.insert(undotask, {ubpos, lis[ubpos], src})
      -- print("ADD", src, ubpos, lis[ubpos])
      lis[ubpos] = t[src]
      local r = lower_bound(lis, 1000000007) - 1
      ret[src] = r
    end
    -- print(src, len[src])
    stpos[src] = sti
    sti = sti + 1
    while cpos[src] < #edge[src] do
      cpos[src] = cpos[src] + 1
      local dst = edge[src][cpos[src]]
      if not asked[dst] then
        len[dst] = len[src] + 1
        table.insert(tasks, src)
        table.insert(tasks, -1)
        table.insert(tasks, dst)
        break
      end
    end
  end
end
print(table.concat(ret, "\n"))


Measured memory_bytes: 95652
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    graph = []
    for _ in range(M):
        a, b, c = map(int, rl().split())
        a -= 1
        b -= 1
        c *= -1
        graph.append([a, b, c])
    
    def bellman_ford(s):
        dist_ls = [10 ** 15] * N
        dist_ls[s] = 0
        for i in range(N):
            for s, t, w in graph:
                if dist_ls[s] + w < dist_ls[t]:
                    dist_ls[t] = dist_ls[s] + w
                    if i == N - 1 and t == N - 1:
                        return -1
        return dist_ls
    
    dist = bellman_ford(0)
    if dist == -1:
        print('inf')
    else:
        print(-1 * dist[-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3484
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
bool test(LL a,LL b,LL c,LL d) {
    if(a<b) return 0;
    if(d<b) return 0;
    if(c>=b) return 1;
    //cout<<"fnsdfkj ";
    LL huj=a-c+b-1;
    huj/=b;
    huj*=b;
    LL poc=a-huj;
    //de(poc);
    LL sko=d%b;
    LL nwm=__gcd(sko,b);
    //de(nwm);
    LL naj=b-poc-1;
    naj/=nwm;
    naj*=nwm;
    naj+=poc;
    //de(naj);
    if(naj>c) return 0;
    return 1;
}
int32_t main(void) {
    int qwe;
    cin>>qwe;
    while(qwe--) {
        LL a,b,c,d;
        cin>>a>>b>>c>>d;
        if(test(a,b,c,d)) cout<<"Yes\n";
        else cout<<"No\n";
    }
}
/*
1
9 7 6 9
*/


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

const int N_MAX = 1000;
const int M_MAX = 1000;
typedef long long ll;
ll dp[N_MAX + 1][M_MAX + 1];

int D[N_MAX + 1];
int C[M_MAX + 1];

int N;
int M;

int main()
{
	cin >> N;
	cin >> M;
	for(int i = 0;i < N;i++)
	{
		cin >> D[i];
	}
	for(int i = 0;i < M;i++)
	{
		cin >> C[i];
	}
	
	for(int i = 0;i < N_MAX + 1;i++)
	{
		for(int j = 0;j < M_MAX + 1;j++)
		{
			dp[i][j] = 1000000000000000000;
		}
	}
	for(int i = 0;i < M_MAX + 1;i++)
	{
		dp[i][0] = 0;
	}
	
	for(int i = 0;i < M;i++)
	{
		for(int j = -1;j < N;j++)
		{
			if(j == -1)
			{
				dp[i+1][j+1] = dp[i][j+1];
			}
			else
				dp[i + 1][j + 1] = min(dp[i][j+1],dp[i][j] + D[j] * C[i]);
		}
	}
	cout << dp[M][N] << endl;
	return 0;
}

Measured memory_bytes: 10924
//=================================
// Created on: 2018/07/07 21:03:01
//=================================
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
mt19937 mt{random_device{}()};
struct CostGraph
{
    using T = ll;
    CostGraph(const int v) : V{v}, edge(v), rev_edge(v) {}
    struct Edge
    {
        Edge(const int from, const int to, const T cost) : from{from}, to{to}, cost{cost} {}
        const int from, to;
        const T cost;
        bool operator<(const Edge& e) const { return cost != e.cost ? cost < e.cost : to < e.to; }
    };
    void addEdge(const int from, const int to, const T cost)
    {
        edge[from].push_back(Edge{from, to, cost}), rev_edge[to].push_back(Edge(to, from, cost));
    }
    const int V;
    vector<vector<Edge>> edge, rev_edge;
};
vector<CostGraph::T> Dijkstra(const CostGraph& g, const int s)
{
    using T = CostGraph::T;
    vector<T> d(g.V, INF<T>);
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.push(make_pair(0, s));
    while (not q.empty()) {
        const T cost = q.top().first;
        const int v = q.top().second;
        q.pop();
        if (d[v] < cost) { continue; }
        for (const auto& e : g.edge[v]) {
            if (d[e.to] <= d[v] + e.cost) { continue; }
            d[e.to] = d[v] + e.cost, q.push({d[e.to], e.to});
        }
    }
    return d;
}

int main()
{
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--, T--;
    CostGraph g1(N), g2(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        ll a, b;
        cin >> a >> b;
        g1.addEdge(u, v, a), g1.addEdge(v, u, a);
        g2.addEdge(u, v, b), g2.addEdge(v, u, b);
    }
    const auto d1 = Dijkstra(g1, S);
    const auto d2 = Dijkstra(g2, T);
    vector<ll> ans(N);
    constexpr ll MAX = 1000000000000000LL;
    for (int i = 0; i < N; i++) { ans[i] = MAX - d1[i] - d2[i]; }
    for (int i = N - 2; i >= 0; i--) { ans[i] = max(ans[i], ans[i + 1]); }
    for (int i = 0; i < N; i++) { cout << ans[i] << endl; }
    return 0;
}


Measured memory_bytes: 34048
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	var ans int
	for i := range a {
		if i%2 == 0 {
			ans += a[i]
		} else {
			ans -= a[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (N, Q) = readInputLine().split(" ").map { it.toInt() }

    val parent = IntArray(N)
    val ans = LongArray(N)
    
    for (i in 1..N-1) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() }
        parent[b - 1] = a - 1
    }
    
    for (i in 1..Q) {
        val (p, x) = readInputLine().split(" ").map { it.toInt() }
        ans[p - 1] += x.toLong()
    }

    for (i in 1 until N) {
        ans[i] += ans[parent[i]]
    }

    println(ans.joinToString(" "))
}

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


Measured memory_bytes: 119096
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
std::ios::sync_with_stdio(false);
  ll k;
  cin >> k;
  int n = 50;
  vl a(n, n - 1 + k / n);
  for (int i = 0; i < k % n; ++i) {
    a[i] += n;
    for (int j = 0; j < n; ++j) if (i != j) --a[j];
  }
  cout << n << endl;
  for (int i = 0; i < n; ++i) {
    cout << a[i] << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }   
    vector<int> B = A;
    SORT(B);
    REP(i, N){
        if(A[i] == B.back()) pr(B[N-2]);
        else pr(B.back());
    }
}

Measured memory_bytes: 3200
from collections import deque
from math import log10

K = int(input())

que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])


for _ in range(K):
    v = que.popleft()
    # print(v)
    d = int(log10(v)+1)
    res = v
    
    l = v % 10

    if l != 0: que.append(v*10 + l-1)
    que.append(v*10 + l)
    if l != 9: que.append(v*10 + l+1)

print(res)

Measured memory_bytes: 11960
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.range;
import std.typecons;
import std.algorithm;

struct RMQSegmentTree(Type = int,string gstr = "a>b"){
	Type[] data;
	size_t height;
	Type initvalue;

	bool greater(Type a,Type b){
		bool ret;
		mixin("ret = "~gstr~";");
		return ret;
	}

	Type greatValue(Type a,Type b){
		if(greater(a,b))
			return a;
		return b;
	}

	void SetSize(size_t size){
		size_t s = 1;
		height = 0;
		while(s<size){
			s*=2;
			++height;
		}
		data = new Type[s*2];
		initvalue = Type.max - greatValue(Type.max,Type.min);
		data[] = initvalue;
	}

	size_t GetIdx(size_t idx,size_t depth){
		size_t blocksize = 1<<depth;
		return blocksize-1+(idx/blocksize)*blocksize*2;
	}

	void SetData(size_t idx,Type value,size_t depth = 0){
		if(depth > height)
			return;
		size_t gi = GetIdx(idx,depth);
		if(greater(value,data[gi])){
			data[gi] = value;
			SetData(idx,value,depth+1);
		}
	}

	Type GetRMQ(size_t begin,size_t end,size_t depth = -1){
		if(depth == -1)
			depth = height;
		if(begin == end)
			return initvalue;
		size_t blocksize = 1<<depth;
		size_t start = begin - begin%blocksize;
		if(start == begin && start + blocksize == end)
			return data[GetIdx(begin,depth)];
		blocksize /= 2;
		Type ret = initvalue;
		if(begin < start + blocksize)
			ret = greatValue(ret, GetRMQ(begin,min(start + blocksize, end), depth-1));
		if(end > start + blocksize)
			ret = greatValue(ret, GetRMQ(max(begin,start + blocksize), end, depth-1));
		return ret;
	}
}

int[] rdi(){
	return readln.split.map!(to!int).array;
}

void main(){
	int n= rdi[0];
	int[] w;
	w = rdi;
	RMQSegmentTree!long st;
	st.SetSize(n);
	long[] dp = new long[n];
	dp[] = 0;
	foreach(i;0..n){
		dp[i] = st.GetRMQ(0,w[i]);
		dp[i] += w[i];
		st.SetData(w[i]-1,dp[i]);
	}
	long res = 0;
	foreach(i;0..n){
		res += w[i];
	}
	long md = 0;
	foreach(i;0..n){
		md = max(md,dp[i]);
	}
	(res-md).writeln;
}

Measured memory_bytes: 8064
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int n,a[200000];
deque<int> deck;
bool rev=0;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        if(!rev){
            deck.push_back(a[i]);
            rev=1;
        }
        else{
            deck.push_front(a[i]);
            rev=0;
        }
    }
    if(!rev){
        printf("%d",deck.front());
        deck.pop_front();
        for(int i=1;i<n;i++){
            printf(" %d",deck.front());
            deck.pop_front();
        }
    }
    else{
        printf("%d",deck.back());
        deck.pop_back();
        for(int i=1;i<n;i++){
            printf(" %d",deck.back());
            deck.pop_back();
        }
    }
    puts("");
    return 0;
}

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

using namespace std;

typedef long long ll;

void ignore() {
    while (getchar() != '\n');
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    long W, a, b;

    scanf("%ld %ld %ld", &W, &a, &b);

    if (b < a) swap(a, b);

    printf("%ld\n", max((long)0, b - (W + a)));

    return 0;
}


Measured memory_bytes: 128
import collections as col
A = []
A = col.deque(A)
n, q = map(int,input().split())
name = {}
time = []
for i in range(n):
    temp = input().split()
    name[temp[0]] = i
    time.append(int(temp[1]))

for x in name.keys():
    A.append(x)
t = 0

while len(A) > 0:
    if time[name[A[0]]] > q:
        time[name[A[0]]] -= q
        t += q
        A.append(A.popleft())
    else:
        t += time[name[A[0]]]
        print(A.popleft(),t)


Measured memory_bytes: 14000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	char a,b;
	cin>>a>>b;

	if(a=='H'){
		if(b=='H') cout << 'H' << endl;
		else cout << 'D' << endl;
	}else{
		if(b=='H') cout << 'D' << endl;
		else cout << 'H' << endl;
	}
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t count = 0;
    int64_t prev = 0;
    for (decltype(N) i = 1; i <= N; ++i) {
        int64_t t;
        std::cin >> t;

        if (prev == 1 && t > 0) {
            count++;
            prev = 0;
            t--;
        }

        count += t / 2;

        if (t % 2 == 1) {
            prev = 1;
        }
        else {
            prev = 0;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


void main() {
    writeln(readln.chomp.split.map!(to!long).take(2).reduce!"a * b" / 2);
}


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

int main(void)
{
    int a,b,ans;
    string op;

    ans = 0;
    while (true)
    {
        cin >> a >> op >> b;
        if (op == "?") break;
        if (op == "+")
            ans = a + b;
        else if (op == "-")
            ans = a - b;
        else if (op == "*")
            ans = a * b;
        else if (op == "/")
            ans = a / b;

        cout << ans << endl;
    }
}



Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    int s[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        sum += s[i];
    }
    if(sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }
    // remove !10*
    sort(&(s[0]), &(s[N]));
    for(int i = 0; i < N; i++){
        if(s[i] % 10 != 0){
            sum -= s[i];
            cout << sum << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/


void solve()
{
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        double l, r;
        cin>>l>>r;
        double lol = sqrt((l*l)+(r*r));
        if(lol<=d)
        {
            ans++;
        }
    }

    cout<<ans<<endl;

}

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

    // ll t;
    // cin >> t;
    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>

using namespace std;

int main() {
  int kazu, asi;
  cin >> kazu >> asi;

  for(int kame = 0; kame <= kazu; kame++){
    int turu = kazu - kame;

    int ashi = 4*kame + 2*turu;
    if(ashi == asi){
      cout << "Yes" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 3616
#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(void) {
    int r, c, k,a,b,d; cin >> r >> c >> k;
    vector<vector<int>> field(r, vector<int>(c, 0));
    rep(i, k) {
        cin >> a >> b >> d; a--; b--;
        field[a][b] = d;
    }vector<vector<vector<ll>>> dp(r+1, vector<vector<ll>>(c+1, vector<ll>(4,0)));
    rep(i, r) rep(j, c) {
        rrep(k, 3) chmax(dp[i][j][k + 1], dp[i][j][k] + field[i][j]); // 多いほうから遷移
        rep(k, 4) {
            chmax(dp[i + 1][j][0], dp[i][j][k]);
            chmax(dp[i][j + 1][k], dp[i][j][k]);
        }
    }ll ans = 0;
    rep(i, 4)chmax(ans,dp[r - 1][c - 1][i]);
    cout << ans << endl;
}


Measured memory_bytes: 671848
N,K = map(int,input().split())
D = set(int(x) for x in input().split())
safe = set(range(10)) - D

def test(N):
  return set(int(x) for x in str(N)) <= safe

def F(N):
  # 下の位から決める
  while N % 10:
    if test(N):
      return N
    N += 1
  # N は 10の倍数
  x = F(N//10)
  y = min(safe)
  return 10*x + y

answer = F(N)
print(answer)

Measured memory_bytes: 3188
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, id_):
        self.id = id_
        self.link = []
        self.check = False
        

def main():
    N, M = map(int, input().split())
    
    nodes = [Node(i) for i in range(N+1)]

    ab = [list(map(int, input().split())) for i in range(M)]

    for i in range(M):
        a, b = ab[i]
        nodes[a].link.append(nodes[b])
        nodes[b].link.append(nodes[a])
    
    ans = 0
    for a, b in ab:
        check = [False] * (N+1)
        q = deque()
        tmp = 0
        q.append(nodes[1])
        check[1] = True
        while len(q) > 0:
            node = q.popleft()
            tmp += 1
            if node.id == a:
                ban_id = b
            elif node.id == b:
                ban_id = a
            else:
                ban_id = -1
            for nex in node.link:
                if nex.id != ban_id and not check[nex.id]:
                    check[nex.id] = True
                    q.append(nex)
        # print(a, b, tmp)
        if tmp != N:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()

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

int main(int argc, char const *argv[]) {
    vector<int> nums(3);
    cin >> nums[0] >> nums[1] >> nums[2];
    swap(nums[0], nums[1]);
    swap(nums[0], nums[2]);
    cout << nums[0] << ' ' << nums[1] << ' ' << nums[2] << endl;
    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  if(n/10==9 ||n%10==9)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int H, W;
	string S;
	cin >> H >> W;
	rep(i, 0, H)
	{
		cin >> S;
		cout << S << endl << S << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        "\n"
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  
int s,w;
cin>>s>>w;
if(s>w)
cout<<"safe"<<endl;
else
cout<<"unsafe"<<endl;
return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, char *argv[])
{
	int i, j, H, W, HW[100][100] = {{0}};
	int N, h = 0, w = 0, s = 0; /* 0: -> 1: <- */
	scanf("%d %d", &H, &W);
	scanf("%d", &N);
	for ( i = 0; i < N; i++ ){
		int a;
		scanf("%d", &a);
		if ( s == 0 ){
			for ( ; w < W; w++, a-- ){
				if ( a == 0 ){
					break;
				}
				HW[h][w] = i+1;
			}
			if ( w == W ){
				h++;
				w = W-1;
				s = 1;
			}
		} else {
			for ( ; w >= 0; w--, a-- ){
				if ( a == 0 ){
					break;
				}
				HW[h][w] = i+1;
			}
			if ( w < 0 ){
				h++;
				s = 0;
				w = 0;
			}
		}
		if ( a == 0 ){
			continue; /* この行はなくてもOK */
		}
		while ( a/W > 0 ){
			for ( j = 0; j < W; j++ ){
				HW[h][j] = i+1;
			}
			h++;
			a -= W;
			s = 0;
			w = 0;
		}

		if ( s == 0 ){
			for ( ; w < W; w++, a-- ){
				if ( a == 0 ){
					break;
				}
				HW[h][w] = i+1;
			}
		} else {
			for ( ; w >= 0; w--, a-- ){
				if ( a == 0 ){
					break;
				}
				HW[h][w] = i+1;
			}
		}
	}
	for ( h = 0; h < H; h++ ){
		for ( w = 0; w < W; w++ ){
			printf("%d%s", HW[h][w], w==W-1?"\n":" ");
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int floor[4][3][10]={0};/*????¬??????????????????????*/
	int n,b,f,r,v;
	int i,j,k;

	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		floor[b-1][f-1][r-1] += v;/*??\?????????????????°????????????????´?*/
		}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
			printf("%2d",floor[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3)/*???????????????????????????????????*/
		printf("####################\n");
	}
	return 0;
}

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

int main(){
    int x;

    cin >> x;

    if (x >= 30){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


const vector<char> te={'A','T','C','G'};

int main(){
    string s;
    cin>>s;
    int n=s.length();
    int ans=0,kari=0;
    rep(i,n){
        bool ok=false;
        rep(j,4){
            if(te[j]==s[i]){
                ok=true;
                break;
            }
        }
        if(ok) kari++;
        else kari=0;
        ans=max(ans,kari);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a,b,c;
	cin >> a>>b>>c;

	vector<int> data(3);
	data[0] = a;
	data[1] = b;
	data[2] = c;
	sort(data.begin(), data.end());
	cout << data[0] + data[1] << endl;


	

	return 0;

}


Measured memory_bytes: 256
/*
 ============================================================================
 Name        : baburu.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>


int bubblrSort(int a[100],int n){
	int kaisuu=0;
	int j;
	int flag=1;
	while(flag){
		flag = 0;
		for(j=n-1;j>0;j--){
			if(a[j]<a[j-1]){
				int tmp;
				tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
						flag = 1;
						kaisuu++;
			}
		}

	}

	return kaisuu;
}

int main(void) {

	int n;
	int koukankaisuu=0;
	int a[100];
	scanf("%d",&n);
	int i=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	koukankaisuu=bubblrSort(a,n);

	printf("%d",a[0]);
	for(i=1;i<n;i++){
			printf(" %d",a[i]);
		}
	printf("\n%d\n",koukankaisuu);

	return 0;
}

Measured memory_bytes: 600
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10 ; 
const long long inf = 1e15 + 10 ; 
int p[maxn] , h[maxn] , ind[maxn] , n , ans ;
long long dp[maxn][maxn] ;

void input() 
{
	cin >> n ;
	for ( int i = 0 ; i < n ; i++ ) 
		cin >> h[i] >> p[i] , ind[i] = i ;
}
bool cmp ( int i , int j ) 
{
	return ( h[i] + p[i] < h[j] + p[j] ) ;
}
void cal_dp() 
{
	for ( int i = 0 ; i <= n ; i++ ) 
		for ( int j = 0 ; j <= n ; j++ ) 
			dp[i][j] = inf ; 

	for ( int i = 0 ; i <= n ; i++ ) 
		dp[i][0] = 0 ;
	
	for ( int i = 0 ; i < n ; i++ ) 
		for ( int j = 0 ; j < n ; j++ ) 
		{
			if ( dp[i][j] <= h[ind[i]] ) 
				dp[i+1][j+1] = min ( dp[i+1][j+1] , dp[i][j] + p[ind[i]] ) ; 

		       	dp[i+1][j] = min ( dp[i+1][j] , dp[i][j] ) ;
		}
}
int main () 
{
	input() ;
	sort ( ind , ind + n , cmp ) ;
	cal_dp() ;
	for ( int i = 0 ; i < n ; i++ ) 
		for ( int j = 0 ; j < n ; j++ ) 
			if ( dp[i+1][j+1] != inf ) 
				ans = max ( ans , j+1 ) ;
	cout << ans << endl;
	
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){

    int N;
    cin >> N;
    rep(i, 0, N){
        if(int(i * 1.08) == N){
            cout << i << '\n';
            return 0;
        }
    }

    cout << ":(\n";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18L;
const ll NINF = -1e18L;

struct Point {
	ll x;
	ll y;
};

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

	int n; cin >> n;
	vector<Point> a(n);
	ll mxS = NINF;
	ll mxD = NINF;
	ll mnS = INF;
	ll mnD = INF;
	for (auto& p: a) {
		cin >> p.x >> p.y;
		ll s = p.x + p.y;
		ll d = p.x - p.y;
		mxS = max(mxS, s);
		mnS = min(mnS, s);
		mxD = max(mxD, d);
		mnD = min(mnD, d);
	}
	ll ans = 0;
	for (auto p: a) {
		ll d1 = p.x + p.y - mxS;
		ll d2 = p.x + p.y - mnS;
		ll d3 = p.x - p.y - mxD;
		ll d4 = p.x - p.y - mnD;
		ans = max({ans, d1, d2, d3, d4});
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
if(a>1&&b>1){
		if(a>b)
		printf("Alice");
		else if(b>a)
		printf("Bob");
		else
		printf("Draw");
	}
	else{
	if(a==1&&b!=1)
	printf("Alice");
	else if(b==1&&a!=1)
	printf("Bob");
	else
	printf("Draw");	
}
}

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

int main() {
  ll a, b ,c;
  cin >> a >> b >> c;
  if (c >= (a + b) && 4 * a * b < (c - (a + b)) * (c - (a + b))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int f(int x){
    int r = 0;
    while (x){
        r += x % 10;
        x /= 10;
    }
    return r;
}

int main() {
    int x;
    cin >> x;
    cout << (x % f(x) == 0 ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int mm = 1; mm <= m; mm++) {
        for(int dd = 1; dd <= d; dd++) {
            ans += dd % 10 >= 2 and dd / 10 >= 2 and (dd % 10) * (dd / 10) == mm;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return

#B
def B():
    s = S()
    for i in range(len(s)):
        if i%2:
            if s[i] not in ["L","U","D"]:
                print("No")
                return
        else:
            if s[i] not in ["R","U","D"]:
                print("No")
                return
    print("Yes")
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39024