akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

typedef complex<double> P;

struct C {
    P p; double r;
    C(const P &p, double r) : p(p), r(r) { }
};

const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

int intersection(C &c1, C &c2){
    if(c1.r > c2.r) swap(c1, c2);

    P p1 = c1.p;
    P p2 = c2.p;
    double r1 = c1.r;
    double r2 = c2.r;

    double centDist = sqrt(norm(p1 - p2));
    if(r1 + r2 < centDist - EPS) return 4;
    if(abs(r1 + r2 - centDist) <= EPS) return 3;
    if(r1 + r2 > centDist + EPS){
        if( r2 - r1 < centDist - EPS ) return 2;
        if( abs(r2 - r1 - centDist) <= EPS ) return 1;
        if( r2 - r1 > centDist + EPS ) return 0;
    }
}


void commonTangent(C &c1, C &c2){
    double p = (c2.p).real() - (c1.p).real();
    double q = (c2.p).imag() - (c1.p).imag();
    double r = c1.r;
    double s = c2.r;
    double D1 = p*p + q*q - (r+s)*(r+s);
    double D2 = p*p + q*q - (r-s)*(r-s);
    P a1((p*r*(r+s) + q*r*sqrt(D1))/(p*p+q*q) + (c1.p).real(), (q*r*(r+s) - p*r*sqrt(D1))/(p*p+q*q) + (c1.p).imag());
    P a2((p*r*(r+s) - q*r*sqrt(D1))/(p*p+q*q) + (c1.p).real(), (q*r*(r+s) + p*r*sqrt(D1))/(p*p+q*q) + (c1.p).imag());
    P a3((p*r*(r-s) + q*r*sqrt(D2))/(p*p+q*q) + (c1.p).real(), (q*r*(r-s) - p*r*sqrt(D2))/(p*p+q*q) + (c1.p).imag());
    P a4((p*r*(r-s) - q*r*sqrt(D2))/(p*p+q*q) + (c1.p).real(), (q*r*(r-s) + p*r*sqrt(D2))/(p*p+q*q) + (c1.p).imag());
    vector<P> tmp;
    int x = intersection(c1, c2);
    switch(x){
        case 4:
            tmp.push_back(a1);
            tmp.push_back(a2);
            tmp.push_back(a3);
            tmp.push_back(a4);
            sort(tmp.begin(), tmp.end());
            printf("%.10f %.10f\n", tmp[0].real(), tmp[0].imag());
            printf("%.10f %.10f\n", tmp[1].real(), tmp[1].imag());
            printf("%.10f %.10f\n", tmp[2].real(), tmp[2].imag());
            printf("%.10f %.10f\n", tmp[3].real(), tmp[3].imag());
            break;
        case 3:
            tmp.push_back(a2);
            tmp.push_back(a3);
            tmp.push_back(a4);
            sort(tmp.begin(), tmp.end());
            printf("%.10f %.10f\n", tmp[0].real(), tmp[0].imag());
            printf("%.10f %.10f\n", tmp[1].real(), tmp[1].imag());
            printf("%.10f %.10f\n", tmp[2].real(), tmp[2].imag());
            break;
        case 2:
            if(a4 < a3) swap(a3, a4);
            printf("%.10f %.10f\n", a3.real(), a3.imag());
            printf("%.10f %.10f\n", a4.real(), a4.imag());
            break;
        case 1:
            printf("%.10f %.10f\n", a3.real(), a3.imag());
            break;
        case 0:
            break;
    }
}

int main(){
    double c1x, c1y, c1r, c2x, c2y, c2r;
    cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r;
    P p1(c1x, c1y);
    P p2(c2x, c2y);
    C c1(p1, c1r);
    C c2(p2, c2r);
    commonTangent(c1, c2);
    return 0;
}

Measured memory_bytes: 3348
#include <iostream>
#include <string>

using namespace std;

int main(void) {

	int n, a, b;
	cin >> n >> a >> b;

	string str;
	cin >> str;

	int count = 0, oversea = 0;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] == 'a') {
			if (count < (a + b)) {
				cout << "Yes" << endl;
				++count;
			} else {
				cout << "No" << endl;
			}
		} else if (str[i] == 'b') {
			if (count < (a + b) && oversea < b) {
				cout << "Yes" << endl;
				++count;
				++oversea;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}

	return 0;

}


