akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 500 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}

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

    int n;
    cin >> n;
    vector < int > a(n+1),boy(n);

    for(int i = 0; i <= n; i++){
        cin >> a[i] ;
    }
    for(int i = 0; i < n; i++)
        cin >> boy[i] ;
    ll ans = 0;
    int monId = 0;
    for(int i = 0; i < n; i++){
        int tmp = min(boy[i],a[i]);
        ans += tmp;
        boy[i] -= tmp;
        a[i] -= tmp;

        tmp = min(boy[i],a[i+1]);
        ans += tmp;
        boy[i] -= tmp;
        a[i+1] -= tmp;
    }
    cout << ans << endl;
    return 0;

}


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

constexpr int D = 365;
constexpr int T = 26;
int c[D];
int s[D][T];

int last[T];
int score = 0;
vector<int> ans;

void Input() {
    int tmp; cin >> tmp;
    REP(i, T) cin >> c[i];
    REP(i, D) REP(j, T) cin >> s[i][j];
    return;
}

int lambda = 6;

int FindMaxProfitContest(int day) {
    int max_profit = -1e9, argmax = -1;
    REP(type, T) {
        int profit = 0;
        profit += s[day - 1][type];
        profit += lambda * c[type] * (day - last[type]);
        if(profit > max_profit) {
            max_profit = profit;
            argmax = type;
        }
    }
    return argmax;
}

void Commit(int day, int contest) {
    ans.push_back(contest);
    last[contest] = day;
    score += s[day - 1][contest];
    REP(type, T) score -= c[type] * (day - last[type]);
    return;
}

void Output() {
    for(auto contest: ans) cout << contest + 1 << endl;
    return;
}

int main() {
    Input();
    for(int day = 1; day <= D; day++) {
        int contest = FindMaxProfitContest(day);
        Commit(day, contest);
    }
    Output();
    // cerr << score << endl;
    return 0;
}


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

fn solve() {
    input! {
        n: usize,
        hv: [usize; n]
    };

    let mut res = 0;
    let mut prev = hv[0];
    let mut c = 0;
    for h in hv.into_iter().skip(1).chain(vec![std::usize::MAX]) {
        if prev >= h {
            c += 1;
        } else {
            res = std::cmp::max(res, c);
            c = 0;
        }
        prev = h;
    }
    println!("{}", res);
}

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


Measured memory_bytes: 3200
#include<stdio.h>
int main( ){
  int a,b,c,d;
  double e;
  scanf("%d %d",&a,&b);
  c=a/b;
  d=a%b;
  e=(double)a/b;
  printf("%d %d %f\n",c,d,e);
  return 0;
}

