akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
template< int char_size >
struct TrieNode {
  int nxt[char_size];

  int exist;
  vector< int > accept;

  TrieNode() : exist(0) {
    memset(nxt, -1, sizeof(nxt));
  }
};

template< int char_size, int margin >
struct Trie {
  using Node = TrieNode< char_size >;

  vector< Node > nodes;
  int root;

  Trie() : root(0) {
    nodes.push_back(Node());
  }

  void update_direct(int node, int id) {
    nodes[node].accept.push_back(id);
  }

  void update_child(int node, int child, int id) {
    ++nodes[node].exist;
  }

  void add(const string &str, int str_index, int node_index, int id) {
    if(str_index == str.size()) {
      update_direct(node_index, id);
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].nxt[c] == -1) {
        nodes[node_index].nxt[c] = (int) nodes.size();
        nodes.push_back(Node());
      }
      add(str, str_index + 1, nodes[node_index].nxt[c], id);
      update_child(node_index, nodes[node_index].nxt[c], id);
    }
  }

  void add(const string &str, int id) {
    add(str, 0, 0, id);
  }

  void add(const string &str) {
    add(str, nodes[0].exist);
  }

  void query(const string &str, const function< void(int) > &f, int str_index, int node_index) {
    for(auto &idx : nodes[node_index].accept) f(idx);
    if(str_index == str.size()) {
      return;
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].nxt[c] == -1) return;
      query(str, f, str_index + 1, nodes[node_index].nxt[c]);
    }
  }

  void query(const string &str, const function< void(int) > &f) {
    query(str, f, 0, 0);
  }

  int count() const {
    return (nodes[0].exist);
  }

  int size() const {
    return ((int) nodes.size());
  }

  vector<ll> ans;
  void solve(){
    dfs(root,0);
  }
  void dfs(int p,int dep){
    if(nodes[p].nxt[0]!=-1 && nodes[p].nxt[1]!=-1){
      dfs(nodes[p].nxt[0],dep+1);
      dfs(nodes[p].nxt[1],dep+1);
    }
    if(nodes[p].nxt[0]!=-1 && nodes[p].nxt[1]==-1){
      ans.push_back(dep);
      dfs(nodes[p].nxt[0],dep+1);
    }
    if(nodes[p].nxt[0]==-1 && nodes[p].nxt[1]!=-1){
      ans.push_back(dep);
      dfs(nodes[p].nxt[1],dep+1);
    }
  }
};

int main()
{
ll n , l ;
cin >> n >> l ;
Trie< 2, '0' > trie;
rep(i,n){
  string s;
  cin >> s;
  trie.add(s);
}
trie.solve();
vector<ll> v=trie.ans;
ll ch=0;
rep(i,v.size()){
  v[i]=l-v[i];
  ll a=1;
  while(v[i]%2==0){
    v[i]/=2;
    a*=2;
  }
  ch^=a;
}
if(ch)cout << "Alice" << endl;
else cout << "Bob" << endl;
return 0;
}

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

using namespace std;


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

    vector<double> p(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }

    // 最初のi枚投げたときに表がj枚出る確率
    vector<vector<double>> dp(N+1, vector<double>(N+1, 0.0));

    // 初期条件
    dp[1][1] = p[1], dp[1][0] = 1-p[1];

    for (int i = 2; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (j == 0) {
                dp[i][j] = dp[i-1][j] * (1-p[i]);
                continue;
            }
            
            dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]);
        }
    }

    double answer = 0.0;

    for (int j = N/2 + 1; j <= N; j++) {
        answer += dp[N][j];
    }
    
    cout << fixed << setprecision(10) << answer << endl;
	return 0;
}

