akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  double a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  double res=0,noudo=0,x,y,M_noudo;
  M_noudo=100*e/(100+e);
  //cout << M_noudo << endl;
  //全探索？A~Dで終わる！？？
  string ans = "No";
  for(int i=0;i<=30;i++){//aの回数
    for(int j=0;j<=15;j++){//bの回数
      for(int k=0;k<=f/c+1;k++){//cの回数
        for(int l=0;l<=f/d+1;l++){//dの回数
          if(100*(a*i+b*j)+c*k+d*l<=f){
            if(i!=0||j!=0){
              noudo=100*(c*k+d*l)/(100*(a*i+b*j)+c*k+d*l);
              if(noudo<=M_noudo&&noudo>=res){
                //cout << a*i << " " << b*j << " " << c*k << " " << d*l <<endl;
                x=100*(a*i+b*j)+c*k+d*l;
                y=c*k+d*l;
                res=noudo;
              }
            }
          }
        }
      }
    }
  }
  cout << x << " " << y <<endl;
  //cout << 100*y/x <<endl;
}


Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;

vector<int> g[N];
bool vis[N];

void dfs(int s) {
    vis[s] = true;
    for (auto &x: g[s]) {
        if (!vis[x]) {
            dfs(x);
        }
    }
}

void test() {
    int n, m;
    cin >> n >> m;
    for (int i = 1, x, y; i <= m; ++i) {
        cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    int ans = -1;
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            dfs(i);
            ++ans;
        }
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


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

int n,m;
int a[1000],b[1000];
int c[1000];
int dp[1000+1][1<<12];
const int inf=1<<30;

template<class T>
void xmin(T &a, T b){if(a>b)a=b;}

void solve(){
    cin>>n>>m;
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
        for(int j=0; j<b[i]; j++){
            int in;
            cin>>in;
            c[i]+=1<<(in-1);
        }
    }
    for(int i=0; i<=1000; i++){
        for(int j=0; j<1<<12; j++){
            dp[i][j]=inf;
        }
        dp[i][0]=0;
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<(1<<n); j++){
            xmin(dp[i+1][j], dp[i][j]);
            xmin(dp[i+1][j | c[i]],dp[i][j]+a[i]);
        }
        //cout<<dp[i][(1<<n)-1]<<endl;
    }
    if(dp[m][(1<<n)-1]<inf)cout<<dp[m][(1<<n) - 1]<<endl;
    else cout<<-1<<endl;
}

int main(){
    //while(1)
    solve();
}

Measured memory_bytes: 16384
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int x = c-a;
        int y = d-b;

        System.out.println((c-y)+" "+(d+x)+" "+(a-y)+" "+(b+x));
        



    }
}


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

using namespace std;

typedef long long ll;

ll dp[100005];

