akhauriyash/Code-Regression huggingface dataset:
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n;cin>>n;
  int t,a;cin>>t>>a;
  int h[n];
  int res = 0;
  rep(i, n){
    cin>>h[i];
  }
  double m = 1000000;
  rep(i, n){
    double tmp = abs(a - (t - (h[i] * 0.006)));
    dump(tmp);
    if (tmp < m){
      m = tmp;
      res = i;
    }
  }
  dump_1d(h, n);

  cout << res+1 << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

vector<int> t;

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

  ll n,c,k;
  
  cin >> n >> c >> k;
  REP(i,n) {
    int x; cin >> x;
    t.push_back(x);
  }
  sort(t.begin(), t.end());
  ll ride_time = t[0]+k, lim = c-1, ans = 1;
  FOR(i,1,n){
    //乗れる
    if(t[i] <= ride_time && lim > 0){      
      lim--;
    }
    //次のバスがほしい
    else if(lim <= 0 || t[i] > ride_time){
      ans++;
      lim = c-1;
      ride_time = t[i]+k;
    }
    //cout << "r_t:" << ride_time << " lim: " << lim << " i: " << i << " ans: " << ans << endl;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 892
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"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 getString() string {
	sc.Scan()
	return sc.Text()
}

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

// Item :
type Item struct {
	priority, value, index int
}

// PQ :
type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// Push :
func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

// Pop :
func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

// Edge :
type Edge struct {
	to, cost int
}

// Path :
type Path struct {
	edges []Edge
}

// Route :
type Route struct {
	path []int
}

// Dijkstra :
func Dijkstra(N, S int, path [][]int) ([]int, []Route) {
	pq := make(PQ, 0)
	heap.Init(&pq)
	d := make([]int, N+1)
	r := make([]Route, N+1)
	// init
	for i := 0; i <= N; i++ {
		d[i] = math.MaxInt32
	}
	d[S] = 0
	r[S].path = []int{S}
	heap.Push(&pq, &Item{0, S, 0})
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		v := item.value
		if d[v] < item.priority {
			continue
		}
		for i, c := range path[v] {
			e := Edge{i, c}
			if d[e.to] > d[v]+e.cost {
				d[e.to] = d[v] + e.cost
				r[e.to].path = append(r[v].path, e.to)
				heap.Push(&pq, &Item{d[e.to], e.to, 0})
			}
		}
	}
	return d, r

}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	b := make([][]int, N)
	n := make([][]int, N)
	for i := 0; i < N; i++ {
		b[i] = make([]int, N)
		n[i] = make([]int, N)
		for j := 0; j < N; j++ {
			b[i][j] = getInt()
			n[i][j] = b[i][j]
		}
	}

	ans := 0
LOOP:
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if b[i][j] > b[i][k]+b[k][j] {
					b[i][j] = b[i][k] + b[k][j]
					ans = -1
					break LOOP
				} else if b[i][j] == b[i][k]+b[k][j] {
					// 経由しても距離が同じなら、ルートを消去
					if i != k && j != k {
						n[i][j] = -1
					}
				}
			}
		}
	}

	if ans == 0 {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if n[i][j] != -1 {
					ans += n[i][j]
				}
			}
		}
		out(ans / 2)
	} else {
		out(-1)
	}
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <math.h>

int main()
{
	double a, b, c, s, l, h, w;
	scanf("%lf %lf %lf", &a, &b, &c);

	w = b * cos(M_PI * c / 180.0);
	h = b * sin(M_PI * c / 180.0);
	s = a * h / 2.0;
	l = a + b + sqrt(h * h + (a - w) * (a - w));

	printf("%.8f %.8f %.8f\n", s, l, h);
	return 0;
}


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


vector<int> P, Q;

void read() {
    P.clear();
    Q.clear();
    
    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        P.push_back(v);
    }

    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        Q.push_back(v);
    }
}


