akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    int n = int.Parse(Console.ReadLine());
    var input = Console.ReadLine().Split();
    int[] a = new int[n];
    int[] b = new int[9];
    
    for(int i=0; i<n; i++){
      a[i] = int.Parse(input[i]);
      if(1 <= a[i] && a[i] <= 399) b[0]++;
      else if(a[i] <= 799) b[1]++;
      else if(a[i] <= 1199) b[2]++;
      else if(a[i] <= 1599) b[3]++;
      else if(a[i] <= 1999) b[4]++;
      else if(a[i] <= 2399) b[5]++;
      else if(a[i] <= 2799) b[6]++;
      else if(a[i] <= 3199) b[7]++;
      else b[8]++;
    }
    int k = 0;
    for(int i=0; i<8; i++){
      if(b[i] > 0) k++;
    }
    int mx = k + b[8];
    //if(mx >= 8) mx = 8;
    int mn = k;
    if(k == 0 && b[8]>0) mn = 1;
    Console.WriteLine(mn + " " + mx);

  }
}

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

int main() {
  int N; cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  int total = 0;
  for (int i = 0; i < N; i++) {
    for (int k = (i+1); k < N; k++) {
      total += (d.at(i) * d.at(k));
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 1000005;
const int mod = 1e9 + 7;

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

int n, m, k;
lint fact[MAXN], invf[MAXN];

lint bino(int x, int y){
	return fact[x] * (invf[y] * invf[x - y] % mod) % mod;
}

int main(){
	fact[0] = invf[0] = 1;
	for(int i=1; i<MAXN; i++){
		fact[i] = fact[i-1] * i % mod;
		invf[i] = ipow(fact[i], mod - 2);
	}
	cin >> n >> m >> k;
	lint func = 0;
	for(int j=0; j<=k; j++){
		func += bino(n - 1 + j, j) * ipow(3, mod - 1 - j) % mod;
		func %= mod;
	}
	lint ret = func * ipow(3, m + k) % mod;
	for(int i=1; i<=m; i++){
		lint aux = bino(n - 1 + i + k, k) * ipow(3, mod - 1 - k) % mod;
		func += mod - aux;
		func *= 3ll * (mod + 1) / 2;
		func += aux;
		func %= mod;
		lint base = ipow(3, m + k - i) * bino(n - 1 + i, i) % mod;
		ret += base * func % mod;
		ret %= mod;
	}
	cout << ret << endl;
}



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

using namespace std;
typedef long long int lld;

const lld mod = 1e9 + 7;
lld ans = 0;
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	lld f = 0,s = 0,rr,ll;
	for(int e=0;e<k;e++) f += e;
	for(int e=n;e>(n-k);e--) s += e;
	ll = k-1;
	rr = (n-k+1);
	ans = (ans+s-f+1)%mod;
	for(int e=k+1;e<=n+1;e++){
		f += (++ll);
		s += (--rr);
		ans = (ans+s-f+1)%mod;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int a = cin.NextInt() - 1; // 0-indexed
        int b = cin.NextInt() - 1; // 0-indexed
        int c = cin.NextInt() - 1; // 0-indexed
        int d = cin.NextInt() - 1; // 0-indexed
        string s = cin.Next();

        bool flag = true;
        for (int i = a; i < c; i++)
        {
            if(s[i] == '#' && s[i + 1] == '#')
            {
                flag = false;
            }
        }
        for (int i = b; i < d; i++)
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                flag = false;
            }
        }

        if (d < c)
        {
            bool over = false;
            for (int i = b; i <= d; i++)
            {
                if(s[i-1]=='.'&& s[i] == '.'&& s[i + 1] == '.')
                {
                    over = true;
                }
            }
            if (!over)
            {
                flag = false;
            }
        }

        if (flag)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    ll res = (1ll<<60);

    ll M = sqrt(N) + 2;
    for(ll p=1;p<=M;p++){
    	if(N%p == 0){
    		ll q = N/p;
    		res = min(abs(p-1)+abs(q-1), res);
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k=-1;cin>>n;
    for(ll i=1;i<=2*n;i++){
        if( (i*(i-1))/2 == n){
            k=i;
            break;
        }
    }
    if(k==-1)return cout<<"No" , 0;
    cout<<"Yes\n";
    vector<ll> v;
    for(ll i=1;i<=n;i++)v.push_back(i);

    vector< vector<ll> > a(k);
    for(ll i=0;i<k;i++){
        for(ll j=i+1;j<k;j++){
            a[i].push_back(v.back());
            a[j].push_back(v.back());
            v.pop_back();
        }
    }

    cout<<k<<"\n";
    for(auto &v:a){
        cout<<v.size()<<" ";
        for(auto &ele:v)cout<<ele<<" ";
        cout<<"\n";
    }
}



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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif


const int MAX = 100100;
bool isp[MAX];

void sieve() {
    for (int i=0; i<MAX; ++i) {
        isp[i] = true;
    }
    for (int i=2; i<MAX; ++i) {
        if ( ! isp[i]) continue;
        for (int j=2*i; j<MAX; j+=i) {
            isp[j] = false;
        }
    }
}

int main() {
    sieve();

    int X;
    cin >> X;

    for (int i=X; i<MAX; ++i) {
        if (isp[i]) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict,deque
n = int(input())
d = defaultdict(list)
l = []
for i in range(n-1):
    a,b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)
    l.append((a,b))

# print(d)

que = deque([a])
visited = [-1] + [False]*n
visited[a] = True

preans = defaultdict(list)
ans = defaultdict(int)
maxi = 1

while que:
    v = que.popleft()
    cnt = 1
    for x in d[v]:
        if not visited[x]:
            while cnt in preans[v]:
                cnt += 1
            maxi = max(maxi,cnt)
            preans[x].append(cnt)
            ans[(v,x)] = cnt
            ans[(x,v)] = cnt
            que.append(x)
            visited[x] = True
            cnt += 1
    # print(preans)
    # print(ans)
print(maxi)

for i in l:
    print(ans[i])

Measured memory_bytes: 156256
N, M = map(int, input().split())
Hs = list(map(int, input().split()))
bad = set()
for _ in range(M):
    a, b = map(int, input().split())
    if Hs[a - 1] <= Hs[b - 1]:
        bad.add(a)
    if Hs[b - 1] <= Hs[a - 1]:
        bad.add(b)
print(N - len(bad))


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	IOS
	
	ll n;
	cin>>n ;
	ll ans=0;
	for(ll i=0;i<n;i++)
		ans+=(i+1)*(n-i);

	for(ll i=0;i<n-1;i++)
	{
		ll x ,y;
		cin>>x>>y;
		x--;y--;
		if(x>y)
			swap(x,y);
		ans-=((x+1)*(n-y));
	}

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<pll> a(n);
  rep(i,n) {
    int p;
    cin >> p;
    a.pb({p,1});
  }
  rep(i,m){
    int p,q;
    cin >> p >> q;
    a.pb({q,p});
  }
  sort(all(a));
  reverse(all(a));
  ll cnt=0,ans=0;
  for(auto p:a){
    if(cnt+p.se<=n){
      ans+=p.fi*p.se;
      cnt+=p.se;
    }
    else{
      ans+=p.fi*(n-cnt);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8292
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x, y;
	cin >> x >> y;
	if (x % y == 0)
		cout << -1;
	else
		cout << x;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef pair<int,int> paii;
typedef long long ll;

int n, m;
bool frnd[1001][1001];
bool invited[1001];

int solve()
{
	int res = 0;
	CLR(invited);
	
	FOR(i, 1, n+1){
		if(frnd[1][i]){
			res++;
			invited[i] = true;
			
			FOR(j, 2, n+1){
				if(frnd[i][j] && !frnd[1][j] && !invited[j]){
					res++;
					invited[j] = true;
				}
			}
		}
	}
	
	return res;
}

int main()
{
	while(cin >> n >> m, (n||m))
	{
		CLR(frnd);
		
		FOR(i, 0, m)
		{
			int a, b;
			cin >> a >> b;
			frnd[a][b] = frnd[b][a] = true;
		}
		
		cout << solve() << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 1; i < N; i++) {
    a[i] += a[i - 1];
  }
  ll ans = abs(a[0] - (a[N - 1] - a[0]));
  for (int i = 0; i < N - 1; i++) {
    ans = min(ans, abs(a[i] - (a[N - 1] - a[i])));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {

  long long int n, input;

  cin >> n;

  for ( long long int i = 0; i < n; i++ ) {

    cin >> input;

    if ( input < 10 ) {
      cout << 0 << endl;
      continue;
    }

    long long int ans = 1;

    while( true ) {

      long long int k = 0;

      for ( long long int j = 10; j <= input; j *= 10 ) {

	k = max( k, ( input / j ) * ( input % j ) );

      }

      input = k;

      if ( input < 10 ) break;

      ans++;

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1160
l = int(input())

ns = [i for i in range(1, 21)]
edges = [(i, i+1, 0) for i in range(1, 20)]

t = l // 2
i = 19
length = 1
while t:
    edges.append((i, i + 1, length))
    i -= 1
    length *= 2
    t //= 2

for i in range(20):
    if l & (1 << i):
        start = l - (l & (2 ** i - 1)) - 2 ** i
        if start == 0: continue
        edges.append((1, 20 - i, start))

print(len(ns), len(edges))
for a, b, l in edges:
    print(a, b, l)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
map<int,int> m;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int h[n],dp[n];
    for(int i=0;i<n;i++)
    {
    	cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a != 1 && b != 1)
    {
        cout << 1;
    }
    else if (a != 2 && b != 2)
    {
        cout << 2;
    }
    else
    {
        cout << 3;
    }

    cout << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
const int inf=1e9+7;

int main()
{	
     ll n;
     cin>>n;
     ll h[n];
     loop(i,0,n)
     {
     	cin>>h[i];
	 }
	 ll dp[n]={0};
	 dp[0]=0;
	 dp[1]=abs(h[0]-h[1]);
	 loop(i,2,n)
	 {
	 	dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	 }
	 cout<<dp[n-1];
    return 0;
}


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

int check(ll arr[],ll n,ll mid,ll k)
{
    ll i,temp=0,g;

    for(i=0;i<n;i++)
    {
        g=arr[i];
        if(g>mid)
        {
            temp=temp+g/mid;
        }
        if(temp>k)
        return 0;
    }
        return 1;
}

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

    ll arr[n],i,s,e,mid,ans,t;
    for(i=0;i<n;i++)
        cin>>arr[i];

    sort(arr,arr+n);

    ans=INT_MAX;

    s=1;
    e=arr[n-1];

    while(s<=e)
    {
        mid=(s+e)/2;
        t=check(arr,n,mid,k);
        if(t==1)
        {
            ans=min(ans,mid);
            e=mid-1;
        }
        else
            s=mid+1;
      //  cout<<"s:  e:  ans:  t "<<s<<" "<<e<<" "<<ans<<" "<<t<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
    long long ans = 0;
    int n, m, i = 1;
    cin >> n >> m;
    vector<int> x(n + 1, 0), y(n + 1);
    while(cin >> x[i++] && i <= n);
    
    for(i = 2; i <= n; i++){
        y[i] = 1e9 + 1000;
        for(int j = 1; j <= m && (i - j ) >= 1; j++)
            y[i] = min(y[i], y[i - j] + abs(x[i] - x[i - j]));
    }
    cout << y[n] << endl;
    return 0;
}

Measured memory_bytes: 3988
#include<cstdio>
#include<fstream>
#include<queue>
#include<iostream>
#include<cstring>
#define N 100010
using namespace std;
int n,m;
struct rode{
  int y,next;
}e[N<<1]={};
int fl[N]={},len=0;
int a[N]={};
inline int read()
{
	int s = 0, w = 1;
	char c = getchar();
	while ((c<'0' || c>'9') && c != '0')c = getchar();
	if (c == '-')w = -1, c = getchar();
	while (c <= '9'&&c >= '0')s = (s << 3) + (s << 1) + c - '0', c = getchar();
	return s * w;
}
inline void inc(int x,int y)
{
  e[++len].y=y;
  e[len].next=fl[x];
  fl[x]=len;
}
struct que{
  int u,d,c;
}qu[N]={};
int c[N]={};
bool vis[N]={};
int s=0;
void dfs(int u,int v,int d,int co)
{
  if(d==0)return ;
  for(int i=fl[u];i;i=e[i].next)
   {
     int vv=e[i].y;
     if(vis[vv])continue;
     if(c[vv]==0)c[vv]=co,--s;
     if(s==0)return ;
     vis[vv]=1;
     dfs(vv,v,d-1,co);
     vis[vv]=0;
   }
}
int main()
{
  n=read();m=read();
  s=n;
  // for(int i=1;i<=n;++i)a[i]=read(),c[i]=0;
  for(int i=1;i<=m;++i)
  {
    int x=read(),y=read();
    inc(x,y);inc(y,x);
  }
  int q=read();
  for(int i=1;i<=q;++i)qu[i].u=read(),qu[i].d=read(),qu[i].c=read();
  for(int i=q;i>=1;--i)
  {
    int u=qu[i].u,d=qu[i].d,co=qu[i].c;
    if(c[u]==0)c[u]=co,--s;
    if(s==0)break;
    vis[u]=1;
    dfs(u,u,d,co);
    vis[u]=0;
  }
  for(int i=1;i<=n;++i)printf("%d\n",c[i]);
  return 0;
}


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

using namespace std;

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

	char ch;
	cin >> ch;
	if(ch<=90)
        cout << 'A' << endl;
    else
        cout << 'a' << endl;

	return 0;
}


Measured memory_bytes: 3656
import collections
 
N = int(input())
l = [input() for _ in range(N)]
 
c = collections.Counter(l)
 
L = c.most_common()
 
values, counts = zip(*c.most_common())
 
A = list(values)
B = list(counts)
 
b = B.count(B[0])
 
a = A[0:b]
c = sorted(a)

for i in c[0:]:
		print(i)

Measured memory_bytes: 73584
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    if(n<1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 1e5+10;
int S[N_MAX];
bool prime[N_MAX];

vector<int> eratosthenes(int n){
  list<int> l(1,2);
  for(int i = 3; i<=n; i+=2) l.push_back(i);
  for(auto it1 = l.begin(); *it1<=sqrt(n); ++it1){
    auto tmp = it1;
    tmp++;
    for(auto it2 = tmp, l_end = l.end(); it2 != l_end; ++it2){
      if(*it2 % *it1 == 0){
        l.erase(it2);
        --it2;
      }
    }
  }
  vector<int> v(l.size());
  int i = 0;
  for(auto it = l.begin(),l_end = l.end(); it != l_end;++it){
    v[i] = *it;
    ++i;
  }
  return v;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int Q;cin >> Q;
  vector<int> v = eratosthenes(N_MAX-1);
  rep(i,v.size()) prime[v[i]] = true;
  repp(x,1,N_MAX){
    S[x] += S[x-1];
    if(prime[x] && prime[(x+1)/2]) S[x] += 1;
  }
  while(Q--){
    int l,r;cin >> l >> r;
    cout << S[r] - S[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int N;cin>>N;
vector<int>v(N); for(int i=0;i<N;++i){
cin>>v[i]; }
sort(v.begin(),v.end());
int answer=v[v.size()/2]-v[v.size()/2-1];
cout<<answer<<endl;
return 0;
   }
   



Measured memory_bytes: 640
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize,
    }
    let mut cnt = vec![1; N+1];

    for i in 2..N+1 {
        let mut k = i;
        let mut flag = true;
        while flag {
            flag = false;
            for j in 2..i+1 {
                if k % j == 0 {
                    k /= j;
                    cnt[j] += 1;
                    flag = true;
                    break;
                }
            }
        }
    }
    println!("{}", cnt.into_iter().fold(1, |acc, x| acc * x % MOD));

}

Measured memory_bytes: 4352
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <iostream>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  set<string> s;
  string last = "";

  REP(i,n){
    char buff[64];
    scanf("%s", buff);

    if(s.count(buff) || (i != 0 && last.back() != buff[0])) {
      puts("No");
      return 0;
    }

    s.insert(buff);
    last = buff;
  }

  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


int A[100009];
ll Sum;
int N;

void input() {
	Sum = 0LL;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		Sum += A[i];
	}
}

void solve() {
	sort(A, A + N);
	int ans = 1; // 一番でかいやつは必ず生き残る可能性がある
	Sum -= A[N - 1];

	for (int i = N - 2; i >= 0; i--) {
		if (A[i + 1] <= 2 * Sum) ans++;
		else break;
		Sum -= A[i];
	}
	
	printf("%d\n", ans);
}

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

	input();
	solve();


	return 0;
}

Measured memory_bytes: 640
use io::*;
use std::*;

fn solve(A: i64, B: i64) {
    for i in (1..10000) {
        let taxA = (i * 8) / 100;
        let taxB = (i * 10) / 100;
        if (taxA == A && taxB == B) {
            println!("{}", i);
            return;
        }
    }
    println!("{}", -1);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut A: i64;
    A = scanner.next();
    let mut B: i64;
    B = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(A, B)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    
    Scanner sin = new Scanner(System.in);

    long sAll = sin.nextLong();

    long s = sAll % 60;
    long m = ((sAll - s) % 3600) / 60;
    long h = ((sAll - s) - m) / 3600;

    System.out.println(h + ":" + m + ":" + s);
  }
}


Measured memory_bytes: 26404
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define sz(a) (int)a.size()
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

void test() {

    double L;
    cin >> L;
    double l,b,h;
    l = L/3;
    L -= l;
    b = L/2;
    h = L - b;
    cout << fixed << setprecision(12) << l*b*h;
    
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 3688
#include <stdio.h>
main(){
  int a,b,c,d;
  scanf("%d %d",&a,&b);
  while(1){
    if(b > a){
      d = b;
      b = a;
      a = d;
    }
    if(b > 1 && b < a){
      c = a % b;
      a = b;
      b = c;
    }
    if(a % b == 0) break;
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int K;cin>>K;
    string s;cin>>s;
    if(s.size()<=K){co(s);return 0;}
    rep(i,K){
        printf("%c",s[i]);
    }
    printf("...\n");
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
  
};




int main(){

   ll n,m; cin >> n >> m;
  UnionFind UF(n);
  
  rep(i,m){
    ll a,b; cin >> a >> b; a--; b--;
    UF.unite(a,b);
  }
  
  ll ans = 0;
  
  rep(i,n){
    ans = max(ans,ll(UF.size(i)));
  }
  
  cout << ans << endl;
  
  
}

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

int main()
{
    string s;
    cin>>s;
    int i;
    bool yes = true;
    for(i=0;i<s.size();i+=2)
    {
        if(s.at(i)=='L')yes=false;
    }
    for(i=1;i<s.size();i+=2)
    {
        if(s.at(i)=='R')yes=false;
    }
    if(yes)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int main()
{
  int a,b;
  int t=0;
  int s=0;
  int i,I,j;
  int f[10],g[10];
  scanf("%d%d",&a,&b);
  for(i=a;i<=b;i++){
    I=i;
    for(j=0;;j++){
      f[j]=I%10;
      if(I/10==0){
        break;
      } else if(I/10!=0){
        I/=10;
      }
    }
    for(j=0;j<5;j++){
      g[j]=f[4-j];
    }
    s=1;
    for(j=0;j<5;j++){
      if(g[j]!=f[j]) s=0;
    }
    if(s==1) t++;
  }
  printf("%d",t);
  return 0;
}


Measured memory_bytes: 1728
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef pair<int, int> pii;

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b; 
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

void Main()
{
	int h, w;
	cin >> h >> w;
	vvi a(h, vi(w)), data(h, vi(w));
  	int b;
	rep(i,h){
		rep(j,w){
			cin >> a[i][j];
		}
	}
  	int mxtemp = 0;
	rep(i,h){
		rep(j,w){
			cin >> b;
          	data[i][j] = abs(b-a[i][j]);
          	chmax(mxtemp, data[i][j]);
		}
	}
  	
	ll mx = (mxtemp+1) * (h + w + 1);
	//cout << "mx = " << mx << endl;
  	// dp[i][j][k] = (i,j) まで偏り k でたどり着けるか
  	vector<vvb> dp(h, vvb(w, vb(mx, false)));
	dp[0][0][data[0][0]] = true;
  	int temp;
  	rep(i,h){
    	rep(j,w){
          	rep(k,mx){
              	if(i!=0){
          			temp = abs(k - data[i][j]);
              		if(dp[i-1][j][k]) dp[i][j][temp] = true;
          			temp = abs(k + data[i][j]);
              		if(dp[i-1][j][k]) dp[i][j][temp] = true;
                }
              	if(j!=0){
              		temp = abs(k - data[i][j]);
					if(dp[i][j-1][k]) dp[i][j][temp] = true;
          			temp = abs(k + data[i][j]);
					if(dp[i][j-1][k]) dp[i][j][temp] = true;
                }
  			}
        }
    }
	/*
    rep(i,h){
      	cout << "i = " << i << endl;
    	rep(j,w){
      		cout << "j = " << j << endl;
        	rep(k,40){
            	cout << dp[i][j][k];
            }
          	cout << endl;
        }
      	cout << endl;
    }
	*/
  	rep(k,mx){
  		if(dp[h-1][w-1][k] == true){
    		cout << k << endl;
      		break;
    	}
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s, t; cin >> s >> t;
  lli n = s.size();
  bool ans = false;
  for (int i=0; i<n; ++i) {
    bool e = equal(begin(s), begin(s)+i, begin(t)+n-i)
      && equal(begin(s)+i, end(s), begin(t));
    if (e) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    int a, b, sum[N+1][N+1];
    rep(i, N+1) rep(j, N+1) sum[i][j] = 0;
    rep(i, M) {
        cin >> a >> b;
        sum[a][b]++;
    }
    rep(i, N+1) rep(j, N) sum[i][j+1] += sum[i][j];
    rep(i, N+1) rep(j, N) sum[j+1][i] += sum[j][i];
    rep(i, Q) {
        cin >> a >> b;
        cout << sum[b][b] - sum[a-1][b] - sum[b][a-1] + sum[a-1][a-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define inf 0x3f3f3f
typedef long long ll;
const int maxn = 2e3+5;
int n,x,y,a[2005][2005],v[2005];
int main(){
	cin >> n >> x >> y;
	for(int i = 1;i < n;i++){
		for(int j = i+1;j <= n;j++){
			a[i][j] = j - i;
		}
	}
	for(int i = 1;i <= x;i++){
		a[i][y] = x - i + 1;
		for(int j = x+1;j <= y;j++){
			a[i][j] = min(j - i,a[i][y]+y - j);
		}
		for(int j = y+1;j <= n;j++){
			a[i][j] = a[i][y]+j - y;
		}
	}
	for(int i = x+1;i < y;i++){
		for(int j = y;j <= n;j++){
			a[i][j] = min(j - i,i - x +1 + j - y);
		}
	}
	for(int i = x+1;i < y;i++){
		for(int j = i+1;j < y;j++){
			a[i][j] = min(j - i,i-x+1+y-j);
		}
	}
	for(int i = 1;i < n;i++){
		for(int j = i +1;j <= n;j++){
			v[a[i][j]]++;
		}
	}
	for(int i = 1;i < n;i++)
		cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  long double sum = 0l;
  for(int i = 0; i < n; i++){
    long double a; cin >> a;
    sum += 1/a;
  }
  printf("%.8llf",1/sum);
}

Measured memory_bytes: 3800
#import <Foundation/Foundation.h>
int main() {
	@autoreleasepool{
		int h,w;
		scanf("%d %d",&h,&w);
		for(int i=1;i<=h;i++){
			for(char j='A';j<'A'+w;j++) {
				char s[6] = {'\0'};
				scanf("%s ",s);
				if ([[NSString stringWithFormat:@"%s", s] isEqualToString:@"snuke"]) {
					printf("%c%d",j,i);
					return 0;			}
			}
		}
	}
}

Measured memory_bytes: 9116
A, B, C = map(int, input().split())

if A == B == C and all(map(lambda x: x%2==0, [A, B, C])):
    print(-1)
else:
    ans = 0
    cookie = A+B+C
    while True:
        if all(map(lambda x: x%2==0, [A, B, C])):
            ans += 1
        else:
            print(ans)
            break
        A = (cookie-A) / 2
        B = (cookie-B) / 2
        C = (cookie-C) / 2

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int x;
    cin>>x;
    int s=0;
    int t=x;
    while(t){
        s+=t%10;
        t/=10;
    }
    if(x%s==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
def lcs(X,Y):
  hist = [0]

  for y in Y:
    for i in range(len(hist)-1, -1, -1):
      found = X.find(y, hist[i])+1
      if found:
        if i+1 >= len(hist):
          hist.append(found)
        else:
          hist[i+1] = min(hist[i+1], found)
  return len(hist)-1


n = int(input())
for _ in range(n):
  a = input()
  b = input()
  print(lcs(a,b))


Measured memory_bytes: 5612
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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

    double sum = 0.0;
    double x;
    std::string u;
    for (int i = 0; i < N; ++i) {
        std::cin >> x >> u;

        if (u == "JPY") {
            sum += (double)(x);
        } else {
            sum += 380000.0 * x;
        }
    }

    std::printf("%.8lf\n", sum);

    return 0;
}

Measured memory_bytes: 256
N = int(input())
abc = [list(map(int,input().split())) for i in range(N)]

infty = 10**10

dp = [[infty, infty, infty] for i in range(N)]

for i in range(3):
    dp[0][i] = abc[0][i]

def solve():
    for i in range(1,N):
        for j in range(3):
            tmp = [0,1,2]
            tmp.remove(j)
            dp[i][j] = max(dp[i-1][tmp[0]],dp[i-1][tmp[1]]) + abc[i][j]

solve()
print(max(dp[N-1]))

Measured memory_bytes: 47344
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }
    let ans = std::cmp::max(std::cmp::max(a + b, a + a - 1), b + b - 1);
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n;
        cin >> n;
        int ans = 1;
        for (int i = 2; i * i <= n; ++i) {
            int tmp = i;
            for (; tmp <= n; tmp *= i) {
                chmax(ans, tmp);
            }
        }
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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

int main() {
  int N; // [2, 10^5]
  cin >> N;
  vector<int> a(N); // buttons
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    a.at(i)--;
  }

  int cur = 0;
  int out = -1;
  for(int i=0;i<N;i++){
    int next = a.at(cur);
    if(next == 2 - 1){
      // button 2
      out = i+1;
      break;
    }
    cur = next;
  }
  cout << out << endl;
}


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

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

    if(N/100==7||(N%100)/10==7||N%10==7){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
string S;
int result;
int main() {
  cin >> S;
  N = S.size();
  result = N / 2;
  int left, right;
  if (N % 2 == 0) {
    left = N / 2 - 1;
    right = left + 1;
  } else {
    left = N / 2;
    right = left;
  }
  char c = S[left];
  while (left >= 0 and right < N) {
    if (c == S[left] and c == S[right]) {
      left--;
      right++;
      result++;
    } else {
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 512
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            string[] str = Console.ReadLine().Split(' ');　//二つ以上のすぺーすくぎりを使う
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);

            if (9 >= a && 9 >= b)
                Console.WriteLine(a * b);
            else
                Console.WriteLine("-1");
            Console.ReadKey();




        }
    }
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

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

	int n = s.size();
	sort(all(s));
	s.erase(unique(all(s)), s.end());

	cout << (n == s.size() ? "yes" : "no") << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		ArrayList<Integer> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int i, num, snum, l = 1, r;
	string s;
	cin >> num >> snum >> s;
	s = "x" + s + "x";
	r = num;
	vector<string> spl(snum), drct(snum);
	for (i = 0; i < snum; i++)
		cin >> spl[i] >> drct[i];
	for (i = snum - 1; i >= 0; i--) {
		if (drct[i] == "L") {
			if (s[l] == spl[i][0])
				l++;
			if (s[r + 1] == spl[i][0])
				r++;
		}
		else {
			if (s[r] == spl[i][0])
				r--;
			if (s[l - 1] == spl[i][0])
				l--;
		}
	}
	cout << r - l + 1 << "\n";
	return 0;
}

Measured memory_bytes: 22348