akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
using LL = long long;

LL solve(int N, vector<pair<LL, LL>> &xys);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<LL, LL>> xys(N);
    for (auto & xy : xys){
        cin >> xy.first >> xy.second;
        if (xy.first > xy.second) swap(xy.first, xy.second);
    }
    cout << solve(N, xys) << endl;
    return 0;
}

LL solve(int N, vector<pair<LL, LL>> &xys){
    // xmin = Rmin, ymax = Bmax となるケース
    // Rmax = xmax, Bmin = ymin とすればよい。
    LL xmin = 2e9;
    LL ymin = 2e9;
    LL xmax = -2e9;
    LL ymax = -2e9;
    LL xmin_rev_min = 2e9;
    LL xmin_rev_max = -2e9;
    LL ymax_rev_min = 2e9;
    LL ymax_rev_max = -2e9;
    vector<pair<int, LL>> ymax_idx_val;
    for (int i = 0; i != N; ++i){
        auto x = xys[i].first;
        auto y = xys[i].second;
        if (x == xmin){
            xmin_rev_min = min(xmin_rev_min, y);
            xmin_rev_max = max(xmin_rev_max, y);
        }
        if (x < xmin){
            xmin = x;
            xmin_rev_min = y;
            xmin_rev_max = y;
        }
        xmax = max(xmax, x);
        ymin = min(ymin, y);
        if (y == ymax){
            ymax_rev_min = min(ymax_rev_min, x);
            ymax_rev_max = max(ymax_rev_max, x);
        }
        if (y > ymax){
            ymax = y;
            ymax_rev_min = x;
            ymax_rev_max = x;
        }
    }
    LL ans1 = (xmax - xmin) * (ymax - ymin);

    // xmin = Rmin, ymax = Rmax となるケース
    LL Bmin = min(ymax_rev_min, xmin_rev_min);
    LL Bmax = max(ymax_rev_max, xmin_rev_max);
    sort(xys.begin(), xys.end());
    Bmax = max(Bmax, xys.back().first);
    LL record = Bmax - xys[0].first;
    for (int i = 1; i != N; ++i){
        Bmax = max(Bmax, xys[i - 1].second);
        Bmin = min(Bmin, xys[i - 1].second);
        record = min(record, Bmax - min(Bmin, xys[i].first));
    }
    LL ans2 = (ymax - xmin) * record;

    return min(ans1, ans2);

}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<set>
#include<queue>
#include<algorithm>
#include<climits>
#include<map>
#include<unordered_map>
#define ll long long

bool isPrime(ll n){
    if(n%2==0 || n%3==0) return false;
    if(n<=1)  return false;
    if(n<=3)  return true;
    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0||n%(i+2)==0)
           return false;
    return true;
}

#define w(t) ll t,tt=1;	cin>>t;		while(t--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>

#define mod 1e9+7
#define inf 1e18

#define lln ll n; cin>>n
#define intn int n; cin>>n
#define YES cout<<"YES"
#define NO cout<<"NO"
#define strr    string str; cin>>str;
#define strn   n=str.length()
#define fr(a,n) for(ll i=a;i<n;i++)
#define loop for(ll i=0;i<n;i++)

using namespace std;

void solve (){
    int n,x,t;
    cin>>n>>x>>t;
    int temp=n/x;
    if(n%x) ++temp;
    cout<<temp*t;
}

int main(){
    IOS
    solve();
    return 0;
}


Measured memory_bytes: 3636
def resolve():
    w = input()
    flag = 0
    abc = "abcdefghijklmnopqrstuvwxyz"
    for i in range(len(abc)):
        if w.count(abc[i])%2 == 0:
            continue
        else:
            flag = 1
    print("Yes" if flag == 0 else "No")
resolve()

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> H >> W >> N;
  DV(G,int,H,W,0);
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N){
    while(P[i]>0){
      G[sum][num]=i+1;
      num++;
      if(num==W){
        sum++;
        num=0;
      }
      P[i]--;
    }
  }
  rep(i,0,H)if(i%2==1)Rev(G[i]);
  rep(i,0,H)rep(j,0,W){
    cout << G[i][j] << " ";
    if(j==W-1)Out("");
  }
}

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

