akhauriyash/Code-Regression huggingface dataset:
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

//const int ids[] = {1, 2, 4, 3, 5, 6};

/* typedef */

typedef vector<int> vi;

struct Dice {
  static const int DN = 6;
  vi ds;

  // 0=X+(top), 1=Y+(front), 2=Z+(right), 3=Z-(left), 4=Y-(back), 5=Z-(bottom)
  Dice(vi &_ds): ds(_ds) {}
  Dice(const int _ds[]) { ds.assign(_ds, _ds + DN); }
  //Dice(): ds(ids, ids + DN) {}

  bool operator==(const Dice &d) const {
    for (int i = 0; i < DN; i++)
      if (ds[i] != d.ds[i]) return false;
    return true;
  }

  bool operator<(const Dice &d) const {
    for (int i = 0; i < DN; i++)
      if (ds[i] != d.ds[i]) return (ds[i] < d.ds[i]);
    return false;
  }

  inline int top()    const { return ds[0]; }
  inline int front()  const { return ds[1]; }
  inline int right()  const { return ds[2]; }
  inline int left()   const { return ds[3]; }
  inline int back()   const { return ds[4]; }
  inline int bottom() const { return ds[5]; }
  
  Dice rotx(int n = 1) { // 1, 2, 4, 3
    Dice r(*this);
    while (n--) {
      int t = r.ds[1];
      r.ds[1] = r.ds[3]; r.ds[3] = r.ds[4]; r.ds[4] = r.ds[2];
      r.ds[2] = t;
    }
    return r;
  }

  Dice roty(int n = 1) { // 2, 0, 3, 5
    Dice r(*this);
    while (n--) {
      int t = r.ds[2];
      r.ds[2] = r.ds[5]; r.ds[5] = r.ds[3]; r.ds[3] = r.ds[0];
      r.ds[0] = t;
    }
    return r;
  }

  Dice rotz(int n = 1) { // 0, 1, 5, 4
    Dice r(*this);
    while (n--) {
      int t = r.ds[0];
      r.ds[0] = r.ds[4]; r.ds[4] = r.ds[5]; r.ds[5] = r.ds[1];
      r.ds[1] = t;
    }
    return r;
  }

  void print() {
    for (int i = 0; i < DN; i++) printf("%d", ds[i]); putchar('\n');
  }

  static void alldices(const Dice &d0, set<Dice> &s) {
    Dice d(d0);
    for (int z = 0; z < 4; z++) {
      Dice dz = d.rotz(z);
      for (int y = 0; y < 4; y++) {
	Dice dy = dz.roty(y);
	for (int x = 0; x < 4; x++)
	  s.insert(dy.rotx(x));
      }
    }
  }
};

typedef set<Dice> sd;

/* global variables */

int ids[6];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < 6; i++) cin >> ids[i];

  Dice d0(ids);
  sd dset;

  Dice::alldices(d0, dset);

  int q;
  cin >> q;

  while (q--) {
    int t, f;
    cin >> t >> f;

    for (sd::iterator sit = dset.begin(); sit != dset.end(); sit++)
      if (sit->top() == t && sit->front() == f) {
	printf("%d\n", sit->right());
	break;
      }
  }
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<=n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  int n; cin>>n;
  int y; cin>>y;
  rep(i,0,n){
    rep(j,0,n-i){
      int k = n-i-j;
      if(10000*i+5000*j+1000*k==y){
        std::cout <<i<<' '<<j<<' '<<k << '\n';
        return 0;
      }
    }
  }
  std::cout <<"-1 -1 -1"<< '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s[4] = {"AC", "WA", "TLE", "RE"};
int cnt[4];
int main() {
    int t; cin >> t;
    while(t--) {
        string k; cin >> k;
        for(int i=0; i<4; i++) {
            if(s[i] == k) cnt[i]++;
        }
    }
    for(int i=0; i<4; i++) {
        cout << s[i] << " x " << cnt[i] << "\n";
    }
}

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

namespace _0020
{
    public class Program

    {
        public static void Main(string[] args)
        {
            string line = ReadSt();
            Console.WriteLine(string.Join("",line.Select(x => char.ToUpper(x))));
        }
        static string ReadSt() { return Console.ReadLine(); }
    }

}



