akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// combination mod prime
// mintが必要
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint c(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[n-k];
  }
  mint f(int n){
    return fact[n];
  }
};

int main(){
    ll n;
    cin >> n;
    vector<ll>a(n+1);
    rep(i,n+1)cin>>a[i];
    vector<ll>cnt(n+1,0);
    rep(i,n+1){
        cnt[a[i]]++;
    }
    ll j;
    rep(i,n+1){
        if(cnt[i]==2)j=i;
    }
    ll x,z;
    rep(i,n+1){
        if(a[i]==j){
            x=i;
            break;
        }
    }
    for(int i=n;i>=0;i--){
        if(a[i]==j){
            z=n-i;
            break;
        }
    }
    combination c(100010);
    for(int i=1;i<=n+1;i++){
        mint ans = c.c(n+1,i);
        ans -= c.c(x+z,i-1);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 6320
s = input()
n = len(s)
check_ls = []
for i in range(n):
    if s[i] != 'x':
        check_ls.append(s[i])
n_check = len(check_ls)
is_kaibun = True
for i in range(n_check//2):
    if check_ls[i] != check_ls[-i-1]:
        is_kaibun = False
if not is_kaibun:
    print(-1)
else:
    num_target = -(-n_check//2)
    not_x_count = 0
    for i in range(n):
        if s[i] != 'x':
            not_x_count += 1
        if not_x_count == num_target:
            center_ind = i
            break
    ans = 0
    #if n_check % 2 ==0:
        #right = center_ind+1
        #left = center_ind
    right = n-1
    left = 0
    while right > left:
        if s[right] == 'x' and s[left] != 'x':
            ans += 1
            left -= 1
        elif s[right] != 'x' and s[left] == 'x':
            ans += 1
            right += 1
        right -= 1
        left += 1
    print(ans)

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

#define TOT 2000001

int main()
{
    int k, x;
    cin >> k >> x;

    for (int i = x - k + 1; i < x + k - 1; i++)
        cout << i << " ";
    
    cout << (x+k-1) << endl;



}


Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{

  ll k;
  ll s[5];

  for (ll i = 0; i < 5; i++)
  {
    cin >> s[i];
  }
  cin >> k;

  for (ll i = 0; i < 5 - 1; i++)
  {
    for (ll j = i + 1; j < 5; j++)
    {
      if (abs(s[i] - s[j]) > k)
      {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int main(){
   int a, b, K;
   cin >> a >> b >> K;
   if(b - a + 1 < 2 * K){
       INC(i, a, b + 1){
           cout << i << endl;
       }
   }else{
       INC(i, a, a + K){
           cout << i << endl;
       }
       INC(i, b + 1 - K, b + 1){
           cout << i << endl;
       }
   }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

typedef struct UnionFind{
    vector<int> rank,par;
    
    void init(int x){
        rep(i,0,x){
            rank.pb(0);
            par.pb(i);
        }
    }
    
    int find(int x){
        if(par[x]==x)return x;
        else return par[x]=find(par[x]);
    }
    
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return ;
        
        if(rank[x]<rank[y])par[x]=y;
        else {
            par[y]=x;
            if(rank[x]==rank[y])rank[x]++;
        }
    }
}UF;

int main(){
    int N,M;
    int ans=0;
    cin>>N>>M;
    vector<int> a(M),b(M);
    rep(i,0,M)cin>>a[i]>>b[i];
    rep(i,0,M){
        UF u;
        u.init(N);
        rep(j,0,M){
            if(i!=j)u.unite(a[j]-1,b[j]-1);
        }
        
        set<int> st;
        rep(j,0,N){
            st.insert(u.find(j));
        }
        if(st.size()>1)ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
 
            String str[] = br.readLine().split("\\s+");
            int array[] = new int[str.length];
 
            for(int i = 0; i < str.length; i++){
                array[i] = Integer.parseInt(str[i]);
            }
 
            Dice dice = new Dice();
            dice.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);
 
 
            str = br.readLine().split("\\s+");
            for(int i = 0; i < str.length; i++){
                array[i] = Integer.parseInt(str[i]);
            }
            Dice dice2 = new Dice();
            dice2.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);
 
            if(dice.equals(dice2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
class Dice{
 
    private int number[];
    private int work[];
    private final String order = "NNNNWNNNWNNNENNNENNNWNNN";
 
    Dice(){
        number = new int[6];
        work = new int[6];
    }
 
 
    public void roll(char dst){
        for(int i = 0; i < 6; i++) work[i] = number[i];
        switch(dst){
        case 'E':
            setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
            break;
        case 'N':
            setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
            break;
        case 'S':
            setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
            break;
        case 'W':
            setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
            break;
        }
    };
 
    public int getTop(){
        return number[0];
    }
 
    public 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;
    }
 
    public boolean equals(Object object){
 
        if(object == this)return true;
        if(object == null)return false;
        if(!(object instanceof Dice))return false;
 
        Dice another = (Dice)object;
 
        boolean FLG;
 
        for(int i = 0; i < order.length(); i++){
            roll(order.charAt(i));
            FLG = true;
            for(int k = 0; k < 6; k++){
                if(this.number[k] != another.number[k]){
                    FLG = false;
                    break;
                }
            }
            if(FLG)return true;
        }
 
        return false;
    }
};


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

using namespace std;

using Int  = int_fast64_t;
using UInt = uint_fast64_t;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

bool sub()
{
    const auto map(cin2vec<UInt>(9));
    const auto N(cin2var<UInt>());
    const auto Bs(cin2vec<UInt>(N));
    vec1<bool> vecBool(9, false);
    for (const auto b : Bs) {
        const auto ite(find(map.begin(), map.end(), b));
        if (ite == map.end()) {
            continue;
        }
        const auto pos = ite - map.begin();
        vecBool[pos] = true;
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[i]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[3 + i]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[6 + i]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[i * 3]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[1 + i * 3]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[2 + i * 3]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[i + i * 3]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    {
        UInt finds = 0u;
        for (auto i = 0u; i < 3u; ++i) {
            if (vecBool[2 - i + i * 3]) ++finds;
        }
        if (finds >= 3u) {
            return true;
        }
    }
    return false;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    if (sub()) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, k;
    cin >> n >> k;
    vector<int32> a(n);
    int32 sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    vector<int32> divisors;
    int32 p = 1;
    while(p * p <= sum){
        if(sum % p == 0){
            if(p * p == sum){
                divisors.pb(p);
            }else{
                divisors.pb(p);
                divisors.pb(sum / p);
            }
        }
        p++;
    }
    sort(ALL(divisors),greater<int32>());
    REP(i,(signed)divisors.size()){
        int32 d = divisors[i];
        vector<int32> r(n);
        REP(i,n){
            r[i] = a[i] % d;
        }
        sort(ALL(r));
        vector<int64> rRuiseki(n + 1);
        rRuiseki[0] = 0;
        REP(i,n){
            rRuiseki[i+1] = rRuiseki[i] + r[i];
        }
        REP(i,n+1){
            int32 minus = rRuiseki[i];
            int32 plus = d * (n - i) - (rRuiseki[n] - rRuiseki[i]);
            if(minus <= k && plus <= k && (plus - minus) % d == 0){
                ANS(d);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

int main(int argc, char** argv)
{
    int r,D,x;
    std::cin >> r;
    std::cin >> D;
    std::cin >> x;

    for(int i=0;i<10;i++)
    {
        x = r*x-D;
        std::cout << x << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int solve(int l, int r, int d) {
    int cnt = 0;
    for (int i = l; i <= r; i ++) {
        if (i % d == 0) cnt ++;
    }

    return cnt;
}

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    cout << solve(l, r, d) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){for(int i=0;i<v.size();++i){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef long long ll;

main(){
	int N,K;
	cin>>N>>K;
	vi a=vi(N);
	cin>>a;
	a<<(int)1e9;
	Sort(a);
	int m;
	for(int l=-1,r=N;m=l+r+1>>1,r-l>1;){
		vi d=vi(K);
		d[0]=1;
		fr(i,N){
			if(i!=m){
				roof(j,K-1,a[i]){
					d[j]|=d[j-a[i]];
				}
			}
		}
		int b=0;
		foor(i,max(0,K-a[m]),K-1){
			b|=d[i];
		}
		(b?r:l)=m;
	}
	cout<<m;
}


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

int main(void)
{
	int i;
	int len;
	int f;
	int n;
	char str[128];
	
	while (fgets(str, 100, stdin) != NULL){
		f = 0;
		n = 0;
		while (1){
			len = strlen(str);
			for (i = 0; i < len; i++){
				if (strncmp(&str[i], "the", 3) == 0){
					f = 1;
				}
				if (strncmp(&str[i], "this", 4) == 0){
					f = 1;
				}
				if (strncmp(&str[i], "that", 4) == 0){
					f = 1;
				}
			}
			if (f == 1){
				break;
			}
			for (i = 0; i < len; i++){
				if (str[i] >= 'a' && str[i] < 'z'){
					str[i]++;
				}
				else if (str[i] == 'z'){
					str[i] = 'a';
				}
			}
			n++;
		}
		printf("%s", str);
	}
	return (0);
}

Measured memory_bytes: 944
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for (int i = 1;;i++){
            int x = sc.nextInt();
            if(x == 0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,x);
        }
    }
}



Measured memory_bytes: 67604
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

int n, t, a[maxn], b[maxn], dp[maxn], p[maxn];

int main() {
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", a + i, b + i);
    p[i] = i;
  }
  sort(p + 1, p + 1 + n, [&](int x, int y) {
    return a[x] < a[y];
  });
  for (int id = 1; id <= n; id++) {
    int i = p[id];
    for (int j = t - 1; j >= 0; j--) {
      dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i <= 7000; i++) ans = max(ans, dp[i]);
  cout << ans;
  return 0;
}

Measured memory_bytes: 384
from collections import deque
s=input()
q=int(input())
sd=deque()
for i in range(len(s)):
    sd.append(s[i])
count=0
for i in range(q):
    que=list(map(str,input().split()))
    if int(que[0])==1:
        count+=1
    else:
        if int(que[1])==1:
            if count%2==0:
                sd.appendleft(str(que[2]))
            else:
                sd.append(str(que[2]))
        else:
            if count%2==0:
                sd.append(str(que[2]))
            else:
                sd.appendleft(str(que[2]))
if count%2!=0:
    sd.reverse()

ans=''.join(sd)
print(ans)

Measured memory_bytes: 8692
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, A: number, B: number } => {
  const [N, A, B] = lines[0].split(' ').map(line => +line)
  const obj = { N, A, B }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N, A, B } = parseLines(lines)
  const answer = N * A < B ? N * A : B
  return `${answer}`

}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        string[] cin = Console.ReadLine().Split();
        int x = int.Parse(cin[0]);
        int y = int.Parse(cin[1]);
        int z = int.Parse(cin[2]);
        Console.WriteLine((x - z) / (y + z));
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(){
  int num,step;
  char S[100001],U[100001];
  int T[100001];
  scanf("%d %d\n",&num,&step);
  scanf("%s",S);
  int Tlen=0,buff;
  for(int i;i<num;){
    buff = S[i];
    int j=0;
    while(S[i]==buff){
      i++;
      j++;
    }
    T[Tlen]=j;
    U[Tlen]=buff;
    Tlen++;
  }
  int max=0,sum,vstep;
  for(int k=0;k<Tlen;k++){
    sum=0;
    if(U[k]=='1'){
      vstep = step*2+1;
    }
    else if(U[k]=='0'&&k==0){
      vstep = step*2;
    }
    else goto skip;
    for(int m=0;m<vstep&&(k+m)<Tlen;m++){
      sum+=T[k+m];
    }
    if(sum>max){
      max=sum;
    }
    skip:;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;i--)
#define ll long long
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,x,y;
int a[N];
ll ans;
int main(){
	scanf("%d\n",&n);
	fo(i,1,n)a[getchar()-'a']++;
	ans=1;
	fo(i,0,26){
		ans=ans*(a[i]+1)%mo;
	}
	ans=(ans+mo-1)%mo;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
M=10**9+7
require"prime"

def extended_euclid_algorithm(a,b)
  d0,x0,y0,d1,x1,y1=a,1,0,b,0,1
  until d1==0
    q=d0/d1
    d0,x0,y0,d1,x1,y1=d1,x1,y1,d0-q*d1,x0-q*x1,y0-q*y1
  end
  [d0,x0,y0]
end

def inverse(a,p)
  d,x,y=extended_euclid_algorithm(a,p)
  x%p
end

#mod pでの組み合わせの数
def mod_combination(n,r,p)
  r=n-r if r>n/2
  return 1 if r==0
  return 0 if n<0
  ret=1
  n.downto(n-r+1){|i|ret = (ret * i) % p}
  r.downto(2){|i|ret = (ret * inverse(i, p)) % p}
  ret
end

def comb(n,r)
  mod_combination(n,r,M)
end

n,m=gets.split.map(&:to_i)
if m==1
  puts 1
  exit
end
pd=m.prime_division
ans=pd.map{|p,r|comb(n+r-1,r)}.inject(:*)%M
puts ans

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

#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

signed main(){
 float n;
 int a,b,c;
  cin >> a >> b >> c;
  
  cout << ((a+b+c)>=22?"bust":"win");
             }


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<ll, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}







void _main() {
        int n, k; cin >> n >> k;
        ll ans = 0;
        for (int a = 1; a <= n; a++) {
                int low = k;
                int high = a - 1;
                if (low > high) {
                        continue;
                }

                int blocks = n / a;
                int rem = n % a;
                ans += blocks * (high - low + 1) + max(0, min(high, rem) - low + 1) - (low == 0);
        }


        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<algorithm>
int main(){
    int n,m,g[9][9],p[8]={1,2,3,4,5,6,7,8},ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            g[i][j]=0;
        }
    }
    for(int i=0;i<m;i++){
        int j,k;
        scanf("%d%d",&j,&k);
        g[j][k]=1;
        g[k][j]=1;
    }
    do{
        int i=0;
        while(i<=n-2){
            if(g[p[i]][p[i+1]]==0)break;
            i++;
        }
        if(i==n-1)ans++;
    }while(std::next_permutation(p+1,p+n));
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100002];
int main()
{
	scanf("%d",&n);
    for(int i=1;i<=n;i++)
    	scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    for(int i=1;i<=n;i++)
        if(i+1>a[i+1]&&a[i]>=i)
		{
            int j=0;
            while(a[j+i+1]==i) j++;
            if((a[i]-i)%2==0&&j%2==0) printf("Second");
            else printf("First");   
    		return 0;
        }
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d.at(i)*d.at(j);
        }
    }
    cout<<ans<<endl;
            
        
}


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

using namespace std;

int N, K;
int vals[102];
bool win[100010];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	win[0] = false;
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> vals[i];
	}
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= N; j++) {
			if (i >= vals[j] && !win[i-vals[j]]) {
				win[i] = true;
			}
		}
		// cout << i << " " << win[i] << endl;
	}
	if (win[K]) {
		cout << "First" << endl;
	}
	else cout << "Second" << endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    for(ll i=1; i>0; i++)
    {
        ll x;
        cin>>x;
        if(x==0) break;
        else
        {
            cout<<"Case"<<" "<<i<<":"<<" "<<x<<endl;
        }
    }
    return 0;
}





Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N,M;
    cin>>N>>M;
    v A(M);
    rep(i,0,M)cin>>A[i];
    ll sum = 0;
    rep(i,0,M)sum += A[i];

    if(sum > N)cout<<-1;
    else cout<<N-sum;
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#define NOT_FOUND -1
int main(){
  int a,n,key,i,n2,count = 0;
  int A[100000];
  int brinarysearch(int,int *,int);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&n2);
  for(i=0;i<n2;i++){scanf("%d",&key);
   a = brinarysearch(n,A,key);
   if(a!=NOT_FOUND)count++;

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

int brinarysearch(int n,int A[],int key){
  int left = 0;
  int right = n,mid;
  while(left<right){
    mid = (left + right) / 2;
	  if(A[mid] == key)
            return mid;
	  else if(key<A[mid])
            right = mid;
        else
	  left = mid + 1;
  }
  return NOT_FOUND;
  
}



Measured memory_bytes: 2088
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

out = ""
for i in range(dy):
  out += "U"
for i in range(dx):
  out += "R"
for i in range(dy):
  out += "D"
for i in range(dx+1):
  out += "L"
for i in range(dy+1):
  out += "U"
for i in range(dx+1):
  out += "R"

out += "DR"

for i in range(dy+1):
  out += "D"
for i in range(dx+1):
  out += "L"

out += "U"

print(out)

Measured memory_bytes: 3064
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (a, b, c, d) = {
    let v: Vec<i64> = read_vec();
    (v[0], v[1], v[2], v[3])
  };

  let (l, h) = (max(a, c), min(b, d));

 let ans =  if l > h { 0 } else { h - l};
 println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    int num[32]={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};
    int k;
    cin >> k;
    cout << num[k-1] <<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	A := getString()
	a := A[0]
	if a >= 'a' && a <= 'z' {
		out("a")
		return
	}
	out("A")
}


Measured memory_bytes: 1772
import sys

INF = 10**9 + 5

N, M, K = map(int, sys.stdin.readline().rstrip().split())
A = [int(x) for x in sys.stdin.readline().rstrip().split()]
B = [int(x) for x in sys.stdin.readline().rstrip().split()]

tmpA = [INF] * (N + 1)
tmpA[0] = 0

cntA = 0
# A だけを読み続けた場合の所要時間を記録
for i in range(1, N + 1):
    tmpA[i] = A[i - 1] + tmpA[i - 1]
    cntA = i
    if tmpA[i] > K:
        break

# print(tmpA, cntA)  # cntA 冊目まで読める

# A を一冊ずつ減らして、最大値を探索
j = 0
vol = 0
tmpB = 0

for i in range(cntA, -1, -1):
    rest = K - tmpA[i]  # 残り時間
    # print(f"A{i} 残時間 : {rest}")
    while j < M + 1:
        # print(f"B {j}冊 {tmpB}分")
        if rest < tmpB:  # 　tmpB が残り時間を超えたら終了
            break
        vol = max(i + j, vol)
        if j >= M:
            break
        tmpB += B[j]  # 超えていなければ新しい本を追加してみる
        j += 1

print(vol)


Measured memory_bytes: 40080
#include<bits/stdc++.h>
#define FR(i,a,b) for(int i=a;i>=b;i--) 
#define FO(i,a,b) for(int i=a;i<=b;i++)
#define FE(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const int N=1005;
int head[N],to[N],nxt[N],f[N],X[N];
int t,n,possible;
void add(int x,int y) {
	nxt[++t]=head[x],head[x]=t,to[t]=y;
}
int tmp[2][5005],rep;
void dfs(int u) {
	if(head[u]==-1) {
		f[u]=0;
		return ;
	}
	int sum=0;
	for(int i=head[u];i!=-1;i=nxt[i]) 
		dfs(to[i]),sum+=X[to[i]]+f[to[i]];
		rep=-1;
	for(int i=head[u];i!=-1;i=nxt[i]) {
		rep++;
		memset(tmp[rep&1],0,sizeof(tmp[rep&1]));
		if(i==head[u]) {
			if(X[to[i]]<=X[u])
				tmp[rep&1][X[to[i]]]=1;
			if(f[to[i]]<=X[u])
				tmp[rep&1][f[to[i]]]=1;
		}
		else {
			FO(j,f[to[i]],X[u]) if(tmp[(rep-1)&1][j-f[to[i]]]) tmp[rep&1][j]=1;
			FO(j,X[to[i]],X[u])	if(tmp[(rep-1)&1][j-X[to[i]]]) tmp[rep&1][j]=1;
		}
	}
	FR(i,X[u],0) if(tmp[rep&1][i]) {
		f[u]=sum-i;return ;
	}
	possible=0;
}
int main() {
//	freopen("data.in","r",stdin);
	memset(head,-1,sizeof(head));
	t=-1;
	cin>>n;
	int fa;possible=1;
	FO(i,2,n) cin>>fa,add(fa,i);
	FO(i,1,n) cin>>X[i];
	dfs(1);
	if(possible) cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
	return 0;
}
/*
40
1 2 1 1 4 5 6 5 9 3 5 4 2 9 2 15 14 7 10 16 11 13 20 2 21 17 23 26 16 26 16 15 30 14 29 28 34 34 26 
2776 2417 1874 4544 730 1108 1387 1071 3369 57 884 3781 4240 573 2630 2105 1530 538 2260 4775 3669 
1131 3512 421 572 4467 167 4460 895 1265 851 1370 2555 967 1979 806 1579 3257 2939 1178 
*/

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
  N, M = map(int, input().split())
  Asum = sum(map(int, input().split()))
  if (N - Asum) < 0:
    print('-1')
  else:
    print(N - Asum)

if __name__ == '__main__':
  main()

Measured memory_bytes: 9488
#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 i, j, k, N, M; cin >> N >> M;
  vector<int> p(M);
  vector<string> s(M);
  map<int, int> map;
  rep (i, M) {
    cin >> p.at(i) >> s.at(i);
    map[--p.at(i)] = 0;
  }
  vector<int> penalty(N, 0);
  int ac = 0, pn = 0;
  rep (i, M) {
    int &m = map[p[i]];
    
     if (m == 0 && s.at(i) == "WA")
      penalty[p[i]] ++;
    if (m == 0 && s.at(i) == "AC"){
      m = 1;
      ac++;
      pn += penalty[p[i]];
    }
  }
  cout << ac << " " << pn << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;

int main(){
	int n, m;
	while(cin>>n >> m){
		if(n == 0 && m == 0) break;
		vi v(n, 0);
		rep(i, n) cin>>v[i];
		sort(all(v));

		int ans = 0;

		for(int i = 0; i < v.size() ; i++){
			auto it = upper_bound(v.begin() + i + 1, v.end(), m - v[i]);
			ans += v.end() - it;
		}

		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3168
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		string S;
		cin >> S;
		if (cin.fail()) break;

		int price = 700;
		if (S[0] == 'o') price += 100;
		if (S[1] == 'o') price += 100;
		if (S[2] == 'o') price += 100;

		cout << price << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long k,i,S=0;
  long a[10000];
  scanf("%ld",&k);
  for(i=0 ; i<=k-1 ; i++){
    scanf("%ld",&a[i]);
    S = S + a[i];
  }
  long min=a[0],max=a[0];
  for(i =1 ;i <= k-1;i++){
  if(a[i] < min){
      min = a[i];
    }
  if(a[i] > max){
      max = a[i];
    }
  }
    printf("%ld %ld %ld\n",min,max,S);
  return 0;
}

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

int main(void){
	
	char masu[10];
	
	while(scanf("%s", masu) != EOF){
		char win='d';
		
		for(int i = 0; i < 3; i++){
			if(masu[i*3] == masu[i*3+1] && masu[i*3+1] == masu[i*3+2] && masu[i*3] != 's'){
				win = masu[i*3];
				break;
			}
			if(masu[i] == masu[i+3] && masu[i+3] == masu[i+6] && masu[i] != 's'){
				win = masu[i];
				break;
			}
		}
		if(win == 'd'){
			if(masu[0] == masu[4] && masu[4] == masu[8]){
				win = masu[0];
			}
			if(masu[2] == masu[4] && masu[4] == masu[6]){
				win = masu[2];
			}
		}
		if(win == 's')win = 'd';
		
		printf("%c\n",win);
		
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		loop : while(true){
			int n = in.nextInt();
			if(n==0) break;
			boolean[][] sch = new boolean[31][n];
			for(int i=0;i<n;i++){
				int m = in.nextInt();
				for(int j=0;j<m;j++){
					sch[in.nextInt()][i] = true;
				}
			}
			long[] tag = new long[n];
			for(int i=0;i<n;i++){
				tag[i] = (1L<<i);
			}
			for(int k=1;k<=30;k++){
				long gather = 0;
				for(int i=0;i<n;i++){
					if(sch[k][i]) gather = gather | tag[i];
				}
				if(gather==(1L<<n)-1){
					System.out.println(k);
					continue loop;
				}
				for(int i=0;i<n;i++){
					if(sch[k][i]) tag[i] = gather;
				}
			}
			System.out.println(-1);
			System.gc();
		}
	}
}

Measured memory_bytes: 61528
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {

  ll N;
  cin >> N;
  string S;
  map<string, int> z;
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    cin >> S;
    sort(begin(S), end(S));
    z[S]++;

    if (z[S] != 1) {
      ans += z[S] - 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>

using namespace std;

typedef pair<int,int> P;//shortest pass,vertex number

const int MAX=100;
const int INF=1<<25;

class edge
{
public:
	int to,cap,cost,rev;
	edge(){}
	edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

int V;
vector<edge> G[MAX];
int h[MAX];
int dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,int cost)
{
	G[from].push_back(edge(to,cap,cost,G[to].size()));
	G[to].push_back(edge(from,0,-cost,G[from].size()-1));
	return;
}

int mincostflow(int s,int t,int f)
{
	int res=0;
	memset(h,0,sizeof(h));
	while(f>0)
	{
		priority_queue<P> Q;
		fill(dist,dist+V,INF);
		dist[s]=0;
		Q.push(P(0,s));
		
		while(!Q.empty())
		{
			P p=Q.top();Q.pop();
			int v=p.second;
			if(dist[v]<p.first*(-1))continue;
			for(int i=0;i<G[v].size();i++)
			{
				edge &e=G[v][i];
				if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to])
				{
					dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
					prevv[e.to]=v;
					preve[e.to]=i;
					Q.push(P(dist[e.to]*(-1),e.to));
				}
			}
		}
		
		if(dist[t]==INF)return -1;
		
		for(int v=0;v<V;v++)h[v]+=dist[v];
		int d=f;
		for(int v=t;v!=s;v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
		f-=d;
		res+=d*h[t];
		
		for(int v=t;v!=s;v=prevv[v])
		{
			edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return res;
}

int main()
{
	int E,F;cin>>V>>E>>F;
	int u,v,c,d;
	for(int i=0;i<E;i++)
	{
		cin>>u>>v>>c>>d;
		add_edge(u,v,c,d);
	}
	cout<<mincostflow(0,V-1,F)<<endl;
	return 0;
}

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

int main()
{
	set<int> a;
	int n, q, tmp, count = 0;
	cin>>n;
	for(int i = 0; i < n; i++)
	{
		cin>>tmp;
		a.insert(tmp);
	}
	cin>>q;
	for(int i = 0; i < q; i++)
	{
		cin>>tmp;
		if(a.find(tmp) != a.end())
		{
			count++;
		}
	} 
	cout<<count<<endl;
} 


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

int main() {
	int n; cin >> n;
	vector<int> mountains(n);
	for (int i = 0; i < n; i++)
	{
		cin >> mountains.at(i);
	}
	
	int maxheight = mountains.at(0);
	int ans = 1;
	for (int i = 1; i < n; i++)
	{
		if (maxheight <= mountains.at(i))
		{
			ans++;
			maxheight = mountains.at(i);
		}
		
	}
	cout << ans << endl;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] Button = new int[N];
            bool[] Checked = new bool[N];

            for (int i = 0; i < N; i++)
            { Button[i] = int.Parse(Console.ReadLine()) - 1; }
            int count = 1;
            int index = 0;
            while (!Checked[index])
            {
                Checked[index] = true;
                index = Button[index];
                if (index == 1) { Console.WriteLine(count); return; }
                count++;
            }
            Console.WriteLine("-1");
            Console.ReadKey();
		}
	}
}


Measured memory_bytes: 15200
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
LL gcd(LL a,LL b)
{
	LL tmp;
	while(b)
	{
		tmp=a;
		a=b,b=tmp%b;
	}
	return a;
}
int main()
{
	LL A,B,C,D;
	int tm;
	scanf("%d",&tm);
	while(tm--)
	{
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		bool f=1;
		if(A<B) f=0;
		else if(D<B) f=0;
		else if(C>=B-1);
		else
		{
			LL E=gcd(B,D);
			if((A-B)/E<(A-C-1)/E) f=0;
		}
		if(f) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 128
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const int INF = 1000000007;
const int N = 30;
int n, m, maxv = -1;
char a[N][N];
int GA[N][N][N][N];

int main() {
	cin >> n >> m;
	memset(a, ' ', sizeof a);
	memset(GA, INF, sizeof GA);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == a[i][j - 1] && a[i][j] == '.')  GA[i][j][i][j - 1] = GA[i][j - 1][i][j] = 1;
			if (a[i][j] == a[i][j + 1] && a[i][j] == '.')  GA[i][j][i][j + 1] = GA[i][j + 1][i][j] = 1;
			if (a[i][j] == a[i + 1][j] && a[i][j] == '.')  GA[i][j][i + 1][j] = GA[i + 1][j][i][j] = 1;
			if (a[i][j] == a[i - 1][j] && a[i][j] == '.')  GA[i][j][i - 1][j] = GA[i - 1][j][i][j] = 1;
		}

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			GA[i][j][i][j] = 0;
	
	for (int ki = 1; ki <= n; ki++)
		for (int kj = 1; kj <= m; kj++) {
			if (a[ki][kj] == '#')
				continue;
			for (int ii = 1; ii <= n; ii++)
				for (int ij = 1; ij <= m; ij++) {
					if (a[ii][ij] == '#')
						continue;
					for (int ji = 1; ji <= n; ji++)
						for (int jj = 1; jj <= m; jj++) {
							if (a[ji][jj] == '#')
								continue;
							if (GA[ii][ij][ji][jj] > GA[ii][ij][ki][kj] + GA[ki][kj][ji][jj]) {
								GA[ii][ij][ji][jj] = GA[ii][ij][ki][kj] + GA[ki][kj][ji][jj];
								GA[ji][jj][ii][ij] = GA[ii][ij][ki][kj] + GA[ki][kj][ji][jj];
							}
						}
				}
					
		}
			

	for (int ii = 1; ii <= n; ii++)
		for (int ij = 1; ij <= m; ij++)
			for (int ji = 1; ji <= n; ji++)
				for (int jj = 1; jj <= m; jj++)
					if (GA[ii][ij][ji][jj] > n*m)
						continue;
					else
						maxv = max(maxv, GA[ii][ij][ji][jj]);
	
	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

string s;
int main(){
	cin >> s;
	int a=s.size();
	char s0 =s[0];
	char sn =s[a-1];
	cout<<s0<<a-2<<sn<<endl;
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=1; i<N; i++) {
			A[i] = sc.nextInt();
			B[A[i]-1]++;
		}
		for(int i=0; i<N; i++) {
			System.out.println(B[i]);
		}

	}

}

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

int N;
long long A[100000], B[100000];
long long deficient_sum = 0, deficient_cnt = 0;
long long surplus[100000];
long long A_sum, B_sum;


int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    A_sum += A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
    B_sum += B[i];
  }

  if(A_sum < B_sum){
    cout << -1 << endl;
    return 0;
  }
  
  for(int i = 0; i < N; i++){
    if(A[i] < B[i]){
      deficient_sum += B[i] - A[i];
      deficient_cnt++;
    }
    surplus[i] = A[i] - B[i];
  }
  int ans = deficient_cnt;
  sort(surplus, surplus + N);
  for(int i = N - 1; i >= 0 && deficient_sum > 0; i--){
    deficient_sum -= surplus[i];
    ans++;
  }
  cout << ans << endl;
}


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

int main(){
    int a,b,c,x;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);
    int count=0;

    for(int ia=0;ia<=10000;ia++){
        if(x<ia*500)break;
        if(a<ia)break;
        for(int ib=0;ib<=10000;ib++){
            if(x<ia*500+ib*100)break;
            if(b<ib)break;
            for(int ic=0;ic<=10000;ic++){
                if(x<ia*500+ib*100+ic*50)break;
                if(c<ic)break;

                if(ia*500+ib*100+ic*50==x)count++;

            }
        }
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 128