Measured memory_bytes: 2692
#include<stdio.h>
int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b){
        printf("%d\n",c);
    }
   else if(b==c){
        printf("%d\n",a);
    }
    else{
        printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
 int main()
 {
 	 int i;
 	 char a[50];
 	 scanf("%s",a);
 	 int len = strlen(a);
 	 for ( int j = 0; j <= len - 2;j++)
	 {
 	 for ( i = j; i < len - 1; i++)
	 {
	 	 if ( a[j] == a[i + 1])
		 goto loop;
	 }
	 }
loop:	 if ( i < len - 1)
	 {
	 	 printf("no\n");
	 }
	 else printf("yes\n");
		 return 0;
 }

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

int main(){
    int h,m,h2,m2,k;
    cin>>h>>m>>h2>>m2>>k;
    int ans;
    ans = (h2-h)*60+m2-m-k;
    if (ans>=0) {
        cout << ans<<endl;
    }else{
        cout << 0<<endl;
    }

}



Measured memory_bytes: 3592
n = int(input())
lst1 = list(map(int, input().split()))
lst1.sort()
lst2 = set()
a, b = 0, 0

for i in lst1:
    if i>b:
        if i in lst2:
            lst2.remove(i)
            if i>a:
                b = a
                a = i
            else:
                b = i
        else:
            lst2.add(i)
print(a*b)

Measured memory_bytes: 14252
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    A = deque([int(input()) for i in range(N)])
    MAX = max(A)
    MAX2 = 0
    Ms = [-1]*N
    for i in range(N):
        if A[i] == MAX:
            if MAX2 != 0:
                Ms[i] = MAX2
            else:
                A[i] = 0
                MAX2 = max(A)
                Ms[i] = MAX2
        else:
            Ms[i] = MAX
    for i in range(N):
        print(Ms[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14528
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=250001;


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

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

    ll lol=((n-1)*(n-2))/2;
    if(k>lol){cout<<"-1";return(0);}

    set<pi> ans;
    for(int i=1;i<=n;++i)
    {
    	for(int j=i+1;j<=n;++j)
    	{
    		ans.insert(mp(i,j));
    	}
    }

    while(k--)
    {
    	set<pi> ::iterator it=ans.begin();
    	while(it->second==n)
    	{
    		advance(it,1);
    	}
    	ans.erase(it);
    }

    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
    	cout<<x.first<<" "<<x.second<<endl;
    }

	return(0);
}


Measured memory_bytes: 640
def a_atCoder_group_contest(N, A):
    A.sort(reverse=True)
    ans = sum(A[1:2 * N:2])  # Aが0-indexedなので、 1, 3,..., 2N-1 番の和をとる
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(a_atCoder_group_contest(N, A))

Measured memory_bytes: 39492
//
// B - たてなが / Thin
//

#include <iostream>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>

std::map<int, std::set<int>> map;

int u,v;

int dist_u[200001];
int dist_v[200001];

void cal_u(const int &cur, const int &depth){
    if(dist_u[cur] || (cur == u && depth))return;
    dist_u[cur] = depth;
    for(const int &next: map[cur]){
        cal_u(next, depth + 1);
    }
}


void cal_v(const int &cur, const int &depth){
    if(dist_v[cur] || (cur == v && depth))return;
    dist_v[cur] = depth;
    for(const int &next: map[cur]){
        cal_v(next, depth + 1);
    }
}


int search_u(const int &cur){
    static int last_node, max_depth = 0;
    static bool visited[200000];
    if(visited[cur])return -1;
    visited[cur] = 1;
    if(dist_u[cur] >= dist_v[cur]) return -1;
    if(dist_v[cur] > max_depth){
        max_depth = dist_v[cur];
        last_node = cur;}
    for(const int &next: map[cur]){
        search_u(next);
    }
    return max_depth;
}

int main(){
    int n;
    std::cin >> n >> u >> v;
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        std::cin >> a >> b;
        map[a].insert(b);
        map[b].insert(a);
    }
    cal_u(u, 0);
    cal_v(v, 0);
    std::cout << search_u(u) - 1;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int e; cin >> e;
    if (e == 0) return;
    int ans = 1e9;
    for (int z = 0; z * z * z <= e; z++)
    for (int y = 0; y * y <= e; y++) {
      int x = e - (z * z * z + y * y);
      if (x < 0) break;
      amin(ans, x + y + z);
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3124
import math

N = int(input())

myo = int(math.log10(N) + 1)

if myo == 1:
    print(N)
elif myo == 2:
    print(9)
elif myo == 3:
    print(9+N-100 +1)
elif myo == 4:
    print(9 + 900)
elif myo == 5:
    print(9+900+N-10000+1)
elif myo == 6:
    print(9+900+90000)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    int count[26] = {0};
    for(int i = 0;i < h;i++){
        string str;
        cin >> str;
        for(int j = 0;j < w;j++){
            int c = str[j]-'a';
            count[c]++;
        }
    }
    int two = 0;
    int one = 0;
    for(int i = 0;i < 26;i++){
        switch (count[i]%4){
            case 1:
                one++;
                break;
            case 2:
                two++;
                break;
            case 3:
                one++;
                two++;
                break;
        }
    }
    if(h%2 == 1){
        two -= w/2;
    }
    if(w%2 == 1){
        two -= h/2;
    }
    if(w%2 == 1 && h%2 == 1){
        one--;
    }
    if(one <= 0 && two <= 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n,m;
  cin >> n;
  m = n;
  int sum = 0;
  while(m){
    sum += m%10;
    m /= 10;
  }
  if(!(n%sum))cout << "Yes" << endl;
  else cout << "No" << endl;





  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007
#define MAX 1000

signed main(){
    int H,W;
    cin>>H>>W;
    int Ch,Cw,Dh,Dw;
    cin>>Ch>>Cw>>Dh>>Dw;

    int cnt[MAX+5][MAX+5]={{0}};
    string S[MAX+5]={{0}};
    for(int i=0;i<H;i++){
        cin>>S[i+1];
        S[i+1]="#"+S[i+1];
        for(int j=1;j<=W;j++){
            cnt[i+1][j]=LLONG_MAX;
        }
    }
    set<int> s2;
    queue<int> qx,qy,qx2,qy2,c2;
    qx.push(Cw);
    qy.push(Ch);
    cnt[Ch][Cw]=0;
    while(!qx.empty()){
        set<int> s;
        int nx=qx.front();
        int ny=qy.front();
        qx.pop();
        qy.pop();
        int dx[]={0,0,1,-1};
        int dy[]={1,-1,0,0};
        for(int i=0;i<4;i++){
            int tx=dx[i]+nx;
            int ty=dy[i]+ny;
            if(tx>=1&&tx<=W&&ty>=1&&ty<=H&&cnt[ty][tx]>cnt[ny][nx]&&
                    S[ty][tx]=='.'){
                cnt[ty][tx]=cnt[ny][nx];
                int o=tx*10000+ty;
                if(s.find(o)==s.end()){
                    qx.push(tx);
                    qy.push(ty);
                    s.insert(o);
                }
            }
        }
        int dx2[]={-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2};
        int dy2[]={-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2};
        for(int i=0;i<24;i++){
            int tx=dx2[i]+nx;
            int ty=dy2[i]+ny;
            if(tx>=1&&tx<=W&&ty>=1&&ty<=H&&cnt[ty][tx]>cnt[ny][nx]+1&&
                    S[ty][tx]=='.'){
                cnt[ty][tx]=cnt[ny][nx]+1;
                int o=tx*10000+ty;
                if(s2.find(o)==s2.end()){
                    qx2.push(tx);
                    qy2.push(ty);
                    s2.insert(o);
                }
            }
        }
        if(qx.empty()){
            while(!qx2.empty()) {
                qx.push(qx2.front());
                qx2.pop();
            }
            while(!qy2.empty()) {
                qy.push(qy2.front());
                qy2.pop();
            }
            s2.clear();
        }
    }
    /*for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cout<<cnt[i][j]<<",";
        }
        cout<<endl;
    }*/
    if(cnt[Dh][Dw]==LLONG_MAX) cout<<"-1"<<endl;
    else cout<<cnt[Dh][Dw]<<endl;
}


Measured memory_bytes: 12528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define int __int128
#define N 6000002
using namespace std;
struct object{
	int c,w,id;
}a[N];
int head[N],ver[N*2],nxt[N*2],l;
int n,maxx,x,d,s,i,j,m[N],p[N],c[N],w[N],ncnt,nc[N],nw[N],f[N],ans;
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void insert(int x,int y)
{
	l++;
	ver[l]=y;
	nxt[l]=head[x];
	head[x]=l;
}
void dfs(int x)
{
	c[x]=m[x];w[x]=1;
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		dfs(y);
		c[x]+=c[y];w[x]+=w[y];
	}
}
int my_comp(const object &a,const object &b)
{
	return a.w*b.c>b.w*a.c;
}
void print(int x)
{
	if(!x) return;
	print(x/10);
	putchar((char)(x%10+'0'));
}
signed main()
{
	n=read();x=read();d=read();
	m[1]=read();
	for(i=2;i<=n;i++){
		m[i]=read();p[i]=read();
		insert(p[i],i);
	}
	dfs(1);
	s=min(n,d);
	for(i=1;i<=n&&s;i++){
		int k;
		for(k=1;s-(1<<k)+1>0;k++){
			ncnt++;
			nc[ncnt]=(1<<(k-1))*c[i];
			nw[ncnt]=(1<<(k-1))*w[i];
			maxx+=nw[ncnt];
		}
		k--;ncnt++;
		nc[ncnt]=(s-(1<<k)+1)*c[i];
		nw[ncnt]=(s-(1<<k)+1)*w[i];
		maxx+=nw[ncnt];
	}
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(i=1;i<=ncnt;i++){
		for(j=maxx;j>=nw[i];j--) f[j]=min(f[j],f[j-nw[i]]+nc[i]);
	}
	for(i=1;i<=n;i++) a[i].c=c[i],a[i].w=w[i],a[i].id=i;
	sort(a+1,a+n+1,my_comp);
	if(ncnt==0){
		int v=x,sum=0;
		for(j=1;j<=n;j++){
			int cnt=(a[j].id==1)?x/c[1]:d;
			if(cnt-s>0){
				if(v>=a[j].c*(cnt-s)) sum+=(cnt-s)*a[j].w,v-=(cnt-s)*a[j].c;
				else{
					sum+=(v/a[j].c)*a[j].w;
					break;
				}
			}
		}
		ans=sum;
	}
	else{
		for(i=0;i<=maxx;i++){
			int v=x-f[i],sum=i;
			if(v<0) continue;
			for(j=1;j<=n;j++){
				int cnt=(a[j].id==1)?(x/c[1]):d;
				if(cnt-s>0){
					if(v>=a[j].c*(cnt-s)) sum+=(cnt-s)*a[j].w,v-=(cnt-s)*a[j].c;
					else{
						sum+=(v/a[j].c)*a[j].w;
						v-=(v/a[j].c)*a[j].c;
						if(v<=0) break;
					}
				}
			}
			ans=max(ans,sum);
		}
	}
	if(!ans) puts("0");
	else print(ans),puts("");
	return 0;
}


Measured memory_bytes: 97392
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) count++;
    }
    cout << count << endl;
    return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  ll h, w, m;
  cin >> h >> w >> m;
  vl bh(h, 0), bw(w, 0);
  map<pii, int> bomb;
  rep(i, 0, m){
    ll a, b;
    cin >> a >> b;
    a--;b--;
    bh[a]++;
    bw[b]++;
    bomb[make_pair(a,b)] = 1;
  }
  
  ll mxh = 0, mxw = 0;
  
  rep(i, 0, h){
    llchmax(mxh, bh[i]);
  }
  vl mxbh(0);
  rep(i, 0, h){
    if(bh[i] == mxh)
      mxbh.push_back(i);
  }
  
  rep(i, 0, w){
    llchmax(mxw, bw[i]);
  }
  vl mxbw(0);
  rep(i, 0, w){
    if(bw[i] == mxw)
      mxbw.push_back(i);
  }
  
  bool check = false;
  
  rep(i, 0, mxbh.size()){
    if(check)
      break;
    rep(j, 0, mxbw.size()){
      pii p = make_pair(mxbh[i], mxbw[j]);
      if(!(bomb.count(p))){
        check = true;
        break;
      }
    }
  }
  
  int ans = mxh + mxw;
  if(!(check))
    ans--;
  
  cout << ans << endl;
  
  return 0;
  
}

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

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

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