int main(){
  int x[5];
  rep(i,5)cin >> x[i];

  rep(i,5){
    if(x[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
key = dict()

n = int(input())
for i in range(n):
  k = input()
  if k in key:
    key[k] += 1
  else:
    key[k] = 1

m = int(input())

for i in range(m):
  k = input()
  if k in key:
    key[k] -= 1
  else:
    key[k] = -1

sub = []
for i in key.values():
  sub.append(i)
print(max([max(sub), 0]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,d[222][222],f,a,b;
string s;
main(){
    cin>>n;
    r(i,222)r(j,222)d[i][j]=(i==j?0:1e8);
    while(n--){
        cin>>a>>s>>b;
        if(s=="lock")d[a][b+111]=-1;
        else d[b+111][a]=-1;
    }
    r(o,222)r(i,222)r(j,222)d[i][j]=min(d[i][j],d[i][o]+d[o][j]);
    r(i,222)if(d[i][i]<0)f++;
    cout<<(f?1:0)<<endl;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll N, C; cin >> N >> C;
    vvi D(C, vi(C, 0)), G(N, vi(N, 0)), M(3, vi(0));
    rep(i, C) rep(j, C) cin >> D[i][j];
    rep(i, N) rep(j, N){ cin >> G[i][j]; G[i][j]--; }

    // 3の剰余算でグループ分け
    rep(i, N) rep(j, N) M[(i+j)%3].push_back(G[i][j]);

    // グループごとに全探索
    vector<vector<pair<ll, ll>>> Discomf(3, vector<pair<ll, ll>>(C));
    rep(i, 3) rep(j, C){
        ll cnt = 0;
        for(auto Pre: M[i]) cnt += D[Pre][j];
        Discomf[i][j] = make_pair(cnt, j);
    }

    ll ans = INFLL;
    rep(i, C){
        rep(j, C){
            if(i == j) continue;
            rep(k, C){
                if(i == k || j == k) continue;
                chmin(ans, Discomf[0][i].first + Discomf[1][j].first + Discomf[2][k].first);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  string S;
  cin >> S;
  int a = S.find("A") == string::npos;
  int b = S.find("B") == string::npos;
  int flag = 0;
  if(a!=1 && b!=1)flag = 1;
  if(flag == 1)cout << "Yes"<< endl;
  else{cout << "No" <<endl;}
  return 0;
}

Measured memory_bytes: 256
from collections import deque, defaultdict
N = int(input())
d = defaultdict(list)
m = dict()
ls = []
for i in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)
    ls.append((a, b))

K = 0
for i in range(N):
    d[i+1].sort()
    K = max(K, len(d[i+1]))
print(K)

q = deque([])
q.append((1, 0))
visited = [0 for i in range(N+1)]
visited[1] = 1
while q:
    l, r = q.popleft()
    flag = 0
    cur = 1
    for i, x in enumerate(d[l], start=1):
        if visited[x] == 1:
            continue
        if flag == 0:
            if cur == r:
                q.append((x, cur+1))
                m[(l, x)] = cur+1
                m[(x, l)] = cur+1
                cur += 2
                visited[x] = 1
                flag = 1
                continue
            m[(l, x)] = cur
            m[(x, l)] = cur
            q.append((x, cur))
            cur += 1
            visited[x] = 1
        else:
            q.append((x, cur))
            m[(l, x)] = cur
            m[(x, l)] = cur
            cur += 1
            visited[x] = 1
for i in range(N-1):
    a, b = ls[i]
    print(m[(a, b)])

Measured memory_bytes: 70056
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String t = scan.next();
    char[] a = new char[n];
    for (int i=0;i<n;i++){
      a[i] = t.charAt(i);
    }

    String f = Character.toString(a[0]);
    for (int j=1;j<n;j++){
      int p = f.length();
      if (a[j] == f.charAt(p-1)){
        continue;
      }
      else{
        f += Character.toString(a[j]);
      }
    }
    System.out.println(f.length());
  }
}


Measured memory_bytes: 58508
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 200000+9;
int n;
int a[MAXN];
vector<pair<int,int> > vec;

void solve(){
	int i;
	for(i=1;i<=n;i++){
		if(a[i]==i){
			int s=i;
			while(a[i]==i && i<=n)
				i++;
			int t=--i;
			vec.push_back(make_pair(s,t));
		}
	}
	int ans=0;
	for(i=0;i<vec.size();i++){
		int len=vec[i].second-vec[i].first+1;
		if(len==1)
			ans++;
		else{
			if(len%2==0)
				len=len/2;
			else if(len%2==1)
				len=len/2+1;
			ans+=len;
		}
	}
	printf("%d\n",ans);
}

int main(){
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	solve();
	return 0;
}


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

int main()
{
    // int N,M;
    // cin >> N>>M;
    // int Mat[N][M];
    int n,x;
    cin >> n >> x;
    int count;
    int a,b,c;
    while((n != 0) || (x!=0)){
        count = 0;
        for (a =1; a<=n; a++){

            for(b=a+1; b<=n; b++){
                for(c=b+1; c<=n; c++){
                    if (a+b+c == x){
                        count++;
                        // printf("%d %d %d\n", a,b,c);
                    }
                }
            }
        }
        cout << count<<endl;
        cin >> n >> x;

    }
    return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  printf("%d\n",max(a * b, c * d));
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

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

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	ll x;
	cin >> x;
	double f = 100;
	ll ans = 0;
	while(true) {
		if (f >= x) {
			cout << ans << endl;
			return 0;
		}
		f *= 1.01;
		f = floor(f);
		ans++;
	}
	return 0;
}

Measured memory_bytes: 3628
/* ex3_3
   kohei_suzuki */

#include <stdio.h>
#include <math.h>

int main(void){
    int num, base; //整数num,進数base
    int dig = 0; //桁数dig

    scanf("%d %d",&num, &base); //num,base入力

    while(num >= pow(base,dig)){ //numとbase^digを比較して桁数を求める
        dig += 1; //digを1ずつ増やして繰り返し比較する
    }

    printf("%d\n",dig); //桁数digを出力

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;



int main(){
   int n; cin>>n;
   vi a(n),b(n),c(n);
   rep(i,0,n) cin>>a[i];
   rep(i,0,n) cin>>b[i];
   rep(i,0,n) c[i]=i+1;

   int begin,end,i=0;
   do{
       if(a==c) begin=i;
       if(b==c) end=i;
       i++;
   }while(next_permutation(c.begin(),c.end()));
   cout<<abs(end-begin)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define fo(i,k,n) for(i=k;i<=n;i++)
#define endl '\n'
ll dp[101][100001];
//memoisation
//ll knapsnack(ll* w,ll* v,ll n,ll mw){
	//if(dp[n][mw]>-1) return dp[n][mw];
	//if(n==0) return 0;//no item left
	//if(mw==0) return 0;//no more capacity
	//ll op1 = knapsnack(w,v,n-1,mw);
	//ll op2 = LLONG_MIN;
	//if(w[n-1]<=mw) op2 = v[n-1]+knapsnack(w,v,n-1,mw-w[n-1]);
	//return dp[n][mw]=max(op1,op2);
//}
//tabulation
ll knapsnacki(ll* w,ll* v,ll n,ll mw){
	ll i,j;
	fo(i,0,mw) dp[0][i]=0;
	fo(i,0,n) dp[i][0]=0;
	fo(i,1,n){
		fo(j,1,mw){
			dp[i][j] = dp[i-1][j];
			if(w[i-1]<=j) dp[i][j] = max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
		}
	}
	return dp[n][mw];
}
void solve(){
	ll i,j,n,mw;
	cin>>n>>mw;
	ll* w = new ll[n];
	ll* v = new ll[n];
	fo(i,0,n-1){
		cin>>w[i]>>v[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<knapsnacki(w,v,n,mw)<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	t=1;//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for( ll i=a;i<n;++i)
#define pb push_back
#define ll long long
#define vi vector<ll>

vi adj[1000001];
ll vis[1000001];

ll ans=0;
void dfs( ll node)
{
	vis[node] =1;
  	for( ll child:adj[node])
    {
		if(!vis[child])
        {
			vis[child] =1;
          dfs(child);
        }
    }
}


void solve()
{
ll n,m; cin>>n>>m;
  rep(i,0,m)
  {
	ll a,b; cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  rep(i,1,n+1)
  {
	if(!vis[i])
    {
		ans++;
      dfs(i);
    }
  }
  
  cout<<ans-1;
}
int main(){
  ll tt=1;
  while(tt--)
  {
		solve();
    	cout<<"\n";
  }


}

Measured memory_bytes: 32116
#include<bits/stdc++.h>
#define ll long long
#define gcd(x,y) __gcd(x,y)
#define fi first
#define se second
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline ll abs(A &a) { return (a < 0 ? -a : a); }
using namespace std;
const ll inf=(1LL<<62);
const ll MOD=(1e9)+7;
const ll mod=998244353;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;
  int sum = 0;
  for (ll i = 0; i < s.size(); i++) {
    int a = s[i] - '0';
    sum += a;
  }
  if (sum % 9 == 0) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }
  return 0;
}
 

Measured memory_bytes: 3740
#include <iostream>

using namespace std;

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

    if (a > b)
    {
        t = a;
        a = b;
        b = t;
    }
    if (b > c)
    {
        t = b;
        b = c;
        c = t;
    }
    if (a > b)
    {
        t = a;
        a = b;
        b = t;
    }

    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
					
public class Program
{	
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		
		int[,] G = new int[n,n];
		
		for(int i = 0; i < n; i++) {
			int[] u = Array.ConvertAll(Console.ReadLine().Split(" ".ToCharArray()), int.Parse);
			
			for(int j = 0; j < u[1];  j++) {
				G[u[0]-1, u[j+2]-1] = 1;
			}
		}
		
		Node[] nodes = new Node[n];
		for(int i = 0; i < n; i++) {
			nodes[i] = new Node(i);
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(G[i,j] != 0) { 
					nodes[i].Children.Add(nodes[j]);
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) nodes[j].Added = false;
			BFS(nodes[0], nodes[i], nodes[0].Children.ToArray());
		}
		
		for(int i = 0; i < n; i++) {
			Console.WriteLine(nodes[i]);
		}
	}
	
	static void BFS(Node start, Node goal,Node[] onWays)
	{
		if(start == goal) return;
		else {
			goal.d++;
			
			List<Node> nexts = new List<Node>();
			foreach (var o in onWays) {
				if(o == goal) return;
				
				if(!o.Added) {
					foreach(Node p in o.Children.ToArray()){
						if(p != start) nexts.Add(p);
					}
					o.Added = true;
				}
			}
			if(nexts.Count != 0) BFS(start, goal, nexts.ToArray());
			else goal.d = -1;
		}
	}
	
}

class Node
{
	public bool Added = false;
	public int d;
	public int Id { get; private set; }
	public List<Node> Children = new List<Node>();
	
	public Node (int id)
	{
		this.Id = id;
	}
	
	public override string ToString()
	{
		return (Id + 1) + " " + d;
	}
}

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) (vec).begin(),(vec).end()
#define int long long

signed main(){
    string s,t;
    int n;cin>>n>>s>>t;
    rep(i,n)printf("%c%c",s[i],t[i]);
    cout<<endl;
}

Measured memory_bytes: 256
# Aizu Problem 0240: Interest Rate

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def get_interest1(y, rate):
    return 100 + y * rate

def get_interest2(y, rate):
    return 100 * (1 + rate / 100)**y

while True:
    n = int(input())
    if n == 0:
        break
    y = int(input())
    high = 0
    for _ in range(n):
        no, rate, btype = [int(__) for __ in input().split()]
        if btype == 1:
            interest = get_interest1(y, rate)
        else:
            interest = get_interest2(y, rate)
        if interest > high:
            high = interest
            best = no
    print(best)

Measured memory_bytes: 7984
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    cout<<max(in()*in(),in()*in());
}

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

int main() {
  int INFINITY = (1<<16);
  int H, W; cin >> H >> W;
  int N = H * W;
  bool sq[N]; int d[N][N];
  for (int i = 0; i < H; i++) {
    string S; cin >> S;
    for (int j = 0; j < W; j++) {
      sq[i*W+j] = (S[j] == '.');
    }
  }
  for (int p1 = 0; p1 < N; p1++) {
    for (int p2 = 0; p2 < N; p2++) {
      d[p1][p2] = INFINITY;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int p = i*W+j;
      if (sq[p]) {
        d[p][p] = 0;
        if (i && sq[p-W]) d[p][p-W] = d[p-W][p] = 1;
        if (j && sq[p-1]) d[p][p-1] = d[p-1][p] = 1;
      }
    }
  }
  for (int k = 0; k < N; k++) {
    for (int p1 = 0; p1 < N; p1++) {
      for (int p2 = 0; p2 < N; p2++) {
        d[p1][p2] = min(d[p1][p2], d[p1][k] + d[k][p2]);
      }
    }
  }
  int move = 0;
  for (int p1 = 0; p1 < N; p1++) {
    for (int p2 = 0; p2 < N; p2++) {
      if (d[p1][p2] != INFINITY && d[p1][p2] > move)
        move = d[p1][p2];
    }
  }
  cout << move << endl;
}


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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < n; i++)

using namespace std;

int N; vector<int> X, Y;
int solve() {

	int res = N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i == j) continue;
			long long dx = X[j] - X[i], dy = Y[j] - Y[i];

			int sub = 0;
			for (int i2 = 0; i2 < N; ++i2) {
				for (int j2 = 0; j2 < N; ++j2) {
					if (j2 == i2) continue;
					if (dx == X[j2] - X[i2] && dy == Y[j2] - Y[i2]) ++sub;
				}
			}
			res = min(res, N - sub);
		}
	}
	return res;
}

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

	cin >> N;
	X.resize(N); Y.resize(N);

	if (N == 1) { cout << "1" << endl; return 0; }
	rep(i, N) { cin >> X[i] >> Y[i]; }

	cout << solve() << endl;
}

Measured memory_bytes: 256
height, width = gets.split(' ').map(&:to_i)
num_list = (0..9).to_a
costs = Array.new(10).map{ gets.split(' ').map(&:to_i) }
cnt_num = Array.new(10).map{ 0 }
height.times do
  gets.split(' ').map(&:to_i).each{|a|
  	cnt_num[a] += 1 if a >= 0
  }
end

fin_costs = Array.new(10).map.with_index{ |_, i|
  if i == 1 then 0
  else
    bots = [{pos: i, log: [i], cost: 0}]
    fin_bot = nil
    until bots.empty?
      bots = bots.flat_map{|b|
        num_list.find_all{|j| not b[:log].include?(j)}\
                .map{|j| {pos: j, log: b[:log]+[j], cost: b[:cost]+costs[b[:pos]][j]} }
      }
      new_bot = bots.find_all{|b| b[:pos] == 1}.min_by{|b| b[:cost] }
      fin_bot = new_bot if fin_bot.nil? or new_bot[:cost] < fin_bot[:cost]
      bots = bots.find_all{|b| b[:pos] != 1 and b[:cost] < fin_bot[:cost] }
    end
    fin_bot[:cost]
  end
}

print(cnt_num.zip(fin_costs).inject(0){|r,(i,j)| r+i*j})


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

int proceso (int a, int b){

	int x = a-b;
	if (x < 0) x*=-1;
	return x;
}

int main (){

	int n;
	cin >> n;

	vector <int> p1 (n,0);
	vector <int> p2 (n,0);

	vector <int> t (n,0);

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

		cin >> t[i];
	}

	if (n == 2){

		cout << proceso(t[0], t[1]) << endl;
		return 0;
	}

	p1[0] = proceso(t[0], t[1]);
	p2[0] = proceso(t[0], t[2]);

	int x=0;

	//cout << p1[0] << " " << p2[0] << endl;

	for (int i=1; i<n-1; i++){

		if (i == 1) x = p1[0];
		else x = min(p1[i-1], p2[i-2]);

		p1[i] = x + proceso(t[i], t[i+1]);

		if (i == n-2) continue;

		p2[i] = x + proceso(t[i], t[i+2]);

		//cout << p1[i] << " " << p2[i] << endl;
	}

	x = min(p1[n-2], p2[n-3]);

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

class RMQ{
  lli n;
  vector<lli>dat;
public:
  RMQ(lli n_){
    n = 1;
    while(n < n_) n *= 2;
    dat.resize(2*n - 1);
    for(lli i = 0; i < 2*n - 1; i++) dat[i] = 0;
  }
  void update(lli k,lli a){
    k += n - 1;
    dat[k] = max(a, dat[k]);
    while(k > 0){
      k = (k - 1)/2;
      dat[k] = max(dat[k*2 + 1], dat[k*2 + 2]);
    }
  }
  void print(){
    for (int i = n - 1; i < 2*n - 1; i++) {
      std::cout << dat[i] << " ";
    }
    std::cout << std::endl;
  }
  lli query(lli a,lli b,lli k = 0,lli l = 0,lli r = 0){
    if(r <= l) r = n;
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return dat[k];
    lli vl = query(a, b, k*2 + 1, l, (r + l)/2);
    lli vr = query(a, b, k*2 + 2, (r + l)/2, r);
    return max(vl, vr);
  }
};


int main(int argc, char *argv[]){
  lli n;
  cin >> n;
  vector<lli> x(n);
  RMQ r(n);
  for (lli i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<lli> dp(n);
  for (int i = 0; i < n; i++) {
    r.update(x[i] - 1, x[i] + r.query(0, x[i] - 1));
  }
   std::cout << (n*(n + 1))/2 - r.query(0, n) << std::endl;
  return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    
    int cnt = 0;
    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < m + 1; j++) {
            if (i * m + j * n - 2 * i * j == k) cnt++;
        }
    }
    
    cout << (cnt ? "Yes" : "No") << endl;
}


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

int main() {
  int d, s;
  while (~scanf("%d", &d)) {
    s = 0;
    for (int i = d; i < 600; i += d) {
      s += i * i * d;
    }
    printf("%d\n", s);
  }
}


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

int main(){
	int answer=0;
	int N;
  	cin>>N;
	vector<int> V(N);
	vector<int> C(N);

	for(int i=0;i<N;i++){
		cin>>V.at(i);
	}
	for(int i=0;i<N;i++){
		cin>>C.at(i);
	}	//definition of variable

	for(int j=0;j<N;j++){
		if((V.at(j)-C.at(j))>0){
			answer+=V.at(j)-C.at(j);
		}
	}

	cout<<answer<<endl;

return 0;
}

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

int main() {
	int n, l;
	int a, b = 1e3;
	int sum;
	scanf("%d%d", &n, &l);
	for(int i = 1; i <= n; i++) {
		a = l + i - 1;
		if(abs(a) < abs(b)) {
			b = a;
		}
		sum += a;
	}
	printf("%d", sum - b);
}

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

int main() {
 int n,d;
  cin >> n >> d;
  int ans = 0 ;
  int range = d*2+1;
  for(int i=0;n>0;i++){
    ans++;
    n -= range;
  }
  cout << ans ;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    if (a >= k) {
      System.out.println((a - k) + " " + b);
    } else if (b >= (k - a)) {
      System.out.println("0 " + (b - (k - a)));
    } else {
      System.out.println("0 0");
    }
  }
}


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

