akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    long long N; cin >> N;
    for (int h = 1; h <= 3500; h++) for (int n = 1; n <= 3500; n++) {
        long long num = N * h * n;
        long long den = 4LL * h * n - N * (h + n);
        if (den > 0 && num % den == 0) {
            long long w = num / den;
            cout << h << " " << n << " " << w << endl;
            return 0;
        }
    }
    return 0;
}


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

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

int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    printf("%d\n", a != c);

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val arr = LongArray(100001)
    var sum = 0L
    val a = readLine()!!.split(' ').map {
        val num = it.toInt()
        arr[num]++
        sum += num
        num
    }
    val q = readLine()!!.toInt()

    repeat(q) {
        val (b, c) = readLine()!!.split(' ').map { it.toLong() }
        val cnt = arr[b.toInt()]
        sum -= cnt*b
        sum += cnt*c
        println(sum)
        arr[b.toInt()] -= cnt
        arr[c.toInt()] += cnt
    }
}


Measured memory_bytes: 61748
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, i;
    cin >> N >> i;
    cout << N-i+1 << endl;
    return 0;
}


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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[int((s).size())-1]
#define prelast(s) (s)[int((s).size())-2]
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define elif else if
#define left asdasd
#define next zaza

#define cclear cout<<flush;
#define x0 kerker
#define time chas
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("a.in", "r", stdin);freopen("a.out", "w", stdout);
#define ref svyazi
#define int long long
#define ii pair<int, int>
#define ld long double
#define list spisok


using namespace std;
//using namespace __gnu_cxx;
string s;
int n,q,pr[1000100],dp[1000100][4],k;
main(){
    kchay;
    cin >> n;
    cin >> s;
    cin >> q;
    for (int i=0;i<n;i++){
        if(s[i]=='M') pr[i]++;
        if (s[i]=='D')dp[i][1]++;
        if (i!=0) {
            pr[i]+=pr[i-1];
            dp[i][1]+=dp[i-1][1];
        }
    }
    for (int i=1;i<n;i++){
        if (s[i]=='M'){
            dp[i][2]+=dp[i-1][1];
        }
        if (s[i]=='C'){
            dp[i][3]+=dp[i-1][2];
        }
        dp[i][2]+=dp[i-1][2];
        dp[i][3]+=dp[i-1][3];
    }
    for (int i=0;i<q;i++){
        cin >> k;
        int temp_ans=0;
        for (int i=k;i<n;i++){
            if (s[i]=='C') temp_ans+=dp[i-k][2]+dp[i-k][1]*(pr[i-1]-pr[i-k]);
        }
        cout<<dp[n-1][3]-temp_ans<<endl;
    }
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;

ll mypow(ll x, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x;
        x *= x;
        n >>= 1;
    }
    return res;
}

int main() {
    cin >> N >> M;
    cout << (1900 * M + 100 * (N - M)) * mypow(2, M) << "\n";
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double anga = 30 * h + 0.5 * m, angb = m * 6;
  double ang = min(abs(anga - angb), 360 - abs(anga - angb));
  
  ang = ang * M_PI / 180;
  
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(ang));
  
  cout << fixed << setprecision(10) << ans << '\n';
}