int getVal(vector<int> &vList) {
    vector<int> order;
    for (int i = 1; i <= vList.size(); ++i) order.push_back(i);

    int idx = 0;
    
    do {
        ++idx;
        if (order == vList) {
            return idx;
        }
    } while(next_permutation(order.begin(), order.end()));
    
    return -1;
}


void work() {
    cout << abs(getVal(P) - getVal(Q)) << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
/**
 * @author karayuu
 */
fun main(args: Array<String>) {
    val (a, op, b) = readLine()!!.split(" ").map { it }
    val _a = a.toInt()
    val _b = b.toInt()

    if (op == "+") {
        println(_a + _b)
    } else {
        println(_a - _b)
    }
}

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

using namespace std;

int arr[105];
int n;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++) arr[i]=1e9;
	for(int i=0;i<n-1;i++)
	{
		int x;
		cin >> x;
		arr[i]=min(arr[i],x);
		arr[i+1]=min(arr[i+1],x);
	}
	int ans=0;
	for(int i=0;i<n;i++) ans+=arr[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool flag=true;
  for(int i=1;i<10;i++){
    if(N/i<10&&N%i==0){
      flag=false;
    }
    else{
    }
  }
  if(flag){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 998244353;
                int arr[MAX];
            //Global Variables



                int main()
                {
                        ll l ,r,x ;
                        scanf("%lld%lld%lld",&l,&r,&x);
                        //cout<<(r/x)<<endl;
                        ll ans = (r/x)-(l/x);
                        if(l%x==0)ans++;
                        printf("%lld\n",ans);
                }


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> A;
    int64_t max = 0;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
        max = std::max(max, t);
    }

    int64_t gcd = A[0];
    for (size_t i = 1; i < N; ++i) {
        gcd = boost::math::gcd(gcd, A[i]);
    }

    if (max >= K && K % gcd == 0) {
        std::cout << "POSSIBLE" << std::endl;
    }
    else {
        std::cout << "IMPOSSIBLE" << std::endl;
    }

    return 0;
}


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

int main(){
  int n;
  int mat[10][10];

  int c = 0;
  for(;;){
    scanf("%d",&n);
    if(!n)break;
    
    printf("Case %d:\n",++c);

    int num = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<=i;j++){
	num++;
	if(i&1)mat[j][i-j] = num;
	else mat[i-j][j] = num;
      }
    }

    for(int i=n-1;i>=0;i--){
      for(int j=0;j<i;j++){
	num++;
	if(i&1)mat[n-1-j][n-i+j] = num;
	else mat[n-i+j][n-1-j] = num;
      }
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)printf("%3d",mat[i][j]);
      putchar('\n');
    }

  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cpresent(container, element) (find(all(container),element) != container.end())
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
#define mod (1000000000 + 7)
#define inf (1e18+5)
#define fi first
#define se second
#define MAXN   1000001 
typedef long long ll;
using namespace std;
int main()
{
	ss
	int n,t,W;
	cin>>n>>W;
	vector<ll> dp(n*1000+5,inf);
	vector<ll> v(n),w(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=sum-v[i];j>=0;j--){
			dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=sum;i++){
		if(dp[i]<=W){
			ans=max(ans,i);
		}
	}
	cout<<ans<<endl;
	
	


  

    

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	bool time[30][65] = {false};
	int n;
	int ct = 0;
	
	for (int j = 0; j < 2; j++){
		cin >> n;
		for (int i = 0; i < n; i++){
			int h, m;
			ct++;
			cin >> h >> m;
			if (time[h][m])  ct--;
			time[h][m] = true;
		}
	} 
	
	for (int i = 0; i <= 24; i++){
		for (int j = 0; j <= 60; j++){
			if (time[i][j] && ct > 1){
				printf("%d:%02d ", i, j);
				ct--;
			}
			else if (time[i][j] && ct == 1){
				printf("%d:%02d\n", i, j);
			}
		}
	}
	return (0);
}

