akhauriyash/Code-Regression huggingface dataset:
import heapq
import math

N, M = map(int, input().split())
A = list(map(int, input().split()))

h = []

for i in range(0, N):
    heapq.heappush(h, -A[i])

for i in range(0, M):
    v = heapq.heappop(h)
    discounted = v / 2
    heapq.heappush(h, discounted)

res = 0
for i in range(0, N):
    res = res + math.floor(-h[i])

print(res)

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

vector<long long> a(50);

bool is_ok(long long k, int n) {
    for (long long x = k - 51; x <= k + 51; x++) {
        long long sum = 0;
        for (int i = 0; i < n; i++) {
            //if (a.at(i) <= n - 1) continue;
            sum += ((a.at(i) + x - n + 1) + n) / (n + 1);
        }
        if (sum <= x) return true;
        //return sum <= k;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    long long ng = -1;
    long long ok = (long long)(1e16 + 1000) * 50;

    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;

        if (is_ok(mid, n)) ok = mid;
        else ng = mid;
    }
    
    for (long long i = ok - 51; i <= ok + 51; i++) {
        long long sum = 0;
        for (int j = 0; j < n; j++) {
            //if (a.at(i) <= n - 1) continue;
            sum += ((a.at(j) + i - n + 1) + n) / (n + 1);
        }
        if (sum <= i) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main () {

    vector<int> v(9,0);
    REP(i,9) v[i] = 100*(i+1) + 10*(i+1) + (i+1);  

    int n;
    cin >> n;

    REP(i,9) if (n <= v[i]) {
        cout << v[i] << endl;
        return 0;
    }

}

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

int main() {
	int a[810];
	for (int i = 0; i < 10; i++) {
		cin >> a[i];
	}
	sort(a, a + 10);
	for (int i = 9; i >= 7; i--) cout << a[i] << endl;
	return 0;
}


Measured memory_bytes: 3144
#include<iostream>
using namespace std;
int main()
{
	int  i, n, a[10009],max ,min;
	long long int sum = 0;
	cin >> n;
	max = -1000001;
	min = -max;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for(i = 0; i < n; i++)
	{ sum += a[i];
	if (a[i] > max)max = a[i];
	if (a[i] < min)min = a[i];	
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            long[] data = new long[N + 1];
            var dic = new Dictionary<long, int>();
            for (int i = 1; i <= N; i++)
            {
                long u = long.Parse(str[i - 1]);
                data[i] = u;
                if (dic.ContainsKey(u)) dic[u]++;
                else dic[u] = 1;
            }

            var dic_sort = dic.OrderByDescending(x => x.Key);

            int c = 0;
            long s1 = 0;
            long s2 = 0;
            bool flag = false;
            foreach(var s in dic_sort)
            {
                if (flag)
                {
                    s2 = s.Key;
                    break;
                }
                if (c + s.Value >= N / 2)
                {
                    if (c + s.Value == N / 2)
                    {
                        s1 = s.Key;
                        flag = true;
                        
                    }
                    else
                    {
                        s1 = s.Key;
                        s2 = s1;
                        break;
                    }
                }
                else c += s.Value;                
            }

            for(int i = 1; i <= N; i++)
            {
                Console.WriteLine(data[i] >= s1 ? s2 : s1);
            }
        }
    }
}

Measured memory_bytes: 49468
import numpy as np

t = np.array(list(input()), dtype='U1')
s = np.array(list(input()), dtype='U1')

ls = len(s)
lt = len(t)

eq = s[:, None] == t[None, :]
dp = [np.zeros(lt + 1, dtype=np.int16)]

# solve
for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out=prev[1:])
    np.maximum.accumulate(prev, out=prev)
    dp.append(prev)

# print([list(line) for line in dp])

# restore
res = ''
i, j = ls, lt
while i > 0 and j > 0:
    if eq[i - 1][j - 1]:
        res += s[i - 1]
        i, j = i - 1, j - 1
        continue

    if dp[i - 1][j] > dp[i][j - 1]:
        i -= 1
    else:
        j -= 1

print(res[::-1])


Measured memory_bytes: 39240
def main():
	n,m = map(int, input().split())
	a = [list(map(int, input().split())) for _ in range(n)]
	b = [int(input()) for _ in range(m)]
	for ai in a:
		print(sum([x[0] * x[1] for x in zip(ai, b)]))

main()



Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
#define mx 200000
int main(){
  int n,m,a,b;
  bool from1[mx+1]={},ton[mx+1]={},f=false;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    if(a==1)from1[b]=true;
    if(b==n)ton[a]=true;
  }
  for(int i=1;i<n&&!f;i++){
    if(from1[i]&&ton[i])
      f=true;
  }
  cout<<(f?"POSSIBLE":"IMPOSSIBLE")<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,f,n) for(int i=f; i<(n); i++)
