akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N; 
long long int W; 
cin >> N >> W; 
long long int A[110] = {}, B[110] = {}, C[110] = {}, D[110] = {}; 
long long int w, v; 
cin >> w >> v; 
int count[5] = {0}; 
A[0] = v; 
count[0] = 1; 
 
for(int i = 1; i < N; i++){
long long int a, b; 
cin >> a >> b; 
if(a == w){
A[count[0]] = b; 
}
else if(a == w+1){
B[count[1]] = b; 
}
else if(a == w+2){
C[count[2]] = b; 
}
else if(a == w+3){
D[count[3]] = b; 
}
count[a-w] ++; 
}
 
sort(A, A+count[0], greater<int>()); 
sort(B, B+count[1], greater<int>()); 
sort(C, C+count[2], greater<int>()); 
sort(D, D+count[3], greater<int>()); 
 
long long int S1[110] = {}, S2[110] = {}, S3[110] = {}, S4[110] = {}; 
for(int i = 1; i <= count[0]; i++){
S1[i] = S1[i-1] + A[i-1]; 
}
for(int i = 1; i <= count[1]; i++){
S2[i] = S2[i-1] + B[i-1]; 
}
for(int i = 1; i <= count[2]; i++){
S3[i] = S3[i-1] + C[i-1]; 
}
for(int i = 1; i <= count[3]; i++){
S4[i] = S4[i-1] + D[i-1]; 
}
long long int ans = 0; 
for(int a = 0; a <= count[0]; a++){
 for(int b = 0; b <= count[1]; b++){
  for(int c = 0; c <= count[2]; c++){
   for(int d = 0; d <= count[3]; d++){
    if(a * w + b * (w+1) + c * (w+2) + d * (w+3) <= W){
     ans = max(ans, S1[a] + S2[b] + S3[c] + S4[d]);
    }
   }
  } 
 }
}
  cout << ans << 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;
int INF = 1000000009;
int main()
{
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s[i]==','){
      s[i] = ' ';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
//69行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

//Simple Array Input
#define SAI int n;cin >> n;vi a(n);ain(a)
//Simple Graph Input
#define SGI(m) for(int i=0;i<m;i++){int a,b;cin >> a >> b;g[--a].pb(--b);g[b].pb(a);}
//Simple Tree Input
#define STI SGI(n-1)

typedef long long ll;
typedef long long integer;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){
    for(int i=0;i<a.size();i++)cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
}
///////////////////////////////////////////////////////////