Measured memory_bytes: 18152
import string

S = input()

if S[0] != 'A':
    print('WA')
    exit()

if S[2:len(S) - 1].count('C') != 1:
    print('WA')
    exit()

if S[1] == 'C' or S[-1] == 'C':
    print('WA')
    exit()

for s in string.ascii_uppercase.replace('C', ''):
    if s in S[1:]:
        print('WA')
        exit()

print('AC')


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



int main(){
  
  string s;
  cin >> s;
  int ans=-1;
  int ans2=-1;
  if(s.size()==2){
    if(s[0]==s[1]){
      cout << 1 << " " << 2;
      return 0;
    }
  }
  rep(i,s.size()-2){
    if(s[i]==s[i+1]){
      ans=i+1;
      ans2=i+1+1;
      break;
    }
    else if(s[i]==s[i+2]){
      ans=i+1;
      ans2=i+2+1;
      break;
    }
    else if(s[i+1]==s[i+2]){
      ans=i+1+1;
      ans2=i+2+1;
    }
  }
  cout << ans << " " << ans2 << endl;

  
  return 0;

}


Measured memory_bytes: 512
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll n;
     cin >> n;
     ll f[n];

    for(ll i=0 ; i<n ; ++i) {
        ll x,y;
        cin >> x >> y;
        if(x == y)
            f[i] = 1;
        else
            f[i] = 0;
    }

    for(ll i= 0 ; i + 2 < n ; ++i) {

         if(f[i] + f[i+1] + f[i+2] == 3) {
            cout << "Yes";
            return;
         } 
    } 

    cout << "No";
}

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



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n;
vector<int> a;

long long pow(long long x, long long n){
    if(n == 0) return 1;
    long long res = pow(x * x, n / 2);
    if(n & 1) res = res * x;
    return res;
}

