akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

struct UnionFind{
    vector<ll> par;
    vector<ll> sizes;
    UnionFind(ll n) : par(n), sizes(n, 1) {
        rep(i,n) par[i] = i;
    }
    int find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return sizes[find(x)];
    }
};

map<pair<int, int>, int> mp;
vector<pair<int,int>> vp;

int main(){
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n);
    UnionFind rail(n);
    rep(i, k){
        int p, q;
        cin >> p >> q;
        p--, q--;
        road.unite(p, q);
    }
    rep(i, l){
        int r, s;
        cin >> r >> s;
        r--, s--;
        rail.unite(r, s);
    }

    rep(i, n){
        int a = road.find(i);
        int b = rail.find(i);
        mp[{a,b}]++;
        vp.push_back({a,b});
    }

    for(auto e : vp) cout << mp[e] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 22332
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 998244353;


int main(void){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int N = 190;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

char s[N];
int n, m, g[N][N];
int dp[2][N][N][N];

void init() {
	read(n); read(m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j) {
			g[i][j] = ((s[j] == '#')? 1 : 0);
			g[i][j] += g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1];
		}
	}
}

void solve() {
	for (int l = 1; l <= m; ++l) {
		for (int r = l; r <= m; ++r) {
			for (int i = 1; i <= n; ++i) {
				int x = max(i - 1, dp[0][i - 1][l][r]);
				while (x < n) {
					int cnt = g[x + 1][r] - g[i - 1][r] - g[x + 1][l - 1] + g[i - 1][l - 1];
					if (cnt == 0 || cnt == (x - i + 2) * (r - l + 1)) ++x;
					else break;
				}
				dp[0][i][l][r] = x;
			}
		}
	}
	int k = 1, pre = 0, cur = 1;
	for (; dp[pre][1][1][m] < n; ++k) {
		mset(dp[cur], 0);
		for (int i = 1; i <= n; ++i) {
			for (int len = 1; len <= m; ++len) {
				for (int l = 1, r = len; r <= m; ++l, ++r) {
					if (dp[pre][i][l][r] == n) {
						dp[cur][i][l][r] = n;
						continue;
					}
					dp[cur][i][l][r] = dp[pre][ dp[pre][i][l][r] + 1 ][l][r];
					int L = l, R = r - 1, P = 0;
					while (L <= R) {
						int mid = (L + R) >> 1;
						int lv = dp[pre][i][l][mid], rv = dp[pre][i][mid + 1][r];
						cmax(P, min(lv, rv));
						if (lv < rv) {
							R = mid - 1;
						} else {
							L = mid + 1;
						}
					}
					cmax(dp[cur][i][l][r], P);
				}
			}
		}
		swap(pre, cur);
	}
	printf("%d\n", k - 1);
}

int main() {
	init();
	solve();
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 2e3+ 2, mod = 1e9 + 7;


void solve() {
     string s;
     cin >> s;
     int n = s.length();
     if(s[n - 1] == 's') {
          s += "es";
     } else {
          s += 's';
     }
     cout << s;
}    


int main() {
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case #:" << tc << " ";
		solve();
	}
}

Measured memory_bytes: 3632
#include <stdio.h>
 
int main() {
  int a[101][101] = {0};
  int b[101] = {0};
  int d[101] = {0};
  int i,j,r,c;
  int x;
  int e = 0;
 
  scanf("%d %d" , &r,&c);
 
  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      scanf("%d",&x);
      a[j][i] = x;
    }
  }
 
  for(j=0; j<r; j++){
    for(i=0; i<c; i++) {
      b[i] += a[j][i];
    }
  }
 
  for(j=0; j<r; j++){
    for(i=0; i<c; i++){
      d[j] += a[j][i];
    }
  }
 
  for(j=0; j<r; j++) {
    for(i=0; i<c; i++) {
      printf("%d ",a[j][i]);
    }
    printf("%d\n", d[j]);
  }
  for(i =0; i<c; i++) {
    printf("%d " ,b[i]);
    e += b[i];
  }
  printf("%d\n", e);
 
  return 0;
}


