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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

template<typename T> void warshall_floyd(vector<vector<T>>& g) {
    int n = g.size();
    REP(k, n) REP(i, n) REP(j, n) g[i][j] = min(g[i][j] ,g[i][k] + g[k][j]);
}

void solve() {
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> g(n, vector<ll>(n, (ll)INF * INF));
    vector<vector<ll>> h(n, vector<ll>(n, (ll)INF * INF));
    REP(i, n) {
        g[i][i] = 0;
        h[i][i] = 0;
    }
    int a, b;
    ll c;
    REP(i, m) {
        cin >> a >> b >> c;
        a--; b--;
        if (c > l) continue;
        g[a][b] = c;
        g[b][a] = c;
    }

    warshall_floyd(g);

    REP(i, n) REP(j, n) {
        if (i == j) continue;
        if (g[i][j] <= l) {
            h[i][j] = 1;
        }
    }
    warshall_floyd(h);

    int q;
    cin >> q;
    int s, t;
    REP(i, q) {
        cin >> s >> t;
        s--; t--;
        if (g[s][t] == (ll)INF * INF) {
            cout << -1 << EOL;
            continue;
        }
        cout << h[s][t] - 1 << EOL;
    }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }

    int sum = 1, heighest = H.at(0);
    for(int i = 1 ; i < N; i++){
        if(heighest <= H.at(i)){
            sum += 1; heighest = H.at(i);
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
h,w,n = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(n)]
J = [0] * 10
black = dict()
for i in ab:
  black[i] = 1
for a,b in ab:
  for x in range(max(0,3-a),min(3,h+1-a)):
    for y in range(max(0,3-b),min(3,w+1-b)):
      j = 0
      for X in range(a+x-2,a+x+1):
        for Y in range(b+y-2,b+y+1):
          if (X,Y) in black:
            j += 1
      J[j] += 1
for i in range(2,10):
  J[i] //= i
ALL = (h-2) * (w-2)
J[0] = ALL - sum(J[1:])
for i in J:
  print(i)

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

using namespace std;

class UnionFind {
  vector<int> graph_;
  vector<int> sizes_;

 public:
  UnionFind(int size) : graph_(size, -1), sizes_(size, 1){};
  int Root(int key) {
    if (graph_[key] < 0 || graph_[key] == key) {
      return key;
    } else {
      return graph_[key] = Root(graph_[key]);
    }
  }

  bool Same(int key1, int key2) { return Root(key1) == Root(key2); }

  void Unite(int key1, int key2) {
    if (Same(key1, key2)) {
      return;
    }

    int root1 = Root(key1);
    int root2 = Root(key2);
    int size = Size(root1) + Size(root2);
    graph_[root1] = root2;
    sizes_[root2] = size;
  }

  int Size(int key) {
    int root = Root(key);
    return sizes_[root];
  }
};

using Edge = array<int, 3>;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<pair<int, int>> vx, vy;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    vx.push_back({x, i});
    vy.push_back({y, i});
  }

  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());

  vector<array<int, 3>> edges;
  for (int i = 1; i < vx.size(); ++i) {
    auto p1 = vx[i], p2 = vx[i - 1];
    edges.push_back({abs(p1.first - p2.first), p1.second, p2.second});
  }

  for (int i = 1; i < vy.size(); ++i) {
    auto p1 = vy[i], p2 = vy[i - 1];
    edges.push_back({abs(p1.first - p2.first), p1.second, p2.second});
  }

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

  // 入力された辺を優先度付きキューへ入れる
  priority_queue<Edge, vector<Edge>, greater<array<int, 3>>> edge_q;
  for (auto &e : edges) {
    edge_q.push(e);
  }

  // キューから取り出し，閉路が出来なければ追加
  int ans = 0;
  UnionFind uf(n);
  while (!edge_q.empty()) {
    auto &edge = edge_q.top();
    if (!uf.Same(edge[1], edge[2])) {
      uf.Unite(edge[1], edge[2]);
      ans += edge[0];
    }

    edge_q.pop();
  }

  cout << ans << '\n';
}