bool f(int mid){
    // cout << " " << mid << endl;
    int beet = mid, limit = 1;
    while(beet < 1e13){
        limit++;
        beet *= mid;
    }
    int apre = min(limit, a[0]);
    int cnt = pow(mid, apre);
    rep(i, 1, n){
        int anow = min(limit, a[i]);
        if(a[i - 1] < a[i]){
            cnt *= pow(mid, anow - apre);
        }else if(a[i - 1] == a[i]){
            cnt--;
        }else if(apre > anow){
            int dv = pow(mid, apre - anow);
            cnt = (cnt + dv - 1) / dv;
            cnt--;
        }
        if(cnt <= 0) return false;
        apre = anow;
        // cout << cnt << endl;
    }
    return true;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    bool g = true;
    rep(i, 1, n){
        if(a[i - 1] >= a[i]) g = false;
    }
    if(g){
        cout << 1 << endl;
        return 0;
    }
    int ng = 1, ok = n;
    while(ok - ng > 1){
        int mid = (ok + ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;public class Main{public static void main(String[]args){Scanner scan=new Scanner(System.in);
		//String str=scan.next();
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=scan.nextInt();
		int count=0;
		for(int i=a>=b?a:b;;i--) {
			if(a%i==0&&b%i==0) {
				count++;
				if(count==ans) {
					System.out.println(i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
void unique_function()
{
    int n;
    cin>>n;
    unordered_set<string> unique;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        unique.insert(s);
    }
    cout<<unique.size();
}
int main()
{
    unique_function();
}

Measured memory_bytes: 17684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K ,Q;
  cin >> N >> K >> Q;
  //各選手の正解数合計[0,0,0,...]
  vector<int> wins(N);
  
  //for (int i = 0; i < N; i++) cout << wins.at(i) << endl;
  
  for (int i = 0; i < Q; i++) {
    int w;
    cin >> w;
    //cout << w << endl;
    wins.at(w-1) ++;
  }
  
  for (int i = 0; i < N; i++) {
    if (wins.at(i) + K - Q <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  
}

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

int main(void){
    
    int a,b;
    cin >> a >> b;
 
    if(a > b){
        for(int i=0;i<a;i++){
            cout << b;
        }
        cout << endl;
    }
    else{
        for(int i=0;i<b;i++){
            cout << a;
        }
        cout << endl;
    }
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int a, p;
  cin >> a >> p;
  cout << (a * 3 + p) / 2 << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>

using namespace std;

const int MAX=100010;
const int INFTY=1<<30;

int n,col[MAX],d[MAX];
vector<pair<int,int>> Q[MAX];//target,weight

void dijkstra(int s)
{
	priority_queue<pair<int,int>> PQ;//weight,id
	for(int i=0;i<n;i++)
	{
		d[i]=INFTY;
		col[i]=0;
	}
	d[s]=0;
	PQ.push(make_pair(0,s));
	col[s]=1;
	
	while(!PQ.empty())
	{
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<Q[u].size();j++)
		{
			int v=Q[u][j].first;
			if(col[v]==2)continue;
			if(d[u]+Q[u][j].second<d[v])
			{
				d[v]=d[u]+Q[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}
	
	return;
}

int main()
{
	cin>>n;
	int a,b;
	for(int i=0;i<n-1;i++)
	{
		cin>>a>>b;a--;b--;
		Q[a].push_back(make_pair(b,1));
		Q[b].push_back(make_pair(a,1));
	}
	int k;cin>>k;
	int dd[MAX];
	memset(dd,-1,sizeof(dd));
	n++;
	for(int i=0;i<k;i++)
	{
		cin>>a>>b;a--;
		Q[n-1].push_back(make_pair(a,b));
		dd[a]=b;
	}
	
	dijkstra(n-1);
	
	for(int i=0;i<n-1;i++)
	{
		if(dd[i]!=-1)
		{
			if(dd[i]!=d[i])
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	
	for(int i=0;i<n-1;i++)
	{
		for(int j=0;j<Q[i].size();j++)
		{
			if(abs(d[i]-d[Q[i][j].first])!=1)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	
	cout<<"Yes"<<endl;
	for(int i=0;i<n-1;i++)
	{
		cout<<d[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 9768
#include <iostream>
#include <bitset>

using namespace std;

int n;

int dfs(unsigned int score, bitset<3> bits){
    if(score > n) return 0;
    int res = bits.count() == 3;
    auto nextbits = bits;
    for(int i = 3; i <= 7; i += 2){
        nextbits[i - 3 / 2] = true;
        res += dfs(score * 10 + i, nextbits);
        nextbits[i - 3 / 2] = bits[i - 3 / 2];
    }
    return res;
}

int main(){
    cin >> n;
    cout << dfs(0, bitset<3>(0)) << "\n";
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<ll, ll> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    string s;
    cin >> s;
    rep(i, s.length()) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

#define MAX_V 200005


int V, E, r; //頂点数、辺数、始点
vector<int>G[MAX_V]; //グラフ情報
int d[MAX_V]; //最短距離
vector<int>ans;


void dfs(int v, int p = -1) { //今見てる頂点とその親
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] == p)continue;
		ans[G[v][i]] += ans[v];
		dfs(G[v][i], v);
	}
}

signed main() {
	int Q;
	cin >> V >> Q;
	rep(i, V - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ans.resize(V);
	rep(i, Q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i, V)cout << ans[i] << endl;
}

Measured memory_bytes: 27392
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)

def Yakusu(n):

    ans = 0

    for i in range(1 , n + 1 , 2):
        if make_divisors(i) == 8:
            ans += 1

    return ans

def main():
    n = int(input())
    print(Yakusu(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	cin >> n;
 	priority_queue <double, vector<double>, greater<double>> q;
 	for(int i=1; i<=n; i++) 
 	{
 		double v;
 		cin >> v;
 		q.push(v);
 	}
 	while(sz(q)>=2)
 	{
 		auto u = q.top(); q.pop();
 		auto v = q.top(); q.pop();
 		q.push((u+v)/2);
 	}
 	auto ans = q.top();
 	cout << fixed << setprecision(12) << ans;
	return 0;
}


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

int tonum(char c){
	if('0'<=c && c<='9') return c-'0';
	if('A'<=c && c <='Z') return c-'A'+10;
	return c-'a'+36;
}

int conv(int p, string s){
	int res=0;
	int base = 1;
	for(int i=s.length()-1; i>=0; i--, base*=p){
		res += tonum(s[i])*base;
	}
	return res;
}

vector<int> split(int a){
	vector<int> res;
	int con=0;
	for(int i=0; i<20; i++){
		if((1<<i & a) != 0){
			con++;
		}else if(con != 0){
			res.push_back(con);
			con = 0;
		}
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		int p;
		string s;
		cin >> p >> s;
		a[i] = conv(p, s);
	}
	
	vector<int> len;
	for(int i=0; i<(int)a.size(); i++){
		vector<int> tmp = split(a[i]);
		len.insert(len.end(), tmp.begin(), tmp.end());
	}
	
	int g=0;
	for(int i=0; i<n; i++){
		g ^= len[i];
	}
	if(g==0){
		cout << "lose" << endl;
	}else{
		cout << "win" << endl;
	}
	return 0;
}


Measured memory_bytes: 7048
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 301
#define INF (1LL << 50)
#define MAXN 100001
#define MAXM 100001
#define MAXK 100002
#define MAXV 100001
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;
typedef pair<int, int> P;
struct edge{
    int to, from, cost;
};
static vector<edge> E;
int V;
P x[MAXV], y[MAXV];

static int ran[MAXV];
static int parent[MAXV];

void init_union_find(int n){
    for(int i = 0;i < n;i++){
        ran[i] = 0;
        parent[i] = i;
    }
    return;
}

int find(int c){
    if(parent[c] == c) return c;
    return parent[c] = find(parent[c]);
}

bool same(int l, int r){
    return find(l) == find(r);
}

void link(int l, int r){
    l = find(l);
    r = find(r);
    if(l == r) return;

    if(ran[l] < ran[r]){
        parent[l] = r; 
    }else {
        parent[r] = l;
        if(ran[l] == ran[r]){
            ran[l]++;
        }
    }

    return;
}

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

int kruskal(){
    int sum = 0;
    init_union_find(V);
    sort(E.begin(), E.end(), comp);
    for(int i = 0;i < E.size();i++){
        const edge &e = E[i];
        if(!same(e.from, e.to)){
            link(e.from, e.to);
            sum += e.cost;
        }
    }

    return sum;
}

int main(){
    cin >> V;
    int X, Y;
    for(int i = 0;i < V;i++){
        cin >> X >> Y;
        x[i] = {X, i};
        y[i] = {Y, i};
    }
    sort(x, x + V);
    sort(y, y + V);
    for(int i = 0;i < V;i++){
        if(i > 0){
            E.push_back({x[i- 1].second, x[i].second, x[i].first - x[i - 1].first});
            E.push_back({y[i - 1].second, y[i].second, y[i].first - y[i - 1].first});
        }
        if(i < V - 1){
            E.push_back({x[i + 1].second, x[i].second, x[i + 1].first - x[i].first});
            E.push_back({y[i + 1].second, y[i].second, y[i + 1].first - y[i].first});
        }
    }
    printf("%d\n", kruskal());
    return 0;
}

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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}

int main(void) {
    int n;
    cin >> n;
    
    int a[n];
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    
    double ans = 0.0;
    
    REP(i, n) {
        ans += 1.0 / (double)a[i];
    }
    
    cout << 1.0/ans << endl;
}

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

#include <vector>
#include <algorithm>
typedef long long int ll;

int main(int argc, char **argv)
{
	cin.tie(0);
    ios::sync_with_stdio(false);

	int N;
	cin >> N;

	std::vector<int> A_v;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		A_v.push_back(tmp);
	}

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

	ll max_v = 0;

	for (int i=0; i < N / 2; i++)
	{
		max_v -= A_v[i] * 2;
	}

	if (N % 2 == 0)
	{
		for (int i = N / 2; i < N; i++)
		{
			max_v += A_v[i] * 2;
		}
		//max_v = max_v - (A_v[N/2+1] - A_v[N/2]);
		max_v = max_v - (A_v[N/2] - A_v[N/2-1]);
	
	}
	else
	{
		for (int i = N / 2 + 1; i < N; i++)
		{
			max_v += A_v[i] * 2;
		}
		int tmp = min(A_v[N/2] - A_v[N/2 -1], A_v[N/2+1] - A_v[N/2]);
		//int tmp = max(A_v[N/2] - A_v[N/2 -1], A_v[N/2+1] - A_v[N/2]);
		//cout << "tmp=" << tmp << endl;
		max_v = max_v - tmp;
		//max_v = max_v + tmp;
	}
	
	cout << max_v;

	return 0;
	
}



Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

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

int main(void){
    ll n,m;string s,t;
    cin>>n>>m>>s>>t;
    ll g=gcd(n,m);
    ll l=n*m/gcd(n,m);
    if(s[0]!=t[0]){
        cout<<-1<<endl;
        return 0;
    }
    if(g==1){
        cout<<l<<endl;
        return 0;
    }
    else{
        ll p=n/g,q=m/g;
        for(ll i=0;i<g;i++){
            if(s[p*i]!=t[q*i]){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    cout<<l<<endl;
    
    return 0;
}


Measured memory_bytes: 512
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        
        double tan  = H*30 + M*0.5;
        double tyou = M*6;
        double kakdo = Math.abs(tan-tyou);
        
        double yogen = A*A + B*B - 2*A*B*Math.cos(kakdo * (Math.PI / 180));
        double sqrt_yogen = Math.sqrt(yogen);
        
        System.out.println(sqrt_yogen);
    }
}

Measured memory_bytes: 35924
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }

        int[] Res = solve2(A, N, K);
        for(int i=0;i<N;i++){
            System.out.print(Res[i] + " ");
        }

    }

    public static int[] solve2(int[] A, int N, int K){
        for(int i=0;i<K;i++){
            int[] B = new int[N];
            for(int j=0;j<N;j++){
                add2(B, j-A[j], j+A[j]);
            }
            int now=0;
            int min=Integer.MAX_VALUE;
            for(int j=0;j<N;j++){
                now += B[j];
                A[j] = now;
                min = Math.min(A[j], min);
            }
            if(min >= N){
                return A;
            }
        }
        return A;
    }

    public static void add2(int[] B, int s ,int e){
        s = Math.max(s, 0);
        e = Math.min(e, B.length-1);
        B[s] ++;
        if(e < B.length-1)
            B[e+1] --;
    }




    public static int[] solve(int[] A, int N, int K){
        for(int i=0;i<K;i++){
            int[] B = new int[N];
            for(int j=0;j<N;j++){
                add(B, j-A[j], j+A[j]);
            }
            A = B;
        }
        return A;
    }

    public static void add(int[] B, int s ,int e){
        s = Math.max(s, 0);
        e = Math.min(e, B.length-1);
        for(int i=s;i<=e;i++){
            B[i]++;
        }
    }

}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b;
    cin >> a >> b;
    ll ans = ll(a) * b / __gcd(a, b);
    cout << ans << endl;
    return 0;
}



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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    vector<ll> p_cum(n+1, 0);
    rep(i, n){
        cin >> p[i];
        p_cum[i+1] = p_cum[i] + p[i];
    }

    ll ma_a = 0;
    rep(i, n-k+1){
        ll tmp = p_cum[i+k] - p_cum[i];
        ma_a = max(tmp, ma_a);
    }
    double ans = double((ma_a+k))/2.0;
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 6404
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	const int MAX = 1000000;
	vector<int> cub, sq;
	for (int i = 0; i*i*i <= MAX; ++i)
		cub.push_back(i*i*i);
	for (int i = 0; i*i <= MAX; ++i)
		sq.push_back(i*i);
	cub.push_back(MAX + 1);
	sq.push_back(MAX + 1);

	int e;
	while (scanf("%d", &e), e)
	{
		int res = e;
		for (int z = 0; cub[z] <= e; ++z)
			for (int y = 0; sq[y] + cub[z] <= e; ++y)
				min_swap(res, (e - (sq[y] + cub[z])) + y + z);
		printf("%d\n", res);
	}
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
vector<ll> A;
vector<ll> L;
vector<ll> R;

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    while (b != 0) {
        int r = a % b;

        a = b;
        b = r;
    }

    return a;
}

int main(void) {

    cin >> N;

    rep(i, N) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    L.push_back(0);
    REP(i, 0, N) {
        L.push_back(gcd(L.back(), A[i]));
    }

    reverse(ALLOF(A));
    R.push_back(0);
    REP (i, 0, N) {
        R.push_back(gcd(R.back(), A[i]));
    }
    reverse(ALLOF(A));

    int m = 1;
    REP(i, 0, N) {
        int g = gcd(L[i], R[N - i - 1]);
        if (g > m) m = g;
    }

    // REP(i, 0, N) {
    //     int g = i == 0 ? A[1] : A[0];
    //     REP(k, 0, N - 1) {
    //         if (k == i) continue;
    //         int ni = k + 1;
    //         if (ni == i) ni++;
    //         if (ni >= N) continue;

    //         g = gcd(g, A[ni]);
            
    //     }
    //     if (g > max) max = g;
    //     //cout << g << endl;
    // }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 3316
#include<cstdio>
using namespace std;
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x=i,z=0;
		while (x) z++,x/=10;
		if (z%2) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define REP(i, n) for(int i = 1; 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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int getdig(ll N){
    int digit = 0;
    while(N != 0){
        N /= 10;
        digit++;
    }
    return digit;
}

int main()
{
    ll N;
    cin >> N;
    /*vector<ll> vec;
    REP(i,sqrt(N)){
        if(N % i == 0){
            vec.push_back(i);
        }
    }
    ll ans_N = N / vec[vec.size()-1];
    ll ans = 0;
    while(ans_N != 0){
        ans_N = ans_N / 10;
        ans++;
    }
    cout << ans << endl;
    return 0;*/
    ll ansN = 1;
    REPR(i,ceil(sqrt(N))){
        if(N % i == 0){
            ansN = i;
            break;
        }
        else{continue;}
    }
    ll ans_N = N / ansN;
    cout << getdig(ans_N)<< endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
int m, n, ans;
bool visited[maxn];
vector < int > edge[maxn];
void dfs(int now){
	if(visited[now])return;
	visited[now] = true;
	for(auto &i : edge[now])dfs(i);
}
int main(){
	cin >> n >> m;
	for(int a, b, c, i = 0;i < m;++i){
		cin >> a >> b >> c;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	for(int i = 1;i <= n;++i){
		if(!visited[i]){
			++ans;
			dfs(i);
		}
	}
	cout << ans << '\n';
}


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

int main() {
  int x;
  cin >> x;
  int box[4][3][10]={{{}}};
  int a,b,c,y;
  for(int i=0; i<x; i++){
    cin >> a >> b >> c >> y;
    a=a-1;
    b=b-1;
    c=c-1;
    box[a][b][c]+=y;
  }
  string z="####################";
  for(int j=0; j<4; j++){
    for(int k=0; k<3; k++){
      for(int l=0; l<10;l++){
        cout << ' ' << box[j][k][l];
      }
      cout << endl;
    }
    if(j!=3)
    cout << z << endl;
  }
}



Measured memory_bytes: 3104
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
const long long int N = 6999999;
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m,ans = 0;
  cin >> n >> m;
  vector<pair<int,int>>v(m);
  for (int i = 0; i < m; ++i)
  {
    int a,b;
    cin >> a >> b;
    v[i].ff = a;
    v[i].ss = b;
  }
  sort(v.begin(),v.end());
  int l = v[0].ff,r = v[0].ss;
  for (int i = 1; i < m; ++i)
  {
    l = v[i].ff;
    if(v[i].ss < r)
      r = v[i].ss;
    if (l > r)
    {
      cout << "0\n";
      return 0;
    }
  }
  ans = r-l+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int n, p, last;
  while (true) {
    bool is_first = true;
    int first = -1;
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> p;
      if (first < 0) {
        first = last = p;
      } else if (p == last + 1) {
        ++last;
      } else {
        if (not is_first) {
          cout << ' ';
        }
        if (first == last) {
          cout << first;
        } else {
          cout << first << "-" << last;
        }
        is_first = false;
        first = last = p;
      }
    }
    if (not is_first) {
      cout << ' ';
    }
    if (first == last) {
      cout << first;
    } else {
      cout << first << "-" << last;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    if (m<n){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 35776
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  Int n;cin >> n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++){
    cin >> a[i];
    a[i]-=(i+1);
  }
  sort(a.begin(),a.end());
  Int kizyun = a[n/2];
  Int sum = 0;
  for(auto &i:a){
    sum+=abs(i-kizyun);
  }
  cout << sum << endl;
}


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

int main() {
    long long N;
    cin >> N;
    vector<long long> a(N);
    rep(i, N) {
        cin >> a[i];
    }
    long long cnt = 1;
    long long now = 0;
    while (true) {
        if (a[now] == 2) {
            cout << cnt << endl;
            return 0;
        }
        now = a[now] - 1;
        cnt += 1;
        if (cnt > N + 100) {
            break;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1024
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let n: i32 = s.parse().unwrap();

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let m: Vec<i32> = {
        let mut m : Vec<i32> = vec![];
        let mut ws = s.split_whitespace();
        while let Some(_m) = ws.next() {
            m.push(_m.parse().unwrap())
        }
        m
    };

    let mut res = 0;
    for i in 0..(n as usize) {
        for j in (i+1)..(n as usize){
            res += m[i]*m[j]
        }
    }
    println!("{}", res);
}


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

int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0,ans=0;
	//string s;
	cin >> a;
	d = 1;
	for ( b = 2; b < a; b++)
	{
		c = b;
		while(1)
		{
			c *= b;
			if (c>a)
			{
				break;
			}
			if (c>d)
			{
				d = c;
			}

		}
	}
	cout << d << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   int n;cin>>n;
   cout<<(10000-n)%1000<<endl;
}


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

#define INF 2000000
#define MOD 1000000007
#define rep(i, N) for(int i = 0;i < N;i++)
#define ll long long

using namespace std;

int main(void) {
	int A, B, M; cin >> A >> B >> M;
	vector<int> a(A), b(B);
	int ans = INF;

	int mina = INF, minb = INF;
	rep(i, A) {
		cin >> a[i];
		mina = min(mina, a[i]);
	}
	rep(i, B) {
		cin >> b[i];
		minb = min(minb, b[i]);
	}
	ans = min(ans, mina + minb);

	rep(i, M) {
		int x, y, c; cin >> x >> y >> c;
		x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
 
int d, g;
int p[11], c[11];
int sum;
 
int dfs(int i, int k, int s, int x){
    if(i == d - 1){
        if(g <= x + p[k] * 100 * k){
            if(g <= x){
                return s;
            }
            else{
                return s + (g - x - 1) / (100 * k) + 1;
            }
        }
        else{
            return sum;
        }
    }
    else if(i < k - 1){
        return min(dfs(i + 1, k, s, x), dfs(i + 1, k, s + p[i + 1], x + p[i + 1] * 100 * (i + 1) + c[i + 1]));
    }
    else{
        return min(dfs(i + 1, k, s, x), dfs(i + 1, k, s + p[i + 2], x + p[i + 2] * 100 * (i + 2) + c[i + 2]));
    }
}
 
int main()
{
    cin >> d >> g;
    for(int i = 1; i <= d; i++){
        cin >> p[i] >> c[i];
    }
    sum = 0;
    for(int i = 1; i <= d; i++){
        sum += p[i];
    }
    int ans = 100000000;    
    for(int k = 1; k <= d; k++){
        ans = min(ans, dfs(0, k, 0, 0));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long int N, M, A[100001]={}, B[100001]={}, sum_A=0, sum_B=0;
    cin >> N >> M;
    
    for(int i=1; i<=N; i++){
        cin >> A[i];
        sum_A += A[i];
    }
    
    for(int j=1; j<=M; j++){
        cin >> B[j];
        sum_B += B[j];
    }
    cout << sum_A * sum_B << endl;
    return 0;
}



Measured memory_bytes: 4656
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ss = sc.next();
		String[] s = ss.split("");
		int count = 0;
		for (int i = 0; i < n - 1; i++) {
			if (s[i].equals(s[i + 1])) {
				s[i] = "null";
			}
		}
		for (int i = 0; i < n; i++) {
			if (!s[i].equals("null")) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 32396
#include <stdio.h>

#define MAX 101

int main(){
  int i=0,j=0;;
  int n;
  int M[MAX][MAX];
  int u;
  int k;
  int v;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      M[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      M[u][v]=1;
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=2e5+10;
const ll mod=20180623;
int main(){
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n%x==0?n/x*t:(n/x+1)*t);
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
// #define mdfs
int N,M;

int main(void){
    // Your code here!
    cin >> N;
    int lt,lx,ly;
    lt = 0;lx = 0; ly = 0;
    for (int i = 0; i < N; i++) {
        int t,x,y;
        cin >> t >> x >> y;
        if ((t - lt) < (abs(x-lx) + abs(y-ly))) {
            // cout << t << endl;
            cout << "No" << endl;
            return 0;
        }
        
        if (((t - lt) % 2) != (((abs(x-lx) + abs(y-ly)) % 2))) {
            cout << "No" << endl;
            return 0;
        }
        
        lt = t;
        lx = x;
        ly = y;
        
    }
    
    cout << "Yes" << endl;

}


Measured memory_bytes: 256
H, W, A, B = map(int, input().split())
h = {}
p = 10**9+7
q = p - 2
for x in range(H+W-1):
    if h.get(x-1):
        a = (x * h[x-1][0]) % p
    else:
        a = 1
    b = pow(a,q,p)
    h[x] = (a,b)

def C(n, r):
    return h[n][0] * h[r][1] * h[n-r][1]

ans = 0
for i in range(B, W):
    ans += C(i+H - A - 1, i) * C(W - 1 - i + A - 1, W - 1 - i)

print(ans % p)

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b)*c/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<sstream>
#include<algorithm>
#include<set>
using namespace std;

int main()
{
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		int N;
		cin >> N;
		int count = 0;
		set<int> intSet;
		while (N > 9 && intSet.find(N) == intSet.end())
		{
			intSet.insert(N);
			count++;
			string s;
			stringstream strStream;
			strStream << N;
			s = strStream.str();
			int maxV = 0;
			for (int i = 1; i < s.size(); i++)
			{
				string ss = s.substr(0, i);
				string sss = s.substr(i, s.size());
				int ii = atoi(ss.c_str());
				int iii = atoi(sss.c_str());
				maxV = max(maxV, ii * iii);
			}

			N = maxV;
		}
		if (intSet.find(N) != intSet.end())
		{
			cout << -1 << endl;
		}
		else
		{
			cout << count << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

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

int n;
int arr[200005];

bool can(int i){
	if (i==0) return false;
	
	vector<ii> v; //pos and value
	
	rep(x,1,n){
		if (arr[x-1]>=arr[x]){
			if (i==1) return false;
			while (!v.empty() && v.back().fi>arr[x]) v.pop_back();
			
			int curr=arr[x];
			while (true){
				if (curr==0) return false;
				if (v.empty() || v.back().fi!=curr){
					v.push_back(ii(curr,1));
					break;
				}
				else{
					v.back().se++;
					if (v.back().se==i){
						curr--;
						v.pop_back();
					}
					else{
						break;
					}
				}
			}
		}
	}
	
	return true;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	rep(x,0,n) cin>>arr[x];
	
	int lo=0,hi=200005,mi;
	while (hi-lo>1){
		mi=hi+lo>>1;
		
		if (can(mi)) hi=mi;
		else lo=mi;
	}
	
	cout<<hi<<endl;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int x;
        cin >> x;
        mp[x]++;
    }

    int ans = 0;
    int even = 0;
    for (auto p : mp) {
        ans++;
        if (p.second % 2 == 0) even++;
    }

    cout << ans - (even % 2) << endl;
    
}


Measured memory_bytes: 6528
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    e = sum(i%K!=0 and i*2%K==0 for i in range(1, N+1))
    z = sum(i%K==0 for i in range(1, N+1))
    return pow(e, 3) + pow(z, 3)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(N, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9184
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a;
	cin >> a;
	cout << 48-a << endl;
	//printf((a>b) ? "Alice\n" :(a==b)?"Draw\n": "Bob\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,a,sum=0;
    vector<lli> data;
    map<lli,lli> map;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        data.push_back(a);
        map[a]++;
    }
    for(auto itr=map.begin();itr!=map.end();itr++){
        sum+=(itr->second)*(itr->second-1)/2;
    }
    rep(i,0,n){
        cout<<sum-(map[data[i]]-1)<<endl;
    }
}


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

int main(){
    int ans=1,b,N,K;
    cin>>N>>K;

    for(int i=0;i<N;i++){
        if(ans*2<ans+K){
            ans=ans*2;
        }else{
            ans=ans+K;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256