Measured memory_bytes: 2076
// C++ program to find the longest 
// path in the DAG 

#include <bits/stdc++.h> 
using namespace std; 

// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	// Mark as visited 
	vis[node] = true; 

	// Traverse for all its children 
	for (int i = 0; i < adj[node].size(); i++) { 

		// If not visited 
		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		// Store the max of the paths 
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
	// Dp array 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 

	// Visited array to know if the node 
	// has been visited previously or not 
	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	// Call DFS for every unvisited vertex 
	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	// Traverse and find the maximum of all dp[i] 
	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

// Driver Code 
int main() 
{ 
	int n ,m;
	cin>>n>>m;
	vector<int> adj[n + 1]; 
	while(m--)
	{
	    int x,y;
	    cin>>x>>y;
	    addEdge(adj,x,y);
	}
	


	cout << findLongestPath(adj, n); 
	return 0; 
} 


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

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



Measured memory_bytes: 256
// Created by arjun_singh12 (Arjun Singh) on [29-04-2020 20:28:55]
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define M 1000000007
#define INF LLONG_MAX
#define vll vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>>
#define pb push_back
#define pll pair<ll,ll>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define repr(i,n,a) for(ll i=n;i>=a;i--)
#define endl "\n"
#define db(x); cout<<"Debug: "<<#x<<" = "<<x<<endl;
#define dbv(v); cout<<"Debug: Vector "<<#v<<" = "; for(ll i=0;i<sz(v);i++) cout<<v[i]<<" "; cout<<endl;
using namespace std;
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll test=1;
	// cin>>test;
	while(test--)
	{
	    string s1,s2; cin>>s1>>s2;
	    ll m=s1.length(),n=s2.length();
	    ll dp[m+1][n+1]; 
	    rep(i,0,m+1) dp[i][0]=0;
	    rep(j,0,n+1) dp[0][j]=0;
	    rep(i,1,m+1)
	    {
	    	rep(j,1,n+1)
	    	{
	    		if(s1[i-1]==s2[j-1])
	    			dp[i][j]=1+dp[i-1][j-1];
	    		else
	    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	    	}
	    }
//	    cout<<dp[m][n]<<endl;
	    string lcs="";
	    ll ptr1=m,ptr2=n;
	    while(ptr1>0 && ptr2>0)
	    {
	    	if(s1[ptr1-1]==s2[ptr2-1])
	    	{
	    		lcs=s1[ptr1-1]+lcs;
	    		ptr1--;
	    		ptr2--;
	    	}
	    	else
	    	{
	    		if(dp[ptr1-1][ptr2]>dp[ptr1][ptr2-1])
	    		{
	    			// lcs=s1[ptr1-1]+lcs;
	    			ptr1--;
	    		}
	    		else
	    		{
	    			// lcs=s2[ptr2-1]+lcs;
	    			ptr2--;
	    		}
	    	}
	    }
//	    while(ptr1>0)
//	    {
//	    	if(s1[ptr1-1]==s2[0])
//	    	lcs=s1[ptr1-1]+lcs;
//	    	ptr1--;
//	    }
//	    while(ptr2>0)
//	    {
//	    	if(s1[0]==s2[ptr2-1])
//	    	lcs=s2[ptr2-1]+lcs;
//	    	ptr2--;
//	    }
	    cout<<lcs<<endl;
	}
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,a[N][3],b[N][3];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    b[1][0]=a[1][0];
    b[1][1]=a[1][1];
    b[1][2]=a[1][2];
    for(int i=2;i<=n;i++)
    {
        b[i][0]=a[i][0]+max(b[i-1][1],b[i-1][2]);
        b[i][1]=a[i][1]+max(b[i-1][0],b[i-1][2]);
        b[i][2]=a[i][2]+max(b[i-1][1],b[i-1][0]);
    }
    cout<<max(max(b[n][0],b[n][1]),b[n][2]);
}


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

