akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

// powのll番
ll pow(ll a,ll b) {
    ll k = 1;
    REP(_,b) k*=a;
    return b;
}

void solve() {
    int N;
    cin >> N;
    // dp[val] = <それを引き出すのに必要な最小回数>
    vector<int> dp(N+1,INF);
    dp[0] = 0;
    FOR(i,1,N+1) {
        // 1円で取る
        if(i-1 >= 0 ) chmin(dp[i],dp[i-1]+1);
        // 6の累乗円で取る
        int six_k = 1;
        while((i - pow(6,six_k)) >= 0) {
            chmin(dp[i],dp[i-pow(6,six_k)]+1);
            six_k++;
        }

        // 9の累乗円で取る
        int nine_k = 1;
        while((i - pow(9,nine_k)) >= 0) {
            chmin(dp[i],dp[i-pow(9,nine_k)]+1);
            nine_k++;
        }
    }

    cout << dp[N] << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
sum=0
for i in range(n):
    if i>=1 and a[i-1]+1 == a[i]:
        sum += b[a[i]-1] + c[a[i-1]-1]
    else:    
        sum += b[a[i]-1]
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=2e3+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int dp[2005][2005];
int sum[maxn<<2];
#define lss rt<<1
#define rss rt<<1|1
#define lson lss,l,Mid
#define rson rss,Mid+1,r
void insert(int rt,int l,int r,int pos,int k){
    // cout<<l<<" "<<r<<endl;
    if(l==r)return (void)(sum[rt]=k);
    if(pos<=Mid)insert(lson,pos,k);
    else insert(rson,pos,k);
    sum[rt]=(sum[lss]+sum[rss])%mod;
}
int query(int rt,int l,int r,int L,int R){
    if(R<L)return 0;
    if(L<=l&&r<=R)return sum[rt];
    int res=0;
    if(L<=Mid)res+=query(lson,L,R);
    if(R>Mid)res=(res+query(rson,L,R))%mod;
    return res;
}
signed main(){
    //file(a);
    n=read();
    if(n<3){puts("0");return 0;}
    if(n==3){puts("1");return 0;}
    dp[0][0]=1;
    insert(1,1,n+1,0+1,1);//return 0;
    rep(i,1,n/3){
        rep(j,3,n){
            dp[i][j]=query(1,1,n+1,0+1,j-3+1);
            // cout<<"now"<<j<<" "<<0+1<<" "<<j-3+1<<" "<<dp[i][j]<<endl;
            /*rep(g,3,j){
                dp[i][j]+=dp[i-1][j-g];dp[i][j]%=mod;
            }*/
        }
        rep(j,0,n)insert(1,1,n+1,j+1,dp[i][j]);
    }int ans=0;
    rep(i,1,n/3)ans+=dp[i][n],ans%=mod;
    printf("%d\n",ans);


    return 0;
}


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n, m;
    cin >> n >> m;
    vector<P> sc;
    rep(i, m) {
        int s, c;
        cin >> s >> c;
        sc.emplace_back(s, c);
    }
    sort(sc.begin(), sc.end());
    /*
    bool flag = false;
    rep (i, 10) {
        rep (j, 10) {
            rep (k, 10) {
                bool flag = true;
                if ((n==1&&i==0&&j==0)||(n==2&&i==0)||(n==3)) {
                    rep(l, m) {
                        if (sc[l].first!==1)
                    }
                    if (flag) {
                        ans = 100*i+10*j+k;
                        break;
                    }
                }
            }
        }
    }
     */
    vector<int> num(n);
    rep(i, n) {
        num[i] = 0;
    }
    rep (i, m) {
        if (n!=1 && sc[i].first==1 && sc[i].second==0) {
            cout << "-1" << endl;
            return 0;
        }
        if (i<m-1 && sc[i].first==sc[i+1].first && sc[i].second!=sc[i+1].second) {
            cout << "-1" << endl;
            return 0;
        }
    }
    rep(i, m) {
        num[sc[i].first-1] = sc[i].second;
    }
    int ans = 0;
    if (n!=1 && num[0]==0) num[0] = 1;
    rep(i, n) {
        //cout << "num " << num[i] << endl;
        ans = 10*ans+num[i];
        //cout << "a " << ans << endl;
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x, n;
	cin >> x >> n;
	bool vis[205] ;
	for(int i=0;i<204;i++)vis[i]=false;
	for (int i = 0; i < n; i++) {
		int y;
		cin >> y;
		vis[y] = true;
	}
	vector<pair<int, int>>v;
	for (int i = -200; i <= 200; i++) {
		if (!vis[i] || i<=0)
			v.pb(mk(abs(x - i), i));
	}
	sort(v.begin(), v.end());
	int ans = v[0].fi;
	int res1 = 1e9;
	for (int i = 0; i < int(v.size()); i++) {
		if (v[i].fi == ans) {
			res1 = min(res1, v[i].se);
		}
	}
	cout << res1 << endl;
}


Measured memory_bytes: 3620
/*  Isn't it lovely, all alone?             */
/*  Heart made of glass, my mind of stone   */
/*  Tear me to pieces, skin to bone         */
/*  Hello, welcome home                     */

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;


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

ll t=1;
//cin>>t;
while(t--)
{

string s;
cin>>s;

if((s[2]==s[3]) && s[4]==s[5])
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

}
return 0;
}













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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    string S;
    cin >> S;
    if(S[0] == '7' || S[1] == '7' || S[2] == '7') _PR("Yes");
    else _PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll a,b;
