akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    ll K;
    int N;
    cin>>K>>N;;
    ll A[200000];
    rep(i,N) cin>>A[i];
    ll mi = K-(A[0]+K-A[N-1]);
    rep(i,N-1){
        mi = min(mi, K-(A[i+1]-A[i]));
    }
    cout<<mi<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;

struct heap {
   priority_queue<int> q;
   ll sum = 0;
   int cnt = 0;
   int cutoff = 2e9;
   void recalc() {
      while (q.size() && q.top() >= cutoff) {
         ++cnt;
         sum += q.top();
         q.pop();
      }
   }
   void modify(int __cutoff) {
      cutoff = __cutoff;
      recalc();
   }
   void push(int v) {
      q.push(v);
      recalc();
   }
   ll get() { return sum - ll(cnt) * cutoff; }
} hp;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<int> A(N);
   vector<ll> ans(N);
   for (int i = 0; i < N; ++i) cin >> A[i];
   vector<int> st;
   for (int i = N - 1; i >= 0; --i) {
      while (st.size() && A[st.back()] <= A[i]) {
         st.pop_back();
      }
      st.emplace_back(i);
   }
   ll last = 0;
   int ptr = N - 1;
   for (int i = 0; i + 1 < int(st.size()); ++i) {
      hp.modify(A[st[i + 1]]);
      while (ptr > st[i + 1]) {
         hp.push(A[ptr--]);
      }
      ans[st[i]] = hp.get() - last;
      last = hp.get();
   }
   assert(st.back() == 0);
   last = -last;
   for (int i = 0; i < N; ++i) {
      last += A[i];
   }
   ans[0] = last;
   for (int i = 0; i < N; ++i) cout << ans[i] << "\n";
}


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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()

ll inq(ll x, ll y)
{
    if (!y) return 1;
    ll l = inq(x, y / 2);
    if (y % 2) return l * l * x;
    return l * l;
}

signed main()
{
    ll n, c;
    cin >> n >> c, c *= n;
    vector<ll> Len(n), p(n - 1);
    forn(i, n) cin >> Len[i], Len[i] *= n;
    sort(all(Len));
    iota(all(p), 0);
    ll good = 0, all_ways = 0, k = (1 << (n - 1)), we, le, m2, wc;
    while (1)
    {
        all_ways += inq(c / n, n - 1);
        vector<vector<ll> > dp(c + 1, vector<ll>(k));
        dp[Len.back()][0] = 1;
        forn(i, c)
        {
            if (i % n == 0) continue;
            we = p[i % n - 1];
            le = Len[we];
            forn(mask, k)
            {
                if ((1 << we) & mask) continue;
                m2 = mask + (1 << we);
                for (ll ac = i; ac <= c; ac++)
                {
                    wc = max(ac, min(c, le + i));
                    dp[wc][m2] += dp[ac][mask];
                }
            }
        }
        good += dp[c][k - 1];
        if (!next_permutation(all(p)))
        {
            printf("%.15f", (double)good / all_ways);
            return 0;
        }
    }
}


Measured memory_bytes: 384
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = list(map(int, input().split()))
friends = []
for i in range(m):
    f = list(map(int, input().split()))
    friends.append(f)

friend_map = UnionFind(n)

for f in friends:
    friend_map.union(f[0]-1, f[1]-1)

ans = 0
for i in range(n):
    tmp = friend_map.size(i)
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 50108
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cassert>