int a[200000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	sort(a,a+n);
	double A=a[n-1]/2.;
	double Min=INT_MAX;
	int id=-1;
	rep(i,n-1){
		if(Min>abs(A-a[i])){
			Min=abs(A-a[i]);
			id=i;
		}
	}
	cout<<a[n-1]<<' '<<a[id]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
using Graph=vector<vector<int>>;

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  vector<ll> B=A;
  reverse(A.begin(),A.end());

  vector<ll> sum(N+1,0);
  for(int i=0;i<N;i++){
    sum.at(i+1)=sum.at(i)+A.at(i);
  }

  //A降順
  //B昇順

  ll left=0;
  ll right=10000000000;
  while(left+1<right){
    ll x=(left+right)/2;
    ll count=0;
    for(int i=0;i<N;i++){
      int k=lower_bound(B.begin(),B.end(),x-A.at(i))-B.begin();
      count+=N-k;
    }
    if(count>=M){
      left=x;
    }else{
      right=x;
    }
  }

  ll count=0;
  ll ans=0;
  for(int i=0;i<N;i++){
    int k=lower_bound(B.begin(),B.end(),left-A.at(i))-B.begin();
    ans+=sum.at(N-k)+A.at(i)*((ll)N-(ll)k);
    count+=N-k;
  }
  ans-=left*(count-M);
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int k,n;
    vector<int>d;
    int num;
    cin >>k >> n;
    int dd =0 ;
    for(int i=0;i<n;i++){
        cin >> num;
        d.push_back(num);
        if(i){
            dd=max(dd,d[i]-d[i-1]);
        }
    }
    dd=max(dd,d[0]+k-d[n-1]);
    cout << k-dd << endl;
    return 0;
}


Measured memory_bytes: 4320
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
     int a[100005] , count[100005] ;
     int n ;
     long long k ;
     cin >> n >> k ;
     
     for(int i=1;i<=100000;i++){
          count[i] = 0 ;
     }
     
     for(int i=0;i<n;i++){
          int b ;
          cin >> a[i] >> b ;
          count[a[i]] += b ;
     }
     
     sort(a , a+n) ;
     
     long long c = 0 ;
     for(int i=0;i<n;i++){
          
          if(i == n-1){
               cout << a[i] << endl ; 
               break ;
          }
          
          if(a[i] == a[i+1]) continue ;
          
          c += count[a[i]] ;
          if(k<=c){
               cout << a[i] << endl ;
               break ;
          }
     }
    
}


Measured memory_bytes: 1024
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        int[] k = new int[n];
        for(int i = 0; i < n; i++){
            k[i] = sc.nextInt();
            for(int j = 0; j < k[i]; j++){
                a[i][j] = sc.nextInt() - 1;
            }
        }
        int ans = 0;
        for(int j = 0; j < m; j++){
            for(int i = 0; i < n; i++){
                boolean flag = false;
                for(int x = 0; x < k[i]; x++){
                    if(a[i][x] == j) flag = true;
                }
                if(!flag) break;
                if(i == n-1) ans++;
            }
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

map<string,int> mp;

int main()
{
    int n,flag = 0;
    string s,tp;
    int k = 0;
    int len;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(k == 0)
        {
            tp = s;
            len = tp.size();
            k = 1;
            mp[s] = 1;
            continue;
        }

        if(flag == 0)
        {
            if(mp[s])
            {
                printf("No\n");
                flag = 1;
            }
            else
            {
                mp[s] = 1;
                if(tp[len-1]!=s[0])
                {
                    printf("No\n");
                    flag = 1;
                }
            }
        }
        tp = s;
        len = tp.size();
    }
    if(flag == 0)
        printf("Yes\n");
    return 0;
}


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

