akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

    vector<int> dp(n+1);

    dp[0]=0;

    for(int i=1; i<=n; i++){
        for(int p6 = 1; p6 <= n; p6*=6){
            if(i - p6 < 0) continue;
            dp[i] = min(dp[i-1]+1, dp[i - p6]+1);
        }
        for(int p9=1; p9 <= n; p9*=9){
            if(i-p9 < 0) continue;
            dp[i] = min(dp[i], dp[i-p9]+1);
        }
    }    
    

    cout << dp[n] << endl;
}

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

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    if(b <= a) {
        cout << "delicious";
    }
    else if(b <= a + x) {
        cout << "safe";
    }
    else
        cout << "dangerous";



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,n;	cin >> h >> n;
  int sum=0;
  for(int i=0;i<n;i++){
    int x;	cin >> x;
    sum+=x;
  }
  if(sum>=h)	cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ll a[105];
int main(){FAST;
cin>>n;
ll sum = 0;
for(ll i=1;i<=n;++i){
  cin>>a[i];
  sum+=a[i];
}
ll avg = sum/n;
ll ans1 = 0,ans2 = 0;
for(ll i=1;i<=n;++i){
  ans1+=(a[i]-avg)*(a[i]-avg);
}
for(ll i=1;i<=n;++i){
  ans2+=(a[i]-avg-1)*(a[i]-avg-1);
}
cout<<min(ans1,ans2);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(auto&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(auto&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(auto&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(auto&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(auto&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto& operator<<(auto& o,TRI<S,T,U>& t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 2005;

int t[MAX_N][MAX_N], a[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            t[i][j] = (s[j] == '#');
        }
    }
    h--, w--;
	rep(i,h){
		rep(j,w){
			a[i][j] = (t[i][j]+t[i+1][j]+t[i][j+1]+t[i+1][j+1])%2;
		}
	}
	rep(i,h){
		t[i][w] = 0;
	}
	rep(i,w){
		t[0][i] = 1^a[0][i];
	}
	for(int i = 1; i < h; i++){
		rep(j,w){
			if(a[i][j] == 0){
				t[i][j] = t[i-1][j] + 1;
			}else{
				t[i][j] = 0;
			}
		}
	}
	int ans = max(h+1, w+1);
    deque<P> deq;
	rep(i,h){
		rep(j,w+1){
			if(deq.empty()){
				deq.push_back(P(t[i][j],j));
				continue;
			}
			P p = deq.back();
			if(p.first < t[i][j]){
				deq.push_back(P(t[i][j],j));
			}else if(p.first > t[i][j]){
				int pos;
				while(!deq.empty() && p.first > t[i][j]){
					pos = p.second;
					ans = max(ans, (p.first+1)*(j-p.second+1));
                    deq.pop_back();
					if(!deq.empty()) p = deq.back();
				}
				deq.push_back(P(t[i][j],pos));
			}
		}
	}
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 39824
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    dp = [[10**10 for _ in range(2**n)] for _ in range(m+1)]
    dp[0][0] = 0
    for i in range(m):
        a,b = map(int,input().split())
        c = list(map(int,input().split()))
        S = 0
        for j in range(b):
            x = pow(2,c[j]-1)
            S |= x
        for j in range(2**n):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        for j in range(2**n):
            dp[i+1][j|S] = min(dp[i+1][j|S],dp[i][j]+a)
    if dp[m][2**n-1] == 10**10:
        print(-1)
    else:
        print(dp[m][2**n-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 76636
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 3100;
const ll mod = 1e9 + 7;
ll dp[maxn][maxn], prefdp[maxn][maxn];
ll n;
string code;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    cin>>code;
    dp[1][1] = 1LL;
    prefdp[1][1] = 1LL;
    for(int i=2;i<=n;i++) {
        for(int j=1;j<=i;j++) {
            if(code[i-2] == '>') {
                dp[i][j] = prefdp[i-1][j-1];
                dp[i][j] %= mod;
            }
            else {
                dp[i][j] = prefdp[i-1][i-1] + mod - prefdp[i-1][j-1];
                dp[i][j] %= mod;
            }
            prefdp[i][j] = prefdp[i][j-1] + dp[i][j];
            prefdp[i][j] %= mod;
        }
    }
    ll result = 0LL;
    for(int i=1;i<=n;i++) {
        result += dp[n][i];
        result %= mod;
    }
    cout<<result<<"\n";
    return 0;
}


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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define ABS(X) ((X)>0?(X):-(X))

#define Q 1000000007

int main(void){
  int n,m;
  int br[100010] = {0};
  long long dp[100010];
  
  cin >> n >> m;
  for (int i=0; i<m; i++){
    int t;
    cin >> t;
    br[t] = 1;
  }
  dp[0] = 1;
  dp[1] = !br[1];
  for (int i=2; i<=n; i++){
    dp[i] = dp[i-1] + dp[i-2];
    dp[i] %= Q;
    if (br[i]) dp[i]=0;
  }
  cout << (dp[n]%Q) << endl;
  return 0;
}

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  while (op != '?') {
    switch(op) {
      case '+':
        cout << a + b << endl;
        break;
      case '-':
        cout << a - b << endl;
        break;
      case '*':
        cout << a * b << endl;
        break;
      case '/':
        cout << a / b << endl;
        break;
    }
    cin >> a >> op >> b;
  }
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
string s;

int main()
{
    cin >> n; cin >> s;

    P left{0, 0}; // {W, E}
    P right{0, 0};
    rep(i, n){
        if(s[i] == 'W') right.fi++;
        else right.se++;
    }

    int ans = right.se;
    if(s[0] == 'E') ans--;
    rep(i, n){
        int cnt = 0;
        if(s[i] == 'W'){
            right.fi--;
            cnt = right.se + left.fi;
            left.fi++;
        }
        else{
            right.se--;
            cnt = right.se + left.fi;
            left.se++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 900
import numpy as np
N, M=map(int, input().split())
ab=np.array([list(map(int, input().split())) for i in range(M)])
ab-=1
ab=ab[np.argsort(ab[:, 1]), :]

counter=1
x=ab[0, 1]
for i in range(1, M):
  if ab[i, 0]<x:
    pass
  else:
    counter+=1
    x=ab[i, 1]
    
print(counter)

Measured memory_bytes: 37916
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int n,m; 
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <tuple>
#include <vector>

template <class... Ts> using tuple_t = std::tuple<Ts...>;
template <class T, class U> using map_t = std::map<T, U>;
template <class T, class U> using pair_t = std::pair<T, U>;
template <class T> using vector_t = std::vector<T>;
template <class T> using set_t = std::set<T>;

int min(const vector_t<int> &nums) {
  int min_ = std::numeric_limits<int>::max();
  for (auto &i : nums)
    if (min_ > i)
      min_ = i;
  return min_;
}

int max(const vector_t<int> &nums) {
  int max_ = std::numeric_limits<int>::min();
  for (auto &i : nums)
    if (max_ < i)
      max_ = i;
  return max_;
}

int main() {
  std::string S;
  std::cin >> S;
  if (S[0] != 'A' || std::isupper(S[1])) {
    std::cout << "WA" << std::endl;
    return 0;
  }
  bool flag = true;
  for (auto c : S.substr(2, S.size() - 3)) {
    if (c == 'C') {
	    if(flag)
	    {
		    flag = false;
	    }
	    else
	    {
		    std::cout << "WA" << std::endl;
		    return 0;
	    }
    }
    if (c != 'C' && std::isupper(c)) {
      std::cout << "WA" << std::endl;
      return 0;
    }
  }

  if (flag || std::isupper(S[S.size() - 1]))
    std::cout << "WA" << std::endl;
  else
    std::cout << "AC" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		final long STACK_SIZE=8*1024*1024;
		new Thread(null, new AOJ1305(), "RUN!", STACK_SIZE).start();
		//new Live5015();
	}
	
	class AOJ1305 implements Runnable{
		int N;
		AOJ1305(){}
		@Override public void run(){
			while(sc.hasNext()){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			HashMap<String,HashSet<String>> groups=new HashMap<String,HashSet<String>>();
			String first="";
			for(int i=0; i<N; i++){
				String line=sc.next();
				String[] gn=line.split(":");
				if(i==0)	first=gn[0];
				String[] mem=gn[1].replaceAll("\\.", "").split(",");
				HashSet<String> member=new HashSet<String>();
				for(String s:mem)member.add(s);
				groups.put(gn[0],member);
			}
			
			HashSet<String> ans=recursion(groups,first);
			System.out.println(ans.size());
		}
		HashSet<String> recursion(HashMap<String,HashSet<String>> groups,String target){
			HashSet<String> group=groups.get(target),newGroup=new HashSet<String>();
			newGroup.addAll(group);
			for(String name:group){
				if(groups.containsKey(name)){
					newGroup.remove(name);
					HashSet<String> ret=recursion(groups,name);
					newGroup.addAll(ret);
				}
			}
			groups.remove(target);
			groups.put(target, newGroup);
			return newGroup;
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    string s;
    ll K;
    set<string> st;
    cin >> s >> K;
    ll N = s.length();
    REP(i, N){
        FOR(j, 1, K + 1){
            if(i + j > N) continue;
            st.insert(s.substr(i, j));
        }
    }
    auto itr = st.begin();
    REP(i, K - 1){
        itr++;
    }
    PRINT(*itr);
    return 0;
}

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

int main() {
	string S;
	cin>>S;
	int count=0;
	for(int i=0;i<S.size();i++){
		if(i%2==0){
			if(S.at(i)=='R'||S.at(i)=='U'||S.at(i)=='D') count++;
		}
		if(i%2==1){
			if(S.at(i)=='L'||S.at(i)=='U'||S.at(i)=='D') count++;
		}
	}
	if(count==S.size())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
a = map(int, raw_input().split())
ret = 0
while True:
	mp = 0
	for i in range(n):
		if a[i] > a[mp]:
			mp = i
	if a[mp] < n:
		break
	c = a[mp] // n
	ret += c
	a[mp] = a[mp] % n
	for i in range(n):
		if i != mp:
			a[i] += c
print ret

Measured memory_bytes: 2692
N = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
if a.uniq.size == 1 && a.uniq[0] == 0
    puts "Yes"
else
    grouped = a.group_by{|a| a}
    if grouped.size == 3 && grouped.inject(0){|memo, (key, val)| memo ^ key} == 0 && grouped.map{|key, val| val.length}.uniq.size == 1
        puts "Yes"
    elsif grouped.size == 2 && grouped.map{|key, val| val.length}.sort[0] * 2 == grouped.map{|key, val| val.length}.sort[1] && grouped.sort_by{|key, val| val.length}[0][0] == 0
        puts "Yes"
    else
        puts "No"
    end
end

Measured memory_bytes: 15784
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, k := iScan(), iScan()
	a := iSScan(n)
	m := make(map[int]int)
	for _, v := range a {
		m[v]++
	}
	x := make([]int, len(m))
	i := 0
	for _, v := range m {
		x[i] = v
		i++
	}
	sort.Ints(x)
	if len(x) > k {
		fmt.Println(sum(x[:len(x)-k]))
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 16108
#include<stdio.h>
signed main(){
    int x,n,i,p[1000];
    scanf("%d %d",&x,&n);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }int f[1000]={},a=0;
    for(i=0;i<n;i++){
        f[p[i]]=1;
    }for(i=1;i<=101;i++){
        if(f[i]==0){
            int ab1,ab2;
            ab1=x-a;
            ab2=x-i;
        if(ab1<0){
            ab1=ab1*-1;
        }if(ab2<0){
            ab2=ab2*-1;
        }if(ab1>ab2){
            a=i;
        }
    }}printf("%d\n",a);
    return(0);
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long int 
#define fi first
#define se second
#define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
#define int long long int
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
int32_t main()
{
 int n;
 cin>>n;
 int a[n];
 forn(i,n)cin>>a[i];
 int ans=0;
 int maxi=0;
 forn(i,n)
 {
  maxi=max(maxi,a[i]);
  if(a[i]<maxi)ans+=abs(a[i]-maxi);
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 5156
import java.util.Scanner;

public class Main{

    public static void main(String args[])throws Exception{

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if ((A*B)%2 != 0) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> v(n - 1);
	bool ed[10][10] = {};
	int x = 0;
	for (ll i = 2; i <= n; i++) {
		v[x] = i;
		x++;
	}
	for (ll i = 0; i < m; i++) {
		ll x, y;
		cin >> x >> y;
		ed[x][y] = ed[y][x] = true;
	}
	ll ans = 0;

	do {
		bool flag = false;
		for (ll i = 0; i < n-1; i++) {
			if (i == 0) {
				if (ed[v[i]][1] == false) {
					flag = true;
					break;
				}
			}else {
				if (ed[v[i]][v[i - 1]] == false) {
					flag = true;
					break;
				}
			}
		}
		if(flag==false){
			ans++;
		}
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}

Measured memory_bytes: 256
numbers = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")
puts numbers[gets.to_i - 1].to_i


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

Measured memory_bytes: 256
def main():
    N,A,B=map(int, input().split())
    k = N // (A + B)
    ans = k * A
    if N - k * (A + B) >= A:
        ans += A
    else:
        ans += N - k * (A + B)
    print(ans)
    return

if __name__ == '__main__':
    main()

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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n;
    cin >> n;
    cout << (1000-(n%1000))%1000;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 101010
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
	ll n,i;
	in2(n,i);
	cout<<n*i<<"\n";

}	
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	

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

int n;
ll k;
int a[200001];
int f[200001];

bool solve(ll x) {
  ll tmp = 0;
  for ( int i = 0; i < n; i++ ) {
    ll res = a[i] - x / f[i];
    if ( res < 0 ) { continue; }
    tmp += res;
  }
  if ( tmp <= k ) { return true; } else { return false; }
}

int main() {
  cin >> n >> k;

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

  sort(a, a+n);
  sort(f, f+n, greater<int>());

  ll l = 0;
  ll r = 1e18;

  for ( int i = 0; i < 150; i++ ) {
    ll m = (r + l) / 2;
    if ( solve(m) ) {
      r = m;
    } else {
      l = m;
    }
  }

  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int modPow(ll a, ll n, ll p) { //繰り返し二乗法 a**n % p
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int choose(int n, int k){
  ll x = 1, y = 1;
  rep(i, k){
    x *= n - i;
    y *= i + 1;
    x %= mod;
    y %= mod;
  }
  y = modPow(y, mod - 2, mod);
  return (x * y) % mod;
}
int main(){
  int n,k;
  cin >> n >> k;
  for(int i = 1; i <= k; i++){
    ll ans = choose(n - k + 1, i);
    ans *= choose(k - 1, i - 1);
    ans %= mod;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
// let coding = begin

#include<bits/stdc++.h>

#define ll long long
#define pb       push_back
#define all(a)   a.begin(), a.end()

using namespace std;
const int MAX = 1e9+9;
const int MIN = -1e9;
const int N= 1e5;
int a,b;
int main(){
  cin >> a >> b;
  cout << abs( (a*b) - (a+b -1) ) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <list>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
long long a,b;
char c;
int main()
{
    fast; 
    cin>>a>>c>>b;
    if (c=='+')
       cout<<a+b<<endl;
    else
       cout<<a-b<<endl;
    return 0;
}

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

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

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

int main() {
  int n;cin>>n;
  vi a(n);cin>>a;
  int sign = 1;
  int ans = 0;
  rep(i,n) {
    ans += sign * a[i];
    sign *= -1;
  }
  cout << ans << " ";
  rep(i,n-1) {
    ans = 2*a[i] - ans;
    cout << ans << " ";
  }
}


Measured memory_bytes: 1792
use std::io::BufRead;
use std::cmp::min;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_c();
}

fn solve_c() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let tiles: Vec<char> = input!(r, String).chars().collect();
    let mut start_w_change_tile = 0;
    let mut start_b_change_tile = 0;

    for (i, c) in tiles.into_iter().enumerate() {
        if i % 2 == 0 {
            if c == '0' {
                start_w_change_tile += 1;
            } else {
                start_b_change_tile += 1;
            }
        } else {
            if c == '0' {
                start_b_change_tile += 1;
            } else {
                start_w_change_tile += 1;
            }
        }
    }
    println!("{}", min(start_b_change_tile, start_w_change_tile))
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>

#define MN 100001

int N, C, K;
int T[MN];

void input(){
	std::cin >> N >> C >> K;
	for( int i = 0; i < N; i++ ){
		std::cin >> T[i];
	}
	std::sort(&T[0], &T[N]);
	return;
}

void run(){
	int num = 1;
	int st = T[0];
	int bus = 0;	//number of buses.
	for( int i = 1; i < N; i++ ){
		if( T[i] > st + K ){
			num = 0;
			bus++;
			st = T[i];
		}
		if( num >= C ){
			num = 0;
			bus++;
			st = T[i];
		}
		num++;
	}
	if( num > 0 ){ bus++; }
	std::cout << bus << std::endl;
	return;
}

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


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

int main() {
  int k;
  int cnt = 1; // 項数
  int r = 7; // 余り

  std::cin >> k;

  // k回調べればいい(数列の余剰の周期性による)
  for (int i = 0; i < k; i++) {
    r = r % k;         // 剰余の計算
    if (r == 0) break; // 割り切れた
    cnt++;             // 次の項
    r = r*10 + 7;      // 次の項の剰余は7をkを法としてこれに等しい
  }

  if (cnt == k+1) std::cout << -1;
  else std::cout << cnt;

  return 0;
}

Measured memory_bytes: 3636
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;

int main() {
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)
    cin>>a[i];
    a[0]=inf;
    int thislen=0,maxlen=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=a[i-1])
        {
            thislen+=1;
            maxlen=max(maxlen,thislen);
        }   
        else thislen=1;
    }  
    cout<<maxlen-1;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int a,b;
	cin >> a >> b;
	cout << (b >= a ? a : a - 1) << endl;
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int ans = 0;
	int N, A, B;
	scanf ("%d %d %d", &N, &A, &B);
	for (int i = 0; i <= N; i++) {
		int digit = 0;
		int aa = i;
		while (aa != 0) {
			digit = digit + aa % 10;
			aa /= 10;
		}
		
		if (digit >= A && digit <= B) {
			ans += i;
		}
//		if (i == 10 || i == 100 || i == 1000 || i == 10000) {
//			if (1 >= A && 1 <= B) {
//				ans += i;	
//			}
//		} else if (i < 10) {
//			if (i >= A && i <= B) {
//				ans += i;
//				}
//		} else if (i > 10 && i < 100) {
//			int Bb = i / 10;
//			int Bbb = i - (Bb*10);
//			int B1 = Bb + Bbb;
//			if (B1 >= A && B1 <= B) {
//				ans += i;
//			}	
//		} else if (i > 100 && i < 1000) {
//			int Cc = i / 100;
//			int Ccc = (i - (Cc*100)) / 10;
//			int Cccc = i - (Cc * 100) - (Ccc * 10);
//			int C1 = Cc + Ccc + Cccc;
//			if (C1 >= A && C1 <= B) {
//				ans += i;
//			}	
//		} else if (i > 1000 && i < 10000) {
//			int D = i / 1000;
//			int Dd = (i - (D*100)) / 100;
//			int Ddd = (i - (D * 1000) - (Dd * 100) / 10);
//			int Dddd = i - (D * 1000) - (Dd * 100) - (Ddd * 10);
//			int D1 = D + Dd + Ddd + Dddd;
//			if (D1 >= A && D1 <= B) {
//				ans += i;
//			}
//		}
	}
	printf ("%d", ans);
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	ll ans = 0;
	for(int i = 1; i < N; i++) {
		if(A[i-1] - A[i] > 0) {
			ans += A[i-1] - A[i];
			A[i] += A[i-1] - A[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4840
import heapq


def solve(m, work_map):
    days = work_map.keys()
    ans = 0
    priority_queue = []

    for day in range(1, m + 1):
        if day in days:
            for value in work_map[day]:
                heapq.heappush(priority_queue, -value)
        if len(priority_queue):
            value = -heapq.heappop(priority_queue)
            ans += value

    return ans


def main():
    n, m = map(int, input().split())

    work_map = {}
    # time O(N)
    for i in range(n):
        day, value = list(map(int, input().split()))
        if day > m:
            continue
        if day in work_map.keys():
            work_map[day].append(value)
        else:
            work_map[day] = [value]

    ans = solve(m, work_map)
    print(ans)


main()


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

int main() {
    int n;
    int a[200001];
    long long int sum=0;
    int max=0;
    int i;
    scanf("%d", &n);
    for (i=0;i<n;i++) scanf("%d", &a[i]);
    for (i=0;i<n;i++){
        if (a[i]>max) max=a[i];
        if (max-a[i]>0) sum+=(max-a[i]);
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 2508
sx,sy,tx,ty=map(int,input().split())
a=tx-sx
b=ty-sy
ans="U"*b+"R"*a+"D"*b+"L"*a+"D"+"R"*(a+1)+"U"*(b+1)+"LU"+"L"*(a+1)+"D"*(b+1)+"R"
print(ans)

Measured memory_bytes: 3064
#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>;

int main() {
  int n;
  cin >> n;
  int c[n];
    
  rep(i, n) c[i] = 0;
  
  int x;
  rep(i, n-1){
    cin >> x;
    c[x-1] += 1;
  }
  
  rep(i, n){
    cout << c[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4416
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)

int n, l;

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

  scan(n>>l);
//  vint s(n);
//  REP(i, n) scan(s[i]);

  if(l<=0 && l-1+n>=0)  cout << (l-1)*n + n*(n+1)/2  << endl;
  else if(l>0) cout << (l-1)*n + n*(n+1)/2 - (l) << endl;
  else  cout << (l-1)*n + n*(n+1)/2 - (l-1+n) << endl;
  return 0;
}


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

struct Edge {
  int to, cost;
};

const int MAXN = 500;
int N, M;
vector<Edge> G[MAXN];
int dp[MAXN];

int rec(int v) {
  int &res = dp[v];
  if(res != -1) return res;
  res = 0;
  if(v == 0) return res;
  for(int i = 0; i < G[v].size(); ++i) {
    res = max(res, rec(G[v][i].to) + G[v][i].cost);
  }
  return res;
}

int main() {
  while(cin >> N >> M) {
    fill(G, G+MAXN, vector<Edge>());
    for(int i = 0; i < M; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      G[b].push_back((Edge){a,c});
    }
    fill(dp, dp+MAXN, -1);
    cout << rec(N-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#define inf 1000000000

using namespace std;

struct edge{
	int to, cap, rev;
	edge(int a, int b, int c){
		to = a, cap = b, rev = c;
	}
};

int V, S, T;
int m, n;
int b[505], r[505];
vector<edge> G[1005];
bool used[1005];

void addedge(int s, int t)
{
	G[s].push_back( edge(t, 1, G[t].size()) );
	G[t].push_back( edge(s, 0, G[s].size() - 1) );
}

int gcd(int a, int b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

int dfs(int v, int t, int c)
{
	if(v == t) return c;
	used[v] = true;
	
	int ret;
	for(int i = 0; i < (int)G[v].size(); i++){
		if(used[G[v][i].to] || G[v][i].cap == 0) continue;
		ret = dfs(G[v][i].to, t, min(c, G[v][i].cap));
		if(ret > 0){
			G[v][i].cap -= ret;
			G[G[v][i].to][G[v][i].rev].cap += ret;
			return ret;
		}
	}
	return 0;
}

int main(void)
{
	while(1){
		cin >> m >> n;
		if(m == 0 && n == 0) break;
		V = m + n;
		S = 0, T = V+1;
		
		for(int i = 1; i <= m; i++) cin >> b[i];
		for(int i = 1; i <= n; i++) cin >> r[i];
		
		for(int i = 0; i <= T; i++) G[i].clear();
		for(int i = 1; i <= m; i++) addedge(S, i);
		for(int i = 1; i <= n; i++) addedge(m+i, T);
		
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= n; j++){
				if(gcd(b[i], r[j]) == 1) continue;
				addedge(i, m+j);
			}
		}
		
		int ret, ans = 0;
		while(1){
			for(int i = 0; i <= T; i++) used[i] = false;
			ret = dfs(S, T, inf);
			if(ret == 0) break;
			ans += ret;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

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

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

int main(){
    int n;
    cin >> n;
    
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout << " " << i;
            continue;
        }
        int x=i;
        while(x!=0){
            if(x%10 == 3){
                cout << " " << i;
                break;
            }
            x/=10;
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count=0;
  
  for(int i=A; i<=B; i++){
    if(i/10000 == i%10 &&  (i/1000)%10 == (i/10)%10){
      count++;
    }
  }
  cout << count << endl;
}

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

  int main() {
    int n, l;
    cin >> n >> l;
    int a = 0;
    int due_1 = 0;
    rep(i, n) {
      due_1 += (l + i);
    }
    int k;
    int j;
    int t = 10000000;
    int ans;
    rep(i,n) {
      k = due_1 - (l + i);
      j = due_1 - k;
      if (j <= 0) {
        j = - j;
      }
      if (t > j) {
        t = j;
        ans = k;
      }
    }
    cout << ans << endl;
    
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
vector<int> f;//father, f[root]=-sz; 
vector<int> d;//depth or dif, d[x]=x.val-f[x].val;
int sz[maxn];
int find(int x){
    if(f[x]<0)return x;
    int tmp=find(f[x]);
    d[x]+=d[f[x]];
    return f[x]=tmp;
}
void init(int n=1){f.clear();f.resize(n,-1);d.clear(),d.resize(n,0);}
int dept(int x){find(x);return d[x];}
void unite(int x,int y,int z=0){//y-x=z
    z+=dept(x)-dept(y);
    x=find(x),y=find(y);
    if(x==y)return;
    if(f[x]<f[y])swap(x,y),z*=-1;
    f[x]+=f[y];
    f[y]=x;
    d[y]=z;
}
int main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,q;
    cin>>n>>q;
    init(n);
    rep(i,1,q){
        int op,x,y,z;
        scanf("%d",&op);
        if(op){
            scanf("%d%d",&x,&y);
            if(find(x)!=find(y))cout<<'?'<<endl;
            else cout<<d[y]-d[x]<<endl;
        }else{
            scanf("%d%d%d",&x,&y,&z);
            unite(x,y,z);
        }
    }
}
/*
DSL_1_B
4 3
0 1 2 1
0 2 3 1
1 1 3


5 6
0 0 2 5
0 1 2 3
1 0 1
1 1 3
0 1 4 8
1 0 4

*/



Measured memory_bytes: 4212
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
  fio;
    string a,b;
    int len;
    cin>>len;
    cin>>a>>b;

    string s;
    for(int i=0;i<len;i++){
        s += a[i];
        s += b[i]; 
    }


    cout<<s<<endl;
  rr;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n*a, b) << endl;
}


Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 100005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    int a[n];
    rep0(i,n) cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    int ans=0;
    ans+=a[0];
    int rem=n-2;
    rep1(i,n-1){
        if(!rem) break;
        if(rem==1){
            ans+=a[i];
            rem--;
        }
        else{
            ans+=2*a[i];
            rem-=2;
        }
    }
    cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}



Measured memory_bytes: 5212
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
l = 0
r = N-1

print(l, flush=True)
tmp = input()
if tmp == "Vacant":
	exit()

print(r, flush=True)
tmp2 = input()
if tmp2 == "Vacant":
	exit()

while 2 < r-l:
	p = l + (r - l)//2//2*2
	print(p, flush=True)

	Output = input()
	if Output == "Vacant":
		exit()
	elif Output == tmp:
		l = p
	elif Output == tmp2:
		r = p

print(((r+l)//2), flush=True)
Output = input()
if Output == "Vacant":
	exit()

Measured memory_bytes: 10004