akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
long long n,a,b;
long long ans(long long n,long long a,long long b){
if(a>b){
 return 0;
}
if(n==1){
	if(a!=b){
	return 0;
    }
    return 1;
}
if(n==2){
	if(a==b){
		return 1;
	}
	return 1;

}
return ((n-1)*b+a)-((n-1)*a+b)+1;
}
int main(){
	scanf("%lld %lld %lld",&n,&a,&b);
	long long c;
	c=ans(n,a,b);
	printf("%lld\n",c);

}
	

Measured memory_bytes: 128
// at_abc151c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<stdio.h>
#include<string.h>
using namespace std;
const int MAXN = 1e5 + 5;
int main()
{
    int q,n;cin >> q>>n;
    long long arr[MAXN];
    bool visited[MAXN];
    memset(arr, 0, sizeof(arr));
    memset(visited, 0, sizeof(visited));
    for (int i = 0;i < n;i++) {
        int v1;string verdict; cin >> v1 >> verdict;
        if (visited[v1])continue;
        if (verdict.compare("AC") == 0) {
            visited[v1] = true;
        }
        else {
            arr[v1]++;
        }
    }
    long long Count = 0;
    long long penalty = 0;
    for (int i = 1;i <= q;i++) {
        if (visited[i]) {
            Count++;
            penalty += arr[i];
        }
    }
    cout << Count << " " << penalty << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

int main()
{
	string s;
	cin >> s;
	
	int len = s.size()/2, before = s[s.size()/2]; //len) 홀수면 하나적게 짝수면 그대로
	for(int i=s.size()/2; i<s.size(); i++)
	{
		if (s[i] == s[s.size()-1-i] && before == s[i])
		{
			len++;
			before = s[i];
		}
		else break;
	}
	
	cout << len;
	return 0;
}

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

int main() {
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b < c + d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}


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

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  int a[q];
  int b[n]={};
  for(int i=0;i<q;i++){
    cin >> a[i];
  }
  for(int i=0;i<q;i++){
    b[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(k+b[i]-q>0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
//#include <numeric>

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

ll gcd(ll a, ll b) {
  if (a == 0) return b;
  else if (b==0) return a;
  return b?gcd(b,a%b):a;
}

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}
using P = std::pair<ll, ll>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

using ll = long long;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  int n;
  cin >> n;
  int zero_cnt {};
  map<P, P> mp;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x==0 && y==0) {
      ++zero_cnt;
      continue;
    }
    ll g = gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) x = -x, y = -y;
    else if (y==0 && x<0) x = -x, y=-y;
    bool rot90 = (x<=0);
    if (rot90) {
      ll tmp = x;
      x = y; y = -tmp;
    }
    if (rot90) ++mp[{x, y}].first;
    else ++mp[{x,y}].second;
  }

  mint ans = 1;
  for (const auto& p : mp) {
    int s = p.second.first;
    int t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s) - 1;
    now += mint(2).pow(t) - 1;
    ans *= now;
  }
  ans -= 1;

  ans += zero_cnt;
  cout << ans.x << endl;
}


Measured memory_bytes: 19108
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int pa[100005];
vector<int> G[100005];

