akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int n, a[200]={0};
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    sort(a, a+n);
    int ans=1, now=a[0];
    for(int i=0; i<n; i++){
        if(now != a[i]){
            ans++;
            now=a[i];
        }
    }
    printf("%d\n", ans);

    return 0;
}



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

int main() {
    int bingo[3][3];
    bool card[3][3];
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            cin>>bingo[i][j];
            card[i][j]=false;
        }
    }
    int n;
    cin>>n;
    int open[n];
    for(int i=0; i<n; i++) cin>>open[i];

    for(int k=0; k<n; k++) {
        for(int i=0; i<3; i++) {
            for(int j=0; j<3; j++) {
                if(open[k]==bingo[i][j]) card[i][j]=true;
            }
        }
    }

    bool flag = false;
    if(card[0][0] && card[0][1] && card[0][2]) flag = true;
    if(card[1][0] && card[1][1] && card[1][2]) flag = true;
    if(card[2][0] && card[2][1] && card[2][2]) flag = true;
    if(card[0][0] && card[1][0] && card[2][0]) flag = true;
    if(card[0][1] && card[1][1] && card[2][1]) flag = true;
    if(card[0][2] && card[1][2] && card[2][2]) flag = true;
    if(card[0][0] && card[1][1] && card[2][2]) flag = true;
    if(card[0][2] && card[1][1] && card[2][0]) flag = true;

    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + int(s[i] == '#')
mincost = n
for i in range(n+1):
    mincost = min(mincost, 2 * cum[i] - cum[n] + (n - i))
