akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define N 1e5
#define M 1e9

typedef struct{
  char c;
  int e;
}card;

void merge(card*, int, int, int);
void mergesort(card*, int, int);
void quicksort(card*, int, int);
int partition(card*, int, int);
int isstable(card*, card*, int);

void merge(card A[], int left, int mid, int right){
  int i, j, k, n1=mid-left, n2=right-mid;
  card L[n1+1], R[n2+1];

  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1].e=M; R[n2].e=M;

  for(i=0,j=0,k=left;k<right;k++){
    if(L[i].e<=R[j].e){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }return ;
}

void mergesort(card A[], int left, int right){
  if(left+1<right){
    int mid=(left+right)/2;

    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }return;
}

void quicksort(card *A, int p, int r){

    if(p<r){
        int q=partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }return;
}

int partition(card *A, int p, int r){

  int x=A[r].e, i=p-1, j;
  card tmp;

  for(j=p;j<r;j++){
      if(A[j].e<=x){
      i++;
      tmp=A[i]; A[i]=A[j]; A[j]=tmp;
    }
  }tmp=A[i+1]; A[i+1]=A[r]; A[r]=tmp;
  return i+1;
}

int isstable(card *A, card *B, int n){
    for(int i=0;i<n;i++){
        if(A[i].c!=B[i].c) return 0;
    }return 1;
}

int main(){
  int i, j, n;
  card *t, *a, *b;
  t = (card *)malloc(sizeof(card)*N);
  a = (card *)malloc(sizeof(card)*N);
  b = (card *)malloc(sizeof(card)*N);

  scanf("%d", &n);

  for(i=0;i<n;i++) scanf("%*c%c%d", &t[i].c, &t[i].e);

  for(i=0;i<n;i++){
    a[i]=t[i];
    b[i]=t[i];
  }

  quicksort(a,0,n-1);
  mergesort(b,0,n);

  if(isstable(a,b,n)==1) printf("Stable\n");
  else printf("Not stable\n"); 

  for(i=0;i<n;i++) printf("%c %d\n",a[i].c,a[i].e);

  return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if (H%h==0 && W%w==0) {
		cout<<"No\n"<<endl;
		return 0;
	}
	
	cout<<"Yes\n";
	
	const int T=502;
	rep(i,0,H) rep(j,0,W) {
		if (H%h!=0) {
			if (i%h==0) {
				cout<<T*(h-1)-1;
			} else {
				cout<<-T;
			}
		} else {
			if (j%w==0) {
				cout<<T*(w-1)-1;
			} else {
				cout<<-T;
			}
		}
		cout<<" \n"[j+1==W];
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	while(true){
		int a,b,c; cin>>a>>b>>c;
		if(a==-1 && b==-1 && c==-1)return 0;
		int ans=0;
		int cnt=0;
		if(a!=-1)ans+=a;
		else cnt++;
		if(b!=-1)ans+=b;
		else cnt++;
		if(cnt)cout<<'F'<<endl;
		else if(ans>=80)cout<<'A'<<endl;
		else if(ans>=65)cout<<'B'<<endl;
		else if(ans>=50)cout<<'C'<<endl;
		else if(ans>=30){
			if(c>=50)cout<<'C'<<endl;
			else cout<<'D'<<endl;
		}
		else cout<<'F'<<endl;
	}

	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    int L, R, d; cin >> L >> R >> d;
    int cnt = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) cnt++;
    }
    PRINT(cnt);
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
    int n[1000],x[1000];
    int z=0;
    int i,j,k,l,m;

    for(i=0;;i++){
    scanf("%d %d",&n[i],&x[i]);
    if( 0==n[i] && 0==x[i] ){
        break;
        }
    }

    for(m=0; m<i ;m++){
        for(j=1; j<=n[m]-2 ;j++){
            for(k=j+1; k<=n[m]-1 ;k++){
                for(l=k+1; l<=n[m] ;l++){
                    if( (j+k+l)==x[m] ){
                        z++;
                    }
                }
            }
        }
        printf("%d\n",z);
        z=0;
    }



    return 0;
}


Measured memory_bytes: 2104
// Tue Jun 30 14:06:52 IST 2020  
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()