Measured memory_bytes: 1164
// Problem : A - Duplex Printing
// Contest : AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

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

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define endl "\n"
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;

int a[3][3];
bool vis[3][3];

void yes() {	
	cout << "Yes";
	exit(0);
}

int32_t main()
{
	memset(vis, false, sizeof(vis));
	IOS;
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			cin >> a[i][j];
	int n; cin >> n;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		for(int i = 0; i < 3; i++)
			for(int j = 0; j < 3; j++) {
				if(a[i][j] == x)
					vis[i][j] = true;
			}
	}
	for(int i = 0; i < 3; i++) {
		bool flag = true;
		for(int j = 0; j < 3; j++) {
			flag &= vis[i][j];	
		}
		if(flag)yes();
	}
	for(int i = 0; i < 3; i++) {
		bool flag = true;
		for(int j = 0; j < 3; j++) {
			flag &= vis[j][i];
		}
		if(flag)yes();
	}
	if(vis[0][0] and vis[1][1] and vis[2][2])yes();
	if(vis[2][0] and vis[1][1] and vis[0][2])yes();
	
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int note[15],a[15],x[15][14][2],n,ma=0,c=0;
int cheak(int m){
    int ans=0;
    if(m==n){
        for(int i=0;i<n;i++){
            if(note[i]==1){
                for(int j=0;j<a[i];j++){
                    if(note[x[i][j][0]-1]!=x[i][j][1]){
                        // rep(j,n)cout<<note[j]<<' ';
                        // cout<<endl;
                        goto res;
                    }
                }
            }
            // cout<<ans<<endl;
            // if(ans==3){rep(j,n)cout<<note[j]<<' ';
            // cout<<endl;}
            
        }
            rep(i,n)if(note[i]==1)ans++;
            ma=max(ma,ans);
            ans=0;
    res:
    // rep(j,n)cout<<note[j]<<' ';
    //         cout<<endl;
    return 0;
    }
    else{
        note[m]=0;
        cheak(m+1);
        note[m]=1;
        cheak(m+1);
        return 0;
    }
}
int main(void){
    // Your code here!
    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j][0]>>x[i][j][1];
        }
    }
    cheak(0);
    cout<<ma<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;const int N=2e5+7;
int dp[N],n,i,j,ans,a[N];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(cin>>n,i=1;i<=n;++i){
		cin>>a[i];
		dp[a[i]]=dp[a[i]-1]+1;
		ans=max(ans,dp[a[i]]);
	}
	cout<<(n-ans)<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,m=10000000000,M=-10000000000,r;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> r;
      M=max(M,r-m);
      m=min(m,r);
  }
  cout << M << endl;
}


Measured memory_bytes: 3112
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord

main = C.interact $ put . sol . get

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines

put = C.pack . unlines

sol [[n,a,b],vs] = [show ave,show cnt]
  where
  as = take a $ sortBy (flip compare) vs
  v = last as
  x = length $ filter (==v) as
  y = length $ filter (==v) vs
  ave = fromIntegral (sum as)/fromIntegral a
  cnt = if x==a
    then sum $ binom y <$> [x..min y b]
    else binom y x

binom n k = foldl' (\a i->div (a*(n-i+1)) i) 1 [1..k]

