akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>
#include <stdio.h>

int YMD(int y,int m,int d){
	int ret = 0,i=0;
	ret = (y - 1) * 195;
	ret += 5 * (((y - 1) - (y - 1) % 3) / 3);
	if (y % 3 == 0){
		ret += (m-1) * 20;
	}
	else{
		for (i = 1; i < m; i++)
		{
			ret += 19 + (i % 2);
		}
	}
	ret += d;
	return ret;
}
int main(){
	int n=0,y,m,d,mil,f=0;
	//read data set kazu
	scanf("%d",&n);
	mil = YMD(1000,1,1);
	while (scanf("%d %d %d", &y, &m, &d) != EOF && f!=n){
		printf("%d\n",mil - YMD(y, m, d) );
		f++;
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define mxx 100005
#define endl "\n"
const ll mod=1e9+7;

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

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

    int p=0,ans=0;
    for(int i=0; i<n; i++)
    {
        ll x;
        cin>>x;
    }

    for(int i=0; i<n; i++)
    {
        p++;
        if(p==k)
        {
            ans++;
            p=0;
            if(i==n-1)
                break;
            i--;
        }
    }
    if(p)
        ans++;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let i, ans = ref 0, ref 0
let _ = while !i < n do if ps.(!i) = !i + 1 then (incr i; incr ans); incr i done; Printf.printf "%d\n" !ans

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
ll f[N];
int n, m;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1, w, v; i <= n; i++) {
        scanf("%d%d", &w, &v);
        for (int j = m; j >= w; j--) f[j] = max(f[j], f[j - w] + v);
    }
    printf("%lld\n", f[m]);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	
	string ans = "Yes";
	string pre = to_string(a) + to_string(b);
	double d = sqrt(atoi(pre.c_str()));
	d -= (int)d;
	if(d > 0.0) ans = "No";
	cout << ans << endl;
}




Measured memory_bytes: 256
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
ABCD = input().rstrip()

from itertools import product
ops = list(product(["+","-"],repeat=3))

x = [0]*7
for op in ops:
    x[0::2] = ABCD
    x[1::2] = op
    exp = "".join(x)
    if eval(exp)==7:
        print(exp+"=7")
        sys.exit()

Measured memory_bytes: 3064
open Batteries
open Printf
let () =
  let n,k = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let d_l = Array.to_list @@ Array.init k (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let rec digits base n res =
    if n = 0 then res 
    else digits base (n/base) ((n mod base)::res)
  in

  let intersection xs ys =
    List.fold_left (fun a b -> if List.mem b ys then (b::a) else a) [] xs
  in

  let rec aux n =
    let i_l = digits 10 n [] in
    if intersection i_l d_l = [] then
      n
    else aux (n+1)
  in

  Printf.printf "%d\n" @@
  aux n


Measured memory_bytes: 3072
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; i++)

int n, k, m, r;
int a[20000];

void div(int x, int y){
	rep(i,20000){
		a[i] += x/y;
		x %= y;
		x *= 10;
	}
}

int main(){
	while(scanf("%d%d%d%d", &n, &k, &m, &r),n||k||m||r){
		rep(i,20000) a[i] = 0;
		if(m == 0){
			div(1,n);
			printf("%d.", a[0]);
			for(int i = 1; i < r+1; i++) printf("%d", a[i]);
			printf("\n");
		} else{
			div(1,n);
			for(int i = 1; i <= n-1; i++) div(1,i*n);
			for(int i = 15000; i > 0; i--){
				a[i-1] += a[i]/10;
				a[i] %= 10;
			}
			printf("%d.", a[0]);
			for(int i = 1; i < r+1; i++) printf("%d", a[i]);
			printf("\n");
		}
	}
}

Measured memory_bytes: 1108
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

