akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	Scanner sc;
	int N, M;
	List<int[]>[] to;
	long[] p;
	
	@SuppressWarnings("unchecked")
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		to = new List[N];
		for (int i = 0; i < N; i++) to[i] = new ArrayList<>();
		for (int i = 0; i < N-1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			to[a].add(new int[] {b, i});
			to[b].add(new int[] {a, i});
		}
		M = sc.nextInt();
		p = new long[M];
		for (int i = 0; i < M; i++) {
			int u = sc.nextInt() - 1;
			int v = sc.nextInt() - 1;
			p[i] = pathToLong(u, v);
		}

		long s = 0;
		for (int i = 0; i < (1<<M); i++) {
			long c = 0;
			for (int j = 0; j < M; j++) {
				if ( (i&(1<<j)) > 0 ) c |= p[j];
			}
			int bitCount = Integer.bitCount(i);
			s += ((bitCount%2 == 0)?1:-1)*(1L << (N-1-Long.bitCount(c)));
		}
		
		System.out.println(s);
	}

	private long pathToLong(int u, int v) {
		return dfs(u, u, v);
	}

	private long dfs(int src, int curr, int dest) {
		for (int[] v : to[curr]) {
			if (v[0] == src) continue;
			if (v[0] == dest) return (1L << v[1]);
			long f = dfs(curr, v[0], dest);
			if (f > 0) return f | (1L << v[1]);
		}
		return 0;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 23252
$encode = {
  "A" => "00000",
  "B" => "00001",
  "C" => "00010",
  "D" => "00011",
  "E" => "00100",
  "F" => "00101",
  "G" => "00110",
  "H" => "00111",
  "I" => "01000",
  "J" => "01001",
  "K" => "01010",
  "L" => "01011",
  "M" => "01100",
  "N" => "01101",
  "O" => "01110",
  "P" => "01111",
  "Q" => "10000",
  "R" => "10001",
  "S" => "10010",
  "T" => "10011",
  "U" => "10100",
  "V" => "10101",
  "W" => "10110",
  "X" => "10111",
  "Y" => "11000",
  "Z" => "11001",
  " " => "11010",
  "." => "11011",
  "," => "11100",
  "-" => "11101",
  "'" => "11110",
  "?" => "11111",
}

$decode = {
  "101"      => " ",
  "000000"   => "'",
  "000011"   => ",",
  "10010001" => "-",
  "010001"   => ".",
  "000001"   => "?",
  "100101"   => "A",
  "10011010" => "B",
  "0101"     => "C",
  "0001"     => "D",
  "110"      => "E",
  "01001"    => "F",
  "10011011" => "G",
  "010000"   => "H",
  "0111"     => "I",
  "10011000" => "J",
  "0110"     => "K",
  "00100"    => "L",
  "10011001" => "M",
  "10011110" => "N",
  "00101"    => "O",
  "111"      => "P",
  "10011111" => "Q",
  "1000"     => "R",
  "00110"    => "S",
  "00111"    => "T",
  "10011100" => "U",
  "10011101" => "V",
  "000010"   => "W",
  "10010010" => "X",
  "10010011" => "Y",
  "10010000" => "Z",
}

#$decode = $decode.sort{|a,b|a[0].size<=>b[0].size}.reverse

def ex s
  a = ""
  s.chars do |c|
    a << $encode[c]
  end
  b = ""
  loop do
    f = true
    $decode.each do |k, v|
      if a.index(k) == 0
        b << v
        a[0, k.size] = ""
        f = false
        break
      end
    end
    break if f
  end
  return b
end

$stdin.each do |input|
  s = input[0..-2]
  puts ex s
end

Measured memory_bytes: 6096
#include <algorithm>
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000009
#define PII pair<int, int>

const int N=200010;
int n,a[N];

int main()
{
    bool flag=false;
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%d",a+i);
        if (a[i]>i-1) flag=true;
    }
    if (flag) {
        printf("-1\n");
        return 0;
    }
    ll ans=0;
    ans+=a[n];
    for (int i=n-1;i>=1;i--) {
        if (a[i]<a[i+1]-1) {
            ans=-1;
            break;
        } else if (a[i]>a[i+1]-1) {
            ans+=a[i];
        }
    }
    printf("%lld\n",ans);
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF (1 << 28)    // for x <= 10^9
#define INFL (1ll << 60) // for x <=10^19
#define EPS (1e-10)

using namespace std;

typedef long long ll;

struct Edge {
  int to;
  ll cost;

  Edge(int to, ll cost) {
    this->to = to;
    this->cost = cost;
  }
};

int main() {
  int N;
  cin >> N;
  vector<vector<Edge>> edgesFor = vector<vector<Edge>>(N);
  rep(i, N - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    Edge e1(b, c);
    edgesFor[a].push_back(e1);
    Edge e2(a, c);
    edgesFor[b].push_back(e2);
  }

  int Q, K;
  cin >> Q >> K;
  K--;

  vector<ll> ds(N); // Kからの最短距離
  fill(ds.begin(), ds.end(), INFL);
  deque<int> queue;
  queue.push_back(K);
  ds[K] = 0;
  unordered_set<int> checkedSet;
  checkedSet.insert(K);
  while (!queue.empty()) {
    int i = queue.front();
    queue.pop_front();

    ll d = ds[i];
    for (Edge e : edgesFor[i]) {
      if (checkedSet.count(e.to)) {
        continue;
      }

      ds[e.to] = min(d + e.cost, ds[e.to]);
      queue.push_back(e.to);
      checkedSet.insert(e.to);
    }
  }

  rep(i, Q) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;

    cout << (ds[x] + ds[y]) << endl;
  }
}


