akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int q;
    cin >> q;
    int L[q], R[q], ma = 0, mi = 1e9;
    for(int i = 0; i < q; i++){
        cin >> L[i] >> R[i];
        mi = min(mi, L[i]);
        ma = max(ma, R[i]);
    }
    int A[ma + 1] = {};
    fill(A, A + ma + 1, 1);
    A[0] = A[1] = 0;
    for(int i = 2; i <= sqrt(ma); i++){
        if(A[i]){
            for(int j = i + i; j <= ma; j += i){
                A[j] = 0;
            }
        }
    }

    int B[ma + 1] = {};
    for(int i = mi; i <= ma; i++){
        if(A[i] and A[(i + 1) / 2]){
            B[i] = 1;
        }
    }
    for(int i = 1; i <= ma; i++){
        B[i] = B[i] + B[i - 1];
    }

    for(int i = 0; i < q; i++){
        int cnt = B[R[i]] - B[L[i] - 1];
        cout << cnt << endl;
    }

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
//ABC099A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	if(n < 1000){
		cout << "ABC" << endl;
	}else{
		cout << "ABD" << endl;
	}
	return 0;
}

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

//highlight color RGB = [70,70,70]
#define asll unsigned long long
#define ll long long
#define ld long double
#define imt int
#define pii pair<int,int>
#define st first
#define nd second
#define kj <<" "<<
#define kjb <<" ";
#define dg <<","<<
#define ml <<endl;
#define co cout<<
#define ter cout<<endl;
#define sibi cout<<"TES"<<endl;
#define tes(x) cout<<"TES "<<x<<endl;
#define psbk(x) push_back(x);
#define For(x,a,b) for(int x=(a);x<(b);x++)
#define FOR(x,n) for(int x=0;x<(n);x++)
#define kera(x,m) for( int i = 0;i < m ; i++ ){ cout<<"x["<< i <<"] =" kj x[i] ml}
#define kpr(x) cout<<"("<<x.st dg x.nd <<")" ml
#define kkor(p) cout<<"("<<p.x dg p.y <<")" ml
#define m_p make_pair
asll M=1e9+7;
int n,m,tc;
int p,q,r;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	srand(time(0));
	string s;
	getline(cin,s);
	if(s[s.size()-1]=='s'){
		cout<<s<<"es" ml
	}
	else{
		cout<<s<<"s" ml
	}
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
  int N, M;
  std::map<std::string, int> words{};
  std::string s;

  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> s;
    ++words[s];
  }

  std::cin >> M;
  for (int i = 0; i < M; ++i) {
    std::cin >> s;
    --words[s];
  }

  int max = -1000;
  for (const auto &v : words) {
    max = std::max(max, v.second);
  }
  std::cout << (max > 0 ? max : 0) << std::endl;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
count=0
if a>=b:
	big=a
	sml=b
else:
	big=b
	sml=a