Measured memory_bytes: 4228
// Created by Tanuj Jain
#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;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll bottom_up(vector<ll>&weights, vector<ll>&values, int total_capacity)
{
	int n=weights.size();
	//make a dp table where we map item on rows and value on columns since teh weights can be very large
	int total_values=0;
	for(int i=0;i<n;i++)
		total_values+=values[i];
	vector<vector<ll>>dp(n+1,vector<ll>(total_values+1,INF));
	dp[0][0]=0;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=total_values;j++)
		{
			if(j-values[i-1]>=0)
			{
				//take the min weight obtained by using this item and not using this item
				dp[i][j]=min(dp[i-1][j], weights[i-1] + dp[i-1][j-values[i-1]]);
			}
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	//iterate over the last row and find the maximum value we can get 
	for(ll i=0;i<=total_values;i++)
	{
		if(dp[n][i]<=total_capacity)
			ans=max(ans,i);
	}
	//for(int i=0;i<=n;i++)
	//{
	//	for(int j=0;j<=total_values;j++)
	//		cout<<dp[i][j]<<" ";
	//	cout<<endl;
	//}
	return ans;
}
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int n,w;
	cin>>n>>w;
	vector<ll>weights(n),values(n);
	for(int i=0;i<n;i++)
		cin>>weights[i]>>values[i];
	//for(int i=0;i<n;i++)
	//	cout<<weights[i]<<" "<<values[i]<<endl;

	cout<<bottom_up(weights,values,w);
	
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22)cout<<"bust"<<'\n';
  else cout<<"win"<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