Measured memory_bytes: 13860
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    string s;
    cin >> s;

    int cnt = 0, ans = 0;
    rep(i, 0, s.size())
    {
        if (s[i] == '0')
        {
            if (cnt > 0)
                ans += 2;
            cnt--;
        }
        else
        {
            if (cnt < 0)
                ans += 2;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	s := getString()
	f := 0
	for _, v := range s {
		f += int(v - '0')
	}
	x, _ := strconv.Atoi(s)
	if x%f == 0 {
		out("Yes")
	} else {
		out("No")
	}
}


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

using ll = long long;

struct person {
  ll a, b, c;
};

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

  int x, y, z;
  std::cin >> x >> y >> z;
  std::vector<person> p(x + y + z);

  ll offset = 0;
  for (int i = 0; i < x + y + z; i++) {
    std::cin >> p[i].a >> p[i].b >> p[i].c;
    offset += p[i].c;
    p[i].a -= p[i].c;
    p[i].b -= p[i].c;
  }
  std::sort(p.begin(), p.end(), [&](const auto &lhs, const auto &rhs) {return lhs.a - lhs.b < rhs.a - rhs.b;});

  std::vector<ll> from_left(x + y + z), from_right(x + y + z);

  {
    ll pq_sum = 0;
    std::priority_queue<ll, std::vector<ll>, std::greater<ll>> pq;
    for (int i = 0; i < y; i++) {
      pq.push(p[i].b);
      pq_sum += p[i].b;
    }
    from_left[y - 1] = pq_sum;
    for (int i = y; i + x < x + y + z; i++) {
      pq.push(p[i].b);
      pq_sum += p[i].b - pq.top();
      pq.pop();
      from_left[i] = pq_sum;
    }
  }

  {
    ll pq_sum = 0;
    std::priority_queue<ll, std::vector<ll>, std::greater<ll>> pq;
    for (int i = (x + y + z) - 1; i >= (x + y + z) - x; i--) {
      pq.push(p[i].a);
      pq_sum += p[i].a;
    }
    from_right[(x + y + z) - x] = pq_sum;
    for (int i = (x + y + z) - x - 1; i >= y; i--) {
      pq.push(p[i].a);
      pq_sum += p[i].a - pq.top();
      pq.pop();
      from_right[i] = pq_sum;
    }
  }

  ll ans = LLONG_MIN;
  for (int i = y - 1; i + x < x + y + z; i++) {
    ans = std::max(ans, from_left[i] + from_right[i + 1]);
  }
  std::cout << (ans + offset) << "\n";
}