char c;
int main(void){
    map<char, int> m;
    REP(i,4) {
        cin >> c;
        m[c]++;
    }

    for(auto it : m){
        if(it.second != 2){
            cout << "No" << endl;
            return 0;    
        }    
    }

    if(m.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

using namespace std;
void dfs(int i,vector<int>adj[],vector<bool>&vis,vector<int>&dp){

    vis[i]=1;
    for(int j=0;j<adj[i].size();j++){
        if(!vis[adj[i][j]])dfs(adj[i][j],adj,vis,dp);
        dp[i]=max(dp[i],1+dp[adj[i][j]]);
    }

}
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    vector<int>dp(n+1,0);
    vector<int>adj[n+1];
    for(int i=0;i<m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
    }

    vector<bool>vis(n+1,0);
    for(int i=1;i<=n;i++){
        if(!vis[i])dfs(i,adj,vis,dp);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12480
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n,a,b;
    scan(n,a,b);
    writeln(min(a*n, b));
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;cin>>N;
	vint A(N);rep(i,N)cin>>A[i],A[i]--;
	int ans=0;
	rep(i,N){
		int b;cin>>b;
		ans+=b;
	}
	rep(i,N-1){
		int c;cin>>c;
		int pos=find(all(A),i)-A.begin();
		if(pos+1<N&&A[pos+1]==i+1)ans+=c;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
//$s = trim(fgets(STDIN));
list($H,$A) = explode(" ",trim(fgets(STDIN)));
//$P = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));
//function chmax(&$a,$b) {if ($a<$b){$a=$b;return true;}return false;}
//function chmix(&$a,$b) {if ($a>$b){$a=$b;return true;}return false;}

if (($H % $A)==0)
  printf("%d\n",intdiv($H,$A));
else
  printf("%d\n",intdiv($H,$A)+1);


Measured memory_bytes: 4728
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC= [list(map(int, input().split()))]
for _ in range(1,Q):
    BC.append(list(map(int, input().split())))

num = [0]*10**5

#Aの要素の数を管理するリストnumを作成
for k in range(len(A)):
    num[A[k]-1] += 1

counter = 0 #Biと一致した要素の数
s = sum(A) #合計を初期化

for q in range(Q):
    counter = num[BC[q][0]-1]
    num[BC[q][1]-1] += counter #Ciの数に加える
    num[BC[q][0]-1]=0 #Biと等しい値を0個に
    s += (BC[q][1]- BC[q][0])*counter
    print(s)

Measured memory_bytes: 31984
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
typedef long long ll;
 
using namespace std;
 
int mo[5]={0,0,1,1,0};
char ch[4] = "JOI";
char in[1002][1002],flag[2][3];
int m,n,c=0,ans;
 
bool check(int i,int j){
    int check=0;
    for(int k=0;k<4;k++){
        if(in[i+mo[k]][j+mo[k+1]]==flag[mo[k]][mo[k+1]])
            check++;
    }
    if(check==4) return true;
     
    return false;
}
 
int main(){
     
    scanf("%d%d",&m,&n);
     
    for(int i=1;i<=m;i++){
        scanf("%s",&in[i][1]);
    }
     
    for(int i=0;i<2;i++){
        scanf("%s",flag[i]);
    }
     
     
    for(int i=1;i<m;i++){
        for(int j=1;j<n;j++){
            c+=check(i,j);
        }
    }
     
    ans=c;
     
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            char memo=in[i][j];
            int sc=0;
             
            for(int l=0;l<4;l++){
                sc+=check(i+mo[l]-1,j+mo[l+1]-1);
            }
             
            for(int k=0;k<3;k++){
                int cc=0;
                in[i][j]=ch[k];
                 
                for(int l=0;l<4;l++){
                    cc+=check(i+mo[l]-1,j+mo[l+1]-1);
                }
                ans=max(ans,c+cc-sc);
            }
             
            in[i][j]=memo;
        }
    }
     
    printf("%d\n",ans);
     
    return 0;
}

Measured memory_bytes: 2172
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        Set<Integer> list = new HashSet<>();
        list.add(sc.nextInt());
        list.add(sc.nextInt());
        list.add(sc.nextInt());

        System.out.println(list.size() == 2 ? "Yes" : "No");
    }
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

int main(void){
  int n,k; cin >> n >> k;
  int p[n];
  rep(i,n) cin >> p[i];
  sort(p,p+n);
  int ans = 0;
  rep(i,k){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int L, S;
  if (a >= b) {
    L = a;
    S = b;
  }
  else {
    L = b;
    S = a;
  }
  int ans;
  ans = 0;
  for (int i = 0; i < L; i++) {
    ans += S * pow(10, i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N, T, A; cin >> N >> T >> A;
	V<P<double,int>> H(N);
	REP(i, N) cin >> H[i].first;
	REP(i, N) H[i] = { T - H[i].first*0.006,i };
	REP(i, N) H[i] = { abs(H[i].first - A),i };
	sort(ALL(H));
	cout << H[0].second+1 << endl;

	return 0;
}



Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def prime_factorize(n):
    prime_fact = []
    while n%2 == 0:
        prime_fact.append(2)
        n//=2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime_fact.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime_fact.append(n)
    return prime_fact

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 divisors

if __name__ == "__main__":
    n = int(input())
    a = list(set(prime_factorize(n)))
    a.sort()
    cnt = 0
    for i in range(len(a)):
        e = 1
        while n%(a[i]**e) == 0:
            n = n//a[i]**e
            e += 1
            cnt+=1
    print(cnt)

Measured memory_bytes: 9656
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

#define sz(x) (int)(x).size()
typedef long long ll;
using namespace std;
const int mxN=3e5+5;
int t[mxN<<2];
int n,k;
int arr[mxN],dp[mxN];
vector<pair<int,int>> pmap;

void build(int v,int tl,int tr) {
    if(tl==tr) {
        t[v]=0;
        return;
    }
    int mid=tl+(tr-tl)/2;
    build(v<<1,tl,mid);
    build(v<<1|1,mid+1,tr);
    t[v]=max(t[v<<1],t[v<<1|1]);
}

int qry(int v,int tl,int tr,int l,int r) {
    if(tl>r || tr<l)
        return 0;
    if(tl>=l && tr<=r)
        return t[v];
    int mid=tl+(tr-tl)/2;
    return max(qry(v<<1,tl,mid,l,r),qry(v<<1|1,mid+1,tr,l,r));
}

void upd(int v,int tl,int tr,int pos,int val) {
    if(tl>pos || tr<pos)
        return;
    if(tl==tr && tl==pos) {
        t[v]=val;
        return;
    }
    int mid=tl+(tr-tl)/2;
    upd(v<<1,tl,mid,pos,val);
    upd(v<<1|1,mid+1,tr,pos,val);
    t[v]=max(t[v<<1],t[v<<1|1]);
}

int bsl(int val) {
    int l=0,h=n-1;
    int res=-1;
    while(l<=h) {
        int mid=l+(h-l)/2;
        if(pmap[mid].first>=val) {
            res=pmap[mid].second;
            h=mid-1;
        }
        else
            l=mid+1;
    }
    return res;
}

int bsh(int val) {
    int l=0,h=n-1;
    int res=-1;
    while(l<=h) {
        int mid=l+(h-l)/2;
        if(pmap[mid].first<=val) {
            res=pmap[mid].second;
            l=mid+1;
        }
        else
            h=mid-1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;
    pmap.assign(n,{0,0});
    for(int i=0; i<n; i++) {
        cin >> arr[i];
        pmap[i].first=arr[i];
        pmap[i].second=i;
    }
    sort(pmap.begin(),pmap.end());
    map<int,int> pos;
    for(int i=0; i<n; i++)
        pos[pmap[i].second]=i;
    dp[0]=1;
    build(1,0,n-1);
    upd(1,0,n-1,pos[0],1);
    for(int i=1; i<n; i++) {
        int l=bsl(arr[i]-k),h=bsh(arr[i]+k);
        int lo=n-1;
        if(l!=-1)
            lo=pos[l];
        int hi=0;
        if(h!=-1)
            hi=pos[h];
        int res=qry(1,0,n-1,lo,hi)+1;
        dp[i]=res;
        upd(1,0,n-1,pos[i],res);
    }
    int best=0;
    for(int i=0; i<n; i++)
        best=max(best,dp[i]);
    cout << best;

    return 0;
}


Measured memory_bytes: 26136
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

// nまでの数に対して素数か判定(ユークリッドの互除法)
void is_prime_cal(ll n, vector<bool> &is_prime) {
  vector<bool> tmp(n + 1, true);
  is_prime = tmp;
  for (ll i = 0; i <= n; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (ll j = 2; j * i <= n; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }
}

// nまでの素数を生成
void prime_gen(ll n, vector<ll> &prime) {
  vector<bool> is_prime(n + 1, true);
  is_prime_cal(n, is_prime);
  REP(i, n + 1) {
    if (is_prime[i]) prime.push_back(i);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  vector<ll> prime;
  prime_gen((ll)sqrt(min(a, b)), prime);
  ll ans = 1;
  for (auto p : prime) {
    if (a % p == 0 && b % p == 0) ans++;
    while (a % p==0) a /= p;
    while (b % p == 0) b /= p;
  }
  if (a == b&&a!=1) ans++;

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


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


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    ll money = 1000;
    ll kabu = 0;

    for (int i = 0; i < n-1; i++) {
        if (a.at(i) < a.at(i+1)) {
            kabu = money / a.at(i);
            money %= a.at(i);
            money += kabu * a.at(i+1);
            kabu = 0;       
        }
        //cout << money << " " << kabu << endl;
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define all(c) c.begin(), c.end()
#define sz(c) c.size()
#define rep(i,a,b) for(int i = a;i < b; ++i)
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;


struct Point{
	typedef Point P;
	double x,y;
	explicit Point(double x = 0, double y = 0) : x(x), y(y) {}
	P operator+(P p) const {return P(x+p.x, y+p.y);}
	P operator-(P p) const {return P(x-p.x, y-p.y);}
	P operator*(double d) const {return P(x*d, y*d);}
	P operator/(double d) const {assert(d != 0);return P(x/d, y/d);}
	double dist2() const {return x*x + y*y;}
	double dist() const {return sqrt(x*x + y * y);}
	P perp() const {return P(-y,x);}
	double cross(P p) const {return x*p.y - y*p.x;}
};

typedef Point P;

P ccCenter(const P& A, const P& B, const P& C){
	P b = C-A, c = B-A;
	return A + (b*c.dist2() - c*b.dist2()).perp()/b.cross(c)/2;
}

pair<P, double> mec(vector<P> ps){
	shuffle(all(ps), mt19937(time(0)));
	P o = ps[0];
	double r = 0, EPS = 1+1e-8;
	rep(i,0,sz(ps)){
		if((o - ps[i]).dist() > r * EPS){
			o = ps[i]	, r= 0;
			rep(j,0,i){
				if((o-ps[j]).dist() > r * EPS){
					o = (ps[i] + ps[j])/2;
					r = (o - ps[i]).dist();
					rep(k,0,j){
						if((o-ps[k]).dist() > r * EPS){
							o = ccCenter(ps[i],ps[j],ps[k]);
							r = (o - ps[i]).dist();
						}
					}
				}
			}
		}
	}
	return {o,r};
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<P> v(n);
	rep(i,0,n)cin >> v[i].x >> v[i].y;
	cout.precision(9);
	cout << mec(v).second << '\n';
}


Measured memory_bytes: 384
import math 

n=int(input())
x=list(map(int,input().split()))
a1=a2=0
g1,g2=math.ceil(sum(x)/n),math.floor(sum(x)/n)
for i in x:
    a1+=(i-g1)**2
    a2+=(i-g2)**2
print (min(a1,a2))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
ll g[2], s[2], b[2];
ll dp[5][25000010];

ll knap( const std::vector<ll> &w, const std::vector<ll> &v, ll W )
{
  rep( i, 5 ) rep( j, W+1 )
    dp[i][j] = 0;

  rep( i, 3 ) rep( j, W+1 )
  {
    if( j-w[i] >= 0 )
      chmax( dp[i+1][j], std::max( { dp[i+1][j-w[i]]+v[i], dp[i][j-w[i]]+v[i] } ) );

    chmax( dp[i+1][j], dp[i][j] );
  }

  ll ret = 0;

  rep( j, W+1 )
    chmax( ret, dp[3][j] );

  return W+ret;
}

int main()
{
  std::cin >> N;

  rep( i, 2 )
    std::cin >> g[i] >> s[i] >> b[i];

  ll M = knap( { g[0], s[0], b[0] }, { g[1]-g[0], s[1]-s[0], b[1]-b[0] }, N );

  ll ans = knap( { g[1], s[1], b[1] }, { g[0]-g[1], s[0]-s[1], b[0]-b[1] }, M );

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 976768
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

class UnionFind {
private:
    int sz;
    vector<int> par, size_,SIZE_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1),SIZE_(sz, 0){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
        SIZE_[x] += SIZE_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    int SIZE(int x){
        x = find(x);
        return SIZE_[x];
    }
    void add(int x){
        x = find(x);
        SIZE_[x]++;
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
int main(){
    int n,h,w;
    cin >> n >> h >> w;
    vector<int> a(h+1),b(w+1);
    priority_queue<pair<ll,pair<int,int> > >pq;
    rep(i,n){
        int s,t;
        ll p;
        cin >> s >> t >> p;
        pq.push(MP(p,MP(s,t)));
    }
    ll sm = 0;
    UnionFind uf(h+w+2);
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        int s = x.second.first;
        int t = x.second.second;
        if(uf.same(s,h+t)){
            if(uf.size(s)<uf.SIZE(s)+1){

            }else{
                sm += x.first;
                uf.add(s);
            }
        }else{
            if(uf.size(s)+uf.size(h+t)<uf.SIZE(s)+uf.SIZE(h+t)+1){

            }else{
                uf.unite(s,h+t);
                sm += x.first;
                uf.add(s);
            }
        }
    }

    cout << sm << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1000000000;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    ll h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h, h + n);
    ll ans = INF;
    for(int i=0;i+k-1<n;i++){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    s, w = rl()
    if s > w:
        print ("safe")
    else:
        print ("unsafe")






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


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

int main()
{
    int n;
    cin >> n;
    int res = 0;
    int f;
    for (int i = 1; i <= n; ++i)
    {
        cin >> f;
        if (i%2 != 0 and f%2 != 0)
            res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3564
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

string s;

int main()
{
    int n,cnt=0;
    cin>>n>>s;
    for(int i=0,j=n-1;i<j;i++,j--)
    {
        while(s[i]!='W' && i<j) i++;
        while(s[j]!='R' && i<j) j--;
        if(i<j) cnt++;
    }
    cout<< cnt <<endl;
    return 0;
}

Measured memory_bytes: 3756
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k, c = LI()
    s = S()
    ans = [inf]
    tmp = -inf
    for i in range(n - 1, -1, -1):
        if ans[-1] - c > i and s[i] == "o":
            ans.append(i)
            if len(ans) > k:
                break
    ans.remove(inf)
    ans.sort()
    if len(ans) != k:
        return
    t_ans = [0] * (n + 1)
    for i in range(n):
        if s[i] == "o" and tmp + c + 1 <= i:
            tmp = i
            t_ans[i+1] = t_ans[i] + 1
        else:
            t_ans[i+1] = t_ans[i]
    tt = []
    tmp = 0
    for tmp, ai in enumerate(ans):
        if ai == 0:
            tt.append(str(ai + 1))
            continue
        if t_ans[ai] == tmp:
            tt.append(str(ai + 1))
    print("\n".join(tt))




    return


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


Measured memory_bytes: 73836
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const ll P=1e9+7;

ll n,m,ans=1;

int main()
{
	cin>>n>>m;
	if(m-n>1||n-m>1)
	{
		cout<<0;
		return 0;
	}
	for(ll i=1;i<=n;i++)ans=(i*ans)%P;
	for(ll i=1;i<=m;i++)
		ans=(i*ans)%P;
	if(m-n==0)
	cout<<ans*2ll%P;
	else
	cout<<ans;
}


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

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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ans = 0;
  for(int i = 0; i <= n; ++i){
    for(int j = 0; j <= n; ++j){
      int ball = n - i * r - j * g;
      if(ball >= 0 && ball % b == 0){
        ans++;
      }
    }
  }

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 200005 ;
using namespace std ;

int n, a[N] ;

int main() {
    scanf("%d", &n) ;
    rep(i, 1, n) {
        scanf("%d", &a[i]) ;
    }
    int i ;
    for (i = n ; i ; i -= 2) {
        printf("%d ", a[i]) ;
        if (i == 1) break ;
    }
    for (++ i ; i <= n ; i += 2) {
        printf("%d ", a[i]) ;
    }
    return 0 ;  
}

Measured memory_bytes: 2944
/**
 *  Hi, I'm Arpan.
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

/*******************************************/

void solve()
{
	int d;
	cin >> d;
	vl c(26);
	inv(c);
	ll s[d][26];
	for(int i=0;i<d;i++){
		for(int j=0;j<26;j++){
			cin >> s[i][j];
		}
	}
	vector<pair<ll,ll>> arr(26);
	for(int i=0;i<26;i++){
		arr[i].first = c[i];
		arr[i].second = i+1;
	}
	sort(arr.begin(),arr.end(),sortinrev);
	for(int i=0;i<d;i++){
		cout << arr[i%26].second << endl;
	}

}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    int t = 1;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3748
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)

x = []
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = -1
        x.append(a[i])
        if len(x) == 2:
            break

if len(x) == 2:
    print(x[0]*x[1])
else:
    print(0)


Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        int result = (int) Math.ceil(a / 0.08);
        if ((int) (result * 0.1) != b) {
            if ((int) (b * 10 * 0.08) == a) {
                result = b * 10;
            } else {
                result = -1;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//AtCoder Beginner Contest 132 - A B
int main() {
	char S[101010];
	scanf("%s", S);
	ll len = strlen(S);

	vll count(26);
	rep(i, len) {
		count[S[i] - 'A']++;
	}


	rep(i, 26) {
		if (count[i] != 0 && count[i] != 2) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
}


//AtCoder Beginner Contest 133 - A B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll D;
	scanf("%lld", &D);
	vvll X(N, vll(D, 0));
	rep(i, N) rep(j, D) {
		ll x;
		scanf("%lld", &x);
		X[i][j] = x;
	}

	ll result = 0;

	reps(i, 0, N - 1) {
		reps(j, i + 1, N - 1) {
			ll d2 = 0;
			rep(k, D) {
				ll sub = X[i][k] - X[j][k];
				d2 += sub * sub;
			}

			rep(k, 16000) {
				if (k * k == d2) {
					result++;
					break;
				}
			}
		}
	}

	printf("%lld\n", result);
}
*/

/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = min(A * N, B);

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 134 - A B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll D;
	scanf("%lld", &D);

	ll result = (ll)ceil((double)N / (1 + D * 2));

	printf("%lld\n", result);
}
*/

/*
int main() {
	ll r;
	scanf("%lld", &r);

	ll result = 3 * r * r;

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 135 - B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> p(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &p[i]);
	}

	ll err = 0;
	rep(i, N) {
		if (p[i] != i + 1) {
			err++;
		}
	}

	if (err <= 2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}
*/

//AtCoder Beginner Contest 135 - A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	if (abs(A - B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
		return 0;
	}

	ll ans = abs(A - B) / 2;
	ll result = min(A, B) + ans;

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 126 - B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll front = (s[0] - '0') * 10 + (s[1] - '0');
	ll back = (s[2] - '0') * 10 + (s[3] - '0');

	if ((front > 12 && back > 12) || (front > 12 && back == 0) || (back > 12 && front == 0) || (back == 0 && front == 0)) {
		printf("NA\n");
	}
	else if (front > 12 || front == 0) {
		printf("YYMM\n");
	}
	else if (back > 12 || back == 0) {
		printf("MMYY\n");
	}
	else {
		printf("AMBIGUOUS\n");
	}
}
*/

//AtCoder Beginner Contest 126 - A
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}
*/

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		long k=s.nextLong();

		final int n=50;
		long[]r=IntStream.range(0,50).mapToLong(i->49-i).toArray();

		for(int i=0;i<n;i++)
			r[i]+=k/n;
		k%=n;

		for(int i=0;i<n&&k>0;i++) {
			++r[i];
			--k;
		}

		System.out.println(n);
		System.out.println(Arrays.stream(r).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
	}
}


Measured memory_bytes: 29140
#include <stdio.h>

static const short MAX  = 10;
static const short TOP3 = 3;

int main(int argc, char *argv[]) {
  short cnt = 0;
  short i, j;
  int heights[MAX];

  for(; cnt < MAX; ++cnt) {
    scanf("%d", &heights[cnt]);
  }

  {
    int temp;
    for(i = 0; i < MAX; ++i) {
      for(j = i + 1; j < MAX; ++j) {
        if(heights[i] < heights[j]) {
          temp = heights[i];
          heights[i] = heights[j];
          heights[j] = temp;
        }
      }
    }
  }

  for(cnt = 0; cnt < TOP3; ++cnt) {
    printf("%d\n", heights[cnt]);
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
ll dp[200003][3];
vector<int>v[200003];
bool vis[200003][3];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    int s,t;
    cin>>s>>t;
    queue<pair<int,int> > q;
    memset(dp,0x7f,sizeof dp);
    dp[s][0] = 0;
    vis[s][0] = true;
    q.push({s,0});
    while(!q.empty()){
        int x = q.front().first;
        int r = q.front().second;
        q.pop();
        for(int y:v[x]){
            if(vis[y][(r+1)%3])continue;
            vis[y][(r+1)%3] = true;
            dp[y][(r+1)%3] = min(dp[y][(r+1)%3],dp[x][r]+1);
            q.push({y,(r+1)%3});
        }
    }
    if(!vis[t][0]){
        cout<<-1<<endl;
        return;
    }
    cout<<dp[t][0]/3<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 13056
#include <cstdlib>
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

template <typename T> class Heap{
  struct node_t{
    T val;
    int dep;
    node_t *l;
    node_t *r;

    node_t(T _val) : val(_val), dep(0), l(NULL), r(NULL){}
    ~node_t(){
      if(l != NULL) delete l;
      if(r != NULL) delete r;
    }
  };

  node_t *root;

  node_t *meld(node_t *a, node_t *b){
    if(a == NULL) return b;
    if(b == NULL) return a;
    if(a->val < b->val) swap(a, b);
    a->r = meld(a->r, b);
    if(a->l == NULL || a->l->dep < a->r->dep) swap(a->l, a->r);
    a->dep = (a->r == NULL ? 0 : a->r->dep) + 1;
    return a;
  }
  
public:
  Heap() : root(NULL) {}
  ~Heap() { delete root; }
  
  void meld(Heap &h){
    root = meld(this->root, h.root);
  }
  
  void insert(T val){
    root = meld(this->root, new node_t(val));
  }
  
  T min_element(){
    return root->val;
  }

  T pop(){
    T ret = min_element();
    root = meld(root->l, root->r);
    return ret;
  }
  
  bool empty(){
    return root == NULL;
  }
};

int main(){
  char com[10];
  int n;

  Heap<int> heap;
  
  while(scanf("%s", com) && com[2] != 'd'){
    if(com[0] == 'i'){
      scanf("%d", &n);
      heap.insert(n);
    }else{
      cout << heap.pop() << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 48080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[200010],ans=0,n,x=0,y=0;
int main()
{
    scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1,j=1;i<=n;i++)
    {
		x^=a[i];
		y+=a[i];
		while(x!=y){
			x^=a[j];
			y-=a[j];
			j++;
		}
		ans+=i-j+1;
	}
    printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())

p = 10 ** 9 + 7
s = 0


for r in range(k, n + 2):
    min_val = (r - 1) * r // 2
    max_val = (n - r + 1 + n) * r // 2
    s += (max_val - min_val + 1)
    s %= p

print(s)



Measured memory_bytes: 63644
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string S,T;
	cin >> S >> T;
	int count = 0;
	FOR(i,0,3){
		if(S[i]==T[i])
			count++;
	}
	cout << count << endl;

	return 0;
}



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

#define loop(i,n) for(int i=1;i<=n;i++)
bool chizu[102][204];
bool soto[102][204];
int w,h;

int dfs(int pi,int pj){
  int d[5]={0,-1,0,1,0};
  loop(e,4){
    int qi=pi+d[e-1];
    int qj=pj+d[e];
    if(soto[qi][qj])continue;
    if(0<=qi&&qi<=h+1&&0<=qj&&qj<=w*2+2&&!chizu[qi][qj]){
      soto[qi][qj]=1;
      dfs(qi,qj);
    }
  }
  return 0;
}

int main() {
  bool temp;
  cin>>w>>h;
  loop(i,h)loop(j,w){
    cin>>temp;
    chizu[i][j*2+(i&1)-1]=temp;
    chizu[i][j*2+(i&1)]=temp;
  }
  dfs(0,0);
  int sum=0;
  loop(i,h)loop(j,w*2+1){
    if(soto[i][j])continue;
    int d[5]={0,-1,0,1,0};
    loop(e,4){
      if(soto[i+d[e-1]][j+d[e]])sum++;
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> X >> Y;
    int s[210] = {0};
    s[0] = 300000, s[1] = 200000, s[2] = 100000;
    X--, Y--;
    if (X == 0 && Y == 0) {
        ans += 400000;
    }
    ans += s[X] + s[Y];
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
pS = [[i for i in map(str,input().split())] for j in range(m)]
acd = [False for i in range(n)]
WA = [0 for i in range(n)]

for i in range(m):
  if pS[i][1]=="AC":
    acd[int(pS[i][0])-1]=True
  if acd[int(pS[i][0])-1]==False and pS[i][1]=="WA":
    WA[int(pS[i][0])-1] += 1

acds = sum(acd)
WAs = sum([WA[i] for i in range(n) if acd[i]==True])
print(str(acds) + ' ' + str(WAs))

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

int mod=1e9+7;
int nPr(int n,int r,int m){
    if(r==0)return 1;
    int ret=1;
    for (int i=0;i<r;i++){
        ret=(ret*(n-i)%m)%m;
    }
    return ret;
}

int inv(int i,int m){
    if(i==1)return 1;
    int ret;
    ret=m-((m/i)*inv(m%i,m))%m;
    return ret;
}

int nCr(int n,int r,int m){
    r=min(r,n-r);
    if(r==0)return 1;
    return (nPr(n,r,m)*inv(nPr(r,r,m),m))%m;
}

int nHr(int n,int r,int m){
    return nCr(n+r-1,r,m);
}

signed main(){
    int n,m;cin >>n >>m;
    set<pair<int,int>> s;
    int tmp=m;
    for(int i=2;i<=m;i++){
        int cnt=0;
        while(tmp%i==0){
            tmp/=i;
            cnt++;
        }
        if(cnt>0)s.insert(make_pair(i,cnt));
        if(tmp==1)break;
    }
//    for(auto&& w:s)cout<<w.first<<" "<<w.second<<endl;
    int ans=1;

    // for(auto&& w:s){
    //     int a=nPr(n+w.second-1,w.second,mod);
    //     int b=nPr(w.second,w.second,mod);
    //     int c=inv(b,mod);
    //     int d=(a*c)%mod;
    //     cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    //     cout<<w.first<<" "<<w.second<<" "<<nHr(n,w.second,mod)<<endl;
    // }

    for(auto&& w:s)ans=(ans*nHr(n,w.second,mod))%mod;
    cout<<ans<<endl;

}


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

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, init;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0)
        {
            init = i;
        }
    }
    for(int cx = 0; cx < 101; cx++)
    {
        for(int cy = 0; cy < 101; cy++)
        {
            bool flag = 1;
            int H = h[init] + abs(x[init] - cx) + abs(y[init] - cy);
            for(int i = 0; i < n; i++)
            {
                if(h[i] != 0 && h[i] + abs(x[i] - cx) + abs(y[i] - cy) != H)
                {
                    flag = 0;
                    break;
                }
                if(h[i] == 0 && H - abs(x[i] - cx) - abs(y[i] - cy) > 0)
                {
                    flag = 0;
                    break;
                }
            }
            if(flag)
            {
                cout << cx << ' ' << cy << ' ' << H;
            }
        }
    }

    return 0;
}


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

namespace AtCoder
{
    class Modulo
    {
        public readonly int M = 1000000007;
        private readonly int[] m_facs;
        public Modulo(int n)
        {
            m_facs = new int[n + 1];
            m_facs[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                m_facs[i] = (int)(Math.BigMul(m_facs[i - 1], i) % M);
            }
        }
        public int Fac(int n)
        {
            return m_facs[n];
        }
        public int Pow(int a, int m)
        {
            switch (m)
            {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                long p2 = Math.BigMul(p1, p1) % M;
                return (int)(((m & 1) == 0) ? p2 : p2 * a % M);
            }
        }
        public long Ncr(int n, int r)
        {
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            long res = Fac(n);
            res *= Pow(Fac(r), M - 2);
            res %= M;
            res *= Pow(Fac(n - r), M - 2);
            res %= M;
            return res;
        }
    }

    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int H, int W, int A, int B)
        {
            var modulo = new Modulo(H + W);
            Func<int, int, long> Path = (x, y) => modulo.Ncr(x + y, x);
            long sum = 0;
            for (int x = B; x < W; ++x)
            {
                sum += Path(x, H - A - 1) * Path(W - x - 1, A - 1);
                sum %= MODULO;
            }
            return sum;
        }
        static void Main(string[] args)
        {
            int[] v = ReadInts();
            Console.WriteLine(Solve(v[0], v[1], v[2], v[3]));
        }
    }
}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define sz(a) int((a).size())

int a[3], k;

signed main()
{
	IOS;
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	cin >> k;
	sort(a, a+3);
	int ans = a[0]+a[1];
	for (int i = 0; i < k; i++) 
		a[2] *= 2;
	cout << ans + a[2] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a;
    scanf("%d",&a);
    if(a>=195) printf("5\n");
    else if(a>=189) printf("4\n");
    else if(a>=165) printf("3\n");
    else if(a>=135) printf("2\n");
    else if(a>=105) printf("1\n");
    else printf("0");

    return 0;
}


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

using namespace std;

int sum[1000000];
int main(){
    int m;
    cin >> m;
    int a;
    for(int i=2;i<=m;i++){
       cin >> a;
       sum[a]+=1;
    }   
    for(int i=1;i<=m;i++){
       cout << sum[i] << endl;
     }
    return 0;
}

Measured memory_bytes: 4308