akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 100000000000000;

using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

int dfs(int x, vi *v, vi &vis)
{
    vis[x]=1;
    int cnt=0;
    trav(y,v[x])
    {
        if(vis[y])
            continue;
        cnt+=dfs(y,v,vis);
    }
    return cnt+1;
}

void solve()
{
    int n, m;
    cin>>n>>m;
    vi v[n+1];
    repu(i,1,m)
    {
        int x, y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    vi vis(n+1,0);
    int mx=0;
    repu(i,1,n)
    {
        if(!vis[i])
        {
            mx=max(mx,dfs(i,v,vis));
        }
    }
    cout<<mx<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  int N = SZ(S);
  VI cnt(N+1);
  REP(i,N) cnt[i+1] = cnt[i] + (S[i]=='1');

  int ans = 1;
  for(int k=1;k<=N;++k){
	if(N >= 2*k)
	  ans = k;
	else if(cnt[k] - cnt[N-k] == 0 || cnt[k] - cnt[N-k] == 2*k-N)
	  ans = k;
	else
	  break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

ll N;

#define MOD 1000000007LL

int main()
{

  cin >> N;

  switch(N%10) {
  case 2: case 4: case 5: case 7: case 9: printf("hon\n"); break;
  case 0: case 1: case 6: case 8: printf("pon\n"); break;
  case 3: printf("bon\n"); break;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    vector<int> b(n+1);
    for(int i = n;i>n/2;i--){
        b[i]=a[i];
    }

    for(int i=n/2;i>=1;i--){
        int j=2;
        int m=0;
        while(j*i<=n){
            m += b[j*i];
            j++;
        }
        if(m%2==a[i]){//もう一致してる  
            b[i]=0;
        }
        else{
            b[i]=1;
        }
    }
    int M=0;
    vector<int> ans;
    for(int i=1;i<=n;i++){
        //cout<<b[i]<<" ";
        if(b[i]==1){
            M++;
            ans.push_back(i);
        }
    }
    cout<<M<<endl;
    if(M!=0){
        rep(i,M-1){
            cout<<ans[i]<<" ";
        }
        cout<<ans[M-1]<<endl;
    }

}

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

int main() {
    string s;
    cin >>s;
    int bw = 0, wb = 0;
    for (int i = 0; i < s.size(); i+=2) {
        if (s.at(i)=='0') wb++;
        if (s.at(i)=='1') bw++;
    }
    for (int i = 1; i < s.size(); i+=2) {
        if (s.at(i)=='0') bw++;
        if (s.at(i)=='1') wb++;
    }
    cout << min(bw, wb) << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if(2 * max(max(a, b), c) == a + b + c)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Char
import qualified Data.Sequence as S

main = do
    [n, k] <- map read <$> words <$> getLine
    s      <- getLine
    putStrLn $ show $ solve n k s

solve :: Int -> Int -> String -> Int
solve n k s = doit 1 (S.fromList $ replicate (k * 2 + 1) 0) 0 s
  where
    doit :: Int -> (S.Seq Int) -> Int -> String -> Int
    doit d l p []        = length s - S.index l 0
    doit 0 l p ('1' : t) = max (p - S.index l 0) (doit 1 (l          S.|> p) (p + 1) t)
    doit 1 l p ('0' : t) = max (p - S.index l 0) (doit 0 (S.drop 2 l S.|> p) (p + 1) t)
    doit d l p ( _  : t) = doit d l (p + 1) t

Measured memory_bytes: 11004
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int sum = 0;
        int count = n;
        int[] m = new int[n];
        for (int i = 0; i < n; i++) {
            m[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            sum += m[i];
        }
        x -= sum;
        Arrays.sort(m);
        count += x / m[0];
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
//typedef pair<ll,ll> P;
typedef complex<double> P;
double toRad(double agl){return agl*M_PI/180.0;}
double D(P a, P b) {
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}
P rotate(P a, double r){return P(a.real()*cos(r)-a.imag()*sin(r),a.real()*sin(r)+a.imag()*cos(r));}

void Main() {
  ll a,b,h,m;
  cin >> a >> b >> h >> m;
  P p=P(0,b),q=P(0,a);
  p=rotate(p,toRad(360.0*((double)m/60)));
  q=rotate(q,toRad(360.0*((double)(h*60+m)/720)));
  pd(D(p,q));
}

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


Measured memory_bytes: 4116
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i,j,N,mi;
  string s;cin>>s;
  N=s.size();
  vector<string> v={"maerd","remaerd","esare","resare"};
  while(N){
    mi=0;
    rep(i,4){
      rep(j,v[i].size()){
        if(s[N-1-j]!=v[i][j])break;
      }
      mi+=(j==v[i].size())*v[i].size();
    }
    if(mi){
      N-=mi;
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 512
S = input()
T = input()
maxCount = len(T)
for i in range(len(S)-len(T)+1):
    countNotEqual = 0
    for j in range(len(T)):
        if S[j+i] != T[j]:
            countNotEqual += 1
    if countNotEqual < maxCount:
        maxCount = countNotEqual
print(maxCount)

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

int main()
{
  int a,b;
  bool cf=false;
  for(;cin>>a>>b,a||b;)
    {
      if(cf)
	cout<<endl;
      cf=true;
      bool c=true;
      for(;a<=b;a++)
	{
	  if(a%4==0 && (a%100!=0 || a%400==0))
	    {
	      cout<<a<<endl;
	      c=false;
	    }
	}
      if(c)
	cout<<"NA"<<endl;

    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
long long int gcd(long long int a,long long int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
 
long long int lcm(long long int a, long long int b)
{
   return a * b / gcd(a, b);
}
int main() {
  long long int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e=b-a+1;
  f=lcm(c,d);
  e=e-(b/c-a/c)-(b/d-a/d)+(b/f-a/f);
  if(a%c==0||a%d==0)e--;
  cout<<e;
}

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

public class MainApp
{

	static public void Main()
	{

		long[] NK = Arrayint();

		long ans1 = NK[0] % NK[1];
		long ans2 = NK[1] - ans1;
		long ans = 0;
		if(ans1 > ans2)
		{
			ans = ans2;
		}
		else
		{
			ans = ans1;
		}

		Console.WriteLine(ans);
	

	}


	private static string[] Arraystring()
	{
		return Console.ReadLine().Split(' ');
	}

	private static string Onestring()
	{
		return Console.ReadLine();
	}

	private static int Oneint()
	{
		return int.Parse(Console.ReadLine());
	}

	private static long[] Arrayint()
	{
		return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
	}
}



Measured memory_bytes: 13268
#include<iostream>
using namespace std;
char a[16], b[16] = {'C', 'O', 'D', 'E', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L', '2', '0', '1', '6'};
int ans;
int main(){
    cin >> a;
    for(int i = 0; i < 16; i ++)
        if(a[i] != b[i]) ans ++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] NAB = readln.chomp.split.to!(int[]);
  int N = NAB[0],
      A = NAB[1],
      B = NAB[2];
  int ans;

  foreach (i; 1..(N+1)) {
    int t = i.to!(string).split("").to!(int[]).sum;
    if (A <= t && t <= B) {
      ans += i;
    }
  }

  writeln(ans);
}


Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<iomanip>
#include<stdio.h>
#include<sstream>

using namespace std;

int main(void){
	long N;
	long count = 0;
	int ans = 0;
	string s;

	cin >> s;
	for(int i =0; i < 4; i++){
		if(s.at(i) == '+'){
			ans++;
		}else{
			ans--;	
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int N;
   int ans = 0;
   cin >> N;

       for (int i = 1; i <= N; i += 2){
           int count = 0;
           for (int j = 1; j <= i; j++){
               if (i % j == 0){
                   ++count;
               }
           }
        if (count == 8){
            ++ans;
        }
       }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15)<<

signed main(){
    string s; cin >> s;
    int n=s.size();
    int res=(n)*(n-1)/2+1;
    map<char,int> map;
    rep(i,n) map[s[i]]++;
    //rep(i,n) res-=map[s[i]]*(map[s[i]]-1)/2;
    for(int i='a'; i<='z'; i++){
        char c=i;
        //cout<<c<<' '<<map[c]<<endl;
        res-=map[c]*(map[c]-1)/2;
    }
    cout<<res<<endl;
    
}

Measured memory_bytes: 640
n, k = map(int, input().split())
ans = 0
MOD = 10**9+7
for i in range(k, n+2):
    
    maxim = (n + n - i + 1) * i // 2
    minim = (i - 1) * i // 2
    ans += (maxim - minim + 1)
    
ans %= MOD
print(ans)

Measured memory_bytes: 9176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	Rock = iota
	Scissors
	Paper
	FailRock
	FailScissors
	FailPaper
)

func main() {
	in := readLineInt()
	Count, Dup := in[0], in[1]

	in = readLineInt()
	RockP, ScissorsP, PaperP := in[0], in[1], in[2]

	Machine := readLine()
	ResultArray, Result := make([]int, Count), 0

	for i, M := range strings.Split(Machine, "") {
		var r int
		switch M {
		case "r":
			r = Paper
		case "s":
			r = Rock
		case "p":
			r = Scissors
		}

		if i-Dup >= 0 {
			if isFail(ResultArray[i-Dup]) {
				ResultArray[i] = r
			} else if ResultArray[i-Dup] == r {
				ResultArray[i] = getFail(r)
			} else {
				ResultArray[i] = r
			}
		} else {
			ResultArray[i] = r
		}
	}

	for _, v := range ResultArray {
		switch {
		case v == Rock:
			Result += RockP
		case v == Scissors:
			Result += ScissorsP
		case v == Paper:
			Result += PaperP
		case isFail(v):
			Result += 0
		}
	}

	fmt.Println(Result)
}

func isFail(i int) bool {
	return i == FailPaper || i == FailRock || i == FailScissors
}

func getFail(i int) int {
	switch i {
	case Rock:
		return FailRock
	case Scissors:
		return FailScissors
	case Paper:
		return FailPaper
	}
	return 0
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;


int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

vector<string> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int H, W;
bool seen[510][510];

void dfs(int h, int w)
{
    seen[h][w] = true;
    for (int dir = 0; dir < 4;dir++)
    {
            int nh = h + dx[dir];
            int nw = w + dy[dir];
        
        if(nh < 0|| nh >= H || nw < 0 || nw >= W){
            continue;
        }
        if(field[nh][nw] == '#'){
            continue;
        }
        if(seen[nh][nw]){
            continue;
        }
        dfs(nh, nw);
    }
}

int main()
{
    int N;
    cin >> N;
    set<ll> st;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        st.insert(A);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for i in range(N)]

dic = defaultdict(int)
for s in S:
    if s[0] in "MARCH":
        dic[s[0]] += 1

march = list("MARCH")
comb = list(combinations(march, 3))

ans = 0
for a, b, c in comb:
    ans += dic[a] * dic[b] * dic[c]
print(ans)






Measured memory_bytes: 11840
def wf(d):
    n = 10
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j] , d[i][k] + d[k][j])

    return(d)

H,W = map(int,input().split())

c = []
for i in range(10):
    c.append(list(map(int,input().split())))

A = {}
for i in range(H):
    for j in list(map(int,input().split())):
        if j == -1:
            continue
        if j not in A.keys():
            A[j] = 0
        A[j] += 1


d = wf(c)
ans = 0
for key in A.keys():
    if key != 1:
        ans += A[key]*d[key][1]

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
#define MAX 10010

char table [MAX];

void seive (void){
    int i,j;
    int k =sqrt(MAX);
    memset(table, 0, sizeof(table));
    table[0]=table[1]=1;
    for (i=2;i<=k;i++){
        if(table[i]==0){
            for(j=i+i;j<=MAX;j+=i){
                table[j]=1;
            }
        }
    }
}
int main(){
    seive();
    int i,j,k,n;
    while(cin>>n){
        j = 0;
        for(i=0;i<=n;i++){
            if(!table[i] && !table[n-i+1])j++;
        }
        cout << j << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include<iostream>
using namespace std;
long count[26];
long ncount[26];
main()
{
	int n;cin>>n;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		for(int j=0;j<26;j++)ncount[j]=0;
		for(int j=0;j<s.size();j++)ncount[s[j]-97]++;
		for(int j=0;j<26;j++)count[j]=i?count[j]<ncount[j]?count[j]:ncount[j]:ncount[j];
	}
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<count[i];j++)cout<<char(i+97);
	}
	cout<<endl;
}


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

int main(){
  long long a , b , c , x;
  cin >> a >> b >> c >> x;
  bool ans = false;

  for (int i = 0 ; i <= x ; i ++) {
    for (int j = 0 ; j <= x - i ; j ++) {
      for (int k = 0 ; k <= x - j ; k ++) {
        a *= pow(2 , i);
        b *= pow(2 , j);
        c *= pow(2 , k);
        if (a < b && b < c) {
          ans = true;
          goto fin;
        }
        a /= pow(2 , i);
        b /= pow(2 , j);
        c /= pow(2 , k);
      }
    }

  }
  fin:

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define N 2000009
#define pi pair<ll,ll>
using namespace std;
typedef long long ll;
map<ll,ll>m;
int main()
{
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    ll a[n+5];
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        ans+=m[i-a[i]];
        m[i+a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

Int n;

Int solve(int num, vector<Int> a){
    sort(All(a));
    //cout << num <<":";
    //REP(i,a.size())cout << a[i] << " ";
    return a[num];
}

int main(){
    cin >> n;

    vector<Int> x(n);
    REP(i,n)cin >> x[i];

    Int num=n/2;

    Int r=solve(num,x);
    Int l=solve(num-1,x);

    Int ans;
    for(Int i=0;i<n;i++){
        if(x[i]>l)ans=l;
        else ans=r;
        cout << ans << endl;
    }
}


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

int main() {
    ll n;
    cin>>n;
    string c;
    cin>>c;
    ll length = c.size();
    ll co = 0;
    rep(i,length){
        if(c[i]=='R'){
            co++;
        }
    }
    ll co2 = 0;
    rep(i,co-1){
        if(c[i]=='W'){
            co2++;
        }
    }
    ll co3 = 0;
    for(ll i = co;i < n;i++){
        if(c[i]=='R'){
            co3++;
        }
    }
    ll ans = max(co2,co3);
    cout<<ans<<endl; 
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
int main(){
    int n;
    cin >> n;
    map<string, int> data;
    string key;
    rep(i,n){
        cin >> key;
        data[key]+=1;
    }
    //cout << "---"<<endl;
    int max_val=0;
    for(auto p:data){
        max_val=max(max_val,p.second);
    }
    for(auto p:data){
        if(p.second==max_val){
            cout << p.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<vector<int> > area(h, vector<int>(w, -1));
    queue<pair<int,int> > q;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char a;
            cin >> a;
            if(a == '#'){
                area[i][j] = 0;
                q.push(make_pair(i,j));
            }
        }
    }
    int dx[] = {-1,1,0,0}, dy[] = {0,0,1,-1};
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int x = p.first, y = p.second;
        for(int i = 0; i < 4; i++){
            int tx = x + dx[i], ty = y + dy[i];
            if(tx < 0 || ty < 0 || tx >= h || ty >= w || area[tx][ty] >= 0) continue;
            area[tx][ty] = area[x][y] + 1;
            q.push(make_pair(tx,ty));
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, area[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12432
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		Queue<Integer> q = new PriorityQueue<Integer>();
		for (int i = 0; i < N; i++) {
			q.add(sc.nextInt());
		}

		int[] t = new int[N];
		for (int j = q.size() - 1; j >= 0; --j) {
			t[j] = q.poll();
		}

		long sum = 0;
		if (K <= N)
			for (int l = K; l < t.length; l++) {
				sum += t[l];
			}
		return sum;
	}
}
	

Measured memory_bytes: 95684
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 3005;
const int MOD = 1e9 + 7;
int n;

void add(int& a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

char p[N];
int dp[N][N];
// dp[i][j]: the count of permutations that with length i, 
//           ending with j

void solve() {
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1; // only one way to have permutation length 1
    for (int i = 1; i < n; ++i) {
        int cnt = 0;
        if (p[i] == '>') {
            for (int j = i; ~j; --j) {
                add(cnt, dp[i - 1][j]);
                add(dp[i][j], cnt);
            }
        } else {
            for (int j = 0; j <= i; ++j) {
                add(dp[i][j], cnt);
                add(cnt, dp[i - 1][j]);
            }
        }
    }
    int ans = 0;
    for (int j = 0; j < n; ++j) add(ans, dp[n - 1][j]);
    printf("%d\n", ans);
}

void debug() {
    for (int i = 0; i < n; ++i, putchar('\n')) {
        for (int j = 0; j < n; ++j) {
            printf("%6d ", dp[i][j]);
        }
    }
}

int main() {
    while (~scanf("%d%s", &n, p + 1)) {
        solve();
        // debug();
    }
    return 0;
}

Measured memory_bytes: 35456
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。
vector<pair<long long,long long>> prime_factorize(long long p); // 素因数分解

// class
// ------------------------------------------------
class Combi {
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    map<long long, map<long long, long long>> memo;
    long long n_num;
    long long k_num;
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(long long(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll n;
    cin >> n;

    ll ans = kiriage(n,1000) * 1000 - n;

    cout << ans << endl;

    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
  int i = 1;
  while(1) {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n) {
  int s = 0;
  while(n) {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(97 <= *itr && *itr <= 122) {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(65 <= *itr && *itr <= 90) {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi() {
  n_num = -1;
  k_num = -1;
};

ll Combi::Combination(ll n, ll k) {

  ll ret;
  if(memo[n][k] != 0) {
    ret = memo[n][k];
  } else if(n == k || k == 0) {
    memo[n][k] = 1;
    ret = 1;
  } else {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

long long Combi::nPk_modp(long long n, long long k, long long p) {
  ll ans = 1;
  for(long long i = k; i <= n; i++) {
    ans = (ans * i) % p;
  }

  return ans;
};

vector<pair<long long,long long>> prime_factorize(long long p) {
    vector<pair<long long,long long>> ret;

    for(long long x = 2; x * x <= p; ++x) {
        if(p % x != 0) continue;
        long long num = 0;
        while(p % x == 0) {
            num++;
            p /= x;
        }
        ret.push_back(make_pair(x,num));
    }

    if(p != 1) ret.push_back(make_pair(p, 1));
    
    return ret;
}

Measured memory_bytes: 3616
from collections import deque

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

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

def bfs(i):
    s = -1
    q = deque([])
    q.append((i-1,s))
    while q:
        
        num,bef = q.popleft()
        for j in E[num]:
            if j == bef:
                continue
            else:
                score[j] += score[num]
                q.append((j,num))
            
    return score
print(*bfs(1))


    




Measured memory_bytes: 61768
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);

		//??????????????°??????????????????
		int n = scan.nextInt();

		//????????¨??±??????????????????????????????????????°?????£?¨?
		int taroPoint = 0;
		int hanakoPoint = 0;

		//??????????????°?????°???????????????
		for(int i = 0; i < n; i++){

			//??????????????????????????????
			String taroCade = scan.next();
			String hanakoCade = scan.next();

			//?????????????????????????????§??????????????????????????????????????????compareTo()???????????????(??? ???????????????????¨????)
			int temp = taroCade.compareTo(hanakoCade);

			//temp???0????????§???????????????????°?????????§??????????????????????????????
			if(temp > 0){
				taroPoint += 3;
			} else if (temp == 0){
				taroPoint += 1;
				hanakoPoint += 1;
			} else if (temp < 0){
				hanakoPoint += 3;
			}
		}
		//???????????¨???
		System.out.println(taroPoint + " " + hanakoPoint);
	}

}

Measured memory_bytes: 29260
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;

int n;
string s, t;

string f(string t) {
	int a = 0;
	for (int i = 1; i < n - 1; i++) {
		if (t[i] == 'S') {
			if (s[i] == 'o') {
				t += t[i - 1];
			} else if (t[i - 1] == 'S') {
				t += 'W';
			} else {
				t += 'S';
			}
		} else {
			if (s[i] == 'x') {
				t += t[i - 1];
			} else if (t[i - 1] == 'W') {
				t += 'S';
			} else {
				t += 'W';
			}
		}
	}
	if (t[0] == 'S') {
		if (s[0] == 'o' && t[1] == t[n - 1]) {
			a = 1;
		} else if (s[0] == 'x' && t[1] != t[n - 1]) {
			a = 1;
		} else {
			t = "X";
			return t;
		}
	}
	if (t[0] == 'W') {
		if (s[0] == 'x' && t[1] == t[n - 1]) {
			a = 1;
		} else if (s[0] == 'o' && t[1] != t[n - 1]) {
			a = 1;
		} else {
			t = "X";
			return t;
		}
	}
	if (a==1 && t[n-1] == 'S') {
		if (s[n-1] == 'o' && t[n-2] == t[0]) {
			return t;
		} else if (s[n-1] == 'x' && t[n-2] != t[0]) {
			return t;
		} else {
			t = "X";
			return t;
		}
	}
	if (a==1 && t[n-1] == 'W') {
		if (s[n-1] == 'x' && t[n-2] == t[0]) {
			return t;
		} else if (s[n-1] == 'o' && t[n-2] != t[0]) {
			return t;
		} else {
			t = "X";
			return t;
		}
	}
}

int main() {
	cin >> n >> s;
	string ans;
	ans = f("SS");
	if (ans != "X") {
		cout << ans << endl;
		return 0;
	}
	ans = f("SW");
	if (ans != "X") {
		cout << ans << endl;
		return 0;
	}
	ans = f("WW");
	if (ans != "X") {
		cout << ans << endl;
		return 0;
	}
	ans = f("WS");
	if (ans != "X") {
		cout << ans << endl;
		return 0;
	}
	if (ans == "X") {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;
#define PI 3.14159265358979323846

using namespace std;
int MOD = 1000000007;


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

  int s,w;
  cin >> s >> w;
  if ( w >= s ){
    cout << "unsafe" << endl;
  }
  else {
    cout << "safe" << endl;
  }
  return 0;
}



Measured memory_bytes: 3048
package main

import "fmt"

func ok(xs, ys []int) bool {
	sqsum := 0
	for i, x := range xs {
		sqsum += (x - ys[i]) * (x - ys[i])
	}

	for i := 0; i <= 200; i++ {
		if i*i == sqsum {
			return true
		}
	}
	return false
}

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	xss := make([][]int, n)
	for i := range xss {
		xss[i] = make([]int, d)
		for j := range xss[i] {
			fmt.Scan(&xss[i][j])
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if ok(xss[i], xss[j]) {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer;

public class Main {
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    public static void main(String[] args){
        IO fs = new IO();
        int n = fs.nextInt(),l = fs.nextInt();
        String [] a = new String[n];
        for(int i = 0; i<n; i++){
            a[i] = fs.nextLine();
        }
        Arrays.sort(a);
        String ans = "";
        for(int i = 0; i<n; i++)ans += a[i];
        System.out.println(ans);
    }
}


Measured memory_bytes: 29200
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    map<vector<int>, long long> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vector<int> abc(27);
        for (char c : s) abc[c-'a']++;
        mp[abc]++;
    }
    long long ans = 0;
    for (auto m: mp) {
        ans += m.second * (m.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


#define rep(i,a) for(auto i=0;i<a;i++)
#define rbf(it,a) for(auto &it:a)

double f(int sum,int depth,int n,int m,int k,double nm){
	if(n==depth){

		//cout<<max(sum-k,1)<<" "<<nm<<endl;
		return(max(sum-k,1)/nm);
	}
	else{
		double res=0;
		rep(i,m){
			res+=f(sum+i+1,depth+1,n,m,k,nm);
		}
		return res;
	}

}

int main(){
	cout<<setprecision(8);
	cout<<fixed;
	while(true){
		int n,m,k;
		cin>>n>>m>>k;
		if((n|m|k)==0)break;

		double nm=1;
		{
			int t=n;
			double a=m;
			while(t){
				if(t&1)nm*=a;
				a=a*a;
				t>>=1;
		//		cout<<nm<<endl;
			}
		}
		cout<<f(0,0,n,m,k,nm)<<endl;


	}


	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N;
    double D;
    cin >> N >> D;
    double X[N],Y[N];
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        double d = pow(X[i] * X[i] + Y[i] * Y[i] , 0.5);
        if(d <= D){
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 6244
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define deb(x) cout<<#x<<" "<<x<<"\n"
using namespace std;
string s1,s2,u;
int x1,x2;
int main(){
    cin>>s1>>s2>>x1>>x2>>u;
 
    if(u==s1)x1--;
    else x2--;
    cout<<x1<<" "<<x2;
    
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
T = int(input())
for _ in range(T):
	n, a, b, c, d = map(int, input().split())
	dp = dict()
	dp[n] = 0
	q = [(0, n)]
	def add(x, v):
		if x not in dp:
			dp[x] = v
			return True
		elif dp[x] > v:
			dp[x] = v
			return True
		else:
			return False

	while True:
		l = heappop(q)
		if l[1] == 0:
			break
		x = l[1]
		if x%2 == 0:
			v = min(a, d*(x//2)) + dp[x]
			if add(x//2, v):
				heappush(q, (v, x//2))
		else:
			v = min(a+d, d + d*(x//2)) + dp[x]
			if add(x//2, v):
				heappush(q, (v, x//2))
			v = min(a+d, d + d*(x//2+1)) + dp[x]
			if add(x//2+1, v):
				heappush(q, (v, x//2+1))

		if x%3 == 0:
			v = min(b, d*2*(x//3)) + dp[x]
			if add(x//3, v):
				heappush(q, (v, x//3))
		else:
			m = x%3
			v = min(b+d*m, d*m + d*2*(x//3)) + dp[x]
			if add(x//3, v):
				heappush(q, (v, x//3))
			v = min(b+d*(3-m), d*(3-m) + d*2*(x//3 + 1)) + dp[x]
			if add(x//3+1, v):
				heappush(q, (v, x//3+1))

		if x%5 == 0:
			v = min(c, d*4*(x//5)) + dp[x]
			if add(x//5, v):
				heappush(q, (v, x//5))
		else:
			m = x%5
			v = min(c+d*m, d*m + d*4*(x//5)) + dp[x]
			if add(x//5, v):
				heappush(q, (v, x//5))
			v = min(c+d*(5-m), d*(5-m) + d*4*(x//5 + 1)) + dp[x]
			if add(x//5+1, v):
				heappush(q, (v, x//5+1))

	print(dp[0])

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

using ll = long long int;

const int MAX_N = (int)(2 * (1e5 + 5));

ll h, w, a, b;

ll ans = 0;

/////////////////////////////////////////////////////////////
const ll MOD = (ll)1e9 + 7;

ll fact[MAX_N];
ll inv[MAX_N];
ll factinv[MAX_N];

void init_fact(ll n) {
  inv[1] = fact[0] = factinv[0] = 1;
	for (int i = 2; i <= n; i++) inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
	for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MOD;
	for (int i = 1; i <= n; i++) factinv[i] = factinv[i - 1] * inv[i] % MOD;
}

ll comb(ll n, ll r) {
  if (r > n) return 0;
	return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
}
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%lld %lld %lld %lld", &h, &w, &a, &b);

  init_fact(h + w + 5);

  for (int i = b; i <= w - 1; ++i) {
    ll tmp = (comb(h - 1 - a + i, i) % MOD) * (comb(a - 1 + w - 1 - i, a - 1) % MOD) % MOD;
    ans += tmp;
    ans = ans % MOD;
  }

  printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {FIN

	int n, i, a, b, c;
	cin >> n;
	
	vvi dp(n + 1, vi(3));
	for (i = 0; i < n; i++) {
		cin >> a >> b >> c;
		dp[i + 1][0] = a + max(dp[i][1], dp[i][2]);
		dp[i + 1][1] = b + max(dp[i][0], dp[i][2]);
		dp[i + 1][2] = c + max(dp[i][0], dp[i][1]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";

	return 0;
}

Measured memory_bytes: 8668
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j);a×b行列の入力
 
int main() {
  ll a,b,c,k;
  ci(a>>b>>c>>k);
  k=pow(2,k);
  ll d=a+b+c,e=max({a,b,c});
  co(d-e+e*k);
}

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    map<ll, int> cek;
    for (ll i = 0; i * i * i * i * i <= INF; i++) {
        ll pw = i * i * i * i * i;
        cek[pw] = i;
        cek[-pw] = -i;
    }
    for (auto p: cek) {
        if (cek.count(x + p.fi)) {
            cout << cek[x + p.fi] << ' ' << p.se << '\n';
            exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 4124
using System.Linq;
using static System.Console;

namespace For_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            long[] ns = { 0, 0, 0, 0, 0 };
            string[] Name = new string[n];
            for(int i = 0; i < n; i++)
            {
                Name[i] = ReadLine().Substring(0,1);
            }
            ns[0] = Name.Count(x => x == "M");
            ns[1] = Name.Count(x => x == "A");
            ns[2] = Name.Count(x => x == "R");
            ns[3] = Name.Count(x => x == "C");
            ns[4] = Name.Count(x => x == "H");

            long ans = 0;
            //long[] ns2 = ns.Where(x => x != 0).ToArray();
            for(int i = 0; i < 3; i++)
            {
                for(int j = i + 1; j <= 3; j++)
                {
                    for(int k = j + 1; k <= 4; k++)
                    {
                        ans += ns[i] * ns[j] * ns[k];
                    }
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 17376
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int x=kbd.nextInt();
   int y=kbd.nextInt();

   int Y=y/4;//Max tsuru
   boolean a=false;
   for(int i=Y;i>=0;i--){
     if(y==(x-i)*2+i*4){
       a=true;
     }
   }
   if(a==true){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }
 }
}


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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;

    string s;
    cin>>s;
    int sum = 0;
    for(int i=0; s[i]; i++) {
        sum += s[i]-'0';
        sum %= 9;
    }
    if(sum) cout<<"No\n";
    else cout<<"Yes\n";

}



Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>d(n);
	for(int i=0;i<n;i++)cin>>d[i];
	sort(d.begin(),d.end());
	cout<<d[n/2]-d[n/2 -1];
	
	
	
	
		
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int n;
    
    while(cin >> n, n){
        int ans = 0;
        vector<bool> prime(2 * n + 1, true);
        
        prime[0] = false;
        prime[1] = false;
        
        for(int i = 2; i <= 2 * n; i++){
            if(prime[i] == true){
                for(int j = 2 * i; j <= 2 * n; j += i){
                    prime[j] = false;
                }
            }
        }
        
        for(int i = n + 1; i <= 2 * n; i++){
            if(prime[i]) ans++;
        }
        
        cout << ans << endl;
        
    }
    
    return 0;
    
}

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

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=a;i<=min(b,a+k-1);i++){
    cout<<i<<endl;
  }
  for(int i=max(b-k+1,a+k);i<=b;i++){
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
sort($a);
$m=0;
$ans=0;
$r=100000000000;
$i=0;
while($i<$n){
  if($a[$i]<0){
    ++$m;
    $ans+=(int)abs($a[$i]);
    $r=-$a[$i];
  }else{
    $ans+=(int)$a[$i];
    $r=min($r,$a[$i]);
  }
  ++$i;
}
if($m%2==1){
  $ans-=(int)$r*2;
}
echo $ans;

Measured memory_bytes: 14840