akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=1e5+9,M=2*N;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
    G;while(*ip<'-')G;
    R x=*ip&15;G;
    while(*ip>'-'){x*=10;x+=*ip&15;G;}
    return x;
}
int he[N],ne[M],to[M],f[N],a[N],b[N];
int Getf(R x){
    return x==f[x]?x:f[x]=Getf(f[x]);
}
void Dfs(R x,R op){
    a[x]=op;
    for(R y,i=he[x];i;i=ne[i])
        if((y=to[i])!=f[x])
            f[y]=x,Dfs(y,-op),a[x]+=a[y];
}
int main(){
    R n=in(),m=in(),rt=1,re=1,p=0,ans=0;
    for(R i=1;i<=n;++i)f[i]=i;
    for(R p=0,i=1;i<=m;++i){
        R x=in(),y=in();
        if(Getf(x)!=Getf(y))f[f[x]]=f[y];
        else{rt=x,re=y;continue;}
        ne[++p]=he[x];to[he[x]=p]=y;
        ne[++p]=he[y];to[he[y]=p]=x;
    }
    f[rt]=0;Dfs(rt,1);
    if(n==m){
        for(R x=re;x;x=f[x])b[++p]=a[x];
        if(p&1){
            if(a[rt]&1)return puts("-1"),0;
            for(R x=re;x;x=f[x])a[x]-=a[rt]>>1;
        }
        else{
            if(a[rt])return puts("-1"),0;
            sort(b+1,b+p+1);
            for(R x=re;x;x=f[x])a[x]-=b[p>>1];
        }
    }
    else if(a[rt])return puts("-1"),0;
    for(R i=1;i<=n;++i)ans+=abs(a[i]);
    return cout<<ans<<endl,0;
}

Measured memory_bytes: 15044
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


int main() {
	double x1, y1, x2, y2, x3, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	double d1 = hypot(x1 - x2, y1 - y2);
	double d2 = hypot(x2 - x3, y2 - y3);
	double d3 = hypot(x3 - x1, y3 - y1);
	double s = (d1 + d2 + d3) * 0.5;
	double S = sqrt(s * (s - d1) * (s - d2) * (s - d3));
	double r = 2 * S / (d1 + d2 + d3);
	auto p = max(d1, max(d2, d3));
	cout << fixed << setprecision(15) << r * p / (p + 2 * r) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vi A(N);
    rep(i,N){
        cin >> A[i];
    }
    vi ans;
    int cnt=0;
    while(cnt<100 && A.size()){
        per(i,A.size()){
            if(A[i]-1==i) {
                ans.eb(A[i]);
                A.erase(A.begin()+i);
                break;
            }
        }
        cnt++;
    }
    if(A.size()==0){
        per(i,ans.size()){
            cout << ans[i] << "\n";
        }
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    int a = 0, b = 0, c = 0;

    for(int i=0; i<N; i++){
        int n; cin >> n;
        if(n%4 == 0) c++;
        else if(n%2 == 0) b++;
        else a++;
    }

    if(b == 0){
        if(c >= a-1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(c >= a) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  ll ans = 1;
  rep(i, N) {
    ans *= i+1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
  int H, W, count;
  cin >> H >> W;
  vector<vector<char>> S(H + 2, vector<char>(W + 2));
  vector<vector<string>> ans(H + 2, vector<string>(W + 2));
  for (int i = 0; i < W + 2; i++) S.at(0).at(i) = '.';
  for (int i = 1; i < H + 1; i++) {
    S.at(i).at(0) = '.';
    for (int j = 1; j < W + 1; j++) cin >> S.at(i).at(j);
    S.at(i).at(W + 1) = '.';
  }
  for (int i = 0; i < W + 2; i++) S.at(H + 1).at(i) = '.';
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (S.at(i).at(j) == '#') {
        ans.at(i).at(j) = "#";
        continue;
      }
      count = 0;
      if (S.at(i - 1).at(j - 1) == '#') count++;
      if (S.at(i - 1).at(j) == '#') count++;
      if (S.at(i - 1).at(j + 1) == '#') count++;
      if (S.at(i).at(j - 1) == '#') count++;
      if (S.at(i).at(j + 1) == '#') count++;
      if (S.at(i + 1).at(j - 1) == '#') count++;
      if (S.at(i + 1).at(j) == '#') count++;
      if (S.at(i + 1).at(j + 1) == '#') count++;
      string countstr = to_string(count);
      ans.at(i).at(j) = countstr;
    }
  }
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) cout << ans.at(i).at(j);
    cout << endl;
  }  
}