Measured memory_bytes: 508
#include <stdio.h>
const int N = 15;
int main(){
	int a[N] = {0};
	
	for(int i = 0; i < 10; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < 10; i++)
	{
		for(int j = i; j< 10; j++)
		{
			if(a[i] < a[j])
			{
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp; 
			}
		}
	}
	for(int i = 0; i < 3; i++)
	{
		printf("%d\n", a[i]);
	}
	
	
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int X=2e5+9;
const ll inf=(1ll<<60);
const ll mod=1e9+7;
char a,b;
int main(){
    scanf("%c %c",&a,&b);
    if(a=='H'){
        if(b=='H'){
            puts("H");
            return 0;
        }
        puts("D");
        return 0;
    }
    if(b=='H'){
        puts("D");
        return 0;
    }
    puts("H");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	int A,B;
	cin >> A>>B;
	if ((A * B == 0) || (A >= 10 || B >= 10))
	{
		cout << -1 << endl;
	}
	else
	{
		cout << A * B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B, C, X, Y) = read!(i64, i64, i64, i64, i64);

    let mut cost = std::i64::MAX;
    for i in 0..max(X, Y) + 1 {
        let (x, y) = (max(X - i, 0), max(Y - i, 0));
        cost = min(cost, x * A + y * B + i * C * 2);
    }

    println!("{}", cost)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
ll ncd(ll n,ll d){
    ll x = 1,y=1;
    for(int i=0;i<d;i++){
        x = x*(n-i)%mod;
        y = y*(i+1)%mod;
    }
    return x*modpow(y,mod-2,mod)%mod;
}
int main() {    
    srand(time(NULL));
    for(int j=0;j<14;j++){
    for(int i=0;i<26;i++){
        cout<<i+1<<endl;
    }
    }
    for(int i=0;i<1;i++){

          cout<<rand()%26+1<<endl;  
    }
}
    



Measured memory_bytes: 3644
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	var T []rune = []rune(s)

	for i := 0; i < len(T); i++ {
		c := T[i]
		if c == '?' {
			T[i] = 'D'
		}
	}
	fmt.Println(string(T))
}


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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 1 + n * (n - 1) / 2;
    rep(i, 26) {
        ll cnt = 0;
        rep(j, n) if (s[j] == 'a' + i) cnt++;
        ans -= cnt * (cnt - 1) / 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3696
#include <iostream>

int main(){
    int k, s;
    std::cin >> k >> s;

    int val;
    int counter = 0;
    for(int x = 0; x <= k; ++x){
        for(int y = 0; y <= k; ++y){
            val = s - x - y;
            if(0 <= val && val <= k){
               ++counter;
            }
        }
    }

    std::cout << counter << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    rep(i,1,n+1){
        double r=i*1.08;
        int y=r;
        if(y==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 505
using namespace std;
typedef long long ll;
int sum=0;
int n,m,tot=1,s,t;
int a[maxn],b[maxn],iter[maxn];
ll dis[maxn][maxn];
int head[maxn*maxn],nex[maxn*maxn],to[maxn*maxn];
ll cap[maxn*maxn];
void add(int x,int y,long long z)
{
	to[++tot]=y; cap[tot]=z; nex[tot]=head[x]; head[x]=tot;
	to[++tot]=x; cap[tot]=0; nex[tot]=head[y]; head[y]=tot;
}
int q[maxn],level[maxn];
void bfs()
{
	for(int i=1;i<=t;i++)
		level[i]=0;

	int hd=0,tl=-1;
	q[++tl]=s; level[s]=1;

	while(hd<=tl)
	{
		int now=q[hd]; hd++;
		for(int i=head[now];i;i=nex[i])
		{
			if(cap[i]>0 && !level[to[i]])
			{
				level[to[i]]=level[now]+1;
				q[++tl]=to[i];
			}
		}
	}
}
ll dfs(int s1,int t1,ll flow)
{
	if(s1==t1)
		return flow;
	for(int &i=iter[s1];i;i=nex[i])
	{
		if(cap[i]>0 && level[to[i]]==level[s1]+1)
		{
			ll nex=min(flow,cap[i]);
			ll temp=dfs(to[i],t1,nex);
			if(temp>0)
			{
				cap[i]-=temp;
				cap[i^1]+=temp;
				return temp;
			}
		}
	}
}
ll dinic()
{
	ll flow=0;
	while(1)
	{
		bfs();
		if(!level[t]) return flow;
//		cerr<<level[t]<<endl;
		for(int i=1;i<=t;i++)
			iter[i]=head[i];
		int f;
		while((f=dfs(s,t,1234567890ll*100))>0)
			flow+=f;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);	
	s=n+1,t=n+2;

	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>0)
			add(s,i,a[i]),ans+=a[i];
		else
			add(i,t,-a[i]);
	}

	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			add(j,i,1234567890ll*100);

	printf("%lld\n",max(ans-dinic(),0ll));
}


Measured memory_bytes: 2304
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

Node *root,*NIL;

void insert(int);
void inorder(Node *);
void preorder(Node *);

int main() {

  int n,i,x;
  char com[7];

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(com[0] == 'i') {
      scanf("%d",&x);
      insert(x);
    } else if(com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;

}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL ) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if(z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


Measured memory_bytes: 25156
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL N, K;
	cin >> N >> K;
	LL now = 0;
	REP(i, N - 1) {
		now += now / (K - 1) + 1;
	}
	cout << now << endl;
}

Measured memory_bytes: 3112
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
string s,t;
int main(){
	cin>>s;
	t="keyence";
	if(s.substr(0,7)==t||s.substr(s.size()-7,7)==t)
	{
		cout<<"YES";
		return 0;
	}
	for(int i=1;i<=6;i++)
		if(s.substr(0,i)+s.substr(s.size()-7+i,7-i)==t)
		{
			cout<<"YES";
			return 0;
		}
	cout<<"NO";
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

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

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(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();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i,1,n+1){
    int x = i;
    int cnt = 0;
    while(x != 0) {cnt++, x/=10;}
    if((cnt&1) == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s_num = int(input())
S = list(map(int, input().split()))
t_num = int(input())
T = list(map(int, input().split()))

def linear_search(S, T):
    num = 0
    for target_num in T:
        for s_item in S:
            if target_num == s_item:
                num += 1
                break
    return num


print(linear_search(S, T))



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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  string s = stin();
  deque<char> que(ALL(s));
  int x_count = 0;
  while(que.size() > 1) {
    char front = que.front(), back = que.back();
    if(front == back) {
      que.pop_front();
      que.pop_back();
      continue;
    }
    if(front == 'x') {
      que.pop_front();
      ++x_count;
    } else if(back == 'x') {
      que.pop_back();
      ++x_count;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << x_count;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
    int price = 700;
    char str[4];
    
    scanf("%s", str);
    
    if(str[0] == 'o')
        price = price+100;
    if(str[1] == 'o')
        price = price+100;
    if(str[2] == 'o')
        price = price+100;
    
    printf("%d\n", price);
    
    return 0;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

int plustax(int p,int c){ // p : 消費税, c : 税抜価格
  return int(c * double(100 + p) / 100);
}

main()
{
  while(1){
    int x,y,s; cin >> x >> y >> s;

    if(x == 0ll) break;

    int ans = 0;
    FOR(i,1,s){ // 1つ目の商品の値段
      FOR(j,1,s){
	if(plustax(x,i) + plustax(x,j) == s)
	  ans = max(ans, plustax(y,i) + plustax(y,j));
      }
    }

    cout << ans << endl;
  }
}


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

int main()
{
    int num;
    cin >> num;
    vector<pair<int,int> > v;
    int current;
    for(int i=1;i<=num;i++){
        cin >> current;
        v.push_back(make_pair(current,i));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<num-1;i++){
        cout << v[i].second << " ";
    }
    cout << v[num-1].second << endl;
    return 0;
}

Measured memory_bytes: 1780
// SPDX-License-Identifier: X11
// 2020-08-15 (Live)

#include <stdio.h>

int main() {
  long long X,K,D;
  scanf("%lld %lld %lld", &X, &K, &D);

  if (X < 0)
    X = 0 - X;

  if (K <= X / D) {
    printf("%lld\n", X - K * D);
    return 0;
  }

  if (X % D > D / 2) {
    if ((X / D % 2 && !(K % 2)) || (!(X / D % 2) && K % 2)) {
      printf("%lld\n", 0 - (X % D - D));
      return 0;
    }
    else {
      printf("%lld\n", X % D);
      return 0;
    }
  }
  else {
    if ((X / D % 2 && K % 2) || (!(X / D % 2) && !(K % 2))) {
      printf("%lld\n", X % D);
      return 0;
    }
    else {
      printf("%lld\n", 0 - (X % D - D));
      return 0;
    }
  }
}


Measured memory_bytes: 1728
/*Bismillahir Rahmanir Raheem*/

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

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) scanf("%d", &x)
#define sfc(x) scanf("%c", &x)
#define sfl(x) scanf("%lld", &x)
#define sflu(x) scanf("%llu", &x)
#define sfii(x, y) scanf("%d %d", &x, &y)
#define sfll(x, y) scanf("%lld %lld", &x, &y)
#define sfiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES");
#define pfno pf("NO");
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)

//defined for loop

//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair

//code start

int main()
{
    // freopen("/root/Programming/input.txt", "r", stdin);
    // freopen("/root/Programming/output.txt", "w", stdout);
    ull n, a, b;
    sflu(n);
    sflu(a);
    sflu(b);
    ull ans=0, dv = 0;
    if (a or b)
        dv = (n / (a + b));
    ans = dv * a + min(n - (dv * (a + b)),a);
    if (!a)
        ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = min(A) + min(B)
for i in range(M):
  x, y, c = map(int, input().split())
  ans = min(ans, A[x-1] + B[y-1] - c)
print(ans)

Measured memory_bytes: 18612
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    char s[100];
    ll n,i;
    scanf("%s",s);
    n = strlen(s);
    for(i=0;i<n;i++){
        printf("x");
    }

    printf("\n");
    return 0;
}


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

int dp[10005][100][2];
string s;
int n, d;

int digitSum(int pos, int mo, bool tight) {
	if (pos == n) return !mo;
	int &ans = dp[pos][mo][tight];
	if (ans != -1) return ans;

	ans = 0;
	int lim = tight ? s[pos] - '0' : 9;
	for (int i = 0; i <= lim; i++) {
		ans += digitSum(pos + 1, (mo + i) % d, tight and (i == lim));
		ans %= mod;
	}

	return ans;
}

void solve() {
	cin >> s >> d;
	n = s.length();
	memset(dp, -1, sizeof(dp));
	cout << (digitSum(0, 0, 1) - 1 + mod) % mod << endl;
}
// Remember to clear the global containers

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 20096
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, ans;
int a[100005];
int flag;
int main()
{
	flag = 0;
	ans = 0;
	memset(a, 0, sizeof(a));
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int p = a[1];
	a[1] = 0;
	while(true)
	{
		int o = p;
		if(ans > 1000000 || a[o] == 0) {flag = 1; break;}
		if(p == 2) break;
		ans++;
		p = a[p];
		a[o] = 0;
	}
	if(flag == 1) printf("-1\n");
	else printf("%d\n", ans + 1);
	return 0;
}

Measured memory_bytes: 640
import Data.List
import Text.Printf
main = getLine >>= main' . map read . words
    where
        main' [_, a, b] = getLine >>= main'' a b . sortBy (flip compare) . map read . words
        main'' a b vs = printf "%.6f\n" ave >> print (solve a b v vs)
            where
                xs = take a vs
                (s, v) = foldl' (\(acc, _) x -> (acc + x, x)) (0, 0) xs
                ave = s / fromIntegral a

solve :: Int -> Int -> Double -> [Double] -> Int
solve a b v xxs@(x : _)
    | v == x = sum . take (min b cn - a + 1) . drop a $ pascal cn
    | otherwise = head . drop (a - an) $ pascal vn
    where
        cn = length $ takeWhile (v ==) xxs

        (as, bs) = span (v <) xxs
        an = length as
        vn = length $ takeWhile (v ==) bs

pascal :: Int -> [Int]
pascal n = build 0 [1]
    where
        build m xs
            | n == m = xs
            | otherwise = build (m + 1) $ nextPascal xs

nextPascal :: [Int] -> [Int]
nextPascal = next . (0 :)
    where
        next (x : y : zs) = (x + y) : next (y : zs)
        next xs = xs


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  long long n;
  cin>>n;
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  
  long long ans = 0;
  REP(i,60){
    long long cnt = 0;
    REP(j,n){
      if(a[j] & (1LL<<i)){
        cnt++;
      }
    }
    long long temp = (1LL<<i);
    temp = mod(temp);
    ans += mod(temp*mod(cnt))*mod(n-cnt);
    ans = mod(ans);
  }
  cout<<ans<<endl;
  return 0; 
}

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


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

    int co=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i))co++;
    }
    cout<<co<<endl;
}



Measured memory_bytes: 3840
//???????????????????????????????????°??????

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		
		//??????????????????????????????????????°??¨?????°?????\???
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String[] str = br.readLine().split(" ");
		int rowNum = Integer.parseInt(str[0]);
		int colNum = Integer.parseInt(str[1]);
		
		int[][] arrayA = new int[rowNum][colNum];			 //??????A?????????????´????????????????arrayA
		for(int i=0; i<rowNum; i++) {
			String[] arrayAStr = br.readLine().split(" ");
			for(int j=0; j<colNum; j++) {
				arrayA[i][j]=Integer.parseInt(arrayAStr[j]);
			}
		}
		
		int[] arrayB = new int[colNum];					//??????B?????????????´????????????????arrayB
		for(int i=0; i<colNum; i++) {
			arrayB[i] = Integer.parseInt(br.readLine());
		}
		
		for(int i=0; i<rowNum; i++) {
			int sum = 0;
			for(int j=0; j<colNum; j++) {
				sum = sum +arrayA[i][j]*arrayB[j];
			}
			//????????????
			System.out.println(sum);
		}

	}

}