int main() {
    int a, b, c;
    while(cin >> a >> b >> c){
        vector<int> v(11, 1);
        v[0] = 0; v[a] = 0; v[b] = 0; v[c] = 0;
        int cnt1 = 0, cnt2 = 0;
        for (int i = 0; i <= 10; ++i) {
            if(!v[i]) continue;
            cnt2++;
            if(a+b+i <= 20) cnt1++;
        }
        if(cnt1*2 >= cnt2) puts("YES");
        else puts("NO");
    }
    return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a = ivec(n);
    vec l(n), r(n);
    rep (i, n) {
        int idx = i + a[i];
        if (idx < n) l[idx]++;
    }
    Forr(i, n - 1, 0) {
        int idx = i - a[i];
        if (idx >= 0) r[idx]++;
    }
    int ans = 0;
    rep (i, n)
        ans += r[i] * l[i];
    print(ans);

    return 0;
}


Measured memory_bytes: 7952
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vector<int> A(200010);
  for(int i = 2;i <= N;i++){
    cin >> A[i];
  }
  vector<vector<int>> data(200010);
  for(int i = 2;i <= N;i++){
    data.at(A.at(i)).push_back(i);
  }
  for(int i = 1; i <= N;i++){
    int ans = data.at(i).size();
    cout << ans << endl;
  }



}