int main()
{
  ll ans = 0;
  ll a[2], b[2];
  REP(i,0,2)cin >> a[i];
  REP(i,0,2)cin >> b[i];

  ans = a[0]*b[0];
  REP(i,0,2){
    REP(j,0,2){
      ans = max(ans,a[i]*b[j]);
    }
  }
  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3644
program hina_arare
  implicit none
  integer :: n, i
  character(1) :: s(100)
  read(*,*) n
  read(*,*) s(1:n)
  do i = 1, n
    if (s(i) == "Y") then
      write(*,'(a)') "Four"
      stop
    end if
  end do
  write(*,'(a)') "Three"
end program hina_arare

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n+1); rep(i,n+1) cin>>a[i];
    if(n==0){
        cout<<1-2*(ll)(a[0]!=1)<<endl;
        return 0;
    }

    vint sum(n+2);
    sum.back() = 0;
    repr(i,n+1){
        sum[i] = sum[i+1] + a[i];
    }
    ll ans = 1;
    ll now = 1;
    repf(i,1,n+1){
        now = min((now-a[i-1])*2, sum[i]);
        if(now < a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans += now;
    }
    cout<<ans<<endl;

    return 0;

}

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

int     main() {
        long N, K;
        cin >> N >> K;
        vector<long> h(N);
        for (long i=0; i<N; i++) {
                cin >> h.at(i);
        }
        sort(h.begin(), h.end());
        long H=10e9;
        K--;
        long i=0;
        while(K<N) {
                H=min(H,h.at(K)-h.at(i));
                i++;
                K++;
        }
        cout << H << endl;
        return 0;
}

Measured memory_bytes: 1024
from itertools import permutations as p
N,M,R=map(int,input().split())
r=map(int,input().split())
inf=float("inf")
l=[[inf if i!=j else 0 for i in range(N)] for j in range(N)]

for _ in range(M):
  a,b,c=map(int,input().split())
  l[a-1][b-1]=c
  l[b-1][a-1]=c

for k in range(N):
  for i in range(N):
    for j in range(N):
      l[i][j]=min(l[i][j],l[i][k]+l[k][j])

ans=inf
for i in p(r):
  v=0
  for j in range(R-1):
    v+=l[i[j]-1][i[j+1]-1]
  ans=min(ans,v)
print(ans)

Measured memory_bytes: 72280
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    double Ans = 0;
    cin >> N;    
    vector<pair<double, string> > Pochi(N);
    for(int i = 0;i < N;i++){
        double a;
        string b;
        cin >> a >> b;
        Pochi[i] = make_pair(a,b); 
    }
    for(int i = 0;i < N;i++){
        if(Pochi[i].second == "JPY"){
            Ans += Pochi[i].first;
        }else{
            Ans += Pochi[i].first * 380000.0;
        }
    }
    cout << Ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)


int main()
{

  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);     
  ll n,m;
  cin >> n >> m;
  ll a[m+1];
  rep(i,0,m)cin>>a[i];
  ll s=0;
  rep(i,0,m)s=s+a[i];
  if(n-s>=0)cout<<n-s;
  else cout<<"-1";
} 

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int q;
    cin>>q;
    int cnt=0;
    while (q--){
        int t;
        cin>>t;
        if(t==1)
            cnt++;
        else{
            int f;
            char c;
            cin>>f>>c;
            if(cnt%2==f%2) s+=c; 
            else s=c+s;
        }    
    }
    if(cnt%2) reverse(s.begin(),s.end());
    cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 4568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  cout << a[n-1]-a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int n;cin>>n;
		int i;
		int mi1=INT_MAX,ma1=INT_MIN;
		int mi2=INT_MAX,ma2=INT_MIN;
		repf(i,0,n)
		{
			int x,y;
			cin>>x>>y;
			mi1=min(mi1,x+y);
			ma1=max(ma1,x+y);
			mi2=min(mi2,x-y);
			ma2=max(ma2,x-y);
		}
		cout<<max(ma1-mi1,ma2-mi2);
    }
    return 0;
} 


Measured memory_bytes: 3628
def main():
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    d1 = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

    # for a given number of matches, give the largest digit
    d2 = dict()
    for a in A:
        if d1[a] not in d2: d2[d1[a]] = a
        else: d2[d1[a]] = max(a, d2[d1[a]])

    # for these digit, give the match count
    lv = []
    for a in d2.values(): lv.append(a)

    dp = [None for _ in range(N+1)]
    dp[0] = ""
    for i in range(1, N+1):
        for a in lv:
            j = i - d1[a]
            if j >= 0 and dp[j] != None:
                if dp[i] == None:
                    dp[i] = dp[j] + str(a)
                elif len(dp[i]) < len(dp[j]) + 1:
                    dp[i] = dp[j] + str(a)
                elif len(dp[i]) == len(dp[j]) + 1:
                    dp[i] = max(dp[i], dp[j] + str(a))
                # print(dp[i], i)
    # print(dp)
    return dp[N]