const double pi = 3.141592653589793238;
using namespace  std ;       
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 3e5+7; 
const int INF = INT_MAX;
struct comp{
    bool operator()(const pair<int,int> A,const pair<int,int>& B)const{
        if(A.first == B.first)
            return A.second < B.second ;
        return A.first > B.first;
    } 
};    
int tests(){
    int n;
    cin >> n;
    if(n%1000 == 0)
        return cout << 0 << '\n',0;
    cout << 1000-n%1000 << '\n';
    return 0;
}
int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;  
    while(cases--) 
        tests(); 
     
    return 0 ; 
}

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

using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif
#define rep(i,n) for (int i = 0; i < (n); ++i)

#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    cout << (n * (n-1) + m * (m-1)) / 2 << endl;
    return 0;
}


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

N = int(input())
S = list(input().rstrip())
ord_a = ord("a")

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

bits = [Bit(N) for _ in range(26)]

for i in range(N):
    s = S[i]
    bits[ord(s) - ord_a].add(i + 1, 1)

Q = int(input())

for _ in range(Q):
    query = input().rstrip().split()
    if query[0] == "1":
        i, c = int(query[1]), query[2]
        bits[ord(S[i - 1]) - ord_a].add(i, -1)
        S[i - 1] = c
        bits[ord(S[i - 1]) - ord_a].add(i, 1)
    else:
        l, r = int(query[1]), int(query[2])
        res = 0
        for bit in bits:
            if l != 1:
                res += int(bit.sum(r) - bit.sum(l - 1) > 0)
            else:
                res += int(bit.sum(r) > 0)
        print(res)

Measured memory_bytes: 167068
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int G[100][100];
int inf = 123123123;
bool warshallfloyd(int v){
  int i, j, k;
  rep(k, v)rep(i, v)rep(j, v)if(G[i][k] != inf && G[k][j] != inf && G[i][j] > G[i][k] + G[k][j])G[i][j] = G[i][k] + G[k][j];
  rep(i, v)if(G[i][i] < 0)return false;
  return true;
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    rep(i, n)rep(j, n)G[i][j] = inf;
    rep(i, n){
      int2(r, k); --r;
      rep(j, k){
        int(t); --t;
        G[r][t] = 1;
      }
    }
    warshallfloyd(n);

    int(p);
    for(;p--;){
      int3(s, d, v);
      --s; --d;
      if(G[s][d] < v)printf("%d\n", G[s][d] + 1);
      else puts("NA");
    }

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=2E5+77;
const int INF=(1<<30)+100;

int A[maxn],B[maxn],N,X,Mask;

bool cmp(int a,int b){ 
        return (a&Mask)<(b&Mask);
}

int count(int l,int r){ 
        int p1=lower_bound(B,B+N,l,cmp)-B,p2=upper_bound(B,B+N,r,cmp)-B;
        //cerr<<"p1:"<<p1<<", p2:"<<p2<<endl;
        //cerr<<"count:"<<p2-p1<<endl;
        return p2-p1;
}

int solve(){
        int ret=0;
        sort(A,A+N,cmp);
        sort(B,B+N,cmp);
        for(int i=0;i<N;++i){
                int l=(X-A[i])&Mask,r=(Mask-A[i])&Mask;
                //cerr<<"A[i]:"<<A[i]<<" l:"<<l<<" r:"<<r<<endl;
                if(l>r){
                        ret^=count(l,Mask)&1;
                        ret^=count(0,r)&1;
                }else{
                        ret^=count(l,r)&1;
                }   
        }   
        return ret;
}

int main(){
        scanf("%d",&N);
        for(int i=0;i<N;++i) scanf("%d",A+i);
        for(int i=0;i<N;++i) scanf("%d",B+i);

        int ans=0;
        for(X=1;X>0 && X<INF;X<<=1){
                Mask=(X<<1)-1;
                //cerr<<"X:"<<X<<" Mask:"<<Mask<<endl;
                ans^=X*solve();
        }   
        printf("%d\n",ans);
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
int N,n,a,b,c,d;
scanf("%d",&N);
b=(N/1000);
c=b+1;
n=(c*1000);
a=n-N;
d=N%1000;
if(d==0)
printf("%d\n ",d);
else
printf(" %d\n ",a);
}


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

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void) {
  int i, j, k, l;
  int *a, *b;
  int *x, *y, *c;
  int A, B, M;
  int minA = INT_MAX, minB = INT_MAX;
  int minimum = INT_MAX;
  scanf("%d %d %d", &A, &B, &M);
  a = new int[A];
  b = new int[B];
  x = new int[M];
  y = new int[M];
  c = new int[M];
  for(i = 0;i < A;i++) {
    scanf("%d", &a[i]);
    if(a[i] < minA) minA = a[i];
  }
  for(i = 0;i < B;i++) {
    scanf("%d", &b[i]);
    if(b[i] < minB) minB = b[i];
  }
  minimum = minA + minB;
  for(i = 0;i < M;i++) {
    int price;
    scanf("%d %d %d", &x[i], &y[i], &c[i]);
    price = a[x[i] - 1] + b[y[i] - 1] - c[i];
    if(price < minimum) minimum = price;
  }
  printf("%d\n", minimum);
  return 0;
}