int main(){
    int a,b,d;
    cin>>a>>b>>d;
    int c=0,x=d;;
    int i=1;
    while(d<=b){
        d=x*i;
      
        if(d>=a&&d<=b){
            c++;
          
        }
        i++;

    }
    cout<<c<<endl;

}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  ll h,n; cin>>h>>n;
	VL a(n),b(n),dp; rep(i,n) cin>>a[i]>>b[i];
	ll a_max = 0; rep(i,n) chmax(a_max,a[i]);
	dp.PB(0);
	reps(i,h+a_max){
		ll tmp = LINF;
		rep(j,n){
			if(i-a[j]<0) continue;
			chmin(tmp,dp[i-a[j]]+b[j]);
		}
		dp.PB(tmp);
	}
	ll ans = LINF;
	for(int i=h; i<=h+a_max-1; i++){
		chmin(ans,dp[i]);
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  ll n, asum = 0, bsum = 0;
  cin >> n;
  vector<ll> a;
  for (ll i = 0; i < n; i++) {
    ll m;
    cin >> m;
    a.push_back(m);
    asum += m;
  }
  ll res = 1e10;
  for (ll i = 0; i < n-1; i++) {
    bsum += a[i];
    asum -= a[i];
    ll c = abs(asum-bsum);
    res = res > c ? c : res;
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{

    int a, b;
    cin >> a >> b;
    if (a / 10 > 0 || b / 10 > 0)
    {
        cout << -1;
    }
    else
    {
        cout << a * b;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

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

		int N = sc.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++) p[i]=sc.nextInt();

		int ans = 0;
		for(int i=0; i<N-2; i++){
			if(p[i]<p[i+1] && p[i+1]<p[i+2] || p[i+2]<p[i+1]&&p[i+1]<p[i])ans++;
		}
		out.println(ans);

		out.flush();
	}
}



Measured memory_bytes: 23636
#include <vector>
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
vector<int> a;

int main()
{
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int max = *max_element(a.begin(), a.end());
    int next;
    int cnt;
    if ((cnt = count(a.begin(), a.end(), max)) == 1) {
        auto it = find(a.begin(), a.end(), max);
        a[it - a.begin()] = 0;
        next = *max_element(a.begin(), a.end());
        a[it - a.begin()] = max;
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] < max || (a[i] == max && cnt != 1)) printf("%d\n", max);
        else printf("%d\n", next);
    }

    return 0;
}



Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,n,cnt;
	while(1){
		cin>>n;
		if(n==0) break;
		cnt=0;
		while(1){
			if(n==1) break;
			if(n%2==0) n=n/2;
			else n=n*3+1;
			cnt=cnt+1;
		}
		cout<<cnt<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <tgmath.h>
#include <queue>
#include <cstring>
#include <map>
#include <set>
typedef long long ll;
using namespace std;

struct edge{
    int to;
    ll yen;
    ll snuuk;
};

int n,m,s,t;
ll money_yen = pow(10,15);
vector<vector<edge>> edges;
// startから両替所までの距離(yen);
vector<ll> dYen;
// 両替所からゴールまでの距離(スヌーク);
vector<ll> dSnuuk;
typedef pair<int,int> P;


void dijkstra_Exchange(){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,s));
    dYen[s] = 0;

    while(!que.empty()){
        P p = que.top();
        // cout << p.first<<"v="<<p.second<<endl;
        que.pop();
        int v = p.second;
 
        if(dYen[v] < p.first){
            continue;
        }
        for(int i=0;i<edges[v].size();i++){
            edge e = edges[v][i];
            // cout << "v=" << v<<endl;
            //    cout << "eto=" << e.to<<endl;
            // cout << "dYen[v]+eyen=" << dYen[v] + e.yen << endl;
            if(dYen[e.to] > dYen[v] + e.yen){
                dYen[e.to] = dYen[v] + e.yen;
                que.push(P(dYen[e.to],e.to));
            }
        }
    }
    
}

void dijkstra_Goal(){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,t));
    dSnuuk[t] =0;

    while(!que.empty()){
        P p = que.top();
        que.pop();
        // cout << p.first<<"v="<<p.second<<endl;
        int v = p.second;
        if(dSnuuk[v] < p.first){
            continue;
        }
        for(int i=0;i<edges[v].size();i++){
            edge e = edges[v][i];
            //        cout << "v=" << v<<endl;
            //    cout << "eto=" << e.to<<endl;
            // cout << "dSnuuk[v]+eyen=" << dSnuuk[v] + e.yen << endl;
            if(dSnuuk[e.to] > dSnuuk[v] + e.snuuk){
                dSnuuk[e.to] = dSnuuk[v] + e.snuuk;
                que.push(P(dSnuuk[e.to],e.to));
            }
        }
    }

}