if __name__ == '__main__':
    print(main())

Measured memory_bytes: 28020
#include<bits/stdc++.h>
using namespace std;
       
#define ff              first
#define ss              second                            
#define int             long long
#define rep(i,j,k)      for(int i=(j); i<(int)k; ++i)
#define rrep(i,k,j)     for(int i=(int)k-1; i>=(j); --i)
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define endl            "\n"
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed << setprecision(y) << x
#define mk(arr,n,type)  type *arr = new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define PI              3.14159265358979323846264338327950L
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
       
       
       
       
void c_p_c() {
  ios_base::sync_with_stdio(0); 
  cin.tie(0); 
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif  
}      
// int gcd (int a, int b) {
//   if (b == 0) return a;
//   else return gcd (b, a % b);
// }    
// int gcd(int a, int b, int& x, int& y) {
//   if (b == 0) {
//     x = 1;
//     y = 0;
//     return a;
//   }  
//   int x1, y1;
//   int d = gcd(b, a % b, x1, y1);
//   x = y1;
//   y = x1 - y1 * (a / b);
//   return d;
// }   
// int lcm (int a, int b)  {
//   return a / gcd(a, b) * b;
// }   
// int fact(int n){
//   if(n==0) return 1 ;
//   else return n*fact(n-1); 
// }   

// bool isPrime(int x) {
//   for (int d = 2; d * d <= x; d++) if (x % d == 0) return false;
//   return true;
// }
double pi = 3.141592653589;

inline void solve() {
  float x, y; cin >> x >> y;

  float a = (4 * x - y) / 2;
  float b = (y - 2 * x) / 2;
  
  if (floor(a) != a or floor(b) != b or a < 0 or b < 0) cout << "No";
  else cout << "Yes";  
}    
int32_t main() {
 //c_p_c();
 //w(x)    
 solve();
 return 0;
}      

Measured memory_bytes: 3736
def gcd(a, b):
    if a < b: a, b = b, a
    while b > 0:
        r = a % b
        a, b = b, r
    return a