Measured memory_bytes: 14872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll ans=1;
	vl v(n);
	rep(i,n)cin>>v[i];
	if(v[0]!=0){
		ans=0;
	}
	else{
		sort(all(v));
		if(v[1]==0)ans=0;
		else{
			vl tab(100010);
			rep(i,n){
				tab[v[i]]++;
			}
			range(i,1,n){
				ans*=(tab[v[i]-1]);
				ans%=998244353;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1920
s=int(input())
a=list(map(int, input().split()))
count=0
a.sort()
#print(a)
for i in range(s):
  for j in range(i+1,s):
    for k in range(j+1,s):
      #print('tttt',i,j,k,a[i],a[j],a[k])
      if a[i]==a[j]: continue
      if a[j]==a[k]: continue
      if a[k]==a[i]: continue

     
      ij = a[i]+a[j]
      jk = a[j]+a[k]
      ki = a[k]+a[i]
      #print(ij,jk,ki)
      #print(a[i b],a[j],a[k])
      if (ij > a[k]) and (jk > a[i])and (ki > a[j]):
        #print(i,j,k,a[i],a[j],a[k])
        count +=1
print(count)

Measured memory_bytes: 9220
#define M_E        2.71828182845904523536   // e
#define M_LOG2E    1.44269504088896340736   // log2(e)
#define M_LOG10E   0.434294481903251827651  // log10(e)
#define M_LN2      0.693147180559945309417  // ln(2)
#define M_LN10     2.30258509299404568402   // ln(10)
#define M_PI       3.14159265358979323846   // pi
#define M_PI_2     1.57079632679489661923   // pi/2
#define M_PI_4     0.785398163397448309616  // pi/4
#define M_1_PI     0.318309886183790671538  // 1/pi
#define M_2_PI     0.636619772367581343076  // 2/pi
#define M_2_SQRTPI 1.12837916709551257390   // 2/sqrt(pi)
#define M_SQRT2    1.41421356237309504880   // sqrt(2)
#define M_SQRT1_2  0.707106781186547524401  // 1/sqrt(2)
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define IN_FILE "in.txt"
#define OUT_FILE "out.txt"

#define EPS 1e-6
#define INF 1e18
#define SMALL_INF 1e8

#pragma warning (disable : 4996)

int main() {
#ifdef _DEBUG
	freopen(IN_FILE, "r", stdin);
	freopen(OUT_FILE, "w", stdout);
#endif
	int n;
	cin >> n;
	long long s = 0;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		s += t;
	}
	if (s % 2)
	{
		cout << "NO\n";
	} else
	{
		cout << "YES\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A + B + C > 21) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;


class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        if (888 < N)
        {
            Console.WriteLine("999");
        }
        else if (777 < N)
        {
            Console.WriteLine("888");
        }
        else if (666 < N)
        {
            Console.WriteLine("777");
        }
        else if (555 < N)
        {
            Console.WriteLine("666");
        }
        else if (444 < N)
        {
            Console.WriteLine("555");
        }
        else if (333 < N)
        {
            Console.WriteLine("444");
        }
        else if (222 < N)
        {
            Console.WriteLine("333");
        }
        else if (111 < N)
        {
            Console.WriteLine("222");
        }
        else 
        {
            Console.WriteLine("111");
        }



    }

}


Measured memory_bytes: 11092
def inint(): return int(input())
def inlint(): return list(map(int, input().split()))
def infloat(): return float(input())
def inlffloat(): return list(map(float, input().split()))
def inl(): return list(input())
def putlint(): return "".join(list(map(str, ans)))

a = input()

if(a=="a" or a=="i" or a=="u" or a=="e" or a=="o"):
    print("vowel")
else:
    print("consonant")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    int ans = 0,cnt = 0;
    rep(i,s.size()){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(ans,cnt);
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}


int main(){
    string s,t;
    cin>>s>>t;
    map<char,char> m1,m2;
    int flag=0;
    for(int i=0;i<s.size();i++){

        if(m1.find(s[i])==m1.end()){
            m1[s[i]]=t[i];
        }
        else{
            if(m1[s[i]]==t[i])continue;
            else{
                flag=1;
                break;
            }
        }
        if(m2.find(t[i])==m2.end()){
            m2[t[i]]=s[i];
        }
        else{
            if(m2[t[i]]==s[i])continue;
            else{
                flag=1;
                break;
            }
        }

    }


    if(flag==1)cout<<"No\n";
    else cout<<"Yes\n";
}


Measured memory_bytes: 82036
import bisect
n = int(input())
cnt = 0
l = sorted(list(map(int, input().split())))
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        c_min = b + 1
        c_max = bisect.bisect_left(l, l[a] + l[b]) - 1
        cnt += c_max - c_min + 1
print(cnt)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
const ll mod=1e9+7;
char s[N];
ll dp[N][13]={0};
int main()
{
    scanf("%s",s);
        int n=strlen(s)-1;

    for(int i=0;i<=n;i++)
    {

        if(s[i]=='?')
        {
            if(i==0)
            {
                for(int j=0;j<10;j++)
                    dp[i][j]=1;
            }
            else
            {
                for(int j=0;j<13;j++)
                {
                    for(int k=0;k<=9;k++)
                    {
                        dp[i][(j*10+k)%13]+=dp[i-1][j];
                        dp[i][(j*10+k)%13]%=mod;
                    }
                }
            }
        }
        else
        {
            if(i==0)
            {
                dp[i][s[i]-'0']=1;
            }
            else
            {
                for(int j=0;j<13;j++)
                {
                    dp[i][(j*10+s[i]-'0')%13]+=dp[i-1][j];
                    dp[i][(j*10+s[i]-'0')%13]%=mod;
                }

            }
        }
    }
    cout<<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,ans=0,y;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i],a[i]-=i+1;
    sort(a,a+n);
    
    rep(i,n)ans+=abs(a[i]-(n%2?a[(n-1)/2]:(a[(n-1)/2]+a[n/2])/2));
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())

a = sorted(a)
sum = 0

if n % 2 == 1:
    sum1 = 0
    for i in range(int(n/2)+1, n):
        sum1 += a[i] * 2
    sum1 -= a[int(n / 2)-1]
    sum1 -= a[int(n / 2)]
    for i in range(int(n / 2)-1):
        sum1 -= a[i]*2

    sum2 = 0
    for i in range(int(n/2), n):
        sum2 += a[i] * 2
    sum2 -= a[int(n / 2)]
    sum2 -= a[int(n / 2)+1]
    for i in range(int(n / 2)):
        sum2 -= a[i]*2
    print(max(sum1, sum2))
else:
    sum += a[int(n / 2)]
    for i in range(int(n / 2)+1, n):
        sum += a[i] * 2
    sum -= a[int(n / 2) - 1]
    for i in range(int(n / 2) - 1):
        sum -= a[i] * 2
    print(sum)


Measured memory_bytes: 8300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);

		int n = sc.nextInt();
		int ac = 0, wa = 0, tle = 0, re = 0;
		
		while(n-- > 0) {
			
			String s = sc.next();
			
			if(s.equals("AC"))
				ac++;
			else if(s.equals("WA"))
				wa++;
			else if(s.equals("TLE"))
				tle++;
			else
				re++;
		}
		
		pr.println("AC x " + ac);
		pr.println("WA x " + wa);
		pr.println("TLE x " + tle);
		pr.println("RE x " + re);

		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 48748