int main(){
    cin >> n >> m>> s>> t;
    s--;
    t--;
    edges.resize(n);
    dYen.resize(n,money_yen);
    dSnuuk.resize(n,money_yen);
    for(int i= 0;i<m;i++){
        int u,v,a,b;
        cin >> u >> v>> a>>b;
        u--;
        v--;
        edges[u].push_back({v,a,b});
        edges[v].push_back({u,a,b});
    }
    dijkstra_Exchange();
    dijkstra_Goal();

    vector<ll> ans(n);
    ans.push_back(money_yen);
    for(int i= n-1;i>=0;i--){
        // cout << dYen[i] << " "<< dSnuuk[i] << endl;
        ans[i] = min(ans[i+1],dYen[i]+dSnuuk[i]);
    }
    for(int i=0;i<n;i++){
        cout << (money_yen-ans[i]) << endl;
    }


}

Measured memory_bytes: 13124
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define MAX_N 2002
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<P1,P1> P2;
const ll INF=100000000000000001;
int dp1[MAX_N][MAX_N]={};
int dp2[MAX_N][MAX_N]={};
bool d[MAX_N][MAX_N]={};
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
queue<P1> que;
vector<string> v;

int main() {
	string s;
	cin>>s;
	int k;
	cin>>k;
	int ls=s.length();
	rep(i,ls){
		int x1=s[i]-'a';
		if(x1==0)continue;
		if(x1+k>=26){
			k-=26-x1;
			s[i]='a';
		}
	}

	int x1=s[ls-1]-'a';
	x1=(x1+k)%26;
	s[ls-1]=(char)(x1+'a');
	cout<<s<<endl;

	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    h = int(lines[0])
    w = int(lines[1])
    n = int(lines[2])
    return (h, w, n)


def solve(h, w, n):

    o = max([h, w])

    if n % o == 0:
        result =  n // o
    else:
        result = int(math.floor(n / o)) + 1
    
    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

template <long long mod>
long long mod_pow(long long a, long long b) {
    if (b == 0) return 1;
    long long ret = mod_pow<mod>(a, b / 2);
    ret = ret * ret % mod;
    if (b % 2 == 1) ret = a * ret % mod;
    return ret;
}

ll n, a, b;
const ll MOD = TEN(9) + 7;

int main() {
    fastio();

    cin >> n >> a >> b;

    ll num = 1, denom = 1;
    for (int i = 1; i <= a; i++) {
        denom = denom * i % MOD;
        num = num * (n - i + 1) % MOD;
    }

    ll aa = num * mod_pow<MOD>(denom, MOD - 2) % MOD;

    num = denom = 1;
    for (int i = 1; i <= b; i++) {
        denom = denom * i % MOD;
        num = num * (n - i + 1) % MOD;
    }

    ll bb = num * mod_pow<MOD>(denom, MOD - 2) % MOD;

    cout << ((mod_pow<MOD>(2, n) - aa + MOD) % MOD - bb - 1 + MOD) % MOD << endl;

    return 0;
}

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

int main() {
    double x1,y1,x2,y2;
    double ans;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8f\n",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));

    return 0;
}


Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int kotae = 0;
			if(n <= 36){
				for(int a=0;a<=9;a++){
					for(int b=0;b<=9;b++){
						for(int c=0;c<=9;c++){
							for(int d=0;d<=9;d++){
								if((a+b+c+d) == n){
									kotae++;
								}
							}
						}
					}
				}
			}
			System.out.println(kotae);
		}
	}
}

Measured memory_bytes: 12000
MOD=10**9+7

N,K=map(int,input().split())
ans=0
ans+=N-K+2
ans+=(N+1)*(N+1+K)*(N-K+2)//2
ans%=MOD
ans-=(N+1)*(N+2)*(2*N+3)//6
ans%=MOD
ans+=K*(K-1)*(2*K-1)//6
ans%=MOD
print(ans)

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

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