int main(){
	int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; i++){
  	cin>>a[i];
  }
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(a[1]-a[0]);
  
  for(int i=2; i<n; i++){
  	dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]), dp[i-1] + abs(a[i]-a[i-1]));
  }
  cout<< dp[n-1];
}


Measured memory_bytes: 4316
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;


int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VV<int> hu(n);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p; p--;
        hu[p].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        reverse(begin(hu[i]), end(hu[i]));
    }
    V<int> ans(n);
    V<int> st;
    for (int fe = 0; fe < 2*n; fe++) {
        int i = fe % n;
        for (int d: hu[i]) {
            st.push_back(d);
        }
        if (st.size()) {
            ans[i] = st.back(); st.pop_back();
        }
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 7576
package main

import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  if (a + b) % 2 == 0 {
    fmt.Println((a + b) / 2)
  } else {
    fmt.Println("IMPOSSIBLE")
  }
}



Measured memory_bytes: 640
/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    ll n, x, mn, cnt = 1;
    cin >> n >> mn;
    FOR(i, 1, n){
        cin >> x;
        if(x <= mn){
            cnt++;
            mn = x;
        }
    }
    cout << cnt << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


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

int main(){
  int trees,elec;
  cin>>trees>>elec;
  vector<int> graph(trees);
  vector<int> graph2(trees-elec+1);
  for(int i=0;i<trees;i++){
    cin>>graph.at(i);
  }
  sort(graph.begin(),graph.end());
  for(int i=0;i<trees-elec+1;i++){
    graph2.at(i)=graph.at(i+elec-1)-graph.at(i);
  }
  sort(graph2.begin(),graph2.end());
  cout<<graph2.at(0)<<endl;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    for(int i = 0;i < m;i ++){
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> c(0),d(0);
    set<int> e;

    for(int i = 0;i < m;i ++){
        if(a.at(i) == 1){
            c.push_back(b.at(i));
        }
    }

    for(int i = 0;i < m;i ++){
        if(b.at(i) == n){
            d.push_back(a.at(i));
        }
    }

    for(int i = 0;i < c.size();i ++){
        e.insert(c.at(i));
    }
    for(int i = 0;i < d.size();i ++){
        e.insert(d.at(i));
    }

    if(e.size() == c.size() + d.size()){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << "POSSIBLE" << endl;
    }
}

Measured memory_bytes: 12024
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<P> r(n);
  vector<P> b(n);
  rep(i,n) cin>>r[i].sc>>r[i].fs;
  rep(i,n) cin>>b[i].fs>>b[i].sc;

  sort(ALL(b));
  sort(ALL(r),greater<P>());

  // cout<<"r"<<endl;
  // rep(i,n){
  //   cout<<r[i].fs<<" "<<r[i].sc<<endl;
  // }
  // cout<<"b"<<endl;
  // rep(i,n){
  //   cout<<b[i].fs<<" "<<b[i].sc<<endl;
  // }
  int ans=0;
  vector<bool> memo(n,0);
  // cout<<"ikuyo-"<<endl;
  rep(i,n){
    rep(j,n){
      if(memo[j]) continue;
      if((r[j].sc<b[i].fs)&&(r[j].fs<b[i].sc)){
        ans++;
        memo[j]=1;
        break;
        // cout<<r[j].fs<<" "<<r[j].sc<<endl<<"b"<<endl;
        // cout<<b[i].fs<<" "<<b[i].sc<<endl;
      }
    }
  }
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pairSS
#define int long long
#define MOD 1000000007
int gcd(int a,int b){
  if(a==0){
    return b;
  }
  return gcd(b%a,a);
}
int lcm(int a,int b){
  return a*b/gcd(a,b);
}
int keta(int a){
  int count = 0;
  while(a!=0){
    a = a/10;
    count++;
  }
  return count;
}
signed main(){
	int n;
	cin >> n;
	map<string,int> mp;
	rep(i,n){
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	int ans = 0;
	for(auto & p :mp){
		int s = p.second;
		ans = ans + s*(s-1)/2;
	}
	cout << ans  << endl;
}


Measured memory_bytes: 11136
#include <cstdlib>
#include <vector>
#include <math.h>
#include <iostream>
using namespace std;

int main(){
	vector<vector<int> > a;

	int lines = 0;
	scanf("%d", &lines);

	bool isOk[lines];
	for (int i = 0; i < lines; ++i)
	{
		int l[3];
		for (int j = 0; j < 3; ++j)
			scanf("%d", &l[j]);

		double hen[3] = {pow(l[0], 2), pow(l[1], 2) ,pow(l[2], 2)};
		if(hen[0]+hen[1] == hen[2]) isOk[i] = true;
		else if(hen[1]+hen[2] == hen[0]) isOk[i] = true;
		else if(hen[2]+hen[0] == hen[1]) isOk[i] = true;
		else isOk[i] = false;
	}

	for (int i = 0; i < lines; ++i)
	{
		if(isOk[i]) printf("YES\n");
		else printf("NO\n");
	}
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
    
    int hA, sA, hB, sB;
    scanf("%d %d %d %d", &hA, &sA, &hB, &sB);
    int step = 0;
    while (true) {
        if (step % 2 == 0) {
            hB -= sA;
            if (hB <= 0) {
                printf("Yes\n");
                return 0;
            }
        } else {
            hA -= sB;
            if (hA <= 0) {
                printf("No\n");
                return 0;
            }
        }
        step++;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void solve(void)
{
  int A,B;
  cin>>A>>B;
  cout<<A + (B-A)*2<<endl;
  
  

  return;

   
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

int main() {
  int N; cin >> N;
  int max = -1;
  int min = 1000000001;
  for ( int i = 0; i < N; i++ ) {
    int num; cin >> num;
    if ( num > max ) {
      max = num;

    }
    if ( min > num ) {
      min = num;

    }


  }
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 3e5+1;
ll row[inf], col[inf];
void solve()
{

    ll h,w; cin >> h >> w;
    ll m; cin >> m;
    set<pair<ll,ll>> s;
    while(m--){
        ll x,y; cin >> x >> y;
        row[x]++;
        col[y]++;
        s.insert({x,y});
    }
    ll maxX=0, maxY=0;
    for(ll i=1; i<=h; i++)
        maxX = max(maxX, row[i]);
    for(ll i=1; i<=w; i++)
        maxY = max(maxY, col[i]);
    ll ans = maxX + maxY -1;

    vector<ll> allmaxX, allmaxY;
    for(ll i=1; i<=h; i++)
        if(row[i]==maxX) allmaxX.pb(i);
    for(ll i=1; i<=w; i++)
        if(col[i]==maxY) allmaxY.pb(i);
    
    for(auto A : allmaxX){
        for(auto B : allmaxY)
            if(!s.count({A,B}))
            {
                ans++; goto printing;
            }
    }
    printing:
    cout << ans << endl;
}

int main() {
Knucklehead 
/*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int w = 1;
  while (true) {
    if (w * (w + 1) == n * 2) {
      break;
    } else if (w * (w + 1) > n * 2) {
      cout << "No" << endl;
      return 0;
    }
    w++;
  }
  auto ans = vector<vector<int>>(w + 1);
  int s = 1;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < w - i; j++) {
      ans[i].push_back(s + j);
      ans[i + j + 1].push_back(s + j);
    }
    s += w - i;
  }
  cout << "Yes" << endl;
  cout << w + 1 << endl;
  for (int i = 0; i < w + 1; i++) {
    cout << w << "  ";
    for (int j = 0; j < w; j++) {
      if (j == w - 1) {
        cout << ans[i][j] << endl;
      } else {
        cout << ans[i][j] << "  ";
      }
    }
  }
  return 0;
}


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

using namespace std;

int day[101];
int n, q;
string moji;

void fJ()
{
	string s {moji[moji.length()-1]};
	for (int i = 0; i < moji.length()-1; i++) {
		s += moji[i];
	}
	moji = s;
}

void fC()
{
	string s = "";
	for (int i = 1; i < moji.length(); i++) {
		s += moji[i];
	}
	s += moji[0];
	moji = s;
}

void fE()
{
	int l = moji.length();
	string a="", b="", c="";
	if (l % 2) b += moji[l/2];
	for (int i = 0; i < l/2; i++) {
		a += moji[i];
	}
	for (int i = l/2 + l % 2; i < l; i++) {
		c += moji[i];
	}
	moji = c + b + a;
}

int fP()
{
	int l = moji.length();
	for (int i = 0; i < l; i++) {
		if (isdigit(moji[i])) {
			int t = moji[i] - '0';
			moji[i] = ((t+9) % 10) + '0';
		}
	}
}

int fM()
{
	int l = moji.length();
	for (int i = 0; i < l; i++) {
		if (isdigit(moji[i])) {
			int t = moji[i] - '0';
			moji[i] = ((t+1) % 10) + '0';
		}
	}
}

int fA()
{
	string s = "";
	int l = moji.length();
	for (int i = 0; i < l; i++) {
		s = moji[i] + s;
	}
	moji = s;
}


int main()
{
	int N;
	string hito;
	cin >> N;
	for (int i = 0; i < N; i++) {		
		cin >> hito >> moji;
		for (int j = hito.length()-1; j >= 0; j--) {
			if (hito[j] == 'J') fJ();
			if (hito[j] == 'C') fC();
			if (hito[j] == 'E') fE();
			if (hito[j] == 'A') fA();
			if (hito[j] == 'P') fP();
			if (hito[j] == 'M') fM();
		}
		cout << moji << endl;
	}
}


Measured memory_bytes: 3172
# coding: utf-8

# https://atcoder.jp/contests/abc108


def main():
    N, K = map(int, input().split())

    rests = [x % K for x in range(1, N+1)]
    n_rests = [0 for _ in range(K)]
    
    for r in rests:
        n_rests[r] += 1
    
    ans = 0
    ans += n_rests[0]**3
    for r in range(1, K):
        ans += n_rests[r]**3 if r == K-r else 0
    
    return ans


print(main())


Measured memory_bytes: 10392
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int N, K, A[200005];

int main()
{
	cin >> N >> K;
	for(int i = 1;i <= N;++i)
	{
		cin >> A[i];
		if(i >= K + 1)
		{
			if(A[i] > A[i - K])
				printf("Yes\n");
			else
				printf("No\n");
		}
	}

	return 0;
}

Measured memory_bytes: 4412
n,time_max = map(int,input().split())
cost = []
time = []
for i in range(n):
  a = input().split()
  cost.append(int(a[0]))
  time.append(int(a[1]))

while True:
  min_index = cost.index(min(cost))
  if time[min_index] <= time_max:
    print(cost[min_index])
    break
  elif cost[min_index] == 1001:
    print("TLE")
    break
  else:
    cost[min_index] = 1001

Measured memory_bytes: 3064
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dfs(node: usize, pre: usize, to: &Vec<Vec<usize>>, x_vec: &Vec<u64>, counter: &mut Vec<u64>) {
    // println!("{}", node);
    counter[node] = x_vec[node] + counter[pre];
    for child in &to[node] {
        if *child == pre {
            continue;
        }    
        dfs(*child, node, to, x_vec, counter);
    }
}

fn main() {
    let (n, q) = input_tuple();
    let mut to: Vec<Vec<usize>> = vec![Vec::new(); n as usize];
    let mut x_vec: Vec<u64> = vec![0; n as usize];    
    for _ in 0..(n-1) {
        let (a, b) = input_tuple();
        to[(a-1) as usize].push((b-1) as usize);
        to[(b-1) as usize].push((a-1) as usize);
    }
    for _ in 0..q {
        let (p, x) = input_tuple();
        x_vec[(p-1) as usize] += x;
    }
    let mut counter: Vec<u64> = vec![0; n as usize];
    dfs(0, 0, &to, &x_vec, &mut counter);
    for val in counter {
        print!("{} ", val);
    }
    println!();
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (ll)1e12
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n;
	cin>>n;
	int h[n];
	fr(i,0,n)
	cin>>h[i];
	ll dp[n];
	fr(i,0,n)
	dp[i]=INF;
	dp[0]=0;
	fr(i,0,n-1)
	if(i==n-2)
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
	else{
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}
	cout<<dp[n-1]<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 4792