akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = (int)1e5 + 10;
// make sure N size is correctttt!!!!!!!!!

int n, a[N], down[N], up[N], pref[N], suff[N], mod;
std::vector<int> v[N];

void dfs(int s, int p){
   down[s] = 1;
   if(p != -1){
      v[s].erase(find(v[s].begin(), v[s].end(), p));
   }
   for(auto i: v[s]){
      dfs(i, s);
      down[s] = (down[s] * (1 + down[i])) % mod;
   }
}

void dfs0(int s){
   pref[0] = 1;//indexing has been done from 1-n rather than usual
   for (int i = 0; i < sz(v[s]); ++i)
   {
      pref[i+1] = pref[i] * (1 + down[v[s][i]]) % mod;
   }

   suff[sz(v[s])+1] = 1;
   for (int i = sz(v[s])-1; i >= 0; --i)
   {
      int ptr = i+1;
      suff[ptr] = (suff[ptr+1] * (1 + down[v[s][i]])) % mod; 
   }

   for (int i = 0; i < sz(v[s]); ++i)
   {
      int ver = v[s][i];
      int pre2 = (pref[i+1-1] * suff[i+1+1]) % mod;
      up[ver] = (1 + (up[s]*pre2)%mod)%mod;
      if(up[ver] >= mod)up[ver] -= mod;
   }

   for(auto i: v[s]){
      dfs0(i);
   }

}