ll f(ll n, ll d) { return n - n / d; }

ll f(ll n, ll c, ll d) { return f(n, c) + f(n, d) - f(n, c * d / gcd(c, d)); }

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << f(b, c, d) - f(a - 1, c, d) << endl;
}


Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for (int r = 0; r <= 3000; ++r) {
		for (int g = 0; g <= 3000; ++g) {
			int rem = N - r * R - g * G;
			if (rem >= 0 && rem % B == 0) {
				++ans;
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

bool solve(int N, int K) {
	if (N == 1)return true;
	if (N < K)return false;
	if (N%K == 0)return solve(N / K, K);
	return solve(N%K, K);

}

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

	int N; cin >> N;
	int n = N;
	vector<int> ret;
	map<int, bool>mp;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			if (!mp[i]) {
				ret.push_back(i);
				mp[i] = 1;
			}
			if (i*i != n)
			{
				if (!mp[n / i]) {
					ret.push_back(n / i);
					mp[n / i] = 1;
				}
			}
		}
	}
	n = N - 1;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			if (!mp[i]) {
				ret.push_back(i);
				mp[i] = 1;
			}
			if (i*i != n)
			{
				if (!mp[n / i]) {
					ret.push_back(n / i);
					mp[n / i] = 1;
				}
			}
		}
	}
	SORT(ret);
	int ans = 0;
	fore(i, ret) {
		if (i == 1)continue;
		if (solve(N, i))ans++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3904
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define DEBUGM(d,n,m,i,j) printf("DEBUGM :\n"); rep(i,n){ rep(j,m) if(inf==d[i][j]) printf("inf "); else printf("%d ", d[i][j]); printf("\n");} printf("DEBUGM END LINE\n")

typedef long long ll;

const ll INF =1LL << 62;
const int inf =1 << 29;

ll comb(int num, int rnum){
    ll ans = 1;
    if(num>rnum){
        for(int i=num;i>=num-rnum+1; i--){ans = i * ans; ans = ans / (num-i+1);}
    }
    return ans;
}

int main(){
    int n,a,b; cin >> n >> a >> b;
    vector<long long int> v(n); rep(i,n) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long int>());
    long long int suma = 0; for(int i=0;i<a;i++) suma += v[i];
    double ansd = (double)suma / (double)a;
    bool same = true;
    rep(i,a+1) if(v[i]!=v[0]) same = false;
    if(same){
        int r = a-1;
        while(r<n&&v[r]==v[a-1]) r++;
        if(v[r]!=v[a-1]) r--;
        long long int ans = 0;
        for(int i=a-1;i<=min(r,b-1);i++) ans = ans + comb(r+1, i+1);
        printf("%.10lf\n", ansd);
        cout << ans << endl;   
    }else {
        int l = a-1, r = a-1;
        while(0<=l&&v[l]==v[a-1]) l--;
        if(v[l]!=v[a-1]) l++;
        while(r<n&&v[r]==v[a-1]) r++;
        if(v[r]!=v[a-1]) r--;
        //long long int comb = 1;
        int num = r-l+1;
        int rnum = a-1-l+1;
        
        printf("%.10lf\n", ansd);
        cout << comb(num,rnum) << endl;   
    }
    
    return 0;
}

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

int a[10];

int main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    for (int i = 0; i < 4; i++) {
        int t; cin >> t;
        a[t] = 1;
    }
    
    if (a[1] && a[7] && a[9] &&a[4])
        cout << "YES\n";
    else
        cout << "NO\n";
        
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(), b = scanner.nextInt();
		scanner.close();
		System.out.printf("%d %d", a*b, 2*(a+b));
		System.out.println();
	}

}


Measured memory_bytes: 26040
#include <iostream>
#include <cctype>
#include <cstdio>
using namespace std;

int main()
{
	char ch;
	int count[26] = {}, i;

	while (cin >> ch)
	{

		if (isalpha(ch))
		{
			ch = tolower(ch);
			count[ch - 'a'] += 1;
		}
	}

	for (i = 0; i < 26; i++)
	{
		printf("%c : %d\n", 'a' + i, count[i]);
	}
		
}

Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
using namespace std;

