akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    string c = b;
    reverse(c.begin(), c.end());
    if(a==c) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;



int main(void) {

  int bingo[3][3];
  int n;
  for (int i = 0;i < 3;i++) {
    for (int j = 0;j < 3;j++) {
      cin >> bingo[i][j];
    }
  }
  cin >> n;
  int b[10];

  for (int i = 0;i < n;i++) {
    cin >> b[i];
  }

  for (int i = 0;i < n;i++) {
    for (int j = 0;j < 3;j++) {
      for (int k = 0;k < 3;k++) {
        if (b[i] == bingo[j][k]) {
          bingo[j][k] = 0;
        }
      }
    }
  }
  int flag = 0;

  for (int i = 0;i < 3;i++) {
    if(bingo[i][0] + bingo[i][1] + bingo[i][2] == 0) flag = 1;  
  }
  for (int i = 0;i < 3;i++) {
    if(bingo[0][i] + bingo[1][i] + bingo[2][i] == 0) flag = 1;  
  }

  if(bingo[0][0] + bingo[1][1] + bingo[2][2] == 0) flag = 1;
  if(bingo[0][2] + bingo[1][1] + bingo[2][0] == 0) flag = 1;
  
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
int H,W,i,j,k,t,B[1500][1500],dp[1500][1500]={0},dp2[1500][1500]={0},R=0;


int main()
{
	scanf("%d%d",&H,&W);
	for(i=1;i<=H;i++)
		for(j=1;j<=W;j++)
			scanf("%d",&B[i][j]);
	for(i=1;i<=H;i++)
	{
		for(j=1;j<=W;j++)
			dp[i][j]=(B[i][j]+1)%2;
	}
	for(i=1;i<=H;i++)
		for(j=1;j<=W;j++)
		{
			if(B[i][j])dp[i][j]=0;
			else
			{
				dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
				R=max(R,dp[i][j]);
			}
		}
	printf("%d\n",R*R);
	return 0;
}

Measured memory_bytes: 18204
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 14:30:59 2020

@author: shinba
"""

a,b = map(str,input().split())

if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
else:
    if b == "H":
        print("D")
    else:
        print("H")
    


Measured memory_bytes: 2940
#include <stdio.h>
#define MAX 500000

/* Prototype Declaration */
void maxHeapify(int);
void buildMaxHeap();

/* Global Variables */
int H;
int A[MAX + 1];

int main() {
  int i;

  scanf("%d", &H);
  for ( i = 1; i <= H; i++ )
    scanf("%d", &A[i]);

  //Build
  buildMaxHeap();

  for ( i = 1; i <= H; i++ )
    printf(" %d", A[i]);

  printf("\n");

  return 0;
}

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

void maxHeapify(int i) {
  int left = 2 * i;
  int right = left + 1;
  int largest, tmp;

  if ( left <= H && A[left] > A[i] )
    largest = left;
  else
    largest = i;

  if ( right <= H && A[right] > A[largest] )
    largest = right;

  if ( largest != i ) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }

}

Measured memory_bytes: 2548
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
const int maxn=200010;
int n;
ll ans;
struct node
{
    int x,y;
    double a;
}p[maxn<<1];
ll sx[maxn<<1],sy[maxn<<1];
bool cmp(const node &a,const node &b)
{
    return a.a<b.a;
}
inline void check(int l,int r)
{
    if(l<=r) ans=max(ans,(sx[r]-sx[l-1])*(sx[r]-sx[l-1])+(sy[r]-sy[l-1])*(sy[r]-sy[l-1]));
}
int main()
{
    scanf("%d", &n);
    int i,j;
    for(i=1;i<=n;i++)    scanf("%d%d", &p[i].x, &p[i].y), p[i].a=atan2(p[i].x,p[i].y),p[i+n]=p[i],p[i+n].a+=2*pi;
    sort(p+1,p+2*n+1,cmp);
    for(i=1;i<=2*n;i++)  sx[i]=sx[i-1]+p[i].x,sy[i]=sy[i-1]+p[i].y;
    for(i=j=1;i<=2*n;i++)
    {
        for(;j<i&&p[j].a<=p[i].a-pi;j++,check(j,i-1));
        check(j,i);
    }
    for(;j<=2*n;check(j,2*n),j++);
    printf("%.11lf\n",sqrt((double)ans));
    return 0;
}

Measured memory_bytes: 4480
#include <sstream>
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;


int main(int ac, char* av[]){
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;
    int cnt = 0;
    while(B <= A){
        B *= 2;
        cnt ++;
    }
    while(C <= B){
        C*=2;
        cnt++;
    }
    if(cnt <= K){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
# itne me hi thakk gaye
n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
cnt = 1
ans = arr[0]
for i in range(1, n-1):
    if cnt == n-1:
        break
    if cnt == n-2:
        ans += arr[i]
        cnt += 1
    else:
        ans += 2*arr[i]
        cnt += 2
print(ans)

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

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

int main() {
	stack<int> st;

	char s[100];
	int a, b;
	while( scanf( "%s", &s ) != EOF ) {
		if( s[0] == '+' ) {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push( a + b );
		} else if( s[0] == '-' ) {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push( b - a );
		} else if( s[0] == '*' ) {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push( a * b );
		} else {
			st.push( atoi( s ) );
		}
	}

	printf( "%d\n", st.top() );
}


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

long compound(long money, long year, double per, long marg) {
	for (long k = 0; k < year; k++)
	{
		money += money * per - marg;
	}
	return money;
}

long simple(long money, long year, double per, long marg) {
	long sum = 0;
	for (long i = 0; i < year; i++)
	{
		sum += money * per;
		money -= marg;
	}
	return money + sum;
}

int main() {
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		long money, year, n;
		cin >> money >> year >> n;
		
		long maxMoney = 0;
		for (int j = 0; j < n; j++) {
			int way;
			double per;
			long marg;
			cin >> way >> per >> marg;
			if (way) {
				maxMoney = max(maxMoney, compound(money, year, per, marg));
			}
			else {
				maxMoney = max(maxMoney, simple(money, year, per, marg));
			}
		}
		cout << maxMoney << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i % 2 == 0) { continue; }
            int cnt = 0;
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) { cnt++; }
            }
            if (cnt == 8) { 
                ans++; 
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 2e5+5; 
int n,k,c,ans,pre[N],suf[N];
char s[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k),read(c),scanf("%s",s+1);
	for(ri i=1,cnt=0;i<=n;++i)
		if(s[i]=='o') pre[i]=++cnt,i+=c;
	for(ri i=n,cnt=k;i>=1;--i)
		if(s[i]=='o') suf[i]=cnt--,i-=c;
	for(ri i=1;i<=n;++i) if(suf[i]&&suf[i]==pre[i]) print(i),puts("");
	return 0;
}

Measured memory_bytes: 3200
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M],pre[M];
inline int rsum(int l,int r)
{
    return (pre[r]-pre[l-1]);
}
inline int maxi(int a,int b,int c,int d)
{
    return max(max(a,b),max(c,d));
}
inline int mini(int a,int b,int c,int d)
{
    return min(min(a,b),min(c,d));
}
 main()

{
    fast
    int n,sum=0;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
        pre[i]=sum;
    }
    int l=1,r=3,ses=inf;
    f(i,2,n)
    {
        while(l+2<=i && abs(rsum(1,l)-rsum(l+1,i)) > abs(rsum(1,l+1)-rsum(l+2,i)))l++;
        while(r+2<=n && abs(rsum(i+1,r)-rsum(r+1,n)) > abs(rsum(i+1,r+1)-rsum(r+2,n)))r++;
        int a=rsum(1,l),b=rsum(l+1,i),c=rsum(i+1,r),d=rsum(r+1,n);
        ses=min(ses,maxi(a,b,c,d)-mini(a,b,c,d));
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 6772
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int menu[7],counto=0,Key=10;
	for (int i = 0; i < 5; i++) {
		cin >> menu[i];
		if (menu[i] % 10 == 0) {
			counto += menu[i];
		}
		else {
			counto += (((menu[i] / 10) + 1) * 10);
			Key = min(Key, (menu[i] - (menu[i] / 10 * 10)));
		}
	}
	cout << counto-10+Key << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int len = s.length();
    int ans = 0;
    for(int i = len-1; i > 0; i--){
        s = s.substr(0,i);
        if(i%2!=0) continue;
        else{
            int mid = i / 2 ;
            bool f = false;
            for(int i = 0; i < mid; i++){
                if(s[i] == s[mid+i]) f = true;
                else {f=false; break;}
            }
            if(f){ans = s.length(); break;}
            else continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <sstream>
using namespace std;

int main(){
  string s;
  map<int, int> trade1, trade2;
  while(getline(cin, s)){
    if(s.size() == 0) break;
    replace(s.begin(), s.end(), ',', ' ');
    istringstream is(s);
    int t;
    is >> t;
    trade1[t]++;
  }

  while(getline(cin, s)){
    if(s.size() == 0) break;
    replace(s.begin(), s.end(), ',', ' ');
    istringstream is(s);
    int t;
    is >> t;
    trade2[t]++;
  }
  for(map<int, int>::iterator it = trade1.begin() ; it != trade1.end() ; it++){
    map<int, int>::iterator f = trade2.find(it->first);
    if(f != trade2.end()){
      cout << it->first << ' ' << it->second + trade2[it->first] << endl;
    }
  }
  return 0;
}

  

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,a,n) for(int i=a;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int sz = 1e3 + 5;
const int mod = 1e9;
int main()
{
    string s,t;cin>>s>>t;
    int ans = t.size();
    for(int i = 0;i + t.size() - 1<s.size();i++)
    {
        int p = 0,temp = 0;
        for(int j = i;j < i + t.size();j++)
        {
            if(s[j]!=t[p++])
                temp++;
        }
        ans = min(temp,ans);
    }
    cout<<ans<<endl;
}


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

long long n, k, ans;

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

    for(int i = 1; i <= n; i++){
        if(i-k >= 0){
            ans += n/i*(i-k);
            if(n % i >= k ){
                if(k != 0)  ans += n % i - k + 1;
                else ans += n % i;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<ll, int> cnt;
    rep(i,n){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    vector<ll> cand;
    for(auto p : cnt){
        if(p.second >= 4){
            cand.push_back(p.first);
        }
        if(p.second >= 2){
            cand.push_back(p.first);
        }
    }
    cand.push_back(0);
    cand.push_back(0);
    sort(cand.rbegin(), cand.rend());
    ll ans = cand[0] * cand[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val S = sc.next().toCharArray
    var prev = S(0)
    var cnt = 0
    S.foreach(c => {
      if (!c.equals(prev)) {
        prev = c
        cnt += 1
      }
    })
    println(cnt)
  }
}


Measured memory_bytes: 25300
#include<iostream>
using namespace std;
int a,b,c,ans;
int main()
{
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		c=0;
		b=i;
		while(b!=0)
		{
			b/=10;
			c++;
		}
		if(c%2==1)
			ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
typedef multiset<ll> mlset;
typedef set<ll> mset;
typedef struct node* pnode;
int main()
{
    string s;
    cin>>s;
    ll l=s.length();
    ll sum=0,ma=0;
    for(ll i=0;i<l;i++)
    {
        if(s[i]=='R')
        {
            sum++;
        }
        else
        {
            ma=max(ma,sum);
            sum=0;
        }
    }
    ma=max(ma,sum);
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << ' ' << 2*(a+b) << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n;
  int a[4][4];
  int b;
  bool st = false;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }
  }
  cin >> n;
  for(int i=0;i<n;i++){
  	scanf("%d",&b);
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(b==a[j][k])a[j][k]=0;
      }
    }
  }
  for(int i=0;i<3;i++){
    if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0){
    	st =true;
    }
  }
  for(int i=0;i<3;i++){
    if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0){
      st=true;
    }
  }
  if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) st =true;
  if(a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) st =true;
  if(st) cout <<"Yes"<< endl;
  if(!st) cout <<"No"<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
//comb　nCk
#define MAX 1000009
#define MOD 1000000007
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 x, y;
 
int main(){
    cin >> x >> y;
    COMinit();
    if(x&1){
        if((y-(x+3)/2)%3!=0 || x*2<y || y<(x+3)/2)cout << 0;
        else cout << COM((x+1)/2+(y-(x+3)/2)/3, (y-(x+3)/2)*2/3+1);
    }
    else {
        if((y-x/2)%3!=0 || x*2<y || y<x/2)cout << 0;
        else cout << COM(x/2+(y-x/2)/3, (y-x/2)*2/3);
    }
}

Measured memory_bytes: 23680
#include <cstdio>
#include <string>
using namespace std;
bool it[20000];
int n,x,ans,a[20][20];
int main()
{
	scanf("%d %d",&n,&x);
	for(int i=1;i*i<=20000;i++)
		it[i*i]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=x;j++)
			scanf("%d",&a[i][j]);
		for(int k=1;k<i;k++){
			int all=0;
			for(int l=1;l<=x;l++)
				all+=(a[i][l]-a[k][l])*(a[i][l]-a[k][l]);
			if(it[all]) ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int count = 0;
 
    for(int i = a; i <= b; i++){
        if((c % i)==0)
        count++;
    }
 
    printf("%d\n", count);

    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>
#include<cstdio>
#include<iomanip>

int main(int argc, char *argv[])
{
	ll k;

	cin>>k;
	vector<ll> a(k+1);

	ll s=0;
	ll ret=0;
	for (ll i=k;i>0;i--)
	{
		ll n=k/i;
		ll n3=n*n*n;
		for (ll j=2;i*j<=k;j++)
		{
			n3-=a[i*j];
		}
		a[i]=n3;
		//cerr<<i<<" "<<n3<<endl;
		ret+=n3*i;
		s+=n3;
	}
	cerr<<s<<endl;

	cout<<ret<<endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class Graph
{
public:
    enum
    {
        WHITE = 0,
        GRAY = 1,
        BLACK = 2,
    };

    Graph() {}
    Graph(int n)
    : color(n, WHITE), M(n, vs32(n, INFTY)), d(n, INFTY), p(n, -1)
    {}
    ~Graph() {}

    void prim(int s)
    {
        d[s] = 0;
        
        while (true)
        {
            int minv = INFTY;
            int u = -1;
            rep (i, color.size())
            {
                if (color[i] != BLACK && minv > d[i])
                {
                    minv = d[i];
                    u = i;
                }
            }

            if (u < 0) break;
            d[u] = minv;
            color[u] = BLACK;

            rep (v, color.size())
            {
                if (color[v] != BLACK && d[v] > d[u] + M[u][v])
                {
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    static const int INFTY = 1e9;
    vs32 color;
    vector< vs32 > M;
    vs32 d;
    vs32 p;
};

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

    int n;
    cin >> n;

    Graph g(n);

    int u, v;
    int w;
    int c;
    rep (i, n)
    {
        cin >> u >> c;
        rep (j, c)
        {
            cin >> v >> w;
            g.M[u][v] = w;
        }
    }

    g.prim(0);
    rep (i, n)
    {
        cout << i << " " << g.d[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //?????±?????????????????????
	ios::sync_with_stdio(false); //printf??¨??±??????????????????

	int n;
	while (n = nextInt(), n) {
		int sum = 0;
		for (int i = 0; i < n / 4; i++) {
			sum += nextInt();
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HussienMoustafa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAirConditionerEditorial solver = new AAirConditionerEditorial();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAirConditionerEditorial {
        public void solve(int testNumber, Scanner s, PrintWriter out) {
            int x = s.nextInt();
            out.println(x >= 30 ? "Yes" : "No");

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



Measured memory_bytes: 32892
fun abc121b(args: Array<String>) {
    val (N, M, C) = args[0].split(" ").map { it.toInt() }
    val B = args[1].split(" ").map { it.toInt() }
    val As = args.drop(2).map { a -> a.split(" ").map { it.toInt() } }
    val ans = As.filter {a -> (0 until B.size).map { a[it] * B[it] }.sum() + C > 0}.count()
    println(ans)
}

fun main(args: Array<String>) {
    abc121b(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 36288
from collections import deque
from copy import copy
N = int(input())
A = deque(sorted([int(input()) for _ in range(N)]))
A2 = copy(A)
d = deque()
d.append(A.popleft())
while True:
    try:
        d.append(A.pop())
        d.appendleft(A.pop())
        d.append(A.popleft())
        d.appendleft(A.popleft())
    except IndexError:
        break
ans = 0
for i in range(N-1):
    ans += abs(d[i]-d[i+1])
A = A2
d = deque()
d.append(A.pop())
while True:
    try:
        d.append(A.popleft())
        d.appendleft(A.popleft())
        d.append(A.pop())
        d.appendleft(A.pop())
    except IndexError:
        break
n = 0
for i in range(N-1):
    n += abs(d[i]-d[i+1])
print(max(ans, n))


Measured memory_bytes: 56920
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int a[200010];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	loop(i,1,n) {
		if (a[i] == a[i - 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1792
N = int(input())
if N==0:
  print(0)
  exit()
k=[]
if N%2==1:
  N = N-1
  k.append(1)
else:
  k.append(0)
for i in range(1,50):
  if (N//(-2)**i)%2==1:
    N -=(-2)**i 
    k.append(1)
  else:
    k.append(0)
  if N==0:
    break
for i in range(len(k)-1,-1,-1):
  print(k[i],end="")

"""
for bit in range(1<<30):
  ans = 0
  an = 0
  for i in range(30):
    if bit&(1<<i):
      an += k[i]
      ans += 1<<i
  if an==N:
    ans =  format(ans, 'b')
    print(ans)
    exit()
"""


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>
 
using namespace std;
 
using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
 
 
template<typename T>
T gcd(T a, T b) {
    if (a%b == 0) return b;
    return gcd(b, a%b);
}
 
 
int main(int argc, char **argv) {
    i64 k;
    cin >> k;
 
    i64 ans{0};
 
    for (int i=1; i<k+1; ++i) {
        for (int j=1; j<k+1; ++j) {
            int gcdij= gcd<int>(i,j);
            for (int l=1; l<k+1; ++l) {
                ans += gcd<int>(l, gcdij);
            }
        }
    }
 
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

const int nmax = 40;
const int abmax = 10;
const int inf = 1000000;

int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(){
	int n,ma,mb;
	cin >> n >> ma >> mb;

	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	for(int i=0;i<=n;i++){
		for(int ca = 0; ca <= nmax*abmax; ca++){
			for(int cb=0;cb<=nmax*abmax;cb++){
				dp[i][ca][cb] = inf;
			}
		}
	}

	dp[0][0][0] = 0;

	for(int i=0;i<n;i++){
		for(int ca=0;ca<=nmax*abmax; ca++){
			for(int cb=0; cb<=nmax*abmax; cb++){
				if(dp[i][ca][cb]==inf) continue;
				dp[i+1][ca][cb] = min(dp[i+1][ca][cb],dp[i][ca][cb]);
				dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
			}
		}
	}

	int ans = inf;
	for(int ca = 1; ca <= nmax*abmax; ca++){
		for(int cb = 1; cb <= nmax*abmax; cb++){
			if(ca*mb==cb*ma) ans = min(ans,dp[n][ca][cb]);
		}
	}

	if(ans == inf) ans = -1;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int n , k;
    cin >> n >> k;
    int p = pow(2 , n) - 1;
    if(n == 1 && k == 1)
    {
        cout << -1;
        return 0;
    }
    if(p < k)
    {
        cout << -1;
        return 0;
    }
    if(k == 0)
    {
        for(int i = 0; i <= p; i ++)
            cout << i << ' ' << i << ' ';
        return 0;
    }
    cout << 0 << ' ' << k << ' ' << 0 << ' ';
    for(int i = 1; i <= p; i ++)
    {
        if(i != k)
            cout << i << ' ';

    }
    cout << k << ' ';
    for(int i = p; i >= 1; i --)
    {
        if(i != k)
            cout << i << ' ';
    }
    return 0;
}


Measured memory_bytes: 1920
import sys
input = sys.stdin.readline
def print_ans(N, X, lr):
    """Test Case
    >>> print_ans(3, 6, [3, 4, 5])
    2
    >>> print_ans(4, 9, [3, 3, 3, 3])
    4
    """
    counter = 1
    ans_sum = 0
    for l in lr:
        ans_sum += l
        if ans_sum > X:
            break
        else:
            counter += 1
    print(counter)

if __name__ == '__main__':
    N, X = map(int, input().rstrip().split())
    lr = list(map(int, input().rstrip().split()))
    print_ans(N, X, lr)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		if(size[x]>size[y])swap(x,y);
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};


int main(){
	
	int N,M;
	cin>>N>>M;
	
	unionfind uf(N);
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		uf.unite(a-1,b-1);
	}
	
	int ans = 1;
	for(int i=0;i<N;i++){
		ans = max(ans,uf.get_size(i));
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 5100
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
template <typename T, typename U>
using P = pair<T,U>;
template <typename T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
  int N,M;
  cin >> N >> M;
  vt<int> X(M);
  rep(i,M)  cin >> X[i];
  sort(X.begin(),X.end());
  ll ans = 0;
  vt<int> l(M);
  for (size_t i = 1; i < M; i++)
  {
    int x = X[i] - X[i-1];
    ans += x;
    l[i-1] = x;
  }
  X.clear();
  sort(l.rbegin(),l.rend());
  rep(i,min(N-1,M))
    ans -= l[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 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 main()
{
    map<char,char> mp{{'A','T'},{'T','A'},{'G','C'},{'C','G'}};
    char a; cin >> a;
    cout << mp[a] << endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <map>

int t1,t2,t3,t4;

int n;
int nn;
int a[1<<18];

int high1[1<<18];
int high2[1<<18];

int ans=0;

std::map<int,int> m;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&n);
    nn=(1<<n);
    for (int i=0; i<nn; i++) {
        scanf("%d",a+i);
        if (a[i]>a[0]) high1[i]=i;
        else high2[i]=i;
        // get other high values
        for (int j=1; j<=i; j*=2) {
            if (!(i&j)) continue;
            // merge high1[i-j]
            if (a[high1[i]]<a[high1[i-j]] && high1[i]!=high1[i-j]) {
                high2[i]=high1[i];
                high1[i]=high1[i-j];
            }
            else if (a[high2[i]]<a[high1[i-j]] && high2[i]!=high1[i-j] && high1[i]!=high1[i-j]) {
                high2[i]=high1[i-j];
            }
            // merge high2[i-j]
            if (high2[i-j]==high1[i-j]) continue;
            if (a[high1[i]]<a[high2[i-j]] && high1[i]!=high2[i-j]) {
                high2[i]=high1[i];
                high1[i]=high2[i-j];
            }
            else if (a[high2[i]]<a[high2[i-j]] && high2[i]!=high2[i-j] && high1[i]!=high2[i-j]) {
                high2[i]=high2[i-j];
            }
        }
        if (i) {
            //printf("%d = %d + %d\n",i,high1[i],high2[i]);
            if (ans<a[high1[i]]+a[high2[i]]) {
                ans=a[high1[i]]+a[high2[i]];
            }
            printf("%d\n",ans);
        }
    }
}


Measured memory_bytes: 6144
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String hoge = br.readLine();
		int count =0;
		if(hoge.charAt(0)!='C'){
			count++;
		}
		if(hoge.charAt(1)!='O'){
			count++;
		}
		if(hoge.charAt(2)!='D'){
			count++;
		}
		if(hoge.charAt(3)!='E'){
			count++;
		}
		if(hoge.charAt(4)!='F'){
			count++;
		}
		if(hoge.charAt(5)!='E'){
			count++;
		}
		if(hoge.charAt(6)!='S'){
			count++;
		}
		if(hoge.charAt(7)!='T'){
			count++;
		}
		if(hoge.charAt(8)!='I'){
			count++;
		}
		if(hoge.charAt(9)!='V'){
			count++;
		}
		if(hoge.charAt(10)!='A'){
			count++;
		}
		if(hoge.charAt(11)!='L'){
			count++;
		}
		if(hoge.charAt(12)!='2'){
			count++;
		}
		if(hoge.charAt(13)!='0'){
			count++;
		}
		if(hoge.charAt(14)!='1'){
			count++;
		}
		if(hoge.charAt(15)!='6'){
			count++;
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 8148
#include <stdio.h>

int main() {
  int height_tower_west, height_tower_east, answer;
  scanf("%d %d", &height_tower_west, &height_tower_east);
  answer = (1 + height_tower_east - height_tower_west) * (height_tower_east - height_tower_west) / 2 - height_tower_east;
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int n,k;cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<=i+k;j++)
            if(j<n)
                dp[j] = min(dp[j],dp[i] + abs(h[i]-h[j]));

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


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

int main(){
  string s;
  cin >> s;
  int l=s.size();
  ll ans=0;
  ll a=0;
  rep(i,l-1){
    int x=s[i];
    int y=s[i+1];
    if(x=='A') a++;
    if(x=='B' and y=='C') ans+=a;
    if(x=='A' and y=='C') a=0;
    if(x=='B' and y!='C') a=0;
    if(x=='C' and y=='C') a=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


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


#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define mod 1000000007
#define maxn 300005
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


 ll ch[maxn],cw[maxn];
int main(){
	
	fastio;
    ll h,w,m,x,y;
    cin>>h>>w>>m;
    
   set<pair<ll,ll>>s;
   
   for(int i=0;i<m;i++){
   	cin>>x>>y;
   	s.insert({x,y});
   	ch[x]++;
   	cw[y]++;
   }
   ll m1 = *max_element(ch,ch+h+1);
   ll m2 = *max_element(cw,cw+w+1);
   
   ll ans=m1+m2-1;
   
   vector<ll>v1,v2;
   for(int i=0;i<maxn;i++){
   	if(ch[i] == m1)v1.pb(i);
   }
   for(int i=0;i<maxn;i++){
   	if(cw[i] == m2)v2.pb(i);
   }
   
   for(auto &i:v1){
   	for(auto &j:v2){
   		if(!s.count({i,j})){
   			cout<<ans+1;
   			rt;
   		}
   	}
   }
   cout<<ans;
   
	}


	
	
	
	



Measured memory_bytes: 35032
import java.io.*;
import java.util.StringTokenizer;

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

        int n = in.nextInt();
        int k = in.nextInt();
        out.println((int) Math.ceil((n - 1) / (double) (k - 1)));


        out.close();
        //INT OVERFLOW -> USE LONG
        //ARR OUT OF BOUNDS
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

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

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

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  vector<ll> y; //sqrtまでの約数列挙
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0) y.pb(i);
	}

  int a, b, ans = 100;

  REP(i, y.size()){
    a = 0, b = 0;
    ll z = n / y[i];
    while(y[i]){
      y[i] /= 10;
      a++;
    }
    while(z){
      z /= 10;
      b++;
    }
    ans = min(ans, max(a, b));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def A():
    n = input()
    if int(n[-1]) == 3:
        print("bon")
    elif int(n[-1]) == 0 or int(n[-1]) == 1 or int(n[-1]) == 6 or int(n[-1]) == 8:
        print("pon")
    else:
        print("hon")
A()

Measured memory_bytes: 9176
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long A[300000][61];
  int S[300000][61];
  for(int i=0;i<N;i++){
    cin>>A[i][0];
    long long k=1;
    for(int j=1;j<=60;j++){
      A[i][j]=(A[i][0]%(k*2))/k;
      S[i][j]=A[i][j];
      k*=2;
    }
  }
  for(int i=N-2;i>=1;i--){
    for(int j=1;j<=60;j++) S[i][j]+=S[i+1][j];
  }
  long long answer=0;
  for(int i=0;i<N-1;i++){
    long long k=1;
    for(int j=1;j<=60;j++){
      if(A[i][j]==1) answer+=(N-1-i-S[i+1][j])*(k%1000000007);
      else answer+=S[i+1][j]*(k%1000000007);
      answer%=1000000007;
      k*=2;
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 217536
import numpy as np


def solve():
    N, K = map(int, input().split())
    a_l = np.array(input().split(), int)
    b_l = np.array(input().split(), int)
    a_l.sort()
    b_l.sort()
    b_l = b_l[::-1]

    sum_a = a_l.sum()
    left, right = -1, 10**13
    while left + 1 < right:
        mid = (left + right) // 2
        if sum_a - np.minimum(a_l, mid // b_l).sum() <= K:
            right = mid
        else:
            left = mid

    print(right)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 37212
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a, b, c, kaijo[200010];
int mypow(int x, int y) {
	if (!y)return 1;
	if (y % 2)return mypow(x, y - 1) * x % moder;
	int memo = mypow(x, y / 2);
	return memo * memo % moder;
}
int comb(int x, int y) {
	return kaijo[x] * mypow(kaijo[x - y], moder - 2) % moder * mypow(kaijo[y], moder - 2) % moder;
}
signed main() {
	kaijo[0] = 1;
	REP(i, 200009)kaijo[i] = kaijo[i - 1] * i % moder;
	cin >> n >> a >> b >> c;
	a = a * 100 % moder * mypow(100 - c, moder - 2) % moder;
	b = b * 100 % moder * mypow(100 - c, moder - 2) % moder;
	int ans = 0, cnt = 0;
	for (int i = n; i < 2 * n; i++) {
		int memo = (mypow(a, n) * mypow(b, i - n) % moder + mypow(a, i - n) * mypow(b, n) % moder) % moder * comb(i - 1, n - 1) % moder * i % moder * mypow(mypow(100, i), moder - 2) % moder;
		ans += memo;
		ans %= moder;
	}
	cout << ans * 100 % moder * mypow(100 - c, moder - 2) % moder << endl;
	return 0;
}

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

ll gcd(ll x, ll y) {
    if(y == 0)
        return x;
    else
        return gcd(y,x%y);
}

void print_vec(vector<ll> vec) {
  cout << "{ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i) << " ";
  }
  cout << "}" << endl;
}

void solve() {
    ll N,X; cin >> N >> X;
    vector<ll> x(N);
    for(int i = 0; i < N; i++) {
        int xi;
        cin >> xi;
        x.at(i) = (abs(X-xi));
    }

    //print_vec(x);
    
    ll g = x.at(0);
    for(int i = 1; i < N; i++)
        g = gcd(x.at(i),g);

    cout << g << endl;
}

int main() {
    solve();
}


Measured memory_bytes: 1024