Measured memory_bytes: 384
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)


int main(int, char *[])
{
    int N;
    cin >> N;

    auto count2 = [] (int a) -> uint64_t
    {
        uint64_t n = 0;
        while(a > 1 && (a % 2) == 0)
        {
            ++n;
            a /= 2;
        }
        return n;
    };

    uint64_t sum = 0;
    for(int i = 0; i < N; ++i)
    {
        int v;
        cin >> v;
        sum += count2(v);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

def g(n):
    ret = 0
    for i in range(1, 100):
        n -= i
        if n < 0:
            break
        ret += 1
    return ret

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())

if N == 1:
    print(0)
else:
    f = factorization(N)
    f.sort(key = lambda x: -x[1])
    len_f = len(f)

    answer = 0
    for i in range(len_f):
        answer += g(f[i][1])
    print(answer)


Measured memory_bytes: 68252
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int treeLength = in.nextInt();
    ArrayList<Integer> values = new ArrayList<>();

    for (int i=0; i<treeLength; i++) {
        int tempInt = in.nextInt();
        values.add(tempInt);
    }

    for (int i=0; i<values.size(); i++) {
        System.out.print("node "+(i+1)+": key = "+values.get(i)+", ");
        if (i>0) {
            System.out.print("parent key = "+values.get((i-1)/2)+", ");
    }

    if ((2*i+1)<values.size()) {
        System.out.print("left key = "+values.get(2*i+1)+", ");
    }

    if ((2*i+2)<values.size()) {
        System.out.print("right key = "+values.get(2*i+2)+", ");
    }
        System.out.println();
        }
    }

}


Measured memory_bytes: 27140
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
ll a[10000];
ll first=INF,second=INF,third=INF;
int digit(ll p)
{
	if(p==0ll)return 1;
	int res=0;
	while(p>0ll)p/=10ll,res++;
	return res;
}
void update(ll k)
{
	if(k<first)third=second,second=first,first=k;
	else if(k<second)third=second,second=k;
	else if(k<third)third=k;
}
int main()
{
	vector<ll> vec;
	int n;
	cin >> n;
	for(int i=0;i<n;i++)cin >> a[i];
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ll k=((ll)pow(10,digit(a[i])))*a[j]+a[i];
			update(k);
			k=((ll)pow(10,digit(a[j])))*a[i]+a[j];
			update(k);
		}
	}
	cout << third << endl;
	return 0;
}

Measured memory_bytes: 1264
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
ans=0
for i in range(len(a)):
    cnt+=a[i]
    if cnt>x:
        print(ans)
        break
    else:
        ans+=1
else:
    if cnt!=x:
        print(ans-1)
    else:
        print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<math.h>
#include <stdlib.h>
#define M 100000
using namespace std;


int n, m,l, p = 0 , result = 0;
int x[100010];

int main(){
	scanf("%d %d",&n,&m);
	x[0] = 0;
	for (int i = 1; i < n; i++){
		scanf("%d", &x[i]);
		x[i] += x[i - 1];
	}
	while (m--){
		scanf("%d", &l);
		result += abs(x[p + l] - x[p]);
		result %= M;
		p += l;
	}
	printf("%d\n", result);
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    ll h,w; cin >> h >> w;
    ll c = 0, h1, h2;
    if(w%2 == 0){h1 = h2 = w/2;}
    else {h1 = w/2+1; h2 = w/2;}
    if(h == 1 || w == 1) {cout << 1 << endl; return 0;}

    for(int i = 0; i < h; i++){
        if(i % 2 == 0) c += h1;
        else c += h2;
    }
    cout << c << endl;
    return 0;
}

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

#define fastIO ios::sync_with_stdio(0); cin.tie(NULL);

typedef long long ll;

using namespace std;

int main(){

    fastIO

    string n; cin>>n;

    if(n[n.length()-1] != 's') cout<<n<<'s';

    else cout<<n<<"es";

    return 0;

}

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

