akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

    #define debug(args...)(Debugger()) , args

    class Debugger{
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << std::endl;}

        private:
        
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)
#endif

const int LLMM = 1e15 + 1;

void solve(){

	int x, k, d;
	cin >> x >> k >> d;

	int div = abs(x) / d;

	if(div >= k){
		cout << min(abs(x - (k*d)), abs(x + k*d));
	}else{
		int rem = k - div;
		if(rem % 2 != 0){
			div++;
		}
		cout << min(abs(x - (div*d)), abs(x + (div)*d));
	}

}


int32_t main(){

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



Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>

void irekae(char **a,int i,int h,int w);
void irekae2(char **a,int i,int h,int w);

int main(void)
{
        int h,w,hh;
        int i,j;
        char **a;

        scanf("%d%d",&h,&w);

        hh = h;


        //領域確保
        a = malloc(sizeof(char *)*h);
        for(i=0;i<h;i++)
                *(a+i) = malloc(sizeof(char)*w);


        //文字の読み込み
        for(i=0;i<h;i++){
                scanf("%s",*(a+i));
        }


        //取り除く
        for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                        if(*(*(a+i)+j)=='#')
                                j = 102;
                }
                if(j<102){
                        irekae(a,i,h,w);
                        i--;
                        h--;
                }
        }
        for(i=0;i<w;i++){
                for(j=0;j<h;j++){
                        if(*(*(a+j)+i)=='#')
                                j=102;
                }
                if(j<102){
                        irekae2(a,i,h,w);
                        i--;
                        w--;
                }
        }



        //文字の書き出し
        printf("\n");
        for(i=0;i<h;i++){
                for(j=0;j<w;j++)
                        printf("%c",*(*(a+i)+j));
                printf("\n");
        }


        //領域の開放
        for(i=0;i<hh;i++)
                free(*(a+i));
        free(a);


        return 0;
}

void irekae(char **a,int i,int h,int w)
{
        int ii,jj;

        for(ii=i;ii<h-1;ii++){
                for(jj=0;jj<w;jj++){
                        a[ii][jj] = a[ii+1][jj];
                }
        }

        return;
}

void irekae2(char **a,int i,int h,int w)
{
        int ii,jj;

        for(ii=i;ii<w-1;ii++){
                for(jj=0;jj<h;jj++){
                        a[jj][ii] = a[jj][ii+1];
                }
        }

        return;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define LL long long
using namespace std;
int sum[100001];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a;
        memset(sum,0,sizeof(sum));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a);
            sum[a+1]++;
            sum[a-1]++;
            sum[a]++;
        }
        sort(sum,sum+100001);
        printf("%d\n",sum[100000]);
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    for(int i = 0; i < (n+1) / 2; i++){
        int x = a[i];
        a[i] = a[n-1-i];
        a[n-1-i] = x;
    }
    
    rep(i,n){
        if(i != n - 1) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
}





Measured memory_bytes: 3100
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int i,j,k,n,d;
ll ans,tm10[22];
ll dfs(int x,ll y) {
	if (n-x-1<x) {
		if (y==d) return 1;
		return 0;
	}
	if (x==n-x-1) {
		if (x==0) return 9ll*dfs(x+1,y);
		return 10ll*dfs(x+1,y);
	}
	ll t=(tm10[n-x-1]-tm10[x])/9;
	ll ans=0;
	for (int i=-9;i<=9;i++) if (i*t+y>=0 && (i*t+y)%tm10[x+1]==d%tm10[x+1]) {
		int tt=10-abs(i);
		if (x==0 && i>=0) tt--;
		if (tt) ans+=tt*dfs(x+1,t*i+y);
	}
	return ans;
}
int main() {
	tm10[0]=1;
	for (i=1;i<=18;i++) tm10[i]=10ll*tm10[i-1];
	scanf("%d",&d);
	if (d%9) return puts("0"),0;
	d/=9;
	for (n=1;n<=18;n++) ans+=dfs(0,0ll);
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,t,i,c,sum=0,j,p=0;
    cin>>n>>m>>c;
    int b[m+2],a[n][m];
    for(i=0; i<m; i++)
    {
        cin>>b[i];
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>a[i][j];

        }
    }
    for(i=0; i<n; i++)
    {
        sum=0;
        for(j=0; j<m; j++)
        {
            sum=sum+a[i][j]*b[j];

        }
        //cout<<sum+c<<endl;
        if(sum+c>0)
        {
            p++;
        }
    }