Measured memory_bytes: 896
def main():
  N = int(input())
  A = list(map(int, input().split()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
  
main()


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    S = str(N)
    return YES if len(set(S[:3])) == 1 or len(set(S[1:])) == 1 else NO


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

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

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


Measured memory_bytes: 3064
#include <stdio.h>

char field[10][10];

void s(int x, int y)
{
	int i;
	
	field[y][x] = '0';
	
	for (i = 1; i <= 3; i++){
		if (x + i < 8 && field[y][x + i] == '1'){
			s(x + i, y);
		}
		if (x - i >= 0 && field[y][x - i] == '1'){
			s(x - i, y);
		}
		if (y + i < 8 && field[y + i][x] == '1'){
			s(x, y + i);
		}
		if (y - i >= 0 && field[y - i][x] == '1'){
			s(x, y - i);
		}
	}
}

int main(void)
{
	int i, j, k, n, x, y;
	
	
	scanf("%d", &n);
	
	for (k = 0; k < n; k++){
	
		for (i = 0; i < 8; i++){
			scanf("%s", field[i]);
		}
		
		scanf("%d %d", &x, &y);
		
		s(x - 1, y - 1);
		
		printf("Data %d:\n", k + 1);
		
		for (i = 0; i < 8; i++){
			printf("%s\n", field[i]);
		}
	}
	return (0);
}
	
	

Measured memory_bytes: 608
a, b, c = map(int, input().split())

ans = 'NO'
if a < b and c%a == 0:
  ans = 'YES'
else:
  for i in range(1, 100):
    if (b*i + c)%a == 0:
      ans = 'YES'
      break
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int H, W;
    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; ++i) {
            for(int j = 0; j < W; ++j) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}
 
li mmi(li a){return power(a,mod-2);}
 
li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int n,m;

void solve(){
	cin>>n>>m;
	if(n==1 and m==1){
		cout<<"1";
	}else if(n==1 and m!=1){
		cout<<m-2;
	}else if(n!=1 and m==1){
		cout<<n-2;
	}else if(n==2 or m==2){
		cout<<"0";
	}else{
		cout<<(n-2)*1ll*(m-2);
	}
}

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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func solve(nums []int) int {
	answer := 0
	
	for i, n := range nums {
		if (i+1)%2 == 1 && n%2 == 1 {
			// Odd number
			answer++
		}
	}

	return answer
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)

	result := solve(nums)
	fmt.Println(result)
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,k,a[maxn];

#define mid ((l+r)>>1)
#define ls p<<1
#define rs p<<1|1

struct segment_tree {
    int mn[maxn<<2],mx[maxn<<2];

    void modify(int x,int v,int p=1,int l=1,int r=n) {
        if(l==r) return mn[p]=mx[p]=v,void();
        if(x<=mid) modify(x,v,ls,l,mid);
        else modify(x,v,rs,mid+1,r);
        mn[p]=min(mn[ls],mn[rs]);
        mx[p]=max(mx[ls],mx[rs]);
    }

    int query(int x,int y,int o,int p=1,int l=1,int r=n) {
        if(x<=l&&r<=y) return (o?mn:mx)[p];
        if(y<=mid) return query(x,y,o,ls,l,mid);
        else if(x>mid) return query(x,y,o,rs,mid+1,r);
        else if(!o) return max(query(x,y,o,ls,l,mid),query(x,y,o,rs,mid+1,r));
        else return min(query(x,y,o,ls,l,mid),query(x,y,o,rs,mid+1,r));
    }
}T;

// int p[maxn];

int main() {
    read(n),read(k);for(int i=1;i<=n;i++) read(a[i]);
    // for(int i=k;i<=n;i++) {
    //     for(int j=1;j<=n;j++) p[j]=a[j];
    //     sort(p+i-k+1,p+i+1);
    //     for(int j=1;j<=n;j++) printf("%d ",p[j]);puts("");
    // }
    int ans=0,bo=0,p=0;
    for(int i=1;i<=n;i++) {
        if(a[i]<a[i-1]) p=i;T.modify(i,a[i]);
        if(i<k) continue;
        if(i-k+1>=p) {bo=1;continue;}
        if(i==k) {ans++;continue;}
        if(T.query(i-k,i-1,1)==a[i-k]&&T.query(i-k+1,i,0)==a[i]) ;
        else ans++;
        // printf("%d %d\n",i,p);
    }write(ans+bo);
    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;



int main() {
    fast;

    ll x, y;
    cin >> x >> y;

    if(y >= 2 * x && y <= 4 * x && y % 2 == 0) cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <limits>
#include <cassert>

using namespace std;

using Z = long long;
constexpr Z INF = numeric_limits<Z>::max();

#ifdef DEBUG
# define dump(x) cerr << "dump@" << __LINE__ << " : " << #x << " = " << (x) << endl
# define mesg(m) cerr << "mesg@" << __LINE__ << " : " << m << endl
# define debug if (true)
#else
# define NDEBUG
# define dump(x)
# define mesg(m)
# define debug if (false)
#endif
#define rep(i, n) for (auto i = 0; i < n; i++)
#define rrep(i, n) for (auto i = n; i >= 1; i--)
#define all(c) begin(c), end(c)

Z min_score(Z n) {
  Z l = 1, r = n + 1;
  while (r - l > 1) {
    Z m = (l + r) / 2;
    ((m * (m + 1) / 2 < n) ? l : r) = m;
  }
  return r;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  Z n;
  cin >> n;
  Z lim = min_score(n);
  dump(lim);
  Z rest = n;
  rrep(i, lim) {
    if (i <= rest) {
      cout << i << '\n';
      rest -= i;
    }
  }
  assert(rest == 0);
}


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

public class Program
{

    public void Proc()
    {
		int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

		string ans = "No";
		if(Math.Abs(inpt[0]-inpt[2])<=inpt[3] || Math.Max(Math.Abs(inpt[0]-inpt[1]), Math.Abs(inpt[1]-inpt[2]))<=inpt[3]) {
			ans = "Yes";
		}
		Console.WriteLine(ans);


    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



1 100 2 10




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
  int i, j;
  char a,b;
  int len=0, cnt;
  int L;
  double aa;
  scanf("%d", &L);
//  printf("L %d\n",L);
  aa = (double)L/3;
  printf("%lf\n",aa*aa*aa);
  return 0;
 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int k;
	int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
	cin>>k;
	cout<<a[k]<<endl;
	return 0;
}



Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        mut l: [i32; n]
    }
    l.sort();
    let mut ans = 0;
    if n < 3 {
        println!("{}", ans);
        return
    }
    for i in 0..n-2 {
        for j in i+1..n-1 {
            for k in j+1..n {
                if l[i] < l[j] && l[j] < l[k] && l[k] < l[i] + l[j] {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[51][60*50];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int a;
  cin >> n >> a;
  VLL x(n);
  rep(i,n){
    cin >> x[i];
  }
  dp[0][50*55] = 1;
  rep(i,n){
    rep(j,60*50){
      if(dp[i][j] > 0){
        dp[i+1][j+x[i]-a] += dp[i][j];
        dp[i+1][j] += dp[i][j];
      }
    }
  }
  cout << dp[n][50*55]-1 << endl;
  return 0;
}


Measured memory_bytes: 896
import math
from collections import Counter

def get_prime_factors(n):
    if n == 1:
        return []
    else:
        limit = int(math.sqrt(n))
        for i in range(2, limit + 1):
            if n % i == 0:
                return [i] + get_prime_factors(n // i)
        return [n]


N = int(input())

operations = 0
prime_factors = get_prime_factors(N)
for p, count in Counter(prime_factors).items():
    for i in range(1, count + 1):
        if i <= count:
            operations += 1
            count -= i
        else:
            break
print(operations)


Measured memory_bytes: 9488
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<cctype>
#include<iomanip>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1e15
#define init(x) memset(x,0,sizeof(x))
typedef pair<char*,int> str;
char s[5005];
int n,k;
vector<str> a;
inline bool cmp(const str x,const str y){
	int sx=x.S,sy=y.S;
	for (int i=0;i<sx&&i<sy;++i){
		if (*(x.F+i)<*(y.F+i)) return 1;
		else if (*(x.F+i)>*(y.F+i)) return 0;
	}
	if (sx<sy) return 1;
	else return 0;
}
inline bool cmpp(const str x,const str y){
	int sx=x.S,sy=y.S;
	if (sx!=sy) return 0;
	for (int i=0;i<sx;++i){
		if (*(x.F+i)!=*(y.F+i)) return 0;
	}
	return 1;
}
inline bool f(str x){
	int sz=a.size();
	for (int i=0;i<sz;++i) if (cmpp(a[i],x)) return 1;
	return 0;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>s>>k;
	char ss[10]="1234321";
	//cout<<(mp(ss,1)==mp(ss+6,1))<<" "<<(mp(ss,1)<mp(ss+1,1))<<" "<<(mp(ss,1)<mp(ss,2))<<" "<<(mp(ss+2,1)<mp(ss+1,2))<<endl;
	n=strlen(s);
	for (int i=0;i<n;++i){
		for (int j=1;i+j<=n;++j){
			if (f(mp(s+i,j))) continue;
			a.push_back(mp(s+i,j));
			sort(a.begin(),a.end(),cmp);
			/*if (a.size()>k){
			 cout<<"POPED STRING:";
			 for (int ii=0;ii<a.back().S;++ii) cout<<*(a.back().F+ii);
			 cout<<endl;
			 cout<<"LAST STRING:";
			 for (int ii=0;ii<a[k-1].S;++ii) cout<<*(a[k-1].F+ii);
			 cout<<endl<<"POPED < LAST:"<<(a.back()<a[k-1])<<endl;
			}*/
			if (a.size()>k) a.pop_back();
		}
	}
	/*for (int i=0;i<k;++i){
		cout<<"FINAL-"<<i+1<<":";
		for (int j=0;j<a[i].S;++j) cout<<*(a[i].F+j);
		cout<<endl;
	}*/
	for (int i=0;i<a[k-1].S;++i) cout<<*(a[k-1].F+i);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////


int main(){
  int n,k;
  cin >> n >> k;

  vector<int> v;
  rep(i,0,n){
    int l;
    cin >> l;
    v.push_back(l);
  }

  rvsort(v);
  int sum = 0;
  rep(i,0,k){
    sum += v[i];
  }

  P(sum);

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int k,s,x,y,z,i,j,count=0;
    scanf("%lld%lld",&k,&s);
    for(i=0; i<=k; i++)
    {
        x=i;
        for(j=0;j<=k;j++)
        {
            y=j;
            z=s-x-y;
                if(x+y+z==s&&z>=0&&z<=k)
                {
                   count++;
                }

        }
    }
    printf("%lld\n",count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t
#define db double
inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


void solve(lli n)
{
	
}
	
int main()
{
	fast();
	
	lli t,n;
	string s;
	cin>>n;
	db a[n],x,sum=0,y;
	rep(i,0,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	db prev=a[0],curr,s1=0;
	for(lli i=0;i<n;i++)
	{
		curr=(a[i]+prev)/2;
		prev=curr;
		s1=max(s1,curr);
	}
	cout<<s1;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n, m;
	while(scanf("%d%d", &n, &m)==2)
	{
		vi x(n+1, -1);
		vi s(m), c(m);

		for(int i=0;i<m;i++) scanf("%d%d", &s[i], &c[i]);

		bool is_ok=true;
		for(int i=0;i<m;i++)
		{
			if(x[s[i]]>=0 && x[s[i]]!=c[i]) is_ok=false;
			x[s[i]]=c[i];
		}
		if(n>1 && x[1]==0) is_ok=false;
		for(int i=1;i<=n;i++)
		{
			if(x[i]>=0) continue;
			x[i]=(n>1 && i==1);
		}
		if(is_ok)
		{
			for(int i=1;i<=n;i++) printf("%d", x[i]);
			printf("\n");
		}
		else
		{
			printf("%d\n", -1);
		}
	}
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const LINES = input.split(" ");
  const N = parseInt(LINES[0]);
  const X = parseInt(LINES[1]);
  const T = parseInt(LINES[2]);

  let answer = 0;
  answer = Math.floor(N / X) * T;
  if (N % X != 0){
    answer += T;
  }

  console.log(answer);

}
// デバッグ用
function debug(){
var input = document.getElementById("input").value;
Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int n, m;
    cin >> n;
    map<string, int> c;
    rep(i, n) {
        string s;
        cin >> s;
        c[s]++;
    }

    cin >> m;
    rep(i, m) {
        string t;
        cin >> t;
        c[t]--;
    }

    int ans = 0;
    for (auto a : c) {
        ans = max(ans, a.second);
    }

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


Measured memory_bytes: 256
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int ans = 10000000;
  for(int i = -100; i < 101; i++){
    int sum = 0;
    for(auto k : a) sum += (k - i) * (k - i);
    ans = min(ans, sum);
  }
  
  cout << ans << endl;
}

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

int main(){
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int i = 0;
    while(true){
        if (s[i].size() == 0){
            cout << char('A' + i) << endl;
            return 0;
        }
        char front = s[i][0];
        s[i].erase(0,1);
        i = front - 'a';
    }

}

Measured memory_bytes: 256
import collections
import itertools

def solve():
    N,C = map(int, input().split())
    transform = [list(map(int, input().split())) for _ in range(C)]
    counter = [[0]*C, [0]*C, [0]*C]
    for i in range(N):
        S = list(map(int, input().split()))
        # print(S)
        # print(S[0::3],S[1::3],S[2::3])
        for j in S[0::3]: counter[i%3][j-1] += 1
        for j in S[1::3]: counter[(i+1)%3][j-1] += 1
        for j in S[2::3]: counter[(i+2)%3][j-1] += 1 
    
    trans_0 = [sum( transform[j][i]*counter[0][j] for j in range(C) ) for i in range(C)]
    trans_1 = [sum( transform[j][i]*counter[1][j] for j in range(C) ) for i in range(C)]
    trans_2 = [sum( transform[j][i]*counter[2][j] for j in range(C) ) for i in range(C)]
    # print(counter)
    # print(trans_0,trans_1,trans_2)
    ret = min([trans_0[i]+trans_1[j]+trans_2[k] for (i,j,k) in itertools.product(range(C),repeat = 3)
               if i != j and j != k and k != i])
    # print(all_combination)
    print(ret)
    
solve()

Measured memory_bytes: 4452
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

l = 0
r = N-1
count = 0

M = defaultdict(int)
for a in A:
    if M[a] > 0:
        count += 1
    M[a] += 1

if count % 2 == 0:
    print(N-count)
else:
    print(N-(count+1))


Measured memory_bytes: 62124
#include<bits/stdc++.h>
 
#define ar array 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,a,b) for(int i = a; i < b; i++)
#define deb(x) cout << #x << "=" << x << endl
#define PI 3.1415926535897932384626
#define endl '\n'
 
using namespace std;
 
typedef long long ll; 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
 
 
const  int mxN = 5e5+100;
const  long long INF= 1e18;
const long long mod= 1e9+7;

struct fenwick {
    vector<int> bit;  // binary indexed tree
    int sz;

    fenwick(int _n) {
        this->sz = _n + 1;
        bit.assign(_n + 1, 0);
    }

    fenwick(vector<int> a)
        : fenwick(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int idx) {
        int ret = 0;
        for (++idx; idx > 0; idx -= idx & -idx)
            ret += bit[idx];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (++idx; idx < sz; idx += idx & -idx)
            bit[idx] += delta;
    }
};

int last_seen[mxN];



void solve() {
  int n, q;
  cin >> n >> q;

  vi v(n + 1) ;
  
  rep(i, 1, n + 1) cin >> v[i];

  vector<pair<pii, int> > query;
  rep(i, 0, q) {
    int l, r;
    cin >> l >> r;
    query.pb({{r, l}, i});
  }

  vi ans(q);
  sort(all(query));
  fenwick fen(mxN);

  int r = 1;

  for(auto x: query) {
    while(r <= x.fi.fi) {
      fen.add(last_seen[v[r]], -1);
      fen.add(r,1);
      last_seen[v[r]] = r;
      r++;
    }
    ans[x.se] = fen.sum(x.fi.se, x.fi.fi);
  }

  for(auto x: ans) cout << x << endl;

}

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

int t = 1;
//cin >> t;
while(t--) {
solve();
}
}



Measured memory_bytes: 17380
import numpy
import math
N,D= list(map(int,input().split()))

X = []
for i in range(N):
    x1 = list(map(int,input().split()))
    X.append(x1)
#X = [input().split() for i in range(N)]
#map(int,X)
#print(X)


count = 0
for i in range(N):
    k = i+1
    while k < N:
        dis = 0
        for j in range(D):
#            print("i,j,k,X[i][j],X[k][j]=",i,j,k,X[i][j],X[k][j])
            test = X[i][j] - X[k][j]
            dis = dis + test*test
#        print("dis,k=",dis,k)
        sqdis = math.sqrt(dis)  
        jud = sqdis.is_integer()
#        print(jud)
        if jud == 1:
#            print(jud)
            count = count + 1
        k = k + 1
print(count)

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;

typedef tuple<ll, ll, ll> triple;

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

	ll x, y, z, k;
	cin >> x >> y >> z >> k;

	vll a(x), b(y), c(z);
	for(int i = 0; i < x; i++){
		cin >> a[i];
	}

	for(int i = 0; i < y; i++){
		cin >> b[i];
	}

	for(int i = 0; i < z; i++){
		cin >> c[i];
	}	

	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());


	priority_queue<pair<ll, triple>> pq;
	set<triple> mySet;

	pq.push(make_pair(a[0] + b[0] + c[0], make_tuple(0, 0, 0)));
	mySet.insert(make_tuple(0, 0, 0));

	vll ans;

	while((int)ans.size() < k){
		auto it = pq.top();
		ans.push_back(it.first);
		pq.pop();
		int i1 = get<0>(it.second), i2 = get<1>(it.second), i3 = get<2>(it.second);

		if(i3 + 1 < z && mySet.find(make_tuple(i1, i2, i3 + 1)) == mySet.end()){
			mySet.insert(make_tuple(i1, i2, i3 + 1));
			pq.push(make_pair(a[i1] + b[i2] + c[i3 + 1], make_tuple(i1, i2, i3 + 1)));
		}

		if(i2 + 1 < y && mySet.find(make_tuple(i1, i2 + 1, i3)) == mySet.end()){
			mySet.insert(make_tuple(i1, i2 + 1, i3));
			pq.push(make_pair(a[i1] + b[i2 + 1] + c[i3], make_tuple(i1, i2 + 1, i3)));
		}

		if(i1 + 1 < x && mySet.find(make_tuple(i1 + 1, i2, i3)) == mySet.end()){
			mySet.insert(make_tuple(i1 + 1, i2, i3));
			pq.push(make_pair(a[i1 + 1] + b[i2] + c[i3], make_tuple(i1 + 1, i2, i3)));
		}
	}

	for(auto &it: ans){
		cout << it << "\n";
	}
}		

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int A, B;
  cin>>A>>B;
  if(B%A==0) cout<<A+B<<endl;
  else cout<<B-A<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>s;
    n=s.size();
    for(i=0;i+1<n;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<"Bad\n";
            return 0;
        }
    }
    cout<<"Good\n";
    return 0;
}



Measured memory_bytes: 3580
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include<climits>
using namespace std;


class RMQ{//RangeMinimumQuery
	int n;
	std::vector<int> dat,idx;
	static int calcsize(int n){
		int res=1;
		while(res<n)res<<=1;
		return res;
	}
	int query(int a,int b,int k,int l,int r)const{
		if(r<=a||b<=l)return dat.size()-1;
		if(a<=l&&r<=b)return idx[k];
		else{
			int vl=query(a,b,k*2+1,l,(l+r)/2);
			int vr=query(a,b,k*2+2,(l+r)/2,r);
			return dat[vl]<dat[vr]?vl:vr;
		}
	}
public:
	RMQ(){}
	~RMQ(){}
	void build(const std::vector<int> &a){
		n=calcsize(a.size());
		idx.resize(2*n-1);
		for(int i=0;i<(int)a.size();i++)idx[n-1+i]=i;
		for(int i=a.size();i<n;i++)idx[n-1+i]=a.size();
		dat=a;
		dat.push_back(INT_MAX);
		for(int i=n-2;i>=0;i--){
			idx[i]=dat[idx[i*2+1]]<dat[idx[i*2+2]]?idx[i*2+1]:idx[i*2+2];
		}
	}
	int query(int a,int b)const{//[a,b)の最小値
		return query(a,b,0,0,n);
	}
};


class LCA{
	vector<pair<int,int> > eulertour;
	vector<int> vertex;
	//SparseTableRMQ rmq;
	RMQ rmq;
	void dfs(const vector<int> edge[],int n,vector<int> &depth,int d,int u){
		eulertour[u].first=vertex.size();	
		vertex.push_back(u);
		depth.push_back(d);
		for(int i=0;i<edge[u].size();i++){
			dfs(edge,n,depth,d+1,edge[u][i]);
			eulertour[u].second=vertex.size();
			vertex.push_back(u);
			depth.push_back(d);
		}
		if(edge[u].empty()){
			eulertour[u].second=vertex.size();
			vertex.push_back(u);
			depth.push_back(d);
		}
	}
public:
	LCA(const vector<int> edge[],int n,int root):eulertour(n){
		vector<int> depth;
		dfs(edge,n,depth,0,root);
		rmq.build(depth);
	}
	int query(int u,int v)const{
		if(u==v)return u;
		if(eulertour[u].first<eulertour[v].first && eulertour[v].second<eulertour[u].second)
			return u;
		if(eulertour[v].first<eulertour[u].first && eulertour[u].second<eulertour[v].second)
			return v;
		if(eulertour[u].first>eulertour[v].first)swap(u,v);
		return vertex[rmq.query(eulertour[u].second, eulertour[v].first)];
	}
};


vector<int> edge[100000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int k,v;
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>v;
			edge[i].push_back(v);
		}
	}
	LCA lca(edge,n,0);
	int q,u,v;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>u>>v;
		cout<<lca.query(u,v)<<endl;
	}
	return 0;
}

Measured memory_bytes: 16172
import collections

n = int(input())
vs = list(map(int, input().split()))

vs_even = vs[0::2]
vs_odd = vs[1::2]

count_e = collections.Counter(vs_even).most_common()
count_o = collections.Counter(vs_odd).most_common()

#ダミー
count_e.append((0,0))
count_o.append((0,0))


e_max = len(vs_even) - count_e[0][1]
e_second = len(vs_even) - count_e[1][1]
o_max = len(vs_odd) - count_o[0][1]
o_second = len(vs_odd) - count_o[1][1]

if(count_e[0][0] != count_o[0][0]):
    print(e_max + o_max)

else:
    print(min(e_second+o_max, e_max+o_second))

Measured memory_bytes: 25696
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String hi = "hi";
        if (str.length() % 2 == 1) {
            System.out.println("No");
            return;
        }

        for (int i = 0; i < str.length(); i += 2) {
            if (!str.substring(i, i + 2).equals(hi)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string a[3];
    cin>>a[0]>>a[1]>>a[2];
        if(a[0][a[0].length()-1]==a[1][0]&&a[1][a[1].length()-1]==a[2][0]){
            cout<<"YES"<<endl;
        }
        else
            cout<<"NO"<<endl;
    
   
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>


int main(void) {
	double s,l,h;
	int a,b;
	double c;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%lf",&c);
	c=c*3.14159265/180.0;
	s =(a*b*sin(c)/2.0);
	l=(a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
	h=(b*sin(c));
	printf("%f\n",s);
	printf("%f\n",l);
	printf("%f\n",h);
	return 0;
}

Measured memory_bytes: 1964
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		int[] person = new int[N];
		int[] frames = new int[N];
		int[] team = new int[N];
		long[] xs = new long[N];
		long[] ys = new long[N];
		
		for(int i = 0; i < N; i++){
			frames[i] = sc.nextInt();
			person[i] = sc.nextInt();
			team[i] = sc.nextInt();
			xs[i] = sc.nextLong();
			ys[i] = sc.nextLong();
		}
		
		long[] max_dists = new long[]{-1, -1};
		long[] max_frames = new long[]{-1, -1};
		
		for(int i = 0; i < N - 1; i++){
			if(team[i] != team[i + 1]){ continue; }
			if(person[i] == person[i + 1]){ continue; }
			
			final long dist = (xs[i] - xs[i + 1]) * (xs[i] - xs[i + 1]) + (ys[i] - ys[i + 1]) * (ys[i] - ys[i + 1]);
			final long frame = frames[i + 1] - frames[i];
			
			if((max_dists[team[i]] == -1l) || (max_dists[team[i]] < dist) || (max_dists[team[i]] == dist && max_frames[team[i]] > frame)){
				max_dists[team[i]] = dist;
				max_frames[team[i]] = frame;
			}
		}
		
		for(int i = 0; i <= 1; i++){
			if(max_dists[i] == -1){
				System.out.println("-1 -1");
			}else{
				System.out.printf("%.8f %.8f\n", Math.sqrt(max_dists[i]), max_frames[i] / 60.0f);
			}
		}
		
	}
	
} 

Measured memory_bytes: 20704
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
int ans=0;
void fun(int n){
    for(int i=1;i*i<=(n);i++){
        if(n%i==0){
            if(n%i == i){
                if(i!=1 && (n/(i-1))==(n%(i-1))){
                    ans+=i-1;
                }
            }
            else{
                if(i!=1 && (n/(i-1))==(n%(i-1))){
                    ans+=i-1;
                }

                if((n/i)!=0 && (n/((n/i)-1))==(n%((n/i)-1))){
                    ans+=(n/i)-1;
                }
            }
        }
    }
}
int32_t main(){
	ios::sync_with_stdio(false);

    int n;
    cin>>n;
    if(n==1){
        cout<<0<<"\n";
        return 0;
}

fun(n);
    // int sum=0;
    // for(int i=1;i<=n;i++){
    //     if((n/i)==(n%i)){
    //         deb(i);
    //         sum+=i;
    //     }
    // }
    // cout<<sum<<"\n";
cout<<ans<<"\n";


return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> s;
	int n = s.length(); ll res = 0;
	for (int bit = 0; bit < (1 << (s.size() - 1)); bit++) {
		ll num = s[0] - '0';
		for (int i = 0; i < s.size() - 1; i++) {
			if (bit & 1 << i) {
				res += num;
				num = 0;
			}
			num = num * 10 + s[i + 1] - '0';
		}
		res += num;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define LL long long
#define MAXN 300005
#define p 998244353
using namespace std;

LL n, a, b, k, ans, fac[MAXN], inv[MAXN];

LL ksm(LL x, LL y)
{
	LL sum=1;
	while(y)
	{
		if(y&1) sum=(x*sum)%p;
		x=(x*x)%p; y>>=1;
	}
	return sum;
}

void init()
{
	fac[0]=fac[1]=1;
	inv[0]=inv[1]=1;
	for(int i=2; i<=n; i++) inv[i]=(p-p/i)*inv[p%i]%p;
	for(int i=2; i<=n; i++) fac[i]=fac[i-1]*i%p;
	for(int i=2; i<=n; i++) inv[i]=inv[i-1]*inv[i]%p; 
}

LL com(int n, int m)
{
	if(m>n) return 0; 
	return fac[n]*inv[n-m]%p*inv[m]%p;
}

int main()
{
	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
	if(k==0) {printf("1\n"); return 0;}
	init();
	for(int i=1; a*i<=k && i<=n; i++)
	{
		if((k-a*i)%b!=0) continue;
		int j=(k-a*i)/b;
		ans=(com(n, i)*com(n, j)%p+ans)%p;
	}
	printf("%lld\n", ans);
}

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

using namespace std;

#define ll long long int

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}

ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	SORT(a,n);
	cout << a[n/2]-a[n/2-1] << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	string s, t, temp = "A";
	int sloc, tloc;
	cin >> s >> t;
	REP(i, s.size()){
		if(temp.find(s[i]) > temp.size()) {
			temp = temp + s[i];
			FOR(j,i+1,s.size()){
				sloc = s.find(s[i], j);
				tloc = t.find(t[i], j);
				if(sloc <= s.size() || tloc <= t.size()){
					if(s[i] != s[tloc] || t[i] != t[sloc]){
						cout << "No" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<cmath>
#include<string>

using namespace std;

int main(){
        string s;cin>>s;
        int tmp[2];
        tmp[0] = 0;
        tmp[1] = 0;
        for(int i=0;i<s.length();i++){
                if(i%2) {
                        if(s[i]=='0') tmp[0]++;
                        else tmp[1]++;
                } else {
                        if(s[i]=='0') tmp[1]++;
                        else tmp[0]++;

                }
        }
        cout<<min(tmp[0],tmp[1])<<endl;
        return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a,b,c,ans=0;
    scanf("%d %d %d",&a,&b,&c);
    
    for(int i = a; i <= b; i++) {
        if(c % i == 0) ans++;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>

int main(void)
{
	int n,a[100001],i,max=0,smax=0,flag=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==1){
        	flag=1;
        }
	}
	
	if(flag==1) printf("first\n");
	else printf("second\n");

	
	return 0;
}



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

int main() {
    ll a,b;
    cin >> a >> b;
    int c;
    c = __gcd(a,b);
    
    long long d = a*b;
    cout << d/c << endl;
}

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

int s[] = {1868, 1912, 1926, 1989};
string t = "MTSH";
int e, y;

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

  cin >> e >> y;
  if (e) {
    cout << s[e-1] + y - 1 << "\n";
  } else {
    repr(i, 4) if (y >= s[i]) {
      cout << t[i] << y - s[i] + 1 << "\n";
      break;
    }
  }
}


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

int main(){
        int a, b, c, d;
        string ans = "Yes" ;

        cin >> a >> b >> c >> d;

        while(c > 0){
                c -= b;
                a -= d;
                if(a <= 0 and c > 0){
                        ans = "No";
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

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

void dfs(int p, int x, int parent, vector<vector<int>>& g, vector<long>& ans){
    ans[p] += x;
    for(auto v : g[p]){
        if (v == parent) continue;
        dfs(v, ans[p], p, g, ans);
    }
}

int main() {
    int n, q;
    cin >> n >> q;

    vector<vector<int>> g(n+1);
    vector<long> ans(n+1,0);

    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    rep(i, q){
        int p, x;
        cin >> p >> x;

        ans[p] += x;
    }

    dfs(1, 0, -1, g, ans);

    rep(i, n){
        cout << ans[i+1] << " "; 
    }
    cout << endl;

}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main(void){
    ll n,h;
    cin>>n>>h;
    P p[100000];
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        p[i]=P(b,a);
    }
    ll ans=0;
    sort(p,p+n,greater<P>());
    ll M=0;
    for(int i=0;i<n;i++){
        M=max(M,p[i].second);
    }
    for(int i=0;i<n;i++){
        if(M<=p[i].first){
            ans++;
            h-=p[i].first;
            if(h<=0) break;
        }
    }
    if(h>0){
        ans+=(h-1)/M+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector (Int, Int, Int) -> Int
solve !n !m !xyzs = maximum $ map calcForPattern patterns
 where
  patterns = [ (b1, b2, b3) | b1 <- [1, -1], b2 <- [1, -1], b3 <- [1, -1] ]

  calcForPattern (!b1, !b2, !b3) =
    sum $ take m $ sortBy (flip compare) $ VU.toList $ VU.map
      (\(!x, !y, !z) -> x * b1 + y * b2 + z * b3)
      xyzs

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, m) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  xyzs <-
    VU.replicateM n
    $   (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  print $ solve n m xyzs


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  int k = 0;
  vector<int> num;
  for (int i = 1; i <= A; i++) {
    if (A % i == 0 && B % i == 0) {
      num.push_back(i);
      //cout << i << endl;
    }
  }
  cout << num.at(num.size()-K) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int H,N;
    cin >> H >> N;
    int A;
    rep(i,N){
        cin >> A;
        H-=A;
    }
    if(H<=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
int a,b,k,c;
  c=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
  if(i%k==0){c=1;}}
  if(c==1){cout<<"OK"<<endl;}
  else{cout<<"NG"<<endl;}
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int n;std::cin >> n;
    long double x[n];string u[n];
    rep(i,n)std::cin >> x[i]>>u[i];
    double ans=0;
    rep(i,n){
        if(u[i]=="JPY")ans+=x[i];
        if(u[i]=="BTC") ans+=x[i]*380000.0;
    }
    std::cout << ans << std::endl;
   
}


Measured memory_bytes: 256