akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 1000000;

ll f(ll x){
    if (x % 2 == 0) return x / 2;
    else return 3 * x + 1;
}

int main(void){
    ll s;
    ll a[MAX_N];

    cin >> s;

    a[0] = s;
    rep(i, MAX_N) a[i + 1] = f(a[i]);

    rep(n, MAX_N){
        ll an = a[n];
        For(m, n + 1, MAX_N){
            if (a[m] == an) {cout << m + 1 << endl; return 0;}
            if (a[m] > an && a[m + 1] > an && a[m + 2] > an && a[m + 3] > an) break;
        }
    }

    return 0;
}

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

int main(){

    int n;

    cin >> n;

    vector<int> cnt(n+1,0);

    for(int i=1;i<=n;i++){
        int t=i;
        int k=2;
        while(t>1){
            if(t%k==0){
                t/=k;
                cnt[k]++;
            }else{
                k++;
            }
        }
    }


    ll ans=1;
    ll mo=1e+9+7;
    for(int i=2;i<=n;i++){
        ans*=cnt[i]+1;
        ans%=mo;
    }

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
i=input()
lst = []
lst = [int(c) for c in str(i)]
#print(len(lst))
flag = 0

for i in range(len(lst) -1):
   if lst[i] == lst[i+1]:
      print("Bad")
      flag = 1
      break

if flag != 1:
  print("Good")

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N, Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 21732
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public static void Main()
    {
        //var input = Console.ReadLine().Split();
        //int[] X = Array.ConvertAll(input, int.Parse);
        var input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        string S = Console.ReadLine();
        String ans = "";
        for(int i = 0; i < N; i++)
        {
            if(K == i + 1)
            {
                if(S[i] == 'A')
                {
                    ans += 'a';
                }else if(S[i] == 'B')
                {
                    ans += 'b';
                }
                else
                {
                    ans += 'c';
                }
            }
            else
            {
                ans += S[i];
            }
        }
        Console.WriteLine(ans);
    }
}

//Array.ConvertAll(int.Parse)

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