cout<<p<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
string s[200010];
long long x[200010]={0};
int main(){
	int n,i,j,m;
	long long ans=0,k=0;
	char t;
	cin >> n;
	for(i=1;i<=n;i++){
		x[i]=x[i]+x[i-1]+i;
	}
	for(i=0;i<n;i++){
		cin >> s[i];
	}
	for(m=0;m<n;m++){
		for(i=0;i<s[m].size()-1;i++){
			for(j=i+1;j<s[m].size();j++){
				if(s[m][i]>s[m][j]){
					t=s[m][i];
					s[m][i]=s[m][j];
					s[m][j]=t;
				}
			}
		}
	}
	sort(s,s+n);
	ans=0;
	k=0;
	for(i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			ans+=x[k];
			k=0;
		}
		else
			k++;
	}
	ans+=x[k];
	cout << ans << endl;
	return 0;
}


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

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	int cur = 1;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if(A[i] == cur){
			cur++;
		}
	}
	if(cur == 1){
		cur = N + 2;
	}
	cout << N - cur + 1 << endl;
}

Measured memory_bytes: 1792
k, n = map(int, input().split())
data = list(map(int, input().split()))

# 最長の長さがどこにあるか判定して上げる
# 0 5 15
# 0-1 : data[1]     - data[0] :       5 -  0 =  5
# 1-2 : data[2]     - data[1] :      15 -  5 = 10
# 2-0 : data[0] + k - data[2] :  0 + 20 - 15 =  5

diffs = []
for i in range(n):
  if i+1 <= n-1:
    diffs.append(data[i+1] - data[i])
  
  if i == n-1:
    diffs.append(data[0] + k - data[i])

print(sum(diffs) - max(diffs))


Measured memory_bytes: 26444
import collections
n,m = list(map(int,input().split()))

di = collections.defaultdict(list)
for i in range(m):
    a,b = list(map(int,input().split()))
    di[a-1].append(b-1)
    di[b-1].append(a-1)

ans=[-1]*n
ans[0]=0
que = [0]
#print(di)

while que:
    v = que.pop(0)
    for i in di[v]:
        if ans[i]!=-1:continue
        ans[i]=v
        que.append(i)
    #print(que)

print("Yes")
for i in ans[1:]:
    print(i+1)

Measured memory_bytes: 42560
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B, C, D;
      cin >> A >> B >> C >> D;
      if( (A + D -1 ) / D >= (C + B -1 ) / B ){
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
      

    }

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
const long mod=998244353;
long fac[2<<17],inv[2<<17],ans,N,M,K;
long pow(long a,long b){return b?pow(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
void init(){
	fac[0]=1;
	for(int i=1;i<2<<17;i++)fac[i]=fac[i-1]*i%mod;
	inv[(2<<17)-1]=pow(fac[(2<<17)-1],mod-2);
	for(int i=(2<<17)-1;i--;)inv[i]=inv[i+1]*(i+1)%mod;
}
long com(long n,long r){return fac[n]*inv[r]%mod*inv[n-r]%mod;}
int main()
{
	cin>>N>>M>>K;
	init();
	for(int k=0;k<=K;k++)ans+=com(N-1,k)*M%mod*pow(M-1,N-k-1)%mod;
	cout<<ans%mod<<endl;
}


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


int main() {
  int num, count;
  cin >> num;
  vector<int> s(3);
  
    
  s[0] = num / 100;
  s[1] = num / 10 - s[0]*10;
  s[2] = num - s[0]*100 - s[1]*10;
  count = 0;
  
  for (int i=0; i<3; i++){
    
    if (s[i] == 1){
    count ++;
  }
  }
   
   cout << count << endl;
}
 


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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    vector<vector<int>> A(2, vector<int>(N));
    REP(i, 2){
        REP(j, N){
            scanInt(Aij);
            A[i][j] = Aij;
        }
    }
    ll sum = 0;
    sum += A[0][0];
    REP(j, N){
        sum += A[1][j];
    }
    ll result = sum;
    REP(j, N - 1){
        sum -= A[1][j];
        sum += A[0][j + 1];
        result = max(sum, result);
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

template <class T = int>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) { for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i]; }

	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()) - 1; i++) cusum[i + 1] += cusum[i]; }

	T query(int l, int r) { return cusum[r] - cusum[l]; }  // partial sum of [l, r)
};