int main(void){
 string S,T;
 cin >> S >> T;
  
 for(int i=0;i<S.size();i++){
 	if(S.at(i)!=T.at(i)){
    	cout << "No" << endl;
      	return 0;
    }
 }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
using namespace std;

const int BS=18;

void bitadd(int *bit,int i,int v)
{
  int p=i+1;
  while(p<1<<BS){
    bit[p]=max(bit[p],v);
    p+=p&-p;
  }
}

int bitmax(int *bit,int i)
{
  int p=i+1,ret=-1000000000;
  while(p>0){
    ret=max(ret,bit[p]);
    p-=p&-p;
  }
  return ret;
}




int main()
{
  int n;
  scanf("%d",&n);
  static int a[200000],b[200000];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    b[a[i]-1]=i;
  }
  long long ans=00l;
  static int bit1[1<<18]={0},bit2[1<<18];
  for(int i=0;i<(1<<18);i++){
    bit1[i]=-1;
    bit2[i]=-n;
  }
  for(int i=0;i<n;i++){
    int j=b[i];
    int L=bitmax(bit1,j),R=-bitmax(bit2,n-j-1);
    ans+=(long long)(i+1)*(j-L)*(R-j);
    bitadd(bit1,j,j);
    bitadd(bit2,n-j-1,-j);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(b >= 100) a *= 1000;
  else if(b >= 10) a *= 100;
  else a *= 10;
  double c = sqrt(a + b);
  if(c - int(c) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <random>
#include <cmath>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using ld = long double;

const int mod = 998244353;

ll binpow(ll a, int p = mod - 2) {
    ll res = 1;
    while (p) {
        if (p & 1) {
            (res *= a) %= mod;
        }
        p >>= 1;
        (a *= a) %= mod;
    }
    return res;
}

const int N = 1e7 + 1;

ll f[N], fr[N];
ll pw[N];

ll cnk(int n, int k) {
    return f[n] * fr[k] % mod * fr[n - k] % mod;
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    f[0] = fr[0] = 1;
    pw[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = f[i - 1] * i % mod;
        fr[i] = binpow(f[i]);
        pw[i] = pw[i - 1] * 2 % mod;
    }
    ll ans = binpow(3, n);
    for (int i = n / 2 + 1; i <= n; i++) {
        ll keks = cnk(n, i) * pw[n - i + 1] % mod;
        ans = (ans - keks + mod) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int h;
	int n;
	cin >> h >> n;
	int a[n];
	long long sum = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
	}
	if(sum >= h){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100];
int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }

    ll w;
    ll w2;
    if(sum>=0)
     {w=(sum+n-1)/n;
     w2=w-1;}
     else
       {w=(sum-n+1)/n;
       w2=w+1;}
    ll tot1=0;
    ll tot2=0;
    for(int i=1;i<=n;i++)
    {
        tot1+=pow(abs(a[i]-w),2);
        tot2+=pow(abs(a[i]-w2),2);
    }
    cout<<min(tot1,tot2)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int concat(int x, int y){
    char str1[20];
char str2[20];
    sprintf(str1,"%d",x);
    sprintf(str2,"%d",y);

    strcat(str1,str2);

    return atoi(str1);
}
int main()
{

    int x,y,z,i,j,c=0;
    cin>>x>>y;
    z=concat(x,y);
    for(i=1;i*i<=z;i++)
    {
        if(i*i==z)
            c=1;
    }
    if(c==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}





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

int main(void){
  string s; cin >> s;
  if((s.at(0) != 'R' && s.at(0) != 'U' && s.at(0) != 'D')){
    printf("No");
    return 0;
  }
  for(int i = 1; i < s.length(); i++){
    if(i%2 == 1 && (s.at(i) != 'L' && s.at(i) != 'U' && s.at(i) != 'D')){
      printf("No");
      return 0;
    }
    else if(i%2 == 0 && (s.at(i) != 'R' && s.at(i) != 'U' && s.at(i) != 'D')){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

bool check(string s){
	int n = sz(s);
	bool c =	1;
	FOR(i, 0, n){
		c&=(s[i]==s[n-i-1]);
	}
	return c;
}
void solve(){
	string s, a="";
	cin>>s;
	int n = sz(s);
	if(check(s) && check(s.substr(0, (n-1)/2)) && check(s.substr((n+1)/2))){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type Restaurant struct {
	name  string
	point int
	inedx int
}
type Restaurants []Restaurant

func (r Restaurants) Len() int      { return len(r) }
func (r Restaurants) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
func (r Restaurants) Less(i, j int) bool {
	if r[i].name == r[j].name {
		return r[i].point > r[j].point
	}
	return r[i].name < r[j].name
}

func main() {
	var n int
	fmt.Scan(&n)
	var rs Restaurants = make([]Restaurant, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&rs[i].name, &rs[i].point)
		rs[i].inedx = i + 1
	}
	sort.Sort(rs)
	for _, v := range rs {
		fmt.Println(v.inedx)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  vi a, b;
  rep(i, n)
  {
    ll _a;
    cin >> _a;
    a.push_back(_a);
  }

  rep(i, m)
  {
    ll _b;
    cin >> _b;
    b.push_back(_b);
  }

  int ans = 0;

  ll a_k = 0;
  int a_index = -1;

  ll b_k = 0;
  int b_index = -1;

  // b読める分だけ読む
  while(b_index + 1 < m && b_k + b[b_index + 1] <= k) {
    b_index++;
    b_k += b[b_index];
  }

  ans = b_index + 1;

  // while(a_index < a.size())
  for (int i = 0; i < n; i++)
  {
    a_index++;
    a_k += a[a_index];

    // bを減らす
    while (a_k + b_k > k && b_index >= 0)
    {
      b_k -= b[b_index];
      b_index--;
    }

    if (a_k + b_k > k) {
      break;
    }
    ans = max(ans, a_index + b_index + 2);
  }

  cout << ans << endl;
}


Measured memory_bytes: 5552
n , t = map(int,input().split())
a = list(map(int,input().split()))
mx = 0
l = []
for i in a[::-1]:
    mx = max(mx,i)
    l.append(mx-i)
l.sort()
res = 0
for i in l[::-1]:
    if i==l[-1]:
        res+=1
    else:
        break
print(res)

Measured memory_bytes: 15020
/*input
10
3 3 3 3 4 4 4 5 5 5
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
ll arr[100000];
map<ll,ll>m;
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
			scanf("%lld",&arr[i]);
			m[arr[i]]++;
	}
	sort(arr,arr+n);
	ll s1=0,s2=0;
	for(ll i=n-1;i>=0;i--)
	{
		if(m[arr[i]]>1)
		{
			s1=arr[i];
			m[arr[i]]-=2;
			break;
		}
	}
	for(ll i=n-1;i>=0;i--)
	{
		if(m[arr[i]]>1)
		{
			s2=arr[i];
			m[arr[i]]-=2;
			break;
		}
	}
	cout<<s1*s2<<endl;
}

Measured memory_bytes: 7296
from collections import defaultdict
n = int(input())
O = defaultdict(list)
for i in range(n):
    F = list(map(int, input().split()))
    for j in range(10):
        if F[j] == 1:
            O[j].append(i)
P = []
for _ in range(n):
    _P = list(map(int, input().split()))
    P.append(_P)

max_x = -1 * 10 ** 10
for i in range(1, 1024):
    v = i
    K = [] # Kaburi
    for j in range(10):
        if v % 2 == 1:
            K.extend(O[j])
        v //= 2
    #print(K)
    x = 0
    for l in range(n):
        k = K.count(l)
        x += P[l][k]
    max_x = max(max_x, x)
print(max_x)


Measured memory_bytes: 41692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int n; cin >> n;
	string a, b; cin >> a >> b;
	int ans = 0;
	for (int i = 0; i < a.size(); ++i)
	{
		for (int j = 0; j < b.size(); ++j)
		{
			if(a[i + j] != b[j]) break;
			if(i + j == a.size() - 1){
				printf("%d\n", n + i);
				return 0;
			}
		}
	}
	printf("%d\n", 2 * n);
	return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n;
  while(cin >> n, n) {
    vector<pii> a;
    rep(i, n) {
      int c, m1, s1, m2, s2, m3, s3, m4, s4;
      cin >> c >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
      int sum = (m1+m2+m3+m4)*60 + (s1+s2+s3+s4);
      a.push_back(make_pair(sum, c));
    }
    sort(all(a));
    vector<pii>::iterator it = a.begin();
    cout << it->second << endl; it++;
    cout << it->second << endl;

    it = a.end(); it -= 2;
    cout << it->second << endl;
  }
}

Measured memory_bytes: 1304
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <bitset>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);

constexpr int64 MOD = 1000000007;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vint> a(h, vint(w)), b(h, vint(w));
    Rep(i, h)
    {
        Rep(j, w)
        {
            cin >> a[i][j];
        }
    }
    Rep(i, h)
    {
        Rep(j, w)
        {
            cin >> b[i][j];
        }
    }

    int maxK = 80 * (h + w);
    vector<vector<vint>> dp(h, vector<vint>(w, vint(maxK)));

    dp[0][0][abs(a[0][0] - b[0][0])] = 1;
    InitRep(j, 1, w)
    {
        int currentDif = abs(a[0][j] - b[0][j]);
        Rep(k, maxK)
        {
            if (dp[0][j - 1][k])
            {
                dp[0][j][k + currentDif] = 1;
                dp[0][j][abs(k - currentDif)] = 1;
            }
        }
    }

    InitRep(i, 1, h)
    {
        int rowHeadDif = abs(a[i][0] - b[i][0]);
        Rep(k, maxK)
        {
            if (dp[i - 1][0][k])
            {
                dp[i][0][k + rowHeadDif] = 1;
                dp[i][0][abs(k - rowHeadDif)] = 1;
            }
        }

        InitRep(j, 1, w)
        {
            int currentDif = abs(a[i][j] - b[i][j]);
            Rep(k, maxK)
            {
                if (dp[i - 1][j][k] || dp[i][j - 1][k])
                {
                    dp[i][j][k + currentDif] = 1;
                    dp[i][j][abs(k - currentDif)] = 1;
                }
            }
        }
    }

    Rep(k, maxK)
    {
        if (dp[h - 1][w - 1][k])
        {
            cout << k << endl;
            return 0;
        }
    }

    return 1;
}


Measured memory_bytes: 324736
#include<stdio.h>

int main (void){

    double a,b,c,d,e,f;

    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){

        double X,Y;

        Y = (c*d-f*a)/(b*d-e*a);

        X = (c*e-f*b)/(a*e-d*b);

        printf("%.3lf %.3lf\n",X+0.0004 ,Y+0.0004);
    }

    return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 100010

using namespace std;

int n, m, indeg[maxn], F[maxn], res;
vector<int> A[maxn];
queue<int> Q;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(indeg, 0, sizeof(indeg));
	cin >> n >> m;
	FOR(i, 1, m) {
        int u, v;
        cin >> u >> v;
        A[u].push_back(v);
        ++indeg[v];
	}
	memset(F, 0, sizeof(F));
    FOR(i, 1, n)
        if (!indeg[i]) Q.push(i);
    res = 0;
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        res = F[u];
        if (A[u].empty()) continue;
        FOR(i, 0, A[u].size()-1) {
            F[A[u][i]] = max(F[A[u][i]], F[u]+1);
            if ((--indeg[A[u][i]]) == 0)
                Q.push(A[u][i]);
        }
    }
    cout << res;
	return 0;
}


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

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);
 
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;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
    ll n, T;
    cin >> n >> T;
    
    ll ans = 0;
    ll pret = 0;
    for(ll i = 0; i < n; i++){
        ll t = 0;
        cin >> t;

        if(t - pret <= T){
            ans += t - pret;
        }else{
            ans += T;
        }

        pret = t;
    }
    cout << ans+T << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, w[100], sw[100] = {};
	cin >> n;
	rep(i, n){
		cin >> w[i];
		if(i == 0) sw[0] = w[0];
		else sw[i] = sw[i - 1] + w[i];
	}
	int s = sw[n - 1];
	int ans = 1000000;
	rep(i, n){
		chmin(ans, abs(s - 2 * sw[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

a = int(input())
b = int(input())
c = int(input())
x = int(input())

num = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if(500 * i + 100 * j + 50 * k == x):
                num += 1

print(num)

Measured memory_bytes: 19212
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
 
 public class Main {
   public static void main(String[] args) throws IOException {
     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
     int n = Integer.parseInt(in.readLine());
     StringTokenizer stk = new StringTokenizer(in.readLine());
     in.close();
     String s = stk.nextToken();
     int diff = s.replaceAll("ABC","").length();
     System.out.println((n-diff)/3);
   }
 }

Measured memory_bytes: 22228
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define PI acos(-1)
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a) * (b)).imag()
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define Y imag()
#define X real()
#define EPS 1e-7
#define mod 1000000007
#define N 1e2
using namespace std;
typedef complex <ld> point;
typedef vector <point> polygon;
typedef tuple <ld, ld, ld> line;
typedef vector <point> spolygon;

line lineeq(point x, point y){
	ll a = y.Y - x.Y;
	ll b = x.X - y.X;
	ll c = -a * x.X - b * x.Y;
	ll gcd = abs(__gcd(a, __gcd(b, c)));
	if(a < 0 || (a == 0 && b < 0)) gcd *= -1;
	a /= gcd; b /= gcd; c /= gcd;
	return line(a, b, c);
}

point getpoint(line l1, line l2){
	ld y = (get<0>(l1) * get<2>(l2) - get<0>(l2) * get<2>(l1)) / (get<0>(l2) * get<1>(l1) - get<0>(l1) * get<1>(l2));
	ld x = (get<2>(l1) * get<1>(l2) - get<2>(l2) * get<1>(l1)) / (get<0>(l2) * get<1>(l1) - get<0>(l1) * get<1>(l2));
	return point(x, y);
}

bool onray(point a, point b, point c){
	return dot(b - a, c - a) > -EPS;
}

ll fact(ll n){
	if(n == 0) return 1;
	return n * fact(n - 1);
}

bool isPrime(ll q){
	if(q == 0 || q == 1) return false;
	for(int i = 2; i * i <= q; i++) if(q % i == 0) return false;
	return true;
}

point rotate(point p, ld a){
	return p * polar((ld)1, a * PI / 180);
}

bool canBe(line l1, line l2){
	if(get<0>(l2) * get<1>(l1) - get<0>(l1) * get<1>(l2) != 0) return true;
	return false;
}

ld getangle(point p){
	return arg(p) * 180 / PI;
}

ll fp(ll base, ll x){
	if(x == 0) return 1;
	ll ans = fp(base, x / 2);
	ans = (ans * ans) % mod;
	if(x % 2)
		ans = ((base % mod) * ans) % mod;
	return ans;
}

ll GCD(ll a, ll b){
	if(b == 0) return a;
	if(a == 0) return b;
	return GCD(b, a % b);
}

ll LCM(ll a, ll b){
	return (a * b) / GCD(a, b);
}


ll fac[(int)1e4 + 7], inv[(int)1e4 + 7];

void calcFacAndInv(ll n){
    fac[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fac[i] = (i * fac[i - 1]) % mod;
        inv[i] = fp(fac[i], (ll)mod - 2);
    }
}

ll ncr(ll n, ll r){
    return ((fac[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r){
    return (fac[n] * inv[n - r]) % mod;
}

ll p[55][55] = {};

void pascal(){
    p[0][0] = 1;
    for(int i = 1; i < 55; i++) {
        p[i][0] = 1;
        for(int j = 1; j <= i; j++) p[i][j] = p[i - 1][j] + p[i - 1][j - 1];
    }
}

int main() {
	Data_Nerd
	int n; cin >> n;
	int arr[n], sum[n];
	for(int i = 0; i < n; cin >> arr[i++]);
	sum[0] = 0, sum[1] = abs(arr[0] - arr[1]);
	for(int i = 2; i < n; i++){
		sum[i] = min(abs(arr[i] - arr[i - 2]) + sum[i - 2], abs(arr[i] - arr[i - 1]) + sum[i - 1]);
	}
	cout << sum[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

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

	N = sqrt(N);

	cout << N * N << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Range Product
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	if a > 0 && b > 0 {
		fmt.Println("Positive")
	} else if b >= 0 && a <= 0 {
		fmt.Println("Zero")
	} else {
		if (b-a+1)%2 == 0 {
			fmt.Println("Positive")
		} else {
			fmt.Println("Negative")
		}
	}
}


Measured memory_bytes: 1836
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	cin>> s;
	bool b = false;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '9') b = true;
	}
	if (b) cout << "Yes";
	else cout << "No";
    return 0;
}

Measured memory_bytes: 256
from itertools import product
n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a2,ans = [0],float("inf")
for i in range(n): a2.append(max(a[i],a[-1]))
def g(q):
	c,f = 0,1
	if sum(q)<k-1: f = 0
	else:
		m = a[0]
		for i in range(n-1):
			if q[i]: m,c = max(a[i+1],m+1),c+max(m+1-a[i+1],0)
			elif m<a[i+1]:
				f = 0
				break
	if f: return c
	else: return float("inf")
for i in product((0,1),repeat=n-1): ans = min(ans,g(i))
print(ans)

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  const int64_t mod = 1000000007;
  int64_t n, m;
  std::cin >> n >> m;
  std::vector<int64_t> x(n), y(m);
  std::cin >> x >> y;

  std::vector<int64_t> x_l(n - 1), y_l(m - 1);

  for (int64_t i = 0; i < n - 1; i++) {
    x_l[i] = x[i + 1] - x[i];
  }

  for (int64_t i = 0; i < m - 1; i++) {
    y_l[i] = y[i + 1] - y[i];
  }

  int64_t x_sum = 0;

  for (int64_t i = 0; i < x_l.size(); i++) {
    const int64_t r = ((i + 1) * (x_l.size() - i)) % mod;
    const int64_t v = (r * x_l[i]) % mod;
    x_sum += v;
    x_sum %= mod;
  }

  int64_t y_sum = 0;

  for (int64_t i = 0; i < y_l.size(); i++) {
    const int64_t r = ((i + 1) * (y_l.size() - i)) % mod;
    const int64_t v = (r * y_l[i]) % mod;
    y_sum += v;
    y_sum %= mod;
  }

  std::cout << (x_sum * y_sum) % mod << std::endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int n,x;
    cin>>n>>x;
    int ans=1,sum=0;
    for(int i=0;i<n;++i){
        int l;
        cin>>l;
        sum+=l;
        if(sum>x)break;
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

signed main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(auto& x : a)
        cin >> x;
    // l: 立っているものの数 0の時はこれが加算される
    vector<ll> l(45, 0);
    for(ll i = 0; i < n; ++i){
        for(ll j = 0; j < 45; ++j){
            if(a[i] & (1LL << j))
                ++l[j];
        }
    }

    vector<ll> dp(2, -INF);
    dp[1] = 0;
    for(ll i = 44; i >= 0; --i){
        vector<ll> nex(2, -INF);
        if(dp[0] != -INF){
            nex[0] = max(nex[0], dp[0] + (1LL << i) * (n - l[i]));
            nex[0] = max(nex[0], dp[0] + (1LL << i) * l[i]);
        }

        if(dp[1] < 0)
            continue;
        // 立てる場合
        if(k & (1LL << i)){
            nex[1] = max(nex[1], dp[1] + (1LL << i) * (n - l[i]));
            // 限界まで伸ばす
            nex[0] = max(nex[0], dp[1] + (1LL << i) * l[i]);
        }else{
            // 立てられない場合
            nex[1] = max(nex[1], dp[1] + (1LL << i) * l[i]);
        }
        dp = move(nex);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}


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

int main(){
  int c[3][3];
  rep(i,3) rep(j,3) cin>>c[i][j];
  bool ok=0;
  for(int i=0;i<=c[0][0];i++){
    for(int j=0;j<=c[1][1];j++){
      for(int k=0;k<=c[2][2];k++){
        int a[3],b[3];
        a[0]=i;
        b[0]=c[0][0]-i;
        a[1]=j;
        b[1]=c[1][1]-j;
        a[2]=k;
        b[2]=c[2][2]-k;
        bool f=1;
        rep(s,3){
          rep(t,3){
            if(c[s][t]!=a[s]+b[t]) f=0;
          }
        }
        if(f) ok=1;
      }
    }
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
su = sum(a)
acc = list(itertools.accumulate(a))
b = [abs((su-acc[i]) - acc[i]) for i in range(n-1)]
# print(b)
print(min(b))


Measured memory_bytes: 30404
#include <algorithm>
#include <iostream>

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

// two-sequences.cpp --- Two Sequences
// author: Seong Yong-ju <sei40kr@gmail.com>

using namespace std;

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

  int as[n], bs[n];
  REP(i, n) { cin >> as[i]; }
  REP(i, n) { cin >> bs[i]; }

  int ans = 0;

  REP(k, 29) {
    int t = 1 << k;

    int ys[n];
    REP(i, n) { ys[i] = bs[i] % (t << 1); }
    sort(ys, ys + n);

    REP(i, n) {
      int x = as[i] % (t << 1);

      int *p1 = lower_bound(ys, ys + n, t - x);
      int *p2 = lower_bound(p1, ys + n, (t << 1) - x);
      int *p3 = lower_bound(p2, ys + n, (t << 1) + t - x);

      ans ^= (((p2 - p1) + ((ys + n) - p3)) & 1) << k;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
 
int main(){
  int N,num[100];
  int i,j=0,flag,res,count=0;
 
  scanf("%d",&N);
   
   
  for(i=0;i<N;++i){
    scanf("%d",&num[i]);
  }
 
  while(j!=N){
    flag=1;
 
    while(flag){
    flag=0;
 
  for(i=N-1;i>0;--i){
    if(num[i]<num[i-1]){
      res=num[i];
      num[i]=num[i-1];
      num[i-1]=res;
      ++count;
      flag=1;
    }
  }
    }
  ++j;
  }
 
  for(i=0;i<N;i++){
    printf("%d",num[i]);
    if(i!=N-1) printf(" ");
    else printf("\n");
  }
 
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 604
n = gets.chomp.to_i
res = 0.to_f
for a in 1..n
  xx, uu = gets.chomp.split.map(&:to_s)
  if uu == "BTC"
    res = res + xx.to_f * 380000.0
  else
    res = res + xx.to_f
  end
end
puts res


Measured memory_bytes: 1788
import sys 
import math
try:
    sys.stdin = open('input.txt', 'r') 
    sys.stdout = open('output.txt', 'w')
except:
    pass

input = sys.stdin.readline
ht,st,ha,sa = map(int,input().split())
t = math.ceil(ht/sa)
a = math.ceil(ha/st)
if t>=a:
	print("Yes")
else:
	print("No")
	



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

int main()
{
    int n,z,mx,mn;
    long long int sm;
    cin>>n;
    cin>>z;
    mx=z;mn=z;sm=z;
    for(int i = 0;i<n-1;i++) {
        cin>>z;
        if(z>mx) mx=z;
        else if(z<=mn)mn=z;

        sm = sm + z;
    }
    cout<<mn<<" "<<mx<<" "<<sm<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll n;  cin >> n;
    ll ans = 0;

    for (ll i = 0; i < n-1; i++) {
        ans += (n-i)*(n-i+1)/2;
        ll u, v;   cin >> u >> v;
        if (u > v)
            swap(u, v);

        ans -= u*(n-v+1);
    }

    ans += 1;

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

Measured memory_bytes: 3616
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new aoj1216().doIt();
    }
    class aoj1216{	
    	double distance(double a,double b,double c,double a2,double b2,double c2){
    		return Math.sqrt((a-a2)*(a-a2)+(b-b2)*(b-b2)+(c-c2)*(c-c2));
    	}
    	void doIt(){
    		int n = sc.nextInt();
    		for(int i = 0;i < n;i++){
    			double P = sc.nextDouble();
    			double R = sc.nextDouble();
    			double Q = sc.nextDouble();
    			int m = sc.nextInt();
    			double p[] = new double[m];
    			double r[] = new double[m];
    			double q[] = new double[m];
    			for(int j = 0;j < m;j++){
    				p[j] = sc.nextDouble();
    				r[j] = sc.nextDouble();
    				q[j] = sc.nextDouble();
    			}
    			for(int j = 0;j < m;j++){
    				for(int k = 0;k < m;k++){
    					double t = distance(p[j],r[j],q[j],p[k],r[k],q[k]);
    					for(int l = 0;l < m;l++){
    						if(j == k || k == l || l == j)continue;
    						if(Math.abs(distance(p[j],r[j],q[j],p[l],r[l],q[l])/t - R/P) < 1e-3){
    							if(Math.abs(distance(p[k],r[k],q[k],p[l],r[l],q[l])/t - Q/P) < 1e-3){
    								System.out.println((l+1)+" "+(k+1)+" "+(j+1));
    								j = k = l = m; 
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    }
}

Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    string s;
    std::cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<pair<int,int>> vL;
vector<pair<int,int>> vR;
int t;
int n;
set<int> sL;
set<int> sR;
#define fi first
#define se second
int main(){
	cin>>t;
	while(t--){
		ll ans = 0;
		cin>>n;
		vL.clear();
		vR.clear();
		for(int i=0;i<n;i++){
			int k,l,r;
			cin>>k>>l>>r;
			if(l<r) vR.push_back({l-r,k});
			else vL.push_back({l-r,k});
			ans += r;
		}
		for(int i=1;i<=vL.size();i++) sL.insert(i);
		for(int i=vL.size()+1;i<=n;i++) sR.insert(i);
		sort(vL.begin(),vL.end(),greater<pair<int,int>>());
		sort(vR.begin(),vR.end());
		for(auto i:vL){
			auto tmp = sL.upper_bound(i.se);
			if(tmp == sL.begin()){
				sL.erase(--sL.end());
			}else{
				ans += i.fi;
				sL.erase(--tmp);
			}
		}
		for(auto i:vR){
			auto tmp = sR.upper_bound(i.se);
			if(tmp == sR.end())	{
				sR.erase(sR.begin());
				ans += i.fi;
			}
			else{
				sR.erase(tmp);
			}		
		}
		cout<<ans<<endl;
	}
	
	return 0;
}




Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
	string s; cin >> s;
	bool ok = true;
	for(int i = 0; i < s.size(); i++){
		char c = s[i];
		if(i % 2 == 0) if(c == 'L') ok = false;
		if(i % 2 == 1) if(c == 'R') ok = false;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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


Measured memory_bytes: 2108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if(A * N < B){
            System.out.println(A * N);
        }else{
            System.out.println(B);
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#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__)
constexpr int INF = 1001001001;
using ll = long long;
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    
    vector<vector<int>> dp(3, vector<int>(n+1, 0));
    
    rep(i, n) {
        dp[0][i+1] = max(dp[1][i] + b[i], dp[2][i] + c[i]);
        dp[1][i+1] = max(dp[0][i] + a[i], dp[2][i] + c[i]);
        dp[2][i+1] = max(dp[0][i] + a[i], dp[1][i] + b[i]);
    }
    
    int ans = max(dp[0][n], max(dp[1][n], dp[2][n]));
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2944
import sys


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        return -self.root[self.find(x)]


input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N, M = map(int, input().split())
uf = UF_tree(N)
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

town = set([uf.find(i) for i in range(N)])
print(len(town) - 1)

Measured memory_bytes: 19768