int main(){
    int n;
    std::cin>>n;
    std::vector<std::tuple<int,int,int>> dots(n*2);
    for(size_t i = 0; i < n; i++)
    {
        int a,b;
        std::cin>>a>>b;
        dots[i]=std::make_tuple(a,b,1);//red-1
    }
    for(size_t i = 0; i < n; i++)
    {
        int c,d;
        std::cin>>c>>d;
        dots[i+n]=std::make_tuple(c,d,2);//blue-2
    }
    std::sort(dots.begin(),dots.end());
    std::vector<bool> used(n*2,false);
//std::cout<<"OK\n";
    int ans=0;
    for(int i = 0; i < 2*n; i++)
    {

        int &it=std::get<2>(dots[i]);
        if(it==2){
            if(i==0)continue;
            //std::cout<<"OK\n";
            int redmaxy=-1,redmaxyit=i;
            int &by=std::get<1>(dots[i]);
            for(int j = i-1; j >= 0; --j)
            {
                assert(j>=0);
                if(used[j])continue;
                int &y=std::get<1>(dots[j]);
                int &k=std::get<2>(dots[j]);
                if(k==2)continue;
                if(y<by){
                    if(redmaxy<y){
                        redmaxy=y;
                        redmaxyit=j;
                    }
                }
            }
            if(redmaxyit!=i){
                ++ans;
                used[i]=true;
                used[redmaxyit]=true;
            }
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<int, int>;
const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  set<P> red, blue;
  REP(i, n){
    int a, b;
    cin >> a >> b;
    red.insert(P(a, b));
  }
  REP(i, n){
    int c, d;
    cin >> c >> d;
    blue.insert(P(c, d));
  }

  int ans = 0;
  for(auto b : blue){
    P p(-1, -1);
    for(auto r : red){
      if(r.first < b.first && r.second < b.second){
        if(p.second < r.second) p = r;
      }
    }
    if(p == P(-1, -1)) continue;
    ans++;
    red.erase(p);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	vector< vector<char> > tile(101, vector<char>(101));
	int W, H, i, j;
	map<pair<int, int>, int> passed;
	while (cin>>H>>W, H||W) {
		for (j = 0; j < H; j++)
			for (i = 0; i < W; i++)
				cin>>tile[i][j];
		i = 0;
		j = 0;
		passed.clear();
		while (!passed[make_pair(i,j)]) {
			if (tile[i][j]=='.') {
				cout<<i<<" "<<j<<endl;
				break;
			}
			passed[make_pair(i,j)] = 1;
			if (tile[i][j]=='<') i--;
			else if (tile[i][j]=='>') i++;
			else if (tile[i][j]=='^') j--;
			else if (tile[i][j]=='v') j++;
		}
		if (passed[make_pair(i,j)]) cout<<"LOOP"<<endl;
	}
	return 0;
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int H, W;

int main(){
	cin.tie(0);
	
	while(cin>>H>>W,H||W) {
	    rep(i, H) {
	        rep(j, W) {
	            if(i==0||j==0)cout<<'#';
	            else if(i==H-1||j==W-1)cout<<'#';
	            else cout<<'.';
	        }
	        cout<<endl;
	    }
	    cout<<endl;
	}

	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

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 += 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9+7;



ll fct[3001],inv[3001];
inline ll po(int a,int m,int M)
{
    int ret=1;
    for(a = (a%M+M)%M;m;m>>=1,a=a*(ll)a%M)
        if(m&1)
            ret = ret*(ll)a%M;
    return ret;
}

ll C(ll n,ll r)
{
	ll ret = (inv[r]*inv[n-r])%mod;
	return (ret*fct[n])%mod;
}
void solve()
{
	fct[0]=inv[0]=1;
	for(ll i=1;i<=3000;i++)
	{
		fct[i]=(fct[i-1]*i)%mod;
		inv[i] = po(fct[i],mod-2,mod);
	}

	ll S;
	cin>>S;
	ll k = S/3;
	ll ans=0;
	for(int i=1;i<=k;i++)
	{
		ll s1 = S-3*i;
		ans = (ans+C(s1+i-1,i-1))%mod;
	}
	if(ans<0)ans+=mod;

	d1(ans);
}


int main()
{
	fifo
	ll t=1;
	//cin>>t;
	//cout<<t<<endl;
	for(ll test_case=1;test_case<=t;++test_case)
	{
		//cout<<"#"<<test_case<<endl;
		solve();
	}
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int INF = 1e9+10;
int main()
{
    int q;
    cin >> q;
    while(q--)
    {
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        if(a == b || b == a+1)
        {
            cout << 2 * (a-1) << endl;
            continue;
        }
        ll c = a * b;
        ll n = sqrt(c);
        if(n * n == c)
        {
            cout << 2 * n - 3 << endl;
            continue;
        }
        if(n * (n+1) < c)
        {
            cout << 2 * n - 1 << endl;
        }
        else
        {
            cout << 2 * n - 2 << endl;
        }
    }
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{
	ll q, h, s, d;
	ll n;
	ll q1, h1, s1; //1リットルあたりの値段
	ll q2, h2, s2, d2; //2リットル当たりの値段
	ll min1, min2; //1,2リットルの最安値


	cin >> q >> h >> s >> d;
	cin >> n;

	q1 = q * 4;
	h1 = h * 2;
	s1 = s;

	q2 = q * 8;
	h2 = h * 4;
	s2 = s * 2;
	d2 = d;

	min1 = min({ q1, h1, s1 });
	min2 = min({ q2, h2, s2, d2 });

	if (n % 2 == 0) {
		cout << (n / 2) * min2 << endl;
	}
	else {
		cout << (n / 2) * min2 + min1 << endl;
	}

	return (0);
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define sqz main
#define ll long long
#define reg register int
#define rep(i, a, b) for (reg i = a; i <= b; i++)
#define per(i, a, b) for (reg i = a; i >= b; i--)
#define travel(i, u) for (reg i = head[u]; i; i = edge[i].next)
const ll INF = 1e15;
const int N = 800000;
const double eps = 1e-6, phi = acos(-1);
ll mod(ll a, ll b) {if (a >= b || a < 0) a %= b; if (a < 0) a += b; return a;}
ll read(){ ll x = 0; int zf = 1; char ch; while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
if (ch == '-') zf = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;}
void write(ll y) { if (y < 0) putchar('-'), y = -y; if (y > 9) write(y / 10); putchar(y % 10 + '0');}
int x[N / 4 + 5];
struct node
{
	ll val[2][N + 5];
	int left[N + 5], right[N + 5];
	ll tag[N + 5];
	inline void down(int u)
	{
		val[0][u + u] += tag[u], val[0][u + u + 1] += tag[u];
		val[1][u + u] += tag[u], val[1][u + u + 1] += tag[u];
		tag[u + u] += tag[u], tag[u + u + 1] += tag[u];
		tag[u] = 0;
	}
	inline void up(int u)
	{
		val[0][u] = min(val[0][u + u] , val[0][u + u + 1]);
		val[1][u] = min(val[1][u + u] , val[1][u + u + 1]);
	}
	
	void build(int u, int l, int r) 
	{
		left[u] = l, right[u] = r, val[0][u] = val[1][u] = INF, tag[u] = 0;
		if (l == r) return;
		int mid = (l + r) >> 1;
		build(u + u, l, mid);
		build(u + u + 1, mid + 1, r);
	}
	
	void modify(int u, int pos, ll v)
	{
		int l = left[u], r = right[u], mid = (l + r) >> 1;
		if (l == r)
		{
			val[0][u] = min(val[0][u], v - pos), val[1][u] = min(val[1][u], v + pos);
			return;
		}
		down(u);
		if (pos <= mid) modify(u + u, pos, v);
		else modify(u + u + 1, pos, v);
		up(u);
	}
	
	ll query(int t, int u, int x, int y)
	{
		int l = left[u], r = right[u], mid = (l + r) >> 1; ll T = INF;
		if (x <= l && y >= r) return val[t][u];
		down(u);
		if (x <= mid) T = min(T, query(t, u + u, x, y));
		if (y > mid) T = min(T, query(t, u + u + 1, x, y));
		return T;
	}
	
	ll find(int u)
	{
		int l = left[u], r = right[u], mid = (l + r) >> 1;
		if (l == r) return min(val[0][u] + l, val[1][u] - l);
		down(u);
		return min(find(u + u), find(u + u + 1));
	}
}Segment_tree;
int sqz()
{
	int n = read(), q = read(), pos = read(); x[0] = read();
	Segment_tree.build(1, 1, n);
	Segment_tree.modify(1, pos, 0);
	rep(i, 1, q)
	{
		x[i] = read();
		ll now = min(Segment_tree.query(0, 1, 1, x[i]) + x[i], Segment_tree.query(1, 1, x[i], n) - x[i]);
		Segment_tree.tag[1] += abs(x[i] - x[i - 1]), Segment_tree.val[0][1] += abs(x[i] - x[i - 1]), Segment_tree.val[1][1] += abs(x[i] - x[i - 1]);
		Segment_tree.modify(1, x[i - 1], now);
	}
	printf("%lld\n", Segment_tree.find(1));
}

Measured memory_bytes: 25600
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val count = scala.collection.mutable.Map.empty[Int, Long]
	var sum 	 = 0L

	loop(0, Scanner.nextInt) { i =>
		val a = Scanner.nextInt
		count(a) = count.getOrElse(a, 0L) + 1L
		sum += a
	}

	loop(0, Scanner.nextInt) { i =>
		val b, c = Scanner.nextInt

		sum += (c - b).toLong * count.getOrElse(b, 0L)
		pw.println(sum)

		count(c) = count.getOrElse(c, 0L) + count.getOrElse(b, 0L)
		count(b) = 0
	}

	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


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

int main() {
  int S;
  cin >> S;
  
  int h, m, s;
  
  h = S/3600;
  m = S%3600/60;
  s = S%3600%60;
  
  cout << h  << ':' << m  << ':' << s << endl;
}


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

int main() {
  string s;
  cin >> s;
  
  int len_s = s.length();
  
  int start;
  char c1;
  for (int i = 0; i < len_s; i++) {
    c1 = s[i];
    if (c1 == 'A') {
      start = i;
      break;
    }
  }
  
  int goal;
  char c2;
  for (int j = len_s - 1; j > 0; j--) {
    c2 = s[j];
    if (c2 == 'Z') {
      goal = j;
      break;
    }
  }
  
  int ans = goal - start + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

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

	int A, B;

	cin >> A >> B;

	if(A >= 13) cout << B << endl;
	else if( A > 5) cout << B/2 << endl;
	else cout << 0 << endl;

	Never To return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
mod = 10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, M + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for k in range(N+1):
    ans += cmb(N, k, mod)*(-1)**k*cmb(M, k, mod)*g1[k]*(cmb(M-k, N-k, mod)*g1[N-k])**2
    ans %= mod
print(ans)


Measured memory_bytes: 166312
#include <stdio.h>
int main()
{
    int a,b,i;
    int min,max,mid,cnt=0;
    scanf("%d",&a);
    int x[a];
    for(i=0;i<a;i++)
    {
        scanf("%d",&x[i]);
    }
    scanf("%d",&b);
    int y[b];
    for(i=0;i<b;i++)
    {
        scanf("%d",&y[i]);
        min=0;max=a;
        while(min<max)
        {
            mid=(min+max)/2;
            if(y[i]==x[mid])
            {
                cnt++;
                break;
            }
            else if (y[i]<x[mid])
            {
                max=mid;
            }
            else
            {
                min=mid+1;
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1184
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N; scanf("%d", &N);
	int prev = 0; bool ret = true;
	for (int i = 0; i < N; i++){
		int h; scanf("%d", &h);
		if (prev == h){

		}
		else if (prev < h){
			prev = h - 1;
		}
		else{
			ret = false;
		}
	}

	if (ret){
		printf("Yes");

	}
	else
	{
		printf("No");

	}

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
import sys

X, N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()

lst = set(map(int, input().split()))

for i in range(X+1):
  if X - i not in lst:
    print(X-i)
    sys.exit()
  if X + i not in lst:
    print(X+i)
    sys.exit()

Measured memory_bytes: 9184
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = read().decode('utf-8')
count=0
cnt_max=0
for i in range(len(S)):
  if S[i] in ['A', 'C', 'G', 'T']:
    count +=1
  else:
    cnt_max = max(cnt_max,count)
    count=0
print(cnt_max)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b;
    while (cin >> a >> b) {
        int t = a + b;
        int digit = (a + b ? 1 : 0);
        while (t / 10) {
            t /= 10;
            digit++;
        }
        cout << digit << endl;
    }
}


Measured memory_bytes: 2980
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  int n;
  vector<int> v;
  vector<int> c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    c.push_back(x);
  }
  int ans=0;
  for(int i=0; i<n; i++) {
    if(v[i]>c[i])
      ans+=v[i]-c[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S[10010];
    rep(i, N) {
        cin >> S[i];
    }
    int ans = 0;
    int A = 0, B = 0;
    int AB = 0;
    rep(i, N) {
        if(S[i][0] == 'A' && S[i][1] == 'B') {
            ans++;
        }
        int len = S[i].length();
        if (S[i][0] == 'B' && S[i][len - 1] == 'A') {
            AB++;
            continue;
        }
        if (S[i][0] == 'B') B++;
        
        if (S[i][len - 1] == 'A') A++;
        else if (len> 2 && S[i][len - 2] == 'A' && S[i][len - 1] == 'B') ans++;
    }
    rep(i, N) {
        int len = S[i].length();
       rep(j, len - 1) {
           if (j == 0 || j == len - 2) continue;
           if (S[i][j] == 'A' && S[i][j + 1] == 'B') ans++;
       }
    }
    //cout << ans << " " << A << " " << B << " " << AB << endl;
    if (AB == 0 || max(A, B) > 0) {
        cout << ans + min(A , B) + AB << endl;
    } else {
        cout << ans + min(A, B) + AB - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#define NIL -1

int pre[100],in[100],ans[100],n,pos;

void solve(int L,int R){
	if(!(L<R))return;
	int m,root=pre[pos++];

	for(m=0;m<n;m++){
		if(in[m]==root)break;
	}

	solve(L,m);
	solve(m+1,R);

	//printf("%d",root);
	ans[ ++ans[0] ]=root;

	return;
}

int main(){
	pos=0;
	int i;	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&pre[i]);
	for(i=0;i<n;i++)scanf("%d",&in[i]);

	solve(0,n);
	for(i=1;i<=ans[0];i++){
		if(i>1)printf(" ");
		printf("%d",ans[i]);
	}
	printf("\n");

	return 0;
}



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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(s==u){
		cout<<a-1<<" "<<b;
	} 
	else{
		cout<<a<<" "<<b-1;
	}
	re 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define ull unsigned long long
#define mp make_pair
#define ld long double
#define fi first
#define se second
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=200005;
int n,m,ans;
int a[N];
bool check(int x){
	for(int i=x+1;i<=2*n;i++)if(a[i]+a[2*n+1+x-i]<m)return 0;
	return 1;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=2*n;i++)a[i]=read();
	sort(&a[1],&a[2*n+1]);
	int l=0,r=2*n;
	while(l<r){
		int mid=((l/2+r/2)>>1)*2;
		if(check(mid))r=mid; else l=mid+2;
	}
	for(int i=1;i<=l;i++)ans=max(ans,a[i]+a[l-i+1]);
	for(int i=l+1;i<=2*n;i++)ans=max(ans,a[i]+a[l+1+2*n-i]-m);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc164_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    for(int i=0; i<=10000; i++) {
        if(i%2==0) {
            c -= b;
            if(c<=0) {
                printf("Yes\n");
                return 0;
            }
        } else {
            a -= d;
            if(a<=0) {
                printf("No\n");
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    cout << str.substr(0, str.length()-8) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

bool pal(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return s == t;
}

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

	int n;
	string s;
	cin >> s;
	n = (int)s.size();
	int ans = pal(s);
	// cout << s.substr(0, (n - 1) / 2) << endl;
	// cout << s.substr((n - 1) / 2, n) << endl;
	ans &= pal(s.substr(0, (n - 1) / 2));
	ans &= pal(s.substr((n + 1) / 2, n - (n + 1) / 2));
	if (ans) cout << "Yes\n";
	else cout << "No\n";
} 


Measured memory_bytes: 256
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x
    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
n, m = map(int, input().split())
p = list(map(int, input().split()))
edges = [tuple(map(int, input().split())) for _ in range(m)]
place = Unionfind(n)
d = {}
for x, y in edges:
    place.union(x-1, y-1)
loot = [0] * n
for i in range(n):
    loot[i] = place.find(i)
    if loot[i] not in d:
        d[loot[i]] = {p[i]-1}
    else:
        d[loot[i]].add(p[i]-1)
counter = 0
for i in range(n):
    if i in d[loot[i]]:
        counter += 1
print(counter)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<mint> dp(n+2,0);
    dp[0] = 1;
    set<int> s;
    rep(i,m){
        int a; cin>>a;
        s.ins(a);
    }
    rep(i,n){
        if (s.count(i)) continue;
        if (!s.count(i+1)) dp[i+1]+=dp[i];
        if (!s.count(i+2)) dp[i+2]+=dp[i];
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 5760
#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; }

int main(){
    char a,b; cin >> a >> b;

    if(a == b) cout << 'H' << endl;
    else cout << 'D' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;

int main() {
    int n,m,k;
    scan3Int(n,m,k);
    int a[n], b[m];
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    int amax, bmax, max;
    amax = bmax = max = 0;
    while(amax < n) {
        if (k >= a[amax]) {
            k -= a[amax];
            amax++;
        }
        else break;
    }
    for (int i = amax; i >= 0; --i) {
        while (bmax < m) {
            if (k >= b[bmax]) {
                k -= b[bmax];
                bmax++;
            }
            else break;
        }
        max = max > i + bmax ? max : i + bmax;
        if (i)
            k += a[i - 1];
    }
    printInt(max);
    return 0;
}


Measured memory_bytes: 5384
from heapq import heappop, heappush
N = int(input())
x, y = [0] * N, [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

inds = range(N)
d = [[] for i in range(N)]
xxy = sorted(zip(x, y, inds))
for i in range(N-1):
    cur = xxy[i][2]
    nex = xxy[i+1][2]
    d[cur].append(((xxy[i+1][0] - xxy[i][0]), nex))
    d[nex].append(((xxy[i+1][0] - xxy[i][0]), cur))

yxy = sorted(zip(y, x, inds))
for i in range(N-1):
    cur = yxy[i][2]
    nex = yxy[i+1][2]
    d[cur].append(((yxy[i+1][0] - yxy[i][0]), nex))
    d[nex].append(((yxy[i+1][0] - yxy[i][0]), cur))

ans = 0
used = [False] * N
used[0] = True
q = []
for i in d[0]:
    heappush(q, i)
while len(q) > 0:
    v, x = heappop(q)
    if used[x]:
        continue
    used[x] = True
    ans += v
    for y in d[x]:
        if not used[y[1]]:
            heappush(q, y)

print(ans)


Measured memory_bytes: 124504
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        if(N % (A + B)>=A){
            System.out.println(N / (A + B) * A + A);
        }
        else{
            System.out.println(N / (A + B) * A + N % (A + B));
        }
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
using namespace std;

double mypow(int i, int N){
  if(i == 0 || i == 1) return pow(0.5 , N - 1);
  return pow(0.5 , N - i);
}

int main(){
  int N; cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin >> v[i];

  sort(v.begin(), v.end());

  double ans = 0;
  for(int i = 0; i < N; i++) ans += v[i] * mypow(i, N);
  cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int input() {int a;cin>>a;return a;}

int a,b,t;

signed main() {
    cin >> a >> b >> t;
    cout << t/a*b << endl;
}




Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/cf17-relay-open/submissions/8927584
#include <bits/stdc++.h>
using namespace std;

string rep(string s, int k){
    string t = "";
    for(int i = 0; i < k; i++) t += s;
    return t;
}

int main(){
    int L;
    char s[202020], t[202020];
    scanf("%d %s %s", &L, s, t);
    string S(s), T(t);
    int ns = S.size(), nt = T.size();
    string ans = "}";
    for(int i = 0; i * ns <= L; i++){
        if((L - i * ns) % nt == 0){
            int j = (L - i * ns) / nt;
            ans = min(ans, rep(S, i) + rep(T, j));
            ans = min(ans, rep(T, j) + rep(S, i));
            break;
        }
    }
    for(int i = L / ns; i >= 0; i--){
        if((L - i * ns) % nt == 0){
            int j = (L - i * ns) / nt;
            ans = min(ans, rep(S, i) + rep(T, j));
            ans = min(ans, rep(T, j) + rep(S, i));
            break;
        }
    }
    printf("%s\n", ans.c_str());
    return 0;
}

Measured memory_bytes: 1596
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;


int main(){
	

	int n,m;
	cin>>n>>m;
	int cur=1;
	if(n%2==1)
	for(int i=0;i<m;i++){
		cout<<cur<<" "<<n-cur<<endl;
		cur++;
	}
	else{
		int k=n/4;
		for(int i=0;i<k&&i<m;i++){
			cout<<cur<<" "<<n+1-cur<<endl;
			cur++;
		}
		for(int i=k;i<m;i++){
			cout<<cur<<" "<<n-cur<<endl;
			cur++;
		}
	}
	return 0;
}


	


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int n, m, q;    cin >> n >> m >> q;
    vector<vector<ll>> sum(n+1, vector<ll>(n+1, 0));
    REP(i, m){
        int a, b;   cin >> a >> b;
        sum[a][b] += 1;
    }
    REP(i, n){
        REP(j, n) sum[i+1][j+1] += sum[i][j+1]+sum[i+1][j]-sum[i][j];
    }
    while(0<q--){
        int a, b;   cin >> a >> b;
        ll res=sum[b][b] + sum[a-1][a-1] - (sum[a-1][b]+sum[b][a-1]);
        cout << res << endl;
    }

}

Measured memory_bytes: 2944
num1 = int(input())
arr1 = list(map(int,input().split()))

num2 = int(input())
arr2 = list(map(int,input().split()))

count = 0

for i in range(num2):
    left = 0
    right = num1
    
    while left < right:
        mid = int((left + right) /2)
        
        if arr1[mid] == arr2[i]:
            count +=1
            break
        
        elif arr2[i] < arr1[mid]:
            right = mid
        else:
            left = mid +1
        

print(count)


Measured memory_bytes: 16704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
// #define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, m;
  cin >> H >> W >> m;
  vector<ll> h(m), w(m);
  vector<ll> mhi, mwi;
  REP(i, m) { cin >> h[i] >> w[i], h[i]--, w[i]--; }

  set<pair<ll, ll>> obj;
  REP(i, m) { obj.insert({h[i], w[i]}); }
  ll mh, mw;
  vector<ll> hcnt(H,0),wcnt(W,0);
  REP(i, m) { hcnt[h[i]]++, wcnt[w[i]]++; }
  mh = *max_element(ALL(hcnt));
  mw = *max_element(ALL(wcnt));
  DEBUG(mh);
  DEBUG(mw);
  REP(i, H) {
    if (hcnt[i] == mh) mhi.push_back(i);
  }
  REP(i,W){
    if (wcnt[i] == mw) mwi.push_back(i);
  }


  for (auto hi : mhi) {
    for (auto wi : mwi) {
      if (!obj.count({hi, wi})) {
        DEBUG(hi);
        DEBUG(wi);
        cout << mh + mw << endl;
        return 0;
      }
    }
  }
  cout << mh + mw - 1 << endl;
  return 0;
}


Measured memory_bytes: 39696
#include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int n;
        cin>>n;if(n==-1)return 0;
        int nb=0;
        for(int i=0;i<n;++i){
            int nn,nxb,ans=0;
            cin>>nn;
            switch(nn){
                case 0: nxb=63;break;
                case 1: nxb=6;break;
                case 2: nxb=91;break;
                case 3: nxb=79;break;
                case 4: nxb=102;break;
                case 5: nxb=109;break;
                case 6: nxb=125;break;
                case 7: nxb=39;break;
                case 8: nxb=127;break;
                case 9: nxb=111;break;
            }
            ans=nxb^nb;
            nb=nxb;
            if(ans>63){
                cout<<1;
                ans-=64;
            }else{
                cout<<0;
            }
            if(ans>31){
                cout<<1;
                ans-=32;
            }else{
                cout<<0;
            }
            if(ans>15){
                cout<<1;
                ans-=16;
            }else{
                cout<<0;
            }
            if(ans>7){
                cout<<1;
                ans-=8;
            }else{
                cout<<0;
            }
            if(ans>3){
                cout<<1;
                ans-=4;
            }else{
                cout<<0;
            }
            if(ans>1){
                cout<<1;
                ans-=2;
            }else{
                cout<<0;
            }
            if(ans>0){
                cout<<1;
                ans-=1;
            }else{
                cout<<0;
            }
            cout<<endl;
        }
    }
    return 0;
}

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

int main(void){
    int a, b, c, d, e;
    std::cin >> a >> b >> c >> d >> e;

    std::vector<int> time = {a, b, c, d, e};

    std::vector<int> nextTime(5);
    for(int i = 0; i < 5; i++){
        nextTime.at(i) = (time.at(i) + 9) / 10 * 10;
    }

    long long ans = 1e9+1;

    for(int i = 0; i < 5; i++){
        long long temp = 0;
        for(int j = 0; j < 5; j++){
            if(i == j){
                temp += time.at(i);
            }
            else{
                temp += nextTime.at(j);
            }
        }
        ans = std::min(ans, temp);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>

#define PI 3.141592654
#define DEG_TO_RAD(theta) degToRad(theta)
#define RAD_TO_DEG(theta) radToDeg(theta)

struct point{
	double x;
	double y;
};

double degToRad( double theta )
{
	return PI/180.0 * theta;
}

double radToDeg( double theta )
{
	return 180.0/PI * theta;
}

int main(void)
{
	int n;
	double theta;
	point p;

	while(1){
		p.x = 1.0;
		p.y = 0.0;
		theta = 0.0;

		std::cin >> n;
		if( n == -1 ){
			break;
		}
		if( n < 2 || n > 1000 ){
			continue;
		}
		for( int i = 0 ; i < n-1 ; i++ ){
			theta += 90;
			p.x += cos( DEG_TO_RAD(theta) );
			p.y += sin( DEG_TO_RAD(theta) );
			theta = RAD_TO_DEG( atan( p.y/p.x ) );
			if( p.x <= 0 && p.y >= 0 ){
				theta += 180.0;
			}
			else if( p.x <= 0 && p.y <= 0 ){
				theta += 180.0;
			}
			else if( p.x >= 0 && p.y <= 0 ){
				theta += 360.0;
			}
		}
		printf( "%.2f\n%.2f\n", p.x, p.y );
	}

	return 0;
}

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

int main() {
  // string S, T;
  // cin >> S >> T;
  // int A, B;
  // cin >> A >> B;
  // string U;
  // cin >> U;
  // if (U == S) {
  //   A -= 1;
  // } else {
  //   B -= 1;
  // }
  // cout << A << " " << B;

  string S;
  cin >> S;
  int len;
  len = S.length();
  string ans;
  for (int i = 0; i < len; i++) {
    ans += "x";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, Q;
const int size = 200010;
char S[size];
char ts[size];
int ds[size];
 
inline bool judge(int pos, bool left_judge) {
    if(pos < 0) return left_judge;
    if(pos >= N) return !left_judge;
    REP(i, Q) {
        if(S[pos]==ts[i]) {
            pos += ds[i];
            if(pos < 0) return left_judge;
            if(pos >= N) return !left_judge;
        }
    }
    return false;
}

inline int solve() {
    int l, r, m, res=0;
    for(l=-1, r=N; r-l>1; m=(r+l)/2) {
        if(judge(m, true)) l=m;
        else r=m;
    }
    res -= l+1;
    for(r=N; r-l>1; m=(r+l)/2) {
        if(judge(m, false)) r=m;
        else l=m;
    }
    res += r;
    return res;
}

int main() {
    fastio();
    cin >> N >> Q;
    cin >> S;
    char d;
    REP(i, Q) {
        cin >> ts[i] >> d;
        ds[i] = d=='R'?1:-1;
    }
    cout << solve() << "\n";
	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	int dp[n];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for(int j=min(i,k);j>0;j--){
			if(dp[i]>dp[i-j]+abs(h[i]-h[i-j]))dp[i]=dp[i-j]+abs(h[i]-h[i-j]);
		}
	}cout<<dp[n-1];
	return 0;
}

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

int main()
{
	int a, b, ave;

	cin >> a >> b;

	if ((a + b) % 2 == 1)
		ave = (a + b) / 2 + 1;
	else
		ave = (a + b) / 2;

	cout << ave << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

int main()
{
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; ++i)
    a.push_back(i);
  while (1)
  {
    if (k <= a.size())
    {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old)
    {
      for (int i = -1; i <= 1; ++i)
      {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
}


Measured memory_bytes: 1712
# coding: utf-8

N = int(input())

s = ["" for i in range(N)]
t = [0 for i in range(N)]

for i in range(N):
    xx = input().split()
    s[i] = xx[0]
    t[i] = int(xx[1])

X = input()

index = 0

for i in range(N):
    if s[i] == X:
        index = i
        break

ans = 0

for i in range(index + 1, N):
    ans += t[i]

print(ans)


Measured memory_bytes: 3064