int main(){
    cin>>a>>b;
    string s1,s2;
    for(ll i=0;i<a;i++){
      s1+=to_string(b);
    }
    for(ll i=0;i<b;i++){
      s2+=to_string(a);
    }
    cout<<min(s1,s2)<<endl;
    return 0;
}

Measured memory_bytes: 256
def es()
  a = gets.split(' ')
  b = Hash.new(0)
  q = []
  for j in 0..a.length-1
    if b[a[j]] > 0
      b[a[j]] += 1
    else
      b[a[j]] = 1
    end
  end
  m = b.max { |x, y| x[1] <=> y[1] }
  print m[0]
  print ' '
  for i in 0..a.length-1
    q[i] = a[i].size
  end
  puts a[q.index(q.max)]
end

es()

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

int main(){

  int n;
  int* L;
  int count=0;

  cin >> n;
  L = new int[n];
  for(int i=0;i<n;i++){
    cin >> L[i];
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if((L[i] != L[j]) && (L[j] != L[k]) && (L[i] != L[k])){
          if((abs(L[j]-L[k]) < L[i]) && (L[i] < L[j]+L[k])){
            count++;
          }
        }
      }
    }
  }

  cout << count;
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

ll dp[3001][3001];
ll dps[3001][3001];

int main(){
  int n;cin>>n;
  string s;cin>>s;

  dp[0][0]=1;
  rep(i, n-1){

    dps[i][0]=dp[i][0];
    rep1(j, i+1){
      dps[i][j] += dps[i][j-1] + dp[i][j];
    }

    rep(j, i+2){

      if(s[i]=='<'){
        if(j)dp[i+1][j] += dps[i][j-1];
      }else{
//cout<<i<<' '<<j<<' '<<dps[i][i]<<' '<<dps[i][j-1]<<endl<<"="<<endl;

//cout<<"---"<<endl;
//rep(i, n+1){
//  rep(j, n+1)cout<<dps[i][j]<<' ';cout<<endl;
//}cout<<"---"<<endl;

        dp[i+1][j] += dps[i][i];
        if(j)dp[i+1][j] -= dps[i][j-1];
      }

      dp[i+1][j] %= MOD;
    }
  }

  ll result=0;
  rep(j, n)result += dp[n-1][j];

  cout<<result%MOD<<endl;

  return 0;

rep(i, n+1){
  rep(j, n+1)cout<<dp[i][j]<<' ';cout<<endl;
}cout<<"---"<<endl;

  return 0;
}


Measured memory_bytes: 95892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  string s; cin >> s;
  string ans = "ABC";
  if(s==ans)ans="ARC";
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define max(x,y) ((x)>(y)?(x):(y))
#define ll long long

using namespace std;

const int maxn=2005,md=1e9+7;

ll f[maxn][maxn][2];
ll sum[maxn];
int i,j,k,l,m,n,x,y,q1,q2,ans,tmp;

int main(){
//	freopen("009e.in","r",stdin);
	scanf("%d%d%d",&n,&m,&k);
	m--; k--;
	q1=0; q2=1;
	f[0][0][0]=1;
	fo(i,1,max(n,m)*2){
		fo(j,1,n+1) sum[j]=(sum[j-1]+f[q1][j-1][0]+f[q1][j-1][1])%md;
		fo(j,0,n){
			f[q2][j][0]=(f[q1][j][0]+f[q1][j][1])%md;
			l=max(0,j-k);
			f[q2][j][1]=(sum[j]-sum[l])%md;
		}
		fo(j,0,n)
		if (j%k==n%k && k*i-j<=m && (k*i-j)%k==m%k) ans=(ans+f[q2][j][1])%md;
		tmp=q1; q1=q2; q2=tmp;
	}
	ans=(ans+md)%md;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int inf=(int)2e9;
const long long md=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=md;a%=md;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,md-2); }