Measured memory_bytes: 2176
from fractions import gcd
a,b,c,d=map(int,input().split())
cd=(c*d)//gcd(c,d)

bc=b//c
bd=b//d
bcd=b//(cd)
b_cnt=b-(bc+bd-bcd)

ac=(a-1)//c
ad=(a-1)//d
acd=(a-1)//(cd)
a_cnt=a-1-(ac+ad-acd)

print(b_cnt-a_cnt)

Measured memory_bytes: 5076
N = int(input())
H = list(map(int,input().split()))

def f(x):
    if len(x) == 1:
        return x[0]
    else:
        xmin = min(y for y in x)
        minindex = x.index(xmin)
        if minindex == 0 :
            return f(x[1:])
        elif minindex == len(x)-1:
            return f(x[:len(x)-1])
        else:
            return (f(x[:minindex]) + f(x[minindex+1:]) -xmin)

print(f(H))

Measured memory_bytes: 3064
n,m = map(int, input().split())
a = (n-1) // 2
d = 1
memo = set([])
for i in range(m):
    if n-d in memo or 2*d == n:
        d += 1
    memo.add(d)
    print(a, a+d)
    a -= 1
    d += 2


Measured memory_bytes: 17380
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n,x=5,ans=0;
    cin>>n;
    vector<int>v;
    if(n%2==1)
    {
        cout<<"0";
        exit(0);
    }
    n=n/2;
    while(x<=n)
    {
        v.pb(n/x);
        x=x*5;
    }
    if(sz(v)<=0)
    {
        cout<<"0";
        exit(0);
    }
    
    n=sz(v);
    ans=v[n-1]*(n);
    r(i,n-2,0)
    {
        ans+= (v[i]-v[i+1])*(i+1);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char input[15],temp[15];
	scanf("%s",input);
	int len = strlen(input);
	int i = 0,j = 0;
	while(len--)
	{
		if(input[j] == 'B')
		{
			if(i > 0)
			{
				i--;
			}
			temp[i] = ' ';
			j++;
		}
		else{
			temp[i] = input[j];
			i++;
			j++;
		}
	}
	temp[i] = '\0';
	printf("%s\n",temp);
	return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    bool F[n][n] = {};
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        F[a][b] = true;
        F[b][a] = true;
    }

    vector<int> V(n - 1);
    for(int i = 0; i < n - 1; i++){
        V[i] = i + 1;
    }

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

    int ans = 0;
    do{
        int now = 0, next;
        bool f = true;
        for(int i = 0; i < n - 1; i++){
            next = V[i];
            if(F[now][next]);
            else{
                f = false;
                break;
            }
            now = next;
        }
        if(f) ans++;
    }while(next_permutation(V.begin(), V.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int times = 0;
		
		times = A * B;
		
		System.out.println(times);
 
	}
 
}

Measured memory_bytes: 35780
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
#define LL long long
using namespace std;
const int MAXN = 2 * 1e5 + 5;
int n, a[MAXN], maxx;
LL ans;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		ans += max(maxx - a[i], 0);
		maxx = max(maxx, a[i]);
	}
	printf("%lld", ans);
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int N;
int A[20];
int x[20][20];
int y[20][20];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int m;int a;int r;int c;int h;
    m=0;a=0;r=0;c=0;h=0; 
    REP(i,N){
        string s=in<string>();
        if(s[0]=='M'){
            m++;
        }else if(s[0]=='A'){
            a++;
        }else if(s[0]=='R'){
            r++;
        }else if(s[0]=='C'){
            c++;
        }else if(s[0]=='H'){
            h++;
        }
    }
    int P[10]={0,0,0,0,0,0,1,1,1,2};
    int Q[10]={1,1,1,2,2,3,2,2,3,3};
    int R[10]={2,3,4,3,4,4,3,4,4,4};
    ll D[5];
    D[0]=m;D[1]=a;D[2]=r;D[3]=c;D[4]=h;

    ll ans;ans=0;
    REP(i,10){
        ans+=D[P[i]]*D[Q[i]]*D[R[i]];
    }
    cout<<ans<<endl;
    return 0;
}


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