Measured memory_bytes: 5368
// AOJ 2878 Graph
// 2018.4.14 bal4u
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define QMAX 1000000
typedef struct { long long t; int s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, long long t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX 100002
int hi[MAX], *to[MAX], *d[MAX];
long long dist[MAX];

long long dijkstra(int n, int start, int goal)
{
	int i, s, e;
	long long t, nt;

	memset(dist, 0x10, n << 3);
	qsize = 0;
	enq(start, 0), dist[start] = 0;
	while (qsize) {
		s = que[0].s, t = que[0].t, deq();
		if (s == goal) break; 
		if (dist[s] < t) continue;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], nt = t + d[s][i];
			if (dist[e] > nt) dist[e] = nt, enq(e, nt);
		}
	}
	return t;
}

int main()
{
	int N, M, s, t, i, j, k, a, b, c, x;
	int *memo;

	N = in(), M = in(), s = in()-1, t = in()-1;
	memo = malloc(M<<4);
	j = 0; for (i = 0; i < M; i++) {
		memo[j++] = a = in()-1, memo[j++] = b = in()-1, memo[j++] = c = in()-1;
		memo[j++] = in();
		hi[a]+=2, hi[b]+=2, hi[c]+=2;
	}
	for (i = 0; i < N; i++) if (hi[i]) {
		to[i] = malloc(hi[i]<<2), d[i] = malloc(hi[i]<<2);
	}

	memset(hi, 0, N<<2);
	j = 0; for (i = 0; i < M; i++) {
		a = memo[j++], b = memo[j++], c = memo[j++], x = memo[j++];
		k = hi[a], hi[a]+=2;
		to[a][k] = b, d[a][k++] = x, to[a][k] = c, d[a][k] = x;
		k = hi[b], hi[b]+=2;
		to[b][k] = a, d[b][k++] = x, to[b][k] = c, d[b][k] = x;
		k = hi[c], hi[c]+=2;
		to[c][k] = a, d[c][k++] = x, to[c][k] = b, d[c][k] = x;
	}
	printf("%lld\n", dijkstra(N, s, t));
	return 0;
}


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

int main() {
  vector<int> A(3);
  cin>>A.at(0)>>A.at(1)>>A.at(2);
  sort(A.begin(),A.end());
  cout<<A.at(0)+A.at(1)+A.at(2)*10<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a=fsc.nextInt();
        int b=fsc.nextInt();
        fsc.close();
        if (a%2!=b%2) {
            System.out.print("IMPOSSIBLE");	
        } else {
        	System.out.print((a+b)/2);
        }
        
        
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

const int D_MAX = 100;
const int S_MAX = D_MAX;
const int M_MAX = 300;
const int K_MAX = 50;

int s, d, m;
int k[S_MAX];
int w[S_MAX][K_MAX];
int p[S_MAX][K_MAX];
int f[D_MAX];

int dp[M_MAX+1];

void solve()
{
    memset(dp, 0, sizeof(dp));
    REP(i, d) REP(j, k[f[i]]) for (int l = m-p[f[i]][j]; l >= 0; --l)
        dp[l+p[f[i]][j]] = max(dp[l+p[f[i]][j]], dp[l]+w[f[i]][j]);
    int ans0 = dp[m];
    int ans1 = lower_bound(dp, dp+m+1, ans0)-dp;
    cout << ans0 << ' ' << ans1 << endl;
}

int main()
{ 
    while (cin >> s >> d >> m) {
        REP(i, s) {
            cin >> k[i];
            REP(j, k[i]) cin >> w[i][j] >> p[i][j];
        }
        REP(i, d) cin >> f[i];
        solve();
    }
    return 0;
}


Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll d, c[30] = {}, s[370][30] = {}, last[30] = {}, ans[30][30][370] = {}, bestk = 0, bestl = 0, sum = 0, newsum = 0;

int main() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d) {
		rep(j, 26)cin >> s[i][j];
	}
	rep(k, 26) {
		last[k] = 0;
		rep(l, 26) {
			ll satisfaction = -1000000, contest = 0;
			last[l] = 1;
			satisfaction += s[0][k] + s[1][l];
			rep(i, 26) {
				if (i != k)satisfaction -= c[i];
				if (i != l)satisfaction -= c[l] * (1 - last[i]);
			}
			for (int i = 2; i < 26; i++)last[i] = -1;
			for (int i = 2; i < 26; i++) {
				rep(j, 26) {
					if (satisfaction < s[i][j] + c[j] * (i - last[j])) {
						satisfaction = s[i][j] + c[j] * (i - last[j]);
						contest = j;
					}
					ans[k][l][i] = contest;
					last[contest] = i;
				}
				newsum += satisfaction;
			}
			if (sum < newsum) {
				sum = newsum;
				bestk = k;
				bestl = l;
			}
		}
	}
	rep(i, d)cout << ans[bestk][bestl][i] + 1 << endl;
	return 0;
}

