akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

int dp[105][64];

const int A = 0;
const int C = 1;
const int G = 2;
const int T = 3;

map<char, int> MP = {{'A', A}, {'C', C}, {'G', G}, {'T', T}, {'.', 0}, {'x', 3}};

vector<string> badPre = {".AC", ".CA", ".AG", "A.C", "AC."};
vector<string> mask =   {".xx", ".xx", ".xx", "x.x", "xx."};
vector<int> badNext =   {    G,     G,     C,     G,     G};

// convert from string representation to dp array index
inline int convert(string s) {
    int r = 0;
    for(char c : s) {
        r = r<<2;
        r |= MP[c];
    }
    return r;
}

// restricts bad secuences
bool ok(int pre, int next) {
    for(int i = 0; i < 5; i++) {
        if((pre & convert(mask[i])) == convert(badPre[i]) && next == badNext[i] ) {
            return false;
        }   
    }

    return true;
}

int nextIndex(int pre, int next) {
    pre = pre & 15;
    pre <<= 2;
    pre |= next;
    return pre;
}

int main() {

    int n;
    cin >> n;

    for(int i = 0; i < 64; i++) {
        dp[3][i] = 1;
    }
    dp[3][convert("ACG")] = 0;
    dp[3][convert("CAG")] = 0;
    dp[3][convert("AGC")] = 0;

    for(int i = 4; i <= n; i++) {
        for(int seq = 0; seq < 64; seq++) {
            for(int letter = 0; letter < 4; letter++) {
                if(ok(seq, letter)) {
                    dp[i][nextIndex(seq, letter)] += dp[i-1][seq];
                    dp[i][nextIndex(seq, letter)] %= MOD;
                }
            }
        }
    }

    int result = 0;

    for(int i = 0; i < 64; i++) {
        result += dp[n][i];
        result %= MOD;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

const int INF = 100000;
typedef pair<int, int> P;

ll n, m;
int sx, sy;
int gx, gy;

//移動方向のベクトル
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	cin >> n;
	int ans = 0;
	int b[17] = { 0 };
	int x = 0;
	while (n > 0){
		b[x] = n % 10;
		x++;
		n /= 10;
    }
	for (int i = x - 1; i > 0; i--) {
		if (b[i] + b[i - 1] > b[i] - 1 + 9) ans += b[i];
		else {
			ans += b[i] - 1;
			for (int j = 0; j < x; j++) b[j] = 9;
		}
	}
	ans += b[0];
	cout << ans << endl;
	int qqq; cin >> qqq;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define sqr(x) (x)*(x)
using namespace std;
int fx[2005][2005],fy[2005][2005];
int n,m,i,j,ans=-1<<25,x,y,z,cnt;
char c;
int query(int x,int y,int xx,int yy)
{
	if (x>xx||y>yy) return 0;
	return fy[xx][yy]-fy[x-1][yy]-fy[xx][y-1]+fy[x-1][y-1];
}
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		cin>>x>>y>>c;
		if (c=='B')
		{
			fx[(x%(m*2)+(m*2))%(m*2)+1][(y%(m*2)+(m*2))%(m*2)+1]++; 
		}
		else
		{
			cnt++;
			fx[(x%(m*2)+(m*2))%(m*2)+1][(y%(m*2)+(m*2))%(m*2)+1]--; 
		}
	}
	for (i=1;i<=m*2;i++)
	{
		for (j=1;j<=m*2;j++)
		{
			fy[i][j]=fy[i-1][j]+fy[i][j-1]-fy[i-1][j-1]+fx[i][j];
		}
	}
	for (i=m;i<=m*2;i++)
	{
		for (j=m;j<=m*2;j++)
		{
			int t=cnt;
			t+=query(i-m+1,j-m+1,i,j);
			t+=query(i+1,j+1,m*2,m*2);
			t+=query(1,1,i-m,j-m);
			t+=query(1,j+1,i-m,m*2);
			t+=query(i+1,1,m*2,j-m);
			ans=max(ans,t);
			t=n-cnt;
			t-=query(i-m+1,j-m+1,i,j);
			t-=query(i+1,j+1,m*2,m*2);
			t-=query(1,1,i-m,j-m);
			t-=query(1,j+1,i-m,m*2);
			t-=query(i+1,1,m*2,j-m);
			ans=max(ans,t);
		}
	}
	cout<<ans;
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible") << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c; cin>>a>>b>>c;

	if (a<b && b<c){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}


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

#include<math.h>

using namespace std;

int main()

{

	int n;cin>>n;
	char s[n+1];

	cin>>s;

	int count=0;

	int i,j,k;

	i=0;j=n-1;

	while(i<j)

	{

		if(s[i]=='R')

		i++;

		if(s[j]=='W')

		j--;

		if(s[i]=='W'&&s[j]=='R')

		{

			s[i]='R';

			s[j]='W';

			i++;

			j--;

			count++;

		}

	}

	cout<<count<<endl;

	return 0;

}

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

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            if (Math.Abs(a - b) % 2 == 1)
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            else
            {
                Console.WriteLine(Math.Max(a, b) - Math.Abs(a - b) / 2);
            }
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 11348
n,a=map(int,input().split())
import numpy as np
x=np.array(input().split(),dtype=int)
x-=a
pluslist=[]
minuslist=[]
zerocnt=0
for i in range(len(x)):
  if x[i]==0:
    zerocnt+=1
  elif x[i]>0:
    pluslist.append(x[i])
  else:
    minuslist.append(x[i]*(-1))

dpplus=np.full((sum(pluslist)+1),0,dtype=int)
dpminus=np.full((sum(minuslist)+1),0,dtype=int)
dpplus[0]=1
dpminus[0]=1
for v in pluslist:
  for i in range(len(dpplus)-1,-1,-1):
    if dpplus[i]!=0:
      dpplus[i+v]+=dpplus[i]
for v in minuslist:
  for i in range(len(dpminus)-1,-1,-1):
    if dpminus[i]!=0:
      dpminus[i+v]+=dpminus[i]

ans=2**zerocnt-1
for i in range(1,min(len(dpplus),len(dpminus))):
  ans+=dpplus[i]*dpminus[i]*(2**zerocnt)
  
print(ans)

Measured memory_bytes: 17224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    rep(i, n){
        cin >> a[i]; 
    }
    rep(i, n){
        cin >> b[i]; 
    } 
    
    REP(i, 1, n){
        b[i] += b[i-1];    
    }

    int sum = 0;
    int ans = 0;
    rep(i, n){
        sum += a[i];
        int sum2 = b[n-1] - b[i-1];
        ans = max(ans, sum+sum2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final int INF=Integer.MAX_VALUE;
	static boolean[] used;
	static int flow;
	
	static int V;//頂点
	static int E;//辺
	
	static int H;
	static int W;
	static int s;
	static int t;
	
	static char[][]S;
	
	static List<List<edge>> G;//listの二重構造で隣接リスト実現
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		
		H= sc.nextInt();
		W= sc.nextInt();
		V= H+W+2;
		
		s= 0;
		t=H+W+1;
		
		S= new char[H][W];
		
		G= new ArrayList<>();
		for(int i=0;i<V;i++)G.add(new ArrayList<>());
		
		
		for(int i=0;i<H;i++)	S[i]= sc.next().toCharArray();
		
		sc.close();
		
		if(check(S)){//sからtまでひと飛びで行ける位置関係なら−１
			System.out.println(-1);
		}
		else{
			
		
		//Gの作成。S[]が0originだから、x,yそれぞれ+1することに注意 
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				char com= S[i][j];
				
				int y=i+1;
				int x=H+ j+1;
				
				switch(com){
				case '.':
					break;
				case 'o'://無向グラフだから双方向に繋ぐ
					addedge(y,x,1);
					addedge(x,y,1);
					break;
				case 'S':
					addedge(s,y,INF);
					addedge(s,x,INF);
					break;
				case 'T':
					addedge(y,t,INF);
					addedge(x,t,INF);
					break;
				}
			}
		}
		
		
		
		int ans= max_flow(s,t);
		
		
		System.out.println(ans);
		
		}
		
	}
	
	
	static void addedge(int from,int to,int cap){
		G.get(from).add(new edge(to,cap,G.get(to).size()));
		//同時に逆辺も辿れるようにするため、に双方向に紐をつける。
		G.get(to).add(new edge(from,0,G.get(from).size()-1));
	}
	
	static boolean check(char[][]S){
		boolean res=false;
		int Sx= 0;
		int Sy= 0;
		int Tx= 0;
		int Ty= 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				char com= S[i][j];
				
				if(com=='S'){
					Sy=i;
					Sx=j;
				}
				if(com=='T'){
					Ty= i;	
					Tx= j;
			}	
		}
	}
		if(Sy ==Ty ||Sx== Tx)res= true;
		
		return res;
}
	
	static int dfs(int v,int t,int f){
		if(v == t)return f;//tまでたどり着いた
		
		used[v] = true;
		
		for(int i=0;i<G.get(v).size();i++){
			edge e =G.get(v).get(i);
			
			if(used[e.to] != true && e.cap >0){
				int d= dfs(e.to,t,Math.min(f, e.cap));
				//min(f,e.cap)はまだ流す量を決めている段階。暫定の流量
				
				if(d>0){//tまでたどり着いた(流せる)時
				//v==tのreturn fを受けて、ここで初めてf(=d)を流す
					e.cap-= d;
					G.get(e.to).get(e.rev).cap += d;//直接逆辺のcを変化させて、
					return d;//各辺でdを流すために戻る。　
				}	
			}	
		}
			return 0;
			
	}
		

	static int max_flow(int s,int t) {
		int flow= 0;
		
		
		while(true){
			used =new boolean[V];
			
			int f= dfs(s,t,INF);
			if(f == 0){
				//if(arrive= false)return -1;
				return flow;//if(もうこれ以上流せない)return
			}
			flow +=f;
		}
		
	}

}
class edge {
	
