akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<vector>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
int x;
int main(){
    cin>>x;
    string s=to_string(x);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        puts("Yes");
    }else{
        puts("No");
    }
    
}



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

using namespace std;

int main(){
	int N; cin >> N;
	vector<pair<int, int>> P(N);
	vector<pair<int, int>> PT(N, pair<int, int>(1, 1000000000+1));
	vector<pair<int, int>> PA(N, pair<int, int>(1, 1000000000+1));
	vector<int> T(N), A(N);
	for(int &c:T) cin >> c;
	for(int &c:A) cin >> c;
	bool flag = true;

	PT[0].first = PT[0].second = T[0];
	for(int i = 0; i < N; i++) {
		if(PT[i].first == PT[i].second) continue;
		if(i>0 && T[i] > T[i-1]) {
			PT[i].first = PT[i].second = T[i];
		}
		else {
			PT[i].first = 1;
			PT[i].second = T[i];
		}
	}
	reverse(A.begin(), A.end());
	PA[0].first = PA[0].second = A[0];
	for(int i = 0; i < N; i++) {
		if(PA[i].first == PA[i].second) continue;
		if(i>0 && A[i] > A[i-1]) {
			PA[i].first = PA[i].second = A[i];
		}
		else {
			PA[i].second = min(PA[i].second, A[i]);
		}
	}

	for(int i = 0; i < N; i++) {
		if(PT[i].second < PA[N-1-i].first) {
			flag = false;
		}
		if(PT[i].first > PA[N-1-i].second) {
			flag = false;
		}
		P[i].first = max(PT[i].first, PA[N-1-i].first);
		P[i].second = min(PT[i].second, PA[N-1-i].second);
	}

	long long res = 1;
	if(!flag) res *= 0;
	for(int i = 0; i < N; i++) {
		res *= (P[i].second - P[i].first + 1);
		res %= 1000000000+7;
	}
	cout << res << endl;
	return 0;
}


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


