akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var H = int.Parse(inputs[0]);
        var W = int.Parse(inputs[1]);
        var A = new char[H, W];
        var points = new List<BlackPoint>();
        var whiteCount = 0;
        for (int h = 0; h < H; h++)
        {
            var values = Console.ReadLine();
            for (int w = 0; w < W; w++)
            {
                A[h, w] = values[w];
                if (A[h, w] == '#')
                {
                    points.Add(new BlackPoint(h, w));
                }
                else
                {
                    whiteCount++;
                }
            }
        }

        var nextPoints = new List<BlackPoint>();
        const char BlackMark = '#';
        const char WhiteMark = '.';
        int count = 0;
        while (whiteCount > 0)
        {
            count++;
            foreach (var point in points)
            {
                if (point.h - 1 >= 0 && A[point.h - 1, point.w] == WhiteMark)
                {
                    whiteCount--;
                    A[point.h - 1, point.w] = BlackMark;
                    nextPoints.Add(new BlackPoint(point.h - 1, point.w));
                }

                if (point.h + 1 < H && A[point.h + 1, point.w] == WhiteMark)
                {
                    whiteCount--;
                    A[point.h + 1, point.w] = BlackMark;
                    nextPoints.Add(new BlackPoint(point.h + 1, point.w));
                }

                if (point.w - 1 >= 0 && A[point.h, point.w - 1] == WhiteMark)
                {
                    whiteCount--;
                    A[point.h, point.w - 1] = BlackMark;
                    nextPoints.Add(new BlackPoint(point.h, point.w - 1));
                }

                if (point.w + 1 < W && A[point.h, point.w + 1] == WhiteMark)
                {
                    whiteCount--;
                    A[point.h, point.w + 1] = BlackMark;
                    nextPoints.Add(new BlackPoint(point.h, point.w + 1));
                }
            }
            points = nextPoints;
            nextPoints = new List<BlackPoint>();
        }

        Console.WriteLine(count);

    }

    private struct BlackPoint
    {
        internal int h;
        internal int w;
        internal BlackPoint(int h, int w)
        {
            this.h = h;
            this.w = w;
        }
    }
}



Measured memory_bytes: 34524
#include<stdio.h>
int a[10000],b[10000];
int main(){
	int n,m,i,f;
	int fr[501];
	while(1){
		for(i=0;i<=500;i++){
			fr[i]=0;
			f=0;
		}
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		for(i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
		for(i=1;i<=m;i++){
			if(a[i]==1){
				fr[b[i]]=1;
			}
			else if(b[i]==1){
				fr[a[i]]=1;
			}
		}
		for(i=1;i<=m;i++){
			if(fr[a[i]]==0 && fr[b[i]]==1)fr[a[i]]=2;
			if(fr[a[i]]==1 && fr[b[i]]==0)fr[b[i]]=2;
		}
		for(i=2;i<=500;i++){
			if(fr[i])f++;
		}
		printf("%d\n",f);
	}
	return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int a,b;cin>>a>>b;
    cout<<(a^b)<<endl;
}
        


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <complex>

#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define rtr(c, i) for (typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); --i)
#define contains(c, x) ((c).find(x) != (c).end())
#define Contains(c, x) (find(all(c), x) != (c).end())
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, (n))
#define To_String to_string< char,std::char_traits<char>,std::allocator<char> >

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	string s;
	while (getline(cin, s)) {
		int i = 0;
		ostringstream os;
		while (i < s.size()) {
			if (s[i] == '@') {
				int n = s[i+1]-'0';
				os << string(n, s[i+2]);
				i += 3;
			}
			else {
				os << s[i];
				i++;
			}
		}
		cout << os.str() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = 0, end=0;
        char s[] = sc.next().toCharArray();
        for(int i = 0; i<s.length; i++){
            if(s[i]=='A'){
                start = i;
                break;
            }
        }
        for(int i = s.length-1;0<=i; i--){
            if(s[i]=='Z'){
                end = i;
                break;
            }
        }
        System.out.println(end-start+1);
    }
}