typedef vector<vector<int> > Graph;

const int INF = 1<<28;

int N;
Graph G;
  
int bfs(int src, int dst) {
  queue<int> que;
  vector<int> cost(N, INF);
  que.push(src);
  cost[src] = 0;
  while(que.size()) {
    const int v = que.front();
    que.pop();
    for(int i = 0; i < G[v].size(); ++i) {
      int nv = G[v][i];
      if(cost[nv] != INF) continue;
      cost[nv] = cost[v] + 1;
      que.push(nv);
    }
  }
  return cost[dst];
}

int main() {
  cin >> N;
  G.resize(N);
  vector<vector<int> > to(N);
  map<int,int> id;
  for(int i = 0; i < N; ++i) {
    int r, k;
    cin >> r >> k;
    id[r] = i;
    to[i].resize(k);
    for(int j = 0; j < k; ++j) {
      cin >> to[i][j];
    }
  }
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < to[i].size(); ++j) {
      G[i].push_back(id[to[i][j]]);
    }
  }

  int p;
  cin >> p;
  while(p--) {
    int s, d, v;
    cin >> s >> d >> v;
    s = id[s];
    d = id[d];
    int res = bfs(s, d);
    if(res < v) {
      cout << res+1 << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);




void solve(int testCase){

    int n;
    scanf("%d" , &n);


    vi dp(3 , 0);
    for(int i = 0 ; i < n ; i ++){

            vi curr(3 , 0);
            for(int j = 0 ; j < 3 ; j ++){
                    int x; scanf("%d" , &x);
                    for(int k = 0 ; k < 3 ; k ++){
                            if(j != k){
                                    curr[j] = max(curr[j] , x + dp[k]);
                            }
                    }
            }

            dp = curr;
    }

    printf("%d\n" , max({dp[0] , dp[1] , dp[2]}));

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

from collections import deque

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

if N == 1:
    print(A[0])
    exit()

d = deque()
if N % 2 == 0:
    for i in range(N):
        if i%2 == 1:
            d.appendleft(A[i])
        else:
            d.append(A[i])
else:
    for i in range(N):
        if i%2 == 0:
            d.appendleft(A[i])
        else:
            d.append(A[i])

print(*d)

Measured memory_bytes: 25424
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main()
{
    IOS;
    char c;
    cin >> c;
    c+= 'b'-'a';
    cout << c << "\n";   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    ll n; cin >> n;
    string s; cin >> s;
    ll cw = 0, cr = 0, iw = 0, ir = 0;;
    rep(i,n) {
        if (s[i] == 'W')
            iw++;
        else
            ir++;
    }
    rep(i,ir) {
        if (s[i] == 'W')
            cw++;
    }
    cout <<cw << endl;
    return 0;
}


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

int main(){
  int n;
  char c;
  int ans,ace;

 while(1){
    ans = 0;
    ace = 0;

    while(1){
      c = getchar();
      if(c=='0')goto Loop;
      if(c=='\n')break;
      else if(c!=' '){
	n = c-'0';
	if(n==1){
	  c = getchar();
	  if(c=='\n'){
	    ans += 1;
	    ace = 1;
	    break;
	  }else if(c!=' '){
	    ans += 10;
	  }else{
	    ans += 1;
	    ace = 1;
	  }
	}else{
	  ans += n;
	}
      }
    }

    if(ans<12 && ace)ans+=10;
    if(ans>21)ans = 0;
    cout << ans << endl;
  }
 Loop:return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

        solve();
    }

    static void solve() {
        int add = A + B;
        int sub = A - B;
        int mul = A * B;

        int max = Math.max(Math.max(add, sub), mul);
        System.out.println(max);
    }
}


Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N =  int(input())
given = [list(input().split()) for i in range(N)]
rate = 380000

def solve():
    given_yen = 0
    given_btc = 0
    for comb in given:
        if comb[1] == 'JPY':
            given_yen += int(comb[0])
        if comb[1] == 'BTC':
            given_btc += float(comb[0])
    return given_yen + given_btc * rate

print(solve())

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

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

	string a = s.substr(0,2);
	string b = s.substr(2,3);
	int cnt{};int aa{};int bb{};

	if(a == "01"||a == "02"||a=="03"||a=="04"||a=="05"||a=="06"||a=="07"||a=="08"||a=="09"||a=="10"||a=="11"||a=="12"){
		cnt++;
		aa = 1;
	}
	
	if(b == "01"||b == "02"||b=="03"||b=="04"||b=="05"||b=="06"||b=="07"||b=="08"||b=="09"||b=="10"||b=="11"||b=="12"){
		cnt++;
		bb = 1;
	}

	if(cnt == 0){
		cout << "NA" << endl;
	}
	else if(cnt == 2){
		cout << "AMBIGUOUS" << endl;
	}
	else{
		if(aa == 1)cout << "MMYY" << endl;
		else cout << "YYMM" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[100010];
signed main(){
   int n;
   cin>>n;
   vector<pair<int,int>>v;
   REP(i,n) {
       cin>>a[i];
       v.push_back({a[i],i});
   }
    sort(ALL(v));
    for (int i = 0; i < n; i++)
    {
        cout<<v[i].second+1<<" ";
    }
    cout<<endl;
    return 0;
}

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

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

    int N;
    cin >> N;
    vector<vector<int>> XY(N, vector<int>(2));
    for (int i = 0; i < N; i++) {
        cin >> XY[i][0] >> XY[i][1];
    }
    sort(XY.begin(), XY.end(), [](auto& x, auto& y) { return x[0] > y[0]; });
    sort(XY.begin(), XY.end(), [](auto& x, auto& y) { return x[1] > y[1]; });
    int match = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            int m = 0, p, q;
            p = XY[i][0] - XY[j][0];
            q = XY[i][1] - XY[j][1];
            for (int k = 0; k < N; k++) {
                for (int l = 0; l < N; l++) {
                    if (k == l) continue;
                    if (XY[k][0] - XY[l][0] == p && XY[k][1] - XY[l][1] == q) m++;
                }
            }
            match = max(m, match);
        }
    }
    cout << N - match << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n,x; cin >> n >> x;
	int minD = 100000000;
	int sumD = 0;
	for (int i = 0; i < n; ++i)
	{
		int m; cin >> m;
		sumD += m;
		minD = min(minD,m);
	}

	cout << n + (x-sumD)/minD << endl;

}

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