int main() {

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

	int N, K;
	cin >> N >> K;

	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	sort(h.begin(), h.end(), greater<int>());

	for (int i = 0; i < N - 1; i++) h[i] -= h[i + 1];

	CuSum<> hsum(h);
	int ans = INF;
	for (int i = 0; i <= N - K ; i++) ans = min(hsum.query(i, i + K - 1), ans);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  double sum = 0;
  deque<pair<double, double>> Q;
  for (int i = 0; i < n; ++i) {
    double T, V;
    scanf("%lf%lf", &T, &V);
    double rem = V;
    while (Q.size() && rem > 0) {
      if (Q.front().first > rem) {
        Q.front().first -= rem;
        sum -= rem * Q.front().second;
        break;
      } else {
        rem -= Q.front().first;
        sum -= Q.front().first * Q.front().second;
        Q.pop_front();
      }
    }
    while (Q.size() && Q.back().second > T) {
      double V2 = Q.back().first, T2 = Q.back().second;
      Q.pop_back();
      sum -= V2 * T2;
      T = (V2 * T2 + V * T) / (V2 + V);
      V += V2;
    }
    Q.push_back({V, T});
    sum += V * T;
    printf("%.10f\n", sum / m);
  }
  return 0;
}


Measured memory_bytes: 18704
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    if(K == 1){
        cout << 0 << endstr;
    }
    else{
        ll m = N-(K-1);
        cout << (m-1) << endstr;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
#define rep2(i,from,to) for(int i=(from); i<(to); ++(i))
#define rep(i,to) rep2(i,0,to)
int main() {
	int n;
	while(cin >> n && n) {
		int a[5001];
		int Max = INT_MIN;
		rep(i,n) {
			cin >> a[i]; 
		}
		rep(i,n) {
			int sum = 0;
			rep2(j,i,n) {
				sum += a[j];
				Max = max(Max, sum);
			}
		}
		cout << Max << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
/*
1. I'm the Future Red Coder :)
2. Hopefully, I'll be Yellow Soon.
*/
#include<bits/stdc++.h>
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
ll power(ll a,ll b,ll m=mod) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
/*struct node {
    int l,r,nq;
};
bool compare(const node& a,const node& b) {
    if (a.r != b.r) return a.r<b.r;
    return a.l<b.l;
}*/
/* ******* DSU START ****** */
/*
const int dsusize = (int)1e5+5;
struct node {
    int data;
    int rk,pn;
}dsu[dsusize];
//ll fans;
void initialize(int n) {
    REP(i,1,n) {
        dsu[i].data = 1;
        dsu[i].rk = 0;
        dsu[i].pn = i;
    }
}
int fnd(int i) {
    if (dsu[i].pn != i) dsu[i].pn = fnd(dsu[i].pn);
    return dsu[i].pn;
}
void unn(int i,int j) {
    i = fnd(i);
    j = fnd(j);
    if (i!=j) {
        //fans -= dsu[i].data*dsu[j].data;
        if (dsu[i].rk>dsu[j].rk) {
            dsu[j].pn = i;
            dsu[i].data += dsu[j].data;
        }
        else {
            dsu[i].pn = j;
            dsu[j].data += dsu[i].data;
            if (dsu[i].rk==dsu[j].rk) {
                dsu[j].rk++;
            }
        }
    }
}
*/
/* ******* DSU END****** */

const int N = (int)2e5+5;
const int Q = 250;
multiset<int> s;
int a[N];
void solve() {
    int n;
    cin>>n;
    REP(i,1,n) {
        cin>>a[i];
    }
    s.insert(mod);
    int ans = 0;
    REPN(i,n,1) {
        auto it = s.upper_bound(a[i]);
        if (*it == mod) ans++;
        else s.erase(it);
        s.insert(a[i]);
    }
    cout<<ans;
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll Solve(){
    ll H,W,M; cin>>H>>W>>M;
    vec d(H,0), e(W,0);
    vector<P> D;
    rep(i,M){
        ll h,w; cin>>h>>w;
        h--; w--;
        d[h]++; e[w]++;
        D.pb(mp(h,w));
    }
    ll MAXD=-INF, MAXE=-INF;
    rep(i,H) MAXD=max(d[i],MAXD);
    rep(i,W) MAXE=max(e[i],MAXE);
    
    vec dd,ee;
    rep(i,H) if(MAXD==d[i]) dd.pb(i);
    rep(i,W) if(MAXE==e[i]) ee.pb(i);
    sort(ALL(D));
    if(dd.size()*ee.size()>M) return MAXD+MAXE;
    rep(i,dd.size()) rep(j,ee.size()){
        P f=mp(dd[i],ee[j]);
        if(upper_bound(ALL(D),f)==lower_bound(ALL(D),f)) return MAXD+MAXE;
    }
    return MAXD+MAXE-1;
}
int main(){
    cout<<Solve()<<endl;
}

Measured memory_bytes: 21520
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let (n, m): (u64, u64) = input();
    let x = min(n, m / 2);
    let y = (m - 2 * x) / 4;
    println!("{}", x + y);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

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

int main(){	
	int n;
	cin>>n;
	vector<int> v;
	int a;
	while(n--){
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int last=v[0];
	int ans=1;
	for(int i=1;i<v.size();i++){
		if(v[i]>last){
			ans++;
			last=v[i];
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

if n == 1:
    print(0)
else:

    all = 10**n % (10**9+7)

    no_zero = 9**n % (10**9+7)
    no_nine = no_zero

    no_nine_and_zero = 8**n % (10**9+7)

    print((all-no_nine-no_zero+no_nine_and_zero) % (10**9+7))

Measured memory_bytes: 10700
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int r,g,b;
    cin >> r >> g >> b;
    if ((g*10+b) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n; cin>>n;
  vector<int> A(n);
  for(int i=0; i<n; i++) cin>>A[i];
  bool ok = true;
  for(int i=0; i<n; i++) 
  {
    if(A[i]%2==0)
    {
      if(A[i]%3==0 || A[i]%5==0)
      {
        ok= true;
      }
      else 
      {
		  ok =false;
		  break;
	  }
    }
  }
  if(ok) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n, m;
    cin >> n >> m;
    COMinit();

    ll ans = (PER(m,n)*PER(m,n))%MOD;

    for(int k = 1; k <= n; k++){
        ll tmp = ((COM(n, k)*PER(m, k))%MOD * (PER(m-k,n-k)*PER(m-k,n-k)%MOD))%MOD;
        if (k%2 == 1) ans += MOD - tmp;
        else ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = unsigned long long int;

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

    ll n, k;
    cin >> n >> k;
    bitset<1000> s;
    while(k--) {
        ll d;
        cin >> d;
        while(d--) {
            ll a;
            cin >> a;
            s[--a] = 1;
        }
    }

    ll r = 0;
    for(ll i=0; i<n; i++)
        if(!s[i]) r++;
    cout << r << endl;

}


Measured memory_bytes: 3656
#include <stdio.h>
//prototype
int main(void);

int main(void){

  int n, i, j;
  int init_number = 1;
  int Playing_cards[4][13];
  int card_count = 1;
  char card_mark;
  int card_number;


  //Initialize Playing_cards
  for (i = 0; i <= 3; i++) {
    for (j = 0; j <= 12; j++) {
        Playing_cards[i][j] = init_number;
        init_number++;
    }
    init_number = 1;
  }

  //count the cards
  scanf("%d", &n);

  while(1){

    if(card_count > n){
      break;
    }

    scanf("%c %d", &card_mark, &card_number);

    if(card_mark == 'S'){
      Playing_cards[0][card_number-1] -= card_number;
      card_count++;
    } else if(card_mark == 'H'){
      Playing_cards[1][card_number-1] -= card_number;
      card_count++;
    } else if(card_mark == 'C'){
      Playing_cards[2][card_number-1] -= card_number;
      card_count++;
    } else if(card_mark == 'D'){
      Playing_cards[3][card_number-1] -= card_number;
      card_count++;
    }
  }

  //display the cards not found
  //printf("\n");
  
  for (i = 0; i <= 3; i++) {
    if(i == 0){
      card_mark = 'S';
    } else if(i == 1){
      card_mark = 'H';
    } else if(i == 2){
      card_mark = 'C';
    } else if(i == 3){
      card_mark = 'D';
    }
    for (j = 0; j <= 12; j++){
       if (Playing_cards[i][j] != 0){
          printf("%c %d\n", card_mark, Playing_cards[i][j]);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2112
S = input()
N = len(S) - 1

ans = 0
for i in range(2 ** N):
    add_pos = []
    for j in range(N):
        if (i >> j) & 1:
            add_pos.append(j + 1)

    to_be_sumed = []

    if not add_pos:
        to_be_sumed.append(int(S))

    for i in range(len(add_pos)):
        if i == 0:
            to_be_sumed.append(int(S[:add_pos[i]]))
            if i == len(add_pos) - 1:
                to_be_sumed.append(int(S[add_pos[i]:]))
        else:
            to_be_sumed.append(int(S[add_pos[i - 1]:add_pos[i]]))
            if i == len(add_pos) - 1:
                to_be_sumed.append(int(S[add_pos[i]:]))
    # print(to_be_sumed)
    ans += sum(to_be_sumed)
print(ans)


Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int n, m;
    vector<int> a;
    while(cin >> n >> m && n && m){
        a.resize(n);
        for(auto&& i : a){
            cin >> i;
        }
        sort(begin(a), end(a));
        int ans = -1;
        for(int i = 0; i + 1 < n; i++){
            for(int j = i + 1; j < n; j++){
                if(a[i] + a[j] > m) break;
                ans = max(ans, a[i] + a[j]);
            }
        }
        if(~ans){
            cout << ans << "\n";
        }else{
            cout << "NONE\n";
        }
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> T(M);
	for(int i=0; i<M; ++i){
	    int k; cin >> k;
	    for(int j=0; j<k; ++j){
	        int s; cin >> s;
	        T[i].push_back(s);
	    }
	}
	vector<int> P(M);
	for(int i=0; i<M; ++i) cin >> P[i];
	int ans=0;
	for(int bit=0; !(bit&(1<<N)); ++bit){
	    bool flag=true;
	    for(int i=0; i<M; ++i){
	        int cnt=0;
	        for(int j=0; j<T[i].size(); ++j){
	            if(bit&(1<<(T[i][j]-1))) ++cnt;
	        }
	        if(cnt%2!=P[i]) flag=false;
	    }
	    if(flag) ++ans;
	}
	cout << ans << endl;
	return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  struct node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33032
N, M, V, P = map(int, input().split())
A = [int(i) for i in input().split()]

A.sort()

s = [A[0]]
for i in range(1, N) :
  s.append(A[i] + s[-1])

def check(m) :
  if m >= N - P :
    return True
  if A[m] + M < A[N - P] :
    return False

  rest = M * (V - P)
  x = A[m] + M
  for i in range(N - P + 1) :
    if i == m :
      continue
    rest -= min(x - A[i], M)
  return rest <= 0

ng, ok = -1, N
while ok - ng > 1 :
  m = (ok + ng) // 2
  if check(m) :
    ok = m
  else :
    ng = m

print(N - ng - 1)

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

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int N;
long long dp[3005][3005]; //---- dp[i][j]: a[i, j)を初期局面としたときのX-Y

int main(){
    cin >> N;
    vi a(N+1);
    rep(i,N) cin >> a[i];

    rep(i,N) dp[i][i] = 0; //---- 初期条件

    for(int len = 1; len <= N; ++len){
        for(int i = 0; i < N; ++i){
            int j = i + len;

            //---- 先手番
            if((N - len) % 2 == 0)
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);

            //---- 後手番
            else
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
        }
    }
    cout << dp[0][N];
    return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 1000;
const long double ZERO = 0.0;
ll x[N], y[N], r[N];
long double dst[N];
int used[N];

ll sqr(ll a) { return a * a; }
long double dist(ll x1, ll y1, ll x2, ll y2) {
  return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

long double getdist(int i, int j) {
  return max(ZERO, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]);
}

void solve() {
  ll xs, ys, xf, yf; cin >> xs >> ys >> xf >> yf;
  xf -= xs, yf -= ys;
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> r[i];
    x[i] -= xs, y[i] -= ys;
  }
  for (int v = 0; v < n; v++) {
    long double d = sqrt(sqr(x[v]) + sqr(y[v])) - r[v];
    dst[v] = max(ZERO, d);
  }
  for (int iter = 0; iter < n; iter++) {
    int v = -1;
    for (int u = 0; u < n; u++) {
      if (!used[u] && (v == -1 || dst[u] < dst[v])) v = u;
    }
    if (v == -1) break;
    used[v] = 1;
    for (int u = 0; u < n; u++) {
      dst[u] = min(dst[u], dst[v] + getdist(v, u));
    }
  }
  long double ans = dist(0ll, 0ll, xf, yf);
  for (int v = 0; v < n; v++) {
    long double d = max(ZERO, dist(x[v], y[v], xf, yf) - r[v]);
    ans = min(ans, dst[v] + d);
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3908
readlines.each do |l|
	c1,c2,c3 = l.split.map(&:to_i)
	a = (1..10).to_a - [c1,c2,c3]
	count = 0
	a.each {|x| count += 1 if (c1+c2)+x <= 20}
	puts (count/7.0 >= 0.5 ? "YES" : "NO")
end

Measured memory_bytes: 6112
#include <iostream>

using namespace std;

int main(){
	int X;
	cin >> X;
	if(400<=X && X<600){
		cout << "8";
	}else if(600<=X && X<800){
		cout << "7";
	}else if(800<=X && X<1000){
		cout << "6";
	}else if(1000<=X && X<1200){
		cout << "5";
	}else if(1200<=X && X<1400){
		cout << "4";
	}else if(1400<=X && X<1600){
		cout << "3";
	}else if(1600<=X && X<1800){
		cout << "2";
	}else if(1800<=X && X<2000){
		cout << "1";
	}
	return 0;
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int a; string s; cin >> a >> s;
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
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>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	VecS str(n);
	rep(i, n) cin>> str[i];

	unordered_map<string, ll> ump;
	rep(i, n){
		ump[str[i]]++;
	}

	ll max = 0;
	for(pair<string, ll> i : ump) chmax(max, i.sc);

	VecS ans;
	for(pair<string, ll> i : ump){
		if(i.sc == max) ans.pb(i.fs);
	}

	sort(all(ans));
	for(string s : ans) co(s);

	return 0;
}


Measured memory_bytes: 28228
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
long long n,a,x[50],dp[100][100][5000];
int main(){
    cin>>n>>a;
    for(int i=0;i<n;i++)cin>>x[i];
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(long long k=0;k<5000;k++){
                if(dp[i][j][k]==0)continue;
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                dp[i+1][j][k]+=dp[i][j][k];
            }
        }
    }
    long long s=0;
    for(int i=1;i<=n;i++)s+=dp[n][i][a*i];
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 151808
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String N=sc.next();
        if(N.charAt(0)==N.charAt(2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


        }
        
        
    }


Measured memory_bytes: 23892
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int64_t n, a, b;
	cin >> n >> a >> b;

	int64_t roop = n / (a + b);
	int64_t amari = n % (a + b);

	int64_t ans = 0;
	ans += a * roop;
	ans += min(amari, a);

	cout << ans << endl;
}


Measured memory_bytes: 256
import itertools

N = int(input())
P = int(input().replace(' ', ''))
Q = int(input().replace(' ', ''))
s = [i for i in range(1, N + 1)]
l = list(itertools.permutations(s))
j = []
for i in range(len(l)):
  t = map(str,l[i])
  j.append(int(''.join(t)))

nl = sorted(j) 
a = 0
b = 0

for i in range(len(nl)):
  if nl[i] == P:
    a = i + 1
  if nl[i] == Q:
    b = i + 1
    
print(abs(a -b))

Measured memory_bytes: 9972
#include<iostream>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin>>x>>y;
		if(x==0&&y==0){
			break;
		}
		if(x<=y) cout<<x<<" "<<y<<endl;
		else cout<<y<<" "<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int h, w;
  cin >> h >> w;
  vvi a(h, vi(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  vvi ans;
  auto update = [&](int i, int j, int k, int l) {
    vi now = {i, j, k, l};
    ans.push_back(now);
  };

  rep(i, h) rep(j, w-1) {
    if (a[i][j]%2) {
      --a[i][j];
      ++a[i][j+1];
      update(i, j, i, j+1);
    }
  }
  rep(i, h-1) {
    if (a[i][w-1]%2) {
      --a[i][w-1];
      ++a[i+1][w-1];
      update(i, w-1, i+1, w-1);
    }
  }

  int m = ans.size();
  cout << m << endl;
  rep(i, m) {
    rep(j, 4) printf("%d%c", ans[i][j]+1, j==3 ? '\n':' ');
  }
}

Measured memory_bytes: 11164
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};



typedef struct _state{
  int from,vis;
  double cost;
  _state(double ic,int ifr,int iv):cost(ic),from(ifr),vis(iv){
  };
  bool operator<(const _state&r)const{
    return cost>r.cost;
  };
}state;



main(){
  int n,m,p,a,b;
  while(scanf("%d%d%d%d%d",&n,&m,&p,&a,&b),n){
    --a,--b;
    int ti[n];
    vector<PI> V[m];
    rep(i,n)scanf("%d",ti+i);

    rep(i,p){
      int x,y,z;
      scanf("%d%d%d",&x,&y,&z);
      --x,--y;
      V[x].pb(mp(y,z));
      V[y].pb(mp(x,z));
    }

    priority_queue<state> Q;
    Q.push(state(0,a,0));

    bool cost[1<<n][m];
    memset(cost,0,sizeof(cost));
    double ans=-1;

    while(!Q.empty()){
      int from=Q.top().from,cti=Q.top().vis;
      double ccost=Q.top().cost;
      Q.pop();
      if(cost[cti][from])continue;
      cost[cti][from]=true;
      if(from==b){
        ans=ccost;
        break;
      }

      rep(i,n){
        if(cti>>i&1)continue;
        rep(j,V[from].size()){
          int to=V[from][j].first;
          int cc=V[from][j].second;
          if(cost[cti|1<<i][to])continue;
          double ncost=ccost+1.0*cc/ti[i];
          Q.push(state(ncost,to,cti|1<<i));
        }
      }
    }
    if(ans<0)puts("Impossible");
    else printf("%f\n",ans);
  }
}

Measured memory_bytes: 7776
import java.util.*;

class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      int a = Integer.parseInt(sc.nextLine());
      int b = Integer.parseInt(sc.nextLine());
      int c = Integer.parseInt(sc.nextLine());
      int d = Integer.parseInt(sc.nextLine());
      int e = Integer.parseInt(sc.nextLine());
      int k = Integer.parseInt(sc.nextLine());
      if((e - a) > k){
        System.out.println(":(");
      }else{
        System.out.println("Yay!");
      }
    }
  }
}

Measured memory_bytes: 21844
import math

a, b, deg = map(int, input().split())

c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(deg)))

s = (a+b+c)/2

area = (s * (s - a) * (s - b) * (s - c))**0.5

h = area * 2 / a

print(area)
print(a+b+c)
print(h)


Measured memory_bytes: 5724
n,k,c= map(int, input().split())
s= list(input())


# 左端から一つ探す。

v=[]
#インデックスを収納
count=0
# 丸からいくら進んだか数えておく。
vc=0
# vの現在の数

for i in range(n):
    if s[i]=='o' and vc==0:
        v.append((i,vc))
        vc+=1
    elif s[i]=='o' and count>=c:
        v.append((i,vc))
        count=0
        vc+=1
    else:
        count+=1

if len(v)>k:
    print('')
    exit()

vc=0
count=0
w=[]
#　右端から探す。
for i in range(n-1,-1,-1):
    if s[i]=='o' and vc==0:
        w.append((i,vc))
        vc+=1
    elif s[i]=='o' and count>=c:
        w.append((i,vc))
        count=0
        vc+=1
    else:
        count+=1
ans=[]
w.sort()
# 共通要素について左右にどれだけ働ける日があるかみる。

for i in range(k):
    if v[i][0]==w[i][0]:
        if v[i][1]+w[i][1]<k:
            ans.append(v[i][0])

for i in range(len(ans)):
    print(ans[i]+1)

Measured memory_bytes: 77896