int main() {
    string a = "";
    string b = "";
    string c = "";
    cin >> a;
    cin >> b;
    cin >> c;
    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=109,MX=1e5+9;
ll dp[inf][MX],val[inf],weight[inf],n,w,ans;

ll solve(int pos,int v){

    if(v==0)
        return 0;
    if(pos==n+1 || v<0)
        return 1e15;

    ll &ret=dp[pos][v];
    if(ret!=-1)
        return ret;

    ret=min(solve(pos+1,v-val[pos])+weight[pos],solve(pos+1,v));
    return ret;
}

int main(){

    cin>>n>>w;
    for(int i=1;i<=n;i++)
        cin>>weight[i]>>val[i];

    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<MX;i++){
        ll x=solve(1,i);
        if(x<=w)
            ans=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 85376
import java.util.*;
import java.io.*;

public class Main {

	public static void main (String[] args) {
	   InputReader in = new InputReader(System.in);
	   int n = in.readInt();
	   int a[] = new int[n]; 
	   int b[] = new int[n]; 
	   for(int i = 0; i<n; i++) {
		   a[i] = in.readInt();
		   b[i] = a[i]-(i+1);
	   }
	   Arrays.sort(b);
	   long sum = 0; 
	   for(int i = 0; i<n; i++) {
		   sum += Math.abs(a[i] - (b[n/2] + i+1));
	   }
	   System.out.println(sum); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 27068
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    mll b;
    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n){
        cin >> a[i];
        b[a[i]]++;
    }
    rep(i,1,n+1) cout << b[i] << endl;


}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

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

int main(){
  int n,x; cin >> n >> x;
  int l[n];
  for(int i=0;i<n;i++){
    cin >>l[i];
  }
  int bound[n+1];
  bound[0]=0;
  int count=1;
  for(int i=0; i<n; i++){
    bound[i+1] = bound[i]+l[i];
    if(bound[i+1]<=x){
      count++;
    }
  }
  cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	//std::ifstream in("1_13.txt");
	//std::cin.rdbuf(in.rdbuf());
	int n; cin >> n;
	vector<Int>a(n);
	int count4 = 0, count2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) count4++;
		else if(a[i] % 2 == 0) count2++;
	}
	int remain;
	remain = n - (count4 + 1) - count4;

	
	if (count2 < remain || (remain == 1 && count2 <= 1)||(count2==count4&&count4==remain)) cout << "No";
	else cout << "Yes";

	//cout << count2 << ":" << count4 << ":" << remain;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int h, w, k, sum[15][1005];
char s[15][1005];

int query(int row_lb, int row_ub, int col_lb, int col_ub) {
  return sum[row_ub][col_ub] - sum[row_ub][col_lb - 1] - sum[row_lb - 1][col_ub] + sum[row_lb - 1][col_lb - 1];
}

int calc(int mask) {
  int ans = __builtin_popcount(mask);
  vector<pair<int, int>> cuts;
  for (int i = 0, pre = 1; i < h; ++i) {
    if (i == h - 1 || (mask & 1 << i)) {
      cuts.emplace_back(pre, i + 1);
      pre = i + 2;
    }
  }
  int start = 1;
  while (start <= w) {
    int nxt = w + 1;
    for (const auto &p: cuts) {
      int lb, ub;
      tie(lb, ub) = p;
      if (query(lb, ub, start, start) > k) return h * w;
      int j = start + 1;
      while (j <= w && query(lb, ub, start, j) <= k) ++j;
      nxt = min(nxt, j);
    }
    if (nxt <= w) ++ans;
    start = nxt;
  }
  return ans;
}

int main() {
  cin >> h >> w >> k;
  for (int i = 1; i <= h; ++i) scanf("%s", s[i] + 1);
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + int(s[i][j] == '1');
    }
  }
  int ans = h * w;
  for (int mask = 0; mask < (1 << h - 1); ++mask) {
    ans = min(ans, calc(mask));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC

int main(){
    int n,p=0;cin>>n;
    lint ans;
    bool tate;
    string a,b;cin>>a>>b;
    
    while(p<n){
        if(p==0){
            if(a[p]==b[p]){
                ans=3;
                tate=true;
                p++;
            }
            else {
                ans=6;
                tate=false;
                p+=2;
            }
        }
        else{
            if(a[p]==b[p]){
                if(tate){
                    ans*=2;
                }
                p++;
                tate=true;
            }
            else{
                if(tate){
                    ans*=2;
                }
                else{
                    ans*=3;
                }
                p+=2;
                tate=false;
            }
        }
        ans%=1000000007;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <cstring>
#define inf 0x7fffffff
using namespace std;

int n, t[10005], v[10005], sumt;
double ans, limt[40005];
int main() {
	for(int i = 0; i < 40005; i++) limt[i] = inf;
	ans = 0.0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	scanf("%d", &t[i]), sumt += t[i];
	sumt *= 2;
	for(int i = 1; i <= n; i++)
	scanf("%d", &v[i]);
	double vs = 0.0;
	int ts = 0;
	for(int i = 1; i <= n; i++) {
		for(int k = ts; k <= ts + 2 * t[i]; k++)
		limt[k] = min(limt[k], 1.0 * v[i]);
		double p = 0.5;
		for(int k = ts - 1; k >= 0; k--, p += 0.5)
		limt[k] = min(limt[k], 1.0 * v[i] + p);
		ts += 2 * t[i];
	}
	double p = 0;
	for(int i = sumt; i >= 0; i--, p += 0.5)
	limt[i] = min(limt[i], p);
	for(int i = 1; i <= sumt; i++) {
		double vn = min(vs + 0.5, limt[i]);
		ans += (vs + vn) * 0.25;
		vs = vn;
	}
	printf("%lf\n", ans);
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define MOD 1000000009LL
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

mat operator*(const mat &A,const mat &B){
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();i++){
		for(int k=0;k<B.size();k++){
			for(int j=0;j<B[0].size();j++){
				C[i][j]=(C[i][j]+A[i][k]*B[k][j]%MOD)%MOD;
			}
		}
	}
	return C;
}

mat pow(mat A,ll n){
	mat B(A.size(),vec(A.size()));
	for(int i=0;i<A.size();i++){
		B[i][i]=1;
	}
	while(n>0){
		if(n&1)B=B*A;
		A=A*A;
		n>>=1;
	}
	return B;
}

int w,n;
ll h;
P o[33];
ll sum[2][80];

ll solve(){
	mat A(w,vec(w));
	for(int i=0;i<w;i++){
		for(int j=0;j<w;j++){
			A[i][j]=0;
		}
	}
	for(int i=0;i<w;i++){
		for(int j=max(0,i-1);j<=min(w-1,i+1);j++){
			A[i][j]=1;
		}
	}
	memset(sum,0,sizeof(sum));
	sum[0][0]=1;
	sort(o,o+n+1);
	ll ny=0;
	int now=1,prev=0;
	for(int i=0;i<=n;i++){
		mat G(w,vec(w));
		G=pow(A,o[i].first-ny);
		ny=o[i].first;
		for(int j=0;j<w;j++){
			for(int k=0;k<w;k++){
				sum[now][j]=(sum[now][j]+sum[prev][k]*G[j][k])%MOD;
			}
		}
		memset(sum[prev],0,sizeof(sum[prev]));
		sum[now][o[i].second]=0;
		swap(now,prev);
	}
	return sum[prev][w-1];
}

int main(void){
	int ca=0;
	while(1){
		ca++;
		scanf("%d%lld%d",&w,&h,&n);
		if(w==0 && h==0 && n==0)break;
		for(int i=0;i<n;i++){
			scanf("%d%lld",&o[i].second,&o[i].first);
			o[i].second--;
			o[i].first--;
		}
		o[n]=P(h-1LL,0);
		printf("Case %d: %lld\n",ca,solve());
	}
	return 0;
}

Measured memory_bytes: 2764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#define ll long long

using namespace std;

int main(void){
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll ans[n];
    ll check = 0;
    for(ll i = 0; i < n-1; i+=2)
        check += 2*a[i];
    ans[n-1] = sum - check;
    for(ll i = n-2; i >= 0; i--){
        ans[i] = 2*a[i] - ans[i+1];
    }
    for(ll i = 0; i < n; i++)
        cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2816
using System;

namespace _8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ret = new int[500];
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null) break;
                s = s.ToLower();
                for (int i = 0; i < s.Length; i++)
                {
                    ret[s[i]]++;
                }
            }
            for (int i = 'a'; i <= 'z'; i++)
            {
                Console.WriteLine((char)i + " : " + ret[i]);
            }
        }
    }
}