Measured memory_bytes: 5752
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int H,N;//H=hitpoint,N=技数
    cin>>H>>N;
    vector<pair<int,int>> B(N);
    REP(i,N){
        cin>>B[i].first>>B[i].second;
    }
    //inputend
    sort(ALL(B));//Bは威力順
    vector<int> Hitp(H+1,INT_MAX);
    Hitp[0]=0;
    REP(i,H+1){
        if(Hitp[i]==INT_MAX){
            continue;
        }
        REP(j,N){
            if(i+B[j].first>=H){
                Hitp[H]=min(Hitp[H],Hitp[i]+B[j].second);
            }else{
                Hitp[i+B[j].first]=min(Hitp[i+B[j].first],Hitp[i]+B[j].second);
            }
        }
    }
    cout<<Hitp[H]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;

    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    ll dp1[n],dp2[n],dp3[n];

    dp1[0] = a[0];
    dp2[0] = b[0];
    dp3[0] = c[0];
   //  cout<<dp1[0]<<" "<<dp2[0]<<" "<<dp3[0]<<endl;


    for(int i=1;i<n;i++)
    {
        dp1[i] = max(dp2[i-1],dp3[i-1])+a[i];
        dp2[i] = max(dp1[i-1],dp3[i-1])+b[i];
        dp3[i] = max(dp2[i-1],dp1[i-1])+c[i];
        //cout<<dp1[i]<<" "<<dp2[i]<<" "<<dp3[i]<<endl;
    }

    cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));

    return 0;
}


Measured memory_bytes: 8320
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        m: usize,
        x: u64,
        aa: [(u64,[u64;m]);n]
    }
    let check = |a: &[u64]| -> bool {
        a.iter().all(|v| x <= *v)
    };
    let assign = |a: &mut[u64], b: &[u64]|{
        for (l,r) in a.iter_mut().zip(b) {
            *l += *r;
        }
    };

    let mut res: u64 = std::u64::MAX;
    for b in 0..(1u64 << n) {
        let mut v = vec![0;m];
        let mut cc = 0;
        for (i, t) in aa.iter().enumerate() {
            let c = t.0;
            let a = &t.1;
            if b & (1 << i) != 0 {
                assign(&mut *v, &a);
                cc += c;
            }
        }
        if check(&v) {
            res = std::cmp::min(res, cc);
        }
    }
    if res == std::u64::MAX {
        println!("-1");
    } else {
        println!("{}", res);
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 2144
#include <iostream>

using namespace std;

int main()
{
    int n, d, x, a, eaten;

    cin >> n >> d >> x;
    eaten = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        for (int j = 0; ; j++) 
        if (a*j+1 <= d) {
            eaten++;
        } else {
            break;
        }
    }
    cout << x + eaten << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll h, w, m;
    cin >> h >> w >> m;
    vector<ll> a(m), b(m);
    vector<P> x(h), y(w);
    set<ll> s;
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        x[a[i]].first++;
        y[b[i]].first++;
        s.insert(a[i] * h + b[i]);
    }
    rep(i, h)
    {
        x[i].second = i;
    }
    rep(i, w)
    {
        y[i].second = i;
    }
    sort(x.begin(), x.end());
    reverse(x.begin(), x.end());
    sort(y.begin(), y.end());
    reverse(y.begin(), y.end());
    ll ans = x[0].first + y[0].first - 1;
    ll now = ans;
    rep(i, h)
    {
        bool ex = false;
        rep(j, w)
        {

            if (x[0].first == x[i].first && y[0].first == y[j].first)
            {
                if (!s.count(h * x[i].second + y[j].second))
                {
                    ans = max(ans, x[i].first + y[j].first - (ll)s.count(h * x[i].second + y[j].second));
                    ex = true;
                }
            }
            else
            {
                break;
            }
        }
        if (ex)
        {
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 31500
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e5;
const int mod=1e9+7;
const int M=20009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int id[M+3];
int pup[M+4];
int pdown[M+4];
int a[M+4];
int b[M+4];
 void solve()

{

    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>id[i];
    }
    f(i,1,n)
    {
        a[i]+=i;
    }
    for(int i=n,j=1;i>=1;i--,j++)
    {
        b[i]+=j;
    }
    for(int i=1;i<=n;i++)
    {
        int idx=id[i];
        b[idx]+=i;
        pdown[idx-1]+=i;
        pup[idx-1]-=i;
    }
    int yo=0;
    int cry=0;
    for(int i=n;i>=1;i--)
    {
         yo+=pdown[i];
         b[i]+=yo;
         cry+=pup[i];
         a[i]+=cry;
    }
    int mn=0;
    f(i,1,n)
    {
        mn=min(mn,a[i]);
    }
    f(i,1,n)
    {
        mn=min(mn,b[i]);
    }
    if(mn>0)mn=0;
    else mn=-mn+2;
    f(i,1,n)
    {
        cout<<a[i]+mn<<" ";
    }
    cout<<endl;
    f(i,1,n)
    {
        cout<<b[i]+mn<<" ";
    }
    cout<<endl;

}
 main()
 {
     //freopen("001.txt", "r", stdin);
     int t;
     t=1;
     while(t--)
     {
         solve();
     }
     return 0;
 }













Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    char b;
    cin >> b;

    char table[256];
    table['A'] = 'T';
    table['T'] = 'A';
    table['C'] = 'G';
    table['G'] = 'C';

    cout << table[b] << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

def lcm(a, b):
  return a * b // gcd (a, b)

x = A[0]
for i in range(1,N):
  x = lcm(x,A[i])
x -= 1
ans = 0
for i in range(N):
  ans += x % A[i]
print(ans)



Measured memory_bytes: 5344
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef unsigned long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)


