akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Echo
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  if (n & 1) {
    puts("No");
    return 0;
  }

  int m = n / 2;
  for (int i = 0, j = m; i < m; i++, j++)
    if (s[i] != s[j]) {
      puts("No");
      return 0;
    }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
@letters = [*"a".."z"]

def max(a, b)
  return a > b ? a : b
end

def dfs(s, mx)
  if s.length == @n
    puts s
    return
  end
  @letters.each do |v|
    if v == mx.succ.succ
      break
    end
    t = s + v
    dfs(t, max(mx, v))
  end
end

def main()
  @n = gets.chomp.to_i
  dfs("a", "a")
end

main()

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;

class MaxFlow {
	struct edge {
		int to, cap, rev;
		edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	int DFS(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

public:
	MaxFlow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	int Dinic(int s, int t) {
		int flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m, n | m) {
		vector<int> u(m), v(m);
		for (int i = 0; i < m; i++) {
			cin >> u[i] >> v[i]; u[i]--; v[i]--;
		}
		int mi, ma;
		int l = 0, r = 50;
		while (l + 1 < r) {
			int c = (l + r) / 2;
			MaxFlow mf(n + m + 2);
			for (int i = 0; i < n; i++) {
				mf.add(n + m, i, c);
			}
			for (int i = 0; i < m; i++) {
				mf.add(u[i], n + i, 1);
				mf.add(v[i], n + i, 1);
				mf.add(n + i, n + m + 1, 1);
			}
			if (mf.Dinic(n + m, n + m + 1) == n * c) {
				l = c;
			}
			else {
				r = c;
			}
		}
		mi = l;
		l = 0, r = 100;
		while (l + 1 < r) {
			int c = (l + r) / 2;
			MaxFlow mf(n + m + 2);
			for (int i = 0; i < n; i++) {
				mf.add(n + m, i, c);
			}
			for (int i = 0; i < m; i++) {
				mf.add(u[i], n + i, 1);
				mf.add(v[i], n + i, 1);
				mf.add(n + i, n + m + 1, 1);
			}
			if (mf.Dinic(n + m, n + m + 1) == m) {
				r = c;
			}
			else {
				l = c;
			}
		}
		ma = r;
		cout << mi << ' ' << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 3676
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 max = a + b;
		if((a - b) > max)
			max = a-b;
		if((a * b) > max)
			max = a * b;
		System.out.println(max);
	}
		
}


Measured memory_bytes: 22228
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
if '9' in s:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 74332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
double ev[305][305][305];
int n;
double solve(int a, int b , int c){
    if(!a && !b && !c){
        return 0;
    }
    if(ev[a][b][c] != -1){
        return ev[a][b][c];
    }
    ev[a][b][c] = 0;
    double sum = a+b+c;
    double waste = 1.0*(n-sum)/n;
    if(a){
        ev[a][b][c] += (1.0*a/n)*(1+solve(a-1,b+1,c));
    }
    if(b){
        ev[a][b][c] += (1.0*b/n)*(1+solve(a,b-1,c+1));
    }
    if(c){
        ev[a][b][c] += (1.0*c/n)*(1+solve(a,b,c-1));
    }
    ev[a][b][c] += ev[a][b][c]*(waste/(1-waste));
    ev[a][b][c] += waste/(1-waste);
    return ev[a][b][c];
}
int main() {
    IO;
    cin >> n;
    int temp;
    int cnt[4] = {};
    for(int i = 0; i < n; i++){
        cin >> temp;
        cnt[temp]++;
    }
    for(int i = 0; i < 305; i++){
        for(int j = 0; j < 305; j++){
            for(int k = 0; k < 305; k++){
                ev[i][j][k] = -1;
            }
        }
    }
    ev[0][0][0] = 0;
    solve(cnt[3], cnt[2], cnt[1]);
    cout << setprecision(10) << fixed << ev[cnt[3]][cnt[2]][cnt[1]];


    return 0;
}


Measured memory_bytes: 221952
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>

using namespace std;
#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

constexpr double PI = 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    ll r;
    cin >> r;
    cout << fix(15) << (r * 2) * PI;

    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

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

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

long long dp[300][90010];
long long dp2[300][90010];

int main(){
  
  int n;
  cin>>n;
  int a[n];
  int s = 0;
  REP(i,n){
    cin>>a[i];
    s += a[i];
  }
  
  long long all_ = 1LL;
  REP(i,n){
    all_ *= 3;
    all_ = mod(all_);
  }
  
  //long long dp[n][s+1] = {};
  REP(i,n){
    if(i==0){
      dp[i][0] = 2;
      dp[i][a[i]] = 1;
      continue;
    }
    REP(j,s+1){
      if(j+a[i]>s)break;
      dp[i][j+a[i]] += dp[i-1][j];
      dp[i][j+a[i]] = mod(dp[i][j+a[i]]);
    }
    REP(j,s+1){
      dp[i][j] += 2*dp[i-1][j];
      dp[i][j] = mod(dp[i][j]);
    }
  }
  
  long long temp = 0;
  REP(j,s+1){
    if(j<(s+1)/2){
      continue;
    }
    temp += dp[n-1][j];
    temp = mod(temp);
  }
  
  long long ans;
  if(s%2 == 1){
    ans = all_ - 3LL*temp;
    ans = mod(ans);
    cout<<ans<<endl;
    return 0;
  }
  
  ans = all_ - 3LL*temp;
  ans = mod(ans);
  
  //long long dp2[n][s+1] = {};
  REP(i,n){
    if(i==0){
      dp2[i][0] = 1;
      dp2[i][a[i]] = 1;
      continue;
    }
    REP(j,s+1){
      if(j+a[i]>s)break;
      dp2[i][j+a[i]] += dp2[i-1][j];
      dp2[i][j+a[i]] = mod(dp2[i][j+a[i]]);
    }
    REP(j,s+1){
      dp2[i][j] += dp2[i-1][j];
      dp2[i][j] = mod(dp2[i][j]);
    }
  }
  
  temp = dp2[n-1][s/2];
  ans = ans + 3LL*temp;
  ans = mod(ans);
  cout<<ans<<endl;
      
  return 0;
}

Measured memory_bytes: 421504
n, k = map(int, input().split())

diff = n * (n - 1) // 2 - (n - 1) - k

if diff < 0:
    print(-1)
    exit()

m = (n - 1) + diff
res = [[1, i] for i in range(2, n + 1)]
i = 2
j = 3

while diff:
    diff -= 1
    res.append([i, j])
    j += 1
    if j > n:
        i += 1
        j = i + 1

print(m)
for x, y in res:
    print(x, y)


Measured memory_bytes: 4120
#include <stdio.h>
int main(void){
int i,n,s=100000;
scanf("%d",&n);
for(i=0;i<n;i++){
s=s*105/100;
if(s%1000>0)s=(s/1000+1)*1000;

}
printf("%d\n",s);
return 0;
}



Measured memory_bytes: 2028
n, m = gets.chomp.split(" ").map(&:to_i)

s = gets.chomp
t = gets.chomp

l = n.lcm(m)

x = Hash.new(nil)

n.times do |i|
  j = i * (l / n)
  x[j] = s[i]
end

m.times do |i|
  j = i * (l / m)
  if !x[j].nil?
    if x[j] != t[i]
      puts -1
      exit
    end
  end
end

puts l

Measured memory_bytes: 11772
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define debug(a) cout<<a<<endl
#define clr(a) memset(a,0,sizeof(a))
#define clrne(a) memset(a,-1,sizeof(a))
#define clrinf(a) memset(a,0x3f,sizeof(a))
#define clrneinf(a) memset(a,0xc0,sizeof(a))
#define pb(a) push_back(a)
#define maxn 10001
#define mod 1000000007
#define eps 1e-9
#define inf 0x7fffffff

int main()
{
//  freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
    ll n;
    scanf("%d",&n);
    ll a,b,c;
    int done = 0;
    for (a = 1; !done&&a<=3500; a++)
        for (b = a; !done&&b<=3500; b++)
        {
            double nn = 4.0/n;
            nn -= (1.0/a + 1.0 / b);
            c = 1.0/nn+eps;
            if (c>0&&a*b*c*4==n*(a*b+b*c+a*c))
            {
                cout<<a<<' '<<b<<' '<<c<<endl;
                done = 1;
            }
        }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    
    while(cin >> a >> op >>b){
    
    if(op == '+'){
        cout << (a+b) << endl;
    }else if(op == '-'){
        cout << (a-b) << endl;
    }else if(op == '*'){
        cout << (a*b) << endl;
    }else if(op=='/'){
        cout << (a/b) << endl;
    }else if(op=='?')
    break;
        
    }
    
}


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

using lint = int64_t;
#define bit(n) (lint(1) << n)
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);

        cout << fixed << setprecision(12);
    }
} iosetup;

int main() {
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int last = 0;
    for (int i = 0; i < n - 1; i++) {
        int tmp = a[i] + a[i + 1];
        if (tmp >= l) {
            last = i + 1;
            break;
        }
    }

    if (last == 0) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
        for (int i = 1; i < last; i++) {
            cout << i << endl;
        }
        for (int i = n - 1; i > last; i--) {
            cout << i << endl;
        }
        cout << last << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
int a, b;
using namespace std;
int main(){
    cin >> a >>b;
    vector<int> vec = {a+b, a-b, a*b};
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    cout << vec[0] << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int inf = 1e9;

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

vi g[300005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b + n);
		g[a + n].pb(b + 2 * n);
		g[a + 2 * n].pb(b);
	}
	int s, t;
	cin >> s >> t;
	s--, t--;
	vector<int> dist(3 * n, inf);
	dist[s] = 0;
	queue<int> q;
	q.push(s);
	while(!q.empty()){
		int cur = q.front();
		q.pop();
		for(int u : g[cur]){
			if(dist[u] > dist[cur] + 1){
				dist[u] = dist[cur] + 1;
				q.push(u);
			}
		} 
	}
	if(dist[t] == inf) cout << -1 << endl;
	else cout << dist[t] / 3 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 17792
#include<stdio.h>
#include<vector>
#include<set>
#include<iostream>

const int MAX = 2 * 1000005 + 10;

using namespace std;
long long A[MAX] = { 0 };
long long B[MAX] = { 0 };

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        B[A[i]]++;
    }
    long long sum = 0;
    for (int i = 1; i < N+1; i++)
    {
        sum += B[i] * (B[i] - 1)/2;
    }
    for (int i = 0; i < N; i++)
    {
        cout << sum - (B[A[i]] - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 7296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            long gcd = a[0];
            for (int i = 0; i < n; i++) {
                gcd = Euclid.gcd(gcd, a[i]);
            }

            int cnt = 0;
            while (gcd % 2 == 0) {
                cnt++;
                gcd >>= 1;
            }

            out.println(cnt);
        }

    }

    static class Euclid {
        public static long gcd(long a, long b) {
            return a == 0 ? b : gcd(b % a, a);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 23508
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type priorityQueue []int

func (p priorityQueue) Len() int            { return len(p) }
func (p priorityQueue) Less(i, j int) bool  { return p[i] > p[j] }
func (p priorityQueue) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
func (p *priorityQueue) Push(x interface{}) { *p = append(*p, x.(int)) }
func (p *priorityQueue) Pop() interface{} {
	old := *p
	n := len(old)
	x := old[n-1]
	*p = old[0 : n-1]
	return x
}

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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ts := make(map[int][]int)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		ts[a] = append(ts[a], b)
	}

	pq := make(priorityQueue, n)
	heap.Init(&pq)
	ans := 0
	for i := 1; i <= m; i++ {
		if _, ok := ts[i]; ok {
			for _, v := range ts[i] {
				heap.Push(&pq, v)
			}
		}
		if len(pq) > 0 {
			ans += heap.Pop(&pq).(int)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 12544
#include<cstdio>

int main(){
    int a[4],f,s;
    f = 0;
    s = 0;
    for(int i = 0;i < 3;i++){
        scanf("%d",&a[i]);
    }
    for(int i = 0;i < 3;i++){
        if(a[i] == 5) f++;
        else if(a[i] == 7) s++;
    }
    if(f == 2 && s == 1){
        printf("YES\n");
        
    }
    else{
        printf("NO\n");
    }
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);
            var B = cin.ReadIntArray(N);
            var C = cin.ReadIntArray(N - 1);

            var sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += B[A[i] - 1];
                if (i > 0 && A[i] == A[i - 1] + 1)
                {
                    sum += C[A[i - 1] - 1];
                }
            }

            Console.WriteLine(sum);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
from math import ceil

N = int(input())

ans = [0] * N
for i in range(1, N):
    c, s, f = [int(zz) for zz in input().split()]
    ans[i] = s + c
    for j in range(1, i):
        p = ceil(ans[j] / f) * f
        if p < s:
            ans[j] = s + c
        else:
            ans[j] = c + p

for i in range(1, N):
    print(ans[i])

print(0)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,W;
ll dp[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,100001) dp[i]=1LL<<60;
	dp[0]=0;
	
	cin>>N>>W;
	while(N--) {
		cin>>x>>y;
		for(i=100000;i>=0;i--) dp[i+y]=min(dp[i+y],dp[i]+x);
	}
	
	for(i=100000;i>=0;i--) if(dp[i]<=W) return _P("%d\n",i);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



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

int main() {
  int a,b;
  int cnt=0;
  
  cin >> a >> b;
  
  for (int i=a; i<=b; i++){
    string num;
    num=to_string(i);
    if (num[0]==num[4] && num[1]==num[3]){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;


    
int main(){
  int n; cin >> n; ll a[n];
  rep(i, n){
    cin >> a[i];
  }
  if(a[0]!=0){
    cout << -1 << endl; return 0;
  }
  rep(i, n-1){
    if(a[i+1]>a[i]+1){
      cout << -1 << endl; return 0;
    }
  }
  ll ans = 0;
  for(int i=1; i<n; i++){
    if(a[i]==a[i-1]+1) ans++;
    else ans+=a[i];
  }
  cout << ans << endl; 
}

Measured memory_bytes: 5196
import java.util.Arrays;
    import java.util.Scanner;
     
    public class Main {
     
        public static void main(String[] args) {
           
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0 ; i < n ; i++) {
                a[i] = sc.nextInt();
            }
            Arrays.sort(a);
            int ans = 0;
            for (int i = 0 ; i < k ; i++) {
                ans += a[i];
            }
            System.out.println(ans);
        }
     
    }

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;             
  if (a > 9 || b > 9) cout << -1 << '\n';
  else cout << a * b << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

int N, D;
vector< vector<int> > M;

bool input() {
    cin >> N >> D;
    if (N == 0) return false;
    M.clear(); M.resize(N);
    for (int i = 0; i < N; i++) {
        int m; cin >> m;
        for (int j = 0; j < m; j++) {
            int x; cin >> x;
            M[i].push_back(x);
        }
    }
    return true;
}

struct P {
    int index, power, mindex;
    P() {}
    P(int index, int power, int mindex) : index(index), power(power), mindex(mindex) {}
    bool operator<(const P& p) const {
        if (power == p.power) return index < p.index;
        return power < p.power;
    }
};
ostream& operator<<(ostream& os, const P& p) {
    os << "P(" << p.index << " " << p.power << " " << p.mindex << ")";
    return os;
}

#define iterator set<P>::iterator

const int INF = 1<<28;

int MinPower(const set<P>& s) {
    if (s.empty()) return INF;
    return s.begin()->power;
}
int MaxPower(const set<P>& s) {
    if (s.empty()) return 0;
    iterator it = s.end(); it--;
    return it->power;
}

void solve() {
    set<P> Q[2];
    int cur = 0, next = 1;
    for (int i = 0; i < N; i++) {
        Q[cur].insert(P(i, 0, 0));
    }
    bool updated = true;
    while (updated) {
        //for (iterator it = Q[cur].begin(); it != Q[cur].end(); it++) { cout << *it << " "; } cout << endl;
        updated = false;
        int Min, Max;
        for (iterator it = Q[cur].begin(); it != Q[cur].end(); it++) {
            iterator it2 = it; it2++;
            if (it2 == Q[cur].end()) {
                Min = MinPower(Q[next]);
                Max = MaxPower(Q[next]);
            } else {
                Min = min(it2->power, MinPower(Q[next]));
                Max = max(it2->power, MaxPower(Q[next]));
            }
            if (it->mindex == M[it->index].size()) {
                Q[next].insert(*it);
            } else {
                int npower = it->power + M[it->index][it->mindex];
                if (max(Max, npower) - min(Min, npower) <= D) {
                    Q[next].insert(P(it->index, npower, it->mindex + 1));
                    updated = true;
                } else {
                    Q[next].insert(*it);
                }
            }
        }
        swap(cur, next);
        Q[next].clear();
    }

    for (iterator it = Q[cur].begin(); it != Q[cur].end(); it++) {
        if (M[it->index].size() != it->mindex) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n,k;
    cin>>n>>k;
    vi a(n);
    cin>>a;
    vi count(41,0);
    for(ll i=0;i<=40;i++)
    {
        for(ll k1=0;k1<n;k1++)
        {
            if((1ll<<i)&a[k1])
                count[i]++;
        }
    }
    ll num=0;
    for(ll i=40;i>=0;i--)
    {
        if(count[i]<=n/2)//0 is a majority so place 1 here
        {
            ll num1=(num|(1ll<<i));
            if(num1<=k)
            {
                num=num1;
            }
            //tr3(i,num,num1);
        }
    }
    //tr1(num);
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ans+=(num^a[i]);
    }
    cout<<ans<<nl;
} 


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,x,n) for(int i=(x);i<(n);i++)
#define INT_MAX 2147483647

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
    
    int n,d,ans=0;
    cin >> n >> d;

    ans = (n + 2*d)/(2*d + 1);

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list( map( int, input().split()))
B = [0]*(N+1)
for x in A:
    B[x] = 1
for i in range(N):
    B[i+1] += B[i]
print( min(B[X]-B[0],B[N]-B[X]))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n,c,b,a;
  vector<ll> take(3);
  cin >> n >> a >> b >> c;
  int use = n - 3 + 1;

  vector<ll> l(n);
  map<ll,bool> mp;
  rep(i,n) {
    cin >> l[i];
    mp[l[i]] = true;
  }

  ll ans = INF;
  sorti(l);
  // cout << use << endl;
  do {
    int limitb, limitc;
    for (int i = 0; i < use; ++i) {
      ll tmpa = 0, tmp = 0;
      ll a1 = l[0];

      for (int t = 1; t <= i; ++t) {
        a1 += l[t];
        tmpa += 10;
      }
      tmpa += abs(a - a1);
      
      limitb = (n - (i+1) == 2) ? 1 : (n - (i+1) - 1);
      for (int j = i + 1; j <= i + limitb; ++j) {
        ll b1 = l[i+1], tmpb = 0;
        for (int t = i+2; t <= j; ++t) {
          b1 += l[t];
          tmpb += 10;
        }

        tmpb += abs(b - b1);
        
        limitc = (n - (j + 1) == 1) ? 1 : n - (j + 1);
        for (int k = j+1; k <= j + limitc; ++k) {
          ll c1 = l[j+1], tmpc = 0;
          for (int t = j+2; t <= k; ++t) {
            c1 += l[t];
            tmpc += 10;
          }

          tmpc += abs(c - c1);
          ans = min(ans,tmpa + tmpb + tmpc);
        }
      }

    }

  } while (next_permutation(l.begin(), l.end()));

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int min3(int a,int b,int c)
{
    return min(min(a,b),c);
}
int max3(int a,int b,int c)
{
    return max(max(a,b),c);
}
int gcd(int x, int y)
{
    if(y==0)return x;
    return gcd(y, x%y);
}
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
const int maxn = 5e5+5;
int dir[4][2] = {0,1,0,-1,-1,0,1,0};

ll n,m;
ll ans;
char s[405][405];
ll p[maxn],cnt[maxn],vis[maxn];
ll Hash(ll x,ll y)
{
    return x*450+y;
}
ll Find(ll x)
{
   return x == p[x]?x:p[x] = Find(p[x]);

}
void join(ll x,ll y)
{
    x = Find(x),y = Find(y);
    if(x!=y)
    {
        p[x] = y;
        cnt[y] += cnt[x];
        vis[y] += vis[x];
    }
}
void init()
{
    for(int i=0; i<maxn; i++)
    {
        p[i] = i;
        cnt[i] = 1;
    }
}
int main()
{
    init();
    scanf("%lld%lld",&n,&m);
    for(int i=1; i<=n; i++)
        scanf("%s",s[i]+1);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            if(s[i][j] == '#')
                vis[Hash(i,j)] = 1;

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            for(int k=0; k<4; k++)
            {
                int x = i+dir[k][0];
                int y = j+dir[k][1];
                if(x>0 && x<=n && y>0 && y<=m && s[i][j]!=s[x][y])
                {
                    join(Hash(x,y),Hash(i,j));
                }
            }
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            ll xx = Find(Hash(i,j));
            if(cnt[xx]>1)
            {
                ans += vis[xx]*(cnt[xx]-vis[xx]);
                cnt[xx] = 0;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 11520
#include <stdio.h>
#define L 1
#define B 2
double p[110][110][110]; // [ターン][前ターンの位置][現在地]
int main(void)
{
    int n, t, l, b;
    while (scanf("%d%d%d%d", &n, &t, &l, &b), n) {
        int a[110]={0};
        int i, j, k, d;
        double res;
        for(i=0;i<l;++i) { int x; scanf("%d", &x), a[x]=L; }
        for(i=0;i<b;++i) { int x; scanf("%d", &x), a[x]=B; }

        for(i=0;i<=t;++i) for(j=0;j<=n;++j) for(k=0;k<=n;++k) p[i][j][k]=0;
        p[0][0][0]=1;
        for(i=1;i<=t;++i) for(j=0;j<n;++j) for(k=0;k<n;++k) {
            if (a[k]==L && j!=k) {
                p[i][k][k]+=p[i-1][j][k];
                continue;
            }
            for(d=1;d<=6;++d) {
                int nextpos=k+d;
                if (nextpos>n) nextpos=n-(nextpos-n);
                if (a[nextpos]==B) nextpos=0;
                // Lの位置で1回休んだあと駒を進めたら折り返して
                // また同じ位置に戻ってきた場合は0から移動したことにする。
                // （上のa[k]==L && j!=kで拾うため）
                if (a[k]==L && k==nextpos)
                    p[i][0][nextpos]+=p[i-1][j][k]/6;
                else
                    p[i][k][nextpos]+=p[i-1][j][k]/6;
            }
        }

        res=0;
        for(i=1;i<=t;++i) for(j=0;j<n;++j) res+=p[i][j][n];
        printf("%.6f\n", res);
    }
    return 0;
}

Measured memory_bytes: 10788
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String x = sc.next();
        // final String y = sc.next();

        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int C = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(A <= C && B >= C ? "Yes" : "No");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21844
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
  int x,y,z,n,tmp,t;
  for(;;){
    cin>>x;
    cin>>y;
    cin>>z;
    if(x==0&&y==0&&z==0)
      break;
    cin>>n;
    vector<int> r;
    for(int i=0;i<n;i++){
      cin>>tmp;
      r.push_back(tmp*tmp*4);
    }
    t=min(min(x*x+y*y,y*y+z*z),x*x+z*z);
    for(vector<int>::iterator i=r.begin();i<r.end();i++){
      if(*i>t)
	cout<<"OK"<<endl;
      else
	cout<<"NA"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
/*
Written By mafailure
*/
//In the name of God
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))
#define clr(a,b) memset(a,b,sizeof(a))
const int inf= INT_MAX;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{ 
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n;
	cin>>n;
	string s;
	cin>>s;
	int white=0;
	int red=0;
	
	fr(i,0,s.length())
	{
		 white+=(s[i]=='W');
		 red+=(s[i]=='R');
	}
	int cnt=0;
	
	fr(i,0,red)
	{
		cnt+=(s[i]=='R');
	}
	int ans=red-cnt;
	cnt=0;
	fr(i,red+1,n)
	{
		cnt+=(s[i]=='W');
	}
	ans=min(ans,white-cnt);
	cout<<ans<<endl;
	
	
}



Measured memory_bytes: 3748
#include <iostream>
using namespace std;
int main (void) {
    string S;

    cin >> S;

    int abc[3] = {0};
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'a') {
            abc[0]++;
        } else if (S[i] == 'b') {
            abc[1]++;
        } else if (S[i] == 'c') {
            abc[2]++;
        }
    }
    bool ans = true;
    for (int i = 0; i < 3; i++) {
        if (abc[i] == 0) {
            ans = false;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		Scanner in = new Scanner(System.in);
		char[] str = in.next().toCharArray();
		int len = str.length - 1;
		int num = (1 << len) - 1;
		char[][] bit = new char[num+1][];
		for (int i = 0; i <= num; i++) {
			if (len > 0) {
				bit[i] = String.format("%"+len+"s",Integer.toBinaryString(i))
						.replace(' ', '0').toCharArray();
			}
		}

		List<String> list = new ArrayList<>();

		for (int i = 0; i <= num; i++) {
			StringBuffer sb = new StringBuffer();
			for (int j = 0; j < str.length; j++) {
				sb.append(str[j]);
				if (bit[i] != null && j < bit[i].length && bit[i][j] == '1') {
					sb.append('a');
				}
			}
			list.add(sb.toString());
		}

		long sum = 0;
		for (String string : list) {
			String[] strings = string.split("a");
			for (String moji : strings) {
				sum += Long.parseLong(moji);
			}
		}
		System.out.println(sum);
	}
}


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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


int main()
{
    zig
    string s, t;
    cin>>s;
    int n=0;
    t="";
    for(char b:s)
    {
        if(b=='B')
        {
            if(n)
                n--;
        }
        else
        {
            t[n]=b;
            n++;
        }
    }
    for(int i=0; i<n; i++)
        cout<<t[i];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,k,j,l;
    scanf("%d%d",&n,&k);
    int a[n+3];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=(n-k);i++){
        if(a[k+i]>a[i])
          printf("Yes\n");
        else
          printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 4452
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if ((A1 + A2 + A3) >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int, A: int):
    from math import ceil
    print(ceil(H/A))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] x=new long[n];
		long[] y=new long[n];
		int ans=Integer.MAX_VALUE;
		for(int i=0; i<n; i++){
			x[i] = sc.nextLong();
			y[i]= sc.nextLong();
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				Unionfind uf=new Unionfind(n);
				long xx=x[i]-x[j];
				long yy=y[i]-y[j];
				for(int k=0; k<n;k++){
					for(int t=0; t<n;t++){
						if(x[k]-x[t]==xx && y[k]-y[t]==yy){
							uf.unite(k,t);
						}
					}
				}
				ans=Math.min(ans,uf.count());
			}
		}
		System.out.println(ans);
	
	}
	static class Unionfind{
		int[] parent;
		int count;
		public Unionfind(int n){
			this.parent=new int[n];
			for(int i = 0; i<n; i++){
				parent[i]=i;
			}
			count=n;
		}
		public int root(int t){
			if(parent[t]==t){
				return t;
			}else{
				return parent[t]=root(parent[t]);
			}
		}
		public void unite(int x,int y){
			if(same(x,y)){
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[yroot]=xroot;
			count--;
		}
		public boolean same(int x,int y){
			return root(x)==root(y);
		}
		public int count(){
			return this.count;
		}
	}
}


Measured memory_bytes: 23524
#include <iostream>
using namespace std;
long long q, h, s, d, n;
int main() {
	cin>>q>>h>>s>>d>>n;
	s = min(s, min(2*h, 4*q));
	d = min(2*s, d);
	cout<<n/2*d + n%2*s;
	return 0;
}

Measured memory_bytes: 256
h,w=gets.split.map &:to_i
s=[ ?.*(w+2), *$<.map{|s| ?.+s.chomp+?. }, ?.*(w+2) ]
(1..h).each{|i|
  (1..w).each{|j|
    print s[i][j]==?# ? ?# : [*-1..1].product([*-1..1]).count{|(di,dj)| s[i+di][j+dj]==?# }
  }
  puts
}

Measured memory_bytes: 1788
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), b(n);
  ll sa = 0, sb = 0;
  rep(i, n) {
    cin >> a[i];
    sa += a[i];
  }
  rep(i, n) {
    cin >> b[i];
    sb += b[i];
  }
  ll diff = sb - sa;
  ll na = 0, nb = 0;
  rep(i, n) {
    if (a[i] > b[i]) {
      nb += (a[i] - b[i]);
    } else if (b[i] > a[i]) {
      na += (b[i] - a[i]) / 2 + ((b[i] - a[i]) & 1);
    }
  }
  if (diff >= na) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 504
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [0 for i in range(10**5+1)]
S = [0]
s = 0
for i in range(N):
    B[A[i]] += 1
    s += A[i]
    S.append(s)
for i in range(2,10**5+2):
    B[-i] += B[-i+1]
d = 0
u = 2*10**5
for i in range(30):
    x = (u+d)//2
    if i == 28:
        x += 1
    m = 0
    for i in range(N):
        a = A[i]
        y = max(x - a,0)
        if y <= 10**5:
            m += B[y]
    if m >= M:
        d = x
    else:
        u = x
ans = 0
for i in range(N):
    a = A[i]
    x = max(d - a,0)
    if x <= 10**5:
        y = B[x]
    else:
        y = 0
    ans += (S[N] - S[N-y]) + a*y
ans -= (m-M)*d
print(ans)

Measured memory_bytes: 17028
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> A(N);
	rep(i,N)cin>>A[i];

	int r = 0;
	ll ans = 0;
	int sum = 0;
	rep(l,N){
		while(r < N&& (sum ^ A[r]) == (sum + A[r])){
			sum += A[r];
			r++;
		}
		ans += r - l;
		if(l == r){
			r++;
		}
		else{
			sum -= A[l];
		}
	}	
	cout<<ans<<endl;
}

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

int main() {
    int A, B;
    double T;
    cin >> A >> B >> T;

    int cnt = A;
    int ans = 0;
    while(cnt < T+0.5){
        ans += B;
        cnt += A;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;


int main(){
	string s;
	int num[10];

	int k[10][12] = {0};

	k[0][1] = 1;

	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 12; j++){
			k[i][j] = k[i-1][j-1]+k[i-1][j];
		}
	}

	while(cin >> s){
		if(s == "0")break;
		int sum = 0;
		for(int i = 0; i < s.size(); i++){
			sum += (s[i]-'0')*k[9][i+1];
		}
		
		cout << sum%10 << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1184