using namespace std;

int main()
{
    int w,h,n; cin>>w>>h>>n;
    int a,b,c,d;
    a=0;
    b=w;
    c=0;
    d=h;
    while(n--)
    {
        int x; cin>>x;
        int y; cin>>y;
        int z; cin>>z;
        if(z==1)
        {
            a=max(a,x);
        }
        if(z==2)
        {
            b=min(b,x);
        }
        if(z==3)
        {
            c=max(c,y);
        }
        if(z==4)
        {
            d=min(d,y);
        }
    }
    int x1=max(0,b-a);
    int x2=max(0,d-c);
    cout<<x1*x2;
    return 0;
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			PriorityQueue<Integer> q = new PriorityQueue<>();
			int minus_cnt = 0;
			for (int i = 0; i < N; i++) {
				int a = sc.nextInt();
				if (a < 0) {
					minus_cnt++;
					a = (-1) * a;
				}
				q.add(a);
			}
			long sum = 0;
			if (minus_cnt % 2 != 0) {
				sum -= q.poll();
			}
			while (!q.isEmpty()) {
				sum += q.poll();
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 59720
[n,k] = [int(i) for i in input().split()]
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
#print(h)
dif = []
for i in range(n - k + 1):
    dif.append(h[i+k-1]-h[i])
print(min(dif))


Measured memory_bytes: 11288
#include<stdio.h>
int main() {
	int a, b;
	int d, r;
	double f;
	scanf("%d %d", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %.5f", d, r, f);
}



Measured memory_bytes: 2120