int main(){
    int A, B;
    
    cin >> A >> B;
    
    if((A+B)%2 == 0){
        cout << (A+B)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b){
        for(int i=0;i < b; i++){
            cout<<a;}
    }
     else{
        for(int i=0;i < a; i++){
            cout<<b;}  
            
        }
        cout<<endl;
    
     
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  ll N, K;
  cin >> N >> K;
  if(K == 0){
    cout << N*N << endl;
    return 0;
  }
  ll ans = 0;
  FOR(i, 1, N+1){
    if(i <= K) continue;
    ans += (N/i)*(i-K);
    if(N % i >= K){
      ans += N % i - K+1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;
#define MOD (100000)

int dp[2][1<<20];

int main() {
    int n, m;
    char f[20][20];
    scanf("%d%d", &m, &n);
    rep (i, m) rep (j, n) scanf(" %c", f[i]+j);
    int *cur = dp[0], *nxt = dp[1];
    cur[0] = 1;
    const int nn = 1<<n, mask = nn-1, mm = mask-1;
    rep (h, m) {
        rep (i, n) {
            rep (b, nn) if (cur[b]) {
                const int bb = b&mm;
                const int o = i && (b&1);
                // J
                if (f[h][i] == 'J' || f[h][i] == '?') {
                    nxt[((bb<<1)&mask)|1] += cur[b];
                    nxt[((bb<<1)&mask)|1] %= MOD;
                }
                // O
                if (f[h][i] == 'O' || f[h][i] == '?') {
                    if (o) {
                        nxt[((bb<<1)&mask)|2] += cur[b];
                        nxt[((bb<<1)&mask)|2] %= MOD;
                    }
                    else {
                        nxt[((bb<<1)&mask)] += cur[b];
                        nxt[((bb<<1)&mask)] %= MOD;
                    }
                }
                // I
                if (f[h][i] == 'I' || f[h][i] == '?') {
                    if ((bb&(1<<(n-1)))==0) {
                        nxt[((bb<<1)&mask)] += cur[b];
                        nxt[((bb<<1)&mask)] %= MOD;
                    }
                }
                cur[b] = 0;
            }
            swap(cur, nxt);
        }
    }
    int ans = 1;
    rep (i, m) rep (j, n) if (f[i][j] == '?') ans = (ans*3)%MOD;
    rep (i, nn) {
        ans = (ans-cur[i]+MOD)%MOD;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n,a[200010],ans[200010] = {};

signed main(){
	int n,d;
	cin >> n >> d;
	d = d * 2 + 1;
	cout << (n - 1) / d + 1 << endl;
}


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

using namespace std;

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny")cout << "Cloudy";
    else if(s == "Cloudy")cout << "Rainy";
    else cout << "Sunny";
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string s;
  cin>>s;
  bool f=true;
  for(int i=0;i<(s.size())/2;i++){
    if(s[i]!=s[s.size()-i-1]) f=false;
  }
    for(int i=0;i<(s.size()-2)/2;i++){
      if(s[i]!=s[s.size()/2-1-i]) f=false;
    }
    for(int i=(s.size())/2;i<s.size();i++){
      if(s[i]!=s[s.size()-1-i]) f=false;
    }
    if(f) cout<<"Yes";
    else cout<<"No";
}

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

int main() {
    int cnt = 0;
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "Yes" << endl;
        return 0;
    }
    if (s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3472
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int team = sc.nextInt();
			if(team == 0) break;
			int Maxgame = team * (team - 1) / 2;
			int[] indexA = new int[Maxgame];
			int[] indexB = new int[Maxgame];
			int[] pointA = new int[Maxgame];
			int[] pointB = new int[Maxgame];
			for(int i = 0; i < Maxgame; i++){
				indexA[i] = sc.nextInt() - 1;
				indexB[i] = sc.nextInt() - 1;
				pointA[i] = sc.nextInt();
				pointB[i] = sc.nextInt();
			}
			String solve = solve(team,indexA,indexB,pointA,pointB);
			System.out.println(solve);
		}
	}
	
	private static String solve(int team,int[] indexA,int[] indexB,
			int[] pointA,int[] pointB){
		int[] winpoint = new int[team];
		for(int i = 0;i < indexA.length;i++){
			if(pointA[i] > pointB[i]){
				winpoint[indexA[i]] += 3;
			} else if(pointA[i] < pointB[i]){
				winpoint[indexB[i]] += 3;
			} else {
				winpoint[indexA[i]]++;
				winpoint[indexB[i]]++;
			}
		}
		int[] rank = new int[team];
		for(int i = 0; i < winpoint.length; i++){
			for(int j = 0; j < winpoint.length; j++){
				if(winpoint[i] < winpoint[j])rank[i]++;
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < rank.length; i++){
			sb.append((rank[i] + 1) + "\n");
		}
		return sb.toString().trim();
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
    int N, K; cin >> N >> K;
    vector<LL> H; H.reserve(N);
    REP0(i, N)
    {
        LL h; cin >> h;
        H.push_back(h);
    }
    SORT(H); REVERSE(H);

    LL ans = 0;
    FOR(i, K, N)
    {
        ans += H[i];
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 1e18;
string s;
const int nax = 200005;
int pref[nax],suff[nax],n;
void solve()
 {
  cin>>n>>s;
  loop(i,1,n+1)
   pref[i] = pref[i-1] + (s[i-1] == 'R');
  loopb(i,n,0)
   suff[i] = suff[i+1] + (s[i-1] == 'W');
  int ans = inf;
  loop(i,0,n+1)
   {
		 int r = pref[i];
		 int w = suff[i+1];
		 int r_to_w = n - i - w;
		 int w_to_r = i - r;
		 ans = min(ans,max(r_to_w,w_to_r));
	 }
	 cout<<ans;
  
 }  
signed main()
 {   
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0); 
   /*int t;
   cin>>t;
   loop(i,1,t+1)*/
      solve();
      
  //cerr<<END<<1.0*clock();
  return 0;
} 


Measured memory_bytes: 6864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {
        bitset<6> row(i);
        for (int j = 0; j < (1 << w); j++) {
            bitset<6> column(j);
            int cnt_b = 0;
            for (int l = 0; l < h; l++) {
                for (int m = 0; m < w; m++) {
                    if (row.test(l) and column.test(m)) {
                        if (c[l][m] == '#') cnt_b++;
                    }
                }
            }
            if (cnt_b == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	unordered_map<string, ll> mp;

	inll n;
	REP(i, n)
	{
		instr s_;
		if (mp.find(s_) == mp.end())
			mp[s_] = 1;
		else
			mp[s_]++;
	}
	inll m;
	REP(i, m)
	{
		instr t_;
		if (mp.find(t_) == mp.end())
			mp[t_] = -1;
		else
			mp[t_]--;
	}

	ll a = 0;
	ITRREP(it, mp)
	{
		a = max(a, it->second);
	}

	return OUT(a);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 10000;
    int N = s.length();
    for(int i = 0; i < N-2; i++){
        int tmp = abs((s[i] - '0')*100 + (s[i+1] - '0')*10 + s[i+2] - '0' - 753);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M; cin >> N >> M;
  VI cnt(N+1, 1);
  vector<bool> pos(N+1, false);
  pos[1] = true;
  REP(i,M){
	int x, y; cin >> x >> y;
	if(pos[x]) pos[y] = true;
	if(cnt[x] == 1 && pos[x])
	  pos[x] = false;
	cnt[x]--;
	cnt[y]++;
  }

  int ans = 0;
  FOR(i,1,N+1) if(pos[i]) ++ans;
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
  int n,m;
  cin>>n>>m;
  if(m%2==0 && (2*n-(m/2))>=0 && (m/2-n)>=0)
  {
    cout<<"Yes"<<"\n";
  }
  else
  {
    cout<<"No"<<"\n";
  }
   return(0); 
}

Measured memory_bytes: 3588
n = int(input())
A = list(map(int, input().split()))
def gcd(i, j):
    a = max(i, j)
    b = min(i, j)
    r = a%b
    if r == 0:
        return b
    else:
        return gcd(b, r)
f = gcd(A[0], A[1])      
for i in range(2, n):
    f = gcd(f, A[i])
print(f)

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

#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
  fio;
  ll t, a, n, q, k, i, l, m, c, u, f, j, p, r, x, y, s, b, d;
  cin>>n>>k;
  vector<ll>v(n,0);
  for(i=0;i<n;i++)
  cin>>v[i];c=1;
  for(i=0;i<=k-1;i++)
  c*=v[i];f=c;
  for(i=k;i<n;i++)
  {
   
	if(v[i]>v[i-k])cout<<"Yes\n";
	else cout<<"No\n";
     c=f;
  }
  return 0;
}


Measured memory_bytes: 4732
#include <iostream>
using namespace std;
#define MAX 2000
 
int main(){
    int n,m;
    int ms[MAX+1];
     
    while(true){
        cin >> n >> m;
        if(!n&&!m) break;
         
        for(int i = 0 ; i < n ; i++) cin >> ms[i];
     
        int go,t = 0,cnt = 0;
        bool flg = false;
         
        for(int i = 0 ; i < m ; i++){
            cin >> go;
            if(!flg){
                t += go;
                t += ms[t];
                cnt++;
                if(t >= n-1) flg = true;
            }
        }
        cout << cnt << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1164
import math

N,D = map(int,input().split())
ab = [[int(v) for v in input().split()] for _ in range(N)]

def check(a,b):
    distance = 0
    for x,y in zip(a,b):
        distance += (x - y) ** 2
    return math.floor(math.sqrt(distance)) == math.sqrt(distance)

ans = 0

for i in range(N):
    for j in range(i+1,N):
        ans += check(ab[i],ab[j])

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mInt = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> a(N),b(M);
	rep(i,N)scanf("%d",&a[i]);
	rep(i,M)scanf("%d",&b[i]);
	
	vector<int> c = convolution(a,b);
	
	rep(i,c.size()){
		if(i!=0)printf(" ");
		printf("%d",c[i]);
	}
	cout<<endl;
	
    return 0;
}


Measured memory_bytes: 19044
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  cout << a[0] + a[1] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

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

	string S;
	cin >> S;
	int score = 0;
	for (int i = 1; i < N; ++i)score += S[i - 1] == S[i];

	score = min(score + 2 * K, N-1);

	cout << score << endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import math

n,k = map(int,input().split())

prob = 0
for i in range(1,n + 1):
    if i >= k:
        prob += 1/n
    else:
        ratio = math.ceil(math.log2(k / i))
        prob += (1/n) * ((1/2) ** ratio)

print(prob)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;


class Solution{

public:
    int fee(int N, int K, int X, int Y){

        return N <= K ? N * X : K * X +  (N - K) * Y;
    }
};

int main() {

    int N, K, X, Y;
    scanf("%d%d%d%d", &N, &K, &X, &Y);
    printf("%d\n", Solution().fee(N, K, X, Y));
    
    return 0;
}


Measured memory_bytes: 3224
s = input()[::-1]
flag = 1
i = 0
while i < len(s):
    if s[i:i+5] == "maerd" or s[i:i+5] == "esare":
        i += 5
    elif s[i:i+6] == "resare":
        i += 6
    elif s[i:i+7] == "remaerd":
        i += 7
    else:
        flag = 0
        break

print("YES" if flag else "NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int arr[100005];
int main()
{
fast();
string s;
cin>>s;
int c=0;
for(int i=0;i<4;++i)
    if(s[i]=='+')
    c++;
    else
        c--;
    cout<<c<<endl;
}



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

int N;
int A[50], B[50];
vector<bool> op(51, true);

bool pos(int cur){
  vector<bool> p(51, false);
  p[A[cur]] = true;
  for(int m=50; m>=1; m--){
    if(op[m]){
      for(int i=1; i<=50; i++){
        if(p[i]){
          p[i%m] = true;
        }
      }
    }
  }

  return p[B[cur]];
}

bool posAll(){
  for(int i=0; i<N; i++){
    if(!pos(i))
      return false;
  }
  return true;
}

int main(){
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }

  if(!posAll()){
    cout << -1 << endl;
    return 0;
  }
  for(int i=50; i>=1; i--){
    op[i] = false;
    if(!posAll()){
      op[i] = true;
    }
  }

  long long res = 0;
  long long pow = 2;
  for(int i=1; i<=50; i++){
    if(op[i]){
      res += pow;
    }
    pow *= 2;
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int MAX = 1000000;
const int64_t mod = 1000000007;

int64_t modInverse(int64_t a, int64_t m) 
{ 
    int64_t m0 = m; 
    int64_t y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int64_t q = a / m; 
        int64_t t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

int64_t fac[MAX];
int64_t ifac[MAX];

int64_t C(int n, int k)
{
    return fac[n]*ifac[n-k]%mod*ifac[k]%mod;
}

int64_t calc(int x, int y)
{
    int64_t sum = 0;
    for (int x1=0;x1<=x;++x1)
    {
        if ((x-x1)%2==1) continue;
        int x2 = (x-x1)/2;
        // std::clog << x1 << " " << x2 << std::endl;
        int yy = x1*2+x2;
        if (yy != y) continue;
        // std::clog << "# " << x1 << " " << x2 << std::endl;
        sum = (sum + C(x1+x2,x1)) % mod;
    }
    return sum;
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    int x,y;
    fac[0] = 1;
    for (int i=1;i<MAX;++i) fac[i] = (fac[i-1]*i)%mod;
    for (int i=0;i<MAX;++i) ifac[i] = modInverse(fac[i], mod);
    std::cin >> x >> y;
    std::cout << calc(x, y) << std::endl;
    return 0;
}

Measured memory_bytes: 16000
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

int A[100001], B[100001];
char S[300010];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N;
	scanf("%d ", &N);

	fread(S, 1, N * 3, stdin);

	int r = 0, g = 0, b = 0;
	int rg = 0, gb = 0, br = 0;
	rep(i, 3 * N) {
		if (S[i] == 'R') {
			if (gb) B[gb--]++;
			else if (g) A[g--]++, rg++;
			else if (b) A[b--]++, br++;
			else r++;
		}
		else if (S[i] == 'G') {
			if (br) B[br--]++;
			else if (b) A[b--]++, gb++;
			else if (r) A[r--]++, rg++;
			else g++;
		}
		else {
			if (rg) B[rg--]++;
			else if (r) A[r--]++, br++;
			else if (g) A[g--]++, gb++;
			else b++;
		}
	}

	ll kotae = f.fac[N];
	int L = 1, R = N + 1;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (A[M]) L = M;
		else R = M;
	}
	kotae = kotae * f.fac[L] % mod;
	for (int i = L; i >= 1; i--) {
		if (A[i] > 1) {
			kotae = kotae * modpow(i, A[i] - 1) % mod;
		}
	}
	L = 1;
	R = N + 1;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (B[M]) L = M;
		else R = M;
	}
	kotae = kotae * f.fac[L] % mod;
	for (int i = L; i >= 1; i--) {
		if (B[i] > 1) {
			kotae = kotae * modpow(i, B[i] - 1) % mod;
		}
	}

	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	char nn;
	cin >> nn;
	if(nn >= 'A' && nn <= 'Z')
	{
		puts("A");
	}
	else
	{
		puts("a");
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> ii;
    ii.push_back(0);
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1])ii.push_back(i);
    }
    int mx=0;
    ii.push_back(N);
    rep(i,ii.size()-1){
      	int s=S[ii[i]]-'0';
        int y=min(i+2*K+s,(int)ii.size()-1);
        chmax(mx,ii[y]-ii[i]);
    }
    cout << mx;
}

/*



 */




Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	if(n==2) ans=a[n-1];
	else{
		ans=a[n-1];
		int i=n-2,k=n-2,x=0;
		while(1){
			ans+=a[i];
			x++;
			k--;
			if(k==0) break;
			if(x==2) i--,x=0;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5208
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<Pll> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.rbegin(), a.rend());

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));

    for(int i=0;i<n;++i) {  // 今見ている文字の index
        for(int j=0;j<=i;++j) { // 左は j 文字目まで埋まっている
            if(n-1-(i-j) >= 0) dp[j+1][n-1-(i-j)] = max(dp[j+1][n-1-(i-j)], dp[j][n-1-(i-j)] + a[i].first * abs(a[i].second-j));
            if(n-2-(i-j) >= 0) dp[j][n-2-(i-j)] = max(dp[j][n-2-(i-j)], dp[j][n-1-(i-j)] + a[i].first * abs(a[i].second-(n-1-(i-j))));
        }
    }

    ll ans = 0LL;
    for(int i=0;i<n;++i) {
        ans = max(ans, dp[i+1][i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 34612
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>

using namespace std;

int main(void) {

	int ans, i = 0,cnt = 0;
	string S;

	cin >> S;

	while (S[i + 1] != '\0') {
		if (S[i] != S[i + 1])
			cnt++;
		i++;
	}

	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	count := 0
	ans := n
	for _, c := range s {
		if c == 'E' {
			count++
		}
	}

	for _, c := range s {
		if c == 'E' {
			count--
		}
		ans = min(ans, count)
		if c == 'W' {
			count++
		}
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define h first
#define w second
vector<pair<bool,pair<int,int> > >v;
int n,m,p,q,r,i;
void Vp(bool a,int b,int c){v.push_back(make_pair(a,make_pair(b,c)));}
int main(){
	while(cin>>n&&n){
	cin>>m>>p>>q>>r;v.clear();
	Vp(1,1,r);Vp(0,r+1,n);
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
		for(i=0;i<v.size();i++){
			int a=v[i].w.h,b=v[i].w.w;bool c=v[i].h;
			if(a<=x&&x<b){Vp(c,x+1,b);b=x;}
			if(a<=y&&y<b){Vp(c,y+1,b);b=y;}
			if(0<a&&b<=x)a+=n-x,b+=n-x;
			else if(x<a&&b<=y)a+=n-x-y,b+=n-x-y;
			else if(y<a&&b<=n)a-=y,b-=y;
			v[i].w.h=a,v[i].w.w=b;
		}
	}n=0;
	for(i=0;i<v.size();i++)if(v[i].h)n+=max(0,1+min(v[i].w.w,q)-max(v[i].w.h,p));
	cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 3356
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var plen=arr.shift()-0;
   if(plen==0)break;
   var cnum=arr.shift()-0;
   var width=arr.shift()-0;
   var cspace=arr.shift()-0;
   var line=[];
   while(true){
      var str=arr.shift();
      if(str=="?")break;
      else line.push(str);
   }
   var ary=[];
   line.forEach(function(str,i){
      while(true){
         var s=str.slice(0,width);
         while(s.length!=width)s+=".";
         ary.push(s);
         str=str.slice(width);
         if(str=="")break;
      }
   });
   var und="";
   for(var i=0;i<width;i++)und+=".";
   var spa="";
   for(var i=0;i<cspace;i++)spa+=".";
   while(true){
      if(ary.length==0)break;
      var ARR=[];
      for(var i=0;i<plen;i++)ARR[i]="";
      for(var i=0;i<cnum;i++){
         for(var j=0;j<plen;j++){
            var s=ary.shift();
            if(s==undefined)s=und;
            if(i!=0)ARR[j]+=spa;
         ARR[j]+=s;
         }
      } 
      ARR.forEach(function(v){
         console.log(v);
      });
      console.log("#");
   }
   console.log("?");
}

Measured memory_bytes: 17064
// @date 2020-02-05 22:24 

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

#define ll long long

int main(void) {
    int H, N;
    scanf("%d%d", &H, &N);
    for(int i=0; i<N; i++) {
        int A;
        scanf("%d", &A);
        H-=A;
    }
    if(H<=0) puts("Yes");
    else puts("No");
    return 0;
}

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

int main() {
    int n; cin >> n;
    int a[100010];
    rep(i, 0, n) {
        scanf("%d", &a[i]);
        //0から入れていって１になるようにする
        a[i]--;
    }
    int x = 0;
    rep(i, 0, 100010) {
        //そのためx==1とする
        if (x == 1) {
            cout << i << endl;
            return 0;
        }
        x = a[x];
    }
    cout << -1 << endl;
}

Measured memory_bytes: 640
n, t = gets.split.map(&:to_i)
c = Array.new(n) { Array.new(2) }
(0..n-1).each do |i|
   x, y = gets.split.map(&:to_i)
   c[i][0] = x
   c[i][1] = y
end

d = []
(0..n-1).each do |i|
  if c[i][1] <= t
    d.push(c[i][0])
  end
end

puts d.min.nil? ? "TLE" : d.min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N / 2);
  vector<ll> b(N / 2);
  vector<ll> a_count(100000);
  vector<ll> b_count(100000);
  REP(i, N / 2) { cin >> a.at(i) >> b.at(i); }

  REP(i, N / 2) {
    a_count.at(a.at(i) - 1)++;
    b_count.at(b.at(i) - 1)++;
  }

  ll a_mode_value, b_mode_value;
  ll a_mode_count = 0, b_mode_count = 0;
  REP(i, 100000) {
    if (a_count.at(i) > a_mode_count) {
      a_mode_count = a_count.at(i);
      a_mode_value = i + 1;
    }
    if (b_count.at(i) > b_mode_count) {
      b_mode_count = b_count.at(i);
      b_mode_value = i + 1;
    }
  }

  sort(ALL(a_count));
  sort(ALL(b_count));
  reverse(ALL(a_count));
  reverse(ALL(b_count));

  if (a_mode_value == b_mode_value) {
    std::cout << min(N - a_count.at(0) - b_count.at(1),
                     N - a_count.at(1) - b_count.at(0))
              << '\n';
  } else {
    std::cout << N - a_mode_count - b_mode_count << '\n';
  }
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

//高速な素因数分解
//前処理O(N*logN), クエリO(Q*log(x_i))
template<typename T>
vector<T> smallest_prime_factors(T n) {
    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;
    for (T i = 2; i * i <= n; i++) {
    // 素数だったら
        if (spf[i] == i) {
            for (T j = i * i; j <= n; j += i) {
            // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }
    return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
            x /= spf[x];
        }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    
    auto spf = smallest_prime_factors(1000010);

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    map<int, int> mii;
    rep(i,n){
        set<int> si;
        for(auto u : factolization(v[i],spf)){
            si.insert(u);
        }
        for(auto u : si){
            mii[u]++;
        }
    }
    int cnt = 0;
    for(auto u : mii){
        // cout << u.first << " " << u.second << endl;
        chmax(cnt, u.second);
    }
    if(cnt <= 1){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    if(cnt < n){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 14860
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <utility>
#include <climits>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int cnt = 0;
vector<int> BubbleSort(vector<int> a){
    for(int i=0;i<a.size()-1;i++){
        for(int j=a.size()-1;j>=i+1;j--){
            if(a[j] < a[j-1]){
                swap(a[j],a[j-1]);
                cnt++;
            }
        }
    }
    return a;
}

int main(void){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    
    a = BubbleSort(a);
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1)cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    
    
    return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
  d=I->first,!Z[d]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

int main() {
	int n; cin >> n;
	vector<int>a(n); 
	
	int ans = 0;
	for (auto&& x : a) {
		cin >> x;
		int tmp = x;
		while (tmp % 2 == 0) {
			tmp /= 2;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int W, H;
    int x, y, r;
 
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2140
N = int(input())
S = input()

if N%2!=0:
  print("No")
else:
  check=0
  for i in range(N//2):
    if(S[i]!=S[i+N//2]):
      check=1
      break
  if check==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;

}
int KH[300001], KW[300001];
int h[300001], w[300001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), W = getint(), M = getint();

	rep(i, M) {
		KH[h[i] = getint()]++;
		KW[w[i] = getint()]++;
	}

	int saidaih = -1, hh = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			hh = 1;
		}
		else if (saidaih == KH[i]) hh++;
	}
	int saidaiw = -1, ww = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			ww = 1;
		}
		else if (saidaiw == KW[i]) ww++;
	}

	ll are = ll(hh) * ww;

	int kazu = 0;
	rep(i, M) {
		kazu += (KH[h[i]] == saidaih && KW[w[i]] == saidaiw);
	}

	printf("%d\n", saidaih + saidaiw - (kazu == are));

	Would you please return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef long long ll;

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

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

    int n, a, b;
    cin >> n >> a >> b;
    out(min(b, a * n));

    int ttttttt;
    cin >> ttttttt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b, q; cin >> a >> b >> q;
  V<lint> s(1, -1e18);
  while (a--) {
    lint x; cin >> x;
    s.push_back(x);
  }
  s.push_back(1e18);
  V<lint> t(1, -1e18);
  while (b--) {
    lint x; cin >> x;
    t.push_back(x);
  }
  t.push_back(1e18);
  while (q--) {
    lint x; cin >> x;
    int i = lower_bound(begin(s), end(s), x) - begin(s);
    int j = lower_bound(begin(t), end(t), x) - begin(t);
    lint res = 1e18;
    for (int ii : {i - 1, i}) for (int jj : {j - 1, j}) {
      res = min(res, abs(s[ii] - x) + abs(t[jj] - s[ii]));
      res = min(res, abs(t[jj] - x) + abs(s[ii] - t[jj]));
    }
    cout << res << '\n';
  }
}

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

int main() {
  int n, m, v, p;
  cin>>n>>m>>v>>p;
  long a[n];
  for (int i=0; i<n; i++) cin>>a[i];

  sort(a, a + n);

  int right = n - p;
  while (right > 0 && a[right-1] == a[right]) {
    --right;
  }
  if (right == 0) {
    cout<<n<<endl;
    return 0;
  }
  int orig_right = right;
  int left = -1;
  while (right - 1 > left) {
    int mid = (left + right) / 2;
    if (a[mid] + m < a[orig_right]) {
      left = mid;
      continue;
    }
    int v2 = v - (p - 1) - mid - 1;
    if (v2 <= 0) {
      right = mid;
      continue;
    }
    long b = a[mid] + m;
    queue<long> q;
    for (int i=mid+1; i<n-p+1; i++) {
      q.push(min(b - a[i], (long)m));
    }
    bool ok = true;
    for (int i=0; i<v2; i++) {
      int m2 = m;
      while (m2 > 0) {
        if (q.empty()) {
          ok = false;
          break;
        }
        long front = q.front();
        q.pop();
        if (front > m2) {
          q.push(front - m2);
          m2 = 0;
        } else {
          m2 -= front;
        }
      }
    }
    if (ok) {
      right = mid;
    } else {
      left = mid;
    }
  }
  cout<<n - right<<endl;
}

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

int main(){
  char C;
  cin >> C;
  if( 'A' <= C && C <='Z'){
    cout << 'A' << endl;
  }else if('a' <= C && C <='z'){
    cout << 'a' << endl;  
  }
  return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <valarray>
#include <iomanip>
using namespace std;
//vector<int> Data;


int main(void)
{
	string Data;
	cin >> Data;

	if (Data == "ABC")
	{
		cout<<"ARC" << endl;
		return 0;
	}

	cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, t;
    cin >> x >> t;
    if( x <= t ) cout << 0;
    else cout << x - t;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A,B,C,x,y; cin >> A >> B>> C >> x >> y;
    ll res = 1e9;
    for (int c=0;c<=2*max(x,y);c++){
        int a = max(0,x - c/2);
        int b = max(0,y - c/2);
        res = min(ll(A*a+B*b+C*c),res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    if(x==w/2&&y==h/2){
        cout<<h*w/2<<" "<<1<<endl;
    }else{
        cout<<h*w/2<<" "<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        char[] xs = new char[s.length()];
        
        
        //int n = Integer.parseInt(sc.next());
        
        for(int i = 0; i < xs.length; i++) {
            xs[i] = 'x';
        }
        System.out.println(new String(xs));
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long a,b,c,d,x,y;
	cin >> a >> b >> c >> d;
	x = std::min(a,b); 
	y = std::min(c,d);
	cout << x+y << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void READ() {
#define R READ();
#define INFI 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MEMX(x,num) memset(x,num,sizeof(x))
#define prln(x) cout<<#x<<"="<<x<<endl
#define prt(x) cout<<x<<endl
#define prk(x) x<<" "
#define sz(x) int(x.size())
#define PB(x) push_back(x)
#define LINK(x,y) G[x].PB(y),G[y].PB(x)
#ifndef ONLINE_JUDGE
    freopen("A.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(3);
}
///////////////////////////
const int N=5 +2e5;


int n;
int a[N],b[N];
int main() {
    
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int m1=b[n/2-1],m2=b[n/2];
    for(int i=0;i<n;i++)
    {
        if(a[i]>m1)cout<<m1<<endl;
        else cout<<m2<<endl;
    }



    return 0;
}


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

int main(void)
{
  int i, j;

  for(i = 1 ; i <= 9 ; i++)
    {
      for(j = 1 ; j <= 9 ; j++)
	{
	  cout << i << 'x' << j << '=' << i * j << endl;
	}
    }
  return 0;
}

Measured memory_bytes: 0
N = int(input())

one = [1]
six_multi = [6, 6**2, 6**3, 6**4, 6**5, 6**6]
nine_multi = [9, 9**2, 9**3, 9**4, 9**5]
deposit = one + six_multi + nine_multi

dp = [10**10 for _ in range(N+1)] 
dp[0] = 0

for i in range(0, N):
    for d in range(len(deposit)):
        if i+deposit[d] <= N:
            dp[i+deposit[d]] = min(dp[i+deposit[d]], dp[i] + 1)

print(dp[N])



Measured memory_bytes: 3864