akhauriyash/Code-Regression huggingface dataset:
program main
    implicit none
    character n*3
    integer i
    read(*,*) n
    i = len_trim(n)

    if (n(i:i) == "0") then
        write(*,*) "pon"
    else if (n(i:i) == "1") then
        write(*,*) "pon"
    else if (n(i:i) == "2") then
        write(*,*) "hon"
    else if (n(i:i) == "3") then
        write(*,*) "bon"
    else if (n(i:i) == "4") then
        write(*,*) "hon"
    else if (n(i:i) == "5") then
        write(*,*) "hon"
    else if (n(i:i) == "6") then
        write(*,*) "pon"
    else if (n(i:i) == "7") then
        write(*,*) "hon"
    else if (n(i:i) == "8") then
        write(*,*) "pon"
    else if (n(i:i) == "9") then
        write(*,*) "hon"
    end if

end program

Measured memory_bytes: 2856
import numpy as np
import math


N=int(input())
X_s = list(map(int,input().split()))

X_s = np.array(X_s)
P=np.sum(X_s)/N

P_floor = math.floor(P)
P_ceil = math.ceil(P)

A=np.sum((X_s-P_floor)**2)
B=np.sum((X_s-P_ceil)**2)

print(min(A,B))

Measured memory_bytes: 12504
import math
N, K =map(int,input().split())

ans = 0

for i in range(1, min(N+1,K)):
  omote = math.ceil(math.log2(K/i))
  ans = ans + (0.5**omote)/N

if(N >= K):
  ans = ans + (1- (K-1)/N)

print(ans)

Measured memory_bytes: 3060
N = int(input())
P = tuple(map(int, input().split()))
Q= tuple(map(int, input().split()))
L = []
for i in range(1,N+1):
    L.append(i)
import itertools
A = list(itertools.permutations(L,N))
for i in range(len(A)):
    if P == A[i]:
        a = i+1
    if Q == A[i]:
        b = i+1
print(abs(a-b))

Measured memory_bytes: 8052
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
ll n;

void solve() {
  cin>>n;
  vector<ll> anss(n,0);
  rep(i,0,n-1)
  {
    int in=0;cin>>in;
    anss[in-1]++;
  }

  rep(i,0,n) print(anss[i]);

  return;
}


Measured memory_bytes: 4720
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

sys.setrecursionlimit(10**9)


n,k = map(int, input().split())
G = [[] for i in range(n)]
edges = []
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)
    G[b].append(a)
    edges.append((a,b))

cnt = [0]
def search(cur, prev, depth, k):
    if depth > k:
        cnt[0] += 1
    for to in G[cur]:
        if to != prev:
            search(to, cur, depth+1, k)