Measured memory_bytes: 11784
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int A, B, C; cin >> A >> B >> C;
    
    if (A == B) {
        cout << C << endl;
    } else if (B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3588
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    (n>0)?cout<<"0":cout<<"1"<<endl;

}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	int K;
	cin >> K;

	if (K == 0)
	{
		cout << 2 << endl;
		cout << 1 << " " << 1 << endl;
		return 0;
	}

	if (K == 1)
	{
		cout << 2 << endl;
		cout << 2 << " " << 0 << endl;
		return 0;
	}

	if (K <= 50)
	{
		cout << K << endl;
		for (int i = 0; i < K; i++)
		{
			cout << K << " ";
		}
		cout << endl;
		return 0;
	}

	cout << 50 << endl;

	int base = ((K / 50) - 1) + 50;
	int mod = K % 50;

	for (int i = 0; i < mod; i++)
	{
		int a = base + (50 - (mod - 1));
		cout << a << " ";
	}
	for (int i = mod; i < 50; i++)
	{
		int a = base - mod;
		cout << a << " ";
	}
	cout << endl;
}


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

int main() {
  char a,b,c;
  cin >> a >> b >> c;
  if(a == 'R' && b == 'R' && c == 'R'){
    cout << 3 << endl;
  }
  if(a == 'S' && b == 'R' && c == 'R'){
    cout << 2 << endl;
  }
  if(a == 'R' && b == 'R' && c == 'S'){
    cout << 2 << endl;
  }
  if(a == 'R' && b == 'S' && c == 'S'){
    cout << 1 << endl;
  }
  if(a == 'S' && b == 'R' && c == 'S'){
    cout << 1 << endl;
  }
  if(a == 'S' && b == 'S' && c == 'R'){
    cout << 1 << endl;
  }
  if(a == 'R' && b == 'S' && c == 'R'){
    cout << 1 << endl;
  }
  if(a == 'S' && b == 'S' && c == 'S'){
    cout << 0 << endl;
  }
}


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

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }

    long long sum = 0;
    for(int i = 0; i < N; i++){
        sum += v.at(i);
    }

    long long int psum = 0;
    for(int i = 0; i < N-1; i++){
        sum -= v.at(i);
        psum += v.at(i)*(sum%1000000007LL);
        psum %= 1000000007LL;
    }
    cout << (long long)psum << endl;
}

Measured memory_bytes: 4000
#include <iostream>
#include <math.h>

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

    int n, k;
    cin >> n >> k;
    double prob = 0.;
    for(int i=1;i<=n;++i){
        int buf = i;
        int cnt = 0;
        while(buf<k){
            buf *= 2;
            ++cnt;
        }
        prob += 1./n*pow(1./2., cnt);
    }

    printf("%13.12f\n", prob);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int dice[] = new int[6];
		int pip[] = new int[6];
		int count = 0;
		int order = 0;
		boolean bdice_front = false;
		int dice_front = 0;
		boolean bdice_up = false;
		int dice_up = 0;
		
		//サイコロの目の入力
		dice =  make_dice(scanner);
		
		pip = dice;
		
		//命令数取得
		order = scanner.nextInt();

		//命令数実行
		do {
			dice_up = scanner.nextInt();
			dice_front = scanner.nextInt();
			bdice_front = false;
			bdice_up = false;
			
			for( int i = 0; i < 4; i ++ ){
				for( int j = 0; j < 2; j ++ ){
					if(!bdice_front) {
						for( int k = 0; k < 4; k ++ ){
							if( !bdice_front ) {
								pip = diceroll_s(pip);
								if( pip[1] == dice_front ){
									bdice_front = true;
								}
							}
						}
						pip = diceroll_e(pip);
					}
				}
				if( pip[0] == dice_up ){
					bdice_up = true;
					break;
				}
				pip = diceroll_e(pip);
				
			}
			
			
			//右面出力
			System.out.println(pip[2]);
			count ++;
			if( count >= order){
				break;
			}
		}while(true );
		
		scanner.close();
	}
	
	public static int[] make_dice ( Scanner scanner){
		int dice[] = new int[6];
		
		for(int i = 0; i < 6; i ++){
			dice[i] = scanner.nextInt();
		}
		
		return dice;
	}

	public static int[] diceroll_n(int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[1];
		pip[1] = dice[5];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[0];
		pip[5] = dice[4];
		
		return pip;
	}

	public static int[] diceroll_e (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[3];
		pip[1] = dice[1];
		pip[2] = dice[0];
		pip[3] = dice[5];
		pip[4] = dice[4];
		pip[5] = dice[2];
		
		return pip;
	}

	public static int[] diceroll_w (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[2];
		pip[1] = dice[1];
		pip[2] = dice[5];
		pip[3] = dice[0];
		pip[4] = dice[4];
		pip[5] = dice[3];
		
		return pip;
	}

	public static int[] diceroll_s (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[4];
		pip[1] = dice[0];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[5];
		pip[5] = dice[1];
		
		return pip;
	}
	
}