def lcm(a,b):
    return ((a*b) // gcd(a,b))

def getCnt(a,m):
    cnt = 0
    n = 1
    while(1):
        n = (a * n) % m
        cnt += 1
        if n == 1:
            return cnt

while(1):
    a1,m1,a2,m2,a3,m3 = (int(x) for x in input().split())
    if a1 == 0:
        break
    x = y = z = 1
    cnt1 = getCnt(a1,m1)
    cnt2 = getCnt(a2,m2)
    cnt3 = getCnt(a3,m3)

    ans = lcm(cnt1,cnt2)
    ans = lcm(ans,cnt3)
    print(ans)


Measured memory_bytes: 5600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[100010];
        for(int i=0; i<n; i++){
            int atmp = sc.nextInt();
            a[atmp]++;
            a[atmp+1]++;
            a[atmp+2]++;
        }
        sc.close();

        int[] num = new int[n];
        int max = 0;
        for(int i=0; i<100010; i++){
            if(a[i] > max){
                max = a[i];
            }
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 52332
// https://atcoder.jp/contests/abc133/tasks/abc133_c

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  ll L, R;
  cin >> L >> R;

  if (2100 < R - L)
  {
    cout << 0 << '\n';
  }
  else
  {
    ll minimum = INF;
    for (ll i = L; i < R + 1; i++)
    {
      for (ll j = i + 1; j < R + 1; j++)
      {
        minimum = min(minimum, (i * j) % 2019);
      }
    }
    cout << minimum << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << #x << " = " << x << endl


int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n, m;
	cin >> n >> m;
	int a[n], sum = 0;
	for(int &x: a)
		cin >> x, sum+=x;
	sort(a, a+n);
	bool ans = true;
	for(int i=n-1; i>=n-m; i--)
		if(a[i] < ceil(sum/(4.0*m))){
			ans = false;
			break;
		}

	cout << (ans? "Yes\n": "No\n");
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 100005;
const double PI =4*atan(1);

ll n;
ll c[N][3];
ll dp[2][3];


int main(){
    ios::sync_with_stdio(0);
    //freopen("baklava.in","r",stdin);
    cin.tie(0);
    cout.tie(0);
    //start
    cin >> n;
    for(int i=0;i<=2;i++){
    	dp[0][i]=0;
    }
    for(int i=0;i<n;i++){
    	for(int j=0;j<3;j++)
    	cin >> c[i][j];
    }
    for(int i=1;i<=n;i++){
    	ll pos=i&1;
    	for(int j=0;j<=2;j++)dp[pos][j]=0;
    	for(int j=0;j<3;j++){
    		for(int k=0;k<3;k++){
    			if(k==j)continue;
    			dp[pos][j]=max(dp[pos][j],c[i-1][j]+dp[pos^1][k]);
    		}
    	}
    }
    cout << max(dp[n&1][0],max(dp[n&1][1],dp[n&1][2]));
    

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll> a(n),b(m);
  vector<ll> ra(n+1),rb(m+1);
  ra[0]=0,rb[0]=0;
  rep(i,n){
    cin>>a[i];
    ra[i+1]=ra[i]+a[i];
  }
  rep(i,m){
    cin>>b[i];
    rb[i+1] = rb[i]+b[i];
  }
  ll ans=0;
  auto idx=upper_bound(All(ra),k)-ra.begin();
  for(int i=idx-1;i>=0;i--){
    auto idxb=upper_bound(All(rb),k-ra[i])-rb.begin();
    idxb--;
    //cout<<i<<" "<<idxb<<endl;
    ans=max(ans,(ll)i + idxb);
  }
  cout<<ans<<"\n";


  return 0;
}


Measured memory_bytes: 9532
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll h , n;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> h >> n;
	ll sum = 0 , k;
	for(int i = 1; i <= n ;++i) {
		cin >> k;
		sum += k;
	}
	if(sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
} 

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

int main(){
    int cnt[2];
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        cnt[0] = 0;
        cnt[1] = 0;
        for(int i = 0; i < n; i++){
            int a,b;
            cin >> a >> b;
            if(a > b){
                cnt[0] += a + b;
            }else if(a < b){
                cnt[1] += a + b;
            }else{
                cnt[0] += a;
                cnt[1] += b;
            }
        }
        cout << cnt[0] << " " << cnt[1] << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt=0;
    for(int i = 0; i < n; i++)
    {
        if(s[i]=='R') cnt++;
    }
    if(cnt>n-cnt) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

t_list = []
for i in range(n):
    tmp = int(input())
    t_list.append(tmp)

t_list.sort()
#print(t_list)

ans = 0
tmp = 0
pass_list = []
for t in t_list:
    #print(t)
    #print(pass_list)
    # 最初の乗客
    if len(pass_list) == 0:
        # バス追加
        ans += 1
        # 一番古い乗客の時間をメモ
        tmp = t
        # バスに乗せる
        pass_list.append(t)
        

    else:
        # 一番古い乗客の待ち時間が長い場合新しいバスを用意して乗せる
        if (t - tmp) > k:
            pass_list = []
            #print('バス追加1')
            ans += 1
            # 一番古い乗客の時間をメモ
            tmp = t

            pass_list.append(t)

        # バスに乗せる
        else:
            pass_list.append(t)

    # バスの定員が一杯の場合も新しいバスを用意する
    if len(pass_list) == c:
        pass_list = []
        #print('バス追加2')
        
print(ans)

Measured memory_bytes: 7384
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll mod=1e9+7;
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk,d; 
	scanf("%lld",&n);
	k=1;
	 d=1;
	for(i=1;i<=n;i++)
	{
		d=d*10%mod;
	}
	for(i=1;i<=n;i++)
	{
	   k=k*9%mod;	
	}
	kk=1;
	for(i=1;i<=n;i++)
	{
		kk=kk*9%mod;
	}
	ll kkk=1;
	for(i=1;i<=n;i++)
	{
		 kkk=kkk*8%mod;
	}
//	cout<<d<<endl;
	printf("%lld\n",(d-(((k+kk)%mod-kkk)+mod)%mod+mod)%mod);
	
} 

Measured memory_bytes: 3248
#include <cstdio>
#define Abs(A) A > 0 ? A : -A
long long A, B;
int main() {
	scanf("%lld%lld", &A, &B);
	if(A * B < 0) puts("Zero");
	else if(A > 0 && B > 0 || (A < 0 && B < 0 && ((Abs(A - B) & 1)))) puts("Positive");
	else puts("Negative");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
std::vector<int> G[100010];
std::deque<int> path;
bool used[100010];
int N, M;
int main() {
	std::cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		std::cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
		if (i == 0) {
			path.push_back(a);
			path.push_front(b);
			used[a] = used[b] = true;
		}
	}
	while (true) {
		bool flag = false;
		int d = path.front();
		for (auto u : G[d]) {
			if (!used[u]) {
				flag = true;
				used[u] = true;
				path.push_front(u);
				break;
			}
		}
		d = path.back();
		for (auto u : G[d]) {
			if (!used[u]) {
				flag = true;
				used[u] = true;
				path.push_back(u);
				break;
			}
		}
		if (!flag)break;
	}
	std::cout << path.size() << std::endl;
	for (int i = 0; i < path.size(); i++) {
		std::cout << path[i];
		if (i != path.size() - 1)std::cout << " ";
		else std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
double dp[3001][3001];
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
double solve(vector<double>&ar,int i,int j)
{

    if(j==0)
        return 1;
    if(i==0)
        return 0;
    if(dp[i][j]>-0.9)
        return dp[i][j];
    return dp[i][j]=ar[i]*solve(ar,i-1,j-1)+(1-ar[i])*solve(ar,i-1,j);


}
int main() {
	//code


	    int n;
	    cin>>n;
	    memset(dp,-1,sizeof(dp));
	    vector<double>ar(n+1);
	    for(int i=1;i<n+1;i++)
                    cin>>ar[i];
        prDouble(solve(ar,n,(n+1)/2));



}


Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC044A___高橋君とホテルイージー
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();
            string input3 = Console.ReadLine();
            string input4 = Console.ReadLine();

            int numberOfStay = int.Parse(input1);
            int boundNumberOfStay = int.Parse(input2);
            int firstHalfPrice = int.Parse(input3);
            int secondtHalfPrice = int.Parse(input4);
            int totalPrice = 0;

            bool isOverBoundNum = (numberOfStay - boundNumberOfStay > 0);
            if (isOverBoundNum)
            {
                totalPrice = firstHalfPrice * boundNumberOfStay + secondtHalfPrice * (numberOfStay - boundNumberOfStay);
            }
            else
            {
                totalPrice = firstHalfPrice * numberOfStay;
            }

           

            Console.WriteLine(totalPrice.ToString());
        }
    }
}


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


int main(){
    ll n,m;
    cin >> n >> m;
    auto a = vector<string>(n);
    auto b = vector<string>(m);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    queue<pair<int,int> > q;
    for(int i=0;i+m-1<n;i++){
       auto s=string::npos;
       do{
            s=a[i].find(b[0],s+1);
            if(s!=string::npos) q.push(make_pair(i,s));
       }while(s+b[0].size()<=a[i].size()&&s!=string::npos); 
    }
    
    
    bool f = false;
    while(!q.empty()){
        auto u = q.front();
        q.pop();
        f = false;
        for(int i=u.first;i-u.first<m&&i<n;i++){
               int j = i-u.first;
               if(j>=m){
                   f = false;
                   break;
               }
               if(a[i].substr(u.second,b[j].size()).find(b[j])==string::npos){
                    f= false;
                    break;
               }
               f=true;
        }
        if(f)break;
    }
    
    cout << (f?"Yes":"No");
    
    return 0;
}

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

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

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

struct UFT {
    vector<int> parent;
    vector<int> sz;

    UFT(int n) {
        parent.resize(n);
        sz.resize(n);
        rep(i, n) {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = root(parent[x]);
    }

    bool samegroup(int x, int y) { return root(x) == root(y); }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return;
        if (sz[x] < sz[y])
            swap(x, y);
        sz[x] += sz[y];

        // TODO: no rank check
        parent[y] = x;
    }

    int groups() {
        int ans = 0;
        rep(i, parent.size()) {
            if (root(i) == i) {
                ans++;
            }
        }
        return ans;
    }

    int size(int x) { return sz[root(x)]; }

    void dump() {
        rep(i, parent.size()) { printf("%d\t%d\n", i, size(i)); }
    }
};

int main() {
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    map<int, vector<int>> mp;
    UFT t(n + 1);

    int a, b, c, d;
    rep(i, m) {
        cin >> a >> b;
        mp[a].push_back(b);
        mp[b].push_back(a);
        t.unite(a, b);
    }
    rep(i, k) {
        cin >> c >> d;
        if (t.samegroup(c, d)) {
            mp[c].push_back(d);
            mp[d].push_back(c);
        }
    }

    for (int i = 1; i < n; i++) {
        printf("%d ", t.size(i) - mp[i].size() - 1);
    }
    printf("%d\n", t.size(n) - mp[n].size() - 1);
    // t.dump();

    return 0;
}


Measured memory_bytes: 14080
# -*- coding: utf-8 -*-
x,k,d = list(map(int,input().split()))

mv_cnt_near_zero = abs(x)//d
point_near_zero = abs(x)%d

ret = 0
if mv_cnt_near_zero >=k:
    ret = abs(x) - k * d
else:
    rest_can_mv = k - mv_cnt_near_zero
    if rest_can_mv % 2 ==0:
        ret = point_near_zero
    else:
        ret = abs(point_near_zero - d)

print(ret)

Measured memory_bytes: 9184
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class tenka1_2018_c {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        sort(begin(A), end(A));
        vector<int> B, C;
        for (int i = 0; i < (N + 1) / 2; ++i) {
            B.push_back(A[i]);
        }
        for (int i = (N + 1) / 2; i < N; ++i) {
            C.push_back(A[i]);
        }
        reverse(begin(C), end(C));
        vector<int> res;
        for (int turn = 0, i = 0, j = 0; (int)res.size() < N; turn = 1 - turn) {
            if (turn == 0)
                res.push_back(B[(i - 1 + (int)B.size()) % B.size()]), ++i;
            else
                res.push_back(C[j]), ++j;
        }
        long long sum1 = 0;
        for (int i = 1; i < N; ++i) {
            sum1 += abs(res[i] - res[i - 1]);
        }
    
        B.clear();
        C.clear();
        for (int i = 0; i < N / 2; ++i) {
            B.push_back(A[i]);
        }
        for (int i = N / 2; i < N; ++i) {
            C.push_back(A[i]);
        }
        reverse(begin(C), end(C));
        res.clear();
        for (int turn = 0, i = 0, j = 0; (int)res.size() < N; turn = 1 - turn) {
            if (turn == 0)
                res.push_back(C[(i - 1 + (int)C.size()) % C.size()]), ++i;
            else
                res.push_back(B[j]), ++j;
        }
        long long sum2 = 0;
        for (int i = 1; i < N; ++i) {
            sum2 += abs(res[i] - res[i - 1]);
        }
        out << max(sum1, sum2) << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	tenka1_2018_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int mod = (int)1e9 + 7;

int safe_mod(long long x, int m) {
  x %= m;
  if (x < 0) {
    x += m;
  }
  return (int)x;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum = safe_mod(sum + a[i], mod);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    sum = safe_mod(sum - a[i], mod);
    int prod = safe_mod((long long)a[i] * sum, mod);
    ans = (ans + prod) % mod;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
    long double a,b,c;
    cin >> a >> b >> c;
    if(a+b >= c){
        cout << "No" << endl;
        return 0;
    } else{
        c -= a+b;
        if(c*c > 4*a*b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main() {
    ll X;
    cin >> X;
    while(1){
        if( IsPrime(X)){
            break;
        }
        else{
            X++;
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		if(S.equals(T)) {
			System.out.println(0);
			return;
		}
		int count =0;
		for(int i =0;i<S.length();i++) {
			if(!S.substring(i,i+1).equals(T.substring(i,i+1))) {
				count++;
			}
		}

		System.out.println(count);
	}
}

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

int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}

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

  int n; cin >> n;
  vector<int> a(3*n+1,0);
  for(int i = 1; i <= 3*n; i++){
    cin >> a[i];
  }
  sort(a.begin()+1,a.end());

  int ans = 0;
  for(int i = n+1; i <= 3*n; i+=2){
    ans += a[i];
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
int A;
int B;
int C;
cin >> A;
cin >> B;
cin >> C;
if(A==B&&A==C){
  cout << "No";
}else if(B==C){
  cout << "Yes";
}else if(A==C){
  cout << "Yes";
}else if(A==B){
  cout << "Yes";
}else{
  cout << "No";
}
	return 0;
}


Measured memory_bytes: 3568
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b = LI()
if a+b >= 10:
    print("error")
else:
    print(a+b)
#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
"""
n,a,b = LI()
h = IR(n)
l = 0
r = math.ceil(max(h)/b)
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += max(0,math.ceil((h[i]-b*m)/(a-b)))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
//2008dC
I;int parse(char *p){
  switch(*p){
    case 'F': return 0;
    case 'T': return 1;
    case 'a': return (I>>0)&1;
    case 'b': return (I>>1)&1;
    case 'c': return (I>>2)&1;
    case 'd': return (I>>3)&1;
    case 'e': return (I>>4)&1;
    case 'f': return (I>>5)&1;
    case 'g': return (I>>6)&1;
    case 'h': return (I>>7)&1;
    case 'i': return (I>>8)&1;
    case 'j': return (I>>9)&1;
    case 'k': return (I>>10)&1;
    case '-': return !parse(p+1);
    case '(': {
                int x=0;
                p++;
                char *q=p;
                for(;;p++){
                  if(*p=='(')x++;
                  if(*p==')')x--;
                  if(x==0&&*p!='-')break;
                }
                p++;
                switch(*p){
                  case '*': return parse(q)&parse(p+1);
                  case '+': return parse(q)|parse(p+1);
                  case '-': return !parse(q)|parse(p+2);
                }
              }
  }
}

int main(){
  char p[1001],*q;
  while(1){
    scanf("%s",p);
    if(*p=='#')return 0;
	q=strchr(p,'=')+1;
for(I=0;I<2048;I++)if(parse(p)!=parse(q))goto fail;
    puts("YES");continue;
	fail:puts("NO");
  }
}

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

using namespace std;
int n, k,a[101], b[101], r;
int main()
{
    cin >> n >> k;
  for(int i =1; i<=n; ++i)
  {
      cin >> a[i];
      r += min(a[i], k - a[i])*2;
  }
 cout<<r;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    v_int a(n,k-q);

    rep(i,q) {
        int x;
        cin >> x;
        a[x-1]++;
    }

    rep(i,n) {
        if(a[i]<=0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 3764
n=int(input())
A=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append((a,b))
A.sort(key=lambda x:x[1])
tmp=0
cnt=0
for x,y in A:
    tmp+=x
    if tmp<=y:
        cnt+=1
if cnt==n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 73176
from collections import deque

n = int(input())
ranges = []

def medium(nList):
    nList.sort()
    q = deque(nList)
    while len(q) > 2:
        q.pop()
        q.popleft()
    if len(q) == 2:
        return (q[0] + q[1]) / 2
    else:
        return q[0]

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

m_min = medium(list(map(lambda r: r[0], ranges)))
m_max = medium(list(map(lambda r: r[1], ranges)))
d = m_max - m_min
if n % 2 == 0:
    print(int(d * 2) + 1)
else:
    print(d + 1)

Measured memory_bytes: 129524
import numpy as np
N, D = (int(x) for x in input().split())
points = []
for i in range(N):
    points.append(list(map(int, input().split())))
count = 0
for j in range(N):
    for i in range(j):
        if(i != j):
            pointi = np.array(points[i])
            pointj = np.array(points[j])
            if(np.linalg.norm(pointi - pointj) % 1 == 0):
                count += 1
        else:
            continue
print(count)

Measured memory_bytes: 18996
l = gets.to_i

hoge = (Math.log(l)/Math.log(3)).floor
node_count = 1 + hoge
edges = []

if hoge > 0
  node_count = 2 + hoge
  edges << [1, 2, 0]
  (node_count - 2).times do |i|
    edges << [node_count - i - 1, node_count - i, 0]
    edges << [node_count - i - 1, node_count - i, 3 ** i]
    edges << [node_count - i - 1, node_count - i, (3 ** i) * 2]
  end

  low = 3 ** hoge
  rem = l - low

  until rem <= 0
    fuga = (Math.log(rem)/Math.log(3)).floor
    edges << [1, node_count - fuga, low]
  
    low += 3 ** fuga
    rem = l - low
  end
else
  node_count = 2
  l.times do |i|
    edges << [1, 2, i]
  end
end

puts "#{node_count} #{edges.length}"
edges.each{|e| puts "#{e[0]} #{e[1]} #{e[2]}"}

Measured memory_bytes: 1788
import numpy as np
N, M = map(int, input().split())
 
Adj_matrix = np.zeros((N, N))
for _ in range(M):
    a, b = map(int, input().split())
    Adj_matrix[a - 1, b - 1] += 1
    Adj_matrix[b - 1, a - 1] += 1
    
def initialize():
    explored_list = np.zeros((N, 1))
    return explored_list
  
def is_move(vertex, explored_list, Adj_martrix):
    for i in range(len(explored_list)):
        if explored_list[i] == 0 and Adj_martrix[vertex - 1, i] == 1:
            return True
    return False
  
import copy
 
g_count = 0
 
def graph_exp(vertex, explored_list, Adj_matrix):
    global g_count
    
    explored_list[vertex - 1] += 1
    
    # Recursive End
    if not is_move(vertex, explored_list, Adj_matrix):
        g_count += all(explored_list)
        return 0
    
    # Recursive Call
    for i in range(len(explored_list)):
        if explored_list[i] == 0 and Adj_matrix[vertex - 1, i] == 1:
            graph_exp(i + 1, copy.copy(explored_list), Adj_matrix)
    
explored_list = initialize()
 
graph_exp(1, explored_list, Adj_matrix)
 
print(g_count)

Measured memory_bytes: 14476
import math

a,b,c,d = map(float, input().split()) 

e=6*d
f=30*c+0.5*d

if e<f:
    kakudo=f-e
else:
    kakudo=e-f
    
if kakudo>180:
    kakudo=360-kakudo

a2=a*a
b2=b*b
i=math.cos(math.radians(kakudo))
j=2*a*b*i
print(math.sqrt(a2+b2-j))


Measured memory_bytes: 9372
using System;

class A{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int N = Ar[0], A = Ar[1], B = Ar[2], AN = 0, BN = 0;
    string Temp = Console.ReadLine();
    for (int i = 0; i < N; i++){
      if (Temp.Substring(i, 1) == "c"){
        Console.WriteLine("No");
      }
      else if(Temp.Substring(i, 1) == "a"){ // kokunai
        if (A + B != AN + BN){
          AN++;
          Console.WriteLine("Yes");
        }
        else Console.WriteLine("No");
      }
      else if(Temp.Substring(i, 1) == "b"){ // kokugai
        if (A + B != BN + AN && BN != B){
          BN++;
          Console.WriteLine("Yes");
        }
        else Console.WriteLine("No");
      }
    }
  }
}
      

Measured memory_bytes: 34460
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define ll long long

int d = 365;
int k = 0;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;

    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        //cout << i << endl;
        last[out[i]] = i+1; // タイプ番号
        //cout << "out[" << i << "] " << out[i] << " ";
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
        //cout << "score : " << score << endl;
    }

    //int p = min(int(out.size()+k), int(d));
    //cout << p << endl;
    //if(out.size() >= d) return score;
    //cout << k << endl;
    //cout << out.size() << " " << d << endl;
    int p = min(int(out.size()+k), d);
    for(int i = out.size(); i < p; i++) {
        //cout << i << endl;
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i)-last[j]);
        }
        //cout << score << endl;
    }
    return score;
}

/*
vector<int> proc(int k) {
    vector<int> out;
    ll ans = 0;
    //ll tmp = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
    //cout << "k: " << k << endl;
    //vector<int> out;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    //}
    return out;
}
*/

int main() {
    init();
    /*
    vector<int> out;
    vector<int> ans;
    for(int i = 0; i <= 26; i++) {
        out = proc(i);
        for(int j = 0; j < out.size(); j++) {

        }
    }
    */
    
    vector<int> out;
    ll ans = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
        //cout << "k: " << k << endl;
        //vector<int> out;
        for(int i = 0; i < d; i++) {
            //max_v = -100000000000;
            max_v = LLONG_MIN;
            int best = 0;
            for(int j = 0; j < 26; j++) {
                out.push_back(j);
                ll tmp = calc(out);
                if(max_v < tmp) {
                    max_v = tmp;
                    best = j;
                }
                out.pop_back();
            }
            out.push_back(best);
        }
    //}
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,k;cin>>n>>k;
  deque<int> dq;
  int ans=0;
  rep(i,n){
    int v;cin>>v;
    dq.push_back(v);
  }
  rep(i,1,n+1){
    if(i>k)break;
    rep(j,i+1){
      auto cp=dq;
      vector<int> out;
      rep(t,j){
        out.push_back(cp.front());
        cp.pop_front();
      }
      rep(t,i-j){
        out.push_back(cp.back());
        cp.pop_back();
      }
      sort(all(out));
      rep(t,k-i){
        if(*out.begin()>=0||out.empty())break;
        out.erase(out.begin());
      }
      int tmpsum=0;
      rep(p,out.size())tmpsum+=out[p];
      chmax(ans,tmpsum);
    }
  }
  cout<<ans<<endl;
}        



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

int main() {
  string S;
  cin>>S;
  int a0=0;
  int a1=0;
  rep(i,S.size()){
    if(S[i]=='0') a0++;
    if(S[i]=='1') a1++;
  }
  int x = min(a0,a1);
  cout<<x*2<<endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(a[0] <= a[1] ? a[0] : a[0] - 1);
        }
    }
}



Measured memory_bytes: 13268
import math
N=input()

A = list(map(int, input().split()))

Rate = []
for i in range(9):
    Rate.append(0)

for i in A:
    index=math.floor(i/400)
    if index > 8:
        index = 8
    Rate[index] = Rate[index] + 1

a = 0

for i in range(8):
    if Rate[i] > 0:
        a=a+1

Max = a + Rate[8]
Min = max(a, 1)

print(Min, Max)



Measured memory_bytes: 3064
scan :: String -> Int
scan l = iter 0 0 (reverse l) where
    iter ac _ [] = ac
    iter ac c (x:xs)
        | x =='B' = iter (ac+c) c xs
        | x =='W' = iter ac (c+1) xs

main :: IO() 
main = do
    s <- getLine
    let ans = scan s
    print ans

Measured memory_bytes: 13948
#include <stdio.h>
int main(){
  int n,m,a[128][128],b[128],c;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    c=0;
    for(int j=0;j<m;j++){
      c+=a[i][j]*b[j];
    }
    printf("%d\n",c);
  }
}


Measured memory_bytes: 2144
N = input()
ndig = len(N)
ans1 = N[0] + "9" * (ndig - 1)
ans2 = str(int(N[0]) - 1) + "9" * (ndig - 1)
if int(ans1) <= int(N):
    print(sum(int(d) for d in ans1))
else:
    print(sum(int(d) for d in ans2))

Measured memory_bytes: 3060
n,k=map(int,input().split())
x=list(map(int,input().split()))

ans=10**9

for i in range(n-k+1):
  if x[i+k-1]<0:
    ans=min(ans,-x[i])
  elif x[i]>0:
    ans=min(ans,x[i+k-1])
  else:
    ans=min(ans,2*x[i+k-1]-x[i],2*(-x[i])+x[i+k-1])

print(ans)

Measured memory_bytes: 14568