signed main(){
	IOS
	int n;cin>>n;
	string s;cin>>s;
	vi DP(n,0),DP_new(n);
	DP[0]=1;

	for(int i=n-2;i>=0;i--){
		for(int x=1;x<n;x++){
			DP[x]+=DP[x-1];
			if(DP[x]>=md) DP[x]-=md;
		}
	
		for(int j=0;j<n;j++){
			if(s[i]=='<'){
				int h=0;
				if(j) h=DP[j-1];
				DP_new[j]=h;
			}
			else{
				int h=0;
				if(n-i-1>=0) h+=DP[n-i-1];
				if(j) h-=DP[j-1];
				if(h<0) h+=md;
				DP_new[j]=h;
			}
			if(j>=n-i) DP_new[j]=0;
		}
		swap(DP,DP_new);
	}
	int ans=0;
	for(int j=0;j<n;j++){
		ans+=DP[j];	
		if(ans>=md) ans-=md;
	}
	cout<<ans;
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	A, B, C := sc.nextInt(), sc.nextInt(), sc.nextInt()
	a := A - B
	if a >= C {
		fmt.Println(0)
	} else {
		fmt.Println(C - a)
	}
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
   int x,y,w;
   cin>>x>>y;
   int arr[x+x-1];
   arr[x-1]=y;
   w=y;
   for(int i=x;i<(x+x-1);i++){
      w++;
   arr[i]=w;


   }   for(int i=x-2;i>=0;i--){
        y=y-1;
   arr[i]=y;


   }
   for(int i=0;i<(x+x-1);i++){
    cout<<arr[i]<<" ";

   }

    return 0;
}


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



int MOD=1000000007;
int main(void){
int A,B;
cin >> A >> B;
if(A-(B*2)>0){
	cout << A-B*2 << endl;
}else{
	cout << 0 << endl;
}
}

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

int main(){
  int n,k,i;
  ll p=1000000007;
  cin >> n >> k;
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  
  if(a.at(0)==0&&a.at(n-1)==0){
    cout << 0 << endl;
    return 0;
  }
  
  if(a.at(0)>=0){
    down:
    ll s=1;
    for(i=n-1;i>=n-k;i--){
      s=(s*a.at(i))%p;
    }
    if(s<0){
      s += p;
    }
    cout << s << endl;
    return 0;
  }
  
  
  if(a.at(n-1)<=0){
    if(k%2==1){
      goto down;
    }else{
      ll s=1;
      for(i=0;i<k;i++){
        s=(s*a.at(i))%p;
      }
      if(s<0){
        s += p;
      }
      cout << s << endl;
      return 0;
    }
  }
  
  int l=0,r=n-1;
  for(i=0;i<k;i++){
    if(0-a.at(l)>=a.at(r)){
      l++;
    }else{
      r--;
    }
  }
  if(l%2==1){
    if(l!=0&&(r==n-1||a.at(r)*a.at(r+1)>a.at(l)*a.at(l-1))){
      l--;
      r--;
    }else{
      l++;
      r++;
    }
  }
  ll s=1;
  for(i=0;i<l;i++){
    s=(s*a.at(i))%p;
  }
  for(i=n-1;i>r;i--){
    s=(s*a.at(i))%p;
  }
  if(s<0){
    s += p;
  }
  cout << s << endl;
}

Measured memory_bytes: 4800
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n - 1):
    if (p[i] - p[i - 1] > 0 and p[i + 1] - p[i] >= 0) or (p[i] - p[i - 1] <= 0 and p[i + 1] - p[i] < 0):
        cnt += 1