print(mincost)

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
int a;
vector<vector<int>>b(n);
ll ans=0;
rep(i,n){
    cin>>a;
    a--;
    for(auto v:b[i]){
        if(v==a){
            ans++;
        }
    }
    b[a].pb(i);
}
cout<<ans<<endl;
return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fi > xed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  int ans = 0;
  rep(i, 0, n) {
    cin >> a[i];
    if (i != 0) {
      if (a[i - 1] + a[i] > x) {
        ans += (a[i - 1] + a[i]) - x;
        a[i] = max(a[i]-(a[i - 1] + a[i] - x), (int)0);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(n + 1);
    int x, y;
    rep(i, m)
    {
        cin >> x >> y;
        v[x]++;
        v[y]++;
    }
    bool ans = true;
    rep(i, n + 1)
    {
        ans &= (v[i] % 2 == 0);
    }
    if (ans)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

int bitCount(ll n) {
    int cnt = 0;
    while (n > 0) {
        cnt += n & 1;
        n >>= 1;
    }
    return cnt;
}

int main() {
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N, -1));
    REP(i, 0, N) {
        int a; cin >> a;
        REP(j, 0, a) {
            int x, y; cin >> x >> y;
            A[i][--x] = y;
        }
    }

    int answer = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        bool ok = true;
        REP(i, 0, N) {
            if (bit & (1 << i)) {
                REP(j, 0, N) {
                    if (A[i][j] == -1) continue;
                    if (bit & (1 << j) && A[i][j] == 0) ok = false;
                    if (!(bit & (1 << j)) && A[i][j] == 1) ok = false;
                }
            }
        }
        if (ok) {
            answer = max(answer, bitCount(bit));
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
map<int,ll>::iterator it;
int n,m;
int main(){
	cin>>n>>m;
	map<int,ll> mp;
	multiset<ll> values;
	for(int i=1; i<=m; i++){
		mp[i]=0;
		values.insert(0);
	}
	for(int i=1;i<=n;i++){
		int l,r;
		cin>>l>>r;
		if(r!=m){
			it=mp.upper_bound(r+1);
			if(it!=mp.begin()){
				it--;
				if(it->first!=r+1){
					int64_t v=it->second+(r+1-it->first);
					mp[r+1]=v;
					values.insert(v);
				}
			}
		}
		it=mp.lower_bound(l);
		while(it!=mp.end()&&it->first<=r){
			values.erase(values.find(it->second));
			it=mp.erase(it);
		}
		if(values.size())
			cout<<i+*values.begin()<<endl;
		else
			cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 25440
#include<bits/stdc++.h>
using namespace std;
const int SIZE = 200005;
int A[SIZE];
int main(){
    int N; cin >> N;
    for (int i = 2; i <= N; i++)
    {
        int Ai; cin >> Ai;
        A[Ai]++;
    }
    for (int i = 1; i <= N; i++)
    {
        cout << A[i] << endl;
    }
    
}

Measured memory_bytes: 4364
#include <stdio.h>



int main(void) {

	// 1_7-C Spreadsheet
	
	int r,c;
	int tbl[101][101];
	int i,j;

	scanf("%d",&r);
	scanf("%d",&c);

	for(i=0; i<(r+1); i++){
		for(j=0; j<(c+1); j++){
			tbl[i][j]=0;
		}
	}
	
	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			scanf("%d",&tbl[i][j]);
			tbl[r][j] += tbl[i][j];
			tbl[i][c] += tbl[i][j];
			tbl[r][c] += tbl[i][j];
		}
	}
	for(i=0; i<(r+1); i++){
		for(j=0; j<(c+1); j++){
			printf("%d",tbl[i][j]);
			if(j<c){
				putchar(' ');
			}else{
				putchar('\n');
			}
		}
	}

	return 0;

}

Measured memory_bytes: 644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char r = in.nextChar();
            char g = in.nextChar();
            char b = in.nextChar();
            String sum = r + "" + g + "" + b + "";
            int ans = Integer.parseInt(sum);
            if (ans % 4 == 0) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public char nextChar() {
            return next().charAt(0);
        }

    }
}



Measured memory_bytes: 21460
N = int(input())
A = [int(x) for x in input().split()]
r = [0 for i in range(N)]

temp = sum(A[1::2]) - sum(A[:N-1:2])

r[0] = A[N-1] - temp

for i in range(1,N):
    r[i] = 2*A[i-1] - r[i-1]

r = map(str,r)
print(" ".join(r))


Measured memory_bytes: 18072
#define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define ll long long
#define sz(x) (int)(x).size()
#define endl '\n'
#define print_case() cout << "Case #" << test_case_number++ << ": "

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

int test_case_number = 1;

void solve(){
    print_case();
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin >> k;
    string s;
    cin >> s;

    int n = s.size();
    if(n <= k)
        cout << s << endl;
    else{
        for(int i = 0; i < k; ++i)
            cout << s[i];
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	
	static int N;
	static List<Integer> adj[];
	static int[] dist;
	
	static void calc(int node, int parent) {
		for (int neigh : adj[node]) if (neigh != parent) {
			dist[neigh] = dist[node] + 1;
			calc(neigh, node);
		}
	}
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		N = sc.nextInt();
		adj = new List[N];
		for (int i = 0; i < adj.length; i++) {
			adj[i] = new ArrayList<>();
		}
		for (int i = 0; i < N - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			adj[a].add(b);
			adj[b].add(a);
		}
		dist = new int[N];
		dist[0] = 0;
		calc(0, -1);
		int bestI = -1;
		for (int i = 0; i < N; i++) {
			if (bestI == -1 || dist[bestI] < dist[i]) {
				bestI = i;
			}
		}
		dist[bestI] = 0;
		calc(bestI, -1);
		int diameter = Arrays.stream(dist).max().getAsInt() + 1;
		out.println(diameter % 3 == 2 ? "Second" : "First");
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 92344
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    int N; cin >> N;
    int zoro = 0;
    bool ans = false;
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        if (a == b) zoro++;
        else zoro = 0;
        if (zoro >= 3) ans = true;
    }
    cout << (ans ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

void SolveA()
{
	int n, cnt = 0;
	scanf("%d", &n);

	while (n >= 3)
	{
		n = n - 3;
		cnt++;
	}

	printf("%d\n", cnt);
}

int main()
{
	SolveA();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#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 vv 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 INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int box[1000][1000];
int H, W;
queue<pi> Q;
int num = 0;
pi act[4];

signed main(void) {
    act[0].first = 1;
    act[0].second = 0;
    act[1].first = 0;
    act[1].second = 1;
    act[2].first = -1;
    act[2].second = 0;
    act[3].first = 0;
    act[3].second = -1;

    cin >> H >> W;
    rep(i,H){
        rep(j,W){
            char a;
            cin >> a;
            if(a=='#'){
                box[i][j] = 0;
            }else{
                box[i][j] = -1;
            }
        }
    }

    rep(i,H){
        rep(j,W){
            if(box[i][j]==0){
                pi a;
                a.first = i;
                a.second = j;
                Q.push(a);
            }
        }
    }

    while(!Q.empty()){
        pi now = Q.front();
        Q.pop();
        int i,j;
        i = now.first;
        j = now.second;
        rep(a,4){
            int x,y;
            x = i + act[a].first;
            y = j + act[a].second;

            if(x >=0 && x < H && y >=0 && y < W && box[x][y] == -1){
                box[x][y] = box[i][j] + 1;
                num = box[x][y];
                pi tsugi;
                tsugi.first = x;
                tsugi.second = y;
                Q.push(tsugi);
            }
        }

    }

    cout << num << endl;


    return 0;
}


Measured memory_bytes: 24372
#include<algorithm>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define 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 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main(){
    int t5=0,t7=0;
    for(int i=0;i<3;i++){
        int a;
        cin >> a;
        if(a==5){
            t5++;
        }
        if(a==7){
            t7++;
        }
    }
    if(t5==2 && t7==1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

const int dx[] = {0,1,0,-1, 0,2,0,-2, 0,3,0,-3};
const int dy[] = {1,0,-1,0, 2,0,-2,0, -3,0,3,0};
vector<string> field;

void dfs(int y, int x){// cout << y << " " << x << endl;
    int i;

    field[y][x] = '0';
    rep(i,12){
        int my = y + dy[i];
        int mx = x + dx[i];
        if(my < 0 || mx < 0 || 8 <= mx || 8 <= my) continue;

        if(field[my][mx] == '1') dfs(my,mx);
        field[my][mx] = '0';
    }
}

int main(){
    int i,j,k;
    int pretty = 0;

    int n = in();
    while(n--){
        field.resize(8);
        rep(i,8) cin >> field[i];
        int x = in()-1, y = in()-1;

        dfs(y,x);

        cout << "Data " << ++pretty << ":" << endl;
        rep(i,8) cout << field[i] << endl;
        field.clear();
    }

    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Card{
    public String suit;
    public int value;
    public int index;
    
    Card(String suit,int  value, int index){
	this.suit = suit;
	this.value = value;
	this.index = index;
    }
}

public class Main{
    public static void main(String[] args){
	int i, q;
	
	Scanner s = new Scanner(System.in);
	int n = s.nextInt();
    	Card[] A = new Card[n];

	for(i=0;i<n;i++){
	    A[i] = new Card(s.next(), s.nextInt(), i);
	}
	



	quickSort(A, 0, n-1);

	if(isStable(A) == true){
	    System.out.print("Stable\n");
	}else{
	    System.out.print("Not stable\n");
	}
	for(i=0; i<n; i++){
	    System.out.printf("%s %d\n", A[i].suit, A[i].value);
	    
	}
    }

    public static void quickSort(Card[] A, int p, int r){
	int q;
	if(p < r){
	    q = partition(A, p, r);
	    quickSort(A, p, q - 1);
	    quickSort(A, q + 1, r); 
	}
    }
    
    public static int partition(Card[] A, int p, int r){
	int x, i, j;
	Card tmp;
	x = A[r].value;
	i = p-1;
	for(j=p; j<r; j++){
	    if(A[j].value<=x){
		i++;
		tmp = A[i]; A[i] = A[j]; A[j] = tmp;
	    }
	}
	tmp = A[i+1]; A[i+1] = A[r]; A[r] = tmp;
	return i+1;
    }
    
    static boolean isStable(Card[] A){
	for(int i = 0; i < A.length; i++){
	    for(int j = i + 1; j < A.length; j++){
		if(A[i].value == A[j].value && A[i].index > A[j].index)
		    return false;
	    }
	}
    return true;
    }	    
}

Measured memory_bytes: 140164
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

vector<int> a,b,w;

bool check(int time){
	long long ret = 0;
	rep(i,a.size()){
		if(a[i] <= time && time < b[i])ret += w[i];
	}
	return ret<=150;
}
	
int main(){
	int n;
	while(cin >> n ,n){
		a.resize(n),b.resize(n),w.resize(n);
		rep(i,n){
			cin >> w[i] >> a[i] >> b[i];
		}
		bool ret = true;
		rep(i,n)ret &= check(a[i]);
		rep(i,n)ret &= check(b[i]);
		cout << (ret?"OK":"NG") << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int go[n][2];
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> go[i][0] >> go[i][1];
    for(int i = 0; i < n - 1; i++) {
        if(go[i][0] <= go[i + 1][0] && go[i][1] <= go[i + 1][1])
            ans += max(go[i + 1][0] - go[i][0], go[i + 1][1] - go[i][1]);
        else if(go[i][0] >= go[i + 1][0] && go[i][1] >= go[i + 1][1])
            ans += max(go[i][0] - go[i + 1][0], go[i][1] - go[i + 1][1]);
        else if(go[i][0] <= go[i + 1][0] && go[i][1] >= go[i + 1][1])
            ans += (go[i + 1][0] - go[i][0]) + (go[i][1] - go[i + 1][1]);
        else if(go[i][0] >= go[i + 1][0] && go[i][1] <= go[i + 1][1])
            ans += (go[i][0] - go[i + 1][0]) + (go[i + 1][1] - go[i][1]);
        // cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		for(int i=0;i<M;i++){
			E[A[i]].Add(B[i]);
			E[B[i]].Add(A[i]);
		}
		
		int Inf = (int) 1e9;
		int[] min = new int[N];
		int[] prev = new int[N];
		for(int i=0;i<N;i++){
			min[i] = Inf;
			prev[i] = -1;
		}

		min[0] = 0;
		var q = new Queue<int>();
		q.Enqueue(0);
		while(q.Count > 0){
			var now = q.Dequeue();
			foreach(var nxt in E[now]){
				if(min[nxt] == Inf){
					min[nxt] = min[now] + 1;
					prev[nxt] = now;
					q.Enqueue(nxt);
				}
			}
		}
		
		var sb = new StringBuilder();
		sb.AppendLine("Yes");
		for(int i=1;i<N;i++){
			sb.AppendLine((prev[i] + 1).ToString());
		}
		Console.Write(sb.ToString());
		
		
	}
	int N,M;
	int[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 38572
import sys

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

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
        
if D == 1:
    if N == 100:
        print(10100)
    else:
        print(N * 100)
    
if D == 2:
    if N == 100:
        print(1010000)
    else:
        print(N * 10000)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<Vl> VVl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define BASE  (1000000000 + 7)
#define MAX_N (1000000000)
#define MAX_M (100000)

int N, M;
int X[MAX_M + 1];
Vl A{1, 3, 1};
VVl P{
  {2, 1, 0},
  {3, 1, 2},
  {1, 0, 1}},
Q{{1, 1, 0},
  {0, 1, 2},
  {0, 0, 1}},
R(3, Vl(3));

void mat_print(VVl &a) {
#ifdef DEBUG
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[0].size(); j++) {
      debug_printf("%lld ", a[i][j]);
    }
    debug_printf("\n");
  }
#endif
}

void mat_prod(VVl &a, VVl b, VVl c) {
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[0].size(); j++) {
      a[i][j] = 0;
      for (int k = 0; k < b[0].size(); k++) a[i][j] = (a[i][j] + b[i][k] * c[k][j]) % BASE;
    }
  }
}

void mat_pow(VVl &a, VVl b, ll n) {
  if (n == 0) {
    for (int i = 0; i < a.size(); i++)
      for (int j = 0; j < a[0].size(); j++) a[i][j] = (i == j)? 1: 0;
  } else {
    mat_pow(a, b, n / 2);
    mat_prod(a, a, a);
    if (n % 2 == 1) mat_prod(a, a, b);
  }
}

void solve() {
  mat_pow(R, P, X[0] - 1);
  for (int i = 1; i <= M; i++) {
    VVl s(3, Vl(3));
    mat_prod(R, R, Q);
    mat_pow(s, P, X[i] - X[i - 1] - 1);
    mat_prod(R, R, s);
  }

  ll ans = 0;
  for (int i = 0; i < 3; i++) ans = (ans + R[0][i] * A[i]) % BASE;

  printf("%lld\n", ans);
}

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

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
  int R, C, n;
  cin >> R >> C >> n;
  rep(i, n) {
    int r, c, v;
    cin >> r >> c >> v;
    a[r-1][c-1] = v;
  }
  rep(i, R) rep(j, C) {
    for (int k = 2; k >= 0; k--) {
      chmax(dp[i][j][k+1], dp[i][j][k] + a[i][j]);
    }
    rep(k, 4) {
      chmax(dp[i+1][j][0], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }
  ll ans = 0;
  rep(k, 4) chmax(ans, dp[R-1][C-1][k]);
  cout << ans << endl;
}

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


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

    for(int i=1;i<=2000;i++)
    {
        if((i*8)/100!=a)
            continue;
        if((i)/10!=b)
            continue;
        d1(i);return 0;
    }
    d1(-1);    
}

Measured memory_bytes: 256
#include <stdio.h>

int		main(void)
{
	char s[100001];
	int b;
	int r;
	int i;

	i = 0;
	b = 0;
	r = 0;
	scanf("%s", s);
	while (s[i])
	{
		if (s[i] == '0')
		{
			r++;
		}
		else if(s[i] == '1')
		{
			b++;
		}
		i++;
	}
	if (b > r)
	{
		printf("%d\n", r * 2);
	}
	else
	{
		printf("%d\n", b * 2);
	}
	return 0;
}


Measured memory_bytes: 1828
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<char,int> x,y;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
x['U']=1;x['D']=-1;y['L']=-1;y['R']=1;
int h,w,n;
cin>>h>>w>>n;
int nx,ny;
cin>>nx>>ny;
nx--;ny--;
string s,t;
cin>>s>>t;
bool stay=true;
int l=0,r=w-1;
if(s[n-1]=='L')l++;
if(s[n-1]=='R')r--;
//左右
for(int i=n-2;i>=0;i--){
    if(t[i]=='L'&&r!=w-1)r++;
    if(t[i]=='R'&&l!=0)l--;
    if(s[i]=='L')l++;
    if(s[i]=='R')r--;
    if(l>r)stay=false;
}
 if(ny<l||ny>r)stay=false;
int u=0,d=h-1;
if(s[n-1]=='U')u++;
if(s[n-1]=='D')d--;
//上下
for(int i=n-2;i>=0;i--){
    if(t[i]=='U'&&d!=h-1)d++;
    if(t[i]=='D'&&u!=0)u--;
    if(s[i]=='U')u++;
    if(s[i]=='D')d--;
    if(u>d)stay=false;
}
if(nx<u||nx>d)stay=false;
if(stay)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

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


int main() {
	int n,ans=0;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		a.push_back(b);
	}
	sort(a.begin(),a.end());
	int l=a.at(n/2-1);
	int m=a.at(n/2);
	ans= m-l;
	cout <<ans;
	return 0;
}

Measured memory_bytes: 892
import           Control.Monad
import           Data.Char
main=getLine>>=putStrLn.head.f.map digitToInt
f[a,b,c,d]=do
    [(op0,s0),(op1,s1),(op2,s2)]<-mapM(const[((+),"+"),((-),"-")])[1..3]
    let res = a `op0` b `op1` c `op2` d
    guard $ res == 7
    return $ shows a s0 ++ shows b s1 ++ shows c s2 ++ shows d "=7"

Measured memory_bytes: 380
using System;
 
namespace AOJ
{
    class DigitNumber
    {
        public static void Main(string[] args)
        {
            for (int i = 0; i < 200; i++)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
 
                var tmp = input.Split(' ');
 
                int test = int.Parse(tmp[0]) + int.Parse(tmp[1]);
                Console.WriteLine(test.ToString().Length);
            }
        }
    }
}

Measured memory_bytes: 9176
#include <stdio.h>
#define IN_MAX 999999

char table[IN_MAX+1];

void createtable(){ //0->prime 1->not prime
  int i=2,j;
  table[0]=table[1]=1;
  for(;i<=IN_MAX;i++)
    if(!table[i])
      for(j=i*2;j<=IN_MAX;j+=i)
        table[j]=1;
}

int main(){
  int a,d,n,c,x;
  createtable();
  for(;;){
    c=0;
    scanf("%d%d%d",&a,&d,&n);
    if(a==0)return 0;
    for(x=a;;x+=d){
      if(!table[x])c++;
      if(c==n){
        printf("%d\n",x);
        break;
      }
    }
  }
}

Measured memory_bytes: 1576
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<bool> win(k+1, false);
	for (int i = 0; i < k; i++) {
		for (auto x: a) {
			if (!win[i] && i + x <= k) {
				win[i + x] = true;
			}
		}
	}

	cout << (win[k] ? "First" : "Second") << endl;
	return 0;
}


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

using namespace std;

int main()
{
  int a, b, c; cin >> a >> b >> c;
  int cnt = 0;
  vector<bool> exist(10, 0);
  if(!exist[a])
  {
    exist[a] = 1;
    cnt++;
  }
  if(!exist[b])
  {
    exist[b] = 1;
    cnt++;
  }
  if(!exist[c])
  {
    exist[c] = 1;
    cnt++;
  }
  if(cnt == 2) cout << "Yes";
  else cout << "No";

  return 0;
}

Measured memory_bytes: 256
using System.Linq;
using static System.Console;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s1 = ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var x = s1[2];
            var y = s1[3];

            var zCandidates = Enumerable.Range(x + 1, y - x);

            var ns = ReadLine().Split(' ').Select(i => int.Parse(i));

            var ms = ReadLine().Split(' ').Select(i => int.Parse(i));


            var step1 = zCandidates.Where(i => ns.All(j => j < i));

            if (0 < step1.Count())
            {

                WriteLine(step1.Any(i => ms.All(j => i <= j)) ? "No War" : "War");
            }
            else
            {
                WriteLine("War");
            }

        }
    }
}


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