bool ex[1001];

int main() {
    int X;
    cin >> X;
    ex[1] = true;
    for (int i = 2; i <= X; i++) {
        int a = i * i;
        while (a <= X) {
            ex[a] = true;
            a *= i;
        }
    }
    for (int i = X; i >= 1; --i) {
        if (ex[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

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

#define Bye return 0
#define ll long long

void solve(){
    string str; cin>>str;
    int i = 0, j = str.size() - 1;
    while(str[i]!='A') i++;
    while(str[j]!='Z') j--;
    cout<<(j-i)+1<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    int n;cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    double ab = a[n-1]+a[n-2];
    double ans = -1;
    rep(i,n){
        double cd = a[i+1] - a[i];
        if(i +1 == n-2)break;
        double res = ab/cd;

        ans = max(ans,res);



    }
    ans = max(ans,(double)(a[n-1]+a[n-4])/(a[n-2] - a[n-3]));
    ans = max(ans,(double)(a[n-3]+a[n-4])/(a[n-1]-a[n-2]));
    printf("%lf",ans);
    return 0;
}


Measured memory_bytes: 3292
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")
    };
}



#[allow(non_snake_case, unused_variables)]
fn main() {
    input!{
        N: usize,
        A: usize,
        B: usize,
        S: chars
    }
    let mut cnt: usize = 0;
    let mut cnt_b: usize = 0;
    let output = ["Yes", "No"];
    for c in S {
        let mut ans = 1;
        if c== 'a' {
        	if cnt<A+B { 
                ans = 0;
                cnt += 1;
                }
         }
         if c=='b' {
         	if cnt<A+B && cnt_b<B {
                ans = 0;
                cnt += 1;
                cnt_b += 1;
                }
         }
        println!("{}", output[ans]);
    }
}


Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    int year = atoi(s.substr(0,4).c_str());
    int month = atoi(s.substr(5,7).c_str());
    int day = atoi(s.substr(8,10).c_str());
    
    if (year * 12 + month > 2019*12+4)
    {
        cout << "TBD" << endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }
    
    int a;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

const Int MAX = 510000;
const Int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (Int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(Int n, Int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    Int n;
    cin >> n;
    vector<Int> a(n + 2);
    map<Int, Int> mp;
    Int index = -1;
    Int index2 = -1;
    for (Int i = 0; i < n + 1; i++) {
        cin >> a[i];
        if (mp[a[i]] > 0) {
            index = i;
            index2 = mp[a[i]] - 1;
        }
        mp[a[i]] = i + 1;
    }
    for (Int i = 1; i <= n; i++) {
        if (i == 1) {
            dump(n);
            continue;
        }
        Int res1 = fac[n];
        res1 = (res1 * finv[i]) % mod;
        res1 = (res1 * finv[n - i]) % mod;
        Int res2 = fac[n];
        res2 = (res2 * finv[i - 1]) % mod;
        res2 = (res2 * finv[n - (i - 1)]) % mod;
        Int res3 = (res1 + res2) % mod;
        // if (i - 1 <= n - index) {
        //     res3 = (res3 - COM(n - index, i - 1) + mod) % mod;
        // }
        // if (i - 1 <= index2) {
        //     res3 = (res3 - COM(index2, i - 1) + mod) % mod;
        // }
        if (i - 1 <= n - index + index2) {
            res3 = (res3 - COM(n - index + index2, i - 1) + mod) % mod;
        }
        dump(res3);
    }
    dump(1);
    return 0;
}

Measured memory_bytes: 20224
import math

D, G = map(int, input().split())
P = []
C = []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

ans = float('inf')
for bit in range(1 << D):
    count = 0
    num = 0
    rest_num = set(range(1, D+1))

    for i in range(D):
        if bit & (1 << i):
            num += P[i] * (i+1) * 100 + C[i]
            count += P[i]
            rest_num.discard(i+1)

    if num < G:
        max_num = max(rest_num)
        n = min(P[max_num-1], math.ceil((G-num)/(max_num*100)))
        count += n
        num += n * max_num * 100

    if num >= G:
        ans = min(ans, count)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
string s;
cin >> s;
int count = 0;
for(int i=0;i<s.size();i++){
   if(s[i]!=s[s.size()-1-i]) count++;
}
cout << count/2 << endl;
return 0;
}

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

signed main()
{
   int x,n;
   cin>>x>>n;
   int a[105]={0};
   for(int i=0;i<n;i++)
   {
       int k;
       cin>>k;
       a[k]++;
   }
   int i,j;
   for(i=x;;i++)
   {
       if(a[i]==0)
        break;
   }
   for(j=x;;j--)
   {
       if(a[j]==0)
        break;
   }

   if(i-x<x-j)
    cout<<i<<endl;
    else
        cout<<j<<endl;

}




Measured memory_bytes: 3632
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def i() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = I()
AB = LRI(N)

AB.sort(key=lambda x : x[1])

now = 0
for a, b in AB:
    now += a

    if now > b:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 88152
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



int vs[505][505];
void col(int p,int q,int d){
	if(p+1>=q)return;
	int m=(p+q)/2;
	reg(i,p,m-1)reg(j,m,q-1){
		vs[i][j]=vs[j][i]=d;
	}
	col(p,m,d+1);
	col(m,q,d+1);
}

int main(void){
	int n;
	scanf("%d",&n);
	col(0,n,1);
	rep(i,n)reg(j,i+1,n-1){
		printf("%d%c",vs[i][j],j+1==n?'\n':' ');
	}
	return 0;
}






Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PrintLn(X) cout << X << endl

typedef long long ll;
int a[100];
int sum[10001] = {0};
int N;

int main(void)
{
	cin >> N;
	Rep(i, N) cin >> a[i];
	sum[0] = 1;
	Rep(i, N){
		for(int j = 10000; j >= 0; j--){
			if(sum[j]){
				sum[j + a[i]] = 1;
			}
		}
	}

	for(int i = 10000; i >= 0; i--){
		if(i % 10 != 0 && sum[i]){
			PrintLn(i);
			return 0;
		}
	}
	PrintLn(0);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100 + 10, M = 1e5 + 10;
ll n, m, w, v, dp[M];
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> w >> v;
		for (int j = m; j >= w; j--)
			//if (j >= w)
				dp[j] = max (dp[j - w] + v, dp[j]);	
	} 
	cout << dp[m]/**max_element (dp, dp + m + 1)*/ << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict as dc
n,k = map(int,input().split())
DICT = dc(lambda:0)
for i in range(k):
    d = int(input())
    l = list(map(int,input().split()))

    for i in range(d):
        DICT[l[i]]+=1
ans = 0
for i in range(1,n+1):
    if DICT[i] == 0:
        ans += 1

print(ans)

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

void calculate(string &s,int x,vector<string> &ret,string ans){
  //base
  if(x == s.size()-1) {
    ans += s.at(x);
    ret.push_back(ans);
    return;
  }
  ans += s.at(x);
    for(int i=0;i<2;i++){
      if(i == 0){
        calculate(s,x+1,ret,ans);
      }
      else{
        ans += "+";
        calculate(s,x+1,ret,ans);
      }
    } 
}

int main(){
  string s;
  cin >> s;
  vector<string> ret;
  string ans;
  int x = 0;
  calculate(s,x,ret,ans);
  vector<string> storage;
  string save;
  for(auto i:ret){
    for(int k=0;k<=i.size();k++){
      if(k == i.size()||i.at(k) == '+'){
        storage.push_back(save);
        save = "";
        continue;
      }
      save += i.at(k);
    }
  }
  long long answer = 0;
  for(auto i:storage){
    answer += stoll(i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        int n=s.nextInt(),k=s.nextInt(),temp,j=0;
        int[] a = new int[n];
        int[] arr = new int[n-k+1];
        arr[0]=1;
        for(int i=0;i<(n);i++){
            a[i]=s.nextInt();
        }
//        for(int i=0;i<n;i++){
//            if(i<k) arr[0]*=a[i];
//            else{
//                temp=a[i];
//                arr[i+1-k]=((arr[i-k]*temp)/a[j]);
//                j++;
//            }
//        }
        j=(k);
        for(int i=0;i<(n-k);i++,j++){
            if(a[j]>a[i]) System.out.println("Yes");
            else System.out.println("No");
        }
//        for(int i=1;i<(n-k+1);i++){
//            if(arr[i]>arr[i-1]) System.out.println("Yes");
//            else System.out.println("No");
//        }
    }
}

Measured memory_bytes: 75292
#include <algorithm>
#include <iostream>
#include <vector>
const int INF = (1e9);
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int ans = INF;
  for(int i = 0; i < 4; ++i){
    int t = 0;
    vector<int> B = A;
    if(i >= 2) reverse(B.begin(), B.end());
    for(int j = 0; j < N-1; ++j){
      if(j%2 == i%2){
        if(B[j] < B[j+1] && (j >= N-2 || (j < N-2 && B[j+1] < B[j+2]))){
          ++t;
          B[j+1] = B[j];
        }
      }else{
        if(B[j] > B[j+1] && (j >= N-2 || (j < N-2 && B[j+1] > B[j+2]))){
          ++t;
          B[j+1] = B[j];
        }
      }
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define drep(i,n) for (int i = n; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
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 printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, n)
  {
    cout << '[';
    rep(p, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}


//------------------------------------------------------------
string check(int a, int b)
{
  if      (a == b) return "zero";
  else if (a > b)  return "minus";
  else             return "plus";
}

int main() {
  int N, sum=1;
  string sign="null", tmp="";

  cin >> N;

  vector<ll> v(N);
  rep(i, N) cin >> v.at(i);

  if(N==1 || N==2)
  {
    cout << sum << endl;
    return 0;
  }

  for(int i=1; i<N; i++)
  {
    if (sign=="null" || sign=="zero")
    {
      sign = check(v.at(i-1), v.at(i));
      continue;
    }

    tmp = check(v.at(i-1), v.at(i));
    if ((sign=="plus"&&tmp=="minus") || (sign=="minus"&&tmp=="plus"))
    {
      ++sum;
      sign="null";
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,int>
const LL N=1e5+10;
const LL inf=2147483647;
using namespace std;
template<typename tp> inline void read(tp &x)
{
    x=0; char c=getchar(); bool f=0;
    for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
    for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
    if(f) x=-x;
}
LL sum;
int n,a;
signed main()
{
    read(n);
    for(int i=1;i<=n;i++) 
    {
        read(a);
        sum^=a;   
    }
    puts(sum?"No":"Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool isEven(const string &s){
    int mid = s.length() / 2;
    for(int i = 0 ; i < mid ; ++i){
        if(s[i] != s[i + mid]) return false;
    }
    return true;
}

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    s.pop_back(); s.pop_back();
    while(!isEven(s)){
        s.pop_back();
        s.pop_back();
    }
    cout << s.length() << '\n';
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;

	vector < pair <int, int> > v;
	vector <bool> b;
	for (int i=0; i<N; i++) b.push_back(false);
	b[0] = true;

	for (int i=0; i<M; i++) {
		int a, b;
		cin >> a >> b;
		if (a > b) swap(a, b);
		v.push_back(make_pair(a-1, b-1));
	}

	for (int i=0; i<M; i++) {
		if (v[i].first == 0) b[v[i].second] = true;
	}

	for (int i=0; i<M; i++) {
		if (b[v[i].first] && v[i].second == N-1) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 2456
// Last Change: 04/25/2019 18:51:21.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  char C[2][3];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> C[i][j];
    }
  }

  if (C[0][0] == C[1][2] and C[0][2] == C[1][0] and C[0][1] == C[1][1]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
while True:
    n, m, a = map(int, raw_input().split())
    if n | m | a  == 0:
        break
    L = sorted([map(int, raw_input().split()) for _ in xrange(m)])
    A = range(n + 1)
    for h, p, q in L:
        A[p], A[q] = A[q], A[p]
    print A[a]

Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<int>());
    long long happy=a[0];
    n-=2;
    for(int i=1;n>0;i++){
        if(n>1)happy+=a[i]*2;
        else happy+=a[i];
        n-=2;
    }
    cout<<happy<<endl;
    return 0;
}

Measured memory_bytes: 4424
#include <cmath>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; ++j) {
			cin >> X[i][j];
		}
	}

	int ans = 0;

	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int num = 0;
			for (int k = 0; k < D; ++k) {
				int tmp = (X[i][k] - X[j][k]);
				num += tmp * tmp;
			}
			int tmp2 = (int)(num / sqrt((double)num));
			if (tmp2 * tmp2 == num) {
				ans++;
			}
		}
	}

	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll h,w,n;cin>>h>>w>>n;
  ll m=max(h,w);
  ll ans=(n-n%m)/m;
  if(n%m>0) ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n; cin >> n;
    map<string, int> count;
    REP(i, n) {
        string s; cin >> s;
        count.insert(make_pair(s, 0));
        count[s]++;
    }

    int maxi = 0;
    for (auto i : count)
        maxi = max(maxi, i.second);
    // for (auto itr = count.begin(); itr != count.end(); itr++)
    //     maxi = max(maxi, itr->second);

    for (auto itr = count.begin(); itr != count.end(); itr++)
        if (itr->second == maxi)
            cout << itr->first << '\n';
    return 0;
}


Measured memory_bytes: 23808
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    r:usize,d:usize,x:usize,
     }

    let mut prev = x;
    for _ in 0..10 {
        prev = r * prev - d;
        println!("{}", prev);
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 100005
using namespace std;
int n,w[4][N],a[N],sum[2][N],inv[2],flip[2];
void add(int *sum,int k,int val){
	val&=1;
	for(k;k<=n;k+=k&-k) sum[k]^=val;
}
int find(int *sum,int k){
	int ans=0;
	for(k;k;k-=k&-k) ans^=sum[k];
	return ans;
}
int zh(int a){return a<0?-a:a;}
bool pan(){
	for(int i=1;i<=n;i++){
		if(w[1][i]<w[3][i]){
			if(w[2][i]!=w[1][i]+1||w[2][i]!=w[3][i]-1) return 0;
			if(w[3][i]%3) return 0;
			a[i]=w[3][i]/3;
		}else{
			if(w[2][i]!=w[3][i]+1||w[2][i]!=w[1][i]-1) return 0;
			if(w[1][i]%3) return 0;
			a[i]=-w[1][i]/3;
		}
	}
	for(int i=1;i<=n;i++){
		if(i%2!=(a[i]%2+2)%2) return 0; 
	}
	for(int i=1;i<=n;i++){
		inv[i&1]^=(a[i]<0);
		flip[i&1]^=find(sum[i&1],n)^find(sum[i&1],zh(a[i])-1);
		add(sum[i&1],zh(a[i]),1);
	}
	if(inv[0]==flip[1]&&inv[1]==flip[0]) return 1;
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int p=1;p<=3;p++)
		for(int i=1;i<=n;i++) scanf("%d",&w[p][i]);
	if(pan()) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; ++i)
		cin >> nums[i];

	sort(begin(nums), end(nums));
	map<vector<int>, bool> mapp;
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			if (!(nums[i] == nums[j]))
			{
				for (int k = j + 1; k < n; ++k)
				{
					if (nums[j] == nums[k] || nums[i] == nums[k])
						continue;
					cnt += ((nums[i] + nums[j] > nums[k]));
				}
			}
		}
	}
	cout << cnt;
}

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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)