int main() {
	ll N;
	scll(N);
	printf("%lld\n", (N + 1) / 2);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n, m;
	scanf("%d %d",&n,&m);
	int i,a[50],b[50],c[50],d[50];
	for(i=0;i<n;i++){scanf("%d %d",&a[i],&b[i]);}
	for(i=0;i<m;i++){scanf("%d %d",&c[i],&d[i]);}
	for(i=0;i<n;i++){
		int ab=abs(a[i]-c[0])+abs(b[i]-d[0]),e=1,j;
		for(j=0;j<m;j++){
			int k=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(k<ab){ab=k;e=j+1;}
		}
		printf("%d\n",e);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>

using namespace std;


int main(){
    long long int n;
    long long int n1;
    long long int *nn = (long long int *)(malloc(sizeof(long long int)*1000001));
    long long int q;
    long long int qq;
    long int ans=0;
    cin >> n;
    n1 = n;

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


    for(int i=0;(long long int)i*i<=n;i++){
        nn[i] = i;
    }

    for(int i=2;(long long int)i*i<=n;i++){
        for(int j=2*i;(long long int)j*j<=n;j+=i){
            nn[j] = -1;
        }
    } 


    for(int i=2;(long long int)i*i<=n1;i++){
        q = nn[i];
        qq = q;
        //cout << qq << " " << i << endl;
        if(nn[i] == -1) continue;

        while(!(n%qq)){
            n = n/qq;
            qq = qq*q;
            //cout << n  << " " << qq << endl;
            ans ++;
        }
    }

    if(n1/n < n) ans ++;

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

Measured memory_bytes: 11476
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a, b;
    cin >> a >> b;

    if (b%a==0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	private void doit() {
		while(true){
			int n = sc.nextInt();
			if(n == -1) break;
			int now = calc(n);
			System.out.println(4280 - now);
		}
	}

	private int calc(int n) {
		int res = 1150;
		if(n <= 10){
			return res;
		}
		if(n <= 20){
			return res + (n - 10) * 125;
		}
		if(n <= 30){
			return res + 1250 + (n - 20) * 140;
		}
		else {
			return res + 1250 + 1400 + (n - 30) * 160;
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 18648
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 1; i <= n ; i++)
#define MAX_N 400100

int par[MAX_N];
int myrank[MAX_N];

namespace std{
template <>
class hash<std::pair<int, int>> {
	public:
	size_t operator()(const std::pair<int, int>& x) const{
		return hash<int>()(x.first) ^ hash<int>()(x.second);
	}
};
}

void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		myrank[i] = 0;
	}
}

int find(int x){
	return par[x]==x?x:par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	
	if(myrank[x] < myrank[y]){
		par[x] = y;
	} else {
		par[y] = x;
		if(myrank[x] == myrank[y]) myrank[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}




signed main(){	
	int N, K, L, a, b;
	// map<pair<int,int>,int> mp;
	unordered_map<pair<int,int>,int> mp;
	cin>>N>>K>>L;
	
	init(N*2+5);
	
	rep(i, K){cin>>a>>b;unite(a,b);}
	rep(i, L){cin>>a>>b;unite(a+N,b+N);}
	
	rep(i,N) mp[make_pair(find(i), find(N+i))]++;
	
	rep(i,N) cout<<(i-1?" ":"")<<mp[make_pair(find(i),find(N+i))];
	
	cout<<endl;
	
	
	return 0;
}

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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"

typedef long long ll;
typedef unsigned long long llu;

int main()
{
    FastRead

    llu n,a,b,ans,div;

    cin>>n>>a>>b;

    div = n/(a+b);

    ans = a*div;

    n-=((a+b)*div);

    ans+=min(n,a);

    cout<<ans;
}


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

using namespace std;

const int N = 2e5 + 10;

int a[N];

int main() {
	int n;
	cin >> n;
	
	for (int i = 2; i <= n; i++) cin >> a[i];
	
	map<int, int> cnt;
	for (auto k : a) {
		cnt[k]++;
	}
	
	for (int i = 1; i <= n; i++) {
		cout << cnt[i] << '\n';
	}
	
	return 0;
}

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

using namespace std;
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; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int main(void){
	ll x, y; cin>>x>>y;

	//cout<< (ll)(log2(y / x) + 1) <<endl;

	ll tmp = x, len = 0;
	while(tmp <= y) {
		tmp *= 2;
		len++;
	}

	cout<< len <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main()
{
    int n, m; cin >> n >> m;
    UnionFind tree(n);
    rep(i, m){
        int a, b;cin >> a >> b;
        --a;--b;
        tree.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, tree.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<map>
#include<algorithm>
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	map<string, int>mp;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	ll ans = 0;
	for (auto& p : mp) {
		int s = p.second;
		ans += (ll)s * (s - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

void solve() {
	int h, w, a, b;
	read(h); read(w); read(a); read(b);
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			putchar(((i <= b) ^ (j <= a)) + '0');
		}
		puts("");
	}
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 1280
s = input()
t = input()
min_count = len(s)
for i in range(len(s) - len(t)+1):
    count = 0
    for j in range(len(t)):
        if s[i + j] != t[j]:
            count += 1
    if min_count > count:
        min_count = count
print(min_count)


Measured memory_bytes: 73172
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n,k,ar[N],ans,cnt;
ll sum[N];
ll seg[4*N];
vector < ll > vals;
map < ll,ll > mapper;

ll get_sum(ll i,ll j)
{
    if(i == 0)
        return sum[j];

    return sum[j] - sum[i-1];
}

ll query(ll low,ll high,ll pos,ll slow)
{
    if(high <= slow)
        return seg[pos];
    if(low > slow)
        return 0;

    ll mid = (low+high)/2;

    return query(low,mid,pos*2+1,slow)+query(mid+1,high,pos*2+2,slow);
}

void update(ll low,ll high,ll pos,ll slow)
{
    if(low == slow && low == high)
    {
        seg[pos]++;
        return;
    }
    if(low > slow || high < slow)
        return;

    ll mid = (low+high)/2;

    update(low,mid,pos*2+1,slow);
    update(mid+1,high,pos*2+2,slow);
    seg[pos] = seg[pos*2+1] + seg[pos*2+2];
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;

    rep(i,0,n)
    {
        cin >> ar[i];

        ar[i] -= k;

        if(i == 0)
            sum[i] = ar[i];
        else
            sum[i] = sum[i-1] + ar[i];

        vals.push_back(sum[i]);
    }

    vals.push_back(0);
    sort(vals.begin(),vals.end());

    rep(i,0,vals.size())
    {
        if(!mapper[vals[i]])
        {
            mapper[vals[i]] = cnt;
            cnt++;
        }
    }

    update(0,cnt,0,mapper[0]);

    rep(i,0,n)
    {
   //     cout << sum[i] << " " << mapper[sum[i]] << " " << query(0,cnt,0,mapper[sum[i]]) << endl;
        ans += query(0,cnt,0,mapper[sum[i]]);
        update(0,cnt,0,mapper[sum[i]]);
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 25584
def abstract(str)
    count = 0
    map = {}
    map.default = -1
    str.chars.map{|c|
        n = map[c]
        if n == -1
            map[c] = count
            n = count
            count += 1
        end
        n
    }
end

if abstract(gets.chomp) == abstract(gets.chomp)
    puts "Yes"
else
    puts "No"
end


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

using namespace std;

int main(int argc, const char *argv[]) {
  char a, b, c, d;
  cin >> a >> b >> c >> d;

  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 2; ++k) {
        int sum = a - '0';
        int d1 = b - '0';
        int d2 = c - '0';
        int d3 = d - '0';
        sum += (i == 0) ? -d1 : d1;
        sum += (j == 0) ? -d2 : d2;
        sum += (k == 0) ? -d3 : d3;

        if (sum == 7) {
          string ans = "";
          ans += a;
          ans += i == 0 ? '-' : '+';
          ans += b;
          ans += j == 0 ? '-' : '+';
          ans += c;
          ans += k == 0 ? '-' : '+';
          ans += d;
          ans += "=7";
          cout << ans << '\n';
          return 0;
        }
      }
    }
  }
  return 0;
}

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}

void calculate(){
    int W,H,N;
    Input::input(W,H,N);
    int lx = 0,rx = W,dy = 0, uy = H;
    int x,y,a;
    rep(i,N){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                lx = max(lx,x);
                break;
            case 2:
                rx = min(rx,x);
                break;
            case 3:
                dy = max(dy,y);
                break;
            case 4:
                uy = min(uy,y);
                break;
        }
    }
    if(lx >= rx or dy >= uy){
        cout << 0 << '\n';
        return;
    }
    cout << (rx - lx) * (uy - dy) << '\n';
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    int A, B;
    cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
        cout << A * B;
    } else {
        cout << -1;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int A;
	static int B;
	static int C;
	static int D;
	static int a=0;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();
		D=sc.nextInt();
		fight();
	}
	static void fight() {
		C=C-B;
		if(C<=0) {
			System.out.println("Yes");
		}
		else {
			A=A-D;
			if(A<=0) {
				System.out.println("No");
			}
			else {
				fight();
			}
		}
	}
}

Measured memory_bytes: 35824
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

std::string S;

ll expr( const std::string &s )
{
  ll p = 0, ret = 0;

  while( p < s.size() )
  {
    ll num = 0;

    while( p < s.size() && s[p] != '+' )
      num *= 10, num += s[p]-'0', ++p;

    ret += num;
    ++p;
  }

  return ret;
}

ll rec( int i, std::string acc )
{
  if( i == S.size()-1 )
  {
    acc += S[i];
    
    return expr(acc);
  }

  ll ret = 0;

  ret += rec( i+1, acc+S[i]+"+" );
  ret += rec( i+1, acc+S[i] );

  return ret;
}

int main()
{
  std::cin >> S;
  
  std::cout << rec( 0, "" ) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long f[500][100500],n,m,w[100000],v[1000000];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (long i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for (long i=1;i<=n;i++)
    {
        for (long j=1;j<=m;j++)
        {
            f[i][j]=f[i-1][j];
            if (j>=w[i])
            {
                f[i][j]=max(f[i-1][j], f[i-1][j-w[i]] + v[i] );
            }
        }
    }
    cout<<f[n][m];
}


Measured memory_bytes: 82176
S = input()

flag = 0
for i in range(len(S)):
  if i%2 == 0:
    if (S[i] == 'L'):
      flag = 1
      break
  else:
    if (S[i] == 'R'):
      flag = 1
      break

if flag == 0:
  print("Yes")
else:
  print("No")

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

int main(){
	
	int a,b,m;
	cin >> a >> b >> m;
	vector<int> an,bn;
	for (int i = 0; i < a; i++){
		int temp;
		cin >> temp;
		an.push_back(temp);
	}
	for (int i = 0; i < b; i++){
		int temp;
		cin >> temp;
		bn.push_back(temp);
	}
	int best = 1e9+5;
	for (int i = 0; i< m; i++){
		int x,y,c;
		cin >> x >> y >> c;
		best = min(best, an[x-1]+bn[y-1]-c);
	}
	int mina = *min_element(an.begin(),an.end());
	int minb = *min_element(bn.begin(), bn.end());
	best = min(best, mina+minb);
	cout << best;
	return 0;
}


Measured memory_bytes: 1400
import numpy as np

N = int(input())
num = ['3', '5', '7']
numbers_753 = []
prev = ['']
for _ in range(9):
    temp = []
    generated = []
    for p in prev:
        for n in num:
            cand = p+n
            generated.append(cand)
            if '3' in cand and '5' in cand and '7' in cand:
                temp.append(int(p+n))
    numbers_753 += temp
    prev = generated
numbers_753 = np.array(numbers_753)
print(sum(numbers_753 <= N))

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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

int find_lower(int *a, int n, int v){
    int l = -1, r = n;

    while (r-l > 1){
        int m = (l+r)/2;
        if (a[m] <= v) l = m;
        else r = m;
    }
    return l;
}

void init(){
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}

bool ok(vector<int> a, int k, int x){ //n=6, k=4, x=4, a={1,2,3,4,5,6}
    int n = (int) a.size(); 
    int s = 0;
    int z = 0;
    while (n-z >= k){
        sort(a.rbegin(), a.rend());
        int g = 0;
        for (int i = 0; i < n && g < k; i++){
            if (a[i] > 0){
                g++;
                a[i]--;
                if (a[i] == 0) z++;
            }
        }
        if (g == k) s++;
    }
    return s >= x;
}

void solve(){
    int h, a;
    cin >> h >> a;
    if (h % a == 0) cout << h/a;
    else cout << h/a + 1;
    cout << '\n';
}

int main(){
    //init();

    ios::sync_with_stdio(false);
    cin.tie(0);

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

vector<ll> a, p;
ll f(int N, ll X) {
  if (N==0) {
    if (X<=0) return 0;
    else return 1;
  }
  else if (X<=1+a[N-1]) return f(N-1, X-1);
  else return p[N-1]+1+f(N-1, X-2-a[N-1]);
}

int main() {
  int N;
  ll X;
  cin >> N >> X;
  a.assign(N+1, 0);
  p.assign(N+1, 0);
  a[0] = 1, p[0] = 1;
  for (int i=1; i<=N; i++) {
    a[i] = 2*a[i-1]+3;
    p[i] = 2*p[i-1]+1;
  }
  cout << f(N, X) << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {

	string s, t;
	cin >> s >> t;

	int ans = 0;
	int n = s.size();
	REP(i, n) {
		if (s[i] != t[i])ans++;
	}
	cout << ans << endl;

}

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


void solve(long long a){

    cout <<  a + a*a + a*a*a << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 100

void swap(int *a, int *b);
int bubbleSort(int a[], int n);
int main() {
    int n, a[MAX];
    cin >> n;
    int i, j, count;
    for (i = 0; i < n; i++) cin >> a[i];
    count = bubbleSort(a, n);

    for (i = 0; i < n; i++) cout << a[i] << (i < n - 1 ? " " : "\n");
    cout << count << endl;

    return 0;
}

int bubbleSort(int a[], int n) {
    int count, i, j;
    count = 0;
    bool flag = 1;
    for (i = 0; flag; i++) {
        flag = 0;
        for (j = n - 1; j >= i + 1; j--) {
            if (a[j - 1] > a[j]) {
                flag = 1;
                swap(a[j - 1], a[j]);
                count++;
            }
        }
    }
    return count;
}


Measured memory_bytes: 3084