int main()
{
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int x = 0;
    for(int i=0; i<n; i++){
        if(a[i] == b[i] && a[i] == c[i]){
            x += 2;
        }else{
            if(b[i] == c[i]){
               x++;
            }else{
                if(a[i] == b[i]) x++;
                if(a[i] == c[i]) x++;
            }
        }
    }
    cout << 2*n -x  << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: u64,
    };

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    for _ in 0..n {
        input! {
            result: String,
        };

        let result = result.as_str();

        match result {
            "AC" => ac += 1,
            "WA" => wa += 1,
            "TLE" => tle += 1,
            "RE" => re += 1,
            _ => {}
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}


Measured memory_bytes: 2540
#include "bits/stdc++.h"
using namespace std;
int N;
int main() {
	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	auto DP = [&](auto &&d,int l, int r, int x, int y) ->long long int {
		if (l + 1 == r)return 0;
		long long int ret = LLONG_MAX;
		for (int i = l + 1; i < r; i++) {
			ret = min(ret, ((d(d,l, i, x, x + y)) + (d(d,i, r, x + y, y)) + v[i] * (x + y)));
		}
		return ret;
	};
	cout << DP(DP,0, N - 1, 1, 1) + v.front() + v.back() << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>

int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }

//int n, dp[31];
//
//int func(int p) {
//	if (p == n) {
//		return 1;
//	}
//	int cnt = 0;
//	for (int i = p + 1; n >= i && 3 + p >= i; i++) {
//		if (dp[i] == -1) dp[i] = func(i);
//		cnt += dp[i];
//	}
//	return cnt;
//}
//
//int main() {
//	while (scanf("%d", &n) != EOF) {
//		if (n == 0) return 0;
//		memset(dp, -1, sizeof(dp));
//		printf("%d\n", ((func(0)+9) / 10 + 364) / 365);
//	}
//}

int main() {
	int n, dp[33] = {};
	dp[30] = 1;
	for (int i = 29; 0 <= i; i--) {
		dp[i] = dp[i + 1] + dp[i + 2] + dp[i+3];
	}

	while (1) {
		scanf("%d", &n);
		if (!n)return 0;
		printf("%d\n", ((dp[30 - n] + 9) / 10 + 364) / 365);
	}
	return 0;
}

/*

dp[i] = {dp[i+1]+dp[i+2]+dp[i+3] ????????????

*/

Measured memory_bytes: 1028
#include <stdio.h>
#define N 100000
#define Q 50000
 
int search(int[],int[],int,int);
 
int main(void){
  
  int S[N];
  int T[Q];
  int n,q;
  int i;
  int count=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  
  scanf("%d",&q);
  
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  
  count = search(S,T,n,q);
  
  printf("%d\n",count);
  
  return 0;
}

int search(int S[],int T[],int n,int q){
  
  int i;
  int flag;
  int count=0;
  int min=0;
  int max = n-1;
  int mid;
  
  
  for(i=0;i<q;i++){
    flag=0;
    min = 0;
    max = n-1;
    while(min <= max){
      mid = (min+max)/2;
      
      if(S[mid] == T[i]){
	flag = 1;
	break;
      }
      
      else if(S[mid] < T[i])
	min = mid +1;
      
      else if(S[mid] > T[i])
	max = mid -1;
    }
    if(flag ==1)
      count++;

  }
  
  return count;
}

Measured memory_bytes: 1184
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;
ll gcd(ll x, ll y)
{
  if(x<y)
  {
    swap(x,y);
  }
  while(y>0)
  {
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}
int main(){
  ll a,b,c;cin>>a>>b>>c;
  ll k;cin>>k;
  int co=0;
  for(int i=0;i<10;i++){
    if(a>=b){
      b=b*2;
      co++;
    }
    else{
      break;
    }
  }
  for(int i=0;i<10;i++){
    if(b>=c){
      c=c*2;
      co++;
    }
    else{
      break;
    }
  }
  if(co<=k){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <cctype>

int main() {
        std::string w, t;
        int count = 0;

        std::cin >> w;
        transform (w.begin(), w.end(), w.begin(), tolower);

        while(true){
                std::cin >> t;
                if(t == "END_OF_TEXT") break;
                transform (t.begin(), t.end(), t.begin(), tolower);
                if(w == t) count++;
        }

        std::cout << count << std::endl;
}

Measured memory_bytes: 3116
from functools import reduce

n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
t = [int(m) for m in d]

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

#print(lcm(27, 18, 9, 3))
# 54

#print(lcm(27, 9, 3))
# 27

#print(lcm(*[27, 9, 3]))
# 27

print(lcm_list(t))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5005;
const int Q = 1e9 + 7;

int n;
char g[N][N];
int a[N] , b[N];

int main() {
    scanf("%d" , &n);
    int cnt = 0;
    for (int i = 0 ; i < n ; ++ i) {
        scanf("%s" , g[i]);
        for (int j = 0 ; j < n ; ++ j) {
            if (g[i][j] == '#') {
                ++ a[i];
                ++ b[j];
                ++ cnt;
            }
        }
    }
    if (cnt == 0) {
        puts("-1");
        return 0;
    }
    if (cnt == n * n) {
        puts("0");
        return 0;
    }
    int res = 1 << 30;
    for (int i = 0 ; i < n ; ++ i) {
        int sum = 0 , add = 0;
        for (int j = 0 ; j < n ; ++ j) {
            if (g[i][j] == '.') {
                if (!b[i]) {
                    add = 1;
                }
                ++ sum;
            }
        }
        sum += add;
        /*for (int j = 0 ; j < n ; ++ j) {
            if (g[i][j] == '.') {
                ++ a[i];
                ++ b[j];
            }
            }*/
        for (int j = 0 ; j < n ; ++ j) {
            if (b[j] < n) {
                ++ sum;
            }
        }
        res = min(res , sum);

    }
    cout << res << endl;


}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll h,w,m;
  cin >> h >> w >> m;

  ll a[m],b[m];
  vector<vector<ll>> G;
  for(ll i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G.push_back({a[i],b[i]});
  }
  ll sh[h]={},sw[w]={};
  for(ll i=0;i<m;i++){
    sh[a[i]]++;
    sw[b[i]]++;
  }


  ll H=0,W=0;
  for(ll i=0;i<h;i++){
    H=max(H,sh[i]);
  }
  for(ll i=0;i<w;i++)W=max(W,sw[i]);

  vec u,v;
  for(ll i=0;i<h;i++){
    if(H==sh[i])u.push_back(i);
  }
  for(ll i=0;i<w;i++){
    if(W==sw[i])v.push_back(i);
  }

  //cout << H << " " << W << endl;

  // cout << G[1][0] << G[1][1] << endl; 

  // for(ll i=0;i<G.size();i++){
  //   for(ll j=0;j<G[i].size();j++){
  //     cout << G[i][j] << " ";
  //   }
  //   cout << endl;
  // }

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

  for(ll i=0;i<u.size();i++){
    for(ll j=0;j<v.size();j++){
      vec t={u[i],v[j]};
      if(lower_bound(G.begin(),G.end(),t)-G.begin()==upper_bound(G.begin(),G.end(),t)-G.begin()){
        // cout << u[i] << " " << v[j] << endl;
        // cout << lower_bound(G.begin(),G.end(),t)-G.begin() << " " << upper_bound(G.begin(),G.end(),t)-G.begin() << endl;
        cout << H+W << endl;
        return 0;
      }
    }
  }
  cout << H+W-1 << endl;
  //cout << u[0] << " " << v[1] << endl;
  





}

Measured memory_bytes: 37872
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

int main() {
    int h=read(),a=read();
    printf("%d\n",(int)(ceil(1.0*h/a)+0.5));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

int main(void)
{
    int W, H, x, y, r;

    std::cin >> W;
    std::cin >> H;
    std::cin >> x;
    std::cin >> y;
    std::cin >> r;

    if (x >= r && x <= W-r &&
        y >= r && y <= H-r)
    {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k; cin >> n >>k;
  vector<double>prob(n + 1);
  double a = 1;
  double ans = 0;
  for(int i = 1; i <= n; i++){
    int tmp = i;
    while(tmp < k){
      tmp *=2;
      a /=2.0;
    }
    prob.at(i) = a;
    a = 1;
  }
  
  for(int i = 1; i <= n; i++){
    //cout << prob.at(i) << endl;
    ans += prob.at(i);
  }
  ans /=n;
  printf("%.12f\n",ans);
}


Measured memory_bytes: 3948
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main() {
	
	while(true){
		int N;
		cin >> N;
		
		if(N == 0){
			break;
		}
		
		bool is_floor = true;
		
		bool r_floor = true;
		bool l_floor = true;
		
		int ans = 0;
		
		for(int i = 0; i < N; i++){
			string str;
			cin >> str;
			if(str == "ld"){
				l_floor = true;
			}
			if(str == "rd"){
				r_floor = true;
			}
			if(str == "lu"){
				l_floor = false;
			}
			if(str == "ru"){
				r_floor = false;
			}
			if(l_floor && r_floor){
				if(!is_floor){
					ans++;
				}
				is_floor = true;
			}else if(!l_floor && !r_floor){
				if(is_floor){
					ans++;
				}
				is_floor = false;
			}
		}
		
		cout << ans << endl;
		
	}
	return 0;
}




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

int main(){
  int N; long long T; cin >> N >> T;
  long long t[200010];
  long long sumt=0;
  for(int i=0;i<N;i++){
    cin >> t[i];
    if(i == 0)continue;
    if(t[i-1]+T <= t[i])
      sumt += T;
    else 
    sumt += t[i]-t[i-1];
  }
  cout << sumt+T << endl;
}
  
  


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  
  vector<int> xs(n);
  vector<int> ys(n);

  for (int i = 0; i < n; i++) cin >> xs.at(i);
  for (int i = 0; i < n; i++) cin >> ys.at(i);

  double sum1 = 0.0, sum2 = 0.0, sum3 = 0.0, maxd = 0.0;

  for (int i = 0; i < n; i++) {
    double d = abs(xs.at(i) - ys.at(i));
    sum1 += d;
    sum2 += d * d;
    sum3 += d * d * d;
    if (maxd < d) maxd = d;
  }

  printf("%.6lf\n", sum1);
  printf("%.6lf\n", sqrt(sum2));
  printf("%.6lf\n", pow(sum3, 1.0 / 3));
  printf("%.6lf\n", maxd);

  return 0;
}



Measured memory_bytes: 3340
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


ll a,b,c,x,y;


int main(){

    IN a >>b >> c >> x >>y;
    
    if(c*2 < a+b){
        ll h = x* 2;
       // P(h);
        ll ans = c*h + a*(max(0LL,x-(h/2))) + b*(max(0LL,y-(h/2)));
       // P(ans);
        h = y*2;
        ans = min(ans,c*h + a*(max(0LL,x-(h/2))) + b*(max(0LL,y-(h/2))));
        P(ans);
    }else{
        P(a*x + b*y);
    }
    
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int len=0;
  while(cin >> s){
    string ans;
    len=s.length();
    for(int i=0;i<len;i++){
      if(s[i]=='@'){
	for(int j=0;j<s[i+1]-'0';j++){
	  ans+=s[i+2];
	}
	i+=2;
      }else{
	ans+=s[i];
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1184