vector<vector<int> > G;
bool used[200];
int match[200];
int N,M;

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||!used[w]&&dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  fill(begin(match),end(match),-1);
  for(int v=0;v<N+M;v++){
    if(match[v]<0){
      fill(begin(used),end(used),0);
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}

double sqr(double d){
  return d*d;
}

int main(){
  while(cin>>N>>M,N){
    int tx[100],ty[100],v[100];
    for(int i=0;i<N;i++){
      cin>>tx[i]>>ty[i]>>v[i];
    }
    int bx[100],by[100];
    for(int i=0;i<M;i++){
      cin>>bx[i]>>by[i];
    }
    double l=0,h=1e9;
    for(int i=0;i<99;i++){
      double m=(l+h)/2;
      G=vector<vector<int> >(N+M);
      for(int j=0;j<N;j++){
	for(int k=0;k<M;k++){
	  if(sqrt(sqr(tx[j]-bx[k])+sqr(ty[j]-by[k]))/v[j]<=m){
	    add_edge(j,k+N);
	  }
	}
      }
      if(bipartite_matching()>=M){
	h=m;
      }else{
	l=m;
      }
    }
    cout.precision(10);
    cout<<fixed<<h<<endl;
  }
}

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

const int N = 1e5+10;
vector<int> adj[N];
int waysSub[N], ways[N];
int n, mod;

void dfs(int node, int par) {
    for(int i = 0; i < (int)adj[node].size(); ++i) {
        if(adj[node][i] == par) {
            adj[node].erase(adj[node].begin()+i);
            break;
        }
    }
    waysSub[node] = 1;
    for(int to : adj[node]) {
        dfs(to, node);
        waysSub[node] *= waysSub[to]+1;
        waysSub[node] %= mod;
    }
}

void dfs2(int node, int currWays) {
    ways[node] = currWays*(waysSub[node])%mod;
    vector<int> prefix(adj[node].size());
    vector<int> suffix(adj[node].size());
    int prod = 1;
    for(int i = 0; i < (int)adj[node].size(); ++i) {
        const int to = adj[node][i];
        prod *= waysSub[to]+1;
        prod %= mod;
        prefix[i] = prod;
    }
    prod = 1;
    for(int i = (int)adj[node].size()-1; i >= 0; --i) {
        const int to = adj[node][i];
        prod *= waysSub[to]+1;
        prod %= mod;
        suffix[i] = prod;
    }
    for(int i = 0; i < (int)adj[node].size(); ++i) {
        const int to = adj[node][i];
        int currVal = 1;
        if(i) {
            currVal *= prefix[i-1];
            currVal %= mod;
        }
        if(i+1 < (int)adj[node].size()) {
            currVal *= suffix[i+1];
            currVal %= mod;
        }
        dfs2(to, (currWays*currVal+1)%mod);
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> mod;
    for(int i = 0; i < n-1; ++i) {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,1);
    dfs2(1,1);
    for(int i = 1; i <= n; ++i) {
        cout << ways[i] << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 17408
#include<cstdio>

int main()
{
  int a[4],i=0,count=0,ii=0;

  scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]);


  for(ii=0; ii<4; ii++)
    {

  
  for(i=0; i<4; i++)

    {
      if(a[ii]==a[i])
	{

	  if(ii==i)
	    {
	      continue;
	    }
	  count++; 
	}


    }

    }

if(count==4)
  {
  printf("yes\n");
  }

if(count!=4) printf("no\n");

 
}



Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;
void solve(){
  int n, cnt = 0; cin >> n;
  string s; cin >> s;
  vector<char> v(n);
  for(int i = 0; i < n; i++){
    v[i] = s[i];
  }
  for(int i = 0; i < n; i++){
    if(s[i] == '(') cnt++;
    else{
      if(cnt > 0) cnt--;
      else v.insert(v.begin(), '(');
    }
  }
  for(int i = 0; i < cnt; i++){
    v.push_back(')');
  }
  for(int i = 0; i < v.size(); i++){
    cout << v[i];
  }
  cout << endl;
  return;
}

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


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



int main() {
	char x;
	string a, b;
	cin >> a >> b;
	x = b[0];
	b[0] = b[2];
	b[2] = x;
	if (a == b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

ll gcm(ll a,ll b);

int main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  ll ansgcm = A[0];
  ll ans = 1;
  rep1(i,n) ansgcm = gcm(ansgcm,A[i]);
  rep(i,n) ans *= A[i]/ansgcm;
  ans *= ansgcm;
  int ansans = 0;
  rep(i,n) ansans += A[i]-1;
  cout << ansans << endl;
}

ll gcm(ll a,ll b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcm(a%b,b);
}

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    ll x; cin >> x;
    ll s = 100ll;
    int ans = 0;
    while (s<x) {
        ans++;
        s *= 1.01;
        // cout << s << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main(){
  long int sum=0,d,n;
  scanf("%ld",&n);
  sum=n*(n+1)/2;
  d=n/3;
  sum=sum-(d*(d+1)*3/2);
  d=n/5;
  sum=sum-(d*(d+1)*5/2);
  d=n/15;
  sum=sum+(d*(d+1)*15/2);
  printf("%.0ld",sum);
  return 0;
}

Measured memory_bytes: 1732
package main

import (
	"fmt"
	"os"
)

func main() {
	var (
		n, y int
	)

	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n - i; j++ {
			if 10000 * i + 5000 * j + 1000 * (n - i - j) == y {
				fmt.Println(i, j, n - i - j)
				os.Exit(0)
			}
		}
	}

	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a<=b) {
			System.out.println(a);
		}
		else {
			System.out.println(a-1);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

int main() {
  int n,m;
  cin >> n >> m;
  rep(i,max(m,n)) cout << min(n,m);
  cout << endl;
  return 0;
}


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

int main() {
	
	long long int max=0, max2=0, n,a;
	vector<long int> v={};
	
	cin>>n;
	
	for (int i=0;i<n;i++)
	{
		cin>>a;
		
		if (a>max)
		{
			max2=max;
			max=a;
		}
		else if (a> max2)
		max2=a;
		
		v.push_back(a);
		
	}
	
	for (int i=0;i<n;i++)
	{
		if (v[i]!=max)
		cout<<max<<endl;
		else
		cout<<max2<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3312
import collections,sys,string
n = int(sys.stdin.readline())
a = [collections.defaultdict(int) for _ in range(n)]
for i in range(n):
	ai = a[i]
	s = input()
	for c in s:
		ai[c] += 1
r = ''
for c in string.ascii_lowercase:
	cc = min(t[c] for t in a)
	r += c * cc
print(r)

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

using namespace std;

#define inf (ll)1e15
#define ll long long
#define all(x) x.begin(), x.end()
#define x first
#define y second

const int N = 100010;

int rem[N];
deque<int> dq;

int main(){

    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int k;
    cin >> k;

    memset(rem, 0x7f, sizeof rem);

    rem[0] = k;
    rem[1] = 1;
    
    dq.push_back(1);

    while(dq.size()){

    	int x = dq.front(); dq.pop_front(); //lowest / best choice

    	if(rem[x] < rem[(x * 10) % k]){ // multiply by 10 (cost = 0);
    		rem[(x * 10) % k] = rem[x];
    		dq.push_front((x * 10) % k);
    	}

    	if(rem[x] + 1 < rem[(x + 1) % k]){ // add one (cost = 1);
    		rem[(x + 1) % k] = rem[x] + 1;
    		dq.push_back((x + 1) % k);
    	}
    }

    cout << rem[0] << endl;

    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] >= k) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
//using System;
//class p0003
//{
//    static void Main(string[] args)
//    {
//        int cnt = int.Parse(Console.ReadLine());
//        while (0 < cnt--)
//        {
//            var ary = Console.ReadLine().Split(' ');
//            Array.Sort(ary);
//            var x = (int)Math.Pow(double.Parse(ary[0]), 2);
//            var y = (int)Math.Pow(double.Parse(ary[1]), 2);
//            var z = (int)Math.Pow(double.Parse(ary[2]), 2);
//            Console.WriteLine((x + y == z) ? "YES" : "NO");
//        }
//    }
//}


using System;
 
class p0003{
     
    static void Main(string[] args){
        int n;
        string str;
        string[] s;
        int[] a = new int[3];

        while ((str = Console.ReadLine()) != null)
        {
            n = int.Parse(str);

            while (0 < n--)
            {
                s = (Console.ReadLine()).Split(' ');
                for (int i = 0; i < 3; ++i)
                {
                    a[i] = int.Parse(s[i]);
                    a[i] = a[i] * a[i];
                }
                Console.WriteLine("{0}", ((a[0] == a[1] + a[2] || a[1] == a[0] + a[2] || a[2] == a[0] + a[1]) ? "YES" : "NO"));
            }
        }
    }
     
}

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

int main() {
   int A, B, C, D, i = 0, j = 0;
   cin >> A >> B >> C >>D;
   while(C > 0){
    C = C - B;
    i++;}
   while(A > 0){
    A = A - D;
    j++;}
    if(i <= j){
    cout << "Yes" <<endl;
    }
  else{
    cout << "No" <<endl;
    }
   return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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

























int main() {
	ll n;
	cin >> n;
	ll ans = n * (n + 1) * (n + 2) / 6;
	REP(i, n - 1) {
		ll u, v;
		cin >> u >> v;
		ans -= min(u, v) * (n + 1 - max(u, v));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
import sys
I = sys.stdin.readline
N, M = map(int, I().split())
X = list(map(int, I().split()))
G = [set() for _ in range(N)]
for i in range(M):
    u, v = sorted(map(int, I().split()),key=lambda x:[X[x-1],-x])
    G[v-1].add((u-1,i))
X,d,C = sorted([(x,i) for i, x in enumerate(X)]),[0]*M,[0]*N
for x, u in X:
    if C[u]:continue
    if not G[u]:break
    C[u],S=-1 if sum(C[c]+1 for c, _ in G[u])else 1,[u]
    while S:
        q = S.pop()
        for c, i in G[q]:
            d[i]=str(x)
            if C[c]:continue
            S+=[c]
            C[c]=-C[q]
print("".join(" BW"[i] for i in C)+"\n"+"\n".join(d) if C[u]else -1)

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<typename U, typename V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const int MOD = 1e9 + 7;

int main() {
    FAST_IO();    
    int N; cin >> N;
    string S1, S2; cin >> S1 >> S2;
    vector<int> shape;
    vector<vector<int>> adj(N);
    for(int i = 0; i < N;) {
        if(S1[i] == S2[i]) {
            shape.push_back(1);    
            i += 1;
        } else {
            shape.push_back(2);
            i += 2;
        }
    }
    ll ans;
    if(shape[0] == 1) ans = 3;
    else ans = 6;
    repp(i, 1, sz(shape)-1) {
        if(shape[i] == 1 && shape[i-1] == 1) {
            ans = (ans * 2) % MOD;
        } else if(shape[i] == 1 && shape[i-1] == 2) {
            ans = (ans * 1) % MOD;
        } else if(shape[i] == 2 && shape[i-1] == 1) {
            ans = (ans * 2) % MOD;
        } else if(shape[i] == 2 && shape[i-1] == 2) {
            ans = (ans * 3) % MOD;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,S[1000];
void push(int x)
{
    S[++top]=x;
}
int pop()
{
    top--;
    return S[top+1];
}
int main()
{
    int a,b;
    top = 0;
    char s[100];
    while (scanf("%s",s)!=EOF)
    {
        if(s[0]=='+')
        {
            a= pop();
            b = pop();
            push(a+b);
        }
        else if(s[0]=='-')
        {
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(s[0]=='*')
        {
            a = pop();
            b = pop();
            push(a*b);
        } else{
            push(atoi(s));
        }

    }
    printf("%d\n",pop());
    return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int n;

void dfs(string s, char mx)
{
  if (s.length() == n)
  {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= mx + 1; c++)
  {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main()
{
  cin >> n;
  dfs("", 'a' - 1);
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
signed main(void){
    int x,y;cin>>x>>y;
    int sum=0;
    if(x==1)sum+=300000;
    if(x==2)sum+=200000;
    if(x==3)sum+=100000;
    if(y==1)sum+=300000;
    if(y==2)sum+=200000;
    if(y==3)sum+=100000;
    if(x==1&&y==1)sum+=400000;
    cout<<sum<<endl;
}
        

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};

bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    string S;
    cin>>S;
    string ans="No";

    if((S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2])||(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1])||(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1])){
        ans="Yes";
    }
    
    

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define MAX 100000
 
int A[MAX], n;
 
int partition(int p,int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}
 
int main() {
    int i, q;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++)scanf("%d", &A[i]);
 
    q = partition(0, n - 1);
 
    for (i = 0; i < n; i++) {
        if (i)printf(" ");
        if (i == q)printf("[");
        printf("%d", A[i]);
        if (i == q)printf("]");
    }
    printf("\n");
 
    return 0;
}

Measured memory_bytes: 2160
n,k = map(int,input().split())
A = []
for _ in range(n):
    A.append(list(map(int,input().split())))
A.sort(key=lambda x: x[0])
cnt = 0
while k>0:
    k-=A[cnt][1]
    cnt+=1
print(A[cnt-1][0])


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

int main() {
   int A , B , C , D ;
  cin >> A >> B >> C >> D ;
  if((B+C-1)/B <= (A+D-1)/D ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}




Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int a, b, c, k;

int main() {
  cin >> a >> b >> c >> k;
  for (int i = 0; i < k; i++) {
    if (a >= b) {
      b *= 2;
    } else if (b >= c) {
      c *= 2;
    }
  }
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    LL cnt[10][10] = {{0}};
    REP(i,n){
        LL x = i + 1;
        LL right = x%10;
        LL y = x;
        UNTIL(y < 10){
            y/=10;
        }
        LL left = y;

        cnt[left][right]++;
    }

    LL ans = 0;
    REP(i,n){
        LL x = i + 1;
        LL right = x%10;
        LL y = x;
        UNTIL(y < 10){
            y/=10;
        }
        LL left = y;

        ans += cnt[right][left];
    }
    PUTS(ans);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int[] input = new int[10];
		Scanner s = new Scanner(System.in);
		for(int i=0; i<10; i++){
			//System.out.println("Please input the "+ (i+1) +"th number(integer)");
			input[i]=s.nextInt();
		}
		
		Arrays.sort(input);
		int i=input.length-1;
		while(i>input.length-4){
			System.out.println(input[i]);
			i--;
		}			
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
using namespace std;
main(){
 	int u,v;
  cin>>u>>v;
  int ans=max(0,3-u+1)*100000+max(0,3-v+1)*100000;
  if(u==1&&v==1) ans=ans+400000;
  cout<<ans;
}

Measured memory_bytes: 256
<?php
while(true){
    $text = trim(fgets(STDIN));
    if($text == "-"){ break; }
    $kaisuu = trim(fgets(STDIN));

    for($i = 0; $i < $kaisuu; $i++){
        $syaffuru = trim(fgets(STDIN));
        $a = substr($text, 0, $syaffuru);
        $b = substr($text, $syaffuru);      
        $text = $b.$a;
    }
    echo $text.PHP_EOL;
}

Measured memory_bytes: 15108
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)

	if x+r <= w && y+r <= h && x >= 0 && y >= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (max(a+b, max(a-b, a*b)))<< endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
 
int main()
{
  string n;
  cin >> n;
  if(n[2] == n[3] && n[4] == n[5])
  {
   cout << "Yes" << endl; 
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ret += a[i] * a[j];
        }
    }
    cout << ret << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int x[100];
    cin >> n;
    for(int i=0;i<n;i++)scanf("%d",&x[i]);
    int mi = 1000000;
    for(int i=1;i<=100;i++){
        int sum = 0;
        for(int j=0;j<n;j++){
            sum += pow(x[j]-i,2);
        }
        mi = min(mi,sum);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;


int main() {

  int x; cin >> x;
  for(int i=1; i<=x; i++){
    if( i * (i+1) / 2 >= x ){
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

//　セグメント木
const inf = 1100100100

type segtree struct {
	n int
	v []int
	a []int // 加算値
}

func (s *segtree) init(n int) {
	N := 1
	for n > N {
		N *= 2
	}
	s.v = make([]int, N*2)
	s.a = make([]int, N*2)
	s.n = N
}

func (s *segtree) update() {
	K := s.n
	for K > 0 {
		K /= 2
		for i := K; i < 2*K; i++ {
			s.v[i] = s.compare(s.v[i*2], s.v[i*2+1])
		}
	}
}

func (s *segtree) lazyCalc(k int) {
	s.v[k] += s.a[k]
	if k < s.n {
		s.a[2*k] += s.a[k]
		s.a[2*k+1] += s.a[k]
	}
	s.a[k] = 0
}

func (s *segtree) compare(p, q int) int {
	if p > q {
		return q
	}
	return p
}

func (s *segtree) setSub(a, b, k, l, r, x int) {
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		s.a[k] += x
		s.lazyCalc(k)
	} else {
		s.lazyCalc(k)
		s.setSub(a, b, k*2, l, (l+r)/2, x)
		s.setSub(a, b, k*2+1, (l+r)/2, r, x)
		s.v[k] = s.compare(s.v[2*k], s.v[2*k+1])
	}
}

// set v[k] = val
func (s *segtree) set(a, b, x int) {
	s.setSub(a, b, 1, 0, s.n, x)
}

// querySub
func (s *segtree) querySub(a, b, k, l, r int) int {
	s.lazyCalc(k)
	if b <= l || r <= a {
		return inf
	}
	if a <= l && r <= b {
		return s.v[k] + s.a[k]
	}
	return s.compare(
		s.querySub(a, b, k*2, l, (l+r)/2),
		s.querySub(a, b, k*2+1, (l+r)/2, r))
}

// query([a,b) )
func (s *segtree) query(a, b int) int {
	return s.querySub(a, b, 1, 0, s.n)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, Q := getInt(), getInt()
	var w, h segtree
	w.init(N + 1)
	h.init(N + 1)
	w.set(0, N+1, N-2)
	h.set(0, N+1, N-2)
	W := N
	H := N
	tot := (N - 2) * (N - 2)
	for i := 0; i < Q; i++ {
		op, x := getInt(), getInt()
		if op == 1 {
			tot -= w.query(x, x+1)
			if x < W {
				W = x
				v := h.query(0, 1)
				h.set(0, H+1, -v+x-2)
				// for j := 2; j < N; j++ {
				// 	fmt.Print(h.query(j, j+1), " ")
				// }
				// out(":", v, W, x)
			}
		} else {
			tot -= h.query(x, x+1)
			if x < H {
				H = x
				v := w.query(0, 1)
				w.set(0, W+1, -v+x-2)
			}
		}
	}
	out(tot)
}


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

namespace ConsoleApp111 {
    class Program {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            List<int> inputInt = StringSplit(input);

            int count = inputInt[1] / inputInt[0];

            if(count >= inputInt[2])
            {
                Console.WriteLine(inputInt[2]);
            }
            else
            {
                Console.WriteLine(count);
            }
        }

        static List<int> StringSplit(string input)
        {
            string[] inputStr = input.Split(' ');
            int[] inputInt = new int[input.Length];
            List<int> inputList = new List<int>();

            foreach(string n in inputStr)
            {
                inputList.Add(int.Parse(n));
            }

            return inputList;
        }
        
    }
}

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

int main(){
int N,X,M,min_M,sum;
  cin >> N >> X;
  min_M=100001;
  M=0;
  sum=0;
  
  for(int i =0;i<N;i++){
  cin >>M;
  min_M=min(min_M,M);
  sum+=M; 
  }
  cout <<(X-sum)/min_M+N <<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    if(a <= k){
        k -= a;
        a = 0;
    }else{
        a -= k;
        k = 0;
    }

    if(b <= k){
        b = 0;
    }else{
        b -= k;
    }

    cout << a << ' ' << b << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<int> a(n); rep(i, n){ cin >>a[i]; a[i]--; }
  int res = 0;
  rep(i, n) if (a[a[i]] == i) res++;
  res /= 2;
  cout <<res <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	for (int i = 0; i < str.size(); i++)
	{
		switch (str[i])
		{
		case '1':
			cout << 9;
			break;
		case '9':
			cout << 1;
			break;
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
use std::cmp;

const N: usize = 4000;
const M: usize = 2 * N + 1;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let a = sc.chars();
    let b = sc.chars();
    let c = sc.chars();

    let ab = cross(&a, &b);
    let bc = cross(&b, &c);
    let ac = cross(&a, &c);

    let mut ans = a.len() + b.len() + c.len();
    let a_pos = N;
    for b_pos in 0..M {
        if !ab[b_pos] {
            continue;
        }
        for c_pos in 0..M {
            if !ac[c_pos] {
                continue;
            }

            let head = vec![a_pos, b_pos, c_pos].into_iter().min().unwrap();
            let tail = vec![a_pos + a.len(), b_pos + b.len(), c_pos + c.len()]
                .into_iter()
                .max()
                .unwrap();
            if b_pos >= N {
                if c_pos < b_pos - N || bc[c_pos - (b_pos - N)] {
                    ans = cmp::min(ans, tail - head);
                }
            } else {
                if c_pos + N - b_pos >= M || bc[c_pos + N - b_pos] {
                    ans = cmp::min(ans, tail - head);
                }
            }
        }
    }

    println!("{}", ans);
}

fn cross(a: &Vec<char>, b: &Vec<char>) -> [bool; M] {
    let mut ab = [true; M];
    let a_pos = N;
    for b_pos in 0..(M - b.len()) {
        let mut s = ['?'; M];
        for (i, &a) in a.iter().enumerate() {
            s[i + a_pos] = a;
        }

        let mut ok = true;
        for (i, &b) in b.iter().enumerate() {
            if s[i + b_pos] != '?' && s[i + b_pos] != b && b != '?' {
                ok = false;
                break;
            }
        }
        ab[b_pos] = ok;
    }
    ab
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
fun main (args : Array<String>) {
	readLine()
	val (t, a) = readLine()!!.split(" ")
	val T : Int = t.toInt()
	var A : Int = a.toInt()
	val l = readLine()!!.split(" ")
	val list : MutableList<Int> = mutableListOf()
	var calc1 : Double
	var calc2 : Double
	var calc3 : Double = 0.0
	var result : Int = 0
	for (i in 0..l.size - 1) {
		list.add(l[i].toInt())
	}
	for (i in 0..list.size - 1) {
		calc1 = T - (list[i] * 0.006)
		if (A >= calc1) {
			calc2 = A - calc1
		} else {
			calc2 = calc1 - A
		}
		if (i == 0) calc3 = calc2
		if (calc3 >= calc2) {
			result = i + 1
			calc3 = calc2
		}
	}
	println("${result}")
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  double s=0;
  rep(i,n){
    double c;cin >> c;
    s+=1/c;
  }

  printf("%6f\n",1/s);


}


Measured memory_bytes: 256
N = int(input())

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

is_rising = False
money = 1000
stock = 0

for i in range(N - 1):
    if i == 0:
        if A_li[0] < A_li[1]:
            # できるだけ買う
            stock = money // A_li[0]
            money -= A_li[0] * stock
            is_rising = True
    else:
        if is_rising:
            if A_li[i] > A_li[i + 1]:
                # 全て売る
                money += A_li[i] * stock
                stock = 0
                is_rising = False
        else:
            if A_li[i] < A_li[i + 1]:
                # できるだけ買う
                stock = money // A_li[i]
                money -= A_li[i] * stock
                is_rising = True
    if i + 1 == N - 1:
        # 全て売って終了
        money += A_li[i+1] * stock
        stock = 0

print(money)


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  int anko = max({a,b,c});
  int maojini = min({a,b,c});
  
  cout << anko - maojini << endl; 
  
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func nextInt(sc *bufio.Scanner) (n int, err error) {
	sc.Scan()
	s := sc.Text()
	n, err = strconv.Atoi(s)
	return
}

func readIntNums(sc *bufio.Scanner, n int) ([]int, error) {
	nums := make([]int, n)
	for i, _ := range nums {
		if a, err := nextInt(sc); err == nil {
			nums[i] = a
		} else {
			return nums, err
		}
	}
	return nums, nil
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		s := sc.Text()
		arr := strings.Split(s, " ")
		x, _ := strconv.Atoi(arr[0])
		y, _ := strconv.Atoi(arr[1])
		if x == 0 && y == 0 {
			break
		}
		if x > y {
			x, y = y, x
		}
		fmt.Println(x, y)
	}
}



Measured memory_bytes: 1208
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss, ts; scan(ss, ts);
      for(Int i = (Int)ss.size()-(Int)ts.size(); i >= 0; --i) {
         bool flag = true;
         for(Int k = 0; k < (Int)ts.size(); ++k) {
            if( not ( ss[i+k] == '?' or ss[i+k] == ts[k] ) ) {
               flag = false;
            }
         }
         if( flag ) {
            for(Int k = 0; k < (Int)ts.size(); ++k) {
               ss[i+k] = ts[k];
            }
            for(char& c : ss) {
               if( c == '?' ) c = 'a';
            }
            printf("%s\n", ss.c_str());
            return;
         }
      }
      puts("UNRESTORABLE");
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
using namespace std;

void solve(int test){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = a * c;
	ll cnt = a * d;
	ans = max(ans, cnt);
	cnt = b * d;
	ans = max(ans, cnt);
	cnt = b * c;
	ans = max(ans, cnt);
	if ((a<=0 and b>=0) or (c<=0 and d>=0))
	{
		ans = max(ans, 0LL);
	}
	cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1,k;
	//cin>>t;
	k = t;
	while(t--){
		solve(k - t);
	}
	cerr<<"Timpe elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " mps\n" ;
	return 0;
}

Measured memory_bytes: 3800