using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
LL a, b, n;

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> a >> b >> n;
    LL x = min(n, b - 1);
    cout << a * x / b - a * (x / b) << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, z, w;
        in >> n >> z >> w;
        vll a(n);
        for (int i = 0; i < n; i++) {
            in >> a[i];
        }
        ll ans = 0;
        if (2 <= n) {
            ans = abs(a[a.size() - 2] - a[a.size() - 1]);
        }
        out << max(ans, abs(a[a.size() - 1] - w)) << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

signed main() {
    ll N;
    cin >> N;
    ll A, B;
    cin >> A >> B;
    N = N % 12;
    for(int i = 0;i < N;i++) {
        if(i % 2 == 0) {
            A = A - B;
        }
        else {
            B = A + B;
        }
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 3108
a = input()
d = ['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']
if a in d:
    print("A")
else:
    print("a")

Measured memory_bytes: 8932
#include<iostream>
using namespace std;
int main()
{
	long long l[87];
	long long  a,b,i;
	cin>>a;
	l[0]=2;
	l[1]=1;
	for(i=2;i<=a;i++){
		l[i]=l[i-1]+l[i-2];
	}
	cout<<l[a]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = 0;
    int n = i;
    while (n > 0) {
      sum += n % 10;
      n /= 10;
    }
    if (sum >= A && sum <= B) ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256