i=sml
while i!=0:
	if big%i==0 and sml%i==0:
		count+=1
		if count==k:
			print(i)
			break
	i-=1 

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
const int M = 1e6+5;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<int> cnt(M, 0);
	for (auto x : a) {
		if (cnt[x] != 0) {
			cnt[x] = 2;
			continue;
		} 
		for (int j = x; j < M; j += x) cnt[j]++;
	}
	int ans = 0;
	for (auto x : a) {
		if (cnt[x] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
void upd(ll &x, ll y) {
	x = (x + y) % mod;
}
struct Mat {
	ll a[3][3];
	Mat() {
		memset(a, 0, sizeof a);
	}
	ll *operator [] (int x) {
		return a[x];
	}
	Mat operator * (Mat b) {
		Mat c;
		for(int i = 0 ; i < 3 ; ++ i) {
			for(int j = 0 ; j < 3 ; ++ j) {
				for(int k = 0 ; k < 3 ; ++ k) {
					upd(c[i][j], a[i][k] * b[k][j] % mod);
				}
			}
		}
		return c;
	}
};
Mat pw(Mat a, ll b) {
	Mat r;
	for(int i = 0 ; i < 3 ; ++ i) {
		r[i][i] = 1;
	}
	for( ; b ; b >>= 1, a = a * a) {
		if(b & 1) {
			r = r * a;
		}
	}
	return r;
}

Mat base, coef_non, coef_has;

int main() {

	base[0][2] = 1;
	coef_has[0][0] = coef_has[1][0] = coef_has[2][0] = coef_has[1][1] = coef_has[2][2] = 1;
	coef_has[2][1] = 2;

	coef_non[0][0] = coef_non[1][0] = coef_non[2][0] = coef_non[1][1] = coef_non[0][2] = coef_non[1][2] = 1;
	coef_non[2][1] = coef_non[2][2] = 2;
	

	int n, m, lst = 0; scanf("%d%d", &n, &m);
	for(int i = 1, x ; i <= m ; ++ i) {
		scanf("%d", &x);
		base = base * pw(coef_non, x - lst - 1) * coef_has;
		lst = x;
	}
	if(lst < n) {
		int x = n;
		base = base * pw(coef_non, x - lst - 1) * coef_has;
	}

	// for(int i = 0 ; i < 3 ; ++ i) {
	// 	for(int j = 0 ; j < 3 ; ++ j) {
	// 		printf("%lld ", (base[i][j] % mod + mod) % mod);
	// 	}
	// 	puts("");
	// }
	printf("%lld\n", (base[0][0] % mod + mod) % mod);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl;
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	int s; double w, h; char c;
	while (cin >> s >> c >> w >> c >> h) {
		double bmi = w / pow(h, 2);
		if (25 <= bmi)Cout(s);
	}
}


Measured memory_bytes: 3208
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

vs split(string str, char sep) {
	vs v; stringstream ss(str); string t;
	while (getline(ss, t, sep)) v.push_back(t);
	return v;
}

void init_global() {};

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

	int N, M; cin >> N >> M;
	vs A(N); REP(i, N) cin >> A[i];
	vs B(M); REP(i, M) cin >> B[i];

	bool match;
	FOR(i,0,N-M+1) {
		FOR(j,0,N-M+1) {
			match = true;

			FOR(x,0,M) {
				FOR(y,0,M) {
					if (A[i+x][j+y] != B[x][y]) {
						match = false;
						break;
					}
				}
				if (!match) break;
			}

			if (match) break;
		}
		if (match) break;
	}

	string ans = match ? "Yes" : "No";
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/










int N, A[6];
//---------------------------------------------------------------------------------------------------
vector<vector<int>> B = { {0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0} };
int get(vector<int> v) {
    rep(i, 0, 6) {
        int ok = 1;
        rep(j, 0, 3) if (v[j] != B[i][j]) ok = 0;
        if (ok) return i;
    }
    assert(0);
}
//---------------------------------------------------------------------------------------------------
#define yes "yes"
#define no "no"
string solve() {
    vector<int> v;
    v.push_back(0);
    rep(i, 0, 6) v.push_back(i);

    do {
        int s = 0, t = -1;
        rep(i, 1, 7) if (v[i] == 0) t = i;
        assert(1 <= t);

        vector<int> cnt(6);
        rep(i, s, t) {
            int a = v[i];
            int b = v[i + 1];

            vector<int> w;
            rep(u, 0, 3) rep(v, 0, 3) if (B[a][u] == B[b][v]) w.push_back(v);
            cnt[get(w)]++;
        }

        int ok = 1;
        rep(i, 0, 6) if (cnt[i] > A[i]) ok = 0;
        if (ok) {
            return yes;
        }
    } while (next_permutation(all(v)));

    return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) {
        int w; cin >> w;
        vector<int> v = { 0, 1, 2 };
        rep(j, 0, w) {
            int a; cin >> a;
            if (a == 0) swap(v[0], v[1]);
            else swap(v[1], v[2]);
        }

        A[get(v)]++;
    }

    cout << solve() << endl;
}


Measured memory_bytes: 3248
#include <iostream>
#include <list>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
const int M_value = 100100;
int main() {
    ll N,W;
    cin >> N >> W;
    vector<ll> Wg(N),V(N);
    for(int i=0;i<N;i++){
        cin >> Wg[i] >> V[i];
    }
    vector<vector<ll>> dp(N+10,vector<ll>(M_value));
    for(int i=0;i<N+10;i++){
        for(int j=0;j<M_value;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int v=0;v<M_value;v++){
            if(v-V[i]>=0){
                dp[i+1][v] = min(dp[i][v],dp[i][v-V[i]]+Wg[i]);
            }
            else dp[i+1][v] = dp[i][v];
        }
    }
    ll ans=0;
    for(int v=0;v<M_value;v++){
        if(dp[N][v]<=W) ans=v;
    }
    cout << ans << endl;
}

Measured memory_bytes: 87296
#include <stdio.h>

int
main(void)
{
  int a, b;
  scanf("%d%d", &a, &b);
  if (a > b) {
    printf("a > b\n");
  } else if (a < b) {
    printf("a < b\n");
  } else {
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 1716
#include <stdio.h>

int main(void){
  int A, B, K, i, count;

  scanf("%d %d %d", &A, &B, &K);
  count=0;
  int array[100];
  for(i=100;i>0;i--){
    if(A%i==0&&B%i==0){
      array[count]=i;
      count+=1;
    }
  }
  printf("%d\n", array[K-1]);
  return 0;
}


Measured memory_bytes: 128
from collections import Counter
 
N = int(input())
 
ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))
 
    if s not in ans:
        ans[s] = 0
 
    else:
        ans[s] += 1
        answer += ans[s]
 
print(answer)

Measured memory_bytes: 18236
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
 
using namespace std;
 
const int T = 86400;
const double EPS = 1e-8;
const int N = 3;
 
int n;
double m;
double data[T];
 
bool check(double d){
  double tmp[N];
  double sum = m;
  for(int j=0;j<N;j++){
    for(int i=0;i<T;i++){
      sum -= data[i];
      sum = min(sum + d, m);
      if(sum < 0.0 - EPS) return false;
    }
    tmp[j] = sum;
  }
  if(tmp[N-2] - EPS < tmp[N-1]) return true;
  return false;
}
 
main(){
  while(cin >> n >> m && n){
    fill(data, data+T, 0.0);
    for(int i=0;i<n;i++){
      int s, t;
      double r;
      cin >> s >> t >> r;
      for(int j=s;j<t;j++) data[j] = r;
    }
    double l = 0.0;
    double r = 1e8;
    while(abs(l-r) >= EPS){
      double mid = (l + r) / 2.0;
      if(check(mid)) r = mid;
      else l = mid;
    }
    printf("%.7f\n", l);
  }
}

Measured memory_bytes: 1920
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    xy[i] = [[] for _ in range(a)]
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        xy[i][j].append(x)
        xy[i][j].append(y)

ans = 0
for bit in range(2**n):
    flag = True
    for i in range(n):
        if bit & (1 << i):
            for j in xy[i]:
                x = j[0]
                y = j[1]
                b = bit & (1 << x)
                if (b and y) or (b == 0 and y == 0):
                    continue
                else:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        ans = max(ans, bin(bit).count('1'))
print(ans)


Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   string s;
   cin >> s;
   s[3]='8';
   cout << s << endl;
}

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

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