print(cnt)

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

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    vector<vector<int>> dp(N, vector<int>(1 << N, 1e9));
    for (int i = 0; i < N; i++) {
        dp[i][1 << i] = 0;
    }
    for (int mask = 0; mask < 1 << N; mask++) {
        int p = __builtin_popcount(mask);
        for (int i = 0; i < N; i++) {
            int x = i % 2 == (p - 1) % 2 ? A[i] : B[i];
            for (int j = 0; j < N; j++) {
                if (mask & 1 << j) continue;
                int y = j % 2 == p % 2 ? A[j] : B[j];
                if (x > y) continue;
                dp[j][mask | 1 << j] = min(dp[j][mask | 1 << j], dp[i][mask] + __builtin_popcount(mask >> j));
            }
        }
    }
    int res = 1e9;
    for (int i = 0; i < N; i++) {
        res = min(res, dp[i][(1 << N) - 1]);
    }
    if (res > 1e8) res = -1;
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 22792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	string s;
	int n;
	cin >> s >> n;
	int sz = s.size();
	int rp = min(n, sz);
	rep(i, rp) {
		if (s[i] != *"1") {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << "1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    int n;
    std::cin >> n;
    int min = 1000000;
    int max = -1000000;
    long long sum = 0;
    for (int i = 0, a; i < n && std::cin >> a; i++) {
        if (a < min) min = a;
        if (max < a) max = a;
        sum += a;
    }
    std::cout << min << " " << max << " " << sum << std::endl;
    return 0;
}

Measured memory_bytes: 3096
from math import sqrt
while 1:
    n = input()
    if n == 0:
        break
    C = [map(int, raw_input().split()) for i in xrange(n)]
    P = [[C[0][:2]]]
    # calculate intersections of the circles
    for i in xrange(n-1):
        x0, y0, r0 = C[i]
        x1, y1, r1 = C[i+1]
        rr = (x1 - x0)**2 + (y1 - y0)**2; rd = sqrt(rr)
        rc = (r0**2 + rr - r1**2) / (2 * rd); rs = sqrt(4*r0**2*rr - (r0**2 + rr - r1**2)**2) / (2 * rd)
        ex = (x1 - x0) / rd; ey = (y1 - y0) / rd
        bx = x0 + ex * rc; by = y0 + ey * rc
        P.append([(bx + ey * rs, by - ex * rs), (bx - ey * rs, by + ex * rs)])
    P.append([C[-1][:2]])

    def calc((x0, y0), (x1, y1)):
        return sqrt((x1 - x0)**2 + (y1 - y0)**2)
    def cross((x0, y0), (x1, y1), (x2, y2)):
        return (x1-x0) * (y2-y0) - (x2-x0) * (y1-y0)
    INF = 10**18
    dist = {(0, 0): 0}
    for i in xrange(n):
        for j, (x, y) in enumerate(P[i]):
            left = p_left = None; right = p_right = None
            d = dist[i, j]
            for k in xrange(i+1, n):
                lp, rp = P[k]
                # update left and right
                if left is None or cross((x, y), left, lp) >= 0:
                    left = lp
                if right is None or cross((x, y), rp, right) >= 0:
                    right = rp
                # check if left <= right
                if cross((x, y), left, right) < 0:
                    break

                # propagate cost from P[i][j] to P[k][0] or P[k][1] if possible
                if p_left != left:
                    dist[k, 0] = min(dist.get((k, 0), INF), d + calc((x, y), left))
                    p_left = left
                if p_right != right:
                    dist[k, 1] = min(dist.get((k, 1), INF), d + calc((x, y), right))
                    p_right = right
            else:
                # P[i][j] -> goal

                gp = P[-1][0]
                # check if left <= goal <= right
                if (left is None and right is None) or (cross((x, y), left, gp) >= 0 and cross((x, y), gp, right) >= 0):
                    dist[len(P)-1, 0] = min(dist.get((len(P)-1, 0), INF), d + calc((x, y), gp))
    print "%.06f" % dist[len(P)-1, 0]

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int r= stdIn.nextInt();
		int c= stdIn.nextInt();
		int x[][] = new int[r+1][c+1];
		for(int i=0;i<r; i++) {
			for(int j=0;j<c; j++) {
				x[i][j] = stdIn.nextInt();
				x[i][c] +=x[i][j];
				x[r][j] +=x[i][j];
				x[r][c] +=x[i][j];
			}
		}
		stdIn.close();
		for(int i=0;i<r+1; i++) {
			for(int j=0;j<c+1; j++) {
				System.out.print(x[i][j]);
				if (j<c) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    ll n, a, b; cin >> n >> a >> b;
    V<ll> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    V<ll> x2(n);
    for(int i = 1; i < n; i++){
        x2[i - 1] = abs(x[i] - x[i - 1]);
    }

    ll ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(x2[i] * a < b) ans += x2[i] * a;
        else ans += b;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();	
		int[] arr = r.ria();
		int num = Integer.parseInt("" + arr[0] + arr[1]);
		double dub = Math.sqrt(num);
		if(dub == (int)dub)
			print("Yes");
		else
			print("No");
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21204
N, K = map(int, raw_input().split())
hs = []
for i in range(N):
  hs.append(int(raw_input()))

hs.sort()

minv = abs(hs[0]-hs[K-1])

for i in range(len(hs)-K+1):
  tmp = hs[i+K-1] - hs[i]
  if minv > tmp:
    minv = tmp
print minv


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

using namespace std;

int main()
{
	int n, k;	cin >> n >> k;
	
	vector <bool> Ok(n);
	
	while(k--)
	{
		int d;	scanf("%d", &d);
		
		while(d--)
		{
			int x;	scanf("%d", &x);
			
			Ok[x - 1] = true;
		}
	}
	
	int Ans = 0;
	
	for(int i = 0; i < n; i++)
		if(!Ok[i])
			Ans++;
			
	cout << Ans << endl;
}

Measured memory_bytes: 3644
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

int N, K, A[100005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> K;

    int ans = 0;
    REP(i, N) {
        cin >> A[i];
        if (A[i] > 0) ans += A[i];
    }

    int s = -INF;

    // 白塗り
    int tmp = 0;
    int l = 0;
    int r = 0;
    while (r < N && l < N) {
        if (A[r] > 0) tmp += -A[r];
        while ((r + 1) - (l - 1) <= K) {
            r++;
            if (A[r] > 0) tmp += -A[r];
        }
        s = max(tmp, s);

        if (A[l] > 0) tmp += A[l];
        l++;
        r++;
    }

    // 黒塗り
    l = r = 0;
    tmp = 0;
    while (r < N && l < N) {
        if (A[r] < 0) tmp += A[r];
        while ((r + 1) - (l - 1) <= K) {
            r++;
            if (A[r] < 0) tmp += A[r];
        }
        s = max(tmp, s);

        if (A[l] < 0) tmp += -A[l];
        l++;
        r++;
    }

    cout << ans + s << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n, cnt = 0;
	string s;
	map<string, ll>mp;
	cin >> n;
	vector<ll>ana(n),memo(n+1,0);
	rep(i, n) {
		cin >> s;
		sort(all(s));
		memo[i + 1] = memo[i] + ll(i);
		mp[s]++;
	}
	for (auto m : mp)cnt += memo[m.second];
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 12772
#include <stdio.h>

int main(void) {
	int i,x,y;

	for(i=1;i<3000;i++){
		while(1){
		scanf("%d %d",&x,&y);

		if(x==0&&y==0) break;

		if(x<y)

			printf("%d %d\n",x,y);
		else

			printf("%d %d\n",y,x);
		}
	}
	return 0;
}



Measured memory_bytes: 1980
N,M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    L,R,D = map(int, input().split())
    G[L-1].append((R-1, D))
    G[R-1].append((L-1, -D))

dist = [0] * N
visited = [False] * N

def dfs(v:int):
    """ 矛盾がある -> True """
    stack = [v]
    dist[v] = 0
    visited[v] = True

    while stack:
        v = stack.pop()
        d = dist[v]
        for to, cost in G[v]:
            if visited[to]:
                if dist[to] != d + cost:
                    return True
            else:
                visited[to] = True
                dist[to] = d + cost
                stack.append(to)
    
    return False

flag = True
for v in range(N):
    if not visited[v]:
        if dfs(v):
            flag = False
            break

if flag:
    print('Yes')
else:
    print('No')

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

int main()
{
    int n, o, a[25];

    while( cin >> n )
    {
        if( n == 0 )
            break;

        o = 32;

        for( int i = 0; i < n; i++ )
            cin >> a[i];

        int i = 0;
        while( o != 0 )
        {
            o -= ( o - 1 ) % 5;
            if( o < 0 )
                o = 0;
            cout << o << endl;
    
            if( o == 0 )
                break;

            o -= a[i%n];
            if( o < 0 )
                o = 0;
            cout << o << endl;

            i++;
        }
    }
    return 0;
}


Measured memory_bytes: 3004
/*Bismillahir Rahmanir Rahim
->>Code by aimon
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define f(a,b,x) for(int a=b;a<x;a++)
#define pb push_back
#define endl "\n"
#define MX 200000
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define vi vector<int>

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

    int x,y,a[10001],c=0,d=0,e=0;
    cin>>x>>y;
    if(y==0)
    {
        cout<<x<<endl;
        return 0;
    }
    else
    {
        for(int i=0; i<y; i++)
        {
            cin>>a[i];
        }
        for(int i=0; i<y; i++)
        {
            if(x==a[i])
               c++;
        }
        if(c==0)
        {
            cout<<x<<endl;
            return 0;
        }
        else
        {
            int p=x;
            for(int i=0;i<100;i++)
            {
                x--;
                p++;
                for(int j=0;j<y;j++)
                {
                    if(x==a[j])
                        d++;
                    if(p==a[j])
                        e++;
                }
                if(d==0)
                {
                    cout<<x<<endl;
                    return 0;
                }
                else if(e==0)
                {
                    cout<<p<<endl;
                    return 0;
                }
                d=0;
                e=0;
            }
        }
    }
}


Measured memory_bytes: 3648
# coding: utf-8

from collections import deque

N = int(input())
array = deque(list(map(int, input().split())))
ans, tmp, ctr = 0, 0, 1

for i in range(N):
    tmp = array.popleft()
    if tmp == ctr:
        ctr += 1
    else:
        ans += 1

if ctr > 1:
    print(ans)
else:
    print(-1)


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n, x, t;
	cin >> n >> x >> t;
	cout << (n - 1)/x*t + t << '\n';

	return 0;
}



Measured memory_bytes: 3644
N, K = map(int, input().split())
a = list(map(int, input().split()))

d = {}
d_n = {}
first_d_n = {}
for i in range(N):
  d[i+1] = a[i]
  if i+1 == 1:
    d_n[i+1] = 1
  else:
    d_n[i+1] = 0

m = 1
k = 0 # 累計移動回数
first_d_n[1] = 0

while m:
  m = d[m]
  d_n[m] += 1
  k += 1
  if d_n[m] == 1:
    first_d_n[m] = k
  
  if d_n[m] == 2:
    break
    
first_n = first_d_n[m] # loopの起点に入ったとき

if K - first_n >= 0:
  loop_mod = (K - first_n) % (k - first_n)
  #print(loop_mod)

  if loop_mod == 0:
    print(m)
  else:  
    for l in range(loop_mod):
      m = d[m]
    print(m)

  # print(first_d_n[loop_mod - 
else:
  m = 1
  for l in range(K):
    m = d[m]
  print(m)  
    
    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll a, b;
    cin >> a >> b;
    rep(i, max(a, b)) cout << min(a, b);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3624
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll cnt[N];
void solve()
{
    ll n,m;
    cin>>n>>m;
    ll correct=0;
    ll penalty=0;
    rep(i,m)
    {
        ll x;
        cin>>x;
        string str;
        cin>>str;
        if(vis[x]==1)
                continue;
        if(str=="AC")
        {
            vis[x]=1;
            penalty+=cnt[x];
        }
        else
        {
            cnt[x]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        correct+=vis[i];
    }
    cout<<correct<<' '<<penalty<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 14720
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int A, B;
        cin >> A >> B;

        cout << (A + B + 1) / 2 << endl;

        return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(float,input().split()))
v_list = sorted(v)
for i in range(n-1):
    a = (v_list[0]+v_list[1])/2
    v_list.append(a)
    v_list = sorted(v_list)
    del(v_list[0])
    del(v_list[1])

    
print(max(v_list))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lli;

const lli INF = 1LL<<60;
const int MAXN = 2005;
const int MAXM = 100005;

int N, M, L;
lli K[MAXN], S[MAXM];
lli dp[MAXN][MAXN];

inline lli sumS(int a, int b) {
  if(a > b) swap(a, b);
  if(a == 0) return S[b];
  else return S[b] - S[a-1];
}

int main() {
  while(cin >> N >> M >> L) {
    for(int i = 0; i < N; ++i) {
      cin >> K[i];
    }
    for(int i = 1; i <= M; ++i) {
      cin >> S[i];
      if(i != 0) S[i] += S[i-1];
    }
    sort(K, K+N);
    fill(dp[0], dp[MAXN], INF);
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        int k = max(i,j)+1;
        if(k == N-1) {
          dp[k][k] = min(dp[k][k],
                         dp[i][j] + sumS(K[i],K[k])/L + sumS(K[j],K[k])/L);
        } else {
          dp[k][j] = min(dp[k][j], dp[i][j] + sumS(K[i], K[k])/L);
          dp[i][k] = min(dp[i][k], dp[i][j] + sumS(K[j], K[k])/L);
        }
      }
    }
    cout << dp[N-1][N-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 33388
using System;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            A.TorT();
        }
    }

    class A
    {
        public static void TorT()
        {
            int[] num = Input.getIntArray();
            int train = num[0] * num[1];
            if(train>num[2]) 
            {
                Output.writeInt(num[2]);
            }
            else{
                Output.writeInt(train);
            }
        }
    }
  
    class Input
    {
        public static int getInt()
        {
            int i = int.Parse(Console.ReadLine());
            return i;
        }

        public static string getString()
        {
            string s = Console.ReadLine();
            return s;
        }
        public static int[] getIntArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] num = s.Select(x=>int.Parse(x)).ToArray();
            return num;
        }
    }

    class Output
    {
        public static void writeInt(int i)
        {
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#define ll long long int 
#define vi vector<int>
using namespace std;
int main()
{
  int i,cnt=0,j;
  string s,t;
  cin>>s;
  cin>>t;
  for(i=0;i<s.length();i++)
  {
    if(s[i]!=t[i])
    {
      cout<<"No";
      break;
    }
    else{ cnt=cnt+1;
    }
  }
  if(cnt==s.length())
  {
    cout<<"Yes";
  }
}

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

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

using namespace std;

int main() {
  int N; cin >> N;
  vector<vector<int64_t>> a(3, vector<int64_t>(N));
  rep(k, 3) rep(i, N) cin >> a[k][i];
  rep(k, 3) sort(a[k].begin(), a[k].end());
  a[0].push_back(1LL<<55);
  a[1].push_back(1LL<<55);

  vector<int64_t> bsum(a[1].size() - 1);
  rep(i, a[1].size() - 1) {
    auto iter = lower_bound(a[0].begin(), a[0].end(), a[1][i]);
    bsum[i] = iter - a[0].begin();
    if (i) { bsum[i] += bsum[i - 1]; }
  }

  int64_t ans = 0;
  rep(i, a[2].size()) {
    auto iter = lower_bound(a[1].begin(), a[1].end(), a[2][i]);
    auto size = iter - a[1].begin();
    if (size) {
      ans += bsum[size - 1];
    }
  }

  cout << ans << endl;
}


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

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

int dp[9][(1<<8)]={};
vector<int> v;
int n,m,s;
int d[201][201];
int r[201]={};


//int calc(int s1,int d1){
//	if(dp[s1][d1]>0)return dp[s1][d1];
//	if(d1==(1<<s1))return 0;
//	int d2=d1-(1<<s1);
//	dp[s1][d1]=200000001;
//	for(int i=0;i<s;++i){
//		int k=(1<<i);
//		if((d2&k)==k)dp[s1][d1]=min(dp[s1][d1],d[r[s1]][r[i]]+calc(i,d2));
//	}
//	return dp[s1][d1];
//}
int main() {
	int t,x;
	cin>>x>>t;
//
//	for(int i=0;i<201;++i){
//		for(int j=0;j<201;++j){
//			d[i][j]=200000001;
//		}
//	}
//	cin>>n>>m>>s;
//	bool flg=true;
//	int a,b,c;
//	int ct=0;;
//	for(int i=0;i<s;++i){
//		cin>>r[i];
//		ct+=(1<<i);
//	}
//	for(int i=0;i<m;++i){
//		cin>>a>>b>>c;
//		d[a][b]=c;
//		d[b][a]=c;
//	}
//	while(flg){
//		flg=false;
//		for(int i=1;i<n+1;++i){
//			for(int j=1;j<n+1;++j){
//				for(int k=1;k<n+1;++k){
//					if(d[i][j]>(d[i][k]+d[k][j])){
//						flg=true;
//						d[i][j]=d[i][k]+d[k][j];
//					}
//				}
//			}
//		}
//	}
//
//	int t=200000001;
//
//	for(int i=0;i<s;++i){
//		t=min(t,calc(i,ct));
//	}

	cout<<max(x-t,0)<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String, Integer> hashmap = new HashMap<>();
        make(hashmap);
        String alice = sc.next();
        String bob = sc.next();
        String winner = "";
        if (hashmap.get(alice) > hashmap.get(bob)) {
            winner = "Alice";
        } else if (hashmap.get(bob) > hashmap.get(alice)) {
            winner = "Bob";
        } else {
            winner = "Draw";
        }
        
        System.out.println(winner);
    }
    
    private static void make(HashMap<String, Integer> hashmap) {
        hashmap.put("2", 1);
        hashmap.put("3", 2);
        hashmap.put("4", 3);
        hashmap.put("5", 4);
        hashmap.put("6", 5);
        hashmap.put("7", 6);
        hashmap.put("8", 7);
        hashmap.put("9", 8);
        hashmap.put("10", 9);
        hashmap.put("11", 10);
        hashmap.put("12", 11);
        hashmap.put("13", 12);
        hashmap.put("1", 13);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int M, D;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> M >> D;
    int ans = 0;
    rep(m, 1, M + 1) rep(d1, 2, 10) rep(d10, 2, 10) {
        if(d10 * 10 + d1 <= D and d1 * d10 == m) ans++;
    }
    cout << ans << endl;
}







Measured memory_bytes: 256
N=int(input())
A=[int(input()) for i in range(N)]
A=sorted(A)
b=(N+1)//2
if N%2==0:
  B=A[:b]
  C=A[b:]
  ans=2*(sum(C)-sum(B))-C[0]+B[-1]
  print(ans)
else:
  B=A[:b-1]
  C=A[b-1:]
  ansa=2*(sum(C)-sum(B))-C[0]-C[1]
  B=A[:b]
  C=A[b:]
  ansb=2*(sum(C)-sum(B))+B[-1]+B[-2]
  print(max(ansa,ansb))

Measured memory_bytes: 8284
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int a, b, c;
int main()
{
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c)) << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
a = set(a)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
for i in range(2,n+1):
    if i not in a:
        dp[i] = dp[i-1]+dp[i-2]
print(dp[-1]%mod)

Measured memory_bytes: 460020
n,k=map(int,input().split())
s=input()
cnt=[]
now=s[0]
p=0
for i in range(n):
	if s[i]==now:
		p+=1
	else:
		cnt.append(p)
		now=s[i]
		p=1
cnt.append(p)
ans=0
r=[]
cum_sum=0
for i in range(len(cnt)):
	cum_sum+=cnt[i]
	r.append((cnt[i],cum_sum))
for i in range(len(r)):
	if s[r[i][1]-r[i][0]]=="1":
		e=r[min(i+2*k,len(r)-1)][1]-r[i][1]+r[i][0]
	else:
		e=r[min(i+2*k-1,len(r)-1)][1]-r[i][1]+r[i][0]
	ans=max(ans,e)
print(ans)

Measured memory_bytes: 14324
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pii acos(-1)
#define fo(i0n) for(i=0;i<n;i++)
#define fo(i1n) for(i=1;i<=n;i++)
#define fo(j0n) for(j=0;j<n;j++)
#define fo(j1n) for(j=1;j<=n;j++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define pu push
#define bg begin
#define en end
using namespace std;
ll ma[1000010];
int main()
{

    ll i,j,k,c,d,a,b,e,f,p,q,n,t,m,r,u,g,x,y,l;
    ld bb,cc,aa;
    string st,et,ft;
    priority_queue<ll,vector<ll>,greater<ll> > pq,aq,dq;
    //map<ll,ll> ma,ta;
    map<ll,ll >sa;
    set<ll> se,pe,me;
    ll vv,v[200010],s,ss;
    // fast();

    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a);
        ma[a]++;
            v[i]=a;
    }
    c = 0;
    for(i=0; i<n; i++)
    {
        f = 0;
        for(k=2; k*k<=v[i]; k++)
        {
            if(v[i]%k==0 && (ma[k]!=0 || ma[v[i]/k]!=0))
            {
                f=1;
                break;
            }
        }
        if(f==0 && ma[v[i]]==1 && ma[1]==0)c++;
    }
    if(ma[1]==1)c++;
    printf("%lld\n",c);
}


Measured memory_bytes: 13156
n=gets.to_i
as=[0]+gets.split.map(&:to_i)
lgcd=[0]*(n+2)
rgcd=[0]*(n+2)

(1..n).each do |i|
  lgcd[i]=lgcd[i-1].gcd(as[i])
end
n.downto(0) do |j|
  rgcd[j]=rgcd[j+1].gcd(as[j])
end

ans=0
(1..n).each do |k|
  kgcd=lgcd[k-1].gcd(rgcd[k+1])
  ans=[ans,kgcd].max
end
puts ans


Measured memory_bytes: 23208
Q,H,S,D = list(map(int,input().split()))
N = int(input())*100
TL = sorted([(25,Q,8*Q),(50,H,4*H),(100,S,2*S),(200,D,D)],key=lambda x: x[2])
ans = 0
if N >= TL[0][0]:
    ans += (N//TL[0][0])*TL[0][1]
    N %= TL[0][0]
if N >= TL[1][0]:
    ans += (N//TL[1][0])*TL[1][1]
    N %= TL[1][0]
if N >= TL[2][0]:
    ans += (N//TL[2][0])*TL[2][1]
    N %= TL[2][0]
if N >= TL[3][0]:
    ans += (N//TL[3][0])*TL[3][1]
    N %= TL[3][0]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool isPrime(long long n){
    if(n==1) return 0;
    for(long long i=2;i*i<=n;i++){
        if(n%i == 0){
            return 0;
        }
    }
    return 1;
}

int main() {
    int n,x=0;
    cin >> n;
    int m=n;
    int ans=m;
    int cnt[100000] = {0};
    while(n>1){
        for(int j=2;j*j<=m;j++){
            if(n % j == 0){
                while(n%j==0){
                    n /= j;
                }
                cnt[j]++;
                ans *=((double)(j-1)/j);
                break;
            }
        }
        if(isPrime(n)){
            x=n;
            bool match=false;
            for(int j=2;j*j<=m;j++){
                if(x==j && cnt[j]>0) match=true;
            }
            if(!match) ans *= ((double)(x-1)/x);
            break;
        }
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 3524