int dfs(int v){
  if(G[v].size() == 0) return 0;
  
  vector<int> x;
  rep(i,G[v].size()){
    x.push_back(dfs(G[v][i]));
  }
  sort(ALLOF(x));
  reverse(ALLOF(x));
  int ret = 0;
  rep(i,x.size()){
    ret = max(ret, x[i]+(i+1));
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  pa[1] = 0;
  REP(i,2,N+1){
    cin >> pa[i];
    G[pa[i]].push_back(i);
  }
  cout << dfs(1) << endl;
  
  return 0;
}



Measured memory_bytes: 15488
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  for (int i=0; i<3; i++) {
    if(s[i] == t[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a, b, t;
  cin >> a;
  cin >> b;
  cin >> t;
  
  int result = 0;
  for(int i = a; i <= t; i += a) {
   	result += b;
  }
  
  cout << result;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

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

int f(string s, int div) {
    int n = s.size();
    ll x = 0;
    rep(i,n) {
        if (s[i] == '1') {
            x += modpow(2,n-1-i,div);
            x %= div;
        }
    }
    return x%div;
}

int f_(int x, int ct = 1) {
    if (x == 0) return ct;
    int tmp = x % __builtin_popcount(x);
    if (tmp == 0) return ct+1;
    return f_(tmp,ct+1);
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int div = 0;
    rep(i,n) if (s[i] == '1') div++;
    int x_plus = f(s,div+1);
    int x_minus = -1;
    if (div-1 != 0) x_minus = f(s,div-1);
    rep(i,n) {
        int div_tmp = div;
        string s_tmp = s;
        if (s[i] == '0') {
            s_tmp[i] = '1';
            ll x = x_plus+modpow(2,n-1-i,div+1);
            x %= div+1;
            // debug(x);
            cout << f_(x) << endl;
        }
        if (s[i] == '1') {
            s_tmp[i] = '0';
            if (div-1 == 0) cout << 0 << endl; 
            else {
                ll x = x_minus-modpow(2,n-1-i,div-1);
                if (x < 0) x += div-1;
                x %= div-1;
                // debug(x);
                cout << f_(x) << endl;
            }
        }
        // debug(s_tmp);
    }
}

Measured memory_bytes: 3820
N, K = map(int,input().split())
w = [int(input()) for i in range(N)]

def check(p):
    track = 0
    tmp_w = 0
    for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
    if track + 1 > K:
        return False
    else:
        return True

left = 0
right = 2000000000
while((left + 1) < right):
    mid = (left + right) // 2
    track = check(mid)
    if check(mid):
        right = mid
    else:
        left = mid 
        
print(right)


Measured memory_bytes: 9556
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

char c;
double x[3], y[3];

Point p[3];

double dist(Point a, Point b){
	return abs(a - b);
}

double dot(Point a, Point b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

int main(){
	while (cin >> x[0] >> c >> y[0] >> c >> x[1] >> c >> y[1]
		>> c >> x[2] >> c >> y[2]){
		REP(i, 3)p[i] = Point(x[i], y[i]);
		Point n = (p[1] - p[0])/dist(p[1], p[0]);
		//printf("%.10lf %.10lf\n", n.real(), n.imag());
		//cout << dot(n, p[2] - p[0]) << endl;
		n *= (dot(n, p[2] - p[0]));

		n = n - (p[2] - p[0]);
		n = p[2] + 2.0 * n;
		printf("%.10lf %.10lf\n", n.real(), n.imag());
	}
}

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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;
    
    bool found = false;
    for (u64 r = 0; r <= K; r++) {
        for (u64 g = 0; g <= K; g++) {
            for (u64 b = 0; b <= K; b++) {
                if (r + g + b > K) {
                    continue;
                }
                if (A * pow(2, r) < B * pow(2, g) && B * pow(2, g) < C * pow(2, b)) {
                    found = true;
                    break;
                }
            }
        }
    }
    
    if (found) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

#include <algorithm>
#include <cassert>
#include <vector>


struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    vector<ll> x(m), y(m);
    rep(i, m) cin >> x[i] >> y[i];
    
    dsu g(n);
    rep(i, m) {
        g.merge(x[i] - 1, y[i] - 1);
    }

    ll res = 0;
    rep(i, n) {
        if (g.same(i, p[i] - 1)) {
            res++;
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 5828
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,K=LI()
AS=LI()
SUMM= sum(AS)

DIVS=set()
for i in range(1,40000):
    if SUMM % i == 0:
        DIVS.add(i)
        DIVS.add(SUMM//i)
# DIVS.sort(reversed=True)
# print(DIVS)

DIFF=[0]*N
ACC=[0]*N

# res = 0

for div in sorted(DIVS, reverse=True):
    for i in range(N):
        DIFF[i] = AS[i]%div
    DIFF.sort()
    ACC[0] = DIFF[0]
    for i in range(1,N): ACC[i] = ACC[i-1] + DIFF[i]
    # print(ACC)
    for i in range(N-1):
        left = ACC[i]
        right = (N-1-i)*div-(ACC[N-1]-ACC[i])
        if left%div == right%div:
            if max(left, right) <= K:
                # print(max(left, right))
                print(div)
                exit()


# print(DIFF)
# print(res)


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

char str[10];
int ans,n;
signed main(){
	scanf("%lld",&n);
	ans=n/500*1000;
	n%=500;
	ans+=n/5*5;
	printf("%lld\n",ans);
return 0;
}


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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

i64 n,a,b;

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

  if (a+b > n+1 || a*b < n) {
    cout << -1 << endl;
  } else {
    vector<i64> l;
    for (i64 i = a-1; i >= 0; i--) {
      l.pb(a*b-i);
    }
    i64 m = n - a;
    for (i64 i = 1; i <= a && m > 0; i++) {
      for (i64 j = b-2; j >= 0 && m > 0; j--) {
        l.pb(a*j+i);
        m--;
      }
    }
    vector<i64> cl = l;
    sort(cl.begin(),cl.end());
    for (int i = 0; i < (int)l.size(); i++) {
      cout << lower_bound(cl.begin(),cl.end(),l[i]) - cl.begin() + 1
           << (i+1==(int)l.size()?'\n':' ');
    }
  }

  return 0;
}


Measured memory_bytes: 8684
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	vector<vector<bool>> v(4, vector<bool>(13));
	while (n--) {
		char s;
		int rank;
		cin >> s >> rank;
		if (s == 'S')
			v[0][rank - 1] = true;
		else if (s == 'H')
			v[1][rank - 1] = true;
		else if (s == 'C')
			v[2][rank - 1] = true;
		else
			v[3][rank - 1] = true;
	}
	string order = "SHCD";
	rep(i, 4) {
		rep(r, 13) {
			if (v[i][r] == false)
				cout << order[i] << " " << r + 1 << endl;
		}
	}
}



Measured memory_bytes: 3232
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
	int a,b;
	cin >> a >> b;
	cin >> s;
	if(s[a] == '-'){
		for(int i = 0;i < a;i++){
			if(s[i] == '-') {
				cout << "No";return 0;
			}
		}
		for(int j = a + 1;j < a + 1 + b;j++){
			if(s[j] == '-') {
				cout << "No";return 0;	
			}
		}
	}
	else {
		cout << "No";return 0;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
	int main()
	{
	int num1, num2, num3;
	scanf("%d %d %d", &num1, &num2, &num3);
	if (num1 == num2 && num2 == num3 && num1 == num3){
		printf("No");
	}
	else if (num1!=num2 && num1!=num3 && num2!=num3){
		printf("No");
	} 
	else {
		printf("Yes");
	}
	return 0;
	}

Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	x -= 1;
	y -= 1;

	Graph G(n);
	rep(i,n-1){
		G[i].push_back(i+1);
		G[i+1].push_back(i);
	}

	G[x].push_back(y);
	G[y].push_back(x);

	queue<int> que;
	vector<int> Dist(n, 0);

	rep(i,n){
		vector<int> dist(n, -1);
		dist[i] = 0;
		que.push(i);

		while(!que.empty()){
			int v = que.front();
			que.pop();

			for(int nv : G[v]){
				if(dist[nv] != -1) continue;

				dist[nv] = dist[v] + 1;
				que.push(nv);
			}
		}
		rep(j,n) Dist[dist[j]]++;
	}

	loop(i, 1, n){
		cout << Dist[i]/2 <<endl;
	}
	return 0;
}

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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 9;
const ll maxn = 2e5 + 10;
signed main(){
    int x, y;
    cin >> x >> y;
    int t = 4*x -y, c = y-2*x;
    if (t >= 0 && t %2 == 0 && c >= 0 && c %2==0){
        cout << "Yes"<<endl;
    }else {
        cout << "No" << endl;
    }
}

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

#define ll                 long long
#define mod                1000000007
#define pb                 push_back
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define T(t)               cout << "Case " << t <<": ";
#define scan(v)            for(int i = 0; i<n; i++){ll x;cin>>x;v.pb(x);}
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL);




int main() {



     ll a , b ;
     double t ;
     cin >> a >> t;
     b = 100LL * ( t + 0.001 );
    // cout << 100ll*t << " " << 10LL*0.001 << endl;
     cout << a*b/100 << endl;








    return 0;

}

Measured memory_bytes: 3724
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

char s[20][20];
int i;
int n;

int f(int l){
    int ans=0;
    if(s[i][l]=='+'){
        i++;
        while(i<n&&s[i][l]=='.')ans+=f(l+1);
        return ans;
    }
    if(s[i][l]=='*'){
        i++;
        ans=1;
        while(i<n&&s[i][l]=='.')ans*=f(l+1);
        return ans;
    }
    return atoi(s[i++]+l);
}

void run(){
    cin>>n;
    if(!n)return;
    MEMSET(s);
    rep(i,n)cin>>s[i];
    i=0;
    cout<<f(0)<<endl;
    run();
}


Measured memory_bytes: 3176
local tgt = io.read("*n")
tgt9 = math.floor(tgt / 9)
local first = true
local cnttot = 0
for i = 0, tgt9 do
    local tmp = i
    local cnt9, val9 = 0, 0
    local mul = 9
    while(0 < tmp) do
        local a = tmp % 9
        cnt9, val9 = cnt9 + a, val9 + mul * a
        mul, tmp = mul * 9, math.floor(tmp / 9)
    end
    local rem = tgt - val9
    local cnt6, rem6 = 0, rem
    while(0 < rem6)do
        local a = rem6 % 6
        cnt6, rem6 = cnt6 + a, math.floor(rem6 / 6)
    end
    if(first) then first, cnttot = false, cnt6 + cnt9 else cnttot = math.min(cnttot, cnt6 + cnt9) end
end
print(cnttot)

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

int main()
{
    int N, K;
    cin >> N;
    cin >> K;
    vector<int> xs;
    copy_n(istream_iterator<int>(cin), N, back_inserter(xs));

    vector<int> As;
    transform(
        xs.begin(), xs.end(), back_inserter(As),
        [](auto x) { return x * 2; });
    vector<int> Bs;
    transform(
        xs.begin(), xs.end(), back_inserter(Bs),
        [K](auto x) { return abs(K - x) * 2; });

    vector<int> short_distances;
    transform(
        As.begin(), As.end(), Bs.begin(),
        back_inserter(short_distances),
        [](auto a, auto b) {
            return (a < b) ? a : b;
        });

    auto sum_distance = accumulate(short_distances.begin(), short_distances.end(), 0);
    cout << sum_distance << endl;
    return 0;
}


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for(auto& x : a) cin >> x;

    vector<int> dp(n);
    for(int i = 0; i < n; i++) {
        dp[i] = numeric_limits<int>::max();
        for(int j = 0; j < k; j++) {
            if(i-j-1 >= 0) dp[i] = min(dp[i], dp[i-j-1] + abs(a[i]-a[i-j-1]));
        }
        if(dp[i] == numeric_limits<int>::max()) dp[i] = 0;
    }
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 3988
n = int(input())
al = list(map(int,input().split()))

ansl = [0] * 9

for a in al:
    k = min(a // 400, 8)
    ansl[k] += 1

min_ans = 0
for a in ansl[:8]:
    if a > 0:
        min_ans += 1

max_ans = min_ans
if ansl[-1] > 0:
    if min_ans == 0:
        min_ans += 1
        max_ans += ansl[-1]
    else:
        max_ans = min_ans + ansl[-1]

print(min_ans, max_ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
long long n,m,A[100005],tong=0,i,j;
int main()
{
    cin>>n>>m;
    for (i =1;i<=m;i++)
    { cin>>A[i];
      tong+=A[i];
    }
    if (tong==n) cout<<0;
    else if (tong>n) cout<<-1;
    else cout<<n-tong;
}

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

int main(void) {
  ll N; cin >> N;
  vector<ll> A(N);
  ll c = 0;
  ll a = 0;
  for (ll i = 0; i < N; i++) {
    cin >> A.at(i);
    if (A.at(i) < 0) {
      A.at(i) *= -1;
      c++;
    }
    a += A.at(i);
  }

  if (c%2 == 1) {
    sort(A.begin(), A.end());
    a -= A.front()*2;
  }
  cout << a << endl;

  return 0;
}


Measured memory_bytes: 1024
mod = 10 ** 9 + 7
n, k = map(int, input().split())

a = [1] * (k+1)
b = [ i for i in range(k+1) ]

for i in range(k//2,0,-1):
  cnt = pow( k // i , n, mod )
  for j in range(i*2,k+1,i):
    cnt = ( cnt - a[j] ) % mod
  a[i] = cnt
  b[i] = i * cnt % mod

ans = 0
for i in range(1,k+1):
  ans += b[i]
  if ans >= mod:
    ans %= mod

print(ans)

Measured memory_bytes: 15260
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

l = [0] * 51
l[0] = 1
p = [0] * 51
p[0] = 1
for i in range(1, 51):
    l[i] = l[i - 1] * 2 + 3
    p[i] = p[i - 1] * 2 + 1

ans = 0
for i in range(N, -1, -1):
    if i == 0 and X >= 1:
        ans += 1
        break

    if X <= 1:
        break
    elif X <= l[i - 1] + 1:
        X -= 1
        continue 
    elif X == l[i - 1] + 2:
        ans += 1
        X -= 2
    else:
        ans += p[i - 1] + 1
        X -= l[i - 1] + 2
print(ans)

Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2,s3;
    cin >> s1 >>s2 >> s3;
    cout << char(s1[0] - 'a' + 'A') << char(s2[0] - 'a' + 'A') << char(s3[0] - 'a' + 'A');

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
const int N = 200000;

int n;
int ans[N], in[N];
vector <int> a[N];
priority_queue< pair<int,int> > q;

int main(void)
{
	scanf("%d", &n);
	for (int i=1;i<n;++i)
	{
		int x, y; scanf("%d %d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	memset(ans,-1,sizeof ans);
	int m; scanf("%d", &m);
	for (int i=1;i<=m;++i)
	{
		int x, v; scanf("%d %d", &x, &v);
		ans[x] = v; q.push(make_pair(-v,x));
	}
	while (q.size())
	{
		int x = q.top().second;
		int v = -q.top().first;
		q.pop(); in[x] = 1;
		for (int i=0;i<a[x].size();++i)
		{
			int y = a[x][i];
			if (ans[y] >= 0 and !in[y] and (abs(ans[x]-ans[y]) != 1)) {
				puts("No");
				return 0;
			}
			else if (!in[y]) {
				in[y] = 1;
				ans[y] = v + 1;
				q.push(make_pair(-ans[y],y));
			}
		}
	}
	puts("Yes"); 
	for (int i=1;i<=n;++i)
		printf("%d\n", ans[i], i==n?'\n':' ');
	return 0;
} 

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

static const int N = 100;

int main() {
    int n, p[N+1], m[N+1][N+1];
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i-1] >> p[i];
    }

    for (int i = 1; i <= n; i++) m[i][i] = 0;
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n-l+1; i++) {
            int j = i+l-1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j-1; k++) {
                m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3128
#!/usr/bin/env ruby
# frozen_string_literal: true

input = gets.chomp.split(' ')

a = input[0].to_i
b = input[1].to_i
c = input[2].to_i
k = input[3].to_i

ans = 0

# for a
if k >= a
  ans += a
  k -= a
else
  ans += k
  k = 0
end

# for b
if k >= b
  k -= b
else
  k = 0
end

# for c
if k >= c
  ans -= c
  k -= c
else
  ans -= k
  k = 0
end

=begin
(0..a - 1).each do
  break if k.zero?

  k -= 1
  ans += 1
end

(0..b - 1).each do
  break if k.zero?

  k -= 1
end

(0..c - 1).each do
  break if k.zero?

  k -= 1
  ans -= 1
end
=end

puts ans

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int n;
    int x,maxi = -1;
    map<int,int>mapper;
    sc(n);
    FOR(i,n){
        sc(x);
        mapper[x]++;
        maxi = max(maxi, x);
    }

    if(n == 2){
        if(mapper[1] == 2){
            printf("Possible");
        }else printf("Impossible");
        return 0;
    }

    if(maxi == 1){
        printf("Impossible");
        return 0;
    }

    int perlu = maxi + 1;
    int cur = maxi;
    bool valid = true;
    while(true){
        mapper[cur]-=2;
        if(mapper[cur] < 0)valid = false;
        perlu-=2;
        if(perlu == 1){
            cur--;
            mapper[cur]--;
            if(mapper[cur] < 0)valid = false;
            break;
        }
        if(perlu == 0)break;
        cur--;

    }

    for(map<int,int>::iterator it = mapper.begin();it!=mapper.end();it++){
        if(it->second > 0 && it->first <= cur)valid = false;
    }

    printf("%s", valid ? "Possible" : "Impossible");




    return 0;
}




Measured memory_bytes: 256
H, W = map(int, input().split())
s = [list(input())for _ in range(H)]
grid = [(-1,-1),(-1,1),(1,-1),(1,1),(1,0),(0,1),(-1,0),(0,-1)]
for y in range(H):
    for x in range(W):
        count = 0
        if s[y][x] == '#':
            print('#', end='')
        else:
            for g in grid:
                try:
                    sy = y+g[0]
                    sx = x+g[1]
                except IndexError:
                    continue
                if sy < 0 or sy >= H:
                    continue
                elif sx < 0 or sx >= W:
                    continue
                if s[sy][sx] == '#':
                    count += 1
            print(count,end='')
    print()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll x;
  cin>>x;
  ll ans=(x/11)*2;
  if((x%11)<=6 && (x%11)!=0)ans+=1;
  else if((x%11)>6)ans+=2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	int n;	scanf("%d",&n);
	while(n--){
		int xopt=0,yopt=0;
		for(int x=0,y=0,dx,dy;scanf("%d%d",&dx,&dy),dx||dy;){
			x+=dx,y+=dy;
			if(xopt*xopt+yopt*yopt<x*x+y*y
			||(xopt*xopt+yopt*yopt==x*x+y*y && xopt<x)){
				xopt=x,yopt=y;
			}
		}
		printf("%d %d\n",xopt,yopt);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
  int a, b;

  scanf("%d %d", &a, &b);
  if (a >= 1 && b >= 1 && a <= 100 && b <= 100)
  {
    printf("%d %d\n", a * b, 2 * (a + b));
  }

  return 0;
}

Measured memory_bytes: 596
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int m;
	cin >> m;
	cout << 48 - m << endl;
	return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    string s,t;
    cin>>s;
    cin>>t;
    a =s.size();

    c=0;

    for(b=0;b<a;b++){
        if(s[b]!=t[b]){
            c++;
        }
    }
    cout<<c;

}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int x;
    cin>>x;
    vector<int> factor;
    for(int i=1;i*i<=x;++i){
        if(x%i){
            factor.push_back(i);
            if (x % (x / i) == 0 && i != x / i) factor.push_back(x / i);
        }
    }
    for (int a = -120;a<=120;++a){
        for(int b=-120;b<=120;++b){
            if (b > a && a > 0) break;
            if (b > 0 && a < 0) {
                a = -1;
                break;
            }
            int a5 = a * a * a * a * a;
            int b5 = b * b * b * b * b;
            if (a5-b5==x){
                cout<<a<<" "<<b;
                return 0;
            }
        }
    }
}
/*

y = a^5-b^5 = (a-b)(a^4 + a^3b + a^2b^2 + ab^3 + b^4)
y > 0 therefore a != b
b > a > 0 -> y < 0
a > b > 0 -> y > 0
a > 0 > b ->
    (maybe)
    |a| > |b| -> y > 0
    |b| > |a| -> y < 0
b > 0 > a ->
    (maybe)
    |a| > |b| -> y > 0
0 > a > b ->
*/

Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
using namespace std;
int main()
{
	string a,b;
	cin>>a;
	b="ABC";
	cout<<b+a; 
	return 0;
}

Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int get_id(char c){
	if(c>='a'&&c<='z')return c-'a';
	if(c>='A'&&c<='Z')return c-'A'+26;
	return c-'0'+52;
}
char rev(int x){
	if(x<26)return 'a'+x;
	if(x<52)return 'A'+x-26;
	return '0'+x-52;
}
int cnt[66],func[66],n,tot_ask;
string cmp="";
int dp[199][199];
int dist(string s){
	memset(dp,inf,sizeof dp);
	dp[0][0]=0;tot_ask++; 
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=cmp.size();j++){
			if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			if(i&&j)dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s[i-1]!=cmp[j-1]));
		}
	}
	return dp[s.size()][cmp.size()];
}
int ask(string s){
	#ifdef LOCAL
		return dist(s);
	#endif
	cout<<"? "<<s<<endl;
	fflush(stdout);int x;cin>>x;return x;
}
int Get(string ret,string s,int pos,char c){
	int tot=ret.size()+1+s.size()-pos;
	string ss=ret+c+getstr(s,pos,s.size()-1);
	tot=ss.size();
	#ifdef LOCAL
		return dist(ss)==n-tot;
	#endif
	return n-tot==ask(ss);
}
string merge(string s1,string s2){
	int pos=0;
	string ret="";
	if(rand()&1)swap(s1,s2);
	for(int i=0;i<s1.size();i++){
		while(pos<s2.size()&&Get(ret,s2,pos,s1[i])==0)
		ret.push_back(s2[pos]),pos++;
		ret.push_back(s1[i]);
	}
	while(pos<s2.size())ret.push_back(s2[pos++]);
	return ret;
}
int main(){
	srand(time(0));
	for(int i=0;i<128;i++)cmp.push_back(rev(rand()%62));
	for(int i=0;i<62;i++){
		string s="";s.push_back(rev(i));
		for(int i=0;i<7;i++)s=s+s;
		int got=ask(s);
		cnt[i]=128-got;
	}
	for(int i=0;i<62;i++)n+=cnt[i];
	set<pair<int,string> >s;
	for(int i=0;i<62;i++){
		if(cnt[i]){
			string ins="";
			for(int j=0;j<cnt[i];j++)ins.push_back(rev(i));
			s.insert(make_pair(cnt[i],ins));
		}
	}
	while(s.size()>1){
		string s1=s.begin()->second;s.erase(s.begin());
		string s2=s.begin()->second;s.erase(s.begin());
		string s3=merge(s1,s2);
		s.insert(make_pair(s3.size(),s3));
	}
	cout<<"! "<<s.begin()->second<<endl;
	if(tot_ask>=853-128)assert(0);
	fflush(stdout);
	return 0;
}

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

class UnionFind
{
  public:
    UnionFind(int n);
    int find(int x);
    bool same(int x, int y);
    int size(int x);
    void unite(int xp, int yp);

  private:
    vector<int> par;
    vector<int> sze;
};

UnionFind::UnionFind(int n)
    : par(vector<int>(n)), sze(vector<int>(n, 1))
{
    iota(begin(par), end(par), 0);
}

int UnionFind::find(int x)
{
    if (x != par[x])
        par[x] = find(par[x]);
    return par[x];
}

bool UnionFind::same(int x, int y)
{
    return find(x) == find(y);
}

int UnionFind::size(int x)
{
    return sze[find(x)];
}

void UnionFind::unite(int xp, int yp)
{
    int x = find(xp);
    int y = find(yp);
    if (x == y)
        return;
    if (size(x) > size(y))
    {
        sze[x] += size(y);
        par[y] = x;
    }
    else
    {
        sze[y] += size(x);
        par[x] = y;
    }
}

const int MA = 110000;

int main() {
    int N;
    cin >> N;
    UnionFind uf(2 * MA);
    for(int i=0; i<N; ++i) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, MA + y);
    }

    map<int, long long> cx, cy;
    for(int i=0; i<MA; ++i) cx[uf.find(i)] += 1;
    for(int i=MA; i<2*MA; ++i) cy[uf.find(i)] += 1;

    long long res = 0;
    for(int i=0; i<2*MA; ++i) res += cx[i] * cy[i];
    cout << res - N << endl;
}

Measured memory_bytes: 29440
#include<iostream>
using namespace std;
int main(){
	int N,c=0,x;
	cin>>N;
	x=N;
	while(x>0){
		c+=x%10;
		x=x/10;
	}
	if(N%c==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

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

using namespace std;

const int INF = 2e9 + 3;
const int N = 1e3 + 3;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

const double PI = acos(-1);



void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    pair<int, int> p[m];
    map<int, int> row, col;
    int max_rep_row = 0, max_rep_col = 0;
    for (int i = 0; i < m; i++) {
        int r, c;
        cin >> r >> c;
        p[i] = make_pair(r, c);
        row[r]++;
        col[c]++;
        max_rep_row = max(max_rep_row, row[r]);
        max_rep_col = max(max_rep_col, col[c]);
    }
    int cnt_max_row = 0, cnt_max_col = 0;
    for (auto r : row)
        cnt_max_row += r.second == max_rep_row;
    for (auto c : col)
        cnt_max_col += c.second == max_rep_col;

    int cnt_max_matches = 0;
    for (auto target : p) {
        if (row[target.first] == max_rep_row && col[target.second] == max_rep_col)
            cnt_max_matches++;
    }
    if (cnt_max_matches == 1ll * cnt_max_row *cnt_max_col)
        cout << max_rep_row + max_rep_col - 1;
    else
        cout << max_rep_row + max_rep_col;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 34112
N=int(input())
dd=[list(map(int,input().split())) for i in range(N)]
count=0
last=0
for i in range(N):
    d1=dd[i][0]
    d2=dd[i][1]
    if d1==d2:
        count+=1
        if count==3:
            print('Yes')
            exit()
    else:
        count=0

print('No')

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

ll gcd(ll x, ll y) {return y ? gcd(y,x%y) : x;}

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i=2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
mod = 10**9+7

NN = 10**4 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

N, A, B, C, D = map(int, input().split())

Map = [[] for _ in range(N+1)]
for n in range(1, N+1):
    a = 1
    for _ in range(N+1):
        Map[n].append(a)
        a = a * g2[n] % mod

L = [[] for _ in range(N+1)]
for n in range(A, B+1):
    for c in range(C, D+1):
        if n*c > N:
            continue
        L[n].append(c)

dp = [0]*(N+1)
dp[0] = 1
for n in range(1, N+1):
    for i, c in enumerate(L[n]):
        if i == 0:
            dp2 = dp[:]
        for nn in range(N+1-n*c):
            dp2[nn+n*c] = (dp2[nn+n*c] + dp[nn] * Map[n][c] % mod * Map[c][1] % mod) % mod
        if i == len(L[n])-1:
            dp = dp2

ans = dp[N] * g1[N] % mod
print(ans)


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }



  int main(){
    int N; cin >> N;
    ll H, W; cin >> H >> W;
    int ans = 0;
    REP(i, N){
      ll y, x;
      cin >> y >> x;
      if(H <= y && W <= x) ans++;
    }
  
  print(ans);
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3076
S = input()
L = len(S)
ACGT = ['A', 'C', 'G', 'T']
ans = 0

for i in range(L):
    for j in range(i, L):
        sub_S = S[i:j+1]
        if all([s in ACGT for s in sub_S]):
            if len(sub_S) > ans:
                ans = len(sub_S)

print(ans)


Measured memory_bytes: 61996
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main { 
	public static void main(String[] args) throws Exception { 
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while((line = in.readLine()) != null){
		int i = Integer.parseInt(line);
			System.out.println(i*i*i);
		}}
	}



Measured memory_bytes: 24128
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val s = StdIn.readLine().trim

    var cnt = 0

    var prev: Option[Char] = None
    s.foreach { c =>
      prev.foreach { p =>
        if (p != c) { cnt += 1 }
      }
      prev = Some(c)
    }

    println(cnt)
  }
}


Measured memory_bytes: 29172
n, k, *a = map(int, open(0).read().split())

ans = 0
for l in range(0, k + 1):
    for r in range(0, k + 1 - l):
        if l == r == 0 or l + r > n:
            continue
        b = sorted(a[:l] + a[n - r:])
        c = min(k - l - r, len(b) - 1)
        ans = max(ans, sum(b[c:] if b[c] < 0 else filter(lambda x: x > 0, b)))
print(ans)


Measured memory_bytes: 9056
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

string s;
ll x, ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		if (s[i] == 'B')
			x++;
		else
			ans += x;
	cout << ans << endl;
}



Measured memory_bytes: 720
def resolve():
	S = list(input())
	T = list(input())
	lenT = len(T)
	res = lenT
	for i in range(len(S)-lenT+1):
		tmp = lenT
		for j in range(lenT):
			if S[i+j] == T[j]:
				tmp -= 1
		res = min(res, tmp)
	print(res)
resolve()

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

a = list(map(int,input().split()))
b = list(map(int,input().split()))
anext = a[n]

sum = 0

for i in range(n):
    ind = n - i - 1
    if b[ind] <= anext:
        sum += b[ind]
        anext = a[ind]
        continue
    elif (b[ind] > anext) and (b[ind] < anext + a[ind]):
        sum += b[ind]
        anext = anext + a[ind] - b[ind]
        continue
    else:
        sum += anext + a[ind]
        anext = 0

print(sum)


Measured memory_bytes: 18624