#include <vector>
#include <utility>


#include <algorithm>


int cnt[30];
char s[11000];

bool check(int tgt, int k) {
	queue<int> q;
	REP(i, tgt) q.push(k);

	REP(i,26) {
		for (int j = 0; j < min(tgt, cnt[i]); j++) {
			int t = q.front();
			q.pop();
			q.push(t-1);
		}
	}
	
	return q.front() <= 0;
}

void solve() {
	int n, k;
	scanf("%d %d", &n, &k);

	REP(i,n) {
		scanf("%s", s);
		cnt[s[0]-'A']++;
	}

	int ans = 0;

	int st = 0, ed = n;
	while (st < ed) {
		int md = (st+ed+1)/2;
		if (check(md, k)) st = md;
		else ed = md-1;
	}
	printf("%d\n", st);
}


int main() {
    solve();
}




Measured memory_bytes: 384
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest117-B
#  TODO https://atcoder.jp/contests/abc117/tasks/abc117_b

def solveProblem(lengthList):
	sortedList = sorted(lengthList,reverse=True)
	allIntegerSum = sum(lengthList)
	maxInteger = sortedList.pop(0)
	anotherIntegerSum = allIntegerSum - maxInteger
	if maxInteger < anotherIntegerSum:
		answer="Yes"
	else:
		answer="No"
	return answer