void solve() {
  int n, maxw;
  cin >> n >> maxw;
  for(int i = 1; i <= 100000; i++) dp[i] = 1.1e9;
  while(n--) {
    int w, v;
    cin >> w >> v;
    for(int i = 100000; i >= v; i--) {
      dp[i] = min(dp[i], dp[i-v] + w);
    }
  }
  int ret = 100000;
  while(dp[ret] > maxw) ret--;
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 1024
class Node
  attr_accessor :id, :left, :right

  def initialize(id)
    @id = id
    @left = nil
    @right = nil
  end
end

def reconstruct_visit(node, index, lefts, rights)
  direct_left = compare_preorder(lefts)
  direct_right = compare_preorder(rights)
  if direct_left >= 0 then
    node.left = Node.new(direct_left)
    left_index = lefts.index(direct_left)
    reconstruct_visit(node.left,
          direct_left,
          lefts[0...left_index],
          lefts[left_index+1..-1])
  end
  if direct_right >= 0 then
    node.right = Node.new(direct_right)
    right_index = rights.index(direct_right)
    reconstruct_visit(node.right,
          direct_right,
          rights[0...right_index],
          rights[right_index+1..-1])
  end
end

def compare_preorder(array)
  return -1 if array.size == 0
  ordered_array = array.map do |item|
    [item, @preorder.index(item)]
  end
  ordered_array.sort! {|x, y| x[1] <=> y[1]}
  return ordered_array[0][0]
end

def postorder(node, array)
  if (node.left != nil) then
    postorder(node.left, array)
  end
  if (node.right != nil) then
    postorder(node.right, array)
  end
  array.push(node.id)
end


n = gets.chomp.to_i
@preorder = gets.chomp.split.map(&:to_i)
@inorder = gets.chomp.split.map(&:to_i)

root_node = Node.new(@preorder[0])
root_index = @inorder.index(@preorder[0])
reconstruct_visit(root_node, root_index, @inorder[0...root_index], @inorder[root_index+1..-1])

postorder_array = Array.new
postorder(root_node, postorder_array)
puts postorder_array.join(' ')

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

int main(){
    IOS;
    string s;cin>>s;
    if(s.size()>=6 && s[2]==s[3] && s[4]==s[5])cout<<"Yes";
    else cout<<"No";
    return 0;  
} 





Measured memory_bytes: 256
//JSD
#include<iostream>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define ll long long 
using namespace std;
int main(){
	ll n,k;
	cin>>n>>k;
	if(k>((n-1)*(n-2))/2){
		cout<<"-1\n";
	}
	else{
		set<set<ll> >  s;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(i!=j){
					set<ll > g;
					g.insert(i),g.insert(j);
					s.insert(g);
				}
			}
		}
		set<set<ll > >  v;
		for(int i=1;i<=n-1;i++){
			for(int j=1;j<=n-1;j++){
				if(i!=j){
					set<ll > g;
					g.insert(i),g.insert(j);
					v.insert(g);
				}
			}
		}
		int j=0;
		for(int i=0;i<k;i++){
			s.erase(*v.begin());	
			v.erase(*v.begin());
		}
		cout<<s.size()<<"\n";
		for(auto x: s){
			for(auto y:x) cout<<y<<" ";
			cout<<"\n";
		}
	}
	return  0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll MOD = (ll)1e9 + 7, INF = (ll)1e18;;
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 100100;
ll a[N];
ll n, k = 2, ans = 0;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    ans = a[0] - 1;
    for (int i = 1; i < n; ++i) {
        ll t = (a[i] - 1) / k;
        if (t == 0)
            k = max(k, a[i] + 1);
        ans += t;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	bool ans[26];
	memset(ans,0,sizeof(ans));
	for(int i=0;i<len;i++){
		ans[s[i]-'a']=1;
	}
	int i=0;
	for(i=0;i<26;i++){
		if(ans[i]!=1){
			cout<<(char)('a'+i)<<endl;
			break;
		} 
	}
	if(i==26){
		cout<<"None\n";
	} 
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    int d[6];
    char tmp, c;

    scanf("%d %d %d %d %d %d\n", &d[0], &d[1], &d[2], &d[3], &d[4], &d[5]);
    while ((c=getchar())!=EOF) {
        if (c=='N') {
            tmp=d[0];
            d[0]=d[1];
            d[1]=d[5];
            d[5]=d[4];
            d[4]=tmp;
        }
        if (c=='S') {
            tmp=d[0];
            d[0]=d[4];
            d[4]=d[5];
            d[5]=d[1];
            d[1]=tmp;
        }
        if (c=='E') {
            tmp=d[0];
            d[0]=d[3];
            d[3]=d[5];
            d[5]=d[2];
            d[2]=tmp;
        }
        if (c=='W') {
            tmp=d[0];
            d[0]=d[2];
            d[2]=d[5];
            d[5]=d[3];
            d[3]=tmp;
        }
    }
    printf("%d\n", d[0]);

    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 5e6+100;
const int mod = 1e9+7;
char arr[upperlimit];
int main() {
	int k;
	cin >> arr;
	cin >> k;
	int i=0;
	while(arr[i]!='\0'){
		i++;
	}
	for(int j = 0; j < i; j+=k){
		cout << arr[j];
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

//Range Max Query
class SegmentTree {
private:
	ll n;
	vector<ll>node;

public:
	void init(ll size) {
		n = 1;
		while (n < size) { n *= 2; }
		node.resize(2 * n - 1, -1);
	}

	// node[i] = x 
	void update(ll i, ll x) {
		i += n - 1;
		node[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			node[i] = max(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	// max([a, b))
	ll get_max(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) { r = n; }
		if (r <= a || b <= l) { return -1; }
		if (a <= l && r <= b) { return node[k]; }
		ll vl = get_max(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = get_max(a, b, 2 * k + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
};

ll a, b;
vector<ll>v;
int main() {
	cin >> a >> b;
	SegmentTree tree;
	tree.init(a);
	v.resize(a);
	for (int i = 0; i < a; ++i) { cin >> v[i]; }
	for (int i = 0; i < a; ++i) { tree.update(i, v[i]); }

	ll l = 0, r = b + 1;

	for (int i = 0; i < a - b; ++i) {
		ll mon = tree.get_max(l, r);

		cout << mon;
		for (int j = l; j < r; ++j) {
			if (v[j] == mon) {
				l = j + 1;
				++r;
				break;
			}
		}
	}


	cout << endl;
}


Measured memory_bytes: 8404
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
}

class TRUMP {
  public:
    char m;
    int n;
};

void swapT(TRUMP &a, TRUMP &b) {
    TRUMP t;
    t = a;
    b = a;
    a = t;
}

int main() {
    int N;
    cin >> N;
    vector<TRUMP> A(N), B(N), C(N);
    rep(i, N) {
        cin >> A[i].m >> A[i].n;
        B[i].m = C[i].m = A[i].m;
        B[i].n = C[i].n = A[i].n;
    }

    // bubble
    bool flag = 1;
    while(flag) {
        flag = 0;
        for(int j = N - 1; j > 0; j--) {
            if(B[j].n < B[j - 1].n) {
                swap(B[j], B[j - 1]);
                flag = 1;
            }
        }
    }
    rep(i, N) {
        if(i)
            cout << " ";
        cout << B[i].m << B[i].n;
    }
    cout << endl;
    cout << "Stable" << endl;

    // selection
    rep(i, N) {
        int min = i;
        rep(j, i, N) {
            if(C[j].n < C[min].n)
                min = j;
        }
        if(i != min) {
            swap(C[i], C[min]);
        }
    }
    rep(i, N) {
        if(i)
            cout << " ";
        cout << C[i].m << C[i].n;
    }
    cout << endl;
    flag = 1;
    rep(i, N) { flag = flag & (B[i].m == C[i].m); }
    cout << (flag ? "Stable" : "Not stable") << endl;
}



Measured memory_bytes: 3104
package main

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

/*-----------Main-----------*/

func main() {
	n := readI()
	a := "zabcdefghijklmnopqrstuvwxy"
	ans := ""
	for n != 0 {
		l := n % 26
		ans = string(a[l]) + ans
		n = n / 26
		if l == 0 {
			n--
		}
	}
	fmt.Println(ans)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Println("Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1848
#include <iostream>
#include <map>
#include <cmath>
using namespace std;
int main(void){
    double tmp;
    int a[100],n,ans = 0; cin >> n;
    double ave = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        ave += a[i];
    }
    ave /= n;
    tmp = abs(a[0] - ave);
    for(int i = 0;i < n;i++){
        if(abs(a[i] - ave) < tmp){
            tmp = abs(a[i] - ave);
            ans = i;
        }
    }
   cout << ans << endl;
   return 0;
}

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

using namespace std;

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl

const int maxn = (int)3e5+5;
typedef long long ll;


void solve(){

   int a[6], res = -1;
   for(int i=1 ; i<=5 ; i++) {
      cin >> a[i];
      if(a[i]==0 && res==-1){
         res = i;
      }
   }

   cout << res << endl;
}


int main()
{
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;

    int t=1;
    //cin >> t;
    while(t--){
      solve();
    }


    return 0;
}



Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible") << endl;
}



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

int main() {
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  for (int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  int p = 0;
  for (int i = 0;i < n;i++){
    p += a.at(i);
  }
  
  if (p >= h){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == 's'){
        cout << s + "es" << endl;
    }else{
        cout << s + 's' << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
 
int count;
 
void merge(int A[], int left, int mid, int right, int n){
 
int n1, n2, L[250001], R[250001], i, j, k;
n1 = mid - left;
n2 = right - mid;
for(i = 0; i < n1; i++){
L[i] = A[left + i];
}
for(i = 0; i < n2; i++){
R[i] = A[mid + i];
}
L[n1] = 2000000000;
R[n2] = 2000000000;
i = 0;
j = 0;
for(k = left; k < right; k++){
count++;
if(L[i] <= R[j]){
A[k] = L[i];
i++;
}
else{
A[k] = R[j];
j++;
}
 
}
 
}
 
 
 
void mergeSort(int A[], int left, int right, int n){
 
int mid;
if(left + 1 < right){
mid = (left + right) / 2;
mergeSort(A, left, mid, n);
mergeSort(A, mid, right, n);
merge(A, left, mid, right, n);
}
 
}
 
 
 
int main(void){
 
int A[500000], n, i;
count = 0;
 
scanf("%d",&n);
for(i = 0; i < n; i++){
scanf("%d",&A[i]);
}
 
mergeSort(A, 0, n, n);
 
for(i = 0; i < n; i++){
if(i != 0) printf(" ");
printf("%d", A[i]);
}
 
printf("\n");
printf("%d\n",count);
 
return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    map<string, int> mp;
    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        mp[s] = 1;
    }
    auto begin = mp.begin(), end = mp.end();
    for(auto iter = begin; iter != end; iter++) {
        if(iter->second != 0) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 19064
object Main {

  import scala.io.StdIn

  def main(args: Array[String]): Unit = {
    val Array(n, m, r) = StdIn.readLine.split(" ").map(_.toInt)
    val rs = StdIn.readLine.split(" ").map(_.toInt-1)

    val map = Array.fill(n)(Array.fill(n)(Int.MaxValue / 3))
    for (_ <- 1 to m) {
      val Array(a, b, c) = StdIn.readLine.split(" ").map(_.toInt)
      map(a-1)(b-1) = c
      map(b-1)(a-1) = c
    }

    for {
      k <- 0 until n
      i <- 0 until n
      j <- 0 until n
      if map(i)(k) + map(k)(j) < map(i)(j)
    } {
       map(i)(j) = map(i)(k) + map(k)(j)
    }

    println {
      rs
        .permutations
        .map(_.sliding(2).map { case Array(i, j) => map(i)(j) }.sum)
        .min
    }
  }
}

Measured memory_bytes: 110616
#include <bits/stdc++.h>
using namespace std;
long long N;
long long A[100001];
long long ans = 0;


int main () {
	cin >> N;
	for (long long n = 0; n < N; n ++) {
		cin >> A[n];
	}
	sort(A, A + N, [](long long i, long long j)->bool {return abs(i) < abs(j);});
	reverse(A, A + N);
	for (long long n = 0; n < N - 1; n ++) {
		if (A[n] < 0) {
			A[n] *= -1;
			A[n + 1] *= -1;
		}
	}
	for (long long n = 0; n < N; n ++) {
		ans += A[n];
	}
	cout << ans << endl;
}
	
	

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; ll d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ll x, y; cin >> x >> y;
        if (d * d >= x * x + y * y) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

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

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,c,d;
    cin >> a >> b >> c >>d ;
    if(a+b > c+d) cout << "Left";
    if(a+b < c+d) cout << "Right";
    if(a+b == c+d) cout << "Balanced";
    cout << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for(int i=0;i<a;i++) cin >> p[i];
    for(int i=0;i<b;i++) cin >> q[i];
    for(int i=0;i<c;i++) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    vector<ll> pqr;
    pqr.insert(pqr.end(), p.begin(), p.begin()+x);
    // cout << pqr.size() << endl;
    pqr.insert(pqr.end(), q.begin(), q.begin()+y);
    // cout << pqr.size() << endl;
    pqr.insert(pqr.end(), r.begin(), r.end());
    // cout << pqr.size() << endl;
    sort(pqr.begin(), pqr.end(), greater<ll>());
    ll ans = accumulate(pqr.begin(), pqr.begin()+x+y, 0LL);
    cout << ans << endl;
}


Measured memory_bytes: 6592
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S;

    cin >> S;

    char pre = S[0];
    for (int i = 1; i < S.size(); i++) {
        if (pre == S[i]) {
            cout << "Bad" << endl;
            return 0;
        }

        pre = S[i];
    }

    cout << "Good" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ansDic = new SortedDictionary<int, int>();

            int count = 1;
            foreach (var x in a)
            {
                ansDic.Add(x, count++);
            }

            foreach(var x in ansDic)
            {
                Console.Write(x.Value + " ");
            }

        }
    }
}


Measured memory_bytes: 32248
n, k = gets.chomp!.split(" ").map(&:to_i)
MOD = (10 ** 9) + 7 

$pascal = {
    0 => {0 => 1},
    1 => {0 => 1, 1 => 1},
}

def pascal(n, i)
    return 1 if n == 0
    return $pascal[n][i] if $pascal[n] && $pascal[n][i]

    if n == i || i == 0
        $pascal[n] ||= {}
        $pascal[n][i] = 1
    else
        $pascal[n] ||= {}
        $pascal[n][i] = (pascal(n-1, i-1) + pascal(n-1, i)) % MOD
    end

    return $pascal[n][i]
end

# 入れられる場所の数
red = n - k + 1

1.upto(k) do |i|
    # i回の操作で取り除ける => i個にi-1個の仕切りを入れて青玉をi個に分割する

    if i > red # 入れられる場所の数よりも分割数のほうが多いので入れられない
        puts 0
    else
        x = pascal(red, i)
        y = pascal(k - 1, i - 1)
        puts (x * y) % MOD
    end
end


Measured memory_bytes: 45692
def main():
    a, b, c, k = (int(i) for i in input().split())
    xa = min(a, k)
    k -= xa
    xb = min(b, k)
    k -= xb
    xc = k
    ans = xa - xc
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61960
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int num[26] = { 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0 };
	while (s != "#") {
		ans = 0;
		for (int i = 1; i < s.size(); i++) {
			ans += abs(num[s[i] - 'a'] - num[s[i - 1] - 'a']);
		}
		cout << ans << endl;
		cin >> s;
	}
	return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	string str;
	cin>>str;
	bool is=true;
	for(ll i=0;i<str.size();i=i+2){
		if(str[i]=='L'){
			is=false;
			break;
		}
	}
	for(ll i=1;i<(ll)str.size();i=i+2){
		if(str[i]=='R'){
			is=false;
			break;
		}
	}
	if(is){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#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 r;
  cin >> r;

  double res = (double) 2 * r * M_PI;

  cout << fixed << setprecision(10) << res << endl;

  return 0;
}


Measured memory_bytes: 3784
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define next Next
#define y1 _y1
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
LL s;
LL x1,y1,x2,y2;
int main(){
	s=read();
	//x1y2-x2y1
	LL a=sqrt(s);
	while (a*a<s)
		a++;
	LL d=a*a-s;
	x1=y2=a;
	if (d>a)
		d-=a,x1--;
	x2=1,y1=d;
	cout<<"0 0 "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,0,n) cin >> a[i];
  int ans = 0;
  rep(i,0,n-1) rep(j,i+1,n) {
    ans += a[i] * a[j];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long long N;
  cin>>N;
  double n=sqrt(N);
  long long a,b;
  for (long long i=n/1; i>0; i--){
    if(N%i==0) {a=i;  b=N/a; break;}
  
  }
  cout<<a+b-2<<endl;
}
    
  

Measured memory_bytes: 256
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int64_t n, k;
    cin >> n >> k;

    int64_t ans = 0;

    vector<int64_t> vs(k, 0);
    for (int i = 1; i <= n; i++)
    {
        vs[i % k]++;
    }

    ans += vs[0] * vs[0] * vs[0];

    if (k % 2 == 0)
    {
        ans += vs[k / 2] * vs[k / 2] * vs[k / 2];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
import bisect

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()

    # O(N^2 * logN)の全探索で解く
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
n= int(input())

a=list(map(int, input().split()))
correct=sorted(a)

p=0
for i in range(n-1):
  for j in range(n-i-1):
    a[i], a[n-j-1] = a[n-j-1], a[i]
    if a == correct:
      p += 1
      
    else:
      pass
    a[i], a[n-j-1] = a[n-j-1], a[i]
    
if p == 1 or a == correct:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
map<long,long>mp;
int main()
{
    long i,j,t,a,b,n,c,y,m,prev,sum,ans=1;
    t=1;
    // cin>>t;
    while(t--)
    {
       string s;
       cin>>n;
       long arr[n];
       for(i=0;i<n;i++)
       {
           cin>>arr[i];
           mp[arr[i]]++;
       }
       m=0;
       bool flag=false;
       for(auto x:mp)
       {
           if(x.second>=4)
           {
               m=4;
           }
           else if(x.second>=2)m+=2;
       }
       if(m<4)
       {
           cout<<0;
           return 0;
       }
       sort(arr,arr+n);
       reverse(arr,arr+n);
       long count=1;
       long times=0;
       for(i=1;i<n;i++)
       {
           if(arr[i-1]==arr[i])
           {
               count++;
           }
          
           if(count==2)
           {
               ans*=arr[i];
               times++;
               count=1;
               i++;
           }
           if(times==2)break;
       }
       cout<<ans;
    }
}

Measured memory_bytes: 7296
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);
int n,h;
vii v;
ll dp[1005][10005];
ll go(int idx,int rem){
     if(rem<=0)
         return 0;
     if(idx==n)
         return 1e18;
     ll &ret=dp[idx][rem];
     if(~ret)
         return ret;
    return ret=min(go(idx,rem-v[idx].f)+v[idx].s,go(idx+1,rem));
}
void solve(){
    cin>>h>>n;
    v.resize(n);
    for(auto &i:v)
        cin>>i.f>>i.s;
    mem(dp,-1);
    cout<<go(0,h)<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 82872
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A= keyboard.nextInt();
		int B= keyboard.nextInt();
		int C= keyboard.nextInt();
		int K= keyboard.nextInt();
		
		int ans =0;
		
		if(A<=K){
			ans = A;
			K -= A;
			if(K!=0 && B<=K){
				//ans += 0;
				K -= B;
				ans -=K;
			}
		}else{
			ans = K;
		}

		System.out.print(ans);
		keyboard.close();	
		
	}
}

Measured memory_bytes: 35640
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  itn n,m; cin >> n >> m;
  vector<vector<int> > a(n,vector<int>(m));
  rep(i,n)rep(j,m){
    cin >> a[i][j];
    a[i][j]--;
  }
  set<int> erased;
  vector<set<int> > sp(m);
  map<int,int> it;
  set<itn> tg;
  rep(i,n) tg.insert(i);
  int ans=n;
  while(erased.size()<=m-1){
    for(auto i:tg){
      while(erased.count(a[i][it[i]])) it[i]++;
      sp[a[i][it[i]++]].insert(i);
    }
    tg.clear();
    int mx=0;
    rep(i,m) chmax(mx,(int)sp[i].size());
    rep(i,m){
      if(sp[i].size()==mx){
        for(auto v:sp[i]) tg.insert(v);
        erased.insert(i);
        sp[i].clear();
      }
    }
    chmin(ans,mx);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4012
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<vector<char> > a(h, vector<char>(w)); REP(i, h) REP(j, w) cin >> a[i][j];
  vector<vector<long long> > dp(h, vector<long long>(w, 0));
  dp[0][0] = 1;
  FOR(i, 1, h) if (a[i][0] == '.') dp[i][0] = dp[i-1][0];
  FOR(j, 1, w) if (a[0][j] == '.') dp[0][j] = dp[0][j-1];
  FOR(i, 1, h) FOR(j, 1, w) if (a[i][j] == '.') {
    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
  }
  cout << dp[h-1][w-1] << '\n';
  return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    // factor
    for(ll x=1; x*x<=n; x++)if(n%x==0){
        if(x>1){
            ll m = x-1;
            if(n == (n/m)*(m+1))ans += m;
        }
        if(n/x!=x){
            ll m = n/x-1;
            if(n == (n/m)*(m+1))ans += m;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

namespace tree {
struct union_find {
  static const int Max = 22;
  int par[Max], rank[Max], size[Max], compnum;

  union_find(int N) {
    compnum = N;
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

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

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int N, M;
unordered_map<string, int> idmap;
vector<string> langs;
bool speaks[23][33];

void input() {
  langs.clear(); langs.resize(N);
  rep(i, N) {
    cin >> langs[i];
    idmap[langs[i]] = i;
  }
  memset(speaks, 0, sizeof speaks);
  rep(i, M) {
    int k; cin >> k;
    rep(_, k) {
      string s; cin >> s;
      speaks[i][idmap[s]] = 1;
    }
  }
}

bool next_combination(int& comb, int const BitSize) {
  int x = comb & -comb, y = comb + x;
  comb = ((comb & ~y) / x >> 1) | y;
  return comb < 1 << BitSize;
}

void solve() {

  REP(K, 1, min(N + 1, 6)) {
    int comb = (1 << K) - 1;
    do {
      vector<int> uselangs;
      rep(i, N) {
        if(!(comb & 1 << i)) continue;
        uselangs.push_back(i);
      }

      tree::union_find uf(M);

      rep(i, M) REP(j, i + 1, M)
        for(auto langid: uselangs)
          if(speaks[i][langid] && speaks[j][langid])
            uf(i, j);

      if(uf.num_of_comps() == 1) {
        printf("%d\n", (int)uselangs.size());
        for(auto e: uselangs) printf("%s\n", langs[e].c_str());
        return;
      }
    } while(next_combination(comb, N));
  }
  puts("Impossible");
}

int main() {
  bool first = 0;
  for(; cin >> N >> M && (N|M);) {
    if(first) cout << endl;
    first = 1;
    input();
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3344
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int r = scan.nextInt();
    int D = scan.nextInt();
    int x = scan.nextInt();
    for (int i = 0;i < 10;i++) {
      x = r * x - D;
      System.out.println(x);
    }
  }
}


Measured memory_bytes: 35676
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const ll N = 1e6 + 2;
const ll Mod = 2520;

int cnt[N];
int dev[N];

int main()
{
	GO;
	int n;
	cin >> n;
	while (n--)
	{
		int x; cin >> x;
		cnt[x]++;
	}
	int ans = 0;
	for (int i = 1; i < N; i++)
	{
		if (cnt[i] == 1 && !dev[i])
			ans++;
		if (!cnt[i])continue;
		for (int j = i; j < N; j += i)
			dev[j] = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11460