#include<bits/stdc++.h>
using namespace std;main(){for(long long i,n,j[99999],s,a;;cout<<a<<endl){cin>>n;if(!n)break;for(i=s=0;i++<n;s+=a)cin>>a;for(i=n;i>1;cin>>j[--i]);for(sort(j+1,j+n);n>0;s+=j[n])a=max(n--*s,a);}}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

using ll = long long;
using namespace std;


signed main() {
    int N, M;cin >> N >> M;
    vector<vector<int>> vec(N);
    for(int i = 0;i < M;i++){
        int a, b;cin >> a >> b;
        vec[b - 1].push_back(a - 1);
    }
    set<int> current;
    int ans = 0;
    for(int i = 0;i < N;i++){
        bool f = false;
        for(auto a : vec[i]){
            if(current.find(a) != current.end()){
                f = true;
            }
        }
        if(f){
            ans++;
            current.clear();
        }
        current.insert(i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9372
a,b,c = gets.to_i, gets.to_i, gets.to_i
yen = gets.to_i

counter = 0
0.upto(a) do |a|
  0.upto(b) do |b|
    0.upto(c) do |c|
      total = 500 * a + 100 * b + 50 * c
      counter += 1 if total == yen
    end
  end
end
p counter


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k[32]= {
        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
    };
    int n; cin >> n;
    cout << k[n-1] << endl;
}

Measured memory_bytes: 256
n, m, x = gets.chomp.split.map(&:to_i)

cs = []
as = []
n.times do
  t = gets.chomp.split.map(&:to_i)
  cs.push t[0]
  as.push t[1..-1]
end

res = 1<<60

(2**n).times do |i|
  xs = Array.new(m, 0)
  tmp = 0

  n.times do |k|
    if (i >> k & 1) == 1
      tmp += cs[k]
      as[k].each.with_index do |a, i|
        xs[i] += a
      end
    end
  end

  if xs.all? { |xx| xx >= x }
    res = [res, tmp].min
  end
end

if res == 1<<60
  puts -1
else
  puts res
end

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

using namespace std;

void solve() {
    map<int, int> mp;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int v; cin >> v;
        if (mp.count(v)) {
            cout << "NO"; return;
        }
        mp[v] = 1;
    }
    cout << "YES";
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 9600
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var n = int.Parse(Console.ReadLine().Trim());
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var ans = getAns0(h, w, n, a);
        print(h, w, ans);
    }
    static void print(int h, int w, int[,] a)
    {
        var t = new int[w];
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
                t[j] = a[i, j];
            Console.WriteLine(string.Join(" ", t));
        }
    }
    static int[,] getAns0(int h, int w, int n, int[] a)
    {
        var t = new int[h, w];
        for (int i = 0; i < (h + 1) / 2; i++)
            for (int j = 0; j < w; j++)
            {
                if (2 * i < h) t[2 * i, j] = 2 * w * i + j;
                if (2 * i + 1 < h) t[2 * i + 1, j] = 2 * w * (i + 1) - j - 1;
            }
        var ps = new P[h * w];
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                ps[t[i, j]] = new P { x = i, y = j };
        var pos = 0;
        var ans = new int[h, w];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < a[i]; j++)
            {
                var c = ps[pos++];
                ans[c.x, c.y] = i + 1;
            }
        }
        return ans;
    }
}