Measured memory_bytes: 29752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int r=1;
  for(int i=0;i<n;i++){
    while(r<=d){
      x++;
      r+=a[i];
    }
    r=1
      ;
  }
  cout << x;
}


Measured memory_bytes: 256
using System;
public class Aprob {
    public static void Main() {
        string[] read = new string[3];
        read = Console.ReadLine().Split(' ');
        int A = int.Parse(read[0]);
        int B = int.Parse(read[1]);
        int C = int.Parse(read[2]);
        if (A+B+C==17&A*B*C==175) {
            Console.WriteLine("YES");
        } else {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 2648
//29/12/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;


int main(){
    _fastio
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;



    return 0;
}


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

int main()
{
    ll n, d,ans = 0;
    cin >> n >> d;
    while(n--){
      ll x, y;
      cin >> x >> y;
      if(x*x + y*y <= d*d)
        ans++;
    }
    cout << ans << endl;
}

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

int main() {
    int cnt[5] = {};
    rep(i,3) {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    string ans = "YES";
    rep(i,5) {
        if (cnt[i] > 2) ans = "NO";  
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin >>  N >> X;
  vector<int>m(N);
  for(int i=0;  i<N; i++){
    cin >> m[i];
  }
  for(int i=0; i<N ; i++){
    X=X-m[i];
  }
  sort(m.begin(),m.end());
  cout << N + X/m[0] << endl;
}

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

const int MAX_N = 200000;

int main() {
	int N;
	std::string S;

	std::cin >> N >> S;

	static int black[MAX_N + 1] = {};
	for(int i = 1; i <= N; ++i) {
		if(S[i - 1] == '#') black[i] = black[i - 1] + 1;
		else black[i] = black[i - 1];
	}

	int ans = MAX_N;
	for(int i = 0; i <= N; ++i) {
		ans = std::min(ans, black[i] + N - i - black[N] + black[i]);
	}

	std::cout << ans << std::endl;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

ll h[100100];
int main() {
  int n, k;
  cin >> n >> k;
  repi(n) cin >> h[i];
  sort(h, h + n);
  ll re = LLONG_MAX;
  repi(n - k + 1) updatemin(re, h[i + k - 1] - h[i]);
  cout << re << endl;
}


Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := getInt()
	M := getInt()

	sumAc := 0
	sumWa := 0

	post := make(map[int]string)
	cnt := make([]int, N)
	for i := 0; i < M; i++ {
		p := getInt() - 1
		s := getString()

		if post[p] == "AC" {
			continue
		}

		if s == "AC" {
			sumAc++
			sumWa += cnt[p]
		} else if s == "WA" {
			cnt[p]++
		}

		post[p] = s
	}

	fmt.Println(sumAc, sumWa)
}

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

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 8960
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val letters = listOfString()
    println("${letters[0].substring(0, 1)}${letters[1].substring(0, 1)}${letters[2].substring(0, 1)}".toUpperCase())
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37868
package main

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

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 isHeisei(y, m, d int) bool {
	if y < 2019 {
		return true
	}
	if y > 2019 {
		return false
	}

	if m < 4 {
		return true
	}
	if m > 4 {
		return false
	}

	if d < 31 {
		return true
	}
	return false
}

func main() {
	defer stdout.Flush()

	ds := strings.Split(readString(), "/")
	y, _ := strconv.Atoi(ds[0])
	m, _ := strconv.Atoi(ds[1])
	d, _ := strconv.Atoi(ds[2])
	if isHeisei(y, m, d) {
		println("Heisei")
	} else {
		println("TBD")
	}
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 5000500;
const int mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    map < pair < int, int > , vector < pair < int, int > > > g;
    int n;
    cin >> n;
    vector < pair < int, int > > v;
    for(int i = 0 ; i < n ; ++i){
        int x, y;
        cin >> x >> y;
        for(int j = 0 ; j < i ; ++j){
            if(v[j].first == x && v[j].second == y) continue;
            g[{x - v[j].first, y - v[j].second}].push_back({j, i});
            g[{-x + v[j].first, - y + v[j].second}].push_back({i, j});
        }
        v.push_back({x, y});
    }
    int in[n + 1];
    int ans = n;
    for(auto pq : g){
        memset(in, 0 , sizeof in);
        queue < int > q;
        for(auto u : pq.second)
            in[u.second]++;
        int sm = 0;
        for(int i = 0 ; i < n ; ++i)
            sm += !in[i];
        ans = min(ans, sm);
    }
    cout << ans << '\n';
    return 0;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	ll x;
	cin>>x;
	if(x>=400 && x<=599)
		cout<<8;
	else if(x>=600 && x<800)
		cout<<7;
	else if(x>=800 && x<1000)
		cout<<6;
	else if(x>=1000 && x<1200)
		cout<<5;
	else if(x>=1200 && x<1400)
		cout<<4;
	else if(x>=1400 && x<1600)
		cout<<3;
	else if(x>=1600 && x<1800)
		cout<<2;
	else if(x>=1800)
		cout<<1;
} 

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  ll X;
  cin>>X;
  vector<pair<ll,int>> kouho;
  for(ll i(0);i<=4000;i++){
    ll tmp = i*i*i*i*i;
    kouho.push_back({tmp,i});
    kouho.push_back({-1*tmp,-1*i});
  }
  for(int i(0);i<=4000;i++){
    for(int j(0);j<=4000;j++){
      if(kouho[i].first - kouho[j].first == X){
        cout << kouho[i].second << " " << kouho[j].second << endl;
        return 0;
      }
    }
  }
  return 0;
}



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


typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define Pi 3.14159265
#define double
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

bool compare(pii a, pii b){
    if(a.first==b.first)return a.second<b.second;
    return a.first>b.first;
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n,ll k){
    if(n==0)return k;
    if(n%2==0)return modexp((x*x)%mod,n/2,k);
    return (x*modexp((x*x)%mod,n/2,k))%mod;
}

int main(){
    fastio;
    //clock_t tm = clock();
    int t,r,c,k,n,l,x,y,q;string s;
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    else if(s=="MON")cout<<6<<endl;
    else if(s=="TUE")cout<<5<<endl;
    else if(s=="WED")cout<<4<<endl;
    else if(s=="THU")cout<<3<<endl;
    else if(s=="FRI")cout<<2<<endl;
    else if(s=="SAT")cout<<1<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int q = ri();
	std::string s;
	std::cin >> s;
	int l[q];
	int r[q];
	for (int i = 0; i < q; i++) {
		l[i] = ri() - 1;
		r[i] = ri() - 1;
	}
	int sum[n - 1];
	int cur = 0;
	for (int i = 0; i + 1 < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') cur++;
		sum[i] = cur;
	}
	for (int i = 0; i < q; i++) {
		if (r[i] == 0) {
			std::cout << 0 << std::endl;
			continue;
		}
		int res = sum[r[i] - 1];
		if (l[i]) res -= sum[l[i] - 1];
		std::cout << res << std::endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
    int n;
    vector<int> v;
    for(int i=0; cin>>n && i<5; i++) v.push_back(n);
    
    stable_sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    cout << v.at(0);
    for(int i=1; i<5; i++) cout << " " << v.at(i);
    cout << endl;

    return 0;
}

Measured memory_bytes: 1216
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
const int inf=1e9;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

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

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    vector<int> c(m,0);
    rep(i,m) cin>>c.at(i);
    vector<vector<int>> dp(m+1,vector<int>(n+1,inf));
    dp[0][0]=0;
    REP(i,1,m+1){
        rep(j,n+1){
            chmin(dp[i][j],dp[i-1][j]);
            if(j-c[i-1]>=0) chmin(dp[i][j],dp[i][j-c[i-1]]+1);
        }
    }
    cout<<dp[m][n]<<endl;
}


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

using namespace std;
typedef long long int ll;

ll MOD = 1000000007;

int main(){

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

    if(N + 1 < M || M + 1 < N){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;

    for(ll i = N; i > 0; i--){
        ans *= i;
        ans %= MOD;
    }
    for(ll i = M; i > 0; i--){
        ans *= i;
        ans %= MOD;
    }

    if(N == M){
        ans *= 2;
        ans %= MOD;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define mod 1000000007
#define pf push_forward
#define pb push_back
#define mp make_pair
#define f(i,in,n) for(i=in; i<n; ++i)
#define scant int t; cin>>t;while(t--)
using namespace std;
main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int n, i;
	cin >> n;
	int h[n];
	for (i = 0; i < n; i++) {
		cin >> h[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1];

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
	int n,a;
	
	vector<int>vec;
	ll dp[52][3000][52];
ll dfs(int pos,int sum,int cnt){
	
	if(pos==n)
	{
		if(cnt!=0 && sum%cnt==0){
			int temp=sum/cnt;
			if(temp==a){
				return 1;
			}
		}
		return 0;
	}
	if(dp[pos][sum][cnt]!=-1){
		return dp[pos][sum][cnt];
	}
	ll ans=0;
	ans+=dfs(pos+1,sum,cnt);
	ans+=dfs(pos+1,sum+vec[pos],cnt+1);
	return dp[pos][sum][cnt]=ans;
}
int main(){
	

	cin>>n>>a;
	vec.resize(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		cin>>vec[i];
	}
	ll res=dfs(0,0,0);
	cout<<res<<endl;
	
	return 0;
}


Measured memory_bytes: 67016
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int r0,w0,c,r;
    while (cin>>r0>>w0>>c>>r) {
        if (r0==0&&w0==0&&c==0&&r==0) {
            break;
        } else {
            int x=0;
            while (1) {
                double y=(r0+x*r)/c-w0;
                if (y>=0) {
                    cout<<x<<endl;
                    break;
                } else {
                    x++;
                }
            }
        }
    }
}



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

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    if (a1 + a2 + a3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const vector<int> w = inputVec<int>(N);
	vector<int> lsum(N,w[0]);
	vector<int> rsum(N,w[N-1]);
	REP(i, 1, N) {
		lsum[i] = lsum[i - 1] + w[i];
	}
	for (int i = N - 2; i >= 0; i--) {
		rsum[i] = rsum[i + 1] + w[i];
	}

	int minval = 100000000;
	for (int i = 1; i < N; ++i) {
		chMin(minval, abs(rsum[i + 1] - lsum[i]));
	}

	outputVal(minval);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


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

int main() {
  // cin, coutが速くなる？
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< pair<int, int> > a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  // begin(), end() : 昇順
  // rbegin(), rend() : 降順
  sort(a.rbegin(), a.rend());
  for(int i = 0; i < n; i++) {
    // 降順にしたときに最大値をとるindexのみ2番目の値を出力
    if(i == a[0].second) cout << a[1].first << endl;
    else                 cout << a[0].first << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
ans str =
  let na = length $ filter (== 'A') $ drop 1 str
      nb = length $ filter (== 'B') $ drop 1 str
  in
    if na > nb
    then [na+1,nb]
    else [na,nb+1]

main = do
  c <- getContents
  let i = takeWhile (/= "0") $ lines c
      o = map ans i
  mapM_ putStrLn $ map unwords $ map (map show) o

Measured memory_bytes: 3392
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int p[3];

int main(void) {
  int n,m;
  cin >> n >> m;
  rep(i,3) p[i] = -1;
  bool ok = true;
  rep(i,m) {
    bool okk = false;
    int a,b;
    cin >> a;
    if(p[a-1] != -1) {
      b = p[a-1];
      okk = true;
    }
    cin >> p[a-1];
    if(okk){
      if(b != p[a-1]){
        ok = false;
      }
    }
  }
  if(n != 1 && p[0] == 0) ok = false;
  int res = 0;
  if(ok){
    
    if(n==3){
    if(p[2] != -1) res += p[2];
    if(p[1] != -1) res += p[1]*10;
    if(p[0] != -1) res += p[0]*100;
    else res += 100;
    }
    if(n==2){
      if(p[1] != -1) res += p[1];
      if(p[0] != -1) res += p[0]*10;
      else res += 10;
    }
    if(n==1){
      if(p[0] != -1) res += p[0];
    }
  }
  if(ok) cout << res << endl;
  else cout << "-1" << endl;
    
  
}


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

int n, w;
ll dp[100100];

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

    cin >> n >> w;
    for (int i = 0; i <= 100000; i++)
        dp[i] = 2e9;
    dp[0] = 0;
    for (int i = 1; i <= n; i++){
        int a, b;
        cin >> a >> b;
        for (int j = 100000-b; j >= 0; j--)
            dp[j+b] = min(dp[j+b], dp[j]+a);
    }
    int ans = 0;
    for (int i = 0; i <= 100000; i++){
        if (dp[i] <= w)
            ans = max(ans, i);
    }

    cout << ans;

}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int ans = -1;
    int a, b;

    scanf("%d%d", &a, &b);

    for (int i = 1; i <= 10000; i++)
        if ((a <= (double)i * 0.08 && (double)i * 0.08 < a + 1) && (b <= (double)i * 0.1 && (double)i * 0.1 < b + 1))
        {
            ans = i;
            break;
        }

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

    return 0;
}

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

int main() {
  int N;cin>>N;
  //vector<long> T(N);
  queue<long> A;
  for(int i=0;i<N;i++){
    long T;cin>>T;
    A.push(T);
  }
  while(A.size()>1){
    long X=A.front();
    A.pop();
    long Y=A.front();
    A.pop();
    long Z=(X/gcd(X,Y))*Y;
    A.push(Z);
  }
  cout<<A.front()<<endl;
}
  

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
"""
A - Range Product
https://atcoder.jp/contests/agc002/tasks/agc002_a

"""
import sys


def solve(a, b):
    if a*b <= 0:
        return 'Zero'
    if a > 0 and b > 0:
        return 'Positive'
    if (b-a)%2==0:
        return 'Negative'
    return 'Positive'


def main(args):
    a, b = map(int, input().split())
    ans = solve(a, b)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = splitInt(sc.nextLine(), " ");
		int result;
		if(array[0]<=5) {
			result = 0;
		}else if(array[0]<=12) {
			result = array[1]/2;
		}else {
			result = array[1];
		}
		System.out.println(result);
		
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
	
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    for (int i = 0;i < n;i++) cin >> h[i];

    int high = h[0];
    int cnt = 1;
    for (int i = 1;i < n;i++) {
        if (high <= h[i]) {
            cnt++;
            high = h[i];
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
edge = [[] for _ in [0]*n]
for i in range(~-n):
    a, b = map(int, input().split())
    a -= 1;b -= 1
    edge[a] += [[b, i]]
ans = [0] * ~-n

def dfs(now, color):
    count = 1
    for to, i in edge[now]:
        # 親の色と同じとき
        if count == color:
            count += 1
        ans[i] = count
        dfs(to, count)
        count += 1

# 開始根は0番目に
dfs(0, 0)

print(max(ans))
for p in ans:
    print(p)


Measured memory_bytes: 71016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >>n;
  int A[n+1];
  for(int i = 0;i<n;i++){
    cin >>A[i];
  }
  int res = 0;
  for(int i = 1;i<=n-2;i++){
    if(min({A[i-1],A[i],A[i+1]})!=A[i] && max({A[i-1],A[i],A[i+1]})!=A[i]){
      res+=1;
    }
  }
  cout <<res <<endl;
}
    
    


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll n, x;
ll p[50], a[50];

// レベルnのバーガーの下からxそうに含まれるパティの枚数
ll f(ll n, ll x) {
    if (n == 0) return x <= 0 ? 0 : 1;
    else if (x <= 1 + a[n - 1]) return f(n - 1, x - 1);
    else if (x == 2 + a[n - 1]) return 1 + p[n - 1];
    else return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}


void solve() {
    p[0] = 1, a[0] = 1;
    repone(i, n - 1) {
        p[i] = 2 * p[i - 1] + 1;
        a[i] = 2 * a[i - 1] + 3;
    }
    cout << f(n, x) << endl;
}

int main() {
    cin >> n >> x;
    solve();
    return 0;
}

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

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

char ask(vector<int> v)
{
    cout<<"?";
    for(auto x:v) cout<<' '<<x;
    cout<<nl;
    cout.flush();
    string s;
    cin>>s;
    return s[0];
}
char res[300];
int32_t main()
{
    int n=in();
    vector<int> v(n);
    iota(v.begin(),v.end(),1);
    char first = ask(v);
    int l=2,r=n+1,ans;
    while(l<=r){
        int mid = (l+r)>>1;
        vector<int> v;
        for(int i=mid; i<mid+n; i++) v.eb(i);
        if(first!=ask(v)) ans=mid, r=mid-1;
        else l=mid+1;
    }
    v.clear();
    for(int i=ans; i<=ans+n-2; i++) v.eb(i);
    for(int i=1; i<ans; i++){
        v.eb(i);
        res[i]=ask(v);
        v.pop_back();
    }
    for(int i=ans+n-1; i<=2*n; i++){
        v.eb(i);
        res[i]=ask(v);
        v.pop_back();
    }
    v.clear();
    for(int i=1; i<=2*n; i++){
        if(i>=ans&&i<=ans+n-2);
        else v.eb(i);
    }
    for(auto x:v){
        if(res[x]=='R'){
            v.erase(find(v.begin(), v.end(),x));
            break;
        }
    }
    for(auto x:v){
        if(res[x]=='B'){
            v.erase(find(v.begin(), v.end(),x));
            break;
        }
    }

    for(int i=ans;i<=ans+n-2;i++){
        v.eb(i);
        res[i]=ask(v);
        v.pop_back();
    }
    cout<<"! ";
    for(int i=1;i<=2*n;i++) cout<<res[i];
    cout<<nl;
    cout.flush();
    return 0;
}


Measured memory_bytes: 724
#include <iostream>

using namespace std;

int main() {
    int a, b, c, i;
    cin >> a >> b >> c;
    i=0;
    for (a=a;a<=b;a++) {
        if (c % a == 0)
        i=i+1;
    }
    
    cout<< i << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

constexpr int day = 86400;

int main() {
    vector<int> cnt(day*2+2);
    int s, n;
    cin >> n >> s;
    s %= day;
    cnt[s+1] = cnt[day+s+1] =  1;
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        s = (s+a+b)%day;
        cnt[s+1]++; cnt[s+day+1]++;
    }
    for (int i = 0; i+1 < cnt.size(); ++i) {
        cnt[i+1] += cnt[i];
    }
    int ans = 0;
    for (int i = 0; i+10801 < cnt.size(); ++i) {
        ans = max(ans, cnt[i+10801]-cnt[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	vector<string>A;
	for (int i = 0; i < N; i++) {
		string S; cin >> S;
		A.push_back(S);
	}
	sort(A.begin(), A.end());
	int ans = N;
	for (int i = 0; i < N - 1; i++) {
		if (A.at(i) == A.at(i + 1)) ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11660
w,h,n=list(map(int,input().split()))
max_1=0
max_2=w
max_3=0
max_4=h
for i in range(n):
  x,y,a=list(map(int,input().split()))
  if(a==1):
    if(max_1<x):
      max_1=x
  elif(a==2):
    if(max_2>x):
      max_2=x
  elif(a==3):
    if(max_3<y):
      max_3=y
  else:
    if(max_4>y):
      max_4=y

x=max_2-max_1
y=max_4-max_3
if(x<0):
  x=0
if(y<0):
  y=0
print(x*y)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll a;
  string b;
  cin >> a >> b;
  ll b0 = a * (b[0]-'0') * 100;
  ll b1 = a * (b[2]-'0') * 10;
  ll b2 = a * (b[3]-'0');
  cout << (b0+b1+b2)/100 << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N, M;
vi cols;
vector<vi> graph;
vector<vector<bool>> done;
int currentCol = -1;

void calc(int pos, int rem) {
	if (rem < 0) return;
	if (done[pos][rem]) return;
	done[pos][rem] = true;

	if (rem == 0) cols[pos] = currentCol;

	calc(pos, rem - 1);
	for (int n : graph[pos]) {
		calc(n, rem - 1);
	}
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	graph.resize(N);
	cols.resize(N);
	done = vector<vector<bool>> (N, vector<bool> (10));
	F0R(i, M) {
		int a, b; cin >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	int Q; cin >> Q;
	vector<tuple<int, int, int>> queries (Q);
	F0R(i, Q) {
		int v, d, c; cin >> v >> d >> c;
		queries.push_back(make_tuple(v-1, d, c));
	}
	reverse(queries.begin(), queries.end());
	for (tuple<int, int, int> tup : queries) {
		currentCol = get<2>(tup);
		calc(get<0>(tup), get<1>(tup));
	}
	F0R(i, N) print(cols[i]);
}

Measured memory_bytes: 16228
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 30
int main(void)
{
	int p[101], s[MAX + 1] = { 0 }, a, b, q;
	while(1){
		scanf_s("%d,%d", &a, &b);
		if (a == 0 && b == 0) break;
		s[b] = true;
		p[a] = b;
	}
	while (scanf_s("%d", &q) != EOF) {
		for (int i = MAX, k = 0; i >= 0; --i) {
			if (s[i]) ++k;
			if (i == p[q]) {
				printf("%d\n", k);
				break;
			}
		}
	}

}

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

sys.setrecursionlimit(1000000)
mod = 1000000007

M = 10000
l = [1]*(M+1)
prime = []
p = 2
while p <= M:
    while p <= M and not l[p]:
        p += 1
    j = p
    while j <= M:
        l[j] = 0
        j += p
    prime.append(p)
l = len(prime)
def solve(m,a,b):
    ans = [0,0,0]
    for i in range(l):
        p = prime[i]
        k = min(l,bisect.bisect_right(prime,p*b/a)+1,bisect.bisect_right(prime,m/p)+1)
        for j in range(max(0,k-3),k):
            q = prime[j]
            if p <= q:
                if a*q <= b*p:
                    s = p*q
                    if s <= m:
                        if ans[0] <= s:
                            ans = [s,p,q]
    print(*ans[1:])
    return

#Solve
if __name__ == "__main__":
    while 1:
        m,a,b = LI()
        if m == a == b == 0:
            break
        solve(m,a,b)



Measured memory_bytes: 8648
#include <iostream>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;

int main() {
  int n, y; cin >> n >> y;
  bool ans = false;
  int a, b, c;
  for (int i = 0; i <= y; i += 10000) {
    if (ans) break;
    for (int j = 0; j <= y - i; j += 5000) {
      int k = y - i - j;
      a = i / 10000; b = j / 5000; c = k / 1000;
      if (a + b + c == n) {
        ans = true;
        break;
      }
    }
  }
  if (ans) cout << a << " " << b << " " << c << endl;
  else cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
int a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> ans;
    while (n > 0) {
        bool fnd = false;
        int nm = 0;
        for (int i = n; i >= 1; i--) {
            if (a[i] == i) {
                ans.push_back(i);
                nm = i;
                fnd = true;
                break;
            }
        }
        if (fnd == false) {
            cout <<"-1\n";
            return 0;
        }
        int nn = 0;
        for (int i = 1; i <= n; i++) {
            if (i != nm) {
                nn++;
                a[nn] = a[i];
            }
        }
        n = nn;
    }
    reverse(ans.begin(), ans.end());
    for (auto it: ans) {
        cout << it << "\n";
    }
    return 0;
}

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

int main(){
  long long n,i,j,lcur=1,rcur,ans=0,zero=0,x,y;
  cin >> n;
  vector<long long> a(n);
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ans=a[n-1]-a[0];
  for(i=1; i<n-1; i++){
    if(a[i]<0){
      lcur++;
    }
    ans+=max(-a[i],a[i]);
  }
  cout << ans << endl;
  rcur=n-lcur;
  
  if(lcur==1){
    x=a[0];
    for(i=1; i<n-1; i++){
      cout << x << ' ' << a[i] << endl;
      x-=a[i];
    }
    cout << a[n-1] << ' ' << x << endl;
  }else{
    x=a[0];
    for(i=lcur; i<n-1; i++){
      cout << x << ' ' << a[i] << endl;
      x-=a[i];
    }
    cout << a[n-1] << ' ' << x << endl;
    x=a[n-1]-x;
    for(i=1; i<lcur; i++){
      cout << x << ' ' << a[i] << endl;
      x-=a[i];
    }
    
  }
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    double L; cin >> L;
    double a, b, c;
    a = b = c = L/3;

    double s = a*b*c;
    printf("%.6f\n", s);
}

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

using namespace std;

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


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

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

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

void solve(){
	ll n;
	cin>>n;
	map<ll,ll> mp;
	REP(i,n){
		ll a;
		cin>>a;
		mp[a]++;
	}
	if(mp.size()==n) cout<<"YES"<<en;
	else cout<<"NO"<<en;
}

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

    solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 12800
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	map<string, int> counter;

	string s;
	int n_max = 0;
	for (int i=0; i<N; i++) {
		cin >> s;
		counter[s]++;
		n_max = max(n_max, counter[s]);
	}

	vector<string> ans;
	for (auto itr = counter.begin(); itr != counter.end(); itr++) {
		if (itr->second == n_max) {
			ans.push_back(itr->first);
		}
	}

	for (auto s : ans) {
		cout << s << endl;
	}

	return 0;
}

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

typedef long long ll;

ll n;
vector<ll> v;
set<ll> s,t;

int main(){

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

    cin>>n;
    {
        ll clo=n;
        for(int i=2;i<=1e6;i++){
            while(clo%i==0){
                v.push_back(i);
                clo/=i;
            }
        }
        if(clo>1){
            v.push_back(clo);
        }
    }
    t.insert(1);
    for(int i=0;i<v.size();i++){
        s.clear();
        for(set<ll>::iterator it=t.begin();it!=t.end();++it){
            s.insert((*it)*v[i]);
        }
        for(set<ll>::iterator it=s.begin();it!=s.end();++it){
            t.insert(*it);
        }
    }
    ll ans=1e18;
    for(set<ll>::iterator it=t.begin();it!=t.end();++it){
        ans=min((*it)+n/(*it)-2,ans);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 768
n = gets.to_i
a = gets.split.map(&:to_i)
hash = Hash.new(0)
a.each do |ar|
  hash[ar] += 1
end
arr = hash.values.to_a
unti = arr.inject(0){|sum,i| sum += (i * (i-1))} / 2
memo = Hash.new(0)
a.each do |i|
  hash[i] -= 1
  s = 0
  if memo.fetch(i,nil) == nil
    s = unti + ((hash[i] * (hash[i] - 1)) / 2) - (((hash[i] + 1) * hash[i]) / 2)
    memo[i] = s
  else
    s = memo[i]
  end
  puts s
  hash[i] += 1
end


Measured memory_bytes: 37900