if __name__ == '__main__':
	_ = input()
	lList = list(map(int,input().strip().split(' ')))
	solution = solveProblem(lList)
	print("{}".format(solution))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int a[n];
 int i;
 for(i=0;i<n;i++)
 cin>>a[i];
 int dp[n];
 dp[0]=0;
 dp[1]=abs(a[1]-a[0]);
 for(i=2;i<n;i++)
 {
 	dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
 	//cout<<dp[i]<<endl;
 }
 cout<<dp[n-1]<<endl;
 return 0;
}


Measured memory_bytes: 1024
#include<iostream>
int main() {

  int n,i,j,c;
  int list[999999];
  for(i=0;i<999999;i++)list[i]=i+2;
  for(j=2;j*j<999999+3;j++)
    if(list[j-2]!=0)
      for(i=1;j-2+list[j-2]*i<999999+1;i++)
	list[j-2+list[j-2]*i]=0;
  while(std::cin>>n){
    c=0;
    for(i=0; i<n-1; i++)
      if(list[i]!=0)c++;

    std::cout<<c<<"\n";
  }
}

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

string S, T;

int main () {
  cin >> S >> T;
  int ans = 0;
  rep(i,3) {
    if(S[i] == T[i]) ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int D;
    cin >> D;
    string S = "Christmas";
    string eve = " Eve";
    rep(0, i, 25 - D)
    {
        S += eve;
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

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); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, ll T, vector<ll> t) {
  ll res = 0;
  REP(i,N) {
    if (i == N - 1) res += T;
    else res += min(T, t[i + 1] - t[i]);
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll T;
	scanf("%lld", &N);
	vector<ll> t(N-1+1);
	scanf("%lld", &T);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &t[i]);
	}
	solve(N, T, t);
	return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

vector<int> yakusu(int n){
    vector<int> res;
    for(int i = 1; i*i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(n / i != i) res.push_back(n / i);
        }
    }
    return res;
}

