akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 300000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
char S[MAX_N + 1];

int main(void)
{
  cin >> N >> S;

  vector<int> wa(N + 1), ea(N + 1);

  wa[0] = 0;
  // wa
  for (int i = 0; i < N; i++) {
    if (S[i] == 'W') {
      wa[i + 1] = wa[i] + 1;
    }
    else {
      wa[i + 1] = wa[i];
    }
  }

  ea[N - 1] = 0;
  // ea
  for (int i = N - 1; i > 0; i--) {
    if (S[i] == 'E') {
      ea[i - 1] = ea[i] + 1;
    }
    else {
      ea[i - 1] = ea[i];
    }
  }

  // cout << endl;
  // for (int i = 0; i < N; i++) cout << wa[i] << SLN(i, N);
  // for (int i = 0; i < N; i++) cout << ea[i] << SLN(i, N);

  ll ans = inf;
  for (int i = 0; i < N; i++) {
    ans = min(ans, (ll)wa[i] + ea[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	string s;
	cin >> s;
	int res_0 = 0;
	int res_1 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (i & 1) {
			// odd
			if (s[i] != '1') res_0++;
			if (s[i] != '0') res_1++;
		} else {
			// even
			if (s[i] != '0') res_0++;
			if (s[i] != '1') res_1++;
		}
	}
	cout << min(res_0, res_1) << endl;
}


Measured memory_bytes: 512
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);

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

int main() {
  int64_t n, k;
  cin >> n >>k;
//  int a;
  
  cout<< min(n%k , abs(n%k-k))<<endl;
//  a = n % k;
//  if(a<=abs(a-k))cout<< a <<endl;
//  else cout<<abs(a-k)<<endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())

    f = [0] * (N+1)

    for x in range(1, 100):
        for y in range(x, 100):
            for z in range(y, 100):
                if (ans := (x+y+z)**2 - x*y - y*z - z*x) in range(1, N+1):
                    count = 0
                    if x == y and y == z:
                        count = 1
                    elif x != y and y != z and z != x:
                        count = 6
                    else:
                        count = 3
                    f[ans] += count
    
    for i in range(1, N+1):
        print(f[i])




def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 9236
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    in sum=0ll;
    for(in i=1;i<=n;i++){
        in kn=n/i;
        sum +=kn*(kn+1ll)/2*i;
    }
    cout<<sum<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

struct Edge {
  ll t,i;
  Edge(ll t,ll i):t(t),i(i){}
};

vector<Edge> g[55];

vec es;
bool dfs(ll v,ll t,ll p=-1){
  if(v==t)return true;
  for(Edge e:g[v]){
    if(e.t==p)continue;
    if(dfs(e.t,t,v)){
      es.push_back(e.i);
      return true;
    }
  }
  return false;
}

void solve(){
  /* (´~`) */
  ll n;cin>>n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    g[a].emplace_back(b,i);
    g[b].emplace_back(a,i);
  }

  ll m;cin>>m;
  vec eset(m);
  rep(i,m){
    ll a,b;cin>>a>>b;
    a--;b--;
    es=vec();
    dfs(a,b);
    for(ll e:es){
      eset[i]|=1ll<<e;
    }
  }

  ll ans=0;
  rep(i,1<<m){
    ll mask=0;
    rep(j,m){
      if(i>>j&1)mask|=eset[j];
      ll white=__builtin_popcountll(mask);
      ll now=1ll<<(n-1-white);
      if(__builtin_popcountll(i)%2==0)ans+=now;
      else ans-=now;
    }
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 384
use std::io;


/// https://beta.atcoder.jp/contests/agc006/tasks/agc006_a
fn main() {
    let _ = read_one::<usize>();
    let s = read_one::<String>();
    let t = read_one::<String>();
    let mut ans = s.clone();
    let mut buf = t.clone();
    let mut post = "".to_string();
    while buf.len() > 0 {
        if s.contains(&buf) { ans += &post; break; }
        post.insert(0, buf.pop().unwrap());
    }
    if buf.len() == 0 { ans += &t; }
    println!("{}", ans.len());
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
  int N, i, A, B;
  A = 0;
  B = 0;
  cin >> N;
  vector<int> vec(N);
  for ( i = 0; i < N; i++) {
  cin >> vec.at(i);  
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for ( i = 0; i < N; i++) {
    if( i % 2 == 0 ) A += vec.at(i);
    else B += vec.at(i);
  }
  cout << A - B << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 998244353
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve(){
    int n, k;
    cin>>n>>k;
    vec v(n);
    fo(i,n){
        cin >> v[i];
    }
    so(v);
    int ans = 0;
    fo(i,k){
        ans += v[i];
    }
    cout << ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3668
#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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

struct UnionFind {
    vector<int> par; vector<int> rank;

    UnionFind(int N) : par(N), rank(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i; 
            rank[i] = 0;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        } else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, q; cin >> N >> q;
    UnionFind T(N);
    for (int i = 0; i < q; i++) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) {
            T.unite(x, y);
        } else {
            cout << (T.same(x, y)) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3176
from collections import Counter
# counter（l）.most_common()：リストについて出現回の多い順に（要素、要素数）で返す
a=int(input())
A=list(map(int,input().split()))
b=[A[i] for i in range(a) if i%2==0]
c=[A[i] for i in range(a) if i%2==1]
#　全部同じ数の時
if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

Measured memory_bytes: 21084
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

class Main{
    static List<Integer> edges[];
    static int white[];
    static boolean nibu=true;
    static void bfs(int v, int c){
        if(white[v]>=0){if(c%2!=white[v])nibu=false;}
        else{
            white[v]=c;
            for(int u :edges[v])bfs(u, (c+1)%2);
        }
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        boolean[][] edge = new boolean[N][N];
        while(M-->0){
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            edge[a][b]=edge[b][a]=true;
        }
        edges = new ArrayList[N];
        white = new int[N];
        Arrays.fill(white, -1);
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
        Set<Integer> set = new HashSet<>();
        for(int i=0;i<N;++i)for(int j=i+1;j<N;++j)if(!edge[i][j]){
            edges[i].add(j);
            edges[j].add(i);
            set.add(i);
            set.add(j);
        }
        List<Integer> sub = new ArrayList<>();
        for(int i=0;i<N;++i){
            if(set.contains(i) && white[i]<0)bfs(i, 0);
            int nn=0,mm=0;
            for(int j=0;j<N;++j){
                if(white[j]==0)++nn;
                if(white[j]==1)++mm;
                if(white[j]>=0)white[j]=2;
            }
            sub.add(Math.abs(nn-mm));
        }
        if(!nibu)System.out.println(-1);
        else{
            int amari = 0;
            for(int i=0;i<N;++i)if(white[i]<0)++amari;
            boolean[][] dp =new boolean[N+1][N];
            dp[0][0]=true;
            for(int i=0;i<N;++i){
                for(int j=0;j<N;++j){
                    if(dp[i][Math.abs(j-sub.get(i))])dp[i+1][j]=true;
                    if(j+sub.get(i)<N && dp[i][j+sub.get(i)])dp[i+1][j]=true;
                }
            }
            int s=0;
            for(int i=N-1;i>=0;--i)if(dp[N][i])s=i;
            int left=-1,right=s-1;
            while(++left + ++right < N-amari);
            while(amari-->0){
                if(right>left)++left;
                else ++right;
            }
            System.out.println((left*(left-1))/2 + (right*(right-1)/2));
        }
    }
}

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

using namespace std;

int main(){
	long long A, B, C, K;
	long long MX = 1e18;
	cin >> A >> B >> C >> K;
	long long ans = A - B;
	if(K & 1LL) ans = B - A;
	if(ans > MX) cout << "unfair\n";
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

std::vector<std::vector<ll>> d;

void warshall_floyd(int n){
    rep(i,0,n){
        rep(j,0,n){
            rep(k,0,n){
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    d.resize(n);
    rep(i,0,n){
        d[i].assign(n,INF);
        d[i][i] = 0;
    }
    vector<int> a(m),b(m),c(m);
    rep(i,0,m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    warshall_floyd(n);
    vector<int> e(m,0);
    rep(i,0,m){
        rep(j,0,n){
            if(d[j][a[i]]+c[i]==d[j][b[i]]){
                e[i]++;
            }
        }
    }
    int ans = 0;
    rep(i,0,m){
        if(e[i]==0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string a,b;
  cin>>a>>b;
  a+=b;
  int num=atoi(a.c_str());
  for(int i=1;i<=1000;i++){
    if(i*i==num){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int main(void) {
	char S[128];
	int len, i;
	int asumisu = 0;
	if (scanf("%127s", S) != 1) return 1;
	len = (int)strlen(S);
	for (i = 0; i < len - 1 - i; i++) {
		if (S[i] != S[len - 1 - i]) asumisu++;
	}
	printf("%d\n", asumisu);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();
        System.out.println((60*H2+M2)-(60*H1+M1)-K);
    }
}

Measured memory_bytes: 35800
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> Map;
    ll sum = 0;
    rep(i,N){ 
        cin >> A[i];
        Map[A[i]]++;
        sum += A[i];
    }

    ll Q;
    cin >> Q;
    rep(i,Q){
        ll B, C;
        cin >> B >> C;
        ll num = Map[B];
        Map[B] = 0;
        Map[C] += num;
        sum += num * (C-B);
        cout << sum << endl;
    }

}

Measured memory_bytes: 9944
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int n = b - a - 1;
    int ax = 0;
    for (int i = 1; i <= n; i++) {
      ax += i;
    }
    System.out.println(ax - a);
  }
}

Measured memory_bytes: 23508
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int S=0,T;
struct edge{
	int s,t,cap;long long v;int nxt;
}e[50005];
int e_cnt,last[5005];
void addedge(int u,int v,int cap,long long l){
	e[e_cnt]=(edge){u,v,cap,l,last[u]};
	last[u]=e_cnt++;
	e[e_cnt]=(edge){v,u,0,-l,last[v]};
	last[v]=e_cnt++;
}
long long d[5005];int fa[5005],Mn[5005];
bool in[5005];
int q[5005],h,t;
bool spfa(){
	for(int i=0;i<=T;i++)d[i]=-1e18;
	for(int i=0;i<=T;i++)Mn[i]=0;
	memset(in,0,sizeof(in));
	h=t=-1;
	d[S]=0; Mn[S]=1e9;
	q[++t]=S;
	while(h!=t){
		h=(h+1)%5000;
		int x=q[h];
		// cerr<<x<<endl;
		for(int i=last[x];i!=-1;i=e[i].nxt)if(e[i].cap&&d[e[i].t]<d[x]+e[i].v){
			d[e[i].t]=d[x]+e[i].v;
			fa[e[i].t]=i;
			Mn[e[i].t]=min(Mn[x],e[i].cap);
			if(!in[e[i].t])q[t=(t+1)%5000]=e[i].t,in[e[i].t]=1;
		}
		in[x]=0;
	}
	return Mn[T]>0;
}
pair<int,long long> solve(){
	int flow=0;long long cost=0;
	while(spfa()){
		// cerr<<flow<<endl;
		flow+=Mn[T];
		cost+=d[T]*Mn[T];
		int u=T;
		while(u!=S){
			e[fa[u]].cap-=Mn[T];
			e[fa[u]^1].cap+=Mn[T];
			u=e[fa[u]].s;
		}
	}
	return make_pair(flow,cost);
}
int x0[1005],y0[1005],c0[1005],x1[1005],y1[1005],c1[1005];
int main(){
	//freopen("a.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&x0[i],&y0[i],&c0[i]);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&x1[i],&y1[i],&c1[i]);
	memset(last,-1,sizeof(last));
	for(int i=1;i<=n;i++)addedge(S,i,c0[i],0);
	for(int i=1;i<=n;i++){
		addedge(i,n+1,1e9,x0[i]+y0[i]);
		addedge(i,n+2,1e9,x0[i]-y0[i]);
		addedge(i,n+3,1e9,-x0[i]+y0[i]);
		addedge(i,n+4,1e9,-x0[i]-y0[i]);
		
		addedge(n+1,i+n+4,1e9,-x1[i]-y1[i]);
		addedge(n+2,i+n+4,1e9,-x1[i]+y1[i]);
		addedge(n+3,i+n+4,1e9,x1[i]-y1[i]);
		addedge(n+4,i+n+4,1e9,x1[i]+y1[i]);
	}
	T=2*n+5;
	for(int i=1;i<=n;i++)addedge(i+n+4,T,c1[i],0);
	printf("%lld\n",solve().second);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

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


    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, 0, n)

const int inf = 999999999;
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	cin.tie(0);
	int R, G;
	cin >> R >> G;
	cout << G + (G - R);

	system("pause");
	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


ll gcd(ll a,ll b){
  if(a<b)swap(a,b);
  if(a%b==0)return b;
  return gcd(a%b,b);
}


ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}


int main()
{
  ll a, b, c, d, xc, xd, xcd, cdlcm;
  cin >> a >> b >> c >> d;
  xc = b / c - (a - 1) / c;
  xd = b / d - (a - 1) / d;
  cdlcm = lcm(c, d);
  xcd = b / cdlcm - (a - 1) / cdlcm;
  cout << b - a + 1 - xc - xd + xcd << endl;
}


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

using ll= long long;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    string T; cin >> T;
    int size=T.size();
    vector<vector<ll>> dp(size+1, vector<ll>(2, 0));
    if(T[0] == 'P'){
        dp[1][0]=0;
        dp[1][1]=-INF;
    }
    else if(T[0] == 'D'){
        dp[1][0]=-INF;
        dp[1][1]=1;
    }
    else{
        dp[1][0]=-INF;
        dp[1][1]=1;
        T[0]='D';
    }
    for(int i=1; i<size; i++){
        if(T[i] == 'P'){
            dp[i+1][0]=max(dp[i][0],dp[i][1]);
            dp[i+1][1]=-INF;
        }
        else if(T[i] == 'D'){
            dp[i+1][1]=max(dp[i][0]+2,dp[i][1]+1);
            dp[i+1][0]=-INF;
        }
        else{
            dp[i+1][0]=max(dp[i][0],dp[i][1]);
            dp[i+1][1]=max(dp[i][0]+2,dp[i][1]+1);
            if(dp[i+1][0] > dp[i+1][1]){
                T[i]='P';
                dp[i+1][1]=-INF;
            }
            else{
                T[i]='D';
                dp[i+1][0]=-INF;
            }
        }
    }
    cout << T << endl;
    return 0;
}


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

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



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

    llong a,b,c; cin>>a>>b>>c;
    llong k; cin>>k;
    if(k%2==0) cout<<a-b<<endl;
    else cout<<b-a<<endl;


    return  0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>

using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};


int main(){
	int solutions[200][8];
	int counter=0;
	int array[8]={0,1,2,3,4,5,6,7};
	do{
		bool ok=true;
		for(int i=0;i<8;i++){
			if(ok){
				for(int j=i+1;j<8;j++){
					if(i!=j and abs(array[i]-array[j])==abs(i-j)){
						ok=false;
					}
				}
			}
		}
		if(ok){
			for(int i=0;i<8;i++){
				solutions[counter][i]=array[i];
			}
			counter++;
		}
	}while(next_permutation(array,array+8));
	int n;cin>>n;
	int check[8],ind[8];
	for(int i=0;i<n;i++){
		cin>>ind[i]>>check[i];
	}
	for(int i=0;i<counter;i++){
		bool ok=true;
		for(int j=0;j<n;j++){
			if(solutions[i][ind[j]]!=check[j]){
				ok=false;
			}
		}
		if(ok){
			for(int k=0;k<8;k++){
				for(int j=0;j<solutions[i][k];j++){
					cout<<".";
				}
				cout<<"Q";
				for(int j=solutions[i][k]+1;j<8;j++){
					cout<<".";
				}
				cout<<endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if

signed main(){
  int n;
  cin>>n;
  int sum=0;
  for(int i=1; i<=n; i++){
    int b=i;
    if(b%3==0)
      b=0;
    else if(b%5==0)
      b=0;
    sum+=b;
  }
  cout<<sum<<endl;
}


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

#define N 2100
struct Edge {
	int v, nxt;
} e[N << 1];
int head[N], cnt;

inline void addedge(int u, int v) {
	e[++cnt] = (Edge){v, head[u]};
	head[u] = cnt;
}

int count(int x, int fa, int k) {
	if (!k)
		return 1;
	int ans = 1;
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].v != fa)
		ans += count(e[i].v, x, k - 1);
	return ans;
}

int main() {
	int n, k, s = 0, t = 0;
	scanf("%d %d", &n, &k);
	for (int i = 1, u, v; i < n; i++)
		scanf("%d %d", &u, &v), addedge(u, v), addedge(v, u);
	
	if (k % 2 == 0) {
		int ans = 0;
		for (int i = 1; i <= n; i++)
			ans = max(ans, count(i, 0, k / 2));
		printf("%d\n", n - ans);
	} else {
		int ans = 0;
		for (int i = 1; i <= n; i++)
			for (int j = head[i]; j; j = e[j].nxt)
				ans = max(ans, count(i, e[j].v, k / 2) + count(e[j].v, i, k / 2));
		printf("%d\n", n - ans);
	}
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    if(n<105){
        cout<<0<<endl;
        return 0;
    }
    if(n<135){
        cout<<1<<endl;
        return 0;
    }
    if(n<165){
        cout<<2<<endl;
        return 0;
    }
    if(n<189){
        cout<<3<<endl;
        return 0;
    }
    if(n<195){
        cout<<4<<endl;
        return 0;
    }
    cout<<5<<endl;
    return 0;
}

Measured memory_bytes: 384
#! /usr/bin/env ruby

input = STDIN.read.split("\n").map{|l| l.split(" ").map{|i| i.to_i}}

N = input[0][0]
M = input[0][1]

input.shift

prefs = {}
years_city_index = {}

input.each_with_index do |py, i|
  pref = py[0]
  year = py[1]
  years_city_index[year] = i

  if prefs[pref] == nil
    prefs[pref] = []
  end
  prefs[pref].push(year)
end

numbers = []

prefs.each do |pref, years|
  years.sort!
  years.each_with_index do |y, i|
    number = format('%06d', pref) + format('%06d', i + 1)
    city_i = years_city_index[y]
    numbers[city_i] = number
  end
end

numbers.each do |number|
  puts number
end


Measured memory_bytes: 42236
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int n,k,ans=1919114514;
int i;
cin>>n>>k;
vector<int>h(n);
for(i=0;i<n;i++)cin>>h[i];
sort(h.begin(),h.end());
for(i=0;i<n-k+1;i++){
if(ans>h[i+k-1]-h[i])ans=h[i+k-1]-h[i];
}

cout<<ans;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int d = sc.nextInt();
		
		int[][] x = new int[n][d];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int tmp = 0;
				for (int k = 0; k < d; k++) {
					tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
				}
				
				int sqrt = (int)Math.sqrt(tmp);
				if (sqrt * sqrt == tmp) {
					ans++;
				}
			}
		}
		
		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

int n;

int main(){
    cin >> n;
    int d[n];
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    sort(d, d+n);
    cout << d[n/2]-d[n/2-1] << endl;
}


Measured memory_bytes: 888
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Arrow
import Control.Monad
import Control.Monad.ST
import Control.Monad.State.Strict
import Data.Char
import Data.Function
import Data.List
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Unsafe as B

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

main :: IO ()
main = do
  !n <- readLn :: IO Int
  print $ n^3


Measured memory_bytes: 508
import collections

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

c = collections.Counter(a)
i = 0
cnt = 0
for key, val in sorted(c.items(), key=lambda x: -x[1]):
    # print(key, val)
    cnt += val
    i += 1
    if i >= k:
        break
        
print(n - cnt)

Measured memory_bytes: 43088
#include<bits/stdc++.h>
using namespace std;
const int inf=100000+10;
vector<int> v[inf];
queue<int> q;
int d[inf],ans[inf];
int n,m,x,y;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		v[x].push_back(y);
		d[y]++;
	}
	for(int i=1;i<=n;i++){
		if(!d[i]) q.push(i);
	}
	while(!q.empty()){
		int u=q.front();
		int num=ans[u];
		q.pop();
		for(int i=0;i<v[u].size();i++){
			int nex=v[u][i];
			d[nex]--;
			if(!d[nex]) q.push(nex);
			ans[nex]=max(ans[nex],num+1);
		}
	}
	int fans=0;
	for(int i=1;i<=n;i++) fans=max(fans,ans[i]);
	cout<<fans<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int mult(int x, int y) {
	return 1ll * x * y % mod;
}
void mult_self(int& x, int y) {
	x = mult(x, y);
}
int add(int x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
	return x;
}
void add_self(int& x, int y) {
	x = add(x, y);
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) {
		x += mod;
	}
	return x;
}
void sub_self(int& x, int y) {
	x = sub(x, y);
}
int bin_pow(int x, int y) {
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 0) {
		return bin_pow(mult(x, x), y / 2);
	}
	return mult(x, bin_pow(x, y - 1));
}
int inv(int x) {
	return bin_pow(x, mod - 2);
}
const int maxn = 4e5;
vector<int> fact(maxn), inv_fact(maxn);
int C(int x, int y) {
	return mult(fact[x], mult(inv_fact[y], inv_fact[x - y]));
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	fact[0] = 1;
	for (int i = 1; i < maxn; ++i) {
		fact[i] = mult(fact[i - 1], i);
	}
	for (int i = 0; i < maxn; ++i) {
		inv_fact[i] = inv(fact[i]);
	}
	int n, k;
	cin >> n >> k;
	int answer = 0;
	for (int i = 1; i <= n; ++i) {
		if (n - i <= k) {
			add_self(answer, mult(C(n, i), C(n - 1, i - 1)));
		} 
		//~ debug(i, answer);
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    String a = s1.toUpperCase();
    String b = s2.toUpperCase();
    String c = s3.toUpperCase();
    System.out.print(a.charAt(0));
    System.out.print(b.charAt(0));
    System.out.print(c.charAt(0));
    System.out.println();
  }
}


Measured memory_bytes: 22612
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();
    let s = {
        let mut ss = 0;
        let mut nn = n;
        while nn > 0 {
            ss += nn % 10;
            nn /= 10;
        }
        ss
    };

    yn(n % s == 0);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
  ll H,W,M;cin>>H>>W>>M;
  vl h(M),w(M);
  vl nh(H+1),nw(W+1);
  rep(i,M){
    cin>>h[i]>>w[i];
    nh[h[i]]++,nw[w[i]]++;
  }
  ll mh=0,mw=0,ch=0,cw=0;
  rep(i,H+1){
    mh=max(mh,nh[i]);
  }
  rep(i,H+1){
    if(nh[i]==mh)ch++;
  }
  rep(i,W+1){
    mw=max(mw,nw[i]);
  }
  rep(i,W+1){
    if(nw[i]==mw)cw++;
  }
  ll j=0;
  rep(i,M){
     if(nh[h[i]]+nw[w[i]]-1 ==mh+mw -1)j++;
  }
  if(j==ch*cw)cout<<mh+mw-1<<endl;
  else cout<<mh+mw<<endl;
    
  
 
}






Measured memory_bytes: 12736
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

internal class Program {
    static void Main() => CustomMain();

    static void Solve() {
        var a = ReadIntArray();
        if (a.Sum() >= 10) {
            WriteAnswer("error");
            return;
        }

        WriteAnswer(a.Sum());
    }


    static void CustomMain() {
#if DEBUG
        // ファイルからテストケースを読み込む
        ChangeStdIn();
        // 時間計測
        var stopwatch = new Stopwatch();
        stopwatch.Start();
#endif
        // 出力高速化
        var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(streamWriter);
        // 回答
        Solve();
#if DEBUG
        stopwatch.Stop();
        Console.WriteLine(stopwatch.Elapsed);
#endif
        Console.Out.Flush();
    }

    static string ReadString() => Console.ReadLine().Trim();
    static int ReadInt() => int.Parse(ReadString());
    static long ReadLong() => long.Parse(ReadString());
    static float ReadFloat() => float.Parse(ReadString());
    static double ReadDouble => double.Parse(ReadString());

    static string[] ReadStringArray() => ReadString().Split(' ');
    static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
    static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
    static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
    static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

    static T TypeConversion<T>(string s) {
        if (typeof(T) == typeof(int)) {
            return (T) Convert.ChangeType(int.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(long)) {
            return (T) Convert.ChangeType(long.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(double)) {
            return (T) Convert.ChangeType(double.Parse(s), typeof(T));
        } else {
            return (T) Convert.ChangeType(s, typeof(T));
        }
    }

    static void ReadMulti<T, U>(out T a, out U b) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
    }

    static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
        c = TypeConversion<V>(str[2]);
    }

    static void WriteAnswer(object ans) => Console.WriteLine(ans);

    static bool IsOdd(long num) {
        return (num & 1) == 1;
    }

    static bool IsEven(long num) {
        return (num & 1) == 0;
    }

    static long GCD(long a, long b) {
        return b != 0 ? GCD(b, a % b) : a;
    }

    static long RoundUp(long a, long b) {
        return (a + b - 1) / b;
    }


    static void ChangeStdIn() {
        var path = "./../../TestCase.txt";
        var exStdIn = new System.IO.StreamReader(path);
        Console.SetIn(exStdIn);
    }
}

Measured memory_bytes: 13652
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;

	int count=0;
	if (s[0] == 'o') count++;
	if (s[1] == 'o') count++;
	if (s[2] == 'o') count++;

	cout << 700 + 100 * count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  n1 = N / 1000;
  n2 = N % 1000 / 100;
  n3 = N % 100 / 10 ;
  n4 = N % 10;
  
  if (n2 != n3) { cout << "No" << endl; }
  else if (n1 == n2 || n3 == n4) { cout << "Yes" << endl; }
  else cout << "No" << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#define inf 1000000000

using namespace std;

struct State{
	int x, y, dir;
	State(){}
	State(int a, int b, int c){
		x = a, y = b, dir = c;
	}
	bool operator<(const State& obj)const{
		return x > obj.x || (x == obj.x && y > obj.y) || (x == obj.x && y == obj.y && dir > obj.dir);
	}
};
typedef pair<int, State> P;

int H, W, N;
char s[1000005];
char map[1005][1005];
int sx, sy, gx, gy;
int dist[1005][1005][4];

int dir[1000005];
int next[1000005][4];
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void dijkstra()
{
	for(int x = 1; x <= W; x++){
		for(int y = 1; y <= H; y++){
			for(int d = 0; d < 4; d++){
				dist[x][y][d] = inf;
			}
		}
	}
	dist[sx][sy][1] = 0;
	
	priority_queue<P, vector<P>, greater<P> > Q;
	Q.push(make_pair(0, State(sx, sy, 1)));
	
	int x, y, dir, d;
	int nx, ny, ndir;
	while(Q.size()){
		d = Q.top().first;
		x = Q.top().second.x;
		y = Q.top().second.y;
		dir = Q.top().second.dir;
		Q.pop();
		
		if(dist[x][y][dir] < d) continue;
		
		nx = x + dx[dir], ny = y + dy[dir], ndir = dir;
		if(nx <= 0 || nx > W || ny <= 0 || ny > H) goto pass;
		if(map[nx][ny] == '#') goto pass;
		if(dist[nx][ny][ndir] < inf) goto pass;
		
		dist[nx][ny][ndir] = dist[x][y][dir];
		Q.push(make_pair(dist[nx][ny][ndir], State(nx, ny, ndir)));
		
		pass:;
		for(int i = 0; i < 4; i++){
			nx = x, ny = y, ndir = i;
			if(dist[nx][ny][ndir] < inf) continue;
			if(next[d][ndir] >= inf) continue;
			if(dist[nx][ny][ndir] > next[d][ndir]){
				dist[nx][ny][ndir] = next[d][ndir];
				Q.push(make_pair(dist[nx][ny][ndir], State(nx, ny, ndir)));
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> H >> W >> N;
		if(H == 0 && W == 0 && N == 0) break;
		
		for(int i = 1; i <= N; i++) cin >> s[i];
		for(int y = 1; y <= H; y++){
			for(int x = 1; x <= W; x++){
				cin >> map[x][y];
				if(map[x][y] == 'S'){
					map[x][y] ='.';
					sx = x, sy = y;
				}
				if(map[x][y] == 'G'){
					map[x][y] = '.';
					gx = x, gy = y;
				}
			}
		}
		
		dir[0] = 1;
		for(int i = 1; i <= N; i++){
			if(s[i] == 'L') dir[i] = (dir[i-1] + 1) % 4;
			if(s[i] == 'R') dir[i] = (dir[i-1] + 3) % 4;
		}
		int nx[4] = {inf, inf, inf, inf};
		for(int i = N; i >= 0; i--){
			nx[dir[i]] = i;
			for(int j = 0; j < 4; j++) next[i][j] = nx[j];
		}
		
		dijkstra();
		
		bool ans = false;
		for(int i = 0; i < 4; i++){
			ans |= (dist[gx][gy][i] < inf); 
		}
		if(ans) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}


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

using namespace std;

int euclidean_gcd(int a, int b) {
  if (a < b) euclidean_gcd(b, a);
  int r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int n, x;
  vector<int> vx;
  cin >> n >> x;

  if (n == 1) {
    int xx;
    cin >> xx;
    cout << (int)abs(x - xx) << endl;
  } else {
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      vx.push_back(tmp);
    }
    sort(vx.begin(), vx.end());
    int ans = vx[1] - vx[0];
    for (int i = 1; i < n - 1; i++) {
      int diff = vx[i + 1] - vx[i];
      ans = euclidean_gcd(ans, diff);
    }
    int xdif = (int)abs(vx[0] - x);
    int ans_tmp = max( euclidean_gcd(xdif, ans), ans_tmp);
    for (int i = 1; i < n; i++) {
      xdif = (int)abs(vx[i] - x);
      ans_tmp = max( euclidean_gcd(xdif, ans), ans_tmp);
    }
    cout << ans_tmp << endl;
  }
}

Measured memory_bytes: 892
#include <cstdio>
#include <cmath>

bool triangle(int x, int y, int z) {
	return pow((double)x, 2) + pow((double)y, 2) == pow((double)z, 2);
}

int main(void) {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		if(triangle(x, y, z) || triangle(y, z, x) || triangle(z, x, y))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 596