Measured memory_bytes: 27464
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int n, t, avg, mintask = 10001,sum = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &t); sum += t;
        avg = sum / i;
        mintask = min(mintask, avg);
    }
    printf("%d\n", mintask);
    return 0;
}


Measured memory_bytes: 2732
H, W = map(int, input().split())
a = [input() for _ in range(H)]

a = [row for row in a if not all(map(lambda i: i == ".", row))]
a_T = [col for col in zip(*a) if not all(map(lambda i: i == ".", col))]
for row in zip(*a_T):
    print("".join(row))

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

int main(void){
  int a, b, out;
  char op;
  
  while(1){

    cin >> a >> op >> b;
    
    if(op == '+'){
      out = a + b;
      
    } else if(op == '-'){
      out = a - b;
      
    } else if(op == '*'){
      out = a * b;
      
    } else if(op == '/'){
      out = a / b;
      
    } else {
      break;
      
    }

    cout << out << endl;
  }

  return 0;
}

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

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

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n;
int a[25][25];
int dp[25][1<<21];
vector<int>v[23];

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	return;
}

void solve(){
	dp[0][0]=1;
	for(int i=0;i<(1<<n);i++){
		int cnt=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j))cnt++;
		}
		v[cnt].eb(i);
	}
	for(int i=0;i<n;i++){
		for(int j:v[i]){
			if(dp[i][j]==0)continue;
			for(int k=0;k<n;k++){
				if(!a[i][k])continue;
				dp[i+1][j|(1<<k)]+=dp[i][j];
				dp[i+1][j|(1<<k)]%=MOD;
			}
		}
	}
	cout<<dp[n][(1<<n)-1]<<endl;
	return;
}

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

Measured memory_bytes: 179644