int main(void){
    cin.tie(0);
  	ios::sync_with_stdio(false);
	int n,p;cin >> n >> p;
	ll mod = p;

	string s;cin >> s;

	reverse(s.begin(),s.end());

	if(p == 2 || p == 5){
        ll ans = 0;
        reverse(s.begin(),s.end());

        rep(i,n){
            if((s[i] - '0') % p == 0){
                ans += (ll)(i + 1);
            }
        }
        cout << ans << '\n';
        return 0;
	}
	
	vector<ll> a(n);
	ll now = 1;
	rep(i,n){
		a[i] = (now * (s[i] - '0')) % mod;
		now = (now * 10LL) % mod;
	}		
	vector<ll> c(n+1,0);
	rep(i,n){
		c[i+1] = (c[i] + a[i]) % mod;
	}

	vector<ll> cnt(p+1,0);
	rep(i,n+1){
		cnt[c[i]]++;
	}
	ll ans = 0;
	rep(i,p){
		ll c = cnt[i];
		ans += c * (c - 1) / 2; 
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3732
#include<stdio.h>
int main()
{
    long int N,n;
    scanf("%ld",&N);
    if(N%1000==0)
    {
        printf("0");

    }
    else if(N%1000!=0)
    {
        n=1000-(N%1000);
        printf("%ld",n);
    }

}


Measured memory_bytes: 1732
n = gets.to_i

xy = []
n.times do
    x, y = gets.split.map(&:to_i)
    xy << [x - y, x + y]
end

xy.sort_by!{|e| e[0]}
a = xy[-1][0] - xy[0][0]
xy.sort_by!{|e| e[1]}
b = xy[-1][1] - xy[0][1]
p [a, b].max

Measured memory_bytes: 36284
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最小公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最大公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans[300000] = {0};
    int oddr = 0;
    int ever = 1;
    int last = 0;
    FOR(i,1,s.size()){
      if(s[i]=='R'){
        if(i%2)oddr++;
        else ever++;
        last = i;
      }else{
        if(!(i%2)){
          ans[i]+=ever;
          ans[i-1]+=oddr;
        }else{
          ans[i]+=oddr;
          ans[i-1]+=ever;
        }
        if((i-last)%2) ans[last+1]++;
        else ans[last]++;
        oddr = 0;
        ever = 0;
      }
    }
    REP(i,s.size())cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2000
def change(t) :
    if t == 1 :
        return 6000
    elif t == 2 :
        return 4000
    elif t == 3 :
        return 3000
    elif t == 4 :
        return 2000


t1, n1 = map(int, input().split())
t2, n2 = map(int, input().split())
t3, n3 = map(int, input().split())
t4, n4 = map(int, input().split())

print(change(t1) * n1)
print(change(t2) * n2)
print(change(t3) * n3)
print(change(t4) * n4)


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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main() {
  Bint N,c=2;
  string s;
  cin>>N;
  if(N==0){
    cout<<0;
  }
  else{
  while(N!=0){
    if(N%c!=0){
      N-=c/2;
      s+='1';
    }
    else{
      s+='0';
    }
    c*=-2;
    //cout<<N<<" ";
  }
  reverse(s.begin(),s.end());
  cout<<s;
  }
  

 
}


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

ll solve(int n, vector<ll> a) {
  ll ans = 1;
  for(int i=0;i<n;i++) {
    if(a[i] == 0) {
      return 0;
    }
  }
  for(auto aa: a) {
    if(aa <= 1000000000000000000/ans) {
      ans *= aa;
    } else {
      return -1;
    }
  }
  if(ans > 1000000000000000000 || ans <=0) {
    return -1;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  cout << solve(n, a);
}


Measured memory_bytes: 4780
import math
x=int(input())
def eratosthenes(n):
    """n以下の素数をエラトステネスの篩によって求める.リストをかえす"""
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
ans=eratosthenes(10**5+3)
for i in  range(len(ans)):
    if ans[i]>=x:
        print(ans[i])
        exit()
    else:
        pass

Measured memory_bytes: 85112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,d,ans,x[210],y[210],p[210];

int main(){
	scanf("%d",&n);
	int M=998244353;
	p[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		p[i]=1ll*p[i-1]*2%M;
	}
	ans=p[n]-n-1;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			d=0;
			for(int k=j+1;k<=n;k++)d+=(y[i]-y[j])*(x[i]-x[k])==(y[i]-y[k])*(x[i]-x[j]);
			ans=(ans+M-p[d])%M;
		}
	}
	printf("%d",ans);
  	return 0;
}

Measured memory_bytes: 3796
from operator import itemgetter
n,m=map(int,input().split())
L=[]
for _ in range(m):
    a,b=map(int,input().split())
    L.append([a,b])
L.sort(key=itemgetter(1))
cut=0
cnt=0
for i in L:
    if not (i[0]<=cut<i[1]):
        cut=i[1]-1
        cnt+=1
print(cnt)

Measured memory_bytes: 63040
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

vector<vector<int>> G,G2;
vector<bool> checked;
int ans;

int depth(int now){
	vector<int> memo;
	rep(i,G[now].size()){
		int next = G[now][i];
		if(!checked[next]){
			checked[next] = true;
			memo.push_back(depth(next));
			//ret = max(ret, depth(next)+1);
		}
	}
	if(memo.size() == 0){
		return 1;
	}
	sort(all(memo));
	reverse(all(memo));
	if(memo.size() >= 2){
		ans = max(ans, memo[0]+memo[1]+1);
	}else{
		ans = max(ans, memo[0]+1);
	}
	//cout<<now<<" "<<ret<<endl;
	return memo[0] + 1;
}

int main(void){
	ans = 0;
	int n;
	cin>>n;
	rep(i,n){
		G.push_back(vector<int>());
		checked.push_back(false);
	}
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	checked[0] = true;
	vector<int> rets;
	depth(0);
	/*if(G[0].size() == 1){
		ans = depth(0);
		cout<<ans<<endl;
	}else{		
		rep(i,G[0].size()){
			rets.push_back(depth(G[0][i]));
		}
		sort(all(rets));
		reverse(all(rets));
		ans = rets[0] + rets[1] + 1;
		cout<<ans<<" "<<rets[0]<<" "<<rets[1]<<endl;
	}*/
	//cout<<ans<<endl;

	if(ans%3 == 2){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	
	return 0;
}


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

 int main() {
     int n;
     cin >> n;
     bool OK =false;
        for (int i =0; i<=n/4;i++){
            for (int j=0;j<=n/7;j++){
                if (i*4+j*7 ==n) OK =true;
            }
        }
        if (OK == false ) cout << "No" << endl;
        else cout << "Yes" << endl;
     }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int f(int n) {
  int a = 0;
  while(n) {
    a = n;
    n /= 10;
  }
  return a;
}

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> vec(10, vector<int>(10, 0));

  for (int i = 1; i <= n; i++) {
    int a = i % 10;
    int b = f(i);
    vec.at(a).at(b)++;
  }
  ll ans = 0;
  reps(i, 1, 10) {
    reps(j, 1, 10) {
      ans += vec.at(i).at(j) * vec.at(j).at(i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x := larger(iScan(), iScan())
	n := iScan()
	fmt.Println((n + x - 1) / x)
}


Measured memory_bytes: 1772
import sys
input = sys.stdin.readline
S = input().strip()
Q = int(input())
f = 0
add = ['', '']
for q in range(Q):
    query = input().strip()
    if query == '1':
        f ^= 1 
    else:
        _, F, C = query.split(' ')
        add[int(F)-1^f] += C
print(''.join([add[f][::-1], S[::(f*-1*2)+1], add[f*-1+1]]))


Measured memory_bytes: 4436
n,m=map(int,input().split())
a = [None] * n
for i in range(n):
    a[i] = list(map(int,input().split()))
b = [None] * m
for i in range(m):
    b[i] = int(input())

c = [None] * n
for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += a[i][j] * b[j]
    c[i] = tmp

for val in c:
    print(val)


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    string s[n];
    rep(i, n) { cin >> s[i]; }
    map<string, int> m;
    rep(i, n) {
        if (m[s[i]] == 0) {
            m[s[i]] = 1;
        } else {
            m[s[i]]++;
        }
    }
    ll ans = 0;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 25508
#include <stdio.h>
int n,G[101][101];
int d[101];
int T = 0;
int F[101] = {0};
int k = 0;
 
void visit(int u) {
  int i,j,v;
  T++; 
  d[u] = T;
 
  for(v=0;v<n;v++) {
    if(G[u][v] == 1 && d[v] == 0 ) {
      visit(v);
    }
  }
   
  T++;
  F[u] = T;
 
}
 
 
 
int main() {
   
   
  int i,j,k,l,u,a,t;
 
  for(i=0;i<n;i++) d[i] = 0;
 
  scanf("%d",&n);
 
  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++) {
      G[i][j] = 0;
 
    }
 
  for(i=0;i<n;i++){
 
    scanf("%d %d ",&k,&u);
    //	printf("u = %d\n",u);
 
    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
  for(i=0;i<n;i++) {
    if(d[i] == 0)
    visit (i);
  }
     
  for(i=0;i<n;i++) {
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
  return 0;
 
     
     
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000000

int h;
int A[N+1];

void swap(int *a,int *b){
  int tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}
void maxHeapfy(int i){
  int largest,l=2*i,r=2*i+1;

  if(l<=h&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=h&&A[r]>A[largest]) largest = r;
  if(largest!=i){
    swap(&A[i],&A[largest]);
    maxHeapfy(largest);
  }
}

void buildMaxHeap(void){
  int i;
  for(i=h/2;i>=1;i--){
    maxHeapfy(i);
  }
}


int main(){
  int i;
  scanf("%d",&h);
  for(i=1;i<=h;i++) scanf("%d",&A[i]);
  buildMaxHeap();

  for(i=1;i<=h;i++) printf(" %d",A[i]);
  printf("\n");
  return 0;
}

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

using namespace std;

int N, Y;

void solve() {
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N - i; ++j) {
            if (Y == 10000 * i + 5000 * j + 1000 * (N - i - j)) {
                printf("%d %d %d \n", i, j, N - i - j);
                return;
            }
        }
    }
    printf("-1 -1 -1\n");
}

int main() {
    cin >> N >> Y;
    solve();
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll st[4*N],fl[N];
void build(ll node,ll nl,ll nr){
	if(nl==nr){
		st[node]=fl[nl];
		return ;
	}
	build(2*node,nl,(nl+nr)/2);
	build(2*node+1,(nl+nr)/2+1,nr);
	st[node]=st[node*2]+st[node*2+1];
}
ll query(ll node,ll nl,ll nr,ll ql,ll qr){
	if(nl>qr||ql>nr){
		return 0;
	}
	if(nl>=ql&&qr>=nr){
		return st[node];
	}
	ll a,b;
	a=query(2*node,nl,(nl+nr)/2,ql,qr);
	b=query(2*node+1,(nl+nr)/2+1,nr,ql,qr);
	return (a+b);
}
void update(ll node,ll nl,ll nr,ll idx){
	if(nl>idx||idx>nr){
		return ;
	}
	if(idx<=nl&&idx>=nr){
		st[node]=st[node]+1;
		return ;
	}
	update(2*node,nl,(nl+nr)/2,idx);
	update(2*node+1,(nl+nr)/2+1,nr,idx);
	st[node]=st[2*node]+st[2*node+1];
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	build(1,1,n);
	ll an=0;
	for(i=1;i<=n;i++){
		update(1,1,n,ar[i]);
		k=query(1,1,n,ar[i],n);
		//cout<<i<<" "<<k<<endl;
		if(k==i) an++;
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 6400
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define mod 1000000007
#define limit 200001
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i = 0; i < n; i++)
#define max(a,b) {if(a>b){return a;}return b;}
#define min(a,b) {if(a<b){return a;}return b;}

int main(){
    int n,i,j;
    int tmp = 0;
    int under_point = 0;
    int max_value = 0;
    int a[2][100];
    
    scanf("%d",&n);
    rep(i,n) scanf("%d",&a[0][i]);
    rep(j,n) scanf("%d",&a[1][j]);
    
    for(i = 0; i < n; i++){
        for(j = 0; j < under_point; j++) tmp += a[0][j];
        tmp += a[0][under_point];
        tmp += a[1][under_point];
        for(j = under_point+1; j < n; j++) tmp += a[1][j];
        if(tmp > max_value){
            max_value = tmp;
//            printf("max = %d\n",max_value);
        }
        tmp = 0;
        under_point++;
    }
    
    printf("%d\n",max_value);
}


Measured memory_bytes: 128
#include <iostream>//头文件
using namespace std;//名字空间
int main()
{
    int a,b;
    cin>>a>>b;
    if(a%2==1&&b%2==1)//判断它们是否都是奇数
        cout<<"Odd";//输出“Odd”
    else
        cout<<"Even";//“输出Even”
    return 0;
}

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

public class Main {
	// ------------------------

	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		// ------------------------
		long n=sc.nextInt(),minAbs=Integer.MAX_VALUE,sum=0,negs=0;
		for(int i=0;i<n;i++){
			int x=sc.nextInt();
			sum+=Math.abs(x);
			minAbs=Math.min(minAbs,Math.abs(x));
			if(x<0)
				negs++;
		}
		if(negs%2==1)
			sum-=2*minAbs;
		System.out.println(sum);
		// ------------------------
		out.close();
	}
	//------------------------

	public static PrintWriter out;
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 41996
#include <stdio.h>
int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    S%=3600;
    m=S/60;
    S%=60;
    s=S;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}
    


Measured memory_bytes: 2104
// ABC070A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main (void) {
    int N;
    cin >> N;
    set<string> S;
    rep(i, N) {
        string s;
        cin >> s;
        S.insert(s);
    }
    
    cout << S.size() << endl;
}


Measured memory_bytes: 19216
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
using namespace std;
int main()
{
  int n,m,p,a,b;
  for(;cin>>n>>m>>p>>a>>b,n;)
    {
      int t[n];
      for(int i=0;i<n;i++)
	cin>>t[i];
      int edge[m+2][m+2];
      memset(edge,-1,sizeof(edge));
      for(int i=0;i<p;i++)
	{
	  int x,y,z;
	  cin>>x>>y>>z;
	  edge[x][y]=z;
	  edge[y][x]=z;
	}
      //time,now,bit
      priority_queue< pair<double,pair<int,int > >, vector<pair<double,pair<int,int > > >,greater<pair<double,pair<int,int > > > >qu;
      qu.push(make_pair(0.0,make_pair(a,0)));
      map<pair<int,int>,bool> hash;
      bool flag=true;
      while(!qu.empty())
	{
	  double time=qu.top().first;
	  int now=qu.top().second.first;
	  int bit=qu.top().second.second;
	  qu.pop();
	  //	  cout<<"now: "<<time<<" "<<now<<" "<<bit<<endl;
	  if(now==b)
	    {
	      flag=false;
	      cout<<time<<endl;
	      break;
	    }
	  if(hash.count(make_pair(now,bit))!=0)
	    continue;
	  hash[make_pair(now,bit)]=true;
	  for(int i=0;i<=m;i++)
	    {
	      if(edge[now][i]!=-1)
		{
		  //		  cout<<"edge:"<<now<<"->"<<i<<endl;
		  for(int j=0;j<n;j++)
		    {
		      //		      cout<<"bit ;"<<bit<<" "<< (1<<j)<<endl;
		      //		      cout<<(bit & (1<<j))<<endl;
		      //		      cout<<(hash.count(make_pair(i,bit|(1<<j))))<<endl;
		      if(((bit & (1<<j)) == 0) &&
			 (hash.count(make_pair(i,bit|(1<<j))) == 0))
			{
			  ///	  cout<<"IN"<<endl;
			  qu.push(make_pair(time+(double(edge[now][i])/t[j]),make_pair(i,bit|(1<<j))));
			}
		      /*
		      else
			{
			  cout<<"OUT"<<endl;
			  cout<<(bit & (1<<j) == 0)<<endl;
			  cout<<(hash.count(make_pair(i,bit|(1<<j))))<<endl;
			}
		      */
		    }
		}
	    }
	}
      if(flag)
	cout<<"Impossible"<<endl;
    }
}

Measured memory_bytes: 15776
#include <stdio.h>

int main(){
    char S[4];
    int price = 700;
    scanf("%s", S);

    if(S[0] == 'o') price += 100;
    if(S[1] == 'o') price += 100;
    if(S[2] == 'o') price += 100;

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#define MAXN 300010
#define Endl '\n'
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ll long long int
#define pii pair<ll,ll>
#define all(v) v.begin(),v.end()
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define fk(x,n) for(ll k=x;k<n;k++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll exp(ll x,ll y,ll mod)
{
	ll res=1;
	x=x%mod;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y = y>>1;
		x=(x*x)%mod;
	}
	return res;
}
ll modinverse(ll x,ll mod)
{
    return exp(x,mod-2,mod);
}
using namespace std;
const ll inf = 0x3f3f3f3f3f3f3f3fll;
void solve()
{
    string s,t;
    cin>>s>>t;

    ll res=inf,n1=s.size(),n2=t.size();
    fi(0,n1-n2+1)
    {
        ll sum=0,k=0;
        fj(i,i+n2)
        {
            if(s[j]!=t[k])
                sum++;
            k++;
        }
        //cout<<sum<<endl;
        res=min(res,sum);
    }
    cout<<res;
}
int main()
{
    fastio;
    ll t;
    t=1;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
		int n, i, j, tmp;
		cin >> n;
		int x[n], y[n], sub[n];
		for (i=0; i<n; i++) cin >> x[i];
		for (i=0; i<n; i++) cin >> y[i];
		double d1=0, d2, d3, dinf;

		for (i=0; i<n; i++) d1+=(abs(x[i]-y[i]));
		for (i=0; i<n; i++) d2+=(abs((x[i]-y[i])*(x[i]-y[i])));
		d2 = sqrt(d2);
		for (i=0; i<n; i++) d3+=(abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i])));
		d3 = cbrt(d3);
		for (i=0; i<n; i++) {
				tmp = abs(x[i]-y[i]);
				if (dinf < tmp) dinf = tmp;
		}

		cout << fixed << d1 << "\n";
		cout << fixed << d2 << "\n";
		cout << fixed << d3 << "\n";
		cout << fixed << dinf << "\n";
}

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

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



Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize
    };

    let mut ht_counts = HashMap::new();
    for x in 1..=n {
        let chars = x
            .to_string()
            .chars()
            .map(|ch| ch.to_digit(10).unwrap() as usize)
            .collect::<Vec<_>>();
        let head = chars[0];
        let tail = chars[chars.len() - 1];
        *ht_counts.entry((head, tail)).or_insert(0) += 1;
    }
    let mut res = 0_usize;
    for h in 1..=9 {
        for t in 1..=9 {
            match (ht_counts.get(&(h, t)), ht_counts.get(&(t, h))) {
                (Some(&a), Some(&b)) => {
                    res += a * b;
                }
                _ => {}
            }
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

void trase(int* A, int n) {
	for (int i = 0; i < n; ++i) {
		if (i > 0) { cout << ' '; }
		cout << A[i];
	}
	cout << endl;
}

void insertion(int* A, int n) {
	int v, j;
	for (int i = 1; i < n; ++i) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trase(A, n);
		}

}

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

	int* A = new int[n];
	for (int i = 0; i < n ; ++i) {
		cin >> A[i];

	}

	trase(A, n);
	insertion(A, n);

	delete[] A;

}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    ll a,b,n; cin >> a >> b >> n;
    if(n>=b-1){
        ll x=b-1;
        cout << (a*x)/b-a*(x/b) << endl;
        
    }else{
        cout << (a*n)/b-a*(n/b) << endl;
    }

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Raag4924 ios_base::sync_with_stdio(0);
#define fastio cin.tie(0);cout.tie(0);
#define mod 1000000007
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/
const int N = 101;
const int M = 100005;
int dp[N][M];
int32_t main()
{
    Raag4924
    fastio

    int n,k;
    cin>>n>>k;

    vi v(n+1);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=0;i<=n;i++)dp[i][0] = 1;
    for(int i=1;i<=n;i++)
    {
        int length = v[i]+1;
        int sum=0;
        for(int j=0;j<length;j++)
        {
            sum=(sum%mod+dp[i-1][j]%mod)%mod;
            dp[i][j] = sum;
        }
        for(int j = length;j<=k;j++){
            sum = (sum%mod+dp[i-1][j]%mod-dp[i-1][j-length]%mod+mod)%mod;
            dp[i][j] = sum;
        }
    }

    cout<<dp[n][k]<<"\n";

    


  
 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


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

using namespace std;


void solve() {
    int n, k;
    cin >> n >> k;
    long double res = 0.0;
    for (int i = 1; i <= n; i++) {
        long double p = 1.0;
        int j = i;
        while (j<k) {
            j <<= 1;
            p /= 2;
        }
        res += p;
    }
    res /= n;
    cout << fixed << setprecision(12) << res;
}

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


Measured memory_bytes: 256
n = int(input())
A = []
for i in range(1, n // 2 + 1):
    a = str(i)
    b = str(n - i)
    t = 0
    for j in a:
        t += int(j)
    for k in b:
        t += int(k)
    A.append(t)
print(min(A))

Measured memory_bytes: 43356
// using meet in the meddle method for maximum independent set problem O(m*1.414^(m))


   #include <bits/stdc++.h>

  #define inf  1000000007
  #define  mp make_pair
  #define  pb push_back
  #define  pa pair<int,int> 
  using namespace std;



bool ok[1<<25];
bool miok[1<<25];
int an[1<<25];
int dp[1<<25];


struct MaxIndep{ 
	private:
	public:

	int hi,mi;
	vector<pa> e1,e2,e3;
 
	void makeok(){
		for(int i=0;i<(1<<hi);i++)ok[i]=true;
	
		for(auto t:e1){
			ok[(1<<t.first)+(1<<t.second)]=false;
		}
	
		for(int i=1;i<(1<<hi);i++){
			bool b=ok[i];
		
			for(int j=0;j<hi;j++){
				if(0==(i&(1<<j)))continue;
				if(ok[i^(1<<j)]==false){
					b=false;
					break;
				}
			}
			ok[i]=b;
		}
		return;
	
	}
 
	void makean(){
		for(int i=0;i<(1<<hi);i++)an[i]=(1<<(mi))-1;
	
		for(auto t:e3){
			an[(1<<t.first)]^= (1<<(t.second-hi));
		}
	
		for(int i=0;i<(1<<hi);i++){
		
			for(int j=0;j<hi;j++){
				if(0==(i&(1<<j)))continue;
				an[i]=an[1<<j]&an[i-(1<<j)];
				break;
			}
		}
	
	}
 
	void makedp(){
		for(int i=0;i<(1<<mi);i++)miok[i]=true;
	
		for(auto t:e2){
			miok[(1<<t.first)+(1<<t.second)]=false;
		}
	
		for(int i=1;i<(1<<mi);i++){
			bool b=miok[i];
		
			for(int j=0;j<mi;j++){
				if(0==(i&(1<<j)))continue;
				if(miok[i-(1<<j)]==false){
					b=false;
					break;
				}
			}
			miok[i]=b;
		}
	
		for(int i=0;i<(1<<mi);i++){
			if(miok[i]){
				int cnt=0;
				cnt=__builtin_popcount(i);
				dp[i]=cnt;
			}
			else dp[i]=0;
		}
	
		for(int i=0;i<(1<<mi);i++){
			for(int j=0;j<mi;j++){
				if(0==(i&(1<<j)))continue;
				dp[i]=max(dp[i],dp[i-(1<<j)]);
			}
		
		}
	}


	int solve(vector<vector<int>> ve){
		int n=ve.size();
		if(n==1) return 1;
		
		 hi=n/2;
   	 	 mi=n-hi;
		
		
		
		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)if(ve[i][j]){
    		if(j<hi)e1.pb(mp(i,j));
    		else if(i>=hi)e2.pb(mp(i-hi,j-hi));
    		else e3.pb(mp(i,j));
		}
	
	    makeok();
   		makean();
    	makedp();
    	
	    int ans=0;
	    	
	    for(int i=0;i<(1<<hi);i++)if(ok[i]){
	    	int cnt=0;
	    	for(int j=0;j<hi;j++)if(i&(1<<j))cnt++;
	    	
	    	ans=max(ans,cnt+dp[an[i]]);
	    }
		return ans;
	}


	
};


vector<int> a[60];

bool dame(int n,int x,int y){
	
	vector<pa> V;
	for(int i=0;i<n;i++)V.pb({a[x][i],a[y][i]});
	sort(V.begin(),V.end());
	for(int i=0;i<n-1;i++)if(V[i].second>V[i+1].second)return 0;
	return 1;
	
}

void SOL(){
 	int n,m;
 	cin>>n>>m;
	if(n==0 && m==0) exit(0);
	for(int i=0;i<m;i++)a[i].clear();
 	for(int i=0;i<n;i++)for(int j=0;j<m;j++){
 		int y;
 		cin>>y;
 		a[j].pb(y);
 	}
 	vector<vector<int>> ve(m,vector<int>(m,0));
 	
 	for(int i=0;i<m;i++)for(int j=i+1;j<m;j++){
 		if(!dame(n,i,j))ve[i][j]=1;
 	}
 	
 	 MaxIndep md;
 	cout<<md.solve(ve)<<endl;
}

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

 	while(1)SOL();
 	return 0;
 
  }
 


Measured memory_bytes: 13484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll a, b; cin >> n >> a >> b;
  vector<ll> X(n); rep(i, n) cin >> X[i];
  ll ans = 0;
  rep(i, n-1) {
    ans += min((X[i+1]-X[i])*a, b);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    char c;
    cin >> c;
    print(char(c + 1));

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <cstdint>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <cstring>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

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 rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(int N, vector<ll> & A) {
  vector<ll> res(N, 0);
  rep(i, N) {
    int x = 0;
    while (A[i] % 2 == 0) ++x, A[i] /= 2;
    res[i] = x;
  }
  return *min_element(all(res));
}

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

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

  auto ans = solve(N, A);
  cout << ans << endl;

  return 0;
}


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

int main() {
	vector<pair<int,int>> x(100),y(100);
	int n, m,o,t,h,k=0;
	o = t = h = 10;
	cin >> n >> m;
	vector<int> s(m), c(m);
	for(int i = 0; i < m; ++i) {
		cin >> s.at(i) >> c.at(i);
		if(s.at(i) == 1) {
			o = min(o,c.at(i));
		}
		if(s.at(i) == 2) {
			t =min(t, c.at(i));
		}
		if(s.at(i) == 3) {
			h = min(h,c.at(i));
		}
		x.at(s.at(i)).first += 1;
		if(x.at(s.at(i)).first > 0 && c.at(i) == x.at(s.at(i)).second) {
			x.at(s.at(i)).first -= 1;
			x.at(s.at(i)).second = c.at(i);
		}
		if(x.at(s.at(i)).second==0)
			x.at(s.at(i)).second = c.at(i);
		else if(x.at(s.at(i)).second!=c.at(i)) {
			cout << "-1" << endl;
			return 0;
		}
		if(x.at(s.at(i)).second == c.at(i))
			x.at(s.at(i)).first = 1;
		if(x.at(s.at(i)).second != c.at(i))
			k = 1;
		if(s.at(i) == 1 && c.at(i) == 0 && n != 1) {
			cout << "-1" << endl;
			return 0;
		}
		if(x.at(s.at(i)).first!=0)
			if(x.at(s.at(i)).second != c.at(i)) {
				cout << "-1" << endl;
				return 0;
			}
		/*if(x.at(s.at(i)).second != c.at(i)) {
			cout << "-1" << endl;
			return 0;
		}*/
		/*if(x.at(s.at(i)).second!=c.at(i)) {
			cout << "-1" << endl;
			return 0;
		}*/
	}
	if(o == 10) {
		o = 1;
		if(n == 1)
			o = 0;
	}
	if(t == 10) {
		t = 0;
	}
	if(h == 10)
		h = 0;

	cout << o;
	if(n == 2)
		cout << t;
	if(n == 3)
		cout<<t << h;
	cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int n,m;
vector<pair<ll,ll>> g[100000];
ll d[100000];


void dikestra(int s)
{
	d[s]=0;
	priority_queue<P,vector<P>,greater<>> PQ;
	PQ.push(P(0,s));
	d[s]=0;
	while (!PQ.empty())
	{
		P now = PQ.top();
		ll v = now.second;
		PQ.pop();
		if(d[v]<now.first)continue;
		for(int i = 0;i<g[v].size();++i)
		{
			P next = g[v][i];
			if(d[next.first]>d[v]+next.second)
			{
				d[next.first] = d[v]+next.second;
				PQ.push(P(d[next.first],next.first));
			}
		}
	}
	
}

int main()
{
	for(int i = 0;i<100000;i++)d[i]=1e18;
	int s,t;
	cin >> n >> m;
	cin  >> s ;
	//s--;
	t--;
	for(int i = 0;i<m;i++)
	{
		ll u,v,d;
		cin >> u >> v >> d;
		//v--;
		//u--;
		g[u].emplace_back(v,d);
		//g[v].emplace_back(u,d);
	}
	dikestra(s);
	for(int i = 0;i<n;i++)
	{
		if(d[i]==1e18)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}
}


Measured memory_bytes: 19464
abc = input().split()

x = []
for i in range(0, 3): x.append(int(abc[i]))
for j in range(0, 2):
    for i in range(0, 2):
        if x[i] > x[i + 1]:
            tmp = x[i + 1]
            x[i + 1] = x[i]
            x[i] = tmp
print(x[0], x[1], x[2])


Measured memory_bytes: 5600
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 2e5 + 5;
   
ll n, res;
ll a[MAXN], pref[MAXN];
unordered_map<ll, ll> ct;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
		ct[pref[i]] = 0;
	}
	
	ct[0] = 1;
	for (int i = 1; i <= n; i++) {
		res += ct[pref[i]];
		ct[pref[i]]++;
	}
	cout << res;
	return 0;
}	


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

// input
int N;
vector<int> L;


void input() {
    cin >> N;
    L = vector<int>(N);
    rep(i, N) cin >> L[i];
}


int main() {
    input();
    int s = 0;
    rep(i, N) s += L[i];
    int m = *max_element(L.begin(), L.end());
    string ans;
    if (m < s - m) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}


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

int constexpr N = 100000 + 9, M = 1000000000 + 7;
int dp[N][13], p[N];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  reverse(s.begin(), s.end());
  s = ' ' + s;

  p[0] = 1;
  for(int i = 1; i < N; ++i) {
    p[i] = 10ll * p[i - 1] % 13;
  }

  dp[0][0] = 1;
  
  for(int i = 1; i <= n; ++i) {
    if(s[i] != '?') {
      for(int j = 0; j < 13; ++j) {
        int d = (j + 1ll * (s[i] - '0') * p[i - 1]) % 13;
        dp[i][d] += dp[i - 1][j];
        if(dp[i][d] >= M) dp[i][d] -= M;
      }
    } else {
      for(int j = 0; j < 13; ++j) {
        for(int k = 0; k < 10; ++k) {
          int d = (j + k * p[i - 1]) % 13;
          dp[i][d] += dp[i - 1][j];
          if(dp[i][d] >= M) dp[i][d] -= M;
        }
      }
    }
  }
  cout << dp[n][5] << '\n';
}


Measured memory_bytes: 5868