	int to;
	int cap;
	int rev;//逆辺にアクセスする
	
	edge(int to,int cap,int rev){
		this.to =to;
		this.cap =cap;
		this.rev =rev;
	}
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,A,B;
	cin >> N >> A >> B;

	int n[10];

	int rec = 0;
	for(int i=1;i<=N;++i){
		n[5] = i / 10000;
		n[4] = (i - n[5] * 10000) / 1000;
		n[3] = (i - n[5] * 10000 - n[4] * 1000) / 100;
		n[2] = (i - n[5] * 10000 - n[4] * 1000 - n[3] * 100) / 10;
		n[1] =  i - n[5] * 10000 - n[4] * 1000 - n[3] * 100 - n[2] * 10;
		int souwa = n[5] + n[4] + n[3] + n[2] + n[1];
		for(int j=A;j<=B;++j){
			if(souwa == j) rec += i;
		}
	}

	cout << rec << endl;
//	cout << n[4] << n[3] << n[2] << n[1] << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;++i){
        int m=i;double l=1;
        while(m<k){
             m*=2;
             l/=2;
        }
        ans+=l/n;
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
int mytop=-1;
struct stack1{
    int a[100000];
    bool isempty(){
        if(mytop==-1)return 1;
            return 0;
    }
    bool isfull(){
    if(mytop==100000-1)return 1;
    return 0;
    }
    int push(int x){
        if(!isfull()){
            a[++mytop]=x;
            return 1;
        }
        return 0;
    }
    int top(){
        if(isempty()){return -1;}
        return a[mytop];
    }
    int pop(){
        mytop--;
        return a[mytop+1];
    }
};
int main(){
    stack1 s;
    string a;
    int b,c;
    while(cin>>a){
        if(a[0]=='+'){
            b=s.pop();
            c=s.pop();
            s.push(b+c);
        }else
        if(a[0]=='-'){
            c=s.pop();
            b=s.pop();
            s.push(b-c);
        }else
        if(a[0]=='*'){
            b=s.pop();
            c=s.pop();
            s.push(b*c);
        }else{
            s.push(atoi(a.c_str()));
        }
    }
    cout<<s.top()<<endl;
return 0;}

Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	vector<double> a(n),b(n),c(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	double ans=0;
	for(int i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)!=m)continue;
		vector<int> v(n,0);
		for(int j=0;j<n;j++){
			if((i>>j)&1)v[j]=1;
		}
		double sum=0;
		for(int j=0;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(v[j]==1&&v[k]==1){
					sum+=(a[j]-a[k])*(a[j]-a[k])+(b[j]-b[k])*(b[j]-b[k])+(c[j]-c[k])*(c[j]-c[k]);
				}
			}
		}
		ans=max(ans,sum);
	}
	printf("%.8f\n",ans);
}


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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a > b){
		int s = a;
		a = b;
		b = s;
		
	}
	if (a > c){
		int s = a;
		a = c;
		c = s;
		
	}
	if (b > c){	
		int s = b;
		b = c;
		c = s;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}


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

