akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // ver2.2.8
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,l;
  cin >> n >> l;
  
  Vi get(n+1),home(n+1),getr(n+1),homer(n+1);
  
  Vi len(n),v(n);
  rep(i,0,n) cin >> len[i] >> v[i];
  
  int sum=0;
  
  rep(i,0,n){
    sum += v[i];
    get[i+1] = sum - len[i];
    home[i+1] = sum - 2*len[i];
  }
  
  sum = 0;
  repreq(i,n-1,0){
    sum += v[i];
    getr[i] = sum - (l-len[i]);
    homer[i] = sum - (l-len[i])*2;
  }
  
  
  int maxx = 0;
  rep(i,0,n+1){
    maxx = max(maxx,home[i]);
    home[i] = maxx;
  }
  
  maxx=0;
  
  repreq(i,n,0){
    maxx = max(maxx,homer[i]);
    homer[i] = maxx;
  }
  
  
  int ans = 0;
  //Verr(getr);
  //cerr<<endl;
  //Verr(home);
  
  rep(i,0,n+1){
    ans = max(ans,get[i]+homer[i]);
  }
  rep(i,0,n+1){
    ans = max(ans,getr[i]+home[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long 
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/



int main(){
    //IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        ll n,sum=0;
        cin>>n;
        ll a[n+1];
        FOR(i,n)cin>>a[i];
        sort(a,a+n,greater<int>());
        sum+=a[0];
        ll i=1,j=1;
        while(j+1<n){
            //cout<<j<<"\n";
            if(j+2<n){
                sum+=2*a[i];
                j+=2;
            }
            else if(j+1<n){
                sum+=a[i];
                j++;
            }
            i++;
            //cout<<sum<<"\n";
        }
        cout<<sum<<"\n";


    }
    
    return 0;
} 

Measured memory_bytes: 5208
#include<stdio.h>
int main(){
  int w,h,i,j,n;
  while(scanf("%d %d",&w,&h),w||h){
    int f[20][20],d[20][20]={0};
    for(i=0;i<400;i++)f[i/20][i%20]=1;
    scanf("%d",&n);
    while(n--){
      scanf("%d %d",&i,&j);
      f[j][i]=0;
    }
    d[1][0]=1;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++)d[i][j]=d[i-1][j]*f[i-1][j]+d[i][j-1]*f[i][j-1];
    }
    printf("%d\n",d[h][w]);
  }
  return 0;
}
  

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main()
{
    int H, W, D;
    cin >> H >> W >> D;

    //cout << H << W << D;

    vector<int> dis(H * W, 0);
    vector<P> match(H * W);

    rep(i, H) {
        rep(j, W) {
            int A;
            cin >> A;
            match[A - 1] = P(i, j);
        }
    }

    

    rep(i, D) {
        for (int j = i + D; j < H * W; j += D) {
            P s = match[j];
            P e = match[j - D];
            dis[j] = dis[j - D] + (abs(s.first - e.first) + abs(s.second - e.second));
        }
    }
    
    int Q;
    cin >> Q;
    vector<P> LR(Q);
    
    /*
    rep(i, D) {
        rep(j, H * W) {
            cout << dis[j] << " ";
        }
        cout << endl;
    }
    */

    rep(i, Q) {
        cin >> LR[i].first >> LR[i].second;
    }

    rep(i, Q) {
        int L, R;
        L = LR[i].first;
        R = LR[i].second;
        L--;
        R--;
        cout << dis[R] - dis[L] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

string s;

int scnt;

int main() {
    cin >> s; scnt = 0;

    int rem = 0;

    FORN(i, s.size()) {
        if (s[i] == 'T') {
            if (scnt > 0) {
                scnt--;
                rem++;
            }
        }
        else {
            scnt++;
        }
    }

    printf("%d\n", (int)s.size() - 2 * rem);

    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdbool.h>

int main(void){
    int flag = false;
    int N;
    scanf("%i", &N);
    int H[N];
    for (int i = 0; i < N; i++){
        scanf("%i", &H[i]);
    }
    for (int i = N - 2; i >= 0; i--){
        if (H[i] == H[i + 1] + 1){
            H[i] -= 1;
        } else if (H[i] <= H[i + 1]){
        } else {
            flag = true;
            break;
        }
    }
    if (flag){
        puts("No");
    } else {
        puts("Yes");
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
 
int main()
{
  int K;
  cin >> K;
  
  int sum=0;
  for(int i=1;i<K+1;i++)
  {
  for(int j=1;j<K+1;j++)
  {
  for(int l=1;l<K+1;l++)
  {
    sum += gcd(i,gcd(j,l));
  }
  } 
  }
  
  cout << sum;
  return 0;
}

Measured memory_bytes: 3632
/*input
314159265 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    int cnt = 0;
    while(n > 0)
    {
    	n /= k;
    	cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
d=[h%2and w%2,w%2*h//2+h%2*w//2,0,h//2*(w//2)]
for i in map(s.count,set(s)-{'\n'}):
  for j in(3,1,0):
    while d[j]and i>j:
      i-=j+1
      d[j]-=1
print('YNeos'[sum(d)>0::2])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
 
typedef unsigned long long ull;
 
int main(void){
	int X,Y,Z,K;
  	std::cin >> X >> Y >> Z >> K;
  	std::vector<ull> X_, Y_, Z_;
  	X_.resize(X);
  	Y_.resize(Y);
  	Z_.resize(Z);
  	for(int i = 0; i < X; ++i){
    	std::cin >> X_[i];
    }
  	for(int i = 0; i < Y; ++i){
    	std::cin >> Y_[i];
    }
  	for(int i = 0; i < Z; ++i){
    	std::cin >> Z_[i];
    }
  

    std::vector<ull> XY_;
    for(int i = 0; i < X; ++i){
        for(int j = 0; j < Y; ++j){
            XY_.push_back(X_[i]+Y_[j]);
        }
    }

    std::sort(XY_.begin(), XY_.end(), std::greater<ull>());

    std::vector<ull> XYZ_;

    for(int i = 0; i < std::min(K, X*Y); ++i){
        for(int j = 0; j < Z ; ++j){
            XYZ_.push_back(XY_[i] + Z_[j]);
        }
    }

    std::sort(XYZ_.begin(), XYZ_.end(), std::greater<ull>());

    for(int i = 0; i < K; ++i){
        std::cout << XYZ_[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 42856
H, W = map(int, input().split())
S = [input() for _ in range(H)]

# 方向差分のリストをもつ
dx = [1,-1,0,0,1,-1,1,-1]
dy = [0,0,1,-1,1,1,-1,-1]

for i in range(H):
  ans = ''
  for j in range(W):
    if S[i][j] == '#':
      ans += '#'
    else:
      count = 0  
      for d in range(8):
        x = i + dx[d]
        y = j + dy[d]
        if x in range(0,H) and y in range(0,W):
          if S[x][y] == '#':
            count += 1
      ans += str(count)
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    int N,x,y;
    cin >> N >> x >> y;
    vector<int> c(N);
    for (int i=1; i<N; ++i) {
        vector<int> d(N+1, 100000);
        queue<int> q;
        q.push(i);
        d[i] = 0;
        while (!q.empty()) {
            int v = q.front(); q.pop();
            if (v > 1 && updmin(d[v-1], d[v] + 1))
                q.push(v-1);
            if (v < N && updmin(d[v+1], d[v] + 1))
                q.push(v+1);
            if (v == x && updmin(d[y], d[v] + 1))
                q.push(y);
            if (v == y && updmin(d[x], d[v] + 1))
                q.push(x);
        }
        for (int j=i+1; j<=N; ++j)
            c[d[j]]++;
    }
    for (int i=1; i<N; ++i)
        cout << c[i] << endl;
}


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

int main(){
  int a, b, c;
  bool have;
  int ans;
  cin >> a >> b >> c;
  if(a == b){
    if(b == c) ans = 1;
    else ans = 2;
  }
  else if(a == c){
    ans = 2;
  }
  else if(b == c) ans = 2;
  else ans = 3;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = input()
a_cnt = 0
b_cnt = 0
while True:
    try:
        a_order = 0
        b_order = 0
        s = list(input().split())
        if s[0] > s[1]:
            a_cnt += 3
        elif s[0] == s[1]:
            a_cnt += 1
            b_cnt += 1
        else:
            b_cnt += 3
    except EOFError:
        break

print(a_cnt,b_cnt)
            






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

int main() {
    int N; cin >> N;
    for(int i=1; i<10; ++i) {
        for(int j=1; j<10; ++j) {
            if(i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(ll i = 0; i < x; i++)
typedef long long ll;
const ll N = 1e9 + 7;
using namespace std;

int main(){
    string s; cin >> s;
    string num;
    bool ok = true;
    // while(ok){
    //     int pos = s.find("BC");
    //     if(pos == string::npos) break;
    //     s.replace(pos,2,"D");
    // }
    ll i = 0;
    // cout << s.size() << " ";
    while(i < s.size()){
        if(s[i] == 'A') num.push_back('A');
        else if(s[i] == 'B' && s[i+1] == 'C') {
            num.push_back('D');
            i++;
        }
        else num.push_back(s[i]);
        i++;
    }
    // rep(i,num.size())
    //     cout << num[i];
    ll ans = 0;
    ll temp = 0;
    rep(i,num.size()){
        if(num[i] == 'A') temp++;
        else if(num[i] == 'D') ans += temp;
        else temp = 0;
        // cout << temp << endl;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 776
import java.io.PrintWriter;
import java.util.*;
//https://qiita.com/p_shiki37/items/3902f4e3adc3aeb382f1

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

        String b = "Yes";
        for (int i=0; i<S.length(); i++) {
            if (i % 2 == 0) {
                if ("L".equals(S.substring(i, i+1))) {
                    b = "No";
                    break;
                }
            } else {
                if ("R".equals(S.substring(i, i+1))) {
                    b = "No";
                    break;
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        sb.append(b);

        PrintWriter out = new PrintWriter(System.out);
        out.println(sb);
        out.flush();
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  long sum = 0;
  if (N <= K) {
    cout << 0 << endl;
  }
  else {
    sort(H.begin(), H.end());
    for (int i = 0; i < (H.size() - K); i++) {
      sum += H.at(i);
    }
    cout << sum << endl;
  }
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

void solve(int N,int x){
    int xmin = 1, xmax = 2*N-1;
    if (x <= xmin || xmax <= x) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    vi a(2*N-1, 0);
    if (N==2) {
        // x==2
        rep(i,3) a[i] = 1+i;
    } else {
        vector<bool> used(2*N, false);

        a[N] = x; used[x] = true;
        if (x <= N) {
            // ... x+1 1 x x+2 ...
            a[N-1] = 1;   used[1] = true;
            a[N-2] = x+1; used[x+1] = true;
            a[N+1] = x+2; used[x+2] = true;
        } else {
            // ... x-1 2n-1 x x-2 ...
            a[N-1] = 2*N-1; used[2*N-1] = true;
            a[N-2] = x-1;   used[x-1] = true;
            a[N+1] = x-2;   used[x-2] = true;
        }
        for (int i=0,j=1; i<=2*N-1; ++i) {
            if (a[i] == 0) {
                while (used[j]) ++j;
                a[i] = j++;
            }
        }
    }

#ifdef DEBUG
    fprintf(stderr, "N=%d, x=%d\n", N, x);
    cerr << a << endl;
#endif
    rep(i, 2*N-1) {
        cout << a[i] << endl;
    }
}

int main() {
    int N,x; cin>>N>>x;
    solve(N,x);
    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll ans = a[0];
  int left = n-2;
  for(i=1;i<n;i++)
  {
    if(left > 2)
    {
      ans += a[i]*2;
      left -= 2;
    }
    else
    {
      ans += a[i]*left;
      break;
    }
  }
  cout << ans << "\n";
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;
            if (s == "SUN") ans = 7;
            else if (s == "MON") ans = 6;
            else if (s == "TUE") ans = 5;
            else if (s == "WED") ans = 4;
            else if (s == "THU") ans = 3;
            else if (s == "FRI") ans = 2;
            else if (s == "SAT") ans = 1;


            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define reg(i,a,b) for(ll i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=2e4;
int ans;
int a[mx];
int b[mx];
int c[mx];
int d[mx];
int main() {
	int n;
	scanf("%d",&n);
	reg (i,1,n) {
	    in(a[i]);
	}
	reg (i,1,n) {
	    in(b[i]);
	    c[i]=a[i]-b[i];
	}
	reg (i,1,n) {
		d[i]=max(d[i-1],d[i-1]+c[i]);
	}
	printf("%d\n",d[n]);
	return 0;
}




Measured memory_bytes: 256
import qualified Data.Map.Lazy as ML
import Data.Maybe
import Control.Monad
import Data.Functor

main::IO ()
main=do
   n<-read <$> getLine::IO Int
   when (n>0) $
     do
        table<- replicateM n getLine
        let transMap=ML.fromList $ map (\(a:_:b:_)->(a,b)) table
        m<-read <$> getLine::IO Int
        str<-map head <$> replicateM m getLine
        putStrLn $ translate transMap str
        main


translate::Ord k=>ML.Map k k->[k]->[k]
translate mp str=map (\c->fromMaybe c (ML.lookup c mp)) str

Measured memory_bytes: 22568
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

template<class F>
i64 bisect(i64 l, i64 r, F f) { // (l, r]
  if (r - l <= 1) return r;
  i64 m = l + (r - l) / 2;
  return f(m) ? bisect(l, m, f) : bisect(m, r, f);
}
i64 n, m;
i64 a[301][301];
int main() {
  cin >> n >> m;
  for (i64 i = 0; i < n; ++i) {
    for (i64 j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }

  i64 ans = bisect(0, n, [&](i64 x) {
    vector<bool> b(m + 1, true);
    while (true) {
      vector<i64> cnt(m + 1);
      for (i64 i = 0; i < n; ++i) {
        for (i64 j = 0; j < m; ++j) {
          i64 k = a[i][j];
          if (b[k]) {
            cnt[k]++;
            break;
          }
        }
      }
      bool ok = true, ex = false;
      for (i64 k = 1; k <= m; ++k) {
        if (cnt[k] > x) {
          b[k] = false;
          ok = false;
        }
        ex |= cnt[k] > 0;
      }
      if (!ex) return false;
      if (ok) return true;
    }
  }); 
  cout << ans << endl;
  return 0;
}


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

namespace ConsoleTest
{
    class Program
    {
        private static int[][] _memo;
        private static int[] _shortest;

        static void Main(string[] args)
        {
            int[] v = MyIo.Ints();
            //int[] v = new int[] { 10000, 1, 2 };
            int n = v[0];
            int x = v[1];
            int y = v[2];
           
            CalcShortest(n,x,y);
            SumShortest(n);

            for (int k = 1; k <= n-1; k++)
            {
                //Console.WriteLine(SumShortest(n,x,y,k));
                Console.WriteLine(_shortest[k]);
            }
        }

        private static void SumShortest(int n)
        {
            _shortest = new int[n + 1];
            for (int i = 1; i <= n - 1; ++i)
            {
                for (int j = i + 1; j <= n; ++j)
                {
                    _shortest[_memo[i][j]]++;
                }
            }
        }

        private static void CalcShortest(int n, int x, int y)
        {
            _memo = new int[n + 1][];
            for (int i = 0; i <= n; ++i)
            {
                _memo[i] = new int[n + 1];
            }
            for (int i = 1; i <= n - 1; ++i)
            {
                for (int j = i + 1; j <= n; ++j)
                {
                    int s = ShortestDistance(n, x, y, i, j);
                    _memo[i][j] = s;
                }
            }
        }


        private static int ShortestDistance(int n, int x, int y, int i, int j)
        {
            var basic = j - i;
            int toX = Math.Abs(x - i);
            int toY = Math.Abs(y - j);
            var branch = toX + toY+1;
            //Console.WriteLine(string.Format("SD for({4}, {5}) : {0}, {1}, {2}, {3}", basic, toX, toY, branch, i,j));
            return Math.Min(basic, branch);
        }
    }
    static class MyIo
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
        public static int[][] MultiInts(int num)
        {
            var result = new int[num][];
            for(int i = 0; i < num; ++i)
            {
                result[i] = Ints();
            }
            return result;
        }
        public static T[] MultiItems<T>(int num, Func<string,T> parser)
        {
            var result = new T[num];
            for(int i =0; i < num; ++i)
            {
                result[i] = parser(Console.ReadLine());
            }
            return result;
        }
    }
}


Measured memory_bytes: 32968
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
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 T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 3010;

//head

string s, t;
int n, m;
int dp[N][N];
string ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s >> t;
  n = s.size();
  m = t.size();
  rep(i, n) {
    rep(j, m) {
      if(s[i] == t[j]) {
        chmax(dp[i+1][j+1], dp[i][j]+1);
      }
      else {
        chmax(dp[i+1][j+1], max(dp[i][j+1], dp[i+1][j]));
      }
    }
  }

  int i = n, j = m;
  while(i and j) {
    if(dp[i][j]-1 == dp[i-1][j-1] and s[i-1] == t[j-1]) {
      i--;
      j--;
      ans += s[i];
    }
    else if(dp[i][j-1] == dp[i][j]) j--;
    else i--;
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 38816
#include <bits/stdc++.h>
#define F first
#define S second
#define mkp(x, y) make_pair(x, y)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;


map<ll, ll> mp;
ll a[222222], dp[222222];
vector<int> ans;
int main()
{
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
	}
	ll mx = 0, ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		mp[a[i]] = i;
		dp[i] = dp[mp[a[i] - 1]] + 1;
		if(dp[i] > mx)
		{
			mx = dp[i];
			ans = a[i];
		}
	}
	cout << n - mx;
}

Measured memory_bytes: 15872
c = [list(map(int, input().split())) for i in range(3)]
if c[0][0]-c[0][1] != c[1][0]-c[1][1] or c[1][0]-c[1][1] != c[2][0]-c[2][1] or c[0][0] - c[0][1] != c[2][0]-c[2][1] or c[0][1]-c[0][2] != c[1][1]-c[1][2] or c[1][1]-c[1][2] != c[2][1]-c[2][2] or c[0][1] - c[0][2] != c[2][1]-c[2][2] or c[0][0]-c[0][2] != c[1][0]-c[1][2] or c[1][0]-c[1][2] != c[2][0]-c[2][2] or c[0][0] - c[0][2] != c[2][0]-c[2][2]:
		print("No")
		exit()
print("Yes")

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

int main()
{
    char a;
    cin>>a;
    if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
    {
        cout <<"vowel";
    }
    else
    {
        cout <<"consonant";
    }
}


Measured memory_bytes: 256
local H,W,M=io.read("n","n","n")
local bombh={}
local bombw={}
local map={}
for i=1,math.max(H,W) do
    bombh[i]={}
    bombw[i]={}
    map[i]={}
end

for i=1,M do
    local h,w=io.read("n","n")
    table.insert(bombh[h],w)
    table.insert(bombw[w],h)
    map[h][w]=true
end

local hmax=0
local wmax=0
for i=1,math.max(H,W) do
    hmax=math.max(hmax,#bombh[i])
    wmax=math.max(wmax,#bombw[i])
end

local max=hmax+wmax-1
local maxh={}
local maxw={}
for h=1,#bombh do
    if #bombh[h]==hmax then
        table.insert(maxh,h)
    end
end
for w=1,#bombw do
    if #bombw[w]==wmax then
        table.insert(maxw,w)
    end
end

for i=1,#maxh do
    local h=maxh[i]
    for j=1,#maxw do
        local w=maxw[j]
        if (map[h] and (not map[h][w])) then
            max=max+1
            print(max)
            return
        end
    end
end
print(max)

Measured memory_bytes: 93456
N = int(input())
H = [int(i) for i in input().split()]

ans = 0
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14224
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(N: int, A: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): プレイヤー数（2 <= N <= 2*10**5）
        A (list): フレンドリーさ
    """
    # 求解処理
    A = sorted(A, reverse=True)
    ans = 0
    for n in range(1, N + 1):
        if n == 1:
            continue
        ans += A[math.ceil(n / 2) - 1]

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(N, A)


Measured memory_bytes: 30752
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    ll n;
    cin>>n;
    ll w;
    cin>>w;
    ll a[n],b[n];
    ll sum=0;
    fori(n) cin>>a[i]>>b[i];
    fori(n) sum+=b[i];
    
    vector<ll> dp(sum+1,d7);
    dp[0]=0;
    fori(n){
        for(ll y=sum-b[i];y>=0;y--){
            dp[y+b[i]]=min(dp[y]+a[i],dp[y+b[i]]);
        }
    }
    ll ans=0;
    fori(sum+1){
        if(dp[i]<=w){
            ans=max(ans,i);
        }
    }
    cout<<ans;
    
    
//code ends
    return 0;
}


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

int main() {
	vector<int> x,y;
	int n,o,p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>o>>p;
		x.push_back(o);
		y.push_back(p);
	}
	bool check=false;
	for(int i=0;i<n-2;i++){
		if(x[i]==y[i]&&x[i+1]==y[i+1]&&x[i+2]==y[i+2]){
			check=true;
		}
	}
	if(check){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,i,ans=0;
	cin>>n;
	int l[2*n];
	for(i=0;i<2*n;i++)cin>>l[i];
	sort(l,l+2*n);
	for(i=0;i<2*n;i+=2){
		ans+=min(l[i],l[i+1]);
	}
	cout<<ans<<endl;
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
s=str(input())
t=str(input())

flag=False

m=0

for i in range(len(s)-len(t)+1):
  cnt=0
  for j in range(len(t)):
    #print(s[i+j],t[j])
    if s[i+j]==t[j]:
      cnt+=1
      flag=True
    
  if m==0 or m<cnt:
    m=cnt

print(len(t)-m)


Measured memory_bytes: 67624
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  int x, t;
  cin >> x >> t;
  if (x - t >= 0) cout << x - t << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9+7)
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modinv(LL a){
	LL b = MOD, u = 1, v = 0;
	while(b){
		LL t = a / b;
		a -= t * b;swap(a, b);
		u -= t * v;swap(u, v);
	}
	u%=MOD;
	if(u < 0) u += MOD;
	return u;

}
LL exp(LL a, LL b){
	LL res = 1;
	LL sum = a;
	while(b){
		if(b&1)res = (res * sum) % MOD;
		sum = (sum * sum) % MOD;
		b>>=1;
	}
	return res;
}

LL factorial(LL x){
	static LL memo[100001]={0};
	if(x<=1)return 1;
	if(memo[x])return memo[x];
	return memo[x] = x * factorial(x-1) % MOD;
}

LL C(LL a, LL b){
	return factorial(a) * exp(factorial(b)*factorial(a-b)%MOD, MOD-2)%MOD;
}

int main(){
	LL N, M;
	cin >> N >> M;
	for(int i=N;i*i<=M;++i){
		if(M%i==0){
			cout << M/i << endl;
			return 0;
		}
	}
	LL ans = 1;
	for(int i=2;i*N<=M;++i){
		if(M%i==0){
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

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

int main(void) {
    int n; cin >> n;
    string s; cin >> s;
    ll r = 0;
    ll g = 0;
    ll b = 0;
    for(int i = 0; i < n; i++) {
        if(s[i]== 'R') r++;
        else if(s[i]== 'G') g++;
        else    b++;
    }
    /*
    r = count(s.begin(),s.end(),'R');
    g = count(s.begin(),s.end(),'G');
    b = count(s.begin(),s.end(),'B');
    */

    ll ans = r * g * b;

    ll del = 0;
    for(int m = 1; m < n -1; m++) {
        for(int d = 1; d <=n; d++) {
            int _min = m - d;
            int _max = m + d;
            if(_min < 0 || _max >= n) continue;
            if(s[m]!=s[_min] && s[_min] != s[_max] && s[_max] != s[m]) {
                del++;
            }
        }
    }
    cout << ans -del << endl;

    return 0;
}

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

int n, m, a[505][505];
struct st {
	int x1, y1, x2, y2;
};
vector<st> b;
void f(st p) {
	a[p.x2][p.y2]++;
	b.push_back(p);
}
int main()
{
	int i, j, k;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			scanf ("%d", &a[i][j]);
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			if (a[i][j] % 2 == 0 || i == n && j == m) continue;
			if (i < n) f({i, j, i + 1, j});
			else f({i, j, i, j + 1});
		}
	}
	cout << b.size() << endl;
	for (i = 0; i < b.size(); i++) {
		printf("%d %d %d %d\n", b[i].x1, b[i].y1, b[i].x2, b[i].y2);
	}
    return 0;
}


Measured memory_bytes: 5232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807-1;
const int inf = 2147483647-1;
ll minl(ll a[],int n){
    ll rtn = a[0];
    REP(i,n){
        if(rtn>a[i])rtn=a[i];
    }
    return rtn;
}
ll maxl(ll a[],int n){
    ll rtn = a[0];
    REP(i,n){
        if(rtn<a[i])rtn=a[i];
    }
    return rtn;
}

int main() {
    int n;
    cin >> n;
    ll a[200010];
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n){
        a[i] -= i+1;
    }
    sort(a,a+n);
    ll cen = a[(n-1)/2];
    ll m=0;
    REP(i,n){
        m += abs(a[i]-cen);
    }
    put(m);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

int H, W;
int table[20][20];
int cnt;

void calc(int current_y, int current_x) {
	table[current_y][current_x] = 3;

	if(current_y > 0 && table[current_y-1][current_x] == 1)
		calc(current_y-1, current_x);
	if(current_x > 0 && table[current_y][current_x-1] == 1)
		calc(current_y, current_x-1);
	if(current_y < H-1 && table[current_y+1][current_x] == 1)
		calc(current_y+1, current_x);
	if(current_x < W-1 && table[current_y][current_x+1] == 1)
		calc(current_y, current_x+1);

	cnt++;
}


int main() {
	while(1) {
		cnt = 0;
		cin >> W >> H;
		if(W == 0 && H == 0) break;

		char temp;
		int current[2];
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				cin >> temp;
				if(temp=='.') table[i][j] = 1;
				else if(temp=='#') table[i][j] = 2;
				else if(temp=='@') {
					table[i][j] = 0;
					current[0] = i;
					current[1] = j;
				}
			}
		}

		calc(current[0], current[1]);

		cout << cnt << endl;
	}

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const double PI = 3.14159265358979;

int main() {
    double a, b, x; cin >> a >> b >> x;
    double theta;

    if(a * a * b / 2 < x){
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    }else{
        theta = atan((a * b * b) / (2 * x));
    }

    theta = theta * 180 / PI;
    cout << setprecision(20) << theta << endl;
}


Measured memory_bytes: 512
S=input()
A=['A','G','T','C']
ans=0
cnt=0
N=len(S)

for i in range(N):
    cnt=0
    for j in range(0,N-i):
        if S[i+j] in A:
            cnt+=1
        else:
            break
    ans=max(ans,cnt)
print(ans)

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

int main() {
    int D, T, S;
    cin >> D >> T >> S;

    if (T * S >= D)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(){

  int a, n, i, ave, total=0, max=0, min=1000;

  while (1){
    total=0, max=0, min=1000;
    scanf ("%d", &n);
    if (n == 0 || n == 1 || n == 2) break;
    for (i = 1; i <= n; i++){
      scanf ("%d",&a);
      total = total + a;
      if (a >= max){
	max = a;
      }
      if (a <= min){
	min = a;
      }
    }
    ave = (total - max - min) / ( n - 2);
    printf ("%d\n", ave);
  }
  return 0; 
}

Measured memory_bytes: 600
use std::io;
use std::f64::consts::PI;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let r: f64 = s.trim().parse().unwrap();
    println!("{:.5} {:.5}", r*r*PI, 2.0*r*PI);
}


Measured memory_bytes: 5056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int H, W, M; cin >> H >> W >> M;

    map<int, set<int>> xy, yx;

    rep(i, M) {
        int x, y; cin >> x >> y;
        x--; y--;
        xy[x].insert(y);
        yx[y].insert(x);
    }

    int xmax = -1, ymax = -1;
    rep(i, H) { xmax = max(xmax, (int) xy[i].size()); }
    rep(i, W) { ymax = max(ymax, (int) yx[i].size()); }

    vi xx, yy;
    rep(i, H) {
        if ((int) xy[i].size() == xmax) {
            xx.push_back(i);
        }
    }
    rep(i, W) {
        if ((int) yx[i].size() == ymax) {
            yy.push_back(i);
        }
    }

    int ans = xmax + ymax - 1;
    rep(i, xx.size()) {
        bool flg = false;
        rep(j, yy.size()) {
            if (!xy[xx[i]].count(yy[j])) {
                ans++;
                flg = true;
                break;
            }
        }
        if (flg) break;
    }

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

ll a[mx], b[mx];
int main() {
    FIO;
    ll n, m, k;
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
     for (ll i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    ll ans = 0;

    for (ll i = 1; i <= n; i++) {
        ll tmp = i;
        if(k < a[i]) {
            break;
        }
        ll rt = k - a[i];
        auto g = upper_bound(b+1, b+m+1, rt);
        ll p = g - (b+1);
        tmp += p;
        ans = max(ans, tmp);
    }

    for (ll i = 1; i <= m; i++) {
        ll tmp = i;
        if(k < b[i]) {
            break;
        }
        ll rt = k - b[i];
        auto g = upper_bound(a+1, a+n+1, rt);
        ll p = g - (a+1);
        tmp += p;
        ans = max(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6716
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/01/26.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;


	ll h,a;
	cin >> h >> a;

	ans = h / a;
	
	if ((h % a) != 0) {
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string a, b; readV(a, b);
  writeln(a == b ? "H" : "D");
}


Measured memory_bytes: 256
n,m = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors
ans = 1
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
print(ans)

Measured memory_bytes: 38640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int>x(N);
	rep(i, N) {
		cin >> x[i];
	}
	vector<int>y(M);
	rep(i, M) {
		cin >> y[i];
	}
	sort(x);
	sort(y);
	int L = max(X, x[N - 1]);
	int R = min(Y, y[0]);
	if (L < R) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

void north (int *d) {
    int tmp;

    tmp=d[0];
    d[0]=d[1];
    d[1]=d[5];
    d[5]=d[4];
    d[4]=tmp;
}

void east (int *d) {
    int tmp;

    tmp=d[0];
    d[0]=d[3];
    d[3]=d[5];
    d[5]=d[2];
    d[2]=tmp;
}

void curl (int *d) {
    int tmp;

    tmp=d[1];
    d[1]=d[2];
    d[2]=d[4];
    d[4]=d[3];
    d[3]=tmp;
}

int compare(int *d1, int *d2) {
    int i=0, n=0;

    for (i=0;i<6;i++) {
        if (d1[i]==d2[i]) n++;
    }
    return n;
}

int process(int *d1, int *d2) {
    int i, j, n=0;

    for (i=0;i<6;i++) {
        for (j=0;j<6;j++) {
            if (d1[i]==d2[j]) n++;
        }
    }
    if (n<6) {
        return 0;
    }
    while (d1[0]!=d2[0]) {
        north(d2);
        if (d1[0]==d2[0]) {
            break;
        } else {
            east(d2);
        }
    }
    n=0;
    i=0;
    j=1;
    while (d1[j]!=d2[j]) {
        if (i>3) j++, i=0;
        curl(d2);
        i++;
    }
    for (i=0;i<7;i++) {
        n=compare(d1, d2);
        if (n==6) break;
        north(d2);
        n=compare(d1, d2);
        if (n==6) break;
        east(d2);
        n=compare(d1, d2);
        if (n==6) break;
    }

    if (n==6) {
        return 1;
    } else {
        return 0;
    }
}



int main(void) {
    int dice[100][6];
    int i, j, n=0, num;

    scanf("%d", &num);
    for (i=0; i<num; i++) {
        scanf("%d %d %d %d %d %d",
            &dice[i][0], &dice[i][1], &dice[i][2],
            &dice[i][3], &dice[i][4], &dice[i][5]);
    }

    for (i=0;i<num;i++) {
        for (j=i+1;j<num;j++) {
            n=process(dice[i], dice[j]);
            if (n==1) {
                printf("No\n");
                return 0;
            }
        }
    }

    printf("Yes\n");

    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
typedef unsigned long long ull;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF

#define V_MAX 100000

int main()
{
  ull i,j,N,W,w,v;
  cin >> N >> W;
  vector<vector<ull>> dp;
  dp.resize(N);
  for(i=0;i<N;++i)
  {
    dp[i].resize(V_MAX+1,INF);
  }
  cin >> w >> v;
  //dp[i][v]:iまでの品を選んで価値vになる組み合わせのうち最小の重さ
  dp[0][0]=0;
  dp[0][v]=w;
  for(i=1;i<N;++i)
  {
    cin >> w >> v;
    for(j=0;j<v;++j)
    {
      dp[i][j]=dp[i-1][j];
    }
    for(j=v;j<=V_MAX;++j)
    {
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w);
    }
  }
  for(j=V_MAX;j>0;--j)
  {
    if(dp[N-1][j]<=W)
    {
      cout << j;
      return 0;
    }
  }
  cout << 0;
  return 0;
}

Measured memory_bytes: 78592
#include <iostream>

using namespace std;

int main()
{
    int c[3][3]={0},a[3]={0},b[3]={0},flag=1;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin >> c[i][j];
    for(int i=0;i<=100;i++)     //枚举
    {
        a[0]=i;
        b[0]=c[0][0]-i;
        b[1]=c[0][1]-i;
        b[2]=c[0][2]-i;
        a[1]=c[1][0]-b[0];
        a[2]=c[2][0]-b[0];
        for(int j=0;j<3;j++)    //验证
        {
            for(int k=0;k<3;k++)
            {
                if(a[j]+b[k]!=c[j][k])
                {
                    flag=0;
                    continue;
                }
            }
        }
        if(flag==1)
        {
            cout << "Yes" << endl;
            return 0;
        }
        flag=1;
    }
    cout << "No" << endl;   //枚举完了，未找到合适解;
    return 0;
}


Measured memory_bytes: 256