ans = float("inf")
# 点中心
if k % 2 == 0:
    for i in range(n):
        cnt = [0]
        search(i, -1, 0, k//2)
        ans = min(ans, cnt[0])
# 辺中心
else:
    for a, b in edges:
        cnt = [0]
        search(a, b, 0, k//2)
        search(b, a, 0, k//2)
        ans = min(ans, cnt[0])

print(ans)

Measured memory_bytes: 226824
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int a[100005];
int N;
int main()
{
	while(cin>>N)
	{
		for(int i=0;i<N;i++)
		scanf("%d",&a[i]);
		sort(a,a+N);
		long long ans=0;
		long long sum1=0,sum2=0,sum3=0;
		if(N&1)
		{
			for(int i=0;i<N/2;i++)
			sum1+=a[i];
			for(int i=N/2+1;i<N;i++)
			sum2+=a[i];
			sum3=max(a[N/2-1]-a[N/2],a[N/2]-a[N/2+1]);
			ans=2*sum2-2*sum1+sum3;
		}
		else
		{
			for(int i=0;i<N/2;i++)
			sum1+=a[i];
			for(int i=N/2;i<N;i++)
			sum2+=a[i];
			sum3=a[N/2-1]-a[N/2];
			ans=2*sum2-2*sum1+sum3;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string.h>

using namespace std;
typedef long long int ll;

int main(){

    int N;
    cin >> N;
    string name[N];
    ll q[5];
    memset(q, 0, sizeof(q));
    for(int i=0; i<N; i++){
        cin >> name[i];
        char first = name[i][0];
        if(first == 'M'){
            q[0] ++;
        }else if(first == 'A'){
            q[1] ++;
        }else if(first == 'R'){
            q[2] ++;
        }else if(first == 'C'){
            q[3] ++;
        }else if(first == 'H'){
            q[4] ++;
        }
    }

    ll total = 0;
    total = q[0] * q[1] * q[2] + q[0] * q[1] * q[3] + q[0] * q[1] * q[4] + q[0] * q[2] * q[3] + q[0] * q[2] * q[4] + q[0] * q[3] * q[4] + q[1] * q[2] * q[3] + q[1] * q[2] * q[4] + q[1] * q[3] * q[4] + q[2] * q[3] * q[4];
    

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define size(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using namespace std;


int N, M, p;
int d[10010];


int solve() {
	sort(&d[0], &d[M]);
	int ans = min(d[M-1]*100, (N-d[0])*100);
	rep(i, 0, M-1)
		ans = min(ans, d[i]*200+(N-d[i+1])*100);
	repr(i, M-1, 0)
		ans = min(ans, (N-d[i])*200+d[i-1]*100);
	return ans;
}


int main() {
	cin >> N >> M >> p;
	rep(i, 0, M) cin >> d[i], d[i] -= p, (d[i] < 0 ? d[i]+=N : 0);

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int a,b;
  cin >> a >> b;
  if(a+b==15) {
    cout << "+" << endl;
    return 0;
  }
  if(a*b==15) {
    cout << "*" << endl;
    return 0;
  }
  cout << "x" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i < h; i++) {
            String a = sc.nextLine();
            System.out.println(a);
            System.out.println(a);
        }
    }
}

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


int main() {
    int K;
   while(cin >> K){
    if (K == 0){
        break;
    }
    else{
         int m=0 ;
    for(int i=0;i<K*(K-1)/2;++i){
        int c;
        cin >> c;
        m += c;
    }  
    int r;
    r = m/(K-1);
    cout << r << endl;
    } 
  
   }
   
    return 0;
}


Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = (a); i < (b); i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int k;
	cin>>k;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != s[k-1]) s[i] = '*';
	}
	cout<<s<<"\n";
	
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int maxn=105;
const int maxx=1e5+5;
int w[maxn],v[maxn];
long long dp[maxx][maxn];
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		for(int i=1;i<=n;++i)
		 cin>>w[i]>>v[i];
		for(int i=1;i<=n;++i) 
		{
			for(int j=0;j<=m;++j)
			{
				if(j-w[i]>=0)
				  dp[j][i]=max(dp[j][i-1],dp[j-w[i]][i-1]+v[i]);
				else
				  dp[j][i]=dp[j][i-1];
			}
		}
		cout<<dp[m][n]<<endl;
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    
    int win = 0;
    for (int i = 0; i < s.size(); i++) {
        char c = s.at(i);
        if (c == 'o')
            win++;

    }
    win = win + (15 - s.size());

    cout << ((win >= 8) ? "YES" : "NO") << endl;
}

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

using namespace std;

typedef long long ll;

string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
	int n,k;cin>>n>>k;
	int p[n];REP(i,n)cin>>p[i];
	sort(p,p+n);
	int sum=0;
	REP(i,k)sum+=p[i];
	cout<<sum<<endl;
}

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

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
#include <time.h>
using namespace std;
int main() {
	long long int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long int cnt = 0, b = 0;
	for (int i = 0; i >= 0; i++) {
		cnt++;
		if (cnt >= n) {
			cout << -1 << endl;
			return 0;
		}
		if (a[b] == 2) {
			cout << cnt << endl;
			return 0;
		}
		else {
			b = a[b]-1; 
		}
	}
}

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

#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)

int main() {
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;

	vector<int> t2;
	REP(i, n) {
		if (t[i] == 'r') t2.push_back(2);
		if (t[i] == 's') t2.push_back(0);
		if (t[i] == 'p') t2.push_back(1);
	}

	int sc[3] = { r, s, p };

	int score = 0;
	REP(i, n) {
		score += sc[t2[i]];
	}

	REP(i, n - k) {
		if (t2[i] == t2[i + k]) {
			if (sc[t2[i]] < sc[t2[i + k]]) {
				score -= sc[t2[i]];
			}
			else {
				score -= sc[t2[i + k]];
				if (i + k * 2 < n) {
					t2[i + k] = 3;
				}
			}
		}
	}
	cout << score;
	return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> h(N), l;
    REP(i, N) cin >> h[i];
    l = h;
    sort(l.begin(), l.end());
    int maxH = l[N-1];

    int ans = 0;
    for (int a = 0; a < maxH; a++) {
        int cnt = 0;
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            if (h[i] > 0) {
                h[i]--;
                tmp++;
            } else {
                if (tmp > 0) {
                    cnt++;
                }
                tmp = 0;
            }
        }
        if (tmp > 0) cnt++;
        ans += cnt; 
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n1,n2,n3,n4; cin >> n1 >> n2 >> n3 >> n4;
	bool flg[4] = {false};
	int nums[4] = {1,9,7,4};
	rep(i,4){
		if(n1==nums[i] || n2==nums[i] || n3==nums[i] || n4==nums[i] ) flg[i] = true;		
	}
	if(flg[0]&&flg[1]&&flg[2]&&flg[3]) out("YES");
	else out("NO");

}




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

#define ll long long
#define f(i,a,n) for (int i=a;i<n;i++)
typedef pair<ll, ll> pa;
const ll mod=1000000007;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n - 1; i++) {
        ll b;
        cin >> b;
        if (i == 0) {
            a[0] = b, a[1] = b;
            continue;
        }
        a[i] = min(a[i], b);
        a[i + 1] = b;
    }
    cout << accumulate(a.begin(), a.end(), 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
long comb(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
using namespace std;
int main(){
  int n;long long k;
  std::cin >> n>>k;
  std::vector<long long> a(n);
  rep(i,n)std::cin >> a[i];
  sort(a.begin(),a.end());
  ll inf=1e18;
  ll R=inf; ll L=-inf;ll x=2;
  while(L+1<R){
      x=(R+L)/2;
      ll k_x=0;
      rep(i,n){
          int l=-1;int r=n;int c;
          if(a[i]>=0){
              while(l+1<r){
                  c=(r+l)/2;
                  if(a[i]*a[c]<x)l=(r+l)/2;else r=(r+l)/2;
              }
              k_x+=r;
          }
          else{
              while(l+1<r){
                  c=(r+l)/2;
                  if(a[i]*a[c]<x)r=(r+l)/2;else l=(r+l)/2;
              }
              k_x+=n-r;
          }
          if(a[i]*a[i]<x)k_x--;
      }
      k_x/=2;
      if(k_x<k)L=x;else R=x; 
  }
   std::cout << L<< std::endl; 
  
  
  
}



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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int> > left, right;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        int add=0, maxdiff=0;
        for(int j=0; j<(int)s.length(); j++){
            if(s[j]=='(') add++;
            else add--;
            maxdiff = max(maxdiff, -add);
        }
        if(add >= 0){
            left.push_back(make_pair(maxdiff, add));
        }else{
            int add=0, maxdiff=0;
            for(int j=s.length()-1; j>=0; j--){
                if(s[j]==')') add++;
                else add--;
                maxdiff = max(maxdiff, -add);
            }
            right.push_back(make_pair(maxdiff, add));
        }
    }
    sort(left.begin(), left.end());
    sort(right.begin(), right.end());

    int depthl=0;
    bool success = true;
    for(int i=0; i<(int)left.size(); i++){
        if(left[i].first > depthl) success = false;
        depthl += left[i].second;
    }
    int depthr=0;
    for(int i=0; i<(int)right.size(); i++){
        if(right[i].first > depthr) success = false;
        depthr += right[i].second;
    }
    if(depthl != depthr) success = false;
    if(success){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 11164
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
static const ll INF=1000000000000000;
struct edge{ ll to,cost;};
ll V,E,s,t;
ll d[100005];
ll d1[100005];
vector<vector<edge>>G(100005);
vector<vector<edge>>G1(100005);
void dijkstra(ll s){
fill(d,d+V,INF);d[s]=0;
  priority_queue<P,vector<P>,greater<P>>que;que.push(P(0,s));
  while(!que.empty()){
  P p=que.top();que.pop();
    ll v=p.second;
    if(d[v]<p.first)
      continue;
    for(auto e:G[v]){
    if(d[v]+e.cost<d[e.to]){
    d[e.to]=d[v]+e.cost;
      que.push(P(d[e.to],e.to));
     }
     }
  }
}
void dijkstra1(ll s){
fill(d1,d1+V,INF);d1[s]=0;
  priority_queue<P,vector<P>,greater<P>>que;que.push(P(0,s));
  while(!que.empty()){
  P p=que.top();que.pop();
    ll v=p.second;
    if(d1[v]<p.first)
      continue;
    for(auto e:G1[v]){
    if(d1[v]+e.cost<d1[e.to]){
    d1[e.to]=d1[v]+e.cost;
      que.push(P(d1[e.to],e.to));
     }
     }
  }
}
int main(){
  cin>>V>>E>>s>>t;s--;t--;
  for(ll i=0;i<E;i++){
  ll u,v,a,b;cin>>u>>v>>a>>b;u--;v--;
    edge e;e.to=v;e.cost=a;
    edge e1;e1.to=u;e1.cost=a;
    edge e2;e2.to=v;e2.cost=b;
    edge e3;e3.to=u;e3.cost=b;
  G[u].push_back(e);
    G[v].push_back(e1);
    G1[u].push_back(e2);
    G1[v].push_back(e3);
   }dijkstra(s);dijkstra1(t);
  priority_queue<ll,vector<ll>,greater<ll>>que;
  vector<ll>D(V);ll Min=INF;
  for(ll i=V-1;0<=i;i--){
  if(d[i]+d1[i]<Min)Min=d[i]+d1[i];
    D[i]=INF-Min;
  }for(ll i=0;i<V;i++)
    cout<<D[i]<<endl;
  return 0;
}

Measured memory_bytes: 21036
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
typedef pair<ll,ll> i_i;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int H,W,m,h,w,maxh=0,maxw=0;
  cin >> H>>W>>m;
  vector<int> hc(H),wc(W),hi,wi;
  set<i_i> st;
  rep(i,m){
    cin >> h>>w;
    h--;w--;
    hc[h]++;
    wc[w]++;
    st.insert({h,w});
  }
  rep(i,H){
    if(chmax(maxh, hc[i])){
      hi={};
      hi.push_back(i);
    }else if(maxh==hc[i]){
      hi.push_back(i);
    }
  }
  rep(i, W){
    if(chmax(maxw, wc[i])){
      wi={};
      wi.push_back(i);
    }else if(maxw==wc[i]){
      wi.push_back(i);
    }
  }
  rep(i, hi.size())rep(j,wi.size()){
    if(!st.count({hi[i],wi[j]})){
      cout << maxh+maxw << endl;
      return 0;
    }
  }
  cout << maxh+maxw-1 << endl;


  return 0;
}


Measured memory_bytes: 28560
var a=[""];
a[1]="',.,!?".split("");
a[2]="abcABC".split("");
a[3]="defDEF".split("");
a[4]="ghiGHI".split("");
a[5]="jklJKL".split("");
a[6]="mnoMNO".split("");
a[7]="pqrsPQRS".split("");
a[8]="tuvTUV".split("");
a[9]="wxyzWXYZ".split("");

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.forEach(function(v){
   v=v.replace(/0+|1+|2+|3+|4+|5+|6+|7+|8+|9+/g,function(x){
      if(x[0]=="0")return x.slice(1).replace(/0/g," ");
      else return a[x[0]-0][x.length-1];
   });
   console.log(v);
});

Measured memory_bytes: 15724
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();

		if(x > 0 && y > 0){
			if((W >= r + x) && (H >= r + y)){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l[i];
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      for(int k=j+1; k<N; k++){
        if(l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
        if(l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) ans ++;
        
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<"is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	ll n,a,i,minn=LONG_LONG_MAX,sum=0,mc=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		if(a<0) mc++;
		minn=min(minn,abs(a));
		sum += abs(a);
	}
	if(mc%2)
	cout<<sum-2*minn;
	else
	cout<<sum;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

v = 1
s = [-1] * (n+1)
d = []
l = 0
c = 0

while s[v] == -1:
  s[v] = len(d)
  d.append(v)
  v = a[v-1]
l = s[v]
c = len(d) - s[v]

if k < l:
  print(d[k])
else:
  k -= l
  k %= c
  print(d[l+k])


Measured memory_bytes: 94676
n = int(input())
s = "abcdefghij"

class Node:
    __slots__ = ["string", "index"]
    def __init__(self, string, index):
        self.string = string
        self.index = index

    def get_children(self):
        parent = self.string
        out = [None]*(self.index+2)
        for i, c in enumerate(s[:self.index+1], 1):
            out[i] = Node(parent+c, max(i, self.index))
        return out[1:]

root = Node("a", 1)
children = [root]
for _ in range(n-1):
    parents, children = children, []
    for parent in parents:
        children.extend(parent.get_children())
for child in children:
    print(child.string)

Measured memory_bytes: 21824
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    ll d=a*a + b*b + c*c -2*(a*b + a*c + b*c);
    if(c-a-b<=0)
     {
         cout<<"No";
         return 0;
     }
    if(d>0)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	string S;
	cin >> S;
	if(S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}	
}

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

int main() {
	int A, B, K;
	cin >> A >> B >> K;

	for (int i = min(A, B); i >= 1; i--) {
		if (A % i == 0 && B % i == 0) {
			K--;
			if (K == 0) {
				cout << i << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main() {
	ios;
	ll k,n,m=-1,a,b,i,c;
	cin>>k>>n;
	cin>>b;
	c=b;
	for(i=1;i<n;i++)
	{
		cin>>a;
		m=max(a-b,m);
		b=a;
	}
	// cout<<m<<" "<<k-a-c;
	m=max(m,k-a+c);
	cout<<k-m;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << max(a * b, c * d) << endl;


  
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

n, m = map(int,input().split())
cnt = [0] * n
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1

for i in cnt:
    print(i)

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n,k;

int main(){
  cin>>n>>k;
  int ans=0;
  while(n>0){
    n/=k;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

auto input(size_t n) {
    return InputType2(n);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t n = input();
    vector<size_t> a = input(n);
    vector<size_t> b = input(n);
    vector<size_t> c = input(n);
    sort(begin(a), end(a));
    sort(begin(b), end(b));
    sort(begin(c), end(c));
    size_t res = 0;
    for (size_t i = 0; i < b.size(); ++i) {
        auto e = b[i];
        auto it1 = lower_bound(begin(a), end(a), e);
        auto it2 = upper_bound(begin(c), end(c), e);
        if (it2 != end(c)) {
            auto d = size_t(distance(begin(a), it1));
            auto f = size_t(distance(it2, end(c)));
            res += d * f;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    ll a,b,n; 
    cin>>a>>b>>n;
    ll x;
    if(n<b) x=n;
    else x=b-1;
    cout<<a*x/b<<endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MAX_N = 1e5 + 10;
const ll MOD = 1e9+7;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}
void init(){
    Inv_init();
    fact_init();
}
ll solve(){
    init();
    
    ll res = 0;
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    vector<ll> cusum(N+1);
    cusum[0] = Inv[0];
    for(int i = 1; i <= N;i++) cusum[i] = (cusum[i-1] + Inv[i])%MOD;
    
    vector<ll> P(N);
    for(int i = 0; i < N;i++){
        P[i] = (cusum[i+1] + cusum[N-i] - 1 + MOD)%MOD;
    }
    for(int i = 0;i  < N;i++){
        (res += A[i]*P[i])%=MOD;
    }
    (res *= fact[N])%=MOD;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

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

vector<int> S[1000];

signed main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
        return 0;
    }
    int k = 0;
    for (int i = 1; i <= 1000; ++i) {
        if (N == i * (i + 1) / 2) {
            cout << "Yes" << endl;
            k = i + 1;
            break;
        }
    }
    if (k == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << k << endl;
    int a = 1;
    rep(i, k) {
        for (int j = i + 1; j < k; ++j) {
            S[i].push_back(a);
            S[j].push_back(a);
            a++;
        }
    }
    rep(i, k) {
        cout << k - 1;
        for (int s:S[i]) {
            cout << " " << s;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#[allow(unused_imports)]
use std::io::Write;

// {{{
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// }}}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut count = 0;
    for ai in a.iter() {
        if *ai == count + 1 {
            count += 1;
        }
    }

    if count == 0 {
        println!("{}", -1);
    } else {
        println!("{}", n - count);
    }
}


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

using namespace std;


int main(){
	int n,m;
	int ac=0,pe=0;
	pair<int,int> temp;
	temp.first = 1;
	temp.second = 1;
	
	cin >> n >> m;
	
	vector<pair<int,string>> v(m);
	vector<pair<int,int>> a(n+1);
	
	for(int i=1;i<n+1;i++){
		a[i] = make_pair(0,1);
	}
	
	for(int i=0;i<m;i++){
		cin >> v[i].first >> v[i].second;
		if(a[v[i].first].second == 1 && v[i].second == "WA")a[v[i].first].first++;
		
		if(a[v[i].first].second == 1 && v[i].second == "AC"){
			a[v[i].first].second = 0;
			ac++;
		}
	}
	
	for(int i=1;i<n+1;i++){
		if(a[i].second == 0 ) pe += a[i].first;
	}
	
	cout << ac << ' ' << pe << endl;
	
	
	
	return 0; 
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int a, b, n;
    cin >> a >> b >> n;
    int x = min(b - 1, n);

    cout << int((a * x / b) - a * (x / b)) << '\n';
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;  // 階乗と階乗の逆元
  combination(int n):fact(n+1),ifact(n+1) {  // 階乗と階乗の逆元を n まで求める
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

  ll n, k;
  cin >> n >> k;

  combination comb(n+k-1);
  mint ans = comb(n+k-1, n);

  cout << ans.x << endl;

  return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename Edge>
vector<Edge> make_v(size_t a, Edge b) {
    return vector<Edge>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

#include <queue>
#include <tuple>
using Edge = tuple<int, int, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, l;
    while (cin >> n >> m >> l, n + m + l) {
        vector<vector<Edge>> Graph(n);
        REP(i, 0, m) {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            Graph[a - 1].emplace_back(b - 1, d, e);
            Graph[b - 1].emplace_back(a - 1, d, e);
        }
        const ll inf = 1LL << 60;
        auto cost = make_v(n, l + 1, inf);
        priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
        // cost, to, remains
        pq.emplace(0, 0, l);
        while (pq.size()) {
            int c, to, pr;
            tie(c, to, pr) = pq.top();
            pq.pop();
            if (cost[to][pr] < c) continue;
            cost[to][pr] = c;
            for (Edge &t : Graph[to]) {
                int nto, dist, e;
                tie(nto, dist, e) = t;
                if (pr >= dist && cost[nto][pr - dist] > c) {
                    cost[nto][pr - dist] = c;
                    pq.emplace(c, nto, pr - dist);
                }
                if (cost[nto][pr] > c + e) {
                    cost[nto][pr] = c + e;
                    pq.emplace(c + e, nto, pr);
                }
            }
        }
        ll ans = inf;
        REP(i, 0, l + 1) {
            ans = min(ans, cost[n - 1][i]);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3468
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
using namespace std;

typedef struct Edge_s
{
    int to;
    int index;
} Edge;

int N;
int max_color = -1;
map<int, vector<Edge>> edges;
vector<int> answer;

void color_edges(int used_num, int vindex, int parent)
{
    int not_used_smallest_num = 1;
    for (int i = 0; i < edges[vindex].size(); i++)
    {
        if (edges[vindex][i].to == parent)
            continue;
        if (not_used_smallest_num == used_num)
            not_used_smallest_num++;
        answer[edges[vindex][i].index] = not_used_smallest_num;
        color_edges(not_used_smallest_num, edges[vindex][i].to, vindex);
        max_color = max(not_used_smallest_num, max_color);
        not_used_smallest_num++;
    }
}

int main()
{
    cin >> N;
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        edges[a - 1].push_back(Edge{b - 1, i});
        edges[b - 1].push_back(Edge{a - 1, i});
        answer.push_back(-1);
    }
    color_edges(-1, 0, -1);
    cout << max_color << endl;
    for (int i = 0; i < answer.size(); i++)
    {
        cout << answer[i] << endl;
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	cout<<(A+B)%24<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

typedef pair<string,int> P;

string change(string L,string R,int len){
  stringstream LL(L),RR(R),T;
  int l,r,t;

  LL >> l; RR >> r;
  t = l - r;
  T << t;

  string tmp,res = "";
  T >> tmp;
  
  for(int i = (int)tmp.size() ; i < len ; i++){
    res += "0";
  }
  res += tmp;
  return res;
}

int main(){
  int L;
  string a;

  while(cin >> a >> L){
    if(a == "0" && L == 0) break;

    vector<P> v;
    int cnt = 1;
    v.push_back(P(a,0));

    if((int)a.size() != L){
      for(int i = (int)a.size() ; i < L ; i++){
	a += "0";
      }
    }

    while(true){
      sort(a.begin(),a.end());
      string b = a;
      reverse(a.begin(),a.end());
      string c = a;
      a = change(c,b,L);
      
      if(cnt){
	for(int i = 0 ; i < (int)v.size() ; i++){
	  if(v[i].first == a){
	    string d = "";
	    int j;
 
	    for(j = 0 ; j < (int)a.size() ; j++){
	      if(a[j] == '0') continue;
	      else break;
	    }
	    for(int k = j ; k < (int)a.size() ; k++){
	      d += a[k];
	    }
	    if(d == "") d += "0";
	    a = d;
	    cout << v[i].second << " " << d << " " 
		 << (cnt - v[i].second) << endl;
	    goto end;
	  }
	}
      }

      v.push_back(P(a,cnt));
      cnt++;
    }
  end:;
  }

  return 0;
}

Measured memory_bytes: 1260
#include<stdio.h>
 
int main(){
 
int n,input,max=0,min=0,i;
long sum=0;
 
scanf("%d",&n);
 
if(n==0){
 printf("undefined\n");
}else{
for(i=0;i<n;i++){
 scanf("%d",&input);
 if(i==0){
  min = input;
  max = input;
  sum = input;
 }else{
  if(max < input) max=input;
  if(input < min) min=input;
  sum += input;
 }
}
 
printf("%d %d %ld\n",min,max,sum);
}
return 0;
 
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索
// 偶奇，逆から，ソート，出現回数，DP
// 存在判定：構成方法，入力の特徴
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N, M; cin >> N >> M;
VI a(M); 
vector<bool> ab(N + 1, false);
rep(i, 0, M) {
    cin >> a[i];
    ab[a[i]] = true;
}

vector<int64_t> dp(N + 1, 0);
dp[0] = 1;
if (!ab[1]) dp[1] = 1;

rep(i, 2, N+1){
    if (ab[i]) continue;
    dp[i] += (dp[i - 1] + dp[i - 2]) % MOD;
}

cout << dp[N] % MOD << "\n";  

}

// 境界，出力文字列 チェック



Measured memory_bytes: 1408
/*à¥à¥*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* â€œStrength is the only thing that matters in this world. Everything else is just a delusion for the weak.â€ â€“ Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 



ll A,B;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>A>>B;
  set<ll> num;
  num.insert(1) ; num.insert(2) ; num.insert(3);

  num.erase(A); num.erase(B);
  cout<<*num.begin()<<'\n';
}



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

  return 0;
}

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

int main()
{
    string S = "";
    cin >> S;
    char c1 = S[2];
    char c2 = S[3];
    char c3 = S[4];
    char c4 = S[5];

    if ((c1 == c2) && (c3 == c4)) cout << "Yes";
        else cout << "No";

    return 0;

}

Measured memory_bytes: 764