Measured memory_bytes: 9116
# coding: utf-8

n = int(input())
t = 0
h = 0

for _ in range(n):
    tc, hc = input().split()

    if tc > hc:
        t += 3
    elif tc < hc:
        h += 3
    else:
        t += 1
        h += 1

print(t, h)


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

int main(){
    int n,m;
    cin >>n>>m;
    if(n<=m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>

using namespace std;

int main() {
	int N = 0;
	cin >> N;
	vector<int> b(N);
	vector<int> a;
	for (int i = 0; i < N; ++i) {
		cin >> b[i];
	}
	for (int i = N; i > 0; --i) {
		int j = i;
		do {
			if (b[j - 1] == j) {
				b.erase(b.begin() + j -  1);
				a.push_back(j);
				break;
			}
			--j;
		} while (j > 0);
		if (j <= 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = N - 1; i >= 0; --i) {
		cout << a[i] << endl;
	}
	return 0;
}

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

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

    if (N % 1000 == 0) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << 1000 - (N % 1000) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
count=1
ans = a[0]
i = 1
while count < n-1:
    ans += a[i]*2
    count += 2
    i += 1
    #print(count,ans,i,a[i]*2)
else:
    if count != n-1:
        #print(a)
        #print(ans,count, i)
        ans -= a[i-1]

print(ans)

Measured memory_bytes: 31500
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].number))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define MOD 998244353
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define INF 100000000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int a[N];


