akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char a[2333333];
int n,p,q;
int main(){
	scanf("%s",a+1);
	n=strlen(a+1);
	FOR(i,1,n)
		if (a[i]=='A'){
			p=i;
			break;
		}
	FORD(i,n,1)
		if (a[i]=='Z'){
			q=i;
			break;
		}
	printf("%d\n",q-p+1);
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    int top, right, bottom, left;
    top = y + r;
    right = x + r;
    bottom = y - r;
    left = x - r;
    if (top <= H && right <= H && bottom >= 0 && left >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3108
n, m = map(int, input().split())
ball = [1] * n
red = set([0])
for _ in range(m):
  x, y = map(int, input().split())
  ball[x-1] -= 1
  ball[y-1] += 1
  if x-1 in red:
  	red.add(y-1)
  if ball[x-1] == 0:
    red.discard(x-1)
print(len(red))

Measured memory_bytes: 12652
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	二分答案!
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
	分析样例：奇数or偶数
	偶数
	线段离散化
	make_pair 慢
	坐标离散化
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL h[100001];LL n,a,b;
bool check(LL x){
	LL tot=0;
	rb(i,1,n){
		if((h[i]-x*b)<=0) continue;
		tot+=((h[i]-x*b)/(a-b));
		if((h[i]-x*b)%(a-b)!=0) tot++; 
	}
	if(tot>x) return false;
	return true;
}
int main(){
	scanf("%lld %lld %lld",&n,&a,&b);
	rb(i,1,n){
		scanf("%lld",&h[i]);
	}
//	int res=-INF;
	LL l=0,r=1000000000;
	while(l<r){
		LL mid=(l+r)>>1;
//		cout<<l<<" "<<r<<" "<<mid<<endl;
		if(check(mid)){
			r=mid;
		}
		else{
			l=mid+1;
		}
	}
//	cout<<check(84172118)<<endl;
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int oriA = (int)Math.ceil(A/0.08);
        int oriB = (int)Math.ceil(B/0.1);
        int min = Math.min(oriA, oriB);
        int max = Math.max(oriA, oriB);
        for(int i = min ; i <= max; i++){
            if((int)Math.floor(i*0.08) == A && (int)Math.floor(i*0.1) == B) {
                os.println(i);
                return;
            }
        }
        os.println(-1);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, a[MAXN], lg[MAXN];
pii f[2][18][MAXN];

struct Node
{
	int l, r, k;
	bool operator < (const Node &b) const { return a[k] > a[b.k]; }
};

priority_queue <Node> q;

inline int Query(int l, int r, bool t)
{
	t ^= l & 1;
	int k = lg[r - l + 1];
	return min(f[t][k][l], f[t][k][r - (1 << k) + 1]).yy;
}

inline void Insert(int l, int r)
{
	if (l < r)
		q.push({l, r, Query(l, r, 0)});
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read(), f[i & 1][0][i] = mp(a[i], i), f[i & 1 ^ 1][0][i] = mp(n + 1, i);
	for (int i = 2; i <= n; i ++)
		lg[i] = lg[i >> 1] + 1;
	for (int k = 0; k < 2; k ++)
		for (int i = 1; i < 18; i ++)
			for (int j = 1; j + (1 << i) - 1 <= n; j ++)
				f[k][i][j] = min(f[k][i - 1][j], f[k][i - 1][j + (1 << i - 1)]);
	for (Insert(1, n); !q.empty(); )
	{
		Node t = q.top(); q.pop();
		int l = t.l, r = t.r, x = t.k, y = Query(x, t.r, 1);
		printf("%d %d ", a[x], a[y]);
		Insert(l, x - 1), Insert(x + 1, y - 1), Insert(y + 1, r);
	}
	return 0;
}


Measured memory_bytes: 59900
#include <iostream>

#include <cassert>
#include <cctype>
using namespace std;
string S;
size_t cur = 0;
int term();
int factor();
int expression();
int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0'; 
	cur = cur + 1;
	return n;
}
int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur]))
		n = n*10 + digit();
	return n;
}
int expression(){
	int a =term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')){
		char op = S[cur++];
		int b = term();
		if (op == '+') a += b;
		else a -= b;
	}
	return a;
}
int term(){
	int a =factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if (op == '*') a *= b; else a /= b;
	}
	return a;
}
int factor(){
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur +=1;
	return n;
}
int main() {

	int N;
	cin >> N;
	for (int i=0; i<N;++i){
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;

}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

int partition(int a[], int p, int r)
{
        int x = a[r],
                i = p - 1;
        int temp;

        for (int j = p; j < r; j++) {
                if (a[j] <= x) {
                        i++;
                        temp = a[i];
                        a[i] = a[j];
                        a[j] = temp;
                }
        }
        temp = a[i + 1];
        a[i + 1] = a[r];
        a[r] = temp;

        return i + 1;
}

int main()
{
        int n;
        cin >> n;
        int *a = new int[n];
        for (int i = 0; i < n; i++) {
                cin >> a[i];
        }

        int pivot = partition(a, 0, n - 1);
        for (int i = 0; i < n - 1; i++) {
                if (i == pivot) {
                        cout << "[" << a[i] << "]";
                } else {
                        cout << a[i];
                }
                cout << " ";
        }
        cout << a[n - 1] << endl;

        return 0;
}

Measured memory_bytes: 1568
using System;

class test{
  static void Main(){
    string[] nums = Console.ReadLine().Split();
    double num1 = Double.Parse(nums[0]);
    double num2 = Double.Parse(nums[1]);
    double answer = num1/(num2*2+1);
    answer = Math.Ceiling(answer);
    Console.Write(answer);
  }
}

Measured memory_bytes: 13140
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let d: usize = read(&mut stdin_lock, &mut buf, b' ');
    let g: i64 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut pcv = vec![(0i64, 0i64); d];
    for i in 0..d {
        pcv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        pcv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut ans = 100 * 10;
    for bits in 0..(1 << d) {
        let mut x = 0i64;
        let mut y = 0;
        for i in 0..d {
            if (bits & (1 << i)) != 0 {
                x += (i as i64 + 1) * 100 * pcv[i].0 + pcv[i].1;
                y += pcv[i].0;
            }
        }
        if x >= g {
            ans = min(ans, y);
        } else {
            for i in 0..d {
                let j = d - i - 1;
                if (bits & (1 << j)) == 0 {
                    for _ in 0..pcv[j].0 {
                        x += (j as i64 + 1) * 100;
                        y += 1;
                        if x >= g {
                            ans = min(ans, y);
                        }
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;
int test[12345678], test1[12345678];
signed main() {
	int n, k, c, cnt = 1, mae = 0; string s; cin >> n >> k >> c >> s;
	for (int h = 0; h < n; h++) {
		if (s[h] == 'o') {
			if (cnt == 1) { test[cnt] = h + 1; cnt++; mae = h; }
			else if (h - mae > c) {
				test[cnt] = h + 1; cnt++; mae = h;
			}
		}
		if (cnt > k) { break; }
	}
	cnt = k;
	for (int h = n - 1; h >= 0; h--) {
		if (s[h] == 'o') {
			if (cnt == k) { test1[cnt] = h + 1; cnt--; mae = h; }
			else if (mae - h > c) {
				test1[cnt] = h + 1; cnt--; mae = h;
			}
		}
		if (cnt == 0) { break; }
	}
	for (int h = 1; h <= k; h++) {
		if (test[h] == test1[h]) {
			cout << test[h] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){ 
    int n;cin>>n;
    ll ans = 0;
    rep(i,n){
        ll a;
        cin >> a;
        while(a%2==0){
            a/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 3616
import sys
import math

N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
    sys.exit()

n = math.factorial(N)
m = math.factorial(M)
MOD = 10**9 + 7

if N == M:
    print(n * m * 2 % MOD)
else:
    print(n * m % MOD)


Measured memory_bytes: 5184
N = int(input())
H = list(map(int, input().split()))

H.insert(0, 1)
H.append(10 **10)

for i in range(1, N + 2):    
    if i < N + 1 and H[i + 1] - H[i] <= -2:
        print('No')
        break
    elif i < N + 1 and H[i + 1] - H[i] == -1:
        if H[i] - H[i - 1] <= 0:
            print('No')
            break
        else:
            H[i] = H[i] - 1
            continue
    elif i < N + 1 and H[i + 1] - H[i] >= 0:
        if H[i] - H[i - 1] == 0:
            continue
        else:
            H[i] = H[i] - 1
            continue
    else:
        print('Yes')

Measured memory_bytes: 14480
#include<iostream>
using namespace std;
int main(){
	int N;
	int x[1009],y[1009];
	int h[1009];
	cin>>N;
	for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>h[i];
    int base_h=h[0];
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int k=0;k<=200;k++){
			    bool flag=true;
			    int search_h=base_h+k;
			    for(int l=0;l<N;l++){
			    	int dist=abs(x[l]-i)+abs(y[l]-j);
			    	if((search_h<dist&&h[l]!=0)||(search_h>=dist&&h[l]!=search_h-dist))flag=false;
			    }
			    if(flag==true)cout<<i<<" "<<j<<" "<<search_h<<endl;
		    }
		}
	}
}

Measured memory_bytes: 256
from functools import reduce

n = int(input())
values = list(map(int, list(input().split())))

def mymin(a, b):
    if a<b :
        return a
    else :
        return b

def mymax(a, b):
    if a>b :
        return a
    else :
        return b

def mysum(a, b):
    return a+b

print(reduce(mymin, values, 1000001), reduce(mymax, values, -1000001), reduce(mysum, values, 0))


Measured memory_bytes: 7268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int n;
    cin >> n;
    vector<int> a,b(n-1);
    for(int i = 0; i < n-1;i++){
        cin >> b[i];
    }
    ll ans = 0;
    a.push_back(b[0]);
    for(int i = 0; i < n-2;i++){    
        a.push_back(min(b[i],b[i+1]));
    }
    a.push_back(b[b.size()-1]);

    for(int i = 0; i < n;i++){
        ans += a[i];
    }


    cout << ans << endl;



    

    return 0;
}

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

using namespace std;
#define MV 200
#define INF 1e10

struct edge{int to,cost; };
vector <edge> G[MV];

int V,E;
long long d[MV+1];//???????????????????´?

bool bellmanford(int s){
  fill(d,d+MV,INF);
  d[s] = 0;
  int c = 0;
  bool upd = false;
  while(true){
    upd = false;
    for(int i = 0;i < V;i++){
      for(int j = 0;j < G[i].size();j++){
	edge e = G[i][j];
	if(d[i] != INF && d[e.to] > d[i] + e.cost){
	  d[e.to] = d[i] + e.cost;
	  upd = true;
	}
      }
    }
    if(!upd)
      break;
    if(c == V-1)
      return true;//?????????????????????
    c++;
  }
  return false;
}

int main(){
  d[MV] = INF+10;
  int first;
  bool flag;
  cin >> V >> E;
  for(int i = 0;i < E;i++){
    int f,t;
    edge e;
    cin >> f >> e.to >> e.cost;
    G[f].push_back(e);
    /*
      G[f]??????f????????§????????????????´???????????????????
     */
    t = e.to;
    /*
    e.to = f;
    G[t].push_back(e);
    */
  }
  long long vec[V][V];
  
  for(int i = 0;i<V;i++){
    flag = bellmanford(i);
    for(int j = 0;j < V;j++){
      vec[i][j] = d[j];
    }
    if(flag == true)
      break;
  }
  if(flag == true)
    cout << "NEGATIVE CYCLE" << endl;
  else{
    for(int i = 0;i < V;i++){
      for(int j = 0;j < V;j++){
	if(vec[i][j] == INF){
	  if(j != V-1)
	    cout << "INF" << " ";
	  else
	    cout << "INF";
	}
	else{
	  if(j != V-1)
	    cout << vec[i][j] << " ";
	  else
	    cout << vec[i][j];
	}
      }
      cout << endl;
    }
    //cout << endl;
  }
  
}

Measured memory_bytes: 3296
#include <iostream>
#include <vector>
#include<algorithm>

using namespace std;

int main(){
	double N, gyaku,res;
    cin >> N;
	vector<double> A(N);

  	for(int i = 0; i < N; i++){
    	cin >> A[i];
      	gyaku += 1/A[i];
    }
  
  	res = 1.0f/gyaku;
      
    cout << res;
  
	return 0;
}

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

cnt = 0

for i in range(N) :
    sum = 0
    for j in range(M) :
        sum += A[i][j] * B[j]
    if sum + C > 0 :
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    int n;cin >> n;
    long long int res[87]={2,1};
    for(int i=2;i<=n;i++){
        res[i]=res[i-1]+res[i-2];
    }
    p(res[n])
}

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

int main()
{
  int i,j,n,swap,count=0;
  int a[100];

  cin >> n;

  for (j=0;j<n;j++){
      cin >> a[j];
  }

  for (i=0;i<n;i++){
    for (j=n-1;j>0;j--){
      if (a[j]<a[j-1]){
	swap=a[j];a[j]=a[j-1];a[j-1]=swap;
	count++;
      }
    }
  }

  for (j=0;j<n;j++){
    cout << a[j];
    if (j<n-1){
      cout << " ";
    }
  }

  cout << endl << count << endl;

  return 0;

}

Measured memory_bytes: 3084
#include <iostream>

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

    int a[101] = {0};
    for(int i=0;i<K;i++)
    {
        int d;
        std::cin >> d;

        for(int j=0;j<d;j++)
        {
            int A;
            std::cin >> A;
            a[A]++;
        }
    }

    int count=0;
    for(int i=0;i<N;i++)
        if(a[i+1] == 0)
            count++;
    std::cout << count << std::endl;
}

Measured memory_bytes: 3652
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
lis=LI()
if n>=m:
    print(0)
    sys.exit()
lis.sort()
dis=[]
for i in range(m-1):
    dis.append(lis[i+1]-lis[i])
ans=0
dis.sort()
for i in range(m-n):
    ans+=dis[i]
print(ans)

Measured memory_bytes: 13820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1000000000000000000ll;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
ll n,a,b,c,d;
map<ll,ll> dp;
ll dfs(ll now){
    if(now==0)return 0;
    ll ans=LINF;
    if(now<=LINF/d)ans=now*d;
    if(dp.find(now)!=dp.end())return dp[now];
    for(int t=-4;t<=4;t++){
        ll x=now+t;
        if(x%2==0&&abs(t)<2&&x/2<now&&x>=0)ans=min(ans,d*abs(t)+a+dfs(x/2));
        if(x%3==0&&abs(t)<3&&x/3<now&&x>=0)ans=min(ans,d*abs(t)+b+dfs(x/3));
        if(x%5==0&&abs(t)<5&&x/5<now&&x>=0)ans=min(ans,d*abs(t)+c+dfs(x/5));
    }
    return dp[now]=ans;
}
void solve(){
    cin>>n>>a>>b>>c>>d;
    dp.clear();
    cout<<dfs(n)<<endl;
    return ;
}
int main(){
    ll t;cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int64_t i=ini;i<n;i++)
#define _rep(i,ini,n) for(int64_t i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
    vector<int64_t> P(A),Q(B),R(C);
    rep(a,0,A) cin>>P.at(a);
    rep(b,0,B) cin>>Q.at(b);
    rep(c,0,C) cin>>R.at(c);

    sort(ToEnd(P),greater<int64_t>());
    sort(ToEnd(Q),greater<int64_t>());
    sort(ToEnd(R),greater<int64_t>());

    vector<int64_t> Ans;
    rep(x,0,X) Ans.push_back(P.at(x));
    rep(y,0,Y) Ans.push_back(Q.at(y));

    sort(ToEnd(Ans));
    
    rep(i,0,min(X+Y,C)){
        if(Ans.at(i)<R.at(i)) Ans.at(i)=R.at(i);
        else break;
    }

    int64_t ans=0;
    for(auto a:Ans) ans+=a;
    cout<<ans<<endl;
}

Measured memory_bytes: 4724
#include "bits/stdc++.h"
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define nl '\n'
#define precision(n) setprecision(n)
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() { _
    int a, b, c; cin >> a >> b >> c;
    vector<int> d = {a, b, c};
    sort(all(d));
    int ans = 0;
    while (d[2] != d[1]) {
        d[2]--;
        ans++;
    }
    while (d[1] != d[0]) {
        if (d[1] - 2 >= d[0]) {
            d[1] -= 2;
            d[2] -= 2;
        } else {
            d[1]--;
            d[2]--;
            ans++;
        }
        ans++;
    }
    cout << ans << nl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
 
using namespace std;
#define prime 1000000007
 
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int n;
ii v[100100];
int ans[100100];

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

    for (int i = 0; i < n; ++i){
        int x;
        scanf("%d", &x);
        v[i] = {x, i};
    }

    sort(v, v+n);

    for (int i = 0; i < n; ++i){
        printf("%d ", v[i].ss+1);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int M = 1e9+7;
const int N = 1e5+5;
int fact[2*N];
int dp[N];
pii v[N];

int pow(int b, int e, int m) {
    int ans = 1;
    while (e) {
        if (e&1) ans = (1ll*ans*b) % m;
        b = (1ll*b*b) % m;
        e /= 2;
    }
    return ans;
}

int ncr(int n, int r) {
    int den = (1ll*fact[r]*fact[n-r]) % M;
    den = pow(den, M-2, M);
    return (1ll*fact[n]*den) % M;
}

int f(int id) {
    int &r = dp[id];
    if (r != -1) return r;
    
    int n = v[id].F - 1;
    int m = v[id].S - 1;
    r = ncr(n+m, m);
    
    forn(i, 0, id) {
        int y = v[i].F - 1;
        int x = v[i].S - 1;
        if (x > m) continue;
        
        int aux = ncr(n-y+m-x, m-x);
        aux = (1ll * aux * f(i)) % M;
        r = (r - aux + M) % M;
    }
    return r;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, m, k;
    cin >> n >> m >> k;
    
    fact[0] = 1;
    forn(i, 1, n+m+1) {
        fact[i] = (1ll*i*fact[i-1]) % M;
    }
    
    forn(i, 0, k) {
        cin >> v[i].F >> v[i].S;
    }
    v[k] = {n, m};
    
    sort(v, v+k);
    memset(dp, -1, sizeof dp);
    int ans = f(k);
    
    cout << ans << endl;
}


Measured memory_bytes: 4796
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=1LL<<60;


int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int r=0,g=0,b=0;
  rep(i,n){
    if(s[i]=='R')r++;
    if(s[i]=='G')g++;
    if(s[i]=='B')b++;
  }
  ll all=r*g*b,part=0;
  rep(i,n){
    int k=1;
    while(1){
      if(2*k+i<n){
	if(s[i]!=s[k+i]&&s[k+i]!=s[2*k+i]&&s[i]!=s[2*k+i]){
	  part++;
	  //cout << i << " , "<<k<< endl;
	}
      }
      else break;
      k++;
    }
  }
  cout << all-part;
}


Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int n,cnt;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cnt+=i;
		if (cnt>=n) 
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

int main(void) {
  int n;
  string a, b, c;
  cin >> n;
  cin >> a >> b >> c;
  int sum = 0;
  for(int i = 0; i < n; i++)
  {
    if (a[i] == b[i] && b[i] == c[i]) {
    }
    else if (a[i] != b[i] && a[i] != c[i] && b[i] != c[i]){
      sum += 2;
    }
    else {
      sum++;
    }
  }

  cout << sum << endl;
  

  return 0;
}

Measured memory_bytes: 256
class DisjointSet:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0]*size
    
    def find(self, x):
        stack = []
        parent = self.parent
        while parent[x] != x:
            stack.append(x)
            x = parent[x]
        for y in stack:
            parent[y] = x
        return x

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)
        
        if self.rank[xr] > self.rank[yr]:
            self.parent[yr] = xr
        elif self.rank[xr] < self.rank[yr]:
            self.parent[xr] = yr
        elif xr != yr:
            self.parent[yr] = xr
            self.rank[xr] += 1

N,M = map(int,input().split())
ds = DisjointSet(N)

for _ in range(M):
    a,b = map(int,input().split())
    ds.union(a-1,b-1)

print(len(set(ds.find(i) for i in range(N)))-1)


Measured memory_bytes: 21464
import java.io.*;
import java.util.*;
public class Main {
   public static void main(String args[]) {
       int n = 0;
       int k = 0;
       int[] arr = null;
       try (Scanner scanner = new Scanner(System.in)) {
           n = scanner.nextInt();
           k = scanner.nextInt();
           arr = new int[n];
           for (int i=0; i < n; i++) {
               arr[i] = scanner.nextInt();
           }
       }
       int[] dp = new int[n];
       dp[0] = 0;
       dp[1] = Math.abs(arr[1] - arr[0]);
       for(int i = 2; i < n ;i++) {
           dp[i] = Integer.MAX_VALUE;
           for(int b = 1; b <= k; b++) {
               if(i-b >= 0) {
                   dp[i] = Math.min(dp[i], dp[i -b] + Math.abs(arr[i]- arr[i-b]));
               }
           }
       }

    //   System.out.println(Arrays.toString(dp));
       System.out.println(dp[n-1]);
   }
}


Measured memory_bytes: 51112
#include <stdio.h>
int main (void){
	int W=0;
	int H =0;

	while(scanf("%d %d",&W,&H)==2 && (W!=0 || H!=0)){
		if(W==0 && H==0){
			break;
		}else{
			for(int i=0; i<W; i++){
							for(int j=0; j<H; j++){
								printf("#");
							}
							printf("\n");
						}
		}
		printf("\n");
		fflush(stdout);

	}
}



Measured memory_bytes: 2052
#include<stdio.h>
#include<string.h>

#define MAXDIGIT 100
#define MAX_K 3

char s[MAXDIGIT+1];
unsigned long int dp[MAXDIGIT+1][MAX_K+1][2];

int main(){
	int K, digit;
	int i, j;
	int num_i_digit;

	scanf("%s", s);
	digit = strlen(s);
	scanf("%d", &K);

	for(i=1; i<=digit; i++){
		dp[i][0][0] = 1;
		dp[i][0][1] = 0;
	}
	dp[1][1][0] = (int)(s[0]-'0')-1;
	dp[1][1][1] = 1;
	for(j=2; j<=K; j++){
		dp[1][j][0] = 0;
		dp[1][j][1] = 0;
	}

	for(i=2; i<=digit; i++){
		num_i_digit = (int)(s[i-1]-'0');
		for(j=1; j<=K; j++){
			/* 上からi桁まで決めて、0でない桁がj個である数の内、Nよりも小さいもの */
			dp[i][j][0] = dp[i-1][j-1][0]*9 + dp[i-1][j][0];
			if(num_i_digit > 0){
				/* i番目の桁の数dが0でないとき */
				/* 上からi-1桁まで決めて、0でない桁がj-1個である数の内、 i番目の桁が0より大きくd未満の数においてはNより小さいと言える */
				/* 上からi-1桁まで決めて、0でない桁がj個である数の内、i番目の桁が0であるものはNより小さいと言える */
				dp[i][j][0] += dp[i-1][j-1][1]*(num_i_digit-1) + dp[i-1][j][1];
			}
			/* 上からi桁まで決めて、0でない桁がj個である数の内、Nよりも小さいとは確定できないもの */
			dp[i][j][1] = (num_i_digit > 0) ? dp[i-1][j-1][1] : dp[i-1][j][1];
		}
	}

	printf("%lu\n", dp[digit][K][0] + dp[digit][K][1]);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, a, b, ans;
inline ll read(){
    ll s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w *= -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
inline void work(){
    n = read(), a = read(), b = read();  
    if (a == 0) puts("0");
    else {
        ll m = n / (a + b); 
        n %= a + b;
        ll ans = m * a; 
        if (n > a) ans += a;
        else ans += n;\
        printf("%lld\n", ans);
    }
}
int main(){
    work();
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define int      long long
# define all(vc)   vc.begin(),vc.end()
# define all2(vc)  vc.rbegin(),vc.rend()
# define pb        push_back
# define vec       vector
# define fi        first 
# pragma GCC optimize "-O3"
# define se        second
# define speed     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# define time      cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std; 
map <int, int> mp;
void solve(){
    int n = 0, m;
    cin >> n >> m;
    vec <int> used(1000, 0);
    for (int i = 0; i < m; ++i)
    {
        int x;
        cin >> x;
        for (int i = 0; i < x; ++i)
        {
            int y;
            cin >> y;
            used[y]++;
        }
    }
    int k = 0;
    for (int i = 1; i <= n; ++i)
    {
        if( !used[i] ) k++;
    }
    cout << k;

}
int32_t main(){
    speed;
    int T = 1;
    //cin >> T;
    while( T-- ){
         solve();
         cout<<'\n';
    }
    time;
}
 

Measured memory_bytes: 3852
n = int(input())
a = [0]*n
x = [0 for i in range(n)]
y = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
    x[i] = [0 for j in range(a[i])]
    y[i] = [0 for j in range(a[i])]
    for j in range(a[i]):
        x[i][j], y[i][j] = map(int,input().split())
        x[i][j] -= 1

mh,h = 0,0
f = True

for i in range(2**n):
    # 全探索
    p = bin(i)
    p = p[2:].zfill(n)
    h = p.count("1")
    f = True
    for j in range(n):
        # 全探索で得られたすべてのパターンに対し
        if (p[j] == "1"):
            # j人目が正直者のとき
            for k in range(a[j]):
                # j人目の全ての証言に対し
                if (y[j][k] != int(p[x[j][k]])):
                    #実際の状況と合致していなければ X
                    f = False
    if (f):
        if (mh < h):
            mh = h

print(mh)




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

int main() {
  char s;
  cin >> s;
  
  if ((s == 'a') || (s == 'i') || (s == 'u') || (s == 'e') || (s == 'o')) {
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        
        int x = a * 800;
        int y = a / 15 * 200;
        System.out.println(x - y);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long n,i,j,k,c[8],cc,dd;
cin>>n;
for(i=0;i<n;i++){
cin>>k;
for(j=0;j<8;j++){c[j]=k%10;k/=10;}
sort(c,c+8);
for(cc=dd=0,j=0;j<8;j++){
cc=cc*10+c[j];
dd=dd*10+c[7-j];
}
cout<<dd-cc<<endl;
}
return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数　
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define INTINF 1000000000
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000  //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

#define N_MAX 100
#define W_MAX 100000
#define v_MAX 1000000000

int main()
{
    int N;
    int W;
    int w[N_MAX + 1];
    int v[N_MAX + 1];

    long long dp0[W_MAX + 1];
    long long dp1[W_MAX + 1];
    long long ans;
    long long tmpmaxdp;

    memset(dp0, 0, sizeof(dp0));
    memset(w, 0, sizeof(w));
    memset(v, 0, sizeof(v));

    cin >> N >> W;
    REP(i, N)
    {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < N; i++)
    {
        memset(dp1, 0, sizeof(dp1));
        for (int j = 0; j < W + 1; j++)
        {
            if (w[i] > j)
            {
                dp1[j] = dp0[j];
            }
            else
            {
                dp1[j] = max(dp0[j],
                             dp0[j - w[i]] + v[i]);
            }
        }
        memcpy(dp0, dp1, sizeof(dp0));
    }
    tmpmaxdp = 0;

    for (int i = 0; i < W + 1; i++)
    {
        if (dp1[i] > tmpmaxdp)
        {
            ans = dp1[i];
        }
    }
    cout << ans;
}

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

int main() {
    int n, m;
    cin >> n >> m;

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

    sort(a, a + n);

    pair<int, int> cb[m];
    int b, c;
    for (int i = 0; i < m; i++) {
        cin >> b >> c;
        cb[i] = {c, b};
    }

    sort(cb, cb + m);
    reverse(cb, cb + m);

    long ans = 0;
    int idx = 0;

    for (int i = 0; i < m; i++) {
        c = cb[i].first;
        b = cb[i].second;

        for (int i = 0; i < b; i++) {
            if (idx >= n) {
                break;
            }
            if (a[idx] >= c) {
                break;
            }

            ans += c;
            idx++;
        }
    }

    for (int i = idx; i < n; i++) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

void solve() {
    int n, l;
    vector<string> s;
    cin >> n >> l;
    string tmp;
    REP(i, n) cin >> tmp, s.push_back(tmp);
    sort(s.begin(), s.end());

    for(auto i = s.begin(); i != s.end(); i++){
        cout << *i;
    }
    cout << endl;
}

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

Measured memory_bytes: 256
program main
  
  implicit none

  integer(8) :: n
  integer(8), allocatable :: a(:), b(:), c(:)

  integer(8) :: i,j, tmp
  integer(8) :: sumb

  read(*,*) n
  allocate( a(n) )
  allocate( b(n) )
  allocate( c(n) )
  read(*,*) a

  b = 0  
  c = 0  
  do i = 1, n
    c(a(i)) =  c(a(i)) + 1
  end do
  sumb = 0
  do i = 1, n
    if( mod(c(i),2) == 0 ) then
      tmp =  int( c(i)/2 )
      b(i) =  tmp*(c(i)-1)
    else
      tmp = int( (c(i)-1)/2 )
      b(i) =  c(i)*tmp
    end if
    sumb = sumb + b(i)
  end do

  do i = 1, n
    if( mod(c(a(i)),2) == 0 ) then
      tmp = int( (c(a(i))-2)/2 )
      print*, sumb - b(a(i)) + tmp*(c(a(i))-1)
    else
      tmp = int( (c(a(i))-1)/2 )
      print*, sumb - b(a(i)) + tmp*(c(a(i))-2)
    end if
  end do
  
  
end program main


Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    int k;
    cin>>k;
    sort(a,a+3);

    while(k--)
    {
        a[2] = a[2] * 2;
    }
    cout<<a[2]+a[0]+a[1]<<endl;
    return 0;
}


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

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;
const ll mod = (ll)1e9+7;

ll n,m;
bool mark[2][54]={0};
string s[2];

int main() {
    fast;
    cin >> n;
    cin >> s[0] >> s[1];
    m = sz(s[0]);
    ll ans = 1;

    forn(j, m) {
        if (s[0][j] == s[1][j]) {
            ll x = 3;
            if (j > 0 and s[0][j - 1] == s[1][j - 1]) x--;
            if (j > 0 and s[0][j - 1] != s[1][j - 1]) x -= 2;
            mark[0][j] = mark[1][j] = 1;
            ans = (ans * x) % mod;
//            cout<<"0 ";
//            cout << j << " " << x << endl;
        } else if (s[0][j] != s[1][j + 1]) {
            ll x = 0;
            if (j > 0 and s[0][j - 1] == s[1][j - 1]) x++;
            if (j > 0 and s[0][j - 1] != s[1][j - 1]) x+=2;
            mark[0][j] = mark[1][j] = 1;
            if(x==0)
            ans = (ans * 6) % mod;
            else if(x==1) ans =(ans*2)%mod;
            else ans =(ans*3)%mod;
//            cout<<"1 ";
//            cout << j << " " << x << endl;
            j++;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c;
  int temp;

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

  if(a>b){
    temp=a;
    a=b;
    b=temp;
  }if(b>c){
    temp=b;
    b=c;
    c=temp;
  }if(a>b){
    temp=a;
    a=b;
    b=temp;
  }

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

  return 0;
}

Measured memory_bytes: 596
import math

def num():
    return int(input())


def nums():
    return map(int,input().split())

a,b,h,m = nums()
t = h*60 + m
th = (t/2)-(6*m)

res = a**2 + b**2 -2*a*b*math.cos(math.radians(th))
print(res**(1/2))

Measured memory_bytes: 9504
#include <stdio.h>

int left[4];
int right[4];

int main(void)
{
	int i;
	double leye;
	double reye;
	
	while (scanf("%lf %lf", &leye, &reye) != EOF){
		if (leye >= 1.1){
			left[0]++;
		}
		else if (leye >= 0.6){
			left[1]++;
		}
		else if (leye >= 0.2){
			left[2]++;
		}
		else {
			left[3]++;
		}
		
		if (reye >= 1.1){
			right[0]++;
		}
		else if (reye >= 0.6){
			right[1]++;
		}
		else if (reye >= 0.2){
			right[2]++;
		}
		else {
			right[3]++;
		}
	}
	
	for (i = 0; i < 4; i++){
		printf("%d %d\n", left[i], right[i]);
	}
	
	return (0);
}

Measured memory_bytes: 628
N = int(input())
A = list(map(int, input().split()))

def getCol(n):
    if n >= 3200:
        return 10
    return (n < 400) + (n < 800) + (n < 1200) + (n < 1600) + (n < 2000) + (n < 2400) + (n < 2800)


cnt = [0] * 100
for a in A:
    col = getCol(a)
    cnt[col] = cnt[col] + 1


num = 0
for i in range(10):
    num = num + (cnt[i] != 0)

mn = max(1, num)
mx = num + cnt[10]
print (mn, mx)
        


Measured memory_bytes: 3064
<?php
$n = trim(fgets(STDIN));
for ($i = 0; $i < $n; ++$i) {
    $a[$i] = trim(fgets(STDIN));
}
$b = $a;
rsort($b);
$sai = $b[0];
$sai1 = $b[1];


for ($i = 0; $i < $n; ++$i) {
    if ($sai > $a[$i])  {
        echo $sai . PHP_EOL;
    } elseif ($sai == $a[$i]) {
        echo $sai1 . PHP_EOL;
    }

}
?>

Measured memory_bytes: 28528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define n 100005
vector<ll> adj[n];
ll N,M;
ll in[n],out[n];
void dfs(ll s,ll p)
{
	if ((adj[s].size()==1 and s!=1) or (s==1 and adj[s].size()==0))
	{
		in[s]=1;
		return;
	}
	
	for(ll i=0;i<adj[s].size();i++)
	{
		ll v=adj[s][i];
		if (v!=p)
		{
			dfs(v,s);
			in[s]=in[s]*((in[v]+1)%M);
			in[s]%=M;
		}
	}
	
}

void dfs2(ll s,ll p,ll Val)
{
	if (p==0)
	{
		out[s]=0;
	}
	else
	{
		out[s]=Val*((out[p]+1)%M);
		if (out[s]>=M)
			out[s]%=M;

	}
	if ((adj[s].size()==1 and s!=1) or (s==1 and adj[s].size()==0))
		return;
	ll sz=adj[s].size();
	ll pre[sz];
	ll suff[sz];
	for(ll i=0;i<sz;i++)
	{
		pre[i]=1;
		suff[i]=1;
	}
	
	vector<ll> a;
	for(ll i=0;i<adj[s].size();i++)
	{
		ll v=adj[s][i];
		if (v!=p)
		{
			a.push_back((in[v]+1)%M);
		}
	}
	/*
	for(ll i=0;i<a.size();i++)
	{
		cout<<a[i]<<" ";
		cout<<endl;
	}*/
	for(ll i=0;i<a.size();i++)
	{
		if (i==0)
			pre[0]=a[0];
		else
		{
			pre[i]=pre[i-1]*(a[i]);
			pre[i]%=M;
		}
	}
	for(ll i=a.size()-1;i>=0;i--)
	{
		if (i==a.size()-1)
			suff[i]=a[i];
		else
		{
			suff[i]=suff[i+1]*(a[i]);
			suff[i]%=M;
		}
	}
	sz=a.size();
	//cout<<sz<<endl;
	a.clear();
	for(ll i=0;i<adj[s].size();i++)
	{
		ll v=adj[s][i];
		if (v!=p)
		{
			a.push_back(v);
		}
	}
	/*
	cout<<a.size()<<endl;
	
	for(ll i=0;i<a.size();i++)
	{
		cout<<a[i]<<" "<<pre[i]<<" "<<suff[i]<<" ";
		cout<<endl;
	}*/
	for(ll i=0;i<a.size();i++)
	{
		ll v=a[i];

		ll val=1;
		if (i==0)
			val*=suff[i+1];
		else if (i==a.size()-1)
		{
			val*=pre[i-1];
		}
		else
		{
			val*=pre[i-1];
			val*=suff[i+1];
			if (val>=M)
				val%=M;
		}
		if (a.size()==1)
			val=1;
		dfs2(v,s,val);
	}

	

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>N>>M;
	ll m=N-1,a,b;
	while(m--)
	{
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(ll i=1;i<=N;i++)
		in[i]=1;
	dfs(1,0);
	memset(out,0,sizeof(out));
	for(ll i=1;i<=N;i++)
		out[i]=0;
	dfs2(1,0,0);
	//cout<<endl;
	for(ll i=1;i<=N;i++)
	{
		//cout<<in[i]<<" "<<out[i]<<endl;
		ll ans=in[i]*((out[i]+1)%M);
		ans%=M;
		cout<<ans<<" ";
	}
}


Measured memory_bytes: 25344
def BubbleSort(C, N):
    for i in range(0, N):
        for j in range(N-1, i, -1):
            if int(C[j][1]) < int(C[j-1][1]):
                C[j], C[j-1] = C[j-1], C[j]
    return C

def SelectionSort(C, N):
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if int(C[j][1]) < int(C[minj][1]):
                minj = j
        if C[i][1] != C[minj][1]:
            C[i], C[minj] = C[minj], C[i]
    return C

N = int(input())
C = list(input().split())
C_dash = C.copy()

b = BubbleSort(C, N)
s = SelectionSort(C_dash, N)

print(" ".join(b))
print("Stable")
print(" ".join(s))
if b == s:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5608
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
    ll ans = 1;
    while (n) 
    {
        if (n&1) ans = (ans*a)%modulo;
        a = (a*a)%modulo; n = n >> 1;
    }
    return ans;
}

void solve() 
{
    int arr[3];
    For(i,0,3)
    {
        cin >> arr[i];
    }
    sort(arr,arr+3);
    if (arr[0] == arr[2] or (arr[0] != arr[1] and arr[1] != arr[2])) 
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

int main() 
{
    fast_io();
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 6;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 7;
const int SM = 1e3 + 7;
const double EPS = 3e-16;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int a, b; cin >> a >> b;
	
	if(a <= 9 && b <= 9) cout << a * b;
	else cout << -1;

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> L(N+1);
  L.at(0) = 2;
  L.at(1) = 1;
  if (N == 1) cout << L.at(1);
  else {
    for (int i=2; i<N+1; i++)
      L.at(i) = L.at(i-1) + L.at(i-2);
    cout << L.at(N) << endl;
  }
}

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



int main(){
  int H,W;
  cin>>H>>W;
  
  vector<vector<char>>map(H,vector<char>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>map.at(i).at(j);
    }
  }
  
  bool OK=true;
    
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(map.at(i).at(j)=='#'){
        bool independent=true;
      
        if(i+1<H){
          if(map.at(i+1).at(j)=='#')
            independent=false;
        }
        if(i-1>=0){
          if(map.at(i-1).at(j)=='#')
            independent=false;
        }
        if(j+1<W){
          if(map.at(i).at(j+1)=='#')
            independent=false;
        }
        if(j-1>=0){
          if(map.at(i).at(j-1)=='#')
            independent=false;
        }
      
        if(independent){
          OK=false;
          //cout<<i<<endl<<j<<endl;
        }
      }
    }
  }
  if(OK)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
           

Measured memory_bytes: 256