Measured memory_bytes: 73748
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    while(cin>>N, N){
        vector<vector<bool>> table(30, vector<bool>(N, false));
        for(int i=0; i<N; i++){
            int f; cin >> f;
            for(int j=0; j<f; j++){
                int d; cin >> d; d--;
                table[d][i] = true;
            }
        }
        
        vector<vector<set<int>>> dp(2, vector<set<int>>(N));
        for(int i=0; i<N; i++)
            dp[0][i].insert(i);
            
        for(int d=1; d<=30; d++){
            for(int i=0; i<N; i++)
                dp[d%2][i] = dp[(d-1)%2][i];
            
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(table[d-1][i] && table[d-1][j]){
                        for(auto x: dp[(d-1)%2][i])
                            dp[d%2][j].insert(x);
                    }
                }
            }
            int flag = false;
            for(int i=0; i<N; i++)
                flag |= dp[d%2][i].size() == N;
            
            if(flag){
                cout << d << endl;
                break;
            }else if(d == 30){
                cout << -1 << endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1436
class Dice
  def initialize(dice = [])
    @dice = dice
  end

  def get_top
    @dice[0]
  end
  
  def get_front
    @dice[1]
  end

  def get_right
    @dice[2]
  end

  def get_left
    @dice[3]
  end

  def get_back
    @dice[4]
  end

  def get_bottom
    @dice[5]
  end

  def get_dice_array
    [ 
      @dice[0],
      @dice[1],
      @dice[2],
      @dice[3],
      @dice[4],
      @dice[5]
    ]
  end

  def set_top(t)
    case t
    when @dice[0]
      return
    when @dice[1]
      self.role("N")
    when @dice[2]
      self.role("W")
    when @dice[3]
      self.role("E")
    when @dice[4]
      self.role("S")
    when @dice[5]
      self.role("N")
      self.role("N")
    end
  end


  def role(c)
    case c
    when "N"
      @dice = 
        [
          @dice[1],
          @dice[5],
          @dice[2],
          @dice[3],
          @dice[0],
          @dice[4]
        ]

    when "S"
      @dice = 
        [
          @dice[4],
          @dice[0],
          @dice[2],
          @dice[3],
          @dice[5],
          @dice[1]
        ]
    
    when "E"
      @dice = 
        [
          @dice[3],
          @dice[1],
          @dice[0],
          @dice[5],
          @dice[4],
          @dice[2]
        ]
    
    when "W"
      @dice = 
        [
          @dice[2],
          @dice[1],
          @dice[5],
          @dice[0],
          @dice[4],
          @dice[3]
        ]
    end
  end

  def set_front(n)
    case n
    when @dice[0]
      return false
    when @dice[1]
      return true
    when @dice[2]
      self.turn("L")
    when @dice[3]
      self.turn("R")
    when @dice[4]
      self.turn("R")
      self.turn("R")
    when @dice[5]
      return false
    end
  end

  def turn(c)
    case c
    when "R"
      @dice =
        [
          @dice[0],
          @dice[2],
          @dice[4],
          @dice[1],
          @dice[3],
          @dice[5]
      ]
    when "L"
      @dice =
        [
          @dice[0],
          @dice[3],
          @dice[1],
          @dice[4],
          @dice[2],
          @dice[5]
        ]
    end
  end
end

gets

dice_arr = gets.split.map(&:to_i)
@dice_origin = Dice.new(dice_arr)
same_dice = false

ARGF.each_line do |line|
  dice_arr = line.split.map(&:to_i)
  @dice = Dice.new(dice_arr)

  4.times do
    4.times do
      if @dice_origin.get_dice_array == @dice.get_dice_array
        same_dice = true
      end
      @dice.turn("R")
    end
    @dice.role("N")
  end

  4.times do
    4.times do
      if @dice_origin.get_dice_array == @dice.get_dice_array
        same_dice = true
      end
      @dice.turn("R")
    end
    @dice.role("E")
  end
end


if same_dice 
  puts "No" 
else
  puts "Yes"
end

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

template<class T>
struct Dijkstra {
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<int> path;
    
    Dijkstra() {}
    Dijkstra(int n) {
        graph.resize(n);
        dist.resize(n);
        prev.resize(n);
    }
    
    void add_edge(int from, int to, T cost) {
        graph[from].emplace_back(to, cost);
    }
    
    void get_distance(int from) {
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        fill(dist.begin(), dist.end(), inf);
        fill(prev.begin(), prev.end(), -1);
        dist[from] = 0;
        pq.push(make_pair(0, from));
        while(!pq.empty()) {
            pair<T, int> p = pq.top(); pq.pop();
            if (dist[p.second] < p.first) continue;
            for (auto e : graph[p.second]) {
                if (dist[e.first] > (dist[p.second] + e.second)) {
                    dist[e.first] = dist[p.second] + e.second;
                    prev[e.first] = p.second;
                    pq.push(make_pair(dist[e.first], e.first));
                }
            }
        }
    }
    
    void get_path(int to) {
        path = vector<int>(0);
        for (; to != -1; to = prev[to]) {
            path.push_back(to);
        }
        reverse(path.begin(), path.end());
    }
    
private:
    vector<vector<pair<int, T>>> graph;
    vector<T> prev;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    Dijkstra<ll> di(n);
    vector<vector<ll>> g(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        di.add_edge(a, b, 1);
        di.add_edge(b, a, 1);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    di.get_distance(0);
    // rep(i, n) printf("%lld\n", di.dist[i]);
    cout << "Yes" << endl;
    reps(i, 1, n) {
        ll mv = LONG_LONG_MAX, mi = -1;
        for(auto x : g[i]) {
            if (mv > di.dist[x]) {
                mv = di.dist[x];
                mi = x;
            }
        }
        cout << (mi + 1) << endl;
    }
    // ans.resize(n, make_pair(-1, -1));
    // ans[0] = make_pair(0, 0);
    // dfs(0);
    // cout << "Yes" << endl;
    // reps(i, 1, n) cout << (ans[i].first + 1) << endl;
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	int p=0,q=0,r=0;
	while(n--){
		int a,b,c;
		cin>>a>>b>>c;
		a += max(q,r); b += max(p,r); c += max(p,q);
		p=a; q=b; r=c;
	}
	cout<< max(p,max(q,r));
}

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

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

    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a >= b){
        ans += a;
        a--;
        ans += max(a, b);
        cout << ans << endl;
    }
    else{
        ans += b;
        b--;
        ans += max(a,b);
        cout << ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
try:
    while 1:

        a,b,c,d,e,f  = list(map(int,input().split()))
        y = (c * d - f * a) / (d * b - a * e)
        x = (c - b * y) / a

        print("{:.3f} {:.3f}".format(x, y))
except Exception:
    pass

Measured memory_bytes: 7532
#include<cstdio>
#include<cmath>
int main(){
  double a,b,c;
  scanf("%lf %lf %lf",&a,&b,&c);
  printf("%.7f\n",a*b*sin((M_PI*c/180))/2);
  printf("%.7f\n",a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos((M_PI*c/180))));
  printf("%.7f\n",b*sin((M_PI*c/180)));
}

Measured memory_bytes: 1128
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define EPS 1e-08

int N, A;
int x[60];
long long dp[60][6000];

int main() {
  cin >> N >> A;
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  dp[0][2600] = 1;
  for (int i=1; i<=N; i++) {
    for (int k=-2600; k<2600; k++) {
      dp[i][2600+k]          += dp[i-1][2600+k];
      dp[i][2600+k+x[i-1]-A] += dp[i-1][2600+k];
    }
  }
  cout << dp[N][2600] - 1 << "\n";
  return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int main(void){
	ll n,m;
	cin>>n>>m;
	if(n==1||m==1)cout<<1;
	else cout<<(ll)(n*m+1)/2;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;


namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public decimal[] DecimalArray()
        {
            var array = Array();
            var result = new decimal[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = decimal.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N, K;
        private int[] A;
        private bool[] Win;
        void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
            A = sc.IntArray();
            Win = new bool[K + 1];

        }

        public void Solve()
        {
            Scan();
            for (int i = 0; i < A[0]; i++)
            {
                Win[i] = false;
            }

            for (int i = A[0]; i <= K; i++)
            {
                bool win = false;
                foreach (var i1 in A)
                {
                    if (i - i1 < 0) break;
                    win |= !Win[i - i1];
                }

                Win[i] = win;
            }
            Console.WriteLine(Win[K] ? "First" : "Second");
        }




        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9+7;
const int MAX_N = 101000;

int N;
ll M;

ll fact[MAX_N];
ll frev[MAX_N];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}

void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= 200000; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}

ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

map<int, ll> prime_factor(ll n){
    map<int, ll> res;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main(){
    cin >> N >> M; 
    ll ans = 1;
    map<int, ll> prime = prime_factor(M);

    fact[0] = frev[0] = 1;
    for(int i = 1; i <= N+100; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    for(auto&& p : prime){
        //if(p == 0) continue;
        ans *= comb(N-1+p.second, N-1);
        ans %= MOD;
    }

    //if (M > 1){
    //        ans = (ans * N) % MOD;
    //    }

    if(N == 1) ans = 1;
    cout << ans % MOD << endl;

    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int s, w;
  cin >> s >> w;

  if (w >= s) {
    cout << "un";
  }
  cout << "safe\n";
}


Measured memory_bytes: 3692
//g++ -std=c++11
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
typedef pair <ld, ld> pd;

typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ld> vd;
typedef vector <pi> vpi;
typedef vector <pl> vpl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define ins insert

const int INF = 1000000000;
const int MAXN = 200000;
const int MOD = 1000000007;
const char nl = '\n';

int main() {

    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);

    bool haycero = false;
    int n;
    ll ans = 1,x = 0;
    ld exp = 0;
    cin >> n;

    for (int i=0; i<n; i++) {
    	cin >> x;
    	ans *= x;
    	if(x==0) haycero = true;
    	exp += log10(x);
    }

    if(haycero) {
    	cout << 0 << nl;
    	return 0;
    }

    if(exp > 18.1) {
    	cout << -1 << nl;
    } else {
    	if(ans <= 1000000000000000000)
    		cout << ans << nl;
    	else
    		cout << -1 << nl;
    }
    
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	int y=c-a,x=d-b;
	cout<<c-x<<" "<<d+y<<" "<<a-x<<" "<<b+y;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		System.out.println(Math.max(Math.min(b,  d) - Math.max(a,  c), 0));
	}

}


Measured memory_bytes: 23124
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost


if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
        if iU - iL <= iX :
            iTotalCost = min(iLCost,iUCost)
            for iK in range(iL+1,iU) :
                iThisCost = fCalcCost(iN,iX,aCum,iK)
                iTotalCost = min(iThisCost,iTotalCost)
            return iTotalCost
        else:
            iM = (iU + iL) // 2
            iMCost = fCalcCost(iN,iX,aCum,iM)
            if iLCost < iUCost :
                return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
            else :
                return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

    print(fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum))
else:
    print(2*iX + 5*aX[0])


Measured memory_bytes: 27244
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
typedef long long ll;

int main()
{
	ll n;
	ll a, b;
	ll x[100005];
	ll ans = 0;

	scanf("%lld %lld %lld", &n, &a, &b);
	for (ll i = 0; i < n; i++) {
		scanf("%lld", &x[i]);
	}

	for (ll i = 0; i < n - 1; i++) {
		ans = ans + min((x[i + 1] - x[i]) * a, b);
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define ull unsigned long long int
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define PI acos(-1)
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<b;i++)
#define gcd(a,b) __gcd(a,b)
#define gcd3(a,b,c) __gcd(__gcd(a,b),c)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;



int main()
{
	ll h,n;
	lsc2(h,n);
	ll a[n],i,s=0;
	rep(i,n)
	{
		lsc(a[i]);
		s+=a[i];
	}
	if(s>=h)cout << "Yes\n";
	else cout << "No\n";
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static boolean[] tony(int n)
    {
        boolean[] array = new boolean[n];
        for(int i = 0;i<n;i++)
        {
            array[i] = true;
        }
        array[0] = false;
        array[1] = false;
        for(int i = 2;i<= Math.sqrt((double)n);i++)
        {
            if(array[i]) {
                int j = i + i;
                while (j < n) {
                    array[j] = false;
                    j = j + i;
                }
            }
        }
        return array;
    }
    static int run(String[] args)
    {
        boolean[] tony = tony(100000000);
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int ans = 0;
            for (int i = 0; i < T; i++) {
                if (tony[scan.nextInt()])
                    ans++;
            }
            System.out.println(ans);
        }
        return 0;
    }

    public static void main(String[] args)
    {
        run(args);
    }
}

Measured memory_bytes: 140472
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    string s;
    cin >> s;
    auto la = atcoder::lcp_array(s, atcoder::suffix_array(s));

    ll ans = 0;
    rep(i, s.size()) ans += i + 1;
    rep(i, la.size()) ans -= la[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15608
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>

using namespace std;
using uint = uint32_t;
using LL = int64_t;
using ULL = uint64_t;
using PP = pair<LL, LL>;
template <typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#define REP(i, a, n) for(LL i = (a), i##_max_ = (n); i < i##_max_; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##_min_ = (a); i >= i##_min_; --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP { cin.tie(NULL); ios::sync_with_stdio(false); }
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U> ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template <class T> T Next() { T buf; cin >> buf; return buf; }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Algebraic.h"
#include "BinaryMatrix.h"
#include "BinaryTree.h"
#include "Bipartite.h"
#include "BIT.h"
#include "DynamicMod.h"
#include "Factorization.h"
#include "FFT.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "LazySegmentTree.h"
#include "Math.h"
#include "Matrix.h"
#include "MinCostFlowSolver.h"
#include "MinMax.h"
#include "Numbers.h"
#include "Polynomial.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "SlidingWindow.h"
#include "SuffixArray.h"
#include "Tree.h"
#include "UnionFind.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>>(istream& ist, __int128& val) { LL tmp; ist >> tmp; val = tmp; return ist; }
ostream& operator<<(ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (b > d) << endl;
	return 0;
}


Measured memory_bytes: 256
n, m, x = map(int,input().split())
an = [int(num) for num in input().split()]

up = 0
down = 0
for a in an :
  if a > x :
    up += 1
  else :
    down += 1

if up > down :
  print(down)
else :
  print(up)
    

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev, col;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    vec<ll> a(n);
    REP(i,n) cin>>a[i];
    Graph g(n);
    REP(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        add_edge(g,a,b,1,true,1);
    }

    vec<int> sz(n, 1);
    vec<vvec<ll>> dp(n,vvec<ll>(2));//頂点iを根とするj書い切ったときにできる部分木の最小値
    
    auto dfs=[&](auto &&self,int v,int p)->void{
        dp[v][0] = vec<ll>(1, INF);//ーをふくまない
        dp[v][1] = vec<ll>(1, INF);//ーをふくむ
        if(a[v]>0) dp[v][0][0]=a[v];
        else dp[v][1][0]=a[v];

        for(auto e:g[v]){
            if(e.to==p) continue;
            self(self,e.to,v);
            vvec<ll> dp2(2,vec<ll>(sz[v]+sz[e.to], INF));
            REP(i,sz[v]){
                REP(j,sz[e.to]){
                    REP(aa,2) REP(bb,2){
                        if(dp[v][aa][i]==INF or dp[e.to][bb][j]==INF) continue;
                        chmin(dp2[aa or bb][i+j], dp[v][aa][i] + dp[e.to][bb][j]);
                        if(bb==0 or dp[e.to][bb][j] < 0) chmin(dp2[aa][i+j+1], dp[v][aa][i]);
                    }
                }
            }
            sz[v]+=sz[e.to];
            dp[v]=dp2;
        }

    };
    dfs(dfs,0,-1);

    REP(i,n){
        if(dp[0][0][i]!=INF or dp[0][1][i]<0){
            cout<<i<<en;
            return;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

using namespace std;

int n, m;
vector <vector<int>> graph;
vector <bool> visited;
int sz = 0;

void dfs(int u) {
	if (visited[u]) {
		return;
	}

	visited[u] = true;
	sz++;

	for (int v: graph[u]) {
		dfs(v);
	}
}

int main() {
	cin >> n >> m;
	
	set <pair<int, int>> edges;

	for (int i = 0; i < m; i++) {
		int u, v;

		cin >> u >> v;

		edges.insert({min(u, v), max(u, v)});
	}

	graph.assign(n+1, vector <int>());

	for (auto edge: edges) {
		graph[edge.first].push_back(edge.second);
		graph[edge.second].push_back(edge.first);
	}

	visited.assign(n+1, false);

	int ans = 0;

	for (int i = 1; i <= n; i++) {
		sz = 0;
		dfs(i);
		ans = max(ans, sz);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 29832
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int a[N];
  int b[N];
  int c[N-1];

  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int i = 0; i < N; i++){
    cin >> b[i];
    ans += b[i];
  }
  for(int i = 0; i < N - 1; i++){
    cin >> c[i];
  }

  for(int i = 0; i < N - 1; i++){
    if(a[i] + 1 == a[i+1]){
      ans += c[a[i] - 1];
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
int main() {fio ;// remove during scanf
	string s;
	int n;
	cin >> s >> n;
	for(int i = 0; i < s.length(); i++) {
		if(i % n == 0) {
			cout << s[i];
		}
	}    return 0;
}

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

int main() {
	int k;
	cin >> k;
	int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout << arr[k-1];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    vector<ll> v(M);
    for (auto &&i : v) {
        cin >> i;
    }
    SORT(v);
    vector<ll> vv(M - 1);
    FOR(i, 1, M) { vv[i - 1] = v[i] - v[i - 1]; }
    ll sum = accumulate(ALL(vv), 0);
    RSORT(vv);
    REP(i, min(N - 1, (int)vv.size())) { sum -= vv[i]; }
    print(sum);

    return 0;
}

Measured memory_bytes: 1792
d = gets.to_i
cs = gets.split.map(&:to_i)
total_score = 0
scored = Array.new(26, 0)
d.times do |i|
  s = gets.split.map(&:to_i)
  score = -100000000000
  temp_id = -1
  (0..25).each do |j|
    temp_score = s[j]
    cs.each_with_index do |c, k|
      next if j == k
      temp_score -= (i+1 - scored[k])
    end
    if temp_score > score
      temp_id = j
      score = temp_score
    end
  end
  puts temp_id + 1
end

Measured memory_bytes: 14436
import sys
#import copy
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
import functools

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def gcd(nums):
    return functools.reduce(euclid, nums)

def euclid(a, b):
    if b > a:
        a, b = b, a
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def main():
    # input
    K = int(readline())

    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += gcd([i,j,k])
    
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

struct drink {
    long price;
    int num;
};

int main() {
    int N, M;
    cin >> N, cin >> M;
    vector<drink> D;
    for (int i = 0; i < N; ++i) {
        long price;
        int num;
        cin >> price, cin >> num;
        D.push_back(drink{price, num});
    }
    sort(D.begin(), D.end(), [](const drink& x, const drink& y) { return x.price < y.price; });
    long money = 0;
    int got = 0;
    for (int i = 0; i < N && got < M; ++i) {
        int toget = min(D[i].num, M - got);
        got += toget;
        money += D[i].price * toget;
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
vi prime(1000050,0);
void solve(){
    ll n; 
    cin >> n;
    for(ll i=2; i*i<=n; i++){
        while(n%i==0){
            n/=i;
            prime.at(i)++;
        }
    }
    ll ans=0;
    rp(i,1000030){
        rp(j,20){
            if(j*(j+1)/2<=prime[i]&&prime[i]<(j+2)*(j+1)/2){
                ans+=j;
                break;
            }
        }
    }
    if(n!=1) ans++;
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 7108
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    float n, t, a, curr = 0, mi = 1000, idx;
    cin >> n >> t >> a;
    vector<float> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        curr = t - (v[i] * .006);
        float diff = abs(a - curr);
        if(diff < mi){
            mi = diff;
            idx = i + 1;
        }
    }
    cout << idx << endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
 
int main(){
    IOS;
    char a;cin>>a;
    cout<<char(a+1);
    return 0;
}   

Measured memory_bytes: 256
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def solve():
    n = getN()

    fac, finv = fact_and_inv(n+2000)

    length = 1
    ans = 0
    while True:
        if length * 3 > n:
            break
        distribution = n - length * 3
        ans += fac[length + distribution - 1] * finv[length-1] * finv[distribution]
        ans %= MOD
        length += 1
    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 10644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[69][69] = {}, z = 0;
    double d;
    cin >> n;
    while (n--) {
        cin >> d;
        ll b = (ll)round(d * 1e9);
        int x = 0, y = 0;
        while (b % 2 == 0) b /= 2, x++;
        while (b % 5 == 0) b /= 5, y++;
        a[x][y]++;
        //cout << x << ' ' << y << '\n';
    }
    for (int i = 0; i < 69; i++) for (int j = 0; j < 69; j++) {
        for (int k = 0; k < 69; k++) for (int l = 0; l < 69; l++) {
            if (i + k >= 18 && j + l >= 18) {
                if (i == k && j == l) z += a[i][j] * (a[i][j] - 1) / 2;
                else if (i < k || (i == k && j < l)) z += a[i][j] * a[k][l];
            }
        }
    }
    cout << z << '\n';
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const int INF = 1e9;


int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    int water = 0,sugar = 0;
    double cons = 0.0;
    for(int a = 0; a * A * 100 < F; ++a){
        for(int b = 0; b * B * 100 < F; ++b){
            int w = a * A * 100 + b * B * 100;
            if(w > F) break;
            int cap = min((a*A + b*B) * E, F - w);
            for(int c = 0; c * C <= cap; ++c){
                for(int d = 0; c * C + d * D <= cap; ++d){
                    int s = c * C + d * D;
                    if(w + s == 0) continue;
                    double con = (double)(100 * s) / (double)(w + s);         
                    if(chmax(cons, con)){
                        water = w + s;
                        sugar = s;
                    }
                }
            }
        }
    }
    if(sugar == 0) water = 100 * A;
    cout << water << " " << sugar << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))
inf = 1001001001
dp = [inf] * (n+1)

dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(n):
    for j in range(k):
        if i + j >= n:
            break
        dp[i + j] = min(dp[i + j], dp[i-1] + abs(h[i+j] - h[i-1]))
print(dp[n-1])


Measured memory_bytes: 52448
import math


def main():
    a, b = input().split()

    f1(a, b)


def f1(a, b):
    c = a + b
    d = int(c)
    sqrt = math.sqrt(d)

    if int(sqrt) == sqrt:
        print("Yes")
    else:
        print("No")


def f2(a, b):
    c = a + b
    d = int(c)
    m = math.sqrt(100100)
    for i in range(11, int(m) + 1):
        if i * i == d:
            print("Yes")
            return

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 1e3+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....


signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        int n;
        cin>>n;
        map<int,int> mp;
        int sum=0;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            sum+=x;
            mp[x]++;
        }
        int t;
        cin>>t;
        while(t--){
            int x,y;
            cin>>x>>y;
            int left=mp[x];
            sum-=left*x;
            sum+=left*y;
            mp[y]+=left;
            mp[x]=0;
            cout<<sum<<endl;
        }
    }
}

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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1e5+1;

void solve()
{
	double i,a,b,h,m;
	cin>>a>>b>>h>>m;
	double ang=30*h-5.5*m;
	if(ang<0)
	ang+=360;
	double cnv=pi/180.0;
	cout<<fixed<<setprecision(20);
	cout<<sqrt(a*a+b*b-2*a*b*cos(ang*cnv));
}

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

Measured memory_bytes: 4244
import java.io.*;

public class Main {

	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = new String[1000];
		int sum = 0;
		while(true)
		{
			str = br.readLine().split("");
			for(int i=0; i<str.length; i++)
			{
				sum += Integer.parseInt(str[i]);
			}
			if(sum==0)	break;
			System.out.println(sum);
			sum = 0;
		}
	}
}

Measured memory_bytes: 25360
#include <iostream>
#include <climits>
#include <memory.h>
using namespace std;
const int MAXN = 15;
int graph[MAXN][MAXN], dp[1<<MAXN][MAXN], p[1<<MAXN];
int n, mask;
void init() {
    for (int i = 0; i <= mask; i++) {
        for (int j = 0; j < n; j++) {
            if ((i&(1<<j)) == 0) continue;
            for (int k = j+1; k < n; k++) {
                if (i&(1<<k)) {
                    p[i] += graph[j][k];
                }
            }
        }
    }
    memset(dp, -1, sizeof(dp));
    dp[1][0] = 0;
}
int main() {
//    freopen("test.txt", "r", stdin);
    int m, a, b, c, sum = 0;
    cin >> n >> m;
    mask = (1<<n) - 1;
    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        graph[--a][--b] = c;
        graph[b][a] = c;
        sum += c;
    }
    init();
    for (int i = 0; i <= mask; i++) {
        for (int j = 0; j < n; j++) {
            if (dp[i][j] == -1) continue;
            for (int k = 0; k < n; k++) {
                if ((i&(1<<k)) == 0 && graph[j][k] > 0) {
                    dp[i|(1<<k)][k] = max(dp[i|(1<<k)][k], dp[i][j] + graph[j][k]);
                }
            }
            int sub = i^mask;
            for (int t = mask; t >= 0; t--) {
                t = t & sub;
                dp[i|t][j] = max(dp[i|t][j], dp[i][j] + p[t|(1<<j)]);
            }
        }
    }
    cout << sum - dp[mask][n-1] << endl;

    return 0;
}

Measured memory_bytes: 2432