Measured memory_bytes: 13536
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int num[6]={0};

void POINT(char point){

  if(point=='E'){
    swap(num[0],num[3]);
    swap(num[3],num[5]);
    swap(num[5],num[2]);
  }
  if(point=='W'){
    swap(num[0],num[2]);
    swap(num[2],num[5]);
    swap(num[5],num[3]);
  }
  if(point=='S'){
    swap(num[0],num[4]);
    swap(num[4],num[5]);
    swap(num[5],num[1]);
  }
  if(point=='N'){
    swap(num[0],num[1]);
    swap(num[1],num[5]);
    swap(num[5],num[4]);
  }

}


int main(){

  int i=0;
  int d[6]={0};
  string s1="NNNNENNNN";
  string s2="NNNNENNNN";
  string s3="EEEENEEEE";

  for(i=0;i<6;i++){
    cin >>num[i];
  }
  for(i=0;i<6;i++){
    cin >>d[i];
  }
  for(i=0;i<s1.size();i++){
    if(num[0]==d[0] && num[5]==d[5]){ /*cout <<"a1";*/  break;    }
    POINT(s1[i]);
  }
  for(i=0;i<s2.size();i++){
    if(num[1]==d[1] && num[4]==d[4]){ /*cout <<"a2";*/  break;    }
    POINT(s2[i]);
  }
  for(i=0;i<s3.size();i++){
    if(num[3]==d[3] && num[2]==d[2]){ /*cout <<"a3";*/  break;    }
    POINT(s3[i]);
  }


  if(num[0]==d[0] && num[1]==d[1] && num[2]==d[2] && num[3]==d[3] && num[4]==d[4] && num[5]==d[5]) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;

  return 0;
}

Measured memory_bytes: 1200
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

vector<pair<int,int>> G[100002];

int x[100002];
int cnt = 0;
void dfs(int id) {
	//繋がってるノードをぜんぶ展開
	for (pair<int, int> p : G[id]) {
		//未訪問なら
		if (x[p.first] == LL_HALFMAX) {
			x[p.first] = x[id] + p.second;
			dfs(p.first);
		}
		//訪問済みなら
		else {
			//矛盾検査
			if (x[p.first] - x[id] != p.second) cnt++;
		}
	}
}

signed main() {
	int N, K;
	cin >> N >> K;
	//p:わるかず
	int ans = 0;
	for (int p = K + 1; p <= N; p++) {
		int add = (N / p)*(p - K) + max((N%p - max(K-1, 0LL)), 0LL);
		ans += add;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	map<ll,ll> mp;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		mp[a]+=b;
	}
	for(auto itr:mp){
		if(k>itr.se){
			k-=itr.se;
			continue;
		}
		cout<<itr.fi<<endl;
		return 0;
	}
}

Measured memory_bytes: 4224