signed main()
{
    
    speed
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    int xd=min(k,a);
    cnt+=xd;
    k-=xd;
    xd=min(k,b);
    cnt+=(xd*0);
    k-=xd;
    xd=min(k,c);
    cnt+=(xd*-1);
    k-=xd;
    cout<<cnt<<endl;





    return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "CONTINUE"
#define FALSE__ "GAMEOVER"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define fcout cout << fixed << setprecision(12)

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, K;
vector<int> a, b, c;
int sum = 0;

void init()
{
	cin >> N >> K;
	b.RS(N+1);
	b[0];
	c.RS(N+1);
	c[0];
	rep(i, N) {
		a.PB(GET<int>());
	}
	rep(i, N) {
		if (a[i] > 0) sum += a[i];
		b[i+1] = b[i] + a[i];
		c[i+1] = c[i] + (a[i] > 0 ? a[i] : 0);
	}
}

void solve()
{
	int mi = LLONG_MAX;
	rep(i, N-K+1) {
		int t = b[i+K] - b[i];
		int u = c[i+K] - c[i];
		chmin3(mi, u - t, u);
	}
	cout << sum - mi << endl;
}





Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

int main(void){
    int n,i,j,sosu[999999],ans=0;
    for(i=0;i<999999;i++) sosu[i]=1;
    sosu[0]=0;
    for(i=2;i<=999999;i++){
        if(sosu[i-1]==1){
            for(j=i*2;j<=999999;j+=i){
                sosu[j-1]=0;
            }
        }
    }
    while(cin >> n){
        ans=0;
        for(i=0;i<n;i++){
            ans+=sosu[i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
#define Maxn 407
#define modp 998244353
int n;
int h[Maxn];
int c[Maxn][Maxn],bin[Maxn];
pair<vector<int>,vector<int> > dfs(int lx,int rx,int x)
{
    if (lx>rx)
    {
        pair<vector<int>,vector<int> > v;
        v.first.clear();
        v.second.clear();
        v.first.push_back(1);
        v.second.push_back(1);
        return v;
    }
    if (lx==rx&&h[lx]==x)
    {
        pair<vector<int>,vector<int> > v;
        v.first.clear();
        v.second.clear();
        v.first.push_back(1);
        v.first.push_back(0);
        v.second.push_back(0);
        v.second.push_back(1);
        return v;
    }
    bool flag=false;
    int pos=-1;
    for (int i=lx;i<=rx;i++)
        if (h[i]==x) 
        {
            flag=true;
            pos=i;
        }
    if (flag)
    {
        pair<vector<int>,vector<int> > v1=dfs(lx,pos-1,x);
        pair<vector<int>,vector<int> > v2=dfs(pos+1,rx,x);
        pair<vector<int>,vector<int> > v;
        v.first.clear();
        v.second.clear();
        for (int i=0;i<=rx-lx+1;i++)
        {
            v.first.push_back(0);
            v.second.push_back(0);
        }
        for (int i=0;i<(int)v1.first.size();i++)
            for (int j=0;j<(int)v2.first.size();j++)
            {
                v.first[i+j]=(v.first[i+j]+1LL*v1.first[i]*v2.first[j])%modp;
                v.second[i+j+1]=(v.second[i+j+1]+1LL*v1.second[i]*v2.second[j])%modp;
            }
        return v;
    }
    pair<vector<int>,vector<int> > v;
    v.first.clear();
    v.second.clear();
    for (int i=0;i<=rx-lx+1;i++)
    {
        v.first.push_back(0);
        v.second.push_back(0);
    }
    pair<vector<int>,vector<int> > v1=dfs(lx,rx,x+1);
    for (int j=0;j<=rx-lx+1;j++)
        for (int i=j;i<=rx-lx+1;i++)
        {
            int tmp=bin[rx-lx+1-i];
            if (j==0) tmp=(tmp+modp-1)%modp;
            tmp=(1LL*tmp*c[i][j])%modp;
            v.first[i-j]=(v.first[i-j]+1LL*tmp*v1.first[i])%modp;
        }
    for (int j=0;j<=rx-lx+1;j++)
        for (int i=j;i<=rx-lx+1;i++)
        {
            int tmp=bin[rx-lx+1-i];
            tmp=(1LL*tmp*c[i][j])%modp;
            v.second[i-j]=(v.second[i-j]+1LL*tmp*v1.second[i])%modp;
        }
    for (int i=0;i<=rx-lx+1;i++)
        v.first[i]=(v.first[i]+v1.second[i])%modp;
    return v;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&h[i]);
    for (int i=0;i<=n;i++)
    {
        c[i][0]=1;
        for (int j=1;j<=i;j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%modp;
    }
    bin[0]=1;
    for (int i=1;i<=n;i++)
        bin[i]=(2LL*bin[i-1])%modp;
    pair<vector<int>,vector<int> > v=dfs(1,n,0);
    printf("%d\n",v.first[0]);
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int r[2]={6,9};
int dp[1005500];
int main(){	FIN;
	int n;
	cin>>n;
	fore(i,1,n+1) {
		dp[i]=dp[i-1]+1;
		fore(_,0,2) {
			int w=r[_];
			while(i-w>=0) {
				dp[i]=min(dp[i],dp[i-w]+1);
				w*=r[_];
			}
		}
	}
	cout<<dp[n]<<"\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 1000000007
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      ll  power(ll  i,ll  j)
      {
        if(j==0)
        return 1 ;
        ll t=power(i,j/2)%maa ;
        if(j%2==0)
        return (t%maa*t%maa)%maa ;
        else
        return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
      }
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      ll a[100001][4] ;
      ll n ;
      ll dp[100001][4] ;
      ll fun(ll i,ll j)
      {
          if(i==n)
          return 0 ;
          else if(dp[i][j]!=-1)
          return dp[i][j] ;
          else
          {
              ll ans=0 ;
              for(ll k=1;k<=3;k++)
              {
                  if(k==j)
                  continue ;
                  
                  
                  else
                  ans=max(ans,a[i][k]+fun(i+1,k)) ;
              }
              return dp[i][j]=ans ;
          }
      }
      int main()
      {

        /// 50-4
        /// freopen("input.txt","r",stdin);
        /// freopen("output.txt","w",stdout);
       
       cin>>n ;
       for(ll i=0;i<n;i++)
       {
           for(ll j=0;j<4;j++)
           dp[i][j]=-1 ;
       }
       for(ll i=0;i<n;i++)
       {
           for(ll j=1;j<=3;j++)
           {
               cin>>a[i][j] ;
           }
         
       }
       cout<<fun(0,0) ;
        
        
        
        
      }








Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int x;
	cin>>x;
	if(x==0)
	{
		cout<<1<<endl;
	}
	if(x==1)
	{
		cout<<0<<endl;
	}
	return 0;
}

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

int main(){
  long n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  long at,bt,ct,dt,et;
  at = (n+a-1)/a;
  bt = (n+b-1)/b;
  ct = (n+c-1)/c;
  dt = (n+d-1)/d;
  et = (n+e-1)/e;
  long time = 0;
  long min = a;
  int flag = 1;
  if(b < min)min = b;
  if(c < min)min = c;
  if(d < min)min = d;
  if(e < min)min = e;
  time = (n+min-1)/min + 4;
  cout << time << endl;

}

Measured memory_bytes: 256
import sys

N = int(input())
xu_list = [input().split() for i in range(N)]

#print(N, xu_list)
ans = 0

for i in xu_list:
    if i[1] == 'BTC':
        ans += float(i[0]) * 380000
    else:
        ans += float(i[0])

print(ans)


Measured memory_bytes: 2940
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

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

    int n;
    cin >> n;

    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    int ans = MOD;
    for (int i = 0; i < (1 << n); i++) {
        vector <P> even, odd;
        for (int j = 0; j < n; j++) {
            // iのjビット目が立っていたら、j番目の数字はbが使われる
            if (i & (1 << j)) {
                if (j % 2 == 0) {
                    odd.push_back(P(b[j], j));
                } else {
                    even.push_back(P(b[j], j));
                }
            } else {
                if (j % 2 == 0) {
                    even.push_back(P(a[j], j));
                } else {
                    odd.push_back(P(a[j], j));
                }
            }
        }

        int even_size = even.size();
        int odd_size = odd.size();
        if (n % 2 == 0) {
            if (even_size != odd_size) {
                continue;
            }
        } else {
            if (even_size != odd_size + 1) {
                continue;
            }
        }

        sort(even.begin(), even.end());
        sort(odd.begin(), odd.end());

        bool check = true;
        int cur = 0;
        vector <int> order(n);
        for (int j = 0; j < n; j++) {
            if (j % 2 == 0) {
                // check even
                if (even[j / 2].first < cur) {
                    check = false;
                    break;
                }

                cur = even[j / 2].first;
                order[j] = even[j / 2].second;
            } else {
                // check odd
                if (odd[j / 2].first < cur) {
                    check = false;
                    break;
                }

                cur = odd[j / 2].first;
                order[j] = odd[j / 2].second;
            }
        }

        if (check) {
            vector <int> count(n, 0);

            int tmp = 0;
            for (int j = 0; j < n; j++) {
                int num = order[j];
                tmp += abs(num + count[num] - j);

                for (int k = 0; k < num; k++) {
                    count[k]++;
                }
            }

            ans = min(ans, tmp);
        }
    }

    if (ans == MOD) {
        cout << -1 << '\n';
    } else {
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#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<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#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)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int h,w,n;cin >> h >> w >> n;
    int sh,sw;cin >> sh >> sw;
    string s,t;cin >> s >> t;
    {
        //top
        int y=sh,x=sw;
        rep(i,n){
            if(s[i]=='U') y--;
            if(y<1){
                cout << "NO" << endl;
                return 0;
            }
            if(t[i]=='D') y++;
            if(y>h) y=h;
        }
    }
    {
        //bottom
        int y=sh,x=sw;
        rep(i,n){
            if(s[i]=='D') y++;
            if(y>h){
                cout << "NO" << endl;
                return 0;
            }
            if(t[i]=='U') y--;
            if(y<1) y=1;
        }
    }
    {
        //right
        int y=sh,x=sw;
        rep(i,n){
            if(s[i]=='R') x++;
            if(x>w){
                cout << "NO" << endl;
                return 0;
            }
            if(t[i]=='L') x--;
            if(x<1) x=1;
        }
    }
    {
        //left
        int y=sh,x=sw;
        rep(i,n){
            if(s[i]=='L') x--;
            if(x<1){
                cout << "NO" << endl;
                return 0;
            }
            if(t[i]=='R') x++;
            if(x>w) x=w;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i, n){
    cin >> a[i];
    c[a[i]]++;
  }
  bool pairwize = true;
  for (int i=2; i<A; i++){
    int cnt = 0;
    for (int j=i; j<A; j+=i){
      cnt += c[j];
    }
    if (cnt > 1) pairwize = false;
  }
  if (pairwize){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = 0;
  rep(i, n) g = gcd(g, a[i]);
  if (g == 1){
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
vector<int>a(n+1);
for(int i=0;i<n+1;i++){
  cin >>a.at(i);
}
vector<int>b(n);
for(int i=0;i<n;i++){
  cin >> b.at(i);
}
long long ans =0;
int j =0;
for(int i=0;i<n;i++){
  j =i;
  if(b.at(i)<=a.at(j)){
    ans+=b.at(i);
    continue;
  }
  else{
    ans+=a.at(i);
    b.at(i)-=a.at(j);
    j++;
    if(b.at(i)<=a.at(j)){
      ans+=b.at(i);
      a.at(j)-=b.at(i);
      continue;
    }
    else{
      ans+=a.at(j);
      a.at(j)=0;
      continue;
    }
  }
}
cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <functional>
#include <string>
#include <sstream>

typedef std::function<void(int, int, int)> func;

int data[4][3][10];

void op(func&& f)
{
	for (int x = 0; x < 4; ++x)
		for (int y = 0; y < 3; ++y)
			for (int z = 0; z < 10; ++z)
				f(x, y, z);
}

int main()
{
	op(
		func(
			[&](int x, int y, int z) { data[x][y][z] = 0; }
		)
	);

	int count;
	std::string temp;
	std::getline(std::cin, temp, '\n');
	count = std::stoi(temp);

	for (int n = 0; n < count; ++n)
	{
		int x, y, z, v;
		std::cin >> x >> y >> z >> v;

		data[x - 1][y - 1][z - 1] += v;
	}

	const char* wall = "####################";
	for (int x = 0; x < 4; ++x)
	{
		for (int y = 0; y < 3; ++y)
		{
			for (int z = 0; z < 10; ++z)
			{
				std::cout << " " << data[x][y][z];
			}

			std::cout << std::endl;
		}

		if (x != 3)
			std::cout << wall << std::endl;
	}

	return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(5);
  for (int i = 0; i < v.size(); i++) {
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  ll x;
  if (n % v.at(0) == 0) {
    x = n / v.at(0);
  } else {
    x = n / v.at(0) + 1;
  }
  
  x += v.size() - 1;
  cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define lld long long int 
using namespace std;
int main() 
{
	int p,q,r;
	cin >> p >> q >> r;
	int a=p+q;
	int b=q+r;
	int c=p+r;
	cout<<min(a,min(b,c))<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
def calc(A):
  return((T - A) / 0.006)

H = list(map(int,input().split()))
x = calc(A)
ans=max(H) - x
for i in range(N):
  if abs(H[i] - x) < abs(ans):
    ans = H[i] - x
    
ans = int(ans + x)
print(H.index(ans)+1)

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

int main(){
      map<string, int> m;
      int n;cin >> n;
      int ans = INT_MIN;
      for(int i = 0;i < n;i++){
            string s;cin >> s;
            m[s]++;
      }
      int t;cin >> t;
      for(int i = 0;i < t;i++){
            string s;cin >> s;
            m[s]--;
      }
      for(auto i : m){
            if(i.second > ans)ans = i.second;
      }
      cout << max(0, ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n,a,b;cin>>n>>a>>b;
  if(n==1&&a==b)cout<<1<<endl;
  else if(n==1||b<a)cout<<0<<endl;
  else cout<<b*(n-2)-a*(n-2)+1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include <string>
int main()
{
    // 整数の入力
    int a;
    cin >> a;
  if(a<30)
  {
      
    // 出力
    cout <<  "No" << endl;
  }
  else
  {
      
    // 出力
    cout << "Yes" << endl;
  }
 
    return 0;
}

Measured memory_bytes: 3620
#input
X = int(input())

#output
#X(n) = 100*(1.01)**(n-1) >= X
#(1.01)**(n-1) >= X/100
#(n-1)log(1.01) >= log(X/100)
#n >= log(X/100)/log(1.01) + 1
n = 0
money = 100
while money < X:
    money *= 1.01
    money = int(money)
    n += 1

print(n)

Measured memory_bytes: 9092
from bisect import bisect_left

n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for i in range(0, k + 1):
    for j in range(0, min(k, n) - i + 1):
        tmp = v[:i] + (v[-j:] if j else [])
        tmp.sort()
        idx = min(k - i - j, bisect_left(tmp, 0))
        ans = max(ans, sum(tmp[idx:]))

print(ans)

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

ll d[50][50];
ll s[550][550];

int main(){
    int n, c;
    cin >> n >> c;
    rep(i, c) rep(j, c) cin >> d[i][j];
    rep(i, n) rep(j, n) cin >> s[i][j];

    vector<ll> p, q, r;

    rep(i, n) rep(j, n){
        if ((i+j)%3 == 0) p.push_back(s[i][j]);
        if ((i+j)%3 == 1) q.push_back(s[i][j]);
        if ((i+j)%3 == 2) r.push_back(s[i][j]);
    }

    vector<P> pp, qq, rr;
    for(int to = 1; to <= c; to++){
        ll tmpp = 0;
        ll tmpq = 0;
        ll tmpr = 0;
        rep(j, p.size()) tmpp += d[p[j]-1][to-1];
        rep(j, q.size()) tmpq += d[q[j]-1][to-1];
        rep(j, r.size()) tmpr += d[r[j]-1][to-1];
        pp.push_back(make_pair(tmpp, to));
        qq.push_back(make_pair(tmpq, to));
        rr.push_back(make_pair(tmpr, to));
    }
    sort(pp.begin(), pp.end());
    sort(qq.begin(), qq.end());
    sort(rr.begin(), rr.end());

    ll ans = LINF;
    rep(i, 3){
        rep(j, 3){
            rep(k, 3){
                if (pp[i].second == qq[j].second || pp[i].second == rr[k].second || rr[k].second == qq[j].second) continue;
                ans = min(ans, pp[i].first+qq[j].first+rr[k].first);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a - c) * (b - d)<< endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn insert_sort(vec: &mut Vec<u64>) {
    let len = vec.len();

    for n in 1 .. len {
        let p = vec[n];

        for m in (0 .. n).rev() {
            if vec[m] < p {
                break;
            }
            vec.swap(m, m + 1);
        }

        show_vec(vec);
    }
}

fn show_vec(vec: &Vec<u64>) {
    println!("{}", vec.iter().map(|x| x.to_string())
             .collect::<Vec<String>>()
             .join(" "));
    
}

fn main() {
    // let mut nums = vec![5,2,4,6,1,3];
    let mut s = String::new();
    let stdin = io::stdin();

    let _ = stdin.read_line(&mut s);
    let n : usize = s.trim().parse().unwrap();

    s.clear();

    let _ = stdin.read_line(&mut s);
    let mut nums : Vec<u64> = s.split_whitespace()
        .take(n)
        .map(|s| s.parse().unwrap()) 
        .collect();

    show_vec(&nums);
    insert_sort(&mut nums);
    //show_vec(&nums);
}



Measured memory_bytes: 5052
#include <iostream>

using namespace std;

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

    int ret = 0;
    for (int i = 2; i <= m; i++) {
        for (int j = 10; j <= d; j++) {
            int x = j / 10;
            int y = j % 10;
            if (x < 2 || y < 2)continue;
            if (i == x * y)ret++;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = input()
cnt = 1
memo = 1
for i in range(n):
  if s[i] == 'c':
    print('No')
  else:
    if cnt <= a + b:
      if s[i] == 'b' and memo <= b:
        memo += 1
        cnt += 1
        print('Yes')
      elif s[i] == 'a':
        cnt += 1
        print('Yes')
      else:
        print('No')   
    else:
      print('No')


Measured memory_bytes: 4016
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	long D, ans;
	long[] pow = new long[20];
	void Solve()
	{
		D = F();
		pow[0] = 1;
		for (var i = 1; i < 20; i++) pow[i] = pow[i - 1] * 10;
		WriteLine(Calc(D));
	}
	long Calc(long D)
	{
		if (D % 9 != 0) return 0;
		D /= 9;
		ans = 0;
		for (var n = 1; n <= 18; n++) DFS(new int[n / 2], n, D, 0);
		return ans;
	}
	void DFS(int[] a, int n, long d, int i)
	{
		if (i == n / 2)
		{
			if (d != 0) return;
			var p = a[0] >= 0 ? 9L - a[0] : 10 + a[0];
			for (var j = 1; j < n / 2; j++) p *= 10 - Abs(a[j]);
			ans += (n % 2 == 0 ? 1 : 10) * p;
		}
		else
		{
			var c = (pow[n - i - 1] - pow[i]) / 9;
			var t = d / c;
			if (d < 0 && d % c != 0) t--;
			foreach (var z in new[] { t, t + 1 })
				if (-9 <= z && z <= 9)
				{
					a[i] = (int)z;
					DFS(a, n, d - z * c, i + 1);
				}
		}
	}
}

Measured memory_bytes: 13140
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

lint dp[55][55][2525] = {{{0}}};

int main(){
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, n){
        cin >> x[i];
    }
    rep(i, n+1){
        dp[i][0][0] = 1;
    }
    REP(i, 1, n+1){
        REP(j, 1, n+1){
            rep(k, 2525){
                if(k >= x[i-1]){
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
                }else{
                    dp[i][j][k] = dp[i-1][j][k];
                }
            }
        }
    }
    lint ans = 0;
    REP(j, 1, n+1){
        ans += dp[n][j][a*j];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    for (int i = 0; i < H; ++i) cin >> c[i];
    int res = 0;
    for (int i = 0; i < (1<<H); ++i) {
        for (int j = 0; j < (1<<W); ++j) {
            int black = 0;
            for (int x = 0; x < H; ++x) {
                for (int y = 0; y < W; ++y) {
                    if ((i>>x)&1) continue; // bitにi番目のフラグが立っているかどうか((bit>>i)&1)
                    if ((j>>y)&1) continue;
                    if (c[x][y] == '#') black++;
                }
            }
            if (black == K) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3612