Measured memory_bytes: 26172
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var count = Int32.Parse(Console.ReadLine());
        var list = new List<long[]>();
        for (int i=0;i<count;++i) {
            var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            list.Add(new long[3] { line[0]+line[1],line[0],line[1]});
        }
        list=list.OrderByDescending(x=>x[0]).ToList();
        var takahashi = 0L;
        var aoki = 0L;
        for (int i = 0; i < count; ++i)
        {
            if (i % 2 == 0) takahashi += list[i][1];
            else aoki += list[i][2];
        }
        Console.WriteLine(takahashi-aoki);
    }
}

Measured memory_bytes: 28332
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;
const long MAX_N=200010;
int flag[MAX_N];//そこから下やったか？
long score[MAX_N];
vector<long> g[MAX_N];
map<long,long> mp;


//足してくパート
void pl(long n,long x){//頂点n以下にxを足す
    score[n]+=x;
    flag[n]=1;
    long d=g[n].size()+1;
    for(long i=1;i<d;i++){
        long a=g[n][i-1];//辺の先の取得
        if(flag[a]==0) {
            pl(a,mp[a]+x);
        }
    }
}

int main(){
    long n,q;
    cin >> n >> q;
    //頂点に対する子をもっている
    for(long i=1;i<n;i++){
        long a,b;
        cin >> a>> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    //各頂点から幾つ足せば良いか
    for(long i=1;i<=q;i++){
        long p,x;
        cin >> p >> x;
        mp[p]+=x;
    }
    
    for(long i=1;i<=n;i++) {
        score[i]=0;flag[i]=0;
    }
    pl(1,mp[1]);
       for(int i=1;i<=n;i++) {
         if(i!=n) cout << score[i] << " " ;
         else cout << score[i] << endl;
       }
    
}




Measured memory_bytes: 43776
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<assert.h>
#define INF 0x3f3f3f3f//3f3f3f3f
#define ll long long
#define ull unsigned long long
#define lowbit(a) ((a)&(-(a)))
using namespace std;

int main() {
    int n,a,b;
    while(cin>>n>>a>>b){
        int c = n-a-b;
        if(c>0)c = 0;
        else c = -c;
        cout<<min(a,b)<<" "<<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<ll> diff(n);
    rep(i,n) diff[i] = a[i] - b[i];
    sort(rall(diff));

    ll total = 0, ans = 0;
    rep(i,n) {
        if (diff[i] < 0){
            total += diff[i];
            ans++;
        } 
    }
    ll i = 0;
    while(total < 0) {
        if (diff[i] <= 0){
            cout << -1 << endl;
            return 0;
        }
        total += diff[i];
        i++;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, z,sum, mn = 999999999, avg, pos, dif,k, mx, xi, yi;
const int MXN=2e5;
const ll mod=1e9+7;
ll pre[MXN];
bool prime[MXN];

bool PE ( ll x )
{
    for ( ll i = 2; i * i <= x; i+=1+(i&1))
    if ( x % i == 0 )
    return false;
    return true;
}
ll dist[MXN];
void sieve()
{
    memset(prime , 1 , sizeof prime);

    for ( ll i = 2; i * i <= MXN; i+=1+(i&1))
    if (prime[i])
    {
          for (ll j = i * i; j < MXN; j +=i)
         prime[j] = false;
    }
}

bool PR ( string s )
{
    int n = s.length();
    for ( ll i = 0; i < n / 2; i++ )
    if ( s[i] != s[n - i - 1] )
    return false;
    return true;
}

string s , o;
ll a[MXN];


bool is(string fs , string nd ) 
{ 
    int j = 0;
    int fn = fs.length();
     int nn = nd.length();

   for (int i=0; i<fn && j<nn; i++) 
      if (fs[i] == nd[j])
         j++; 
  
 
   return j==nn; 
}

bool ok (ll mid )
{
    
}

int main (void){
    
     SpeeD;
cin >> n;
ll a[n][2];
bool f = false;
for (int i  =  0  ; i  < n; i++)
 
for (int j =  0 ;    j < 2  ;j++){
    cin >> a[i][j];
   
}

for (int i  =  0  ; i  < n; i++){
    

    if (a[i][0] == a[i][1])
    {
        c++;
    }
    else c = 0;
    if (c == 3 )
    f = true;
}
f? cout << "Yes": cout << "No";




}


Measured memory_bytes: 3620
n = int(input())
s = [int(i) for i in input().split()]

q = int(input())
t = [int(i) for i in input().split()]

ans = 0
for i in range(q):

    left = 0
    right = n-1

    while left <= right:
        mid = (right+left) // 2

        if t[i] < s[mid]:
            right = mid -1
        elif t[i] > s[mid]:
            left = mid + 1
        else:
            ans += 1
            break

print(ans)


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

int main(){
  int N; cin >> N;
  
  vector<int> card(N);
  for(int i = 0; i < N; i++){
    cin >> card.at(i);
  }
 
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int A =0; int B = 0;
  for(int j = 0; j < N; j+=2){
    A += card.at(j);
  }
  for(int k = 1; k < N; k+=2){
    B += card.at(k);
  }
  cout << A - B << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	vll v;
	while(1){
		ll ma=0,mi=INF,sum=0,a;
		cin >> n;
		if(n==0) break;
		rep(i,n){
			cin >> a;
			sum+=a;
			chmin(mi,a);
			chmax(ma,a);
		}
		v.pb((sum-mi-ma)/(n-2));
	}
	for(auto& e:v) cout << e << endl;
	return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		String W = sc.next().toLowerCase();
		int cnt = 0;

		while(true) {
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(W.equals(T.toLowerCase())) {
				cnt++;
			}			
		}
		System.out.println(cnt);
		sc.close();
		
	}		
}


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

int main(){
  int n, t, a; cin >> n >> t >> a;
  vector<double> h(n); for(int i = 0; i < n; i++) cin >> h.at(i);
  for(int i = 0; i < n; i++){
    h.at(i) = (t - h.at(i)*0.006)- a;
    if(h.at(i) < 0) h.at(i) *= -1;
  }
  int num = 0;
  double mi = h.at(0);
  for(int i = 1; i < n; i++){
    if(mi > h.at(i)){
      mi = h.at(i);
      num = i;
    }
  }
  cout << num+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n, d;
    cin >> n >> d;
    int ans;
    for(int i=1;i<=n;++i) {
        if(i*(1+2*d)>=n) {
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<ll>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define alll(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) ll a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it << endl; } }

int main() {
    ll n,a,b;
    ll sum=0,sumb=0;
    string s;
    cin >>n>>a>>b>>s;
    rep(i, s.size()){
        if (s[i]=='a') {
            if (sum<a+b) {
                pr("Yes");
                sum++;
            }else pr("No");
        }
        if (s[i]=='b') {
            sumb++;
            if (sum<a+b&&sumb<=b) {
                pr("Yes");
                sum++;
            }else pr("No");
        }
        if (s[i]=='c') {
            pr("No");
        }
    }
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A < B) {
    for (int i = 0; i < B; i++) {
      cout << A;
    }
  } else {
    for (int i = 0; i < A; i++) {
      cout << B;
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBiginnerContest179
{
	class Program
	{
		private static int MOD = 998244353;

		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			var array = new List<long>((int)inputs[2] + 1);
			var index = new bool[inputs[2]];

			array.Add(inputs[1]);
			index[inputs[1]] = true;
			var mod = inputs[2];
			var count = 0;
			var sum = array[0];
			for (var i = 0; i < mod; i++)
			{
				array.Add(array[i] * array[i] % mod);
				if (index[0])
				{
					break;
				}
				if (index[array[i + 1]])
				{
					count -= array.IndexOf(array[i + 1]) - 1;
					break;
				}

				count++;
				sum += array[i + 1];
				index[array[i + 1]] = true;
			}


			if (index[0])
			{
				var tmp = 0L;
				for (var i = 0; i < count; i++)
				{
					tmp += array[i];
				}
				Console.WriteLine(tmp);
			}
			else
			{
				var tmp = 0L;
				for (var i = 0; i < array.Count - 1 - count; i++)
				{
					tmp += array[i];
					sum -= array[i];
				}

				var div = (inputs[0] - (array.Count - 1 - count)) / count;
				var m = (inputs[0] - (array.Count - 1 - count)) % count;

				for (var i = 0; i < m; i++)
				{
					tmp += array[i + array.Count - 1 - count];
				}
				Console.WriteLine(tmp + div * sum);
			}
		}

	}
}


Measured memory_bytes: 28384
s = input()
t = input()

sn = len(s)
tn = len(t)

l = r = -1
for i in range(sn, -1, -1):
    if i+tn > sn:
        continue

    if all(sc == tc or sc == "?" for sc, tc in zip(s[i:i+tn], t)):
        l, r = i, i+tn
        break

if l == -1:
    print("UNRESTORABLE")
    exit()

i = 0
while i < sn:
    if l <= i < r:
        print(t[i-l], end="")
    else:
        if s[i] == "?":
            print("a", end="")
        else:
            print(s[i], end="")
    
    i += 1

print()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int n,t,a;
  cin>>n>>t>>a;
  int h[n];
  rep(i,n)cin>>h[i];
  float ans=100000.0;
  int cnt=0;
  rep(i,n){
    float x=t-h[i]*0.006;
    if(ans>abs(a-x)){
      ans=abs(a-x);
      cnt=i+1;
    }
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll h,w,i,tp=0,sum=0,k;
const ll mod=1e9+7;
ll pow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%lld%lld%lld",&h,&w,&k);
	if(k==1)sum=2;
	else
	{
		sum=(k+k*(1LL+k)/2LL)%mod;
		for(i=1;i<k;i++)tp=(tp+i*(k-i))%mod;
		sum=(sum+h*w%mod*2*pow(h+w,mod-2LL)%mod*pow(h+w-1LL,mod-2LL)%mod*tp%mod)%mod;
	}
	for(i=h+w;i>h+w-k;i--)sum=sum*i%mod;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    char c; cin>>c;
    cout<<(char)(c+1)<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	long long x,y;
	while(cin>>x>>y){
		if(x % y == 0){
			cout<<-1<<endl;
		}
		else{
			cout<<x<<endl;
		}
	}
	return 0;	
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	count := 0
	for i := range s {
		for j := i + 1; j < len(s); j++ {
			if s[i] == s[j] {
				count++
			}
		}
	}
	if count == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
import Control.Monad
import Control.Monad.ST
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Array
import Data.Array.ST

main = do
    [n,w]<-map read.words<$>getLine::IO [Int]
    wvs<-replicateM n $ unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[[Int]]

    print $ f n w wvs

f n w wvs = runST $ do
    dp <- newArray ((0,0),(n,w)) 0 :: ST s (STUArray s (Int,Int) Int)
    forM_ [(i,wi,vi,j)|(i,[wi,vi])<-zip [1..] wvs,j<-[0..w]] $ \(i,wi,vi,j) ->
        if j<wi then
            writeArray dp (i,j) =<< readArray dp (i-1,j)
        else
            writeArray dp (i,j) =<< max <$> readArray dp (i-1,j) <*> ((+vi) <$> readArray dp (i-1,j-wi))
    readArray dp (n,w)


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define lli long long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

bool cmp(pair<lli,lli> p1, pair<lli,lli> p2) {
    if(p1.F + p1.S > p2.F + p2.S) return 0;
    else if(p1.F + p1.S < p2.F + p2.S) return 1;
    else {
        if(p1.S < p2.S) return 0;
        else return 1;
    }
}

int main() {

    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    pair<lli,lli> jobs[n];

    for(int i = 0; i < n; i++) {
        lli units, deadline;
        cin >> units >> deadline;
        jobs[i].F = deadline - units;
        jobs[i].S = units;
    }

    sort(jobs, jobs + n, cmp);

    bool ok = true;
    lli time = 0;
    for(int i = 0; i < n; i++) {
        if(time > jobs[i].F) {
            //cout << "tempo  " << time << " maximo" << jobs[i].F << endl;
            ok = false;
        }
        time += jobs[i].S;
    }

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

}


Measured memory_bytes: 3328
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define fileio(in, out) freopen("in", "r", stdin); freopen("out", "w", stdout)
const int mod = (int)(1e9) + 7;
//endregion

int main() {
    io();
    ll n, m, a;
    in2(n, m);
    priority_queue<int> pq;
    fori (i, n) {
        in(a);
        pq.push(a);
    }
    fori (i, m) {
        pq.push(pq.top()/2);
        pq.pop();
    }
    a = 0;
    fori (i, n) {
        a += pq.top();
        pq.pop();
    }
    out(a);
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main(){
	int b, s, t;
	s = 0;
	t = 0;

	for (int i = 0; i < 4; i++){
		cin >> b;
		s += b;
	}
	for (int i = 0; i < 4; i++){
		cin >> b;
		t += b;
	}

	if (s >= t){
		cout << s << endl;
	}
	else {
		cout << t << endl;
	}
		
}

Measured memory_bytes: 3088
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll n,w,i,j,inf=1e18;cin>>n>>w;
ll val[n],wt[n];
for(i=0;i<n;i++) cin>>wt[i]>>val[i];
ll l=0;
for(int x:val) l+=x;
ll dp[n+1][l+1];
for(i=0;i<=n;i++)
{
	for(j=0;j<=l;j++)
	{
		dp[i][j]=inf;
	}
}
for(i=0;i<=n;i++) dp[i][0]=0;
for(i=0;i<=n;i++)
{
	for(j=0;j<=l;j++)
	{
		if(i==0 || j==0) continue;
		else if(val[i-1]>j) dp[i][j]=dp[i-1][j];
		else
		{
			dp[i][j]=min(dp[i-1][j-val[i-1]]+wt[i-1],dp[i-1][j]);
		}
	}
}
ll m=0;
for(i=1;i<=l;i++)
{
	if(dp[n][i]<=w)
	{
		m=i;
	}
}
cout<<m;


return 0;
}


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

const int MXN = 1e4+5;
vector<pair<int, pair<int, int>>> es;

int parent[MXN];
int size[MXN];

void init_uf() {
    for (int i=0; i<MXN; i++) {
        parent[i] = i;
        size[i] = 1;
    }
}

int fs(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = fs(parent[v]);
}

void us(int a, int b) {
    a = fs(a);
    b = fs(b);
    if (a != b) {
        if (size[a] < size[b])
            swap(a, b);
        parent[b] = a;
        size[a] += size[b];
    }
}

long long kruskal() {
    init_uf();
    sort(es.begin(), es.end());
    long long w = 0;
    for (auto e: es) {
        if (fs(e.second.first) == fs(e.second.second)) continue;
        w += e.first;
        us(e.second.first, e.second.second);
    }
    return w;
}

int main() {
    
    int n, m;
    cin >> n >> m;
    while (m--) {
        int v, u, w;
        cin >> v >> u >> w;
        es.push_back({w, {v, u}});
    }
    
    cout << kruskal() << endl;
}



Measured memory_bytes: 4464
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

H,W,K = inputIL()
C = inputSLs(H)


best = INF
for h in range(pow(2,H-1)):
  nC = []
  nC.append([int(i) for i in C[0]])
  for i in range(1,H):
    if h>>(i-1) & 1:
      for j in range(W):
        nC[-1][j] += int(C[i][j])
    else:
      nC.append([int(j) for j in C[i]])
  n = len(nC)
  if max(max(nC[i]) for i in range(n)) > K:
    continue
  count = [0 for j in range(n)]
  cut = 0
  while len(nC[0]):
    now = [nC[j].pop() for j in range(n)]
    if max(count[j]+now[j] for j in range(n)) > K:
      count = now
      cut += 1
    else:
      count = [count[j]+now[j] for j in range(n)]
  
  yoko = H-1
  while h:
    h &= h -1
    yoko -= 1
  best = min(best,cut+yoko)

print(best)

Measured memory_bytes: 89560
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main()
{
  int a, b, c, x;
  scanf("%d %d %d", &a, &b, &c);
  for (int i = a; i <= b; i++)
  {
    if (c % i == 0)
      x++;
  }
  printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 2752
from collections import deque

N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]

tree = [[] for _ in range(N + 1)]
for a, b in X:
    tree[a].append(b)
    tree[b].append(a)

MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD

visited = [False] * (N + 1)
visited[0] = True
visited[1] = True
stack = deque([1])
ans = K
while stack:
    u = stack.popleft()
    child_num = sum(not visited[v] for v in tree[u])
    ans *= comb(K - 1 - int(u != 1), child_num) * fac[child_num]
    ans %= MOD
    for v in tree[u]:
        if not visited[v]:
            visited[u] = True
            stack.append(v)

print(ans)


Measured memory_bytes: 110428
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 3e5 + 5;

ll h, w, m;
pair<ll,ll> a[nax], b[nax];
set<pair<ll,ll>> st;

bool cmp(pair<ll,ll> xx, pair<ll,ll> yy){
	return xx.ff > yy.ff;
};

ll jml(ll x, ll y){
	if(x > h || y > w){
		return 0;
	}
	ll ret = a[x].ff + b[y].ff - (ll)st.count({a[x].ss, b[y].ss});
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> h >> w >> m;
	for(ll i = 1; i <= h; i++){
		a[i].ss = i;
	}
	for(ll i = 1; i <= w; i++){
		b[i].ss = i;
	}
	for(ll i = 1; i <= m; i++){
		ll x, y;
		cin >> x >> y;
		a[x].ff++;
		b[y].ff++;
		st.insert({x, y});
	}
	sort(a + 1, a + 1 + h, cmp);
	sort(b + 1, b + 1 + w, cmp);
	ll ans = 0;
	for(ll i = 1; i <= h; i++){
		for(ll j = 1; j <= w; j++){
			ans = max(ans, jml(i, j));
			if(!st.count({a[i].ss, b[j].ss})){
				break;
			}
		}
	}
	cout << ans << '\n';
}



Measured memory_bytes: 31736
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll ans=0;
    ll n;
    cin>>n;
    ll a;
    ll s=0;
    for(int x=0;x<n;x++)
    {
        cin>>a;
        ans=(ans+(s*a))%mod;
        s+=a;
        s%=mod;
    }
    cout<<ans;
}


Measured memory_bytes: 3652
N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))

maxv = [0] + [min(v[i], v[i+1]) for i in range(N-1)] + [0]
for i in reversed(range(N)):
  if maxv[i] - maxv[i+1] > t[i]:
    maxv[i] = maxv[i+1] + t[i]
for i in range(N):
  if maxv[i+1] - maxv[i] > t[i]:
    maxv[i+1] = maxv[i] + t[i]

def kyori(start, stop, mxv, ti):
  if stop >= start:
    if stop - start >= ti:
      return (stop+start)*ti /2
    elif mxv <= stop:
      return ti*mxv - (mxv-start)**2 /2
    else:
      x = (stop-start+ti)/2
      if mxv >= start + x:
        return (start+start+x)*x /2 + (stop+stop+ti-x)*(ti-x) /2
      else:
        return ti*mxv - ((mxv-start)**2 + (mxv-stop)**2)/2
  else:
    x = (stop-start+ti)/2
    if mxv >= start + x:
      return (start+start+x)*x /2 + (stop+stop+ti-x)*(ti-x) /2
    else:
      return ti*mxv - ((mxv-start)**2 + (mxv-stop)**2)/2


ans = 0
for i in range(N):
  ans += kyori(maxv[i], maxv[i+1], v[i], t[i])

print(ans)

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

vector<pair<ll,ll>> graph[100010];
ll heights[100010];

int main(){
  ll n,m,i,j,a,b;
  cin>>n>>m;
  for(i = 1; i<=n; i++){
    graph[i].clear();
  	cin>>heights[i];
  }
  for(i = 1; i<=m; i++){
    cin>>a>>b;
    graph[a].push_back(mp(heights[b], b));
    graph[b].push_back(mp(heights[a],a));
  }
  for(i = 1; i<=n; i++){
    sort(graph[i].begin(), graph[i].end());
  }
  ll count = 0;
  for(i = 1; i<=n; i++){
    if(graph[i].size() == 0) count++;
    else if(heights[i] > graph[i].back().first) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 11940
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;
vector< vector< char > > amida;
int n, m, t, d;

int check(){
	int cur = m;
	
	REP(i, d){
		if(amida[i][cur - 1] == 1){
			--cur;
		}else if(amida[i][cur] == 1){
			++cur;
		}
	}
	
	return cur == t;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(cin >> n, n){
		cin >> m >> t >> d;
		
		amida.CLR();
		
		amida.RS(d);
		REP(i, d){
			amida[i].RS(n + 1);
			
			FORE(j, 1, n - 1){
				cin >> amida[i][j];
				amida[i][j] -= '0';
			}
		}
		
		if(check()){
			cout << 0 << endl;
		}else{
			
			bool suc = false;
			REP(i, d){
				FORE(j, 1, n - 1){
					
					if(amida[i][j] == 0 && amida[i][j - 1] == 0 && amida[i][j + 1] == 0){
						amida[i][j] = 1;
						
						if(check()){
							cout << i + 1 << " " << j << endl;
							suc = true;
							break;
						}
						
						amida[i][j] = 0;
					}
				}
				if(suc) break;
			}
			
			if(!suc) cout << 1 << endl;
		}
	}
	
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int D[100100];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> D[i];
    }
    sort(D, D + N);
    int lm = D[N / 2 - 1], um = D[N / 2];
    cout << um - lm << endl;
    return 0;
}


Measured memory_bytes: 1024
s = int(input())

a = 0
S = [s]
i = 0

while a not in S:
    if i > 0:
        S.append(a)
    if S[i]%2 == 0:
        a = int(S[i]/2)
    else:
        a = S[i]*3+1
    i += 1

print(i+1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int a,b;
        cin >> a >>b;
        if(a==0 && b==0){
            return 0;
        }
        for(int r=0;r<a;r++){
            for(int i=0;i<b;i++){
                cout << "#" <<flush;
                }
            cout << endl;
        }
        cout << endl;
    }
}



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

int main() {
  string a = "CODEFESTIVAL2016", b;
  cin >> b;
  int c = 0;
  for(int i = 0; i < a.size(); i++){
    if(a.at(i) != b.at(i))
      c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int i,j,k;
	while(1){
	scanf("%d %d",&i,&j);
	if(i==0 && j==0)
	{
		break;
	}
	else if(i <= j)
	{
		printf("%d %d\n",i,j);
	}
	else if(i > j)
	{
		printf("%d %d\n",j,i);
	}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

#define INF (1LL <<50)
vector<vector<long long>> warshall_floyd(vector<vector<long long>> &adjmatrix) {
  int n = adjmatrix.size();
  vector<vector<long long>> dist(adjmatrix);
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        if(dist[i][k]!=INF && dist[k][j]!=INF)
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  return dist;
}

int main() {
  int n,m,R; cin >> n >> m >> R;
  vector<int> r(R);
  rep(i,R) {
    cin >> r[i];
    --r[i];
  }
  sort(ALL(r));

  vector<vector<ll>> adjmatrix(n, vector<ll>(n,INF));
  rep(i,m) {
    int a,b,c; cin >> a >> b >> c;
    --a,--b;
    adjmatrix[a][b] = c;
    adjmatrix[b][a] = c;
  }

  auto wf = warshall_floyd(adjmatrix);

  ll ans = INF;
  do {
    ll sum = 0;
    rep(i, R-1) {
      int from=r[i], to=r[i+1];
      sum += wf[from][to];
    }
    umin(ans,sum);
  }while(next_permutation(ALL(r)));
  cout << ans << endl;
}


Measured memory_bytes: 4236