int32_t main(){_

   int n;
   cin>>n>>mod;

   for (int i = 0; i < n-1; ++i)
   {
      int x, y;
      cin>>x>>y;
      v[x].pb(y);
      v[y].pb(x);
   }

   dfs(1,-1);
   up[1] = 1;
   dfs0(1);

   for (int i = 1; i <= n; ++i)
   {
      cout<<up[i]*down[i]%mod<<'\n';
   }

   //make sure N size is correct!!!!!!!!!
   return 0;
}

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    int n = S.size();
    rep(i, n) {
        ll c = 0;
        while (i < n && S[i] == '<') {
            c++;
            i++;
        }
        ans += c * (c - 1) / 2;
        //cout << c << " " << ans << "\n";
        ll d = 0;
        while (i < n && S[i] == '>') {
            d++;
            i++;
        }
        ans += max(c, d) + d * (d - 1) / 2;
        //cout << d << " " << ans << "\n";
        i--;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 900
#include<stdio.h>
int main(void) {
	int b1 = 0, b2 = 0, b3 = 0;
	scanf("%d %d %d", &b1, &b2, &b3);
	switch (b1) {
	case 0:
		switch (b2) {
		case 0:
			switch (b3) {
			case 0:
				printf("Close\n");
				break;
			case 1:
				printf("Open\n");
				break;
			}
			break;
		case 1:
			switch (b3) {
			case 0:
				printf("Close\n");
				break;
			case 1:
				printf("Open\n");
				break;
			}
			break;
		}
		break;
	case 1:
		switch (b2) {
		case 0:
			switch (b3) {
			case 0:
				printf("Close\n");
				break;
			case 1:
				printf("Open\n");
				break;
			}
			break;
		case 1:
			switch (b3) {
			case 0:
				printf("Open\n");
				break;
			case 1:
				printf("Open\n");
				break;
			}
			break;
		}
		break;
	}
	return 0;
}


Measured memory_bytes: 2048
INF = float("inf") #const
MOD = 10**9+7 #const
MAX = 510000 #const

def main():
    n = int(input())
    h = [list(map(int,input().split())) for i in range(n)]
    dp = [[0]*3 for i in range(n+1)]

    for i in range(n):
        for j in range(3):
            for k in range(3):
                if j!=k:
                    dp[i+1][k] = max(dp[i+1][k],dp[i][j]+h[i][k])

    ans = 0
    for i in range(3):
        ans = max(ans,dp[n][i])
    print(ans)


if __name__ == "__main__":
    main()


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

int main(void){
    int n;
    cin>>n;
    string s;
    vector<int> r(4,0);
    rep(i,n){
        cin>>s;
        if(s=="AC")r[0]++;
        else if(s=="WA")r[1]++;
        else if(s=="TLE")r[2]++;
        else r[3]++;
    }
    cout<<"AC x "<<r[0]<<endl;
    cout<<"WA x "<<r[1]<<endl;
    cout<<"TLE x "<<r[2]<<endl;
    cout<<"RE x "<<r[3]<<endl;
}

Measured memory_bytes: 3656
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+b*max(0,y-i)
    p.append(cash)

print(min(p))


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

int main(void) {
  string S;
  cin >> S;
  bool flag=false;
  
  for(int i=1; i<4; i++){
    if(S[i-1]==S[i]){
      flag=true;
      break;
    }
  }
  
  if(flag==true) cout << "Bad" << endl;
  else cout << "Good" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200100)

def abc157_d():
    N, M, K = map(int, input().split())
    fr = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        fr[a].add(b)
        fr[b].add(a)
    bl = []
    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        bl.append((c,d))

    def dfs(nd, lb):
        nonlocal label, gr
        label[nd] = lb
        gr[lb] += 1
        for ch in fr[nd]:
            if label[ch] != -1: continue
            dfs(ch, lb)

    ans = [0] * N
    label = [-1] * N
    lb = 0
    gr = []
    for i in range(N):
        if label[i] != -1:
            ans[i] = gr[label[i]]
            continue
        gr.append(0)
        dfs(i, lb)
        ans[i] = gr[label[i]]
        lb += 1

    for c, d in bl:
        if label[c] == label[d]:
            ans[c] -= 1
            ans[d] -= 1

    for i in range(N):
        ans[i] -= len(fr[i]) + 1

    print(*ans, sep=' ')

abc157_d()

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

void solve(){
	int n, k; cin >> n >> k;
	vector<int> h(n, 0);
	vector<int> dp(n, 1e9+5);
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	dp[0] = 0;
	for(int i = 0; i < k; i++){
		for(int j = 0; j < i; j++){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	for(int i = k; i < n; i++){
		for(int j = i - k; j < i; j++){
			dp[i] = min(dp[i], dp[j] + abs(h[i]- h[j]));
		}
	}
	cout << dp[n-1] << endl;
}
int main(){
	//int t; cin >> t; 
	//while(t--){
		solve();
	//}
}


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

using namespace std;
#define int long long
#define endl '\n'



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k; cin >> n >> k;
    vector<int> a;
    vector<pair<int, int>> aa;
    vector<int> b, c;
    bool fl = false;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x == 0) {fl = true; continue;}
        a.push_back(x);
        aa.push_back(make_pair(abs(x), a.size() - 1));
        if (x > 0) b.push_back(x);
        else c.push_back(-x);
    }
    sort(aa.rbegin(), aa.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    n = a.size();
    if (n < k) {
        cout << 0 << endl;
        return 0;
    }
    int mr = 0, ls = 0;
    for (int i = 0; i < k; i++) {
        if (a[aa[i].second] > 0) mr++;
        else ls++;
    }
    int mod = 1e9 + 7;
    if (ls % 2 == 0) {
        int ans = 1;
        for (int i = 0; i < k; i++) {
            ans *= aa[i].first;
            ans %= mod;
        }
        cout << ans << endl;
        return 0;
    }
    if (n == k || b.size() == 0) {
        if (fl) cout << 0 << endl;
        else {
            int ans = 1;
            for (int i = 0; i < k; i++) {
                ans *= aa[n - i - 1].first;
                ans %= mod;
            }
            ans = (mod - ans) % mod;
            cout << ans << endl;
        }
        return 0;
    }
    int mx1 = -1, mx2 = -1;
    int dl1 = -1, dl2 = -1;
    // assert(0);
    if (ls < c.size() && mr > 0) {
        mx1 = c[ls];
        dl1 = b[mr - 1];
    }
    if (mr < b.size() && ls > 0) {
        mx2 = b[mr];
        dl2 = c[ls - 1];
    }
    int mx = -1, del = -1;
    if (mx1 == -1) {mx = mx2, del = dl2;}
    if (mx2 == -1) {mx = mx1, del = dl1;}
    // assert(!(mx1 == -1 && mx2 == -1));
    if (mx1 != -1 && mx2 != -1) {
        if (mx1 * dl2 > mx2 * dl1) {mx = mx1; del = dl1;}
        else {mx = mx2; del = dl2;}
    }
    int ans = mx;
    for (int i = 0; i < k; i++) {
        if (aa[i].first == del) {
            del = -1;
            continue;
        }
        ans *= aa[i].first;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11532
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n,k;
    std::cin >> n>>k;
    ll res = k;
    
    for (int i = 1; i < n; i++) {
        res *= k-1;
    }
    std::cout << res << std::endl;
}

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

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

  vector<ll> x(n+1, 0);
  for(ll i = 1; i <= n; i++){
    cin >> x[i];
  }

  ll mint = INFTY;
  for(ll l = 1; l <= n - k + 1; l++){
    ll r = l + k -1;
    mint = min(x[r] - x[l] + min(llabs(x[r]), llabs(x[l])), mint);
  }

  cout << mint << endl;

  return 0;

}

Measured memory_bytes: 1024
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function lineIn(){
		$buf = fgets(STDIN);
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->lineIn();
	
		$ans = 0;
		$buf = array();

		for($i = 0; $i < $s; $i++){
			$buf[] = $this->lineIn();
		}
		
		$unique = array_unique($buf);

		if(sizeof($unique) != sizeof($buf)){
			echo "No\n";
		}else{
			$t = "";
			$b = $buf[0][0];
			foreach($buf as $k => $v){
				$t = $v[0];
				if($b != $t){
					echo "No\n";
					return false;
				}
				$b = $v[(strlen($v) - 1)];
			}
			unset($k);
			unset($v);

			echo "Yes\n";
			return true;
		}
	}
}
?>

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n,k;
    cin>>n>>k;
    if(k==1)cout<<0<<endl;
    else{
        n-=k;
        cout<<n+1-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
w = list(map(int, input().split()))
# 累積和
a2=[0]
for i in w:a2.append(a2[-1]+i)
def SumArea(l, r):
    return a2[l]-a2[r]

minnum = 10**9+7

for i in range(n+1):
    tmp = abs(SumArea(i, n) - SumArea(0, i))
    if tmp < minnum:
        minnum = tmp
    
print(minnum)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    int K,S; cin >> K >> S;
    int cnt = 0;
    rep(i,K+1) rep(j,K+1) if(0<= S-i-j and S-i-j <= K) cnt++;
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;

ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {
    ll m, k;
    cin >> m >> k;

    if (pow2(2, m) <= k) {
        cout << -1 << endl;
        return 0;
    }

    if (m == 0) {
        if (k == 0) {
            cout << "0 0" << endl;
            return 0;
        } else {
            cout << "-1" << endl;
            return 0;
        }
    }

    if (m == 1) {
        if (k == 1) {
            cout << "-1" << endl;
            return 0;
        } else {
            cout << "0 0 1 1" << endl;
            return 0;
        }
    };

    ll c = pow2(2, m);

    vector<ll> ans;
    for (ll i = 0; i < c; i++) {
        if (i == k) continue;
        ans.push_back(i);
    }
    vector<ll> ans2 = ans;
    reverse(ans2.begin(), ans2.end());
    ans.push_back(k);
    ans.insert(ans.end(), ans2.begin(), ans2.end());
    ans.push_back(k);


//    ans.push_back(k);
//    for (ll i = 0; i < c - 1; i++) {
//        ll a = c - 1 - i;
//        ans.push_back(a);
//    }
//    ans.push_back(k);



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

}



Measured memory_bytes: 4976
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

vector<ll> X;
int main()
{
	ll N, P;
	cin >> N >> P;
	ll tmp = P;
	for (ll i = 2; i * i <= P; i++) {
		while (tmp % i == 0) {
			X.push_back(i);
			tmp /= i;
		}
	}
	X.push_back(tmp);
	ll ans = 1;
	ll cnt = 1;
	for (int i = 1; i < X.size(); i++) {
		if (X[i] == X[i - 1]) {
			cnt++;
		}
		else {
			cnt /= N;
			for (int j = 0; j < cnt; j++) {
				ans *= X[i - 1];
			}
			cnt = 1;
		}
	}
	cnt /= N;
	for (int i = 0; i < cnt; i++) {
		ans *= X.back();
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
int n;
long long a[maxn], b[maxn], x, ans, mi;

int main()
{
	ans = 0x7fffffffffffffffll;
	scanf("%d%lld", &n, &x);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	memset(b, 0x3f, sizeof b);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			b[j] = min(b[j], a[(j - i + n) % n]);
		long long tans = 0;
		for (int j = 0; j < n; j++)
			tans += b[j];
		ans = min(ans, tans + i * x);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    vector<ll> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;
    cout << vec[k - 1];
    
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b;
if(b==100)
for(int i=0;i<a*1000+b;i++)
if(i*i==a*1000+b)
{
cout << "Yes" << endl;
return 0;
}
if(b>=10)
for(int i=0;i<a*100+b;i++)
if(i*i==a*100+b)
{
cout << "Yes" << endl;
return 0;
}
if(b<10)
for(int i=0;i<a*10+b;i++)
if(i*i==a*10+b)
{
cout << "Yes" << endl;
return 0;
}
cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    string s;
    cin >> s;
    ll n = sz(s);
    string t = s.substr(0,n/2);
    string u;
    repe(i,n/2 + 1,n){
        u += s[i];
    }
    string v = t;
    reverse(all(v));
    string w = u;
    reverse(all(w));
    string z = s;
    reverse(all(z));
    if(t == v and u == w and s == z){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 256
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    int n ;cin >> n ;
    string s ; map<string,int>m ;
    For(i,n){
        cin >> s ;
        m[s]++ ;
    }
    cout << m.size() << endl ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int>x(n),b(200009);
    for(int i = 0; i < 200009; i++){
        b[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> x[i];
        b[x[i]]++;
    }
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    if(b[k] == 0){
        printf("0\n");
        return 0;
    }
    int ans = 0;
    for(int i = k; ; i++){
        ans = ans + b[i];
        if(b[i] == 0){
            cout << ans << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 4844
#include <stdio.h>

int main(void)
{
	int x, i, n, min, max;
	double sum = 0;
	
	scanf("%d", &x);
	for(i = 0; i < x; i++){
		scanf("%d", &n);
		if(i == 0){
			min = max = n;
		} else{
			if(min > n){
				min = n;
			}
			if(max < n){
				max = n;
			}
		}
		sum += n;
	}
	printf("%d %d %.0lf\n", min, max, sum);
	
	return(0);
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];
    
    bool f = true;
    REP(i,0,N) {
        if(A[i] % 2 == 1) {
            f = false;
            break;
        }
    }
    if(f) PR("second");
    else PR("first");

    return 0;
}

/*



*/

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=a[i]-a[i-1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

struct Trie {
	Trie* next[26];
	int cnt[26];
	Trie() {
		fill_n(next, 26, (Trie *)NULL);
		fill_n(cnt, 26, 0);
	}
};

int main(int argc, char *argv[]) {
	vector<Trie> pool(1000002);
	LL n, ans = 0, pi = 0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		int len = s[i].length();
		vector<int> cf(len + 1);
		for (int j = 0; j < len; ++j) {
			cf[j + 1] = cf[j] | (1 << (s[i][j] - 'a'));
		}
		Trie* node = &(pool[0]);
		for (int j = len - 1; j >= 0; --j) {
			for (int k = 0; k < 26; ++k) {
				if (cf[j + 1] & (1 << k)) {
					node->cnt[k] += 1;
				}
			}
			char c = s[i][j] - 'a';
			if (node->next[c] == NULL) {
				node->next[c] = &(pool[++pi]);
			}
			node = node->next[c];
		}
	}
	for (int i = 0; i < n; ++i) {
		Trie* node = &(pool[0]);
		for (int j = s[i].length() - 1; j > 0; --j) {
			node = node->next[s[i][j] - 'a'];
		}
		ans += node->cnt[s[i][0] - 'a'] - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 314052
#include<stdio.h>
#include<stdlib.h>
//#include<string.h>
int main(void){

	int n,time;
	scanf("%d",&n);
	scanf("%d",&time);
	int i,j;
	int p[n];
	char moji[n][50];
	for(i=0; i<n; i++){
		scanf("%s %d",moji[i],&p[i]);
		//printf("入力した文字は%s\n",moji[i]);
	}
	
	int queuenum=0;
//	int queue[1000];
	
	int sec=0;
	int nokori=n;
	while(nokori>0){
		if(queuenum==n){
			queuenum=0;
		}
		if(p[queuenum]==0){
			queuenum++;
			continue;
		}
		if(p[queuenum]-time>0){
			p[queuenum]-=time;
			//printf("処理%s %d\n",moji[queuenum], p[queuenum]);
			sec+=time;
			queuenum++;
			//nokori++;
		
		}else{
			printf("%s %d\n",moji[queuenum],p[queuenum]+sec);
			sec+=p[queuenum];
			p[queuenum]=0;
			queuenum++;
			nokori--;
		}
	}
	return 0;
}


Measured memory_bytes: 4352
'use strict'

const main = (input) => {
    const X = parseInt(input)
    let ans = 1
    for(let b = 1; b <= X; b++){
        for(let p = 2; p <= X; p++){
            let pow = Math.pow(b, p)
            if(pow > X) break
            if(pow > ans){
                ans = pow
            }
        }
    }
    console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <cstdio>
#include <algorithm>
using namespace std;

int pi[233];

bool bj(int a,int b)
{
	return a>b;
}

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&pi[i]);
		pi[0]+=pi[i];
	}
	sort(pi+1,pi+1+n,bj);
	bool flag=true;
	for(int i=1; i<=m; i++) if(pi[i]*4*m<pi[0])
	{
		flag=false; break;
	}
	if(flag) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
/*____________________________Definitions__________________________*/
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
#define Rep(i, a, b) for (int i=a; i<(b); i++)
#define trav(a,x) for(auto& a : x)
#define nl '\n'
#define ri(n) int n; scanf("%d", &n);
#define rll(n) ll n; scanf("%lld", &n);
/*__________________________________________________________________*/


int main() {

	fastIO
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T = 1;
	while (T--) {
		/*_____________________Code Here____________________________*/

		string s ; cin >> s;
		long long int SUM = 0;
		int l = s.length();
		for (int i = 0 ; i < l; i++) {
			SUM += (s[i] - '0');
		}
		if (SUM % 9 > 0 ) {
			cout << "No" << endl;
		}
		else { cout << "Yes" << endl;}
		/*_____________________End Here____________________________*/
	}
	return 0;
}



Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

string res;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string alpabet = "abcdefghijklmnopqrstuvwxyz";
    string S;
    cin >> S;
    res = "None";
    for (int i = 0; i < 26; i++)
    {
        bool flag = true;
        for (int j = 0; j < S.length(); j++)
        {
            if(alpabet[i]==S[j]){
                flag = false;
            }
        }
        if(flag){
            res = alpabet[i];
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int N,K;
int dp[5000];
int a[5000];

bool solve(int pass){
  if(a[pass]>=K)return false;
  REP(i,K)dp[i]=0;
  dp[0]=1;
  REP(i,N){
    if(i==pass)continue;
    for(int j=K-1;j>=0;j--){
      if(dp[j]==0)continue;
      if(j+a[i]>K)continue;
      dp[j+a[i]]=1;
    }
  }
  FOR(i,K-a[pass],K)if(dp[i]==1)return false;
  return true;

}
int main(){
  cin>>N>>K;
  REP(i,N)cin>>a[i];
  sort(a,a+N);
  if(!solve(0)){
    cout<<0<<endl;
    return 0;
  }
  int l=0;
  int r=N;
  while(r-l>1){
    if(solve((l+r)/2))l=(l+r)/2;
    else r=(l+r)/2;
  }
  // int ans=0;
  // REP(i,N){
  //   if(solve(i))ans++;
  // }
  cout<<r<<endl;
  return 0;
}


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

int main(){
	ll h,w,k;
	char c[10][10];
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)cin>>c[i][j];
	}
	ll ans=0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			bool f[10][10]={};
			for(int l=0;l<h;l++){
				if(i&1<<l)for(int m=0;m<w;m++)f[l][m]=1;
			}
			for(int l=0;l<w;l++){
				if(j&1<<l)for(int m=0;m<h;m++)f[m][l]=1;
			}
			ll cnt=0;
			for(int l=0;l<h;l++)for(int m=0;m<w;m++)if(!f[l][m]&&c[l][m]=='#')cnt++;
			if(cnt==k)ans++;
		}
	}
	cout<<ans;
	return 0;
}


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

int main(){
int N; int M; int P[12]; //Pの最大数より多く
  vector<int> X[12]; //Xの最大数より多く
  cin >> N >> M;
  //Nスイッチの数(max)M電球の数

  for(int i=0; i<M; i++){
    int v,a;
    cin >> v; //つながっているスイッチの数
    for (int j=0; j<v; j++){
      cin >> a; //スイッチの番号(1-N)
      a--; //0番から始めているので1つ戻す
      X[i].push_back(a); //X[i]のお尻にひとつづつ数を加える
    }
  }

    for(int i=0; i<M; i++){
      cin >> P[i];
    }  //P[i]:M個の電球のi番目との接続が偶奇数か


    int count =0;
    for(int i=0; i <(1<<N);i++){
      int bit[12];
      for(int j=0; j < N; j++){
        bit[j]=(i/(1<<j)) % 2 ;  //bit[3]=110000000のように変換してくれる
        //j=1,2,4,8で割っていった余り
      }
        int ans =0;
        for(int j=0;j<M;j++){
          int ret=0;
          //for(int l=0;l<X[j].size(); l++){ //X[j]はスイッチの番号
          for(int l:X[j]){
            ret ^= bit[l];  //^=はXOR演算子
            //retの初期値0だからbit[l]が0なら0を、1なら1を返す
          }
          if(ret !=P[j]){   //もし違うものがあればansを0から変更してしまう
            ans++;
          }
        }
        if(ans==0){
          count++;
        }
      }


        cout << count << endl;
      }

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

ll mod = 1e9+7;
const ld error = 1e-5;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18;
const int nmax = 1e6+10;
///===========================================  template  =======================================================

int main(){
    FASTIO;
    ll inv2 = (mod + 1)/2;

    int n, q;
    cin>>n>>q;
    vector<int> input(n+1);
    for(int i= 1; i <=n; i++) cin>>input[i];
    vector<vector<ll> > memo(n+1, vector<ll>(n+1)), prob;

    for(int i = 1; i<=n; i++)
        for(int j = 1; j<=n; j++)
            if(i != j) memo[i][j] = input[i] > input[j];

    ll cnt = 1;
    for(int i = 0; i<q; i++){
        cnt = 2*cnt % mod;
        int x, y;
        cin>>x>>y;
        for(int j = 1; j<=n; j++){
            if(j == x || j == y) continue;
            memo[j][x] = memo[j][y] = (memo[j][x] + memo[j][y]) * inv2 % mod;
            memo[x][j] = memo[y][j] = (memo[x][j] + memo[y][j]) * inv2 % mod;
        }

        memo[x][y] = memo[y][x] = (memo[x][y] + memo[y][x]) * inv2 % mod;
    }

    ll ans = 0;
    for(int i = 1; i<=n; i++)
        for(int j = i+1; j<=n; j++)
            ans = (ans + memo[i][j]) % mod;

    ans = ans*cnt % mod;

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 72704
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B;
    cin >> A >> B;
    int big = max({ A + B, A - B, A * B });
    cout << big << endl;
}

Measured memory_bytes: 3528
#include<cstdio>
#include<set>

using namespace std;

int d, c[100], s[400][100];
int sat;
int m, t[400];
set<int> app[100];

int last(int d, int i) {
  return *(--app[i].upper_bound(d));
}

int next(int d, int i) {
  return *app[i].upper_bound(d);
}

int main() {
  scanf("%d", &d);
  for (int i = 1; i <= 26; i++) {
    scanf("%d", &c[i]);
    app[i].insert(0);
    app[i].insert(d+1);
  }
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= 26; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 1; i <= d; i++) {
    scanf("%d", &t[i]);
    sat += s[i][t[i]];
    app[t[i]].insert(i);
    for (int j = 1; j <= 26; j++) {
      sat -= c[j] * (i - last(i, j));
    }
    printf("%d\n", sat);
  }
}


Measured memory_bytes: 3492
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll n, k;
	cin >> n >> k;
	vector<double> ps(n);
	rep(i, n) {
		ll a;
		cin >> a;
		ps[i] = a * (a + 1) / 2.0 / (double)a;
	}
	vector<double> sums(n + 1,0);
	rep(i, n) {
		sums[i + 1] = sums[i] + ps[i];
	}
	double m = 0;
	for (int i = k; i <= n;i++) {
		double s = sums[i] - sums[i-k];
		m = max(m, s);
	}
	cout << fixed << setprecision(10);
	cout << m << endl;
	return 0;
}


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

int main(){
  int n;
  float ans=0;
  
  scanf("%d",&n);
  int a[n];
for(int i=0;i<n;i++){
  scanf("%d",&a[i]);
}    
for(int i=0;i<n;i++){
  ans=ans+1.0/a[i];
}    
ans=1.0/ans;

printf("%f",ans);

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;


int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    REP(i, n){
        cin >> l[i];
    }
    int count = 1;
    int tmp = 0;
    REP(i, n){
        tmp += l[i];
        if(tmp <= x){
            count++;
        }
    }
    if(count <= n+1){
        cout << count << endl;
    }else{
        cout << n+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
list($n, $y) = explode(' ', fgets(STDIN));
$r10000 = -1;
$r5000 = -1;
$r1000 = -1;
for ($a = 0; $a <= $n; $a++) {
    for ($b = 0; $a + $b <= $n; $b++) {
        $c = $n - $a - $b;
        if (10000 * $a + 5000 * $b + 1000 * $c == $y) {
            $r10000 = $a;
            $r5000 = $b;
            $r1000 = $c;
        }
    }
}
printf('%d %d %d', $r10000, $r5000, $r1000);
?>

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

#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int MN = 1e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
int N, M, dp[(1 << 12) + 2];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    cin >> N >> M;
    int mn = 1e9;
    for (int i = 1; i <= M; i++) {
        int a, b, mask = 0;
        cin >> a >> b;
        for (int j = 0; j < b; j++) {
            int c; cin >> c;
            mask |= 1 << (c - 1);
        }
        for (int cur = (1 << N) - 1; cur >= 0; cur--) {
            if (dp[cur] == INF) continue;
            int nxt = cur | mask;
            dp[nxt] = min(dp[nxt], dp[cur] + a);
        }
        mn = min(mn, dp[(1 << N) - 1]);
    }
    if (mn == 1e9) mn = -1;
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 3680
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

const int maxn=512+16;

int n,m;
int a[maxn][maxn];
int p[maxn];
bool v[maxn];

int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	REP(i,n) REP(j,m) { cin>>a[i][j]; --a[i][j]; }
	int ret=1000000000;
	memset(v,true,sizeof(v));
	memset(p,0,sizeof(p));
	while (1)
	{
		int c[maxn];
		memset(c,0,sizeof(c));
		REP(i,n) ++c[a[i][p[i]]];
		int z=0;
		REP(i,m) if (c[i]>c[z]) z=i;
		ckmin(ret,c[z]);
		v[z]=false;
		bool ok=true;
		REP(i,n)
		{
			for (;p[i]<m && !v[a[i][p[i]]];p[i]++);
			if (p[i]>=m) ok=false;
		}
		if (!ok) break;
	}
	printf("%d\n",ret);
	return 0;
}



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

const int MINT = 540, MAXT = 1260;
const int T = MAXT - MINT;
const int N = 1000, M = 10000;

short records[M + 1][T + 1];

int main(){
	int n, m, r, q;
	while(cin >> n >> m, n){
		cin >> r;
		int s, e, t, a, b, ans = 0;
		for(int i = 0; i < m; ++i){
			fill(records[i], records[i] + T + 1, 0);
		}
		for(int i = 0; i < r; ++i){
			cin >> t >> a >> b >> s;
			if(s){
				++records[b][t - MINT];
			}
			else{
				--records[b][t - MINT];
			}
		}
		for(int i = 1; i <= m; ++i){
			for(int j = 0;j <= T;++j){
				records[i][j] += records[i][j - 1];
			}
		}
		cin >> q;
		for(int i = 0; i < q; ++i){
			cin >> a >> b >> m;
			ans = 0;
			a -= MINT;
			b -= MINT;
			for(int j = a;j < b; ++j){
				if(records[m][j]) ++ans;
			}
			cout << ans << endl;
		}
	}
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a-b, a*b)) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char[] s = scan.next().toCharArray();
		char[] a = scan.next().toCharArray();
		
		for(int i = 0; i < s.length - a.length + 1; i++){
			for(int j = 0; j < a.length; j++){
				if(a[j] == s[i + j]){
					if(j == a.length - 1){
						System.out.println(i);
					}
				}else break;
			}
		}
		
	}
}

Measured memory_bytes: 26152
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,q,i;
    cin>>n>>k>>q;
    ll a[q+1];
    map<ll,ll> mp1;
    for(i=1;i<=q;i++){
        cin>>a[i];
        mp1[a[i]]++;
    }
    for(i=1;i<=n;i++){
        if(k>q-mp1[i]){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
        cout<<endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N = 101;
int n, x;
int arr[MAX_N];

void solve() {
    scanf("%d%d", &n, &x);
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    sort(arr, arr + n);
    int i = 0;
    while (x > 0 && i < n)
        x -= arr[i++];
    if (x < 0) printf("%d", i - 1);
    else if (x == 0) printf("%d", i);
    else if (x > 0) printf("%d", n - 1);
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b,a) 
	{
		int dp[b+1][a+1];
		memset(dp,0,sizeof(dp));
		dp[1][1]=1;
		int n; cin>>n;
		bool flag[b+1][a+1];
		memset(flag,0,sizeof(flag));
		for(int i = 0; i < n; ++i)
		{
			int s,t; cin>>s>>t;
			flag[t][s]=true;
		}

		for(int i = 1; i <= b; ++i)
		{
			for(int j = 1; j <= a; ++j)
			{
				if(flag[i][j]) continue;
				if(0<=i-1) dp[i][j]+=dp[i-1][j];
				if(0<=j-1) dp[i][j]+=dp[i][j-1];
			}	
		}
		cout<<dp[b][a]<<endl;
	}
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deq;
    int a;
    while (cin >> a) {
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end(),greater<int>());
    for (int i=0;i<deq.size();i++) {
        if (i==deq.size()-1) {
            cout << deq[i] << endl;
        } else {
            cout << deq[i] << " ";
        }
    }
}



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

int main(void){
  int x,a,b;
  cin >> x >> a >> b;
  int A,B;
  if(x >= a){
    A = x - a;
  }
  else if(x < a){
    A = a - x;
  }

  if(x >= b){
    B = x - b;
  }
  else if(x < b){
    B = b - x;
  }

  if(A < B){
    cout << "A" << '\n';
  }
  else if(A > B){
    cout << "B" << '\n';
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = [0]*n  # 0 * n個分の要素数の配列を作成 ex. [0, 0, 0, 0, .....]
for _ in range(k):
    input()
    l = (list(map(int, input().split())))
    for i in l:
        d[i - 1] = 1  # 0を1に変更する

print(d.count(0))  # 0の要素の個数をカウント

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

public class Main {

    void solve() throws IOException {
        int n = ni();
        String[] b = nsa(n);

        int[] cntRow = new int[n];
        int[] cntColumn = new int[n];

        boolean impossible = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (b[i].charAt(j) == '#') {
                    impossible = false;
                    cntRow[i]++;
                    cntColumn[j]++;
                }
            }
        }
        if (impossible) {
            out.println(-1);
            return;
        }

        int cnt = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if (cntColumn[i] != n) cnt++;

            int tmp = n - cntRow[i];
            if (cntColumn[i] == 0) tmp++;
            min = Math.min(min, tmp);
        }

        out.println(cnt + min);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24020