int  main()
{
	int n; cin >> n;
	vector<int> a(n);
	vector<int> b;
	rep(i, n)
	{
		cin >> a[i];
		if (i % 2 == 0)
			b.push_back(a[i]);
		else
			b.insert(b.begin(), a[i]);
	}
	if(n % 2)
		reverse(b.begin(), b.end());
	rep(i, b.size())
		cout << b[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3828
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long x = sc.nextLong();
    long[] a = new long[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextLong();
    }
    long ans = 0;
    if (x < a[0]) {
      ans += a[0] - x;
      a[0] = x;
    }
    for (int i = 0; i < N - 1; i++) {
      if (x < a[i] + a[i + 1]) {
        ans += a[i] + a[i + 1] - x;
        a[i + 1] = x - a[i];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 58780
package main

import (
	"io"
	"os"

	"fmt"
)

func Solve(in io.Reader, out io.Writer) {
	var a, b, c, x, y int
	fmt.Fscan(in, &a, &b, &c, &x, &y)

	if (a+b)-c*2 <= 0 {
		fmt.Fprintln(out, a*x+b*y)
		return
	}

	if x > y {
		fmt.Fprintln(out, (x-y)*min(a, c*2)+y*c*2)
		return
	}

	fmt.Fprintln(out, (y-x)*min(b, c*2)+x*c*2)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

func main() {
	Solve(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;                

#define INT_MAX 0x7fffffff

typedef long long lld;
typedef long double llf;
typedef pair<int, int> pii;

int main(void) {
    
    int arr[5];
    int ans=INT_MAX,tmp;
    
    for(int i=0;i<5;i++){
        cin>>arr[i];
    }
    sort(arr,arr+5);

    do{
        tmp=0;
        for(int i=0;i<5;i++){
            tmp+=arr[i];
            if(tmp%10&&i<4){
                tmp = ((tmp/10)+1)*10;
            }
        } 
        ans = min(ans,tmp);
        
    }while(next_permutation(arr,arr+5));
    cout<<ans;
    return 0;
}







































Measured memory_bytes: 256
b = int(input())
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

a2 = a.copy()

best = None

for i in range(len(a)):
    a[i] = a[i] + 1

for i in range(100):
    x = [0] * b
    for j in range(len(a)):
        a[j] = a[j] - 1
        x[j] = a[j]**2
    s = sum(x)
    if best is None or s < best:
        best = s

print(best)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
  int a[3];
  int t;
  int i, j;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  for(i=0; i < 3; i++){
    for(j = 0; j < 2; j++){
      if(a[j] > a[j+1]){
        t = a[j];
        a[j] = a[j+1];
        a[j+1] = t;
      }
    }
  }
  printf("%d %d %d\n",a[0], a[1], a[2] );
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//List<String> list_wa=new ArrayList<String>();
		//Integer[][] array = new Integer[n][m];
		int n = sc.nextInt();
		double count=0;
		for(int i=0;n>i;i++) {
			double a = sc.nextDouble();
			String s = sc.next();
			if(s.equals("JPY"))
				count = count+a;
			else
				count = count+a*380000;
			//System.out.println(i);
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 23124
L=['a','b','c','d','e','f','g','h','i','j','k','l','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
letter=input()
for i in range(len(L)):
    if letter==L[i]:
        print(L[i+1])
        break

Measured memory_bytes: 3060
#include <iostream>
#include <array>
void print_line(int* A, int N) {
    for(auto i=0; i<N; i++) {
        std::cout << A[i] << ((i<(N-1) ? " " : ""));
    }
    std::cout << std::endl;
}

void insertionSort(int* A, int N) {
    print_line(A,N);
    for(auto i=1; i<N; i++) {
        int v{A[i]};
        int j{i-1};
        while(j>=0 && A[j]>v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        print_line(A,N);
    }
}

int main() {
    int N{};
    std::cin >> N;
    int A[N];
    for(auto i=0; i<N; i++) {
        std::cin >> A[i];
    }
    insertionSort(A,N);
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 9;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

void solve()
{
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000;
    
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3644
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn f(h: u64) -> u64 {
    if h == 1 {
        1
    } else {
        2 * f(h/2) + 1
    }
}

fn main() {
    println!("{}", f(read::<u64>()));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int ans[n]={};
  for(int i=0;i<2*m;i++){
    int a;
    cin >> a;
    ans[a-1]++;
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


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

const int MOD = (int)1e9 + 7;

int n,m,h[101],hnum[101],dh[101];///h记录每一列高度 dh记录离散化后的各不相同的高度 hnum记录h对应dh中的位置，即第几高的高度
long long dp[101][101];///记录第i列第n块高度往上的方案数

int pow_(long long x,int y) {///快速幂求 x的y次方
    long long ans = 1;
    if(y > 0) {
        while(y) {
            if(y % 2)ans = ans * x % MOD;
            x = x * x % MOD;
            y /= 2;
        }
    }
    return ans;
}

int main() {
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++) {
        scanf("%d",&h[i]);
        dh[++ m] = h[i];///先把高度存到dh数组 下标从1开始，方便后面dp
    }
    sort(dh + 1,dh + m + 1);///dh数组排序
    m = unique(dh + 1,dh + m + 1) - dh - 1;///dh数组离散化去掉重复的高度 m是不相同的高度数
    for(int i = 1;i <= n;i ++) {
        hnum[i] = lower_bound(dh + 1,dh + m + 1,h[i]) - dh;///每一列高度在dh数组中对应的位置
    }
    dp[0][0]=1;///初始化 当第0列有1个无连续相同的方案
    for(int i = 1;i <= n;i ++) {///对每一列每个高度段进行更新 更新过程为从下往上
        (dp[i][0] += dp[i - 1][0] * 2 % MOD) %= MOD;///无连续相同方案  加上前i - 1列无连续相同方案数*2 因为可以是与前一列对应位置同色或者异色一共两种方案
        for(int j = hnum[i] + 1;j <= hnum[i - 1];j ++)///如果前一列比这一列高，高出的部分也存着接触部分无连续相同的方案 但是可能会重复加上上一步的方案数所以下面更新高出的部分时会避免
            (dp[i][0] += dp[i - 1][j] * 2 % MOD) %= MOD;
        int d = pow_(2,h[i] - h[i - 1]);///比前一列高出部分的涂色方案数，如果比前一列低 d就等于1
        for(int j = 1;j <= min(hnum[i - 1],hnum[i]);j ++) {
            dp[i][j] = dp[i - 1][j] * d % MOD;///有连续相同颜色的方案数 已经分析过接触部分的颜色一定是定下的 所以这一列接触部分有连续相同部分的方案数由高出部分的变化决定 即 乘上d
        }
        for(int j = hnum[i - 1] + 1;j <= hnum[i];j ++) {///更新比前一列高出的部分 j从上一列的高度加1的下标开始
            if(j > 1)(dp[i][j] += dp[i - 1][0] * (pow_(2,dh[j] - dh[j - 1]) - 1) % MOD * 2 % MOD * pow_(2,h[i] - dh[j]) % MOD) %= MOD;
            ///一般情况 前i - 1列无连续方案 * （第j块高度变化方案 -1表示去掉无连续相同方案) * 2 * 剩下几块高度的变化方案数
            else (dp[1][1] += dp[0][0] * (pow_(2,dh[1]) - 2) % MOD * pow_(2,h[i] - dh[1]) % MOD) %= MOD;
            ///第一列的第一块高度 记录随意变化方案数 -2表示除去dp[i][0]已经记录过的无连续相同方案 勿重复记录
        }
    }
    long long ans = 0;
    for(int i = 0;i <= hnum[n];i++)
        (ans += dp[n][i]) %= MOD;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 2019;

bool judge(vector<ll> V, int l, int r){
    ll temp = V[l];
    V[l] = V[r];
    V[r] = temp;
    ll N = V.size();
    for(int i = 0; i < N-1; i++){
        if(V[i] > V[i+1]) return false;
    }
    return true;
}


int main(){
    ll N; cin >> N;
    vector<ll> P(N);
    for(int i = 0; i < N; i++) cin >> P[i];
    for(int i = 0; i < N-1; i++){
        for(int j = i; j < N; j++){
            if( judge(P, i, j) ) {
                cout << "YES" << endl;
                return 0;
            }
        }

    }

    cout << "NO" << endl;
}


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

long long N,A[200010];
long long W[200010];

long long merge_and_count(long long l, long long r) { // range [l,r)
  if (l+1 >= r) return 0; // empty
  if (l+2 == r) { // [l,r) == [l,l+1] 要素 2 つだけ
    if (A[l] <= A[l+1]) return 0; // 逆転はなし
    swap(A[l], A[l+1]);
    return 1; // 逆転一つ
  }
  long long m = (l+r)/2; // [l,r) == [l,m) + [m,r)
  long long cl = merge_and_count(l, m); // 左半分を再帰的に数える
  long long cr = merge_and_count(m, r); // 右半分を再帰的に数える
  long long c = 0; // 左と右を混ぜるときの逆点数
  long long i=l, j=m; // i は [l,m) を動き, j は [m,r) を動いて，
  long long k=l; // 小さいものから W[k] に書き込む
  while (i<m && j<r) { // A[i] と A[j] を比べながら進む
    if (A[i] <= A[j]) W[k++] = A[i++]; // 左半分の方が小さく逆転なし
    else {
      W[k++] = A[j++];
      c += m-i; // 左半分の方が大きい，左半分で未処理の要素だけ飛び越える
    }
  }
  while (i<m) W[k++] = A[i++]; // 左半分が余った場合
  while (j<r) W[k++] = A[j++]; // 右半分が余った場合
  assert(k == r);
  copy(W+l, W+r, A+l);
  return cl + cr + c;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];
  cout << merge_and_count(0,N) << endl;
}



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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    switch (A) {
        case 1:
            if (B == 2) {
                cout << 3 << endl;
            } else {
                cout << 2 << endl;
            }
            break;
        case 2:
            if (B == 1) {
                cout << 3 << endl;
            } else {
                cout << 1 << endl;
            }
            break;
        default:
            if (B == 1) {
                cout << 2 << endl;
            } else {
                cout << 1 << endl;
            }
    }
}

Measured memory_bytes: 3552
#include <stdio.h>

int main(void){
	int a,b;
	char op;
	do{
		scanf("%d %s %d",&a,&op,&b);
		if(a>=0 && a<=20000 && b>=0 && b<=20000){
			if(op=='+')
				printf("%d\n",a+b);
			else if(op=='-')
				printf("%d\n",a-b);
			else if(op=='*')
				printf("%d\n",a*b);
			else if(op=='/')
				printf("%d\n",a/b);
		}
	}while(op !='?');
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;


void run_case() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while(N) {
        N /= K;
        ans++;
    }    
    cout << ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(10);
    run_case();
    cout.flush();
    return 0;
}


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

int main(){
  string s;cin>>s;
  int N=s.size();
  int ansL,ansR;
  bool OK=false;
  
  for(int i=0;i<N-1;i++){
    if(s.at(i)==s.at(i+1)){
      OK=true;
      ansL=i+1;ansR=i+2;
    }
  }
  for(int i=0;i<N-2;i++){
    if(s.at(i)==s.at(i+2)){
      OK=true;
      ansL=i+1;ansR=i+3;
    }
  }
  
  if(OK)
     cout<<ansL<<" "<<ansR<<endl;
  else
    cout<<"-1 -1"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
int main(){
    int a,b;
    int ans;
    cin >> a >> b;
    
    if(a*2 <= b && b <= a*4 && b%2 == 0)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N;
    float a, sum = 0;
    cin >> N;

    for(size_t i = 0; i < N; i++) {
        cin >> a;
        sum += 1.0 / a;
    }

    sum = 1.0 / sum;
    cout << fixed << setprecision(10);
    cout << sum << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
const int INF = 1000 * 1000 * 1000;
const ll LINF = (ll)INF * INF;
const ll N = 387309894;
using namespace std;
int n;
vector<int> twos;
vector<int> threes;
vector<int> sixs;
int main() {
	for(int i = 2; i <= 30000; i++)
	{
		if(not(i % 6))
		{
			sixs.pb(i);
			continue;
		}
		if(not(i % 3))
		{
			threes.pb(i);
			continue;
		}
		if(not(i % 2))
		{
			twos.pb(i);
		}
	}
	cin >> n;
	if(n == 3)
	{
		cout << "2 5 63";
		return 0;
	}
	if(n == 4)
	{
		cout << "2 5 20 63";
		return 0;
	}
	cout << twos.back() << " ";
	twos.pop_back();
	cout << twos.back() << " ";
	twos.pop_back();
	cout << threes.back() << " ";
	threes.pop_back();
	cout << threes.back() << " ";
	threes.pop_back();
	n -= 4;
	while(n >= 2 && twos.size())
	{
		n -= 2;
		cout << twos.back() << " ";
		twos.pop_back();
		cout << twos.back() << " ";
		twos.pop_back();
	}
	while(n >= 2 && threes.size())
	{
		n -= 2;
		cout << threes.back() << " ";
		threes.pop_back();
		cout << threes.back() << " ";
		threes.pop_back();
	}
	while(n)
	{
		cout << sixs.back() << " ";
		sixs.pop_back();
		n--;
	}



    return 0;
}






Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, d;

    cin >> n >> d;

    cout << (n + d * 2) / (d * 2 + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main () {
	int n;
	n = 5;
	int a[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >>a[i];
		if (a[i] == 0) {
			cout <<i <<endl;
		}
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios::sync_with_stdio(false);
#define pi 3.14159265358979323846264338327950288419716939937510
#define pb push_back
#define max 10000002
typedef long long ll;
using namespace std;
int main()
{

      fast
        ll n;
        cin>>n;
        
         ll a[max]={0};
        for(int i=1;i<=n;i++)
        {
            for(int j=1;i*j<=n;j++)
                {
                    a[i*j]++;
                }
        }

      ll ans=0;
      for(int i=1;i<=n;i++)
        ans+=a[i]*i;

     cout<<ans<<endl;
return 0;

}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char d[4] = {'D', 'R', 'U', 'L'};

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

    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    vector<P> ls;
    int sx, sy, dir;
    map<P, int> rev;
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
        for (int j = 0; j < W; j++)
        {
            if (s[i][j] == '.')
                continue;
            if (s[i][j] == 'o')
            {
                rev[P(i, j)] = ls.size();
                ls.push_back(P(i, j));
                continue;
            }
            sx = i;
            sy = j;
            if (s[i][j] == 'D')
                dir = 0;
            else if (s[i][j] == 'R')
                dir = 1;
            else if (s[i][j] == 'U')
                dir = 2;
            else
                dir = 3;
            s[i][j] = '.';
        }
    }
    // pos, dir, mask
    map<T, string> mp;
    int sz = ls.size();
    ll mask = (1LL << sz) - 1;
    ls.push_back(P(sx, sy));
    queue<T> q;
    q.push(T(sz, dir, mask));
    mp[T(sz, dir, mask)] = "";
    while (!q.empty())
    {
        T t = q.front();
        q.pop();
        int pos = get<0>(t);
        int dir = get<1>(t);
        mask = get<2>(t);
        for (int i = 0; i < 4; i++)
        {
            if (abs(dir - i) == 2)
                continue;
            for (int j = 1; j < 10; j++)
            {
                int nx = ls[pos].first + j * dx[i], ny = ls[pos].second + j * dy[i];
                if (nx < 0 || H <= nx || ny < 0 || W <= ny)
                    continue;
                if (s[nx][ny] != 'o')
                    continue;
                int idx = rev[P(nx, ny)];
                // 訪問済み
                if (((mask >> idx) & 1) == 0)
                    continue;
                ll mask2 = mask ^ (1LL << idx);
                T nt = T(idx, i, mask2);
                if (mp.find(nt) != mp.end())
                    break;
                q.push(nt);
                string ns = mp[t];
                ns += d[i];
                mp[nt] = ns;
                break;
            }
        }
    }
    for(auto t:mp){
        if(get<2>(t.first) == 0){
            cout<<t.second<<endl;
            return 0;
        }
    }
    assert(false);
}



Measured memory_bytes: 7196
#include<bits/stdc++.h>
#define int long long
#define md 1000000007
using namespace std;
int power(int x,int y, int p) 
{ 
   int res = 1;     
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
main()
{
	//freopen("input.txt","rt",stdin);
	int n;
	cin>>n;
	int arr[n];
	vector<string>ma;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		string binary = bitset<60>(arr[i]).to_string();
		ma.push_back(binary);
	}
	int p =0;
	int ans =0;
	for(int i= 59;i>=0;i--)
	{
		int z = 0;
		int o = 0;
		for(int j=0;j<n;j++)
		{
			if(ma[j][i] == '0')
			{
				z++;
			}
			else
			{
				o++;
			}
		}
		int t = 2;
		int tt = (z * o) % md;
		ans = ans + (tt *power(t,p,md))%md;
		ans %= md;
		p++;
	}
	ans %= md;
	cout<<ans<<endl;
}

Measured memory_bytes: 34540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	string s,t;
	cin>>s>>t;
	int cng=0;
	f(i,0,s.length()) if(s[i]!=t[i]) cng++;
	cout<<cng;
	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<LL> fact, finv, inv;

void init_nCk(int N) {
  fact.resize(N + 1);
  finv.resize(N + 1);
  inv.resize(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fact[i] = fact[i - 1] * i % kMod;
    inv[i] = kMod - inv[kMod % i] * (kMod / i) % kMod;
    finv[i] = finv[i - 1] * inv[i] % kMod;
  }
}

LL nCk(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (finv[k] * finv[n - k] % kMod) % kMod;
}

int main() {
  int N, K; std::cin >> N >> K;
  init_nCk(N);
  for (int k = 1; k <= K; ++k) {
    std::cout << nCk(N - K + 1, k) * nCk(K - 1,  k - 1) % kMod << std::endl;
  }
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if

int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  cin>>n;
  int a[n],b[n],asum=0,bsum=0;
  rep(i,n){
    cin>>a[i];
    asum+=a[i];
  }
  //debg(asum);
  rep(i,n){
    cin>>b[i];
    bsum+=b[i];
  }
  //debg(bsum);
  if(asum<bsum){
    cout<<"-1"<<endl;
    return 0;
  }
  
  int abcnt=0,j=0,dif[n];
  rep(i,n){
    if(a[i]<b[i]){
      abcnt++;
    }
    dif[i]=a[i]-b[i];
  }
  sort(dif,dif+n);
  
  if(abcnt==0){
    print(0);
    return 0;
  }

  int minus=0;
  rep(i,n){
    if(dif[i]<0)minus-=dif[i];
  }
  for(i=n-1;minus>=0;--i){
    minus-=dif[i];
    abcnt++;
  }

  
  print(abcnt);
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#define N 200002 //overflow防止

int main(){
	int n,i,w=0,b=0,min=N;
	char s[N];
	scanf("%d %s",&n,s);

	for(i=0;i<n;i++){if(s[i]=='.')w++;}
	min=w;

	for(i=0;i<n;i++){
		if(s[i]=='#'){b++;}//そこまでのb
		else{w--;}//そこからのw
		if(b+w<=min){min=b+w;}
	}

	printf("%d\n", min);
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a, 0, sizeof(a))
#define sqr(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int mn = 4005;
const int mod = 998244353;
#define P mod

int n;
char s[mn];
int sumb[mn],sumr[mn];
ll d[mn][mn];

ll dp(int r,int b){
    ll &ans=d[r][b];
    if (ans!=-1) return ans;
    if (r+b<=n&&(r>sumr[r+b]||b>sumb[r+b])||r>sumr[n]||b>sumb[n]) return ans=0;
    if (r+b==2*n) return ans=1;
    ans=dp(r+1,b)+dp(r,b+1);
    if (ans>=mod) ans-=mod;
    return ans;
}

int main() {
#ifdef LOCAL
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        sumb[i]=sumb[i-1]+s[i]-'0';
        sumr[i]=sumr[i-1]+(2-s[i]+'0');
    }
    memset(d,-1,sizeof d);

    printf("%lld\n",dp(0,0));

    return 0;
}


Measured memory_bytes: 125824
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
  set<int> water,sugar;
  rep(i,f+1) rep(j,f+1){
    if((i*a+j*b)*100 <= f) water.insert((i*a+j*b)*100);
    if(i*c+j*d <= f) sugar.insert(i*c+j*d);
  }
  double concentration = -10.0;
  int mx_sugar = 0, mx_sugarwater = 0;
  for(auto x : water) for(auto y : sugar){
    if(x+y <= f){
      if(100*y <= e*x){
        if(chmax(concentration,100.0*y/(x+y))){
          mx_sugar = y;
          mx_sugarwater = x+y;
        }
      }
    }
  }
  cout << mx_sugarwater << " " << mx_sugar;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3768
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int fun(int x){
	return x*x;
}


int main(){
	int d;
	while(cin >> d){
		int n = 600/d;
		int sum = 0;
		for(int i=0; i<n; i++){
			sum += fun(d*i)*d;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific

using namespace std;

typedef unsigned long long ull;

int main(void) {
    int n;
    cin >> n;
    ull t, a, t_prev, a_prev;
    cin >> t >> a;
    for (int i = 1; i < n; ++i)
    {
        ull m_t, m_a, m;
        t_prev = t;
        a_prev = a;
        cin >> t >> a;
        if (t >= t_prev && a >= a_prev) {
            continue;
        } else {
            m_t = t_prev / t + (t_prev % t ? 1 : 0);
            m_a = a_prev / a + (a_prev % a ? 1 : 0);
            m = max(m_t, m_a);
            t *= m;
            a *= m;
        }
    }
    cout << (a + t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int n,between,temp;
  while (1) {
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
    std::vector<int> a(n);
    for (size_t i = 0; i < n; i++) {
      scanf("%d",&a[i]);
    }
    sort(all(a));
  between=a[1]-a[0];
    for (size_t i = 1; i < n-1; i++) {
      temp=a[i+1]-a[i];
      if(between>temp){
        between=temp;
      }
    }
    printf("%d\n",between);
  }

  return 0;
}

Measured memory_bytes: 3124
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	int k; cin >> k;
	int n = s.size();
	rep(i, n)
	{
		if (s[i] == 'a')continue;
		int x = 'z' - s[i] + 1;
		if (x <= k)
		{
			s[i] = 'a';
			k -= x;
		}
	}
	k %= 26;
	while (k--)
	{
		if (s.back() == 'z')s.back() = 'a';
		else s.back() = char(s.back() + 1);
	}
	cout << s << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
void  add(ll h[] , ll pos , ll val)
{
    h[pos] += val;
    if(h[pos] >= mod)
    h[pos] -= mod;
}


void  sub(ll h[] , ll pos , ll val)
{
    h[pos] -= val;
    if(h[pos] < 0)
    h[pos] += mod;
} 


int main() {
    ll n , k;
    cin >> n >> k;
    ll a[n+1];
    for(ll i = 1 ; i  <= n ; i++)
    cin >> a[i];
    ll dp[k+1];
    memset(dp , 0 , sizeof(dp));
    dp[0] = 1;  
    for(ll i = 1 ; i <= n ; i++)
    {
        ll h[k+1]= {0};
        for(ll j = k ; j >= 0 ; j--)
        {
            ll adder = dp[j];
            ll left = j + 1;
            ll right = j + min(a[i] , (k-j));
            if(left <= right)
            {
                add(h , left , adder);
                if(right+1 <= k)
                sub(h , right+1 , adder);
            }
        }


        ll pre = 0;
        for(ll j = 0 ; j  <= k ; j++)
        {
            pre = pre + h[j];
            if(pre >= mod)
            pre -= mod;
            dp[j] = dp[j] + pre;
            if(dp[j] >= mod)
            dp[j] -= mod;
        }
    }


    cout << dp[k] ;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  map<int,int> memo;
  rep(i,N){
    int D;
    cin >> D;
    memo[D]++;
  }

  bool ret = true;
  
  int M;
  cin >> M;
  rep(i,M){
    int T;
    cin >> T;
    if(memo[T]>0){
      memo[T]--;
    }else{
      ret = false;
      break;
    }
  }

  if(ret) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


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

int main() {
  vector<vector<int>> vec(3, vector<int> (3, 0));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  int x = vec.at(0).at(0);
  int y = vec.at(0).at(1);
  int z = vec.at(0).at(2);
  int o = vec.at(1).at(0);
  int p = vec.at(1).at(1);
  int q = vec.at(1).at(2);
  int s = vec.at(2).at(0);
  int t = vec.at(2).at(1);
  int u = vec.at(2).at(2);
  
  bool ans = 1;
  if((o - x) == (p - y) && (q - z) == (o - x)){
    if((s - x) == (t - y) && (u - z) == (s - x)){
      cout << "Yes" << endl;
      ans = 0;
    }
  }
  
  if(ans) cout << "No" << endl;
  
}

Measured memory_bytes: 256