int main(){

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        const auto &vec = yakusu(i);
        if(vec.size() == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
S = list(input())

if len(S)%2 != 0:
    print("No")
    sys.exit(0)
else:
    i = int(len(S)/2)
    T = S[0:i]
    if T*2 == S:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	string S;
	cin >> S;
	int n = (int)S.size();
	string ans = "WA";
	if (S[0] == 'A') {
		int count_C = 0;
		for (int i = 2; i < n - 1; i++) {
			if (S[i] == 'C') count_C++;
		}
		if (count_C == 1) {
			bool ok = true;
			for (int i = 1; i < n; i++) {
				if ('A' <= S[i] && S[i] <= 'Z') {
					if (S[i] == 'C' && (2 <= i && i < n - 1)) continue;
					else ok = false;
				}
			}
			if (ok) ans = "AC";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 1000000000+7
using namespace std;
using pii=pair<int,int>;



vector<int64_t> fac, finv, inv;

// テーブルを作る前処理
void COMinit(int MAX, int MOD) {
    fac=vector<int64_t>(MAX);/*n!のデーブル　*/
    finv=vector<int64_t>(MAX);/*n!の逆元のテーブル*/
    inv=vector<int64_t>(MAX);/*nの逆元のテーブル*/

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

// 二項係数計算 nCkを与える
int64_t COM(int MOD, 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;
}


int main(){
    int n, m;
    cin>>n>>m;
    int64_t ans=0;
    COMinit(m+100,INF);
    ans=fac[m]*finv[m-n];
    ans%=INF;
    for(int i=1;i<=n;i++){
        int64_t tmp=COM(INF,n,i)*fac[m-i];
        tmp%=INF;
        tmp*=finv[m-n];
        tmp%=INF;
        if(i%2==1){
            tmp*=-1;
        }
        ans+=tmp;
        ans+=INF;
        ans%=INF;
    }

    ans*=fac[m];
    ans%=INF;
    ans*=finv[m-n];
    ans%=INF;

    cout<<ans<<endl;

}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

const int MAX = 1e6;
ll pa, pb;

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll f[MAX], finv[MAX];

ll modcomb(ll n, ll r) {
  if (r < 0 || n < r) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll prob(ll a, ll b) {
  return modpow(pa, a) * modpow(pb, b) % mod * modcomb(a + b, a) % mod;
}

void init() {
  f[0] = 1, finv[0] = 1;
  FOR(i, 1, MAX) {
    f[i] = f[i - 1] * i % mod;
    finv[i] = modinv(f[i]);
  }
}

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

  init();
  pa =  modinv(a + b) * a % mod;
  pb = modinv(a + b) * b % mod;
  ll res = 0;
  rep(i, n) {
    res = (res + prob(n - 1, i) * (n + i) % mod * pa) % mod;
    res = (res + prob(i, n - 1) * (n + i) % mod * pb) % mod;
  }
  res = res * (a + b + c) % mod * modinv(a + b) % mod;
  cout << res << endl;


  
  return 0;
}

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

int main()
{
    ll n;
    string s;
    cin >> n >> s;
    set<char> s1;
    size_t ans = 0;
    rep(i, n-1){
        s1.insert(s[i]);
        set<char> e(begin(s)+i+1, end(s));
        set<char> result;
        set_intersection(s1.begin(), s1.end(), e.begin(), e.end(), inserter(result, result.end()));
        ans = max(result.size(), ans);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  S += " ";
  int mx = 0;
  for (int i = 0, cnt = 0; i < S.size(); i++) {
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') cnt++;
    else mx = max(mx, cnt), cnt = 0;
  }
  cout << mx << "\n";
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())
px = list()

for i in range(M):
    px.append(list(map(int,input().split())))

for i in range(M):

    ans = sum(T) - (T[px[i][0]-1] - px[i][1])
    print(ans)
    

Measured memory_bytes: 3064
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var c = Console.ReadLine().ToCharArray();
            var ans = (int)c[0]+1;
            Console.WriteLine((char)ans);
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long
#define INF 10000000000000000
using namespace std;
int n;
int a[200005];
bool vis[200005][2];
int dp[200005][2];
//0-> take either
//1->take the second one
int even(int i, int bound){
    if(i>=n) return 0;
    if(vis[i][bound]) return dp[i][bound];
    int tr = -INF;
    if(bound==0) tr = max(tr, a[i] + even(i+2, 0));
    tr = max(tr, a[i+1] + even(i+2, 1));
    vis[i][bound] = true;
    return dp[i][bound] = tr;
}
int odd(int i){
    if(i>=n) return 0;
    if(vis[i][0]) return dp[i][0];
    int tr = -INF;
    tr = max(tr, a[i] + odd(i+2));
    tr = max(tr, even(i+1, 0));
    vis[i][0] = true;
    return dp[i][0] = tr;
}
int32_t main() {
    cin>>n;
    for(int i = 1;i<=n;i++) cin>>a[i];
    for(int i = 1;i<=n;i++) vis[i][0] = vis[i][1] = false;
    if(n%2) cout<<odd(1)<<endl;
    else cout<<even(1, 0)<<endl;
    return 0;
}
//-2 4 5 5 6 8
//8 -2 6 4 5 5
//5 5 4 6 -2 8

Measured memory_bytes: 13388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	if(b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, i;
	scanf("%d",&n);
	i = n%10;
	if (i==2 || i==4 || i==5 || i==7 || i==9)
		printf("hon");
	else if (i==0 || i==1 || i==6 || i==8)
		printf("pon");
	else
		printf("bon");
	return 0;
	
}

Measured memory_bytes: 1732
/*input
10 2
bbaabbbaab

*/

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N, K;
	string S;
	cin >> N >> K >> S;
	S += S;
	reverse(S.begin() + N, S.begin() + 2 * N);

	int idx = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (S[idx + j] < S[i + j]) break;
			if (S[idx + j] > S[i + j]) {
				idx = i;
				break;
			}
		}
	}

	int idx2 = idx;
	for (; idx2 < idx + N && S[idx] == S[idx2]; ++idx2);

	--K;
	int part1 = ((N / (idx2 - idx)) >> K) ? ((idx2 - idx) << K) : N;
	for (int i = 0; i < part1; ++i) putchar(S[idx]);
	for (int i = part1; i < N; ++i) putchar(S[idx2 + (i - part1)]);
	putchar('\n');
}

Measured memory_bytes: 256
N = int(input())
c0 = c1 = c2 = c3 = 0

for i in range(N):
  judge = input()
  if judge == "AC":
    c0 += 1
  elif judge == "WA":
    c1 += 1
  elif judge == "TLE":
    c2 += 1
  else:
    c3 += 1

print("AC x " +str(c0))
print("WA x " +str(c1))
print("TLE x "+str(c2))
print("RE x " +str(c3))

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

def f(num):
  return num*(num+1)/2

n1 = int(n/3)
n2 = int(n/5)
n3 = int(n/15)

sm = f(n)- 3*f(n1)-5*f(n2) + 15*f(n3)
# f(n)- 3*f(int(n/3))

print(int(sm))

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

using namespace std;

int main()
{
  string s;

  cin >> s;
  int a = 1000000, z = 0, ans = 0;
  bool active = false;

  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == 'A')
    {
      if (a > i)
      {
        a = i;
      }
    }
    if (s[i] == 'Z')
    {
      if (z < i)
      {
        z = i;
      }
    }
  }

  cout << z - a + 1 << "\n";
}

Measured memory_bytes: 640
n,q = map(int,input().split())
 
a = [0] * (n-1)
b = [0] * (n-1)
info = [[] for _ in range(n)]
 
for i in range(n-1):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    info[a[i]].append(b[i])
    info[b[i]].append(a[i])
 
p = [0] * q
x = [0] * q
 
 
for j in range(q):
    p[j],x[j] = map(int,input().split())
    p[j] -= 1
 
plus = [0] * n
 
for j in range(q):
    plus[p[j]] += x[j]
 
state = [0] * n
state[0] = 1
cur = [0]
 
child = [[] for _ in range(n)]
par = [0] * n
 
ranklist = [[1]]
 
#print(cur)
#print(info)
 
while cur != []:
    cur2 = []
    ranklist.append([])
    for obj in cur:
        for obj2 in info[obj]:
            if state[obj2] == 0:
                state[obj2] = 1
                #child[obj].append(obj2)
                par[obj2] = obj
                cur2.append(obj2)
                ranklist[-1].append(obj2)
    cur = cur2[:]
 
ans = [0] * n
ans[0] = plus[0]
 
for l in ranklist:
    for t in l:
        ans[t] = ans[par[t]] + plus[t]
 
print(" ".join(map(str,ans)))

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

int main() {
    int n,count = 0;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    for (int i = 1; i < n+1; i++){
            if(i % 2 != 0 && data.at(i-1) % 2 != 0)count ++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
N,M = map(int, input().split())
F = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    F[a].append(b)
    F[b].append(a)
    
# 交友関係グループ（辞書型）
D = {}
# グループの親
parent = [-1] * N
# 訪問管理
visited = [False] * N

for root in range(N):
    if visited[root]:
        continue

    D[root] = set([root])
    # 訪問先のスタック
    stack = [root]
    # 訪問先が無くなるまで
    while stack:
        # 訪問者をポップアップ
        n = stack.pop()
        # 訪問者を訪問済み
        visited[n] = True
        # 訪問者のグループの親を設定
        parent[n] = root

        # root のフレンドをグループと訪問先に追加
        for to in F[n]:
            if visited[to]:
                continue
            D[root].add(to)
            stack.append(to)
print(max(map(len,D.values())))

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

int main(){
    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for(int i = l; i <= r;i++){
        if(i%d==0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define true 1
#define false 0
int *A;
  int *m;
 int n;
int main(){

  int q;
  int flug=0;
  int i,j;
  
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  m = (int *)malloc(sizeof(int) * q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
    if(solve(j,m[i])== 1){
      flug = 1;
      }
    }
    if(flug == 1 ) {
      printf("yes\n");
    }else{
      printf("no\n");
    }
    flug =0;
  }
}

int solve(int i,int m){
  int res;
  if(m==0){
    return true;
  }
  if(i >= n){
    return false;
  }
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

/*
void makeCombination(){
  int i;
  for(i=0;i<n;i++){
    S[i] = 0;
  }
  rec(0);
}

void rec(int i){
  if(i==n){
    print("%d",S[i])
      return 1;
  }
    rec(i+1);
    S[i] = 1;
    rec(i+1);
    S[i] = 0;
  }
}
*/



Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var in = newIo(bufio.NewScanner(os.Stdin))

func main() {
	in.setSplit(bufio.ScanLines)
	var fline = strings.Split(in.next(), " ")
	var a, b, c = perseInt(fline[0]), perseInt(fline[1]), perseInt(fline[2])

	print(solve(a, b, c))
}

func print(result int) {
	fmt.Println(result)
}

func solve(a int, b int, c int) int {
	ar := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ar)))
	return ar[0]*10 + ar[1] + ar[2]
}

type io struct {
	sc *bufio.Scanner
}

func newIo(sc *bufio.Scanner) *io {
	i := new(io)
	i.sc = sc
	i.sc.Split(bufio.ScanWords)
	return i
}

func (i *io) setSplit(f bufio.SplitFunc) {
	i.sc.Split(f)
}

func (i *io) nextIntSlice(y int, delim string) [][]int {
	result := make([][]int, y)
	for j := 0; j < y; j++ {
		line := i.next()
		result[j] = perseIntSlice(strings.Split(line, delim))
	}
	return result
}

func (i *io) next() string {
	i.sc.Scan()
	return i.sc.Text()
}

func (i *io) nextInt() int {
	return perseInt(i.next())
}

func (i *io) nextLong() int64 {
	return perseLong(i.next())
}

func perseInt(s string) int {
	in, _ := strconv.Atoi(s)
	return in
}

func perseLong(s string) int64 {
	in, _ := strconv.ParseInt(s, 10, 64)
	return in
}

func perseIntSlice(s []string) []int {
	var r = make([]int, len(s))
	for i := 0; i < len(s); i++ {
		r[i] = perseInt(s[i])
	}
	return r
}


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 20;
int n;
const LL M = 1e9 + 9;
vector<LL> bez[26][N];
vector<string> by_len[N];

inline LL get_hash(const string& s, int id = 0){
	LL res = 0;
	RFOR(i, SZ(s), id){
		res = res * M + s[i];
	}
	return res;
}

inline bool has(const vector<LL>& vec, LL x){
	auto it = lower_bound(ALL(vec), x);
	return it != vec.end() && (*it == x);
}

int cnt[26];

inline int calc(const string& s){
	FILL(cnt, 0);
	for(auto i: s) cnt[i - 'a']++;
	int ans = 0;
	LL res = 0;
	int len = 0;
	RFOR(i, SZ(s) + 1, 0){
		if (i < SZ(s)){
			res = res * M + s[i], len++;
			cnt[s[i] - 'a']--;
		}
		
		FOR(ch, 0, 26) if (cnt[ch]){
			ans += has(bez[ch][len], res);
		}
	}
	
	return ans;
}

inline void add(const string& s){
	const int len = SZ(s);
	bez[s[0] - 'a'][len - 1].PB(get_hash(s, 1));
}

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

	cin >> n;
	FOR(i, 0, n){
		string s; cin >> s;
		by_len[SZ(s)].PB(s);
	}
	
	LL ans = 0;
	FOR(len, 1, N) if (SZ(by_len[len])){
		for(auto s: by_len[len]){
			ans += calc(s);
		}
		
		for(auto s: by_len[len]){
			add(s);
		}
		
		FOR(ch, 0, 26) sort(ALL(bez[ch][len - 1]));
	}
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 675612
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
		  sim > struct rge { c b, e; };
		  sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
		  sim > auto dud(c* x) -> decltype(cout << *x, 0);
		  sim > char dud(...);
		  struct debug {
#ifdef LOCAL
			  ~debug() { cout << endl; }
			  eni(!=) cout << boolalpha << i; ris; }
		  eni(==) ris << range(begin(i), end(i)); }
		  sim, class b dor(pair < b, c > d) {
			    ris << "(" << d.first << ", " << d.second << ")";
		  }
sim dor(rge<c> d) {
	  *this << "[";
	    for (auto it = d.b; it != d.e; ++it)
		    	*this << ", " + 2 * (it == d.b) << *it;
	      ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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

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

  cin >> X;
  cout << (360 / gcd(X, 360)) << endl;

  return 0;
}


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

int main() {

	ll n; cin >> n;
	vector<ll> x(n), y(n), h(n);
	ll index;
	for (ll i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (0 < h[i]) index = i;
	}
	const ll p = 100;
	ll ansCx, ansCy, ansH;
	for (ll cx = 0; cx <= p; cx++) {
		for (ll cy = 0; cy <= p; cy++) {
			ll ansH = h[index] + abs(x[index] - cx) + abs(y[index] - cy);
			bool ok = true;
			for (ll i = 0; i < n; i++) {
				if (0 < h[i] &&  h[i] != ansH - abs(x[i] - cx) - abs(y[i] - cy)) {
					ok = false;
				}
				if (0 == h[i] && h[i] < ansH - abs(x[i] - cx) - abs(y[i] - cy)) {
					ok = false;
				}
			}
			if (ok) {
				ansCx = cx;
				ansCy = cy;
				cout << ansCx << " " << ansCy << " " << ansH << endl;
				return 0;				
			}
		}
	}	
	return 0;
}

Measured memory_bytes: 3588
h,w,m=map(int,input().split())
d=dict()
s=set()
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=map(int,input().split())
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[x*10**6+y]=1
  s.add(x*10**6+y)

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if not(x*10**6+y in s):
      print(ma+mb)
      exit()
print(ma+mb-1)


Measured memory_bytes: 215216
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    UNIQUE(a);
    REP(i, a.size()){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}



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

int main(){
  ll h;
  cin >> h;
  
  ll log2h=0;
  while(pow(2,log2h) <= h){
    log2h++;
  }
  log2h--;
  
  ll ans=1;
  rep(i,log2h){
    ans = 2*ans + 1;
  }
  
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 100002;
ll a,b,c,ans=0;

int main(){
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0){
		ans=0;
	}else{
		ans=min({a*b,b*c,c*a});
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


# inputna
n = int(input())
v = list(map(int, input().split()))
from heapq import heappop as hpp, heappush as hp
h = []
for num in v:
    hp(h, num)
while len(h)>=2:
    v0, v1 = hpp(h), hpp(h)
    hp(h, (v0+v1)/2)
ans = h[0]
print(ans)

Measured memory_bytes: 62412
#include <stdio.h>
main(){
  int a,b,c=0,d,e,mini,n[100],i,j;

  scanf("%d",&a);
  for(i = 0; i < a; i++){
    scanf("%d",&n[i]);
}
  for(i = 1; i <= a; i++){
    mini = n[i-1];
    for(j = i; j <= a-1; j++){
     if(mini > n[j]){
	mini = n[j];
	d = j;
      }
    }
    if(n[i-1] != mini){
      e = n[i-1];
      n[i-1] = mini;
      n[d] = e;
    c++;
    }
  }
     
  for(i = 0; i < a; i++){
    printf("%d",n[i]);
    if(i != a-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

vector<int> pos[30];

int main() {
	string s;
	cin >> s;
	int n = s.size();
	if (s[0] == s[n-1]) {
		if (n%2 == 0) cout << "First" << endl;
		else cout << "Second" << endl;
	} else {
		if (n%2 == 0) cout << "Second" << endl;
		else cout << "First" << endl;
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

string s;
int n;
int A[5001];

void z_algorithm(){
    int l = 1; A[0] = n; A[1] = -1;
    for(int i = 1; i < n; i++){
        if(i-l+A[i-l] < A[l]){
            A[i] = A[i-l];
        }
        else{
            int j = 0;
            if(i <= l+A[l]-1) j = l+A[l]-i;
            while (i+j<n && s[i+j]==s[j]) j++;
            A[i] = j;
            if(i+A[i] > l+A[l]) l = i;
        }
    }
}

int main(){
    cin>>n>>s;
    s = "a"+s;
    int m = n+1;
    int ans = 0;
    rep(i,n){
        s = s.substr(1); m--;
        rep(j,m) A[j]=0;
        z_algorithm();
        rep(j,m) ans = max(ans, min(A[j],j));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll x, y;

/* add your algorithm here */

int main() {
  cin >> x >> y;

  ll res = 0;
  if (x == 0 && y < 0) {
    res = abs(x-y) + 1;
    cout << res << endl;
    return 0;
  }
  if (x > 0 && y == 0) {
    res = x + 1;
    cout << res << endl;
    return 0;
  }
  if (x > y && x < 0) {
    ll t1 = -x;
    ll t2 = abs(t1 - (-y));
    res += t2 + 2;
  } else if (x > y && y > 0) {
    res = x + y;
  } else {
    ll t1,t2;
    t1 = abs(y - x), t2 = abs((-x) - y);
    if (t1 <= t2) {
      res = t1;
    } else {
      res = t2 + 1;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256