akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        x: [usize; 5],
    }

    for i in 0..5 {
        if x[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2076
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	string s;
	cin >> s;
	int res = 0;
	for(char c : s)
		res += c & 15;
	cout << (res%9 ? "No" : "Yes") << '\n';
		
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

// 最大公約数 : 3,4 ->  1
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve()
{
  ll n, t;
  cin >> n;
  map<ll, ll> mp;
  ll l = 1;
  for(int i = 0; i < n; ++i)
  {
    cin >> t;
    ll g = gcd(l, t);
    l /= g;
    l *= t;
  }
  cout << l;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#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 N;
    cin >> N;
    vector<vector<ll>> abc(3, vector<ll>(N));
    rep(i, 3) rep(j, N) cin >> abc.at(i).at(j);

    rep(i, 3) sort(abc.at(i).begin(), abc.at(i).end());
    
    ll ans = 0;
    rep(j, N) {
        ll i = lower_bound(abc.at(0).begin(), abc.at(0).end(), abc.at(1).at(j)) - abc.at(0).begin();
        ll k = upper_bound(abc.at(2).begin(), abc.at(2).end(), abc.at(1).at(j)) - abc.at(2).begin();
        ans += i * (N - k);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3456
module Main where
import Data.Char

main = interact $ printer . solver . parser
int = read :: String -> Int
count a bs = length $ filter (==a) bs
split n ls = map (take n) $ takeWhile (/=[]) $ iterate (drop n) ls

printer = unlines 
parser input = (int hs, int ws, fs) 
  where
    (hs:ws:fs) = words input

solver :: (Int,Int,[String]) -> [String]
solver (h,w,fs) = 
  split w $
  [
    if (fs!!i!!j) == '#'
    then
    '#'
    else
    intToDigit $
    count '#' [(fs!!ii!!jj)
              |ii<-[(i-1)..(i+1)],0<=ii,ii<h,
               jj<-[(j-1)..(j+1)],0<=jj,jj<w]
  |i<-[0..(h-1)],j<-[0..(w-1)]
  ]
    
  


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	cout<<n*m<<endl;
}



Measured memory_bytes: 3164
#include <iostream>
#include <cstring>
using namespace std;
int dp[101][101][5],h,w;
int solve(int x,int y,int p);
int main(){
  while(cin >> w >> h  && w||h){
    memset(dp,0,sizeof(dp));
    cout << solve(0,0,0) << endl;
  }
}
int solve(int x,int y,int p){
  if(dp[x][y][p] != 0) return dp[x][y][p];
  if(x == h-1 && y == w-1) return 1;
  if(x >= h||y >= w) return 0;

  int c;
  switch(p){
  case 0:
    c = solve(x+1,y,1) + solve(x,y+1,2);
    break;
  case 1:
    c = solve(x+1,y,1) + solve(x,y+1,4);
    break;
  case 2:
    c = solve(x,y+1,2) + solve(x+1,y,3);
    break;
  case 3:
    c = solve(x+1,y,1);
    break;
  case 4:
    c = solve(x,y+1,2);
    break;
  }
  return dp[x][y][p] = c % 100000;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++)
     cin >> a.at(i);
  
  int alice = 0;
  int bob = 0;
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; i += 2)
    alice += a.at(i);
  for (int i = 1; i < n; i += 2)
    bob += a.at(i);
  
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int H[100010];
int MAX;
int ans;

int main(){
	cin >> N;
	cin >> H[0];
	for (int i = 1; i < N; i++){
		cin >> H[i];
		if (H[i] <= H[i - 1]){
			ans++;
		}
		else{
			if (ans > MAX){
				MAX = ans;
			}
			ans = 0;
		}
	}
	if (ans > MAX){
		MAX = ans;
	}

	cout << MAX << endl;

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
const int INF = 2000000000;

int H, W;
int g[1001][1001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W;
  queue<pair<int, int>> q;
  fill(g[0], g[1001], INF);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (c == '#') {
        q.push(make_pair(i, j));
        g[i][j] = 0;
      }
    }
  }

  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    int h = p.first, w = p.second;
    if (h - 1 >= 0 && g[h - 1][w] != 0) {
      if (g[h - 1][w] > g[h][w] + 1) {
        g[h - 1][w] = g[h][w] + 1;
        q.push(make_pair(h - 1, w));
      }
    }
    if (w - 1 >= 0 && g[h][w - 1] != 0) {
      if (g[h][w - 1] > g[h][w] + 1) {
        g[h][w - 1] = g[h][w] + 1;
        q.push(make_pair(h, w - 1));
      }
    }
    if (h + 1 < H && g[h + 1][w] != 0) {
      if (g[h + 1][w] > g[h][w] + 1) {
        g[h + 1][w] = g[h][w] + 1;
        q.push(make_pair(h + 1, w));
      }
    }
    if (w + 1 < W && g[h][w + 1] != 0) {
      if (g[h][w + 1] > g[h][w] + 1) {
        g[h][w + 1] = g[h][w] + 1;
        q.push(make_pair(h, w + 1));
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = max(ans, g[i][j]);
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12432
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------


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

    LLI ans = 0;
    int i,c = 0;
    for (i = 0; i < S.size(); i++) {
        if (S[i] == 'B') c++;
        else ans += c;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3668
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int num[5];
	
	for (int i = 0; i < 5; i++){
		scanf("%d", &num[i]);
	}
	
	sort(num, num + 5);
	reverse(num, num + 5);
	
	for (int i = 0; i < 4; i++){
		printf("%d ", num[i]);
	}
	
	printf("%d\n", num[4]);
	
	return (0);
}

Measured memory_bytes: 1040
package main

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

func main() {
	sc := NewScanner()
	count := make([]int, 5)
	for i := 0; i < 3; i++ {
		a, b := sc.NextInt(), sc.NextInt()
		count[a]++
		count[b]++
	}
	for i := 1; i <= 4; i++ {
		if count[i] > 2 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  while(1){
    int a,b;
    string op;
    cin >> a >> op >> b;
    if(op == "+"){
      cout << a+b << endl;
    }else if(op == "-"){
      cout << a-b << endl;
    }else if(op == "*"){
      cout << a*b << endl;
    }else if(op == "/"){
      cout << a/b << endl;
    }else{
      break;
    }    
  }
  return 0;
}



Measured memory_bytes: 3152
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;
typedef uint64_t u64;

typedef struct union_find_add {
  i32 *parent;
  i64 *add;
} union_find;

union_find* new_union_find (i32 n) {
  union_find *u = (union_find *) calloc (1, sizeof (union_find));
  u->parent = (i32 *) calloc (n, sizeof (i32));
  u->add = (i64 *) calloc (n, sizeof (i64));
  for (i32 i = 0; i < n; ++i) {
    u->parent[i] = -1;
  }
  return u;
}

i32 root (union_find *u, i32 x) {
  i32 stack[32];
  i32 top = 0;
  stack[top++] = x;
  while (u->parent[x] >= 0) {
    x = u->parent[x];
    stack[top++] = x;
  }
  i32 r = stack[top - 1];
  i64 buf = 0;
  for (i32 i = top - 2; i >= 0; --i) {
    i32 y = stack[i];
    i64 next = buf + u->add[y];
    u->add[y] += buf;
    buf = next;
    u->parent[y] = r;
  }
  return r;
}

void unite (union_find *u, i32 x, i32 y) {
  x = root (u, x);
  y = root (u, y);
  if (x == y) return;
  if (u->parent[x] > u->parent[y]) {
    i32 s = x;
    x = y;
    y = s;
  }
  u->add[y] -= u->add[x];
  u->parent[x] += u->parent[y];
  u->parent[y] = x;
}

void add (union_find *u, i32 x, i64 v) {
  u->add[root (u, x)] += v;
}

i64 find (union_find *u, i32 x) {
  i32 r = root (u, x);
  return r == x ? u->add[x] : u->add[x] + u->add[r];
}

void radix_sort (u64 *a, i32 n) {
  const i32 w = 5;
  const i32 mask = (1 << w) - 1;
  u64 *val = (u64 *) calloc (n, sizeof (u64));
  i32 *next = (i32 *) calloc (n + (1 << w), sizeof (i32));
  i32 *start = next + n;
  for (i32 b = 34; b < 64; b += w) {
    for (i32 j = 0; j < (1 << w); ++j) {
      start[j] = -1;
    }
    for (i32 i = 0; i < n; ++i) {
      i32 k = (a[i] >> b) & mask;
      val[i] = a[i];
      next[i] = start[k];
      start[k] = i;
    }
    for (i32 i = n - 1, k = mask; k >= 0; --k) {
      for (i32 p = start[k]; p != -1; p = next[p]) {
        a[i--] = val[p];
      }
    }
  }
  free (val);
  free (next);
}

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  u64 *e = (u64 *) calloc (n - 1, sizeof (u64));
  const i32 f = 17;
  const i32 mask = (1 << f) - 1;
  for (i32 i = 0; i < n - 1; ++i) {
    i32 a = read_int() - 1;
    i32 b = read_int() - 1;
    i32 c = read_int();
    e[i] = ((u64) c << 2 * f) + ((u64) a << f) + b;
  }
  radix_sort (e, n - 1);
  union_find *u = new_union_find (n);
  for (i32 i = n - 2; i >= 0; --i) {
    i32 a = root (u, e[i] & mask);
    i32 b = root (u, e[i] >> f & mask);
    i64 c = e[i] >> 2 * f;
    add (u, b, -u->parent[a] * c);
    add (u, a, -u->parent[b] * c);
    unite (u, a, b);
  }
  for (i32 i = 0; i < n; ++i) {
    print_int (find (u, i));
    putchar ('\n');
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 3560
#include <cstdio>

int A,B,C,D,E;

int main(){
	scanf("%d%d%d%d%d",&A,&B,&C,&D,&E);
	int ans = 0;
	if(B <= 0){
		ans = (B-A)*C;
	}
	else if(A>0){
		ans = (B-A)*E;
	}
	else{
		ans = -A*C + D + B*E;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2704
#include<utility>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
/*	int i, g, j, gj, h, gh;
	cin >> i >> g >> j >> gj >> h >> gh;

	if(i + 5*g + 10*j + 50*gj + 100*h + 500*gh >= 1000){
		cout << "1" << endl;
	}

	else{
		cout << "0" << endl;
	}*/

	/*int d, c;
	cin >> d >> c;
	cout << d * c << endl;*/
/*
	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		int k,p;
		cin >> k >> p;
		if(k%p == 0){
			cout << p << endl;
		}
		else cout << k%p << endl;
	}
	*/

	int n,m;
	cin >> n;
	
	int eat[300] = {};
	//iimori
	for(int i=0; i<n; i++){
		int h,m;
		cin >> h >> m;

		eat[i] = h*100+m;
	}
	//turugasaki
	
	cin >> m;
	for(int i=0; i<m; i++){
	int h,m;
	cin >> h >> m;

	eat[n+i] = h*100+m;
	}

	//sort
	sort(eat,eat+(n+m));

	for(int i=0; i<n+m; i++){
		if(eat[i-1] != eat[i]){
			cout << eat[i]/100 << ":";
			if(eat[i]%100 < 10){
				cout << "0";
			}
			if(i == n+m-1 || (eat[n+m-2] == eat[n+m-1]) && i == n+m-2){
				cout << eat[i]%100 << endl;
			}
			else	cout << eat[i]%100 << " ";
		}
	}
	
	/*
	int n,m,p,mc = 0,pc = 0,ra,rb,rc = 999999,rd = 999999;
	cin >> n >> m >> p;

	int D[10001] = {},disr[10001] = {},disl[10001] = {},pld[10001] = {};
	//disr...migi,disl...hidari
	



	for(int i=0; i<m; i++){
		int d;
		cin >> d;
		D[i] = d;
		disr[i] = (n+d-p)%n;
		disl[i] = n-disr[i];
	}

	sort(disr,disr+m);
	sort(disl,disl+m);
	ra = disr[m-1];
	rb = disl[m-1];
	//r
	for(int i=0; i<m; i++){
		rc = min(disl[i]*2+disr[m-i-2],rc);//[m-1-(i+1)])
		rd = min(disr[i]*2+disl[m-1-2],rd);
	}

	int ans = min(min(ra,rb),min(rc,rd));

	cout << ans*100 << endl;
	*/
	return 0;

}



Measured memory_bytes: 3156
def main():
    N,Y = map(int, input().split())
    # N枚でY円はありえるかどうか
    for x in range(min(Y//10000+1, N+1)):
        for y in range(min((Y-x)//5000+1, N+1)):
            z = (Y-10000*x-5000*y)//1000
            if (Y-10000*x-5000*y)%1000==0 and z>=0 and (x+y+z)==N:
                ans = [x,y,z]
                print(*ans)
                return
    ans = [-1,-1,-1]
    print(*ans)
main()


Measured memory_bytes: 3060
S = input()
ans = cond1 = cond2 = cond3 = cond4 = True
if S[0] != "A":
    cond1 = False
T = [S[i] for i in range(len(S)) if i>=2 and i<=len(S)-2]
U = [S[i] for i in range(len(S)) if i!=0]

count = 0
index = -1
for i in range(len(T)):
    if T[i] == "C":
        count+=1
        index = i
    else:
        if not T[i].islower():
            cond3 = False
cond2 = count == 1
for i in range(len(S)):
    if i==1 or i==len(S)-1:
        if not S[i].islower():
            cond4 = False
    

ans = cond1 and cond2 and cond3 and cond4
#print((cond1,cond2,cond3,cond4))
if ans:
    print("AC")
else:
    print("WA")

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

int main()
{
  int x, y;
  cin >> x >> y;

  if(x > y) cout << "a > b" << endl;
  else if(x < y) cout <<"a < b" << endl;
  else if(x == y) cout << "a == b" << endl;

  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const ll INF = (ll)1e9;
const int maxN = (int)1e6;

void solve() {
  int s, w;
  cin >> s >> w;
  if (w >= s) cout << "unsafe"; else cout << "safe";
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int E = 1'000'000;
int n, x[100], y[100], p[E + 1];
double TAU = atan2(0, -1) * 2;

void add(int l, int r) {
	if(l <  0) { add(E + l, E - 1); add(0, r    ); return; }
	if(r >= E) { add(    l, E - 1); add(0, r - E); return; }
	assert(inID(l, 0 ,E));
	assert(inID(r, 0 ,E));
	p[l]++;
	p[r]--;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i]; }
	
	inc(i, n) {
		inc(j, E) { p[j] = 0; }
		
		inc(j, n) {
			if(i == j) { continue; }
			
			int v = (atan2(y[j] - y[i], x[j] - x[i]) / TAU + 0.5) * E;
			add(v - E / 4, v + E / 4);
		}
		
		int s = 0;
		inc1(j, E) { p[j] += p[j - 1]; if(p[j] == 0) { s++; } }
		
		printf("%.8f\n", 1.0 * s / E);
	}
	
	return 0;
}


Measured memory_bytes: 4480
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<cmath>
using namespace std;
int main()
{
	int a, b;
	int t;
	scanf("%d %d", &a, &b);
	t = a + b;
	if(t >= 24)
		printf("%d\n", t - 24);
		else
			printf("%d\n", t);
			return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    ll ans = 1;
    rep(i, n) {
        if (__builtin_mul_overflow(ans, a[i], &ans)) {
            return puts("-1"), 0;
        }
    }
    if (ans > (ll)1e18) return puts("-1"), 0;
    cout << ans << endl;
}

Measured memory_bytes: 3988
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, k;
	cin >> n >> k;
	vi h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	vi dp(n);
	for (int i = 1; i < n; i++)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for (int j = 2; j <= k; j++)
		{
			if (i - j >= 0)
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			else
				break;
		}

	}
	cout << dp[n - 1];
	
	return 0;
}

Measured memory_bytes: 1024
// Code Forces
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define pi 3.1415926535
#define fi first
#define se second
#define vec vector
#define str string
#define FOR(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define dvec(v) vec < ll > v
#define sortA(v) sort(v.begin(),v.end())
#define sortD(v) sort(v.begin(),v.end(),greater <int> ())

using namespace std;

int main(){
    fast
    ll len=0,n=0;
    cin>>len>>n;
    dvec(v);
    set <ll> s;
    ll x=0;
    while(n--){
        cin>>x;
        s.insert(x);
    }
    v.assign(s.begin(),s.end());
    dvec(v1);
    for(x=0;x<v.size()-1;x++){
        v1.pb(v[x+1]-v[x]);
    }
    v1.pb(len+v[0]-v[v.size()-1]);
    sortD(v1);
    cout<<len-v1[0];
    // my code
    return 0;
}

Measured memory_bytes: 13428
cnt = {0 => 5}
gets
gets.split.each do |x|
	x = x.to_i
	cnt[x] += 1 if cnt[x]
	cnt[x] = 1 if !cnt[x]
end
cnt.delete_if{|k, v| v < 2}
ans = cnt.keys.sort
if cnt[ans[-1]] > 3
	p ans[-1]**2
	exit(0)
end
p ans[-1] * ans[-2]

Measured memory_bytes: 14212
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int arr[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> arr[i][j];
		}
	}
	int res[n][3];

	for(int i=0;i<3;i++){
		res[0][i] = arr[0][i];
	}
	for(int i=1;i<n;i++){
		res[i][0] = arr[i][0] + max(res[i-1][1],res[i-1][2]);
		res[i][1] = arr[i][1] + max(res[i-1][0],res[i-1][2]);
		res[i][2] = arr[i][2] + max(res[i-1][0],res[i-1][1]);
	}
	/*for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cout << res[i][j] << " ";
		}
		cout << "\n";
	}*/
	cout << max(max(res[n-1][0],res[n-1][1]),res[n-1][2]);
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  ll f[n][10], p[n][10];
  REP(i, n){
    REP(j, 10)
      cin >> f[i][j];
  }
  REP(i, n){
    REP(j, 11)
      cin >> p[i][j];
  }

  ll ans = -LLINF;
  for(ll bit = 1; bit < (1<<10); bit++){
    vll now(10, 0);
    ll profit = 0;
    REP(i, 10){
      if(bit & (1<<i))
        now[i] = 1;
    }

    REP(i, n){
      ll sameCount = 0;
      REP(j, 10){
        if(now[j] == 1 && f[i][j] == 1)
          sameCount++;
      }
      profit += p[i][sameCount];
    }
    ans = max(ans, profit);
  }

  cout << ans << endl;

  
  
}


Measured memory_bytes: 256
program prob3
    implicit none
    integer::i, j, N, M, p, ac, pe
    integer, allocatable::v(:), c(:)
    character(len=2)::S
    read(*,*) N, M
    allocate(v(N), c(N))
    v = 0
    c = 0
    ac = 0
    pe = 0

    do i = 1, M
        read(*,*) p, S
        if(S .eq. "WA" .and. c(p) == 0) then
            v(p) = v(p) + 1
        else if(S .eq. "AC" .and. c(p) == 0) then
            ac = ac + 1
            pe = pe + v(p)
            c(p) = 1
        end if
    end do
    write(*,*) ac, pe
    deallocate(v, c)
    stop
end program

Measured memory_bytes: 3252
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n, m, x, y, mer;
  char dim;
  cin >> n;
  vector<int> ans;
  while(n){
    vector< vector<int> > gem(21, vector<int>(21));
    for(int i = 0; i < n; i++){
      cin >> x >> y;
      gem[y][x] = 1;
    }
    cin >> m;
    int nowx = 10;
    int nowy = 10;
    for(int j = 0; j < m; j++){
      cin >> dim >> mer;
      for(int k = 1; k <= mer; k++){
        if(dim == 'N') nowy++;
        if(dim == 'E') nowx++;
        if(dim == 'S') nowy--;
        if(dim == 'W') nowx--;
        gem[nowy][nowx] = 0;
      }
    }
    int boo = 0;
    for(int i = 0; i <= 20; i++){
      for(int j = 0; j <= 20; j++){
        if(gem[i][j])boo = 1;
      }
    }
    ans.push_back(boo);
    cin >> n;
  }
  for(int i = 0; i < (int)ans.size(); i++){
    if(!ans[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 10000000000;

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

using namespace std;

//fixed << setprecision(10)

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

vector<ll>h(100010);

vector<ll>dp(100010);

int main() {
	int n, k;
	cin >> n >> k;
	rep(i, n)cin >> h[i];

	rep(i, 100010)dp[i] = INF;

	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
   
using namespace std;
   
string str[2];
int s, n, t, m, lt, rt, t_w, t_t;
long double p;
   
int conv(string s){
  string data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};  
  for(int i=0;i<7;i++) if(s == data[i]) return i;
  if(s == "All") return -1;
}
   
int check(int s_w, int s_t){
  int cnt = 0;
  for(int k=0;k<m;k++){
    int f_w = s_w;
    int f_t = s_t + s;
    if(f_t >= 24 * 60){
      f_t -= 24 * 60;
      f_w = (f_w + 1) % 7;
    }
    bool f = false;
    if(t_w == -1 || (t_w == s_w && t_w == f_w)){
      if(t_t == 0){
        if(0 <= s_t && s_t < 24 * 60 && 0 <= f_t && f_t < 24 * 60) f = true;
      }
      if(t_t == 1){
        if(6 * 60 <= s_t && s_t < 18 * 60 && 6 * 60 <= f_t && f_t < 18 * 60) f = true;
      }
      if(t_t == 2){
        if(((18 * 60 <= s_t && s_t < 24 * 60) || (0 <= s_t && s_t < 6 * 60))
           && ((18 * 60 <= f_t && f_t < 24 * 60) || (0 <= f_t && f_t < 6 * 60))) f = true;
      }
    }
    if(f) cnt++;
    s_t += t;
    if(s_t >= 24 * 60){
      s_t -= 24 * 60;
      s_w = (s_w + 1) % 7;
    }
  }
  return cnt;
}
   
main(){
  while(cin >> s >> n >> t >> str[0] >> str[1] >> p >> m && (s|n|t|m) && str[0] != "None" && str[1] != "None"){
    t_w = conv(str[0]);
    if(str[1] == "All") t_t = 0;
    if(str[1] == "Day") t_t = 1;
    if(str[1] == "Night") t_t = 2;
    long double ans = 0.0;
    for(int i=0;i<7;i++){
      for(int j=0;j<24*60;j++){
        int cnt = check(i, j);
        ans = max(ans, 1.0 - pow((p - 1.0) / p, n * cnt));
      }
    }
    cout << setiosflags(ios::fixed) << setprecision(10) << ans << endl;
  }
}

Measured memory_bytes: 1320
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

#define int long long

signed main()
{
    int N, K;
    cin >> N >> K;
    int denominator = N * (1 << 25);
    int numerator = 0;
    for (int i = 1; i <= N; i++)
    {
        int n_coin = 0;
        while (i * (1 << n_coin) >= 1 && i * (1 << n_coin) < K)
        {
            n_coin++;
        }
        numerator += (1 << (25 - n_coin));
    }

    printf("%.10f\n", (double)numerator / denominator);
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	bool b=false;
	cin>>s;
	for(char i='a';i<='z';i++)
	{
		for(int j=0;j<s.length();j++)
		{
			if(s[j]==i)
			b=true;
		}
		if(!b)
		{
			cout<<i;
			return 0;
		}
		b=false;
	}
	cout<<"None";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int l, r, d; cin >> l >> r >> d;
    int a = (l - 1) / d;
    int b = r / d;
    cout << b - a << endl;
}

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

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL X, A, B;

int main()
{
	in >> X >> A >> B;
	if (B <= X) { out << "delicious" << std::endl; }
	else if (B <= A + X) { out << "safe" << std::endl; }
	else { out << "dangerous" << std::endl; }
	return 0;
}

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

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

    ll ans = 0;
    for (int i = 1; i * i <= n; i++) ans = i * i;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define take_input freopen("input.txt", "r", stdin)
#define ll long long int 
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
#define mod 1000000007

// ll power(ll x, ll n){
// 	ll res = 1;
// 	while(n){
// 		if(n%2) res = ((res%mod)*(x%mod))%mod;
// 		x = ((x%mod)*(x%mod))%mod;
// 		n /= 2;
// 	}
// 	return res%mod;
// }

// int main(){
// 	ll n;
// 	cin >> n;
// 	ll res = (power(10, n)-2*power(9, n)+power(8,n))%mod;
// 	cout << res << "\n";
// }
	
int main(){
	string s;
	cin >> s;
	if((char)s[s.length()-1] == 's'){
		s.append("es");
	}else{
		s.append("s");
			}
	cout << s << "\n";
}

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

const int N=300+15;
const int inf=1e9+7;
int n,m,ans;
int a[N][N],vis[N],num[N];
inline int read()
{
	char ch=getchar();
	int s=0,f=1;
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {s=(s<<3)+(s<<1)+ch-'0';ch=getchar();}
	return s*f;
}
int main()
{
	n=read();m=read();
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			a[i][j]=read();
	ans=inf;
	for (int i=1;i<=m;i++)
	{
		memset(num,0,sizeof(num));
		for (int j=1;j<=n;j++)
			for (int k=1;k<=m;k++)
				if (!vis[a[j][k]])
				{
					num[a[j][k]]++;
					break;
				}
		int s,tans=0;
		for (int j=1;j<=m;j++)
		{
			if (tans<num[j])
			{
				s=j;
				tans=num[j];
			}
		}
		vis[s]=1;
		ans=min(ans,tans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let mut a: Vec<i64> = vec![];

    for i in 1..10 {
        for j in 1..10 {
            a.push(i * j);
        }
    }
    let b: i64 = read();

    if a.contains(&b) {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e12 + 10;;
int n;
ll a, b, c;
ll ans = INF;
typedef long long ll;
void check(ll x)
{
	if(x > 0 && (c ^ x) + x == b)
		ans = min(ans, a - x);
}
void dfs(ll b, ll x, int n)
{
	if(x > a || b < 0) return;
	if(n == 40)
	{
		check(x);
		return;
	}
	int bn = (b >> n) & 1;
	int cn = (c >> n) & 1;
	if(bn != cn) return;
	if(bn)	
	{
		dfs(b, x | (1ll << n), n + 1);
		dfs(b, x, n + 1);
	}
	else
	{
		dfs(b - (1ll << (n + 1)), x | (1ll << n), n + 1);
		dfs(b, x, n + 1);
	}
} 
int main()
{
	cin >> n >> a >> b;
	b += a;
	for(int i = 3; i <= n; ++i)
	{
		 ll val;
		 cin >> val;
		 c ^= val;
	}
	dfs(b, 0, 0);
	if(ans == INF) puts("-1");
	else cout << ans << endl;
	return 0;
}

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

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

  int n; cin >> n;
  ll cnt[5] = {};
  rep(i, n) {
    string s; cin >> s;
    if(s[0] == 'M') cnt[0]++;
    if(s[0] == 'A') cnt[1]++;
    if(s[0] == 'R') cnt[2]++;
    if(s[0] == 'C') cnt[3]++;
    if(s[0] == 'H') cnt[4]++;
  }

  ll ans = 0;
  rep(i, 5) {
    for(int j = i+1; j < 5; j++) {
      for(int k = j+1; k < 5; k++) {
        ans += cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
pos_x_list = []
pos_y_list = []

for i in range(N):
    x, y = map(int, input().split())
    pos_x_list.append(x - y)
    pos_y_list.append(x + y)

print(max(max(pos_x_list) - min(pos_x_list), max(pos_y_list) - min(pos_y_list)))

Measured memory_bytes: 24960
#include <stdio.h>
#include <math.h>
int main(void)
{
  int s[1000], n,i;
  double m, alpha, x;

  while(scanf("%d", &n), n!=0) {
    alpha=0;m=0;
    for(i=0;i<n;i++) {
      scanf("%d", &s[i]);
      m +=s[i];
    }
    m = m/n;
    for(i=0;i<n;i++) {
      x = s[i]-m;
      alpha += x*x;
    }
    printf("%lf\n", sqrt(alpha/n));
  }


  return 0;
}

Measured memory_bytes: 2680
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

vector<ll> total;
vector<vector<int>> g;
vector<ll> pending;

void dfs(int u, int p, ll curr){
    curr+=pending[u];
    total[u] = curr;
    for(int v : g[u]){
        if(v==p) continue;
        dfs(v,u,curr);
    }
}

int main(){
    Shazam;
    int n,q; cin>>n>>q;
    g.resize(n);
    total.resize(n);
    pending.resize(n);
    for(int i = 0 ; i < n-1; i++){
        int a,b; cin>>a>>b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 0; i < q; i++){
        ll p,x; cin>>p>>x;
        pending[p-1] +=x;
    }
    dfs(0,-1,0);
    pra(total);

    return 0;
}

Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    V p(n), q(n);
    rep(i,0,n) cin >> p[i];
    rep(i,0,n) cin >> q[i];
    V a(n);
    rep(i,0,n) a[i]=i+1;
    map<vector<int>,int> mp;

    do {
        mp[a]=mp.size();
    } while(next_permutation(a.begin(),a.end()));
    
    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
}

Measured memory_bytes: 5248
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

// value


void solve() {

    int a, b;
    cin >> a >> b;

    int ans = 0;
    ans += max(a,b);
    if (a==b)a--;
    else a--,b--;
    ans+=max(a,b);

    out(ans);

	return;

}

int main() {

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

	solve();

	return 0;

}

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

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

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll en = 1000;
    ll vol = 0;
    rep(i,n-1) {
        if (a[i]<a[i+1]) {
            ll buy = en / a[i];
            en -= buy * a[i];
            vol += buy;
        } 
        else if (a[i]>a[i+1]) {
            en += (vol*a[i]);
            vol = 0;
        }
    }
    ll ans = en + vol * a[n-1];
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	map<int,int> dp;
	dp[0] = 1;
	int cnt = 0;
	ll res = 0;
	for(int i = 0; i < n; i++){
		int t;cin>>t;
		cnt+=t;
		cnt%=m;
		res+=dp[cnt]++;
	}
	cout<<res;
}




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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x = new long[n];
		long[] y = new long[n];
		long[] z = new long[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
			z[i] = sc.nextLong();
		}
		long[][] sum = new long[8][n];
		for(int i = 0; i < n; i++) {
			sum[0][i] += x[i] + y[i] + z[i];
			sum[1][i] += x[i] + y[i] - z[i];
			sum[2][i] += x[i] - y[i] + z[i];
			sum[3][i] += -x[i] + y[i] + z[i];
			sum[4][i] += -x[i] - y[i] + z[i];
			sum[5][i] += -x[i] + y[i] - z[i];
			sum[6][i] += x[i] - y[i] - z[i];
			sum[7][i] += -x[i] - y[i] - z[i];
		}
		long[] result = new long[8];
		for(int i = 0; i < 8; i++) {
			Arrays.sort(sum[i]);
			for(int j = n - 1; j >= n - m; j--) result[i] += sum[i][j];
		}
		Arrays.sort(result);
		System.out.println(result[7]);
	}

	static void dfs() {

	}

}


Measured memory_bytes: 25824
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length()-1; i++) {
        if (s[i] == 'S'&&s[i+1]=='T') {
            s.erase(i, 2);
            if (i > 0) {
                i = i - 2;
            }
            else {
                i = i - 1;
            }
        }
        if (s.empty()) {
            break;
        }


    }
    if (s.empty()) {
        cout << 0 << endl;
    }
    else {
        cout << s.size() << endl;
    }
 
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int ans = 1;
		
		if (a != b)
			ans++;
		if (b != c && c != a)
			ans++;
		
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 22224