akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[] num = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				num[i] = sum + scanner.nextInt();
				sum = num[i];
			}
			int ans = num[m - 1];
			for (int i = m; i < n; i++)
				ans = Math.max(ans, num[i] - num[i - m]);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 64044
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int mod = 1e9+7;
/*
#define bigint __int128
__int128 abss(__int128 x){if(x>0)return x;
    return -x;
    }
*/
void solve() {
    int n;cin>>n;
    vector<ll>v(n);
    for(ll &i:v)cin>>i;
    ll ans = 0,sum = 0;
    for(int i = 0;i<n;i++)sum+=v[i];
    
    for(int i = 0;i<n;i++){
	sum-=v[i];
	ans = (ans%mod + ((v[i]%mod)*(sum%mod))%mod)%mod;
	}
	cout<<(ans%mod)<<endl;
    
}
int main()
{boost;
int t;t = 1;//cin>>t;
while(t--){solve();}
}


Measured memory_bytes: 4744
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	h := readInt()
	w := readInt()
	for i := 0; i < w+2; i++ {
		printf("#")
	}
	println()
	for i := 0; i < h; i++ {
		printf("#")
		printf("%s", readString())
		println("#")
	}
	for i := 0; i < w+2; i++ {
		printf("#")
	}
	println()
}

// -----------------------------------------------------------------------------


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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    unordered_map<int, int> M;
    fr(i, 0, k)
    {
        int d;
        cin >> d;
        fr(j, 0, d)
        {
            int snk;
            cin >> snk;
            M[snk]++;
        }
    }
    cout << n - sz(M) << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    ll N, M;
    cin >> N >> M;

    ll a = M / N;
    for (int i = a; i > 0; --i) {
        if(M % i == 0){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
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[][] score = new int[2][100001];
		int[][] maxs = new int[2][2];
		int[][] maxer = new int[2][2];
		int[] has = new int[2];
		
		for(int i = 0; i < n; i++)
		{
			int m = i%2;
			int a = sc.nextInt();
			if(score[m][a] == 0)has[m]++;
			score[m][a]++;
		}
		
		for(int i = 1; i <= 100000; i++)
		{
			for(int m = 0; m < 2; m++)
			{
				if(score[m][i] > maxs[m][0])
				{
					maxs[m][1] = maxs[m][0];
					maxer[m][1] = maxer[m][0];
					
					maxs[m][0] = score[m][i];
					maxer[m][0] = i;
				}
				else if(score[m][i] > maxs[m][1])
				{
					maxs[m][1] = score[m][i];
					maxer[m][1] = i;
				}
			}
		}
		
		int an = -1;
		if(maxer[0][0] != maxer[1][0])
		{
			an = n - maxs[0][0] - maxs[1][0];
		}
		else if(has[0] >= 2 && has[1] >= 2)
		{
			an = n - maxs[0][0] - maxs[1][1];
			an = Math.min(an, n - maxs[0][1] - maxs[1][0]);
		}
		else if(has[0] == 1 && has[1] >= 2)
		{
			an = n - maxs[0][0] - maxs[1][1];
		}
		else if(has[0] >= 2 && has[1] == 1)
			an = n - maxs[0][1] - maxs[1][0];
		else if(has[0] == 1 && has[1] == 1)
		{
			an = n/2;
		}
		System.out.println(an);

	}

}


Measured memory_bytes: 59796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ab[i].second >> ab[i].first;
    }
    sort(ab.begin(), ab.end());
    ll a = 0;
    bool ans = true;
    for (int i = 0; i < n; i++)
    {
        a += ab[i].second;
        if (a > ab[i].first)
        {
            ans = false;
        }
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1792
while True:
    N=int(input())
    s=0
    if N==0:
        break
    else:
        M=1000-N
        a=M//500
        b=(M-500*a)//100
        c=(M-500*a-100*b)//50
        d=(M-500*a-100*b-50*c)//10
        e=(M-500*a-100*b-50*c-10*d)//5
        f=M-500*a-100*b-50*c-10*d-5*e
        print(a+b+c+d+e+f)


Measured memory_bytes: 5584
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();
      long output = 0;
      Collections.sort(list, Comparator.reverseOrder());
      int count = 0;
      for(int i = 0; i < N; i++){
        output += list.get(i * 2 + 1);
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 74548
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                // assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"ABA"# => r#"Yes"#,

r#"BBB"# => r#"No"#,

// r#""# => r#""#,

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        mut s: chars,
    }

    s.sort();
    s.dedup();

    if s.len() == 1 {
        "No"
    } else {
        "Yes"
    }.to_string()
}

Measured memory_bytes: 4352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EHandshake {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<int> a;

    int n, m;

    bool check(int v) {
        int num = 0;
        REP(i, n) {
            int o = v - a[i];
            int idx = lower_bound(a.begin(), a.end(), o) - a.begin();
            num += n - idx;
        }
        return num >= m;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> n >> m;
        a.resize(n);
        REP(i, n) cin >> a[i];
        sort(a.begin(), a.end());

        int l = 0;
        int r = INF;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            if (check(mid)) {
                l = mid;
            } else {
                r = mid;
            }
        }

        vector<int> sum(n + 1);
        REP(i, n) sum[i + 1] = sum[i] + a[i];

        int res = 0;
        int num = 0;
        REP(i, n) {
            int o = r - a[i];
            int idx = lower_bound(a.begin(), a.end(), o) - a.begin();
            res += a[i] * (n - idx) + (sum[n] - sum[idx]);
            num += (n - idx);
        }
        if (m > num) {
            res += l * (m - num);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EHandshake solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = [int(input()) for i in range(N)]
    
A_sorted = sorted(A, reverse=True)

previous_moti_diameter = 0
count = 0

for i in A_sorted:
    
    if previous_moti_diameter == i:
        
        pass
    else:
        previous_moti_diameter = i
        count += 1
        
print(count)

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

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n;
ll ar[mnx];
ll ans;

int main(){

cin>>n;
for(int i=1; i<=n; i++){
    cin>>ar[i];
}

int s = 1;

while(s <= n){
    ans++;
    bool l = 0;
    bool r = 0;
    int k = -1;
    for(int i=s+1; i<=n; i++){
        if(ar[i] > ar[i-1]) l = 1;
        if(ar[i] < ar[i-1]) r = 1;
        if(l && r){
            k = i;
            break;
        }
    }
    if(k == -1) k = n + 1;
    s = k;
}

cout<<ans<<endl;

return 0;

}















Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int X,N;
  cin>>X>>N;
  int p[N];
  int C;
  bool a=true;
  int ans;
  rep(i,N)cin>>p[i];
  rep(i,102){
    rep(j,N){
      if(i==p[j]){
        a=false;
        break;
      }
    }
    if(a==false){
      a=true;
      continue;
    }
    if(i==0)C=X;
    else{
      if(C==abs(X-i))break;
      C=min(C,abs(X-i));
    }
    if(C==abs(X-i))ans=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int h,n,a,sum=0;
    cin>>h>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        sum+=a;
    }
    if(h<=sum) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

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

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

template <typename Container>
int SZ(const Container& S) { return S.size(); }

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 100;
LL L[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    L[0] = 2, L[1] = 1;
    int N;
    cin >> N;
    for (int i = 2; i <= N; i++) L[i] = L[i-1] + L[i-2];
    cout << L[N] << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n;cin>>n;
  int a,sum=0;
  vector<int> f(n+1,0);
  int m=ceil(sqrt(n));
  for(int x=1;x<=m;x++){
    for(int y=1;y<=m;y++){
      for(int z=1;z<=m;z++){
        a=x*x+y*y+z*z+x*y+y*z+z*x;
        if(a>n)continue;
        f[a]++;
        //cout<<a<<endl;
      }
    }
  }
  rep(i,n)cout<<f[i+1]<<endl;
}

Measured memory_bytes: 3612
x=0
b=[[0 for col in range(250)] for row in range(10)]
a="first"
while True:
    a=list(input())
    if a[0]=="-":
        break
    m=int(input())
    h=0
    ans=[0]*250
    for i in range(m):
        h=int(input())
        for j in range(h,len(a)):
            ans[j-h]=a[j]
        for k in range(h):
            ans[len(a)-h+k]=a[k]
        for l in range(len(a)):
            a[l]=ans[l]
    for y in range(len(a)):
        b[x][y]=a[y]
    x+=1


for i in range(x):
#        for j in range(len(b[x+1])):
    for j in range(200):
        if b[i][j]==0:
            break
        print(b[i][j],end="")
    print()



Measured memory_bytes: 5660
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define prin(num) cout << num << endl;
#define sprin(str) cout << "str" << endl;
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;


int main() {
    ll W;
    cin >> W;
    vector<ll> weight;
    ll dp[MAX];
    ll i, w;
    for(i=1; i<=W; i*=6) weight.push_back(i);
    for(i=9; i<=W; i*=9) weight.push_back(i);
    ll n=weight.size();
    
    for(w=0; w<MAX; w++) {
            dp[w]=INF;
    }
    dp[0]=0;
    
    for(i=0; i<n; i++) {
        for(w=weight[i]; w<=W; w++) {
            dp[w]=min(dp[w-weight[i]]+1, dp[w]);
        }
    }
    
    
    prin(dp[W]);
}


Measured memory_bytes: 1024
import numpy as np
n, m = list(map(int, input().split()))
p = np.zeros(m, dtype=np.int64)
s = np.zeros(m, dtype=np.bool)
for i in range(m):
    _p, _s = input().split()
    p[i] = int(_p) - 1
    s[i] = _s[0] == 'A'
isAc = np.zeros(n, dtype=np.bool)
waCount = np.zeros(n, dtype=np.int64)
for i in range(m):
    question = p[i]
    isAc[question] = isAc[question] or s[i]
    if (not isAc[question]) and (not s[i]):
        waCount[question] += 1
for j in range(n):
    if not isAc[j]:
        waCount[j] = 0
acCount = np.count_nonzero(isAc)
waSum = np.sum(waCount)
print('{} {}'.format(acCount, waSum))

Measured memory_bytes: 21400
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, d;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> d;
	llint x, y, ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> x >> y;
		if(x*x+y*y <= d*d) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>//２つの整数 a, b と１つの演算子 op を読み込んで、a op b を計算するプログラム

int main(void){
 
	int a,b;
	char op[2];

	while(1){
		scanf("%d %s %d",&a,op,&b);
		if(op[0]=='+')
			printf("%d\n",a+b);
		else if(op[0]=='-')
			printf("%d\n",a-b);
		else if(op[0]=='*')
			printf("%d\n",a*b);
		else if(op[0]=='/')
			printf("%d\n",a/b);
		else if(op[0]=='?')
			break;
	}
	return 0;
}

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

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

  string S;
  cin >> S;

  int l = S.length();
  for (int i = 0; i < l; i++) {
    cout << 'x';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    int n,l;
    cin >> n >> l;

    int a[n] = {};
    ll sum = 0;
    rep(i,0,n){
	a[i] = l+i;
	sum += a[i];
    }

    int ans = 0;
    rep(i,0,n){
	if( abs(sum - (sum-a[i])) <  abs(sum - (sum-a[ans]))){
	    ans = i;
	}
    }

    P(sum -a[ans]);
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n;
  cin>>n;
  string s[n];
  ll ans=0;

  ll enda=0;
  ll beginb=0;
  ll f=1;
  
  for(i=0;i<n;i++) cin>>s[i];
  for(i=0;i<n;i++){
    for(j=0;j<s[i].size()-1;j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
    }
    if(s[i][0]=='B') beginb++;
    if(s[i][s[i].size()-1]=='A') enda++;
    if(s[i][0]=='B'&&s[i][s[i].size()-1]!='A') f=0;
    if(s[i][0]!='B'&&s[i][s[i].size()-1]=='A') f=0;
  }

  if(min(enda,beginb)==0) f=0;
  cout<<ans+min(enda,beginb)-f<<endl;


  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

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

int xs[200], ys[200];

int main(){
    int N;

    while(std::cin >> N, N){
        xs[0] = 0; ys[0] = 0;
        FOR(i, 1, N){
            int n, d;
            std::cin >> n >> d;
        
            xs[i] = xs[n] + dx[d];
            ys[i] = ys[n] + dy[d];
        }

        int minX = 0, maxX = 0, minY = 0, maxY = 0;
        REP(i, N){
            minX = std::min(minX, xs[i]);
            maxX = std::max(maxX, xs[i]);
            minY = std::min(minY, ys[i]);
            maxY = std::max(maxY, ys[i]);
        }

        printf("%d %d\n", maxX-minX+1, maxY-minY+1);
    }
}

Measured memory_bytes: 1144
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll int
int main()
{
    //cout << "Hello world!" << endl;
    ll i,j,k,m,n;
    float t,a;
   cin>>n;
   cin>>t>>a;
   ll ar[n],ind=-1;
   float ans=100000000000;
   for(i=0;i<n;i++){
    cin>>j;
    float f=(t-j*0.006);
    float r=abs(f-a);
   // cout<<r<<" ";
    if(abs(f-a)<ans){
        ans=abs(f-a);
        ind=i;
    }
   }
cout<<ind+1;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static final long MOD = 1_000_000_007;

	public static void main(String[] args) {
		int H = sc.nextInt();
		int W = sc.nextInt();
		boolean[][] a = new boolean[H][W];
		for (int i = 0; i < H; i++) {
			char[] row = sc.next().toCharArray();
			for (int j = 0; j < W; j++) {
				a[i][j] = row[j] == '.';
			}
		}
		long[][] dp = new long[H][W];
		dp[0][0] = 1;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (!a[i][j]) continue;
				if (i > 0) dp[i][j] += dp[i - 1][j];
				if (j > 0) dp[i][j] += dp[i][j - 1];
				if (dp[i][j] >= MOD) dp[i][j] -= MOD;
			}
		}
		System.out.println(dp[H - 1][W - 1]);
	}


}

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

int main() {
  long n;
  cin >> n;
  vector<long> lucasnum(n+1);
  lucasnum[0]=2,lucasnum[1]=1;
  for(long i=2;i<=n;i++) lucasnum[i]=lucasnum[i-1]+lucasnum[i-2];
  cout << lucasnum[n] << endl;
}

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

import sys
from functools import reduce
from operator import xor

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=[INT() for i in range(N)]

mnbit=set()
for i, a in enumerate(A):
    bina=format(a, 'b')
    # 2進で最初に1になる桁を、各値について見る
    mnbit.add(len(bina)-bina.rfind('1'))

# 現状のA全部XOR
res=reduce(xor, A, 0)
ln=len(format(res, 'b'))
cnt=0
for i in range(ln):
    idx=ln-i
    # 大きい桁から見て、1になっているところについて処理する
    if res>>(idx-1)&1:
        # その桁用の値があるか
        if idx in mnbit:
            # あればそれを1減らせば、その桁より下が全部反転する(1111..とXORする)
            res^=(1<<idx)-1
            cnt+=1
        else:
            # 必要な桁用の値がなければNG
            print(-1)
            exit()
print(cnt)


Measured memory_bytes: 7656
#include <stdio.h>

int compare_int(const void *a, const void *b)
{return *(int*)a - *(int*)b;}

int main()
{
  int x[5];
  int i;

  for (i = 0; i < 5; i++)
    scanf("%d", &x[i]);

  qsort(x, 5, sizeof(int), compare_int);

  for (i = 0; i < 5; i++){
    printf("%d", x[4-i]);

    if(i != 4) printf(" ");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

const int DIM = 100;

main() 
{
	IOS
	
	int a, b;
	cin >> a >> b;
	
	a--;
	b--;
 
	cout << DIM << ' ' << DIM << '\n';
	
	for(int h = 0; h < DIM / 2; h++) 
	{
		for(int w = 0; w < DIM; w++) 
		{
			if(a > 0 && h % 2 == 0 && w % 2 == 0) 
			{
				cout << '.';
				a--;
			} 
			else 
			{
				cout << '#';
			}
		}
	
		cout << '\n';
  }
  
	for(int w = 0; w < DIM; w++) 
		cout << '.';
	
	cout << '\n';

	for(int h = DIM / 2 + 1; h < DIM; h++) 
	{
		for(int w = 0; w < DIM; w++) 
		{
			if(b > 0 && h % 2 == 0 && w % 2 == 0) 
			{
				cout << '#';
				b--;
			} 
			else 
			{
				cout << '.';
			}
		}
		
		cout << '\n';
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 1000005
#define mod 1000000007



int main(){
    fastio;
    int n;
    cin>>n;
    int a[4]={0};
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s[0]=='A')
        a[0]++;
        else if(s[0]=='W')
        a[1]++;
        else if(s[0]=='T')
        a[2]++;
        else a[3]++;
    }
    cout<<"AC x "<<a[0]<<"\n"<<"WA x "<<a[1]<<"\n"<<"TLE x "<<a[2]<<"\n"<<"RE x "<<a[3]<<"\n";
    return 0;
}



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

int main(void){
    char s[27]; 
    int yes = 1;

    scanf("%s", s);

    for(int i = 0; i < strlen(s) - 1; i++){
        for(int j = i + 1; j < strlen(s); j++){
            if(s[i] == s[j]){
               yes = 0; 
            }
        }
    }

    if(yes == 1){
        printf("yes\n"); 
    }else{
        printf("no\n");
    }
    return 0;

} 


Measured memory_bytes: 256
//


#pragma GCC optimize ("O3")


#pragma GCC optimize("Ofast")

/* 
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define pb(x) push_back(x)
#define int long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)

clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void Block()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)>=22)
    cout<<"bust"<<endl;
    else
    cout<<"win"<<endl;
}

signed main()
{
    FAST
    
    Block();
    time();
    return 0;
}

Measured memory_bytes: 384
dic = {}

while(1):
    try:
        key,word = (x for x in input().split())
        dic.setdefault(key, [])
        dic[key].append(word)
    except:
        break

for k in sorted(dic.keys()):
    print(k)
    arr = sorted(dic[k],key=int)
    for i in range(0,len(arr)):
        if i != 0:
            print(" ",end="")
        print(arr[i],end="")
    print()



Measured memory_bytes: 5624
n,m  = map(int, input().split())
INF = 1000000007
broken_stairs = set([int(input()) for i in range(m)])

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in broken_stairs:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, n + 1):
	if i in broken_stairs:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF
print(dp[n])


Measured memory_bytes: 13212
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin  >> n;
    vector<int>v(n);
    erep(e,v) cin >> e;
    int ans = 0;
    for(int i = 0; i < v.size() - 1;i++){
        if(v[i] != v[i+1])continue;
        int temp = 1;
        int base = v[i];
        for(int j = i+1; j < v.size();j++){
            if(base == v[j])temp++;
            else{
                i = j-1;
                break;
            }
            if(j == v.size()-1)i = INF;
        }
        ans += (temp /2);
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
char c[]={'R','Y','G','B'};
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    map<P,char>mp;
    int h,w,d;
    cin>>h>>w>>d;
    for(int i=0;i<=h+w-2;i++){
        for(int j=1-w;j<h;j++){
            int p=i/d,q=(j-(1-w))/d;
            p%=2,q%=2;
            mp[{i,j}]=c[p*2+q];
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<mp[{i+j,i-j}];
        }
        cout<<endl;
    }
    return 0;
}

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

const int N = 10;
int a[N][N];

int sqr(int x) {
  return x * x;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
  
    int n, d;
    cin >> n >> d;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < d; j++){
        cin >> a[i][j];
      }
    }
    int ret = 0;
    for (int i = 0; i < n; i++){
      for (int j = i + 1; j < n; j++){
        int sum = 0;
        for (int k = 0; k < d; k++){
          sum += sqr(a[i][k] - a[j][k]);
        }
        int x = (int)(sqrt((double)sum));
        if (x * x == sum)
          ret++;
      }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

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

sort(a.begin(),a.end());
int ans=0;
rep(i,2){
    ans+=abs(a[i+1]-a[i]);
}
cout<<ans<<endl;
 return 0;
}
/*
1 6 3

5

11 5 5

6

100 100 100

0
*/

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong(), a = sc.nextLong(), b = sc.nextLong();
		
		System.out.println(n / (a + b) * a + Math.min(a, n % (a + b)));
	}

}

Measured memory_bytes: 22996
g = 0.0
gets.to_i.times do
  n, m = gets.split.map(&:to_i)
  e = q = 0.0
  m.times do
    v, r = gets.split.map(&:to_f)
    e += v * r
    q += r
  end
  g = [g, e / q].max
end


n, m = gets.split.map(&:to_i)
e = q = 0.0
m.times do
  v, r = gets.split.map(&:to_f)
  e += v * r
  q += r
end

puts (g - e / q > 1e-7) ? "YES" : "NO"

Measured memory_bytes: 8768
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double eps=1e-7;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double cross(P a,P b){return real(b*conj(a));}
double dot(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return imag((c-a)*conj(b-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  return min(min(abs(a-c),abs(a-d)),min(abs(b-c),abs(b-d)));
}

int main(){
  int T;
  cin>>T;
  while(T--){
    double ax,ay,bx,by,cx,cy,dx,dy;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;
    
    cout<< isintersect ( P(ax,ay) , P(bx,by) , P(cx,cy) , P(dx,dy) ) <<endl;
  //    printf("%.12f\n",dist( P(ax,ay) , P(bx,by) , P(cx,cy) , P(dx,dy) ) );
  }
}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
	int ans = 1;
	char col[] = { "AKIHABARA" };
	char s[51];
	int len, clen, cnt = 0;

	cin >> s;
	len = strlen(s);
	clen = strlen(col);


	for (int i = 0; i < clen; i++){
		if (col[i] == 'A'&&col[i] != s[i - cnt])
			cnt++;
		else if (col[i] != s[i - cnt])
			ans = 0;
	}

	if ((len + cnt) > clen)
		ans = 0;

	if (ans == 0)
		cout << "NO\n";
	else
		cout << "YES\n";
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  rep(i,n)if(v[i] == 0){
    cout << 0 << endl;
    return 0;
  }
  __int128_t k = 1;
  rep(i,n){
    k = k*v[i];
    if(k < 0 || k > 1000000000000000000){
      cout << -1 << endl;
      return 0;
    }
  }
  ll res = k;
  cout << res << endl;





  return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

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

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}
int mod = 1000003;
const int maxn = 1000007;
LL fac[maxn];
LL invf[maxn];
LL inv[maxn];

int mult(int a,int b){
    LL res = a;
    res *= b;
    res%=mod;
    return (int)res;
}

int add(int a,int b){
    LL ans = a;
    ans += b;
    ans %= mod;
    return (int)ans;
}

int fpow(int a,int p){
    if(p == 0) return 1;
    int ans = fpow(a,p/2);
    ans = mult(ans,ans);
    if(p&1) ans = mult(ans,a);
    return ans;
}

void init(){
    fac[1] = 1;
    inv[1] = 1;
    _for(i,2,mod){
        fac[i] = mult(i,fac[i-1]);
        inv[i] = mult((mod-mod/i),inv[mod%i]);
    }

    invf[mod-1] = fpow(mod-1,mod-2);
    for(int i = mod-2;i >= 0;i--){
        invf[i] = mult(invf[i+1],i+1);
    }
}

int main()
{
    init();
    int Q;
    scanf("%d",&Q);
    _for(i,0,Q){
        int x,d,n;
        scanf("%d %d %d",&x,&d,&n);
        if(d == 0){
            printf("%d\n",fpow(x,n));
        }
        else{
            int y = mult(x,inv[d]);
            LL yy = (LL)y + n - 1;
            //cout << yy <<" "<<y<<endl;
            if(yy >= mod || x == 0) printf("0\n");
            else{
                printf("%d\n",mult(fpow(d,n),mult(fac[yy],invf[y-1])));
            }
        }
    }

    return 0;
}

Measured memory_bytes: 24320