akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


int main(void){

    int l,k;
    cin>>l>>k;

    vvll dp(l+20,vll(3,0));
    
    dp[1][0]=1;
    dp[k][2]=1;
    for(int i=0;i<=l;i++){
        dp[i+1][1]+=dp[i][0];
        dp[i+1][0]+=dp[i][1];
        dp[i+k][2]+=dp[i][1];
        dp[i+1][1]+=dp[i][2];
    }
    ll ans=0;
    rep(i,l+1){
        ans+=dp[i][0];
        // ans+=dp[i][1];
        ans+=dp[i][2];
    }
    fin(ans);
    // rep(i,l+1)cout<<dp[i][0]<<" ";
    // cout<<endl;
    // rep(i,l+1)cout<<dp[i][1]<<" ";
    // cout<<endl;
    // rep(i,l+1)cout<<dp[i][2]<<" ";
    // cout<<endl;

}


Measured memory_bytes: 3176
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int N;
	cin >> N;

	int ans;
	ans = N % 1000;
	if(ans!=0)
		ans = 1000 - ans;

	cout << ans;

	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 3616
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = Math.max(a, b);
        int d = Math.min(a, b);
        int out = 0;
        out += c;
        out += Math.max(c - 1, d);
        System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 27056
M=10^9+7;n,k=readline()|>split.|>x->parse(Int,x);j=isqrt(n);let x=c=[(i->n÷i-n÷(i+1)).(1:n÷j-1);fill(1,j)];print((i->x=cumsum(reverse(x)).*c.%M).(1:k)[k][end])end

Measured memory_bytes: 293508
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    VI a1(n), a2(n);
    REP(i, n){
        int a;
        cin >> a;
        a1[i] = a;
        a2[i] = a;
    }

    ll ans1 = 0;
    REP(i, n - 1){
        int sum = a1[i] + a1[i + 1];
        if(sum > x){
            a1[i + 1] -= sum - x;
            ans1 += (ll)(sum - x);
            if(a1[i + 1] < 0){
                a1[i] += a1[i + 1];
                a1[i + 1] = 0;
            }
        }
    }

    cout << ans1 << "\n";
    // ll ans2 = 0;
    // FORR(i, n - 1, 1){
    //     int sum = a2[i] + a2[i - 1];
    //     if(sum > x){
    //         a2[i - 1] -= sum - x;
    //         ans2 += (ll)(sum - x);
    //         if(a2[i - 1] < 0){
    //             a2[i] += a2[i - 1];
    //             a2[i - 1] = 0;
    //         }
    //     }
    // }
    //
    // cout << min(ans1, ans2) << endl;
    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  //int dig;
  rep(i, 30){
    N /= K;
    if(N == 0){
      //dig = i+1;
      cout << i+1 << endl;
      break;
    }
  }
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 19541921608536647, base = 61;
    unsigned long N;
    cin >> N;
    vector<unsigned long> s;
    s.reserve(N);
    {
        string S;
        cin >> S;
        transform(S.begin(), S.end(), back_inserter(s), [](auto i) -> unsigned long{return i - 97;});
    }
    const auto f = [&MOD, &base, &N, &s](unsigned long x) -> bool{
        unsigned long h{0}, c{MOD - 1};
        for(unsigned long i = 0; i != x; ++i){
            ((h *= base) += s[i]) %= MOD;
            (c *= base) %= MOD;
        }
        unordered_set<unsigned long> st;
        deque<unsigned long> dq{h};
        for(unsigned long i = 0; i + x != N; ++i){
            dq.push_back(((h *= base) += c * s[i] + s[i + x]) %= MOD);
            if(dq.size() > x){
                st.insert(dq.front());
                dq.pop_front();
            }
            if(st.count(h))return true;
        }
        return false;
    };
    unsigned long L = 0, R = N / 2 + 1;
    while(L + 1 < R){
        auto M = (L + R) / 2;
        (f(M) ? L : R) = M;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define nn 408
void add(int &x,int y){
	x=(x+y)%mod;
}
int qpow(int x,int y=mod-2){
	int res=1;while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
int fort(int a,int A,int b,int B){
	int ans=0;
	add(ans,a*qpow(b,A/a));
	add(ans,b*qpow(a,B/b));
	add(ans,-a*b);
	return ans;
}
int A,B,C,a,b,c,ans;
void foltest(){
	add(ans,a*qpow(fort(b,B,c,C),A/a));
	add(ans,b*qpow(fort(a,A,c,C),B/b));
	add(ans,c*qpow(fort(b,B,a,A),C/c));
	add(ans,-a*b%mod*qpow(c,(A/a)*(B/b)));
	add(ans,-a*c%mod*qpow(b,(A/a)*(C/c)));
	add(ans,-b*c%mod*qpow(a,(C/c)*(B/b)));
	add(ans,a*b%mod*c);
}

int f[nn],rf[nn];
int cc(int x,int y){
	if(x<y) return 0;
	return f[x]*rf[y]%mod*rf[x-y]%mod;
}
int solve(){
	rf[0]=f[0]=1;for(int i=1;i<nn;i++) f[i]=f[i-1]*i%mod,rf[i]=qpow(f[i]);
	int ans=0;
	
	for(int p=1;p<=A/a;p++) for(int q=1;q<=B/b;q++){
		if(p==A/a and q==B/b) continue;
		int t=C/c;t=qpow(qpow(b,p)+qpow(a,q)-1,t)-qpow(qpow(a,q),t)-qpow(qpow(b,p),t)+1;t%=mod;
		t=t*cc(A/a,p)%mod*cc(B/b,q)%mod;
		int extra=0;
		for(int i=0,ff=1;i<=A/a-p;i++,ff=-ff){
			int res=cc(A/a-p,i);
			res=res*qpow(qpow(c,A/a-p-i)-1,B/b-q);
			add(extra,ff*res);
		}
		add(ans,t*extra%mod*c);
	}
	
	
	return ans*a%mod*b%mod;	
}

signed main(){
	cin>>a>>b>>c>>A>>B>>C;
	if(A%a or B%b or C%c) return puts("0")*0;
	foltest();
	add(ans,solve());
	ans%=mod;ans+=mod;cout<<ans%mod;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  string X;
  cin>>X;
  stack<char> st;
  st.push(X[0]);
  for(int i=1;i<X.length();i++){
    if(X[i]=='S') st.push(X[i]);
    else{
      if(!st.empty()&&st.top()=='S') st.pop();
      else st.push(X[i]);
    }
  }
  cout<<st.size()<<endl;
  return 0;
}



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


template <typename Cost = int> class Edge{
public:
  int from,to;
  Cost cost;
  Edge() {}
  Edge(int to, Cost cost): to(to), cost(cost){}
  Edge(int from, int to, Cost cost): from(from), to(to), cost(cost){}

  Edge rev() const {return Edge(to,from,cost);}
  
  friend std::ostream& operator<<(std::ostream &os, const Edge &e){
    os << "(FROM: " << e.from << "," << "TO: " << e.to << "," << "COST: " << e.cost << ")";
    return os;
  }
};

template <typename T> using Graph = std::vector<std::vector<Edge<T>>>;
template <typename T> using Tree = std::vector<std::vector<Edge<T>>>;

template <typename C, typename T> void add_edge(C &g, int from, int to, T w){
  g[from].emplace_back(from, to, w);
}

template <typename C, typename T> void add_undirected(C &g, int a, int b, T w){
  add_edge(g, a, b, w);
  add_edge(g, b, a, w);
}


template <typename F>
struct FixPoint : F{
  explicit constexpr FixPoint(F &&f) noexcept : F(std::forward<F>(f)){}

  template <typename... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) make_fix_point(F &&f){
  return FixPoint<F>(std::forward<F>(f));
}

template <typename F>
static inline constexpr decltype(auto) make_fix_point(F &f){
  return FixPoint<F>(std::forward<F>(f));
}


const int INF = 1 << 25;


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

  Tree<int> tree(N);
  for(int i = 1; i < N; ++i){
    int P; std::cin >> P;
    add_edge(tree, P-1, i, 1);
  }

  std::vector<int> X(N);
  for(int i = 0; i < N; ++i) std::cin >> X[i];

  std::vector<int> dp1(N), dp2(N);

  auto f =
    [&](auto &f, int cur) -> bool{
      for(auto &e : tree[cur]){
        if(not f(e.to)) return false;
      }

      std::vector<int> m(5001, INF);
      m[0] = 0;

      for(auto &e : tree[cur]){
        std::vector<int> temp(5001, INF);

        for(int i = 0; i <= 5000; ++i){
          if(i+dp1[e.to] <= 5000) temp[i+dp1[e.to]] = std::min(temp[i+dp1[e.to]], m[i] + dp2[e.to]);
          if(i+dp2[e.to] <= 5000) temp[i+dp2[e.to]] = std::min(temp[i+dp2[e.to]], m[i] + dp1[e.to]);
        }

        swap(m, temp);
      }

      int a = INF;

      for(int i = 0; i <= X[cur]; ++i){
        a = std::min(a, m[i]);
      }

      if(a == INF){
        return false;
      }

      dp1[cur] = X[cur];
      dp2[cur] = a;
      
      return true;
    };
    
  bool ans = make_fix_point(f)(0);

  std::cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << "\n";

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        private void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var h = cin.ReadInt;
            var ans = (a + b) * h / 2;
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 13268
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  string S; cin >> S;

  deque <char> deq;
  for (int i = 0; i < S.length(); i++){
    deq.push_back(S[i]);
  }
  
  int Q; cin >> Q;
  int Reverse = 0;
  for (int i = 0; i < Q; i++){
    int T; cin >> T;
    if (T == 1){
      Reverse = 1 - Reverse;
      continue;
    }
    int F; char C; cin >> F >> C;
    F--;

    if (Reverse == F){
      deq.push_front(C);
    }else{
      deq.push_back(C);
    }
  }
  
  if (Reverse == 0){
    while (!deq.empty()){
      cout << deq.front(); deq.pop_front();
    }
    cout << endl;
  }else{
    while (!deq.empty()){
      cout << deq.back(); deq.pop_back();
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int read(){
	char c;int num,f=1;
	while(c=getchar(),!isdigit(c))if(c=='-')f=-1;num=c-'0';
	while(c=getchar(), isdigit(c))num=num*10+c-'0';
	return f*num;
}
double a,b,c;
int main()
{
	a=read();b=read();
	b=b/2;
	c=a+b;
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,n;
    int N,M,sum1,sum2;

    scanf("%d %d",&N,&M);

    sum1 = 1;
    sum2 = 1;

    for(i=N-1;i<=N;i++){
        sum1 = sum1*i;
    }  
    sum1 = sum1/2.0;

    for(i=M-1;i<=M;i++){
        sum2 = sum2 * i;
    }
    sum2 = sum2/2.0;

    printf("%d\n",sum1+sum2);
    return 0;
}




        


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

int main() {
	int a;

	cin >> a;

	switch (a % 10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
		break;
	}
}

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

using namespace std;
typedef long long int ll;
int main() 
{

ll r;
cin>>r;

long double a = (2.0)*(3.1415926535)*(r);
    
    cout.setf(ios::fixed,ios::floatfield);
    cout.precision(10);
    
cout<<a;

    

    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }
 
 
 
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i) cin>>a[i];
  int mx=0,mn=INT_MAX;
  for(int i=0;i<n;++i){
    mx=max(a[i],mx);
    mn=min(a[i],mn);
  }
  cout<<mx-mn<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int N, L;
  cin >> N >> L;
  string s[N];
 
  for (int i = 0; i < N; i++) cin >> s[i];
  sort(s, s + N);
  for (int i = 0; i < N; i++) cout << s[i];
  cout << endl;
}

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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S secon

int main(int argc, char const *argv[]) {
  int a,b; std::cin >> a >> b;
  if (a < 10 && b < 10 && a > 0 && b > 0 ) std::cout << a * b << '\n';
  else std::cout << -1 << '\n';
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;

bool check(const vector<int>& A, int k) {
  int N = A.size();
  ll tmp = 0LL;
  REP(i,k + 1) tmp += A[i];
  for(int i = k + 1; i < N; ++i) {
    if(tmp * 2 >= A[i]) {
      tmp += A[i];
    }else{
      return false;
    }
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];
  sort(ALL(A));

  int lb = 0, ub = N;
  while(ub - lb > 1) {
    int mid = (lb + ub) / 2;
    if(check(A, mid)) ub = mid;
    else lb = mid;
  }
  int res;
  if(check(A, lb)) {
    res = N - lb;
  }else{
    res = N - ub;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int n,m,i;
  int a[102], sum = 0 ,count = 0;

  scanf("%d %d", &n,&m);
  for(i=0; i<n; i++)
  {
    scanf("%d", &a[i]);
    sum += a[i];
  }

  for(i=0; i<n; i++)
  {
    if(a[i]*4*m >= sum)
      {count++;}
  }

  if(count >= m)
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 1616
H,W=[int(i) for i in input().split(" ")]
Ch, Cw=[int(i)+1 for i in input().split(" ")]
Dh,Dw=[int(i)+1 for i in input().split(" ")]
S=[[False for i in range(W+4)],[False for i in range(W+4)]]
for i in range(H):
    S.append([False,False]+[j=='.' for j in input()]+[False,False])
S+=[[False for i in range(W+4)],[False for i in range(W+4)]]

def check(h,w,island_num):
    assert S[h][w]
    block[h][w]=island_num
    if S[h-1][w] and block[h-1][w]==-1:
        check(h-1,w,island_num)
    if S[h+1][w] and block[h+1][w]==-1:
        check(h+1,w,island_num)
    if S[h][w-1] and block[h][w-1]==-1:
        check(h,w-1,island_num)
    if S[h][w+1] and block[h][w+1]==-1:
        check(h,w+1,island_num)

block=[]
for i in range(H+4):
    block.append([-1 for j in range(W+4)])

island_num=0

for h in range(H+4):
    for w in range(W+4):
        if S[h][w] and block[h][w]==-1:
            check(h,w,island_num)
            island_num+=1


neighbor={}
for island in range(island_num):
    neighbor[island]=set()


for h in range(2,H+2):
    for w in range(2,W+2):
        if block[h][w]!=-1:
            for y in range(h-2,h+3):
                for x in range(w-2, w+3):
                    if block[y][x]!=-1 and block[h][w]!=block[y][x]:
                        neighbor[block[h][w]].add(block[y][x])


start=block[Ch][Cw]
goal=block[Dh][Dw]
assert start!=-1
assert goal!=-1



dist=[10**10 for i in range(island_num)]
dist[start]=0

nexts=[start]
while True:
    _nexts=[]
    for n in nexts:
        for neigh in neighbor[n]:
            assert neigh!=-1
            if dist[neigh]>dist[n]+1:
                _nexts.append(neigh)
                dist[neigh]=dist[n]+1
    nexts=set(_nexts)
    if len(nexts)==0:
        break

if dist[goal]==10**10:
    print(-1)
else:
    print(dist[goal])


Measured memory_bytes: 153920
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, a[MAXN];
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	int sum = 0;
	for (int i = 1; i <= n + 1; i++)
		sum += abs(a[i] - a[i - 1]);
	for (int i = 1; i <= n; i++)
		writeln(sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1]));
	return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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=1e18;

int main()
{
    ll n;
    cin >> n;
    ll m=n;
    ll sum=0;
    while(m){
        sum+=m%10;
        m/=10;
    }
    if(n%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

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

signed main(){
  string A,B,C;
  cin>>A>>B>>C;
  char N='a';
  bool EMP=true;
  string win="";
  while(EMP){
    if(N=='a'){
      if(A.size()==0){
        EMP=false;
        win+='A';
        break;
      }
      N=A[0];
      A.erase(A.begin()+0);
    }
    if(N=='b'){
      if(B.size()==0){
        EMP=false;
        win+='B';
        break;
      }
      N=B[0];
      B.erase(B.begin()+0);
    }
    if(N=='c'){
      if(C.size()==0){
        EMP=false;
        win+='C';
        break;
      }
      N=C[0];
      C.erase(C.begin()+0);
    }
  }
  cout<<win<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int h,n,sum=0;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	if(sum>=h) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
import copy
B = copy.deepcopy(A)
A = sorted(A)
for i in range(N):
    num = B[i]
    if num != A[-1]:
        print(A[-1])
    else:
        print(A[-2])

Measured memory_bytes: 97936
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();
            int x1 = num[0];
            int y1 = num[1];
            int x2 = num[2];
            int y2 = num[3];

            int xnum = x1 - x2;
            int ynum = y1 - y2;

            int x3 = x2 + ynum;
            int y3 = y2 - xnum;
            int x4 = x3 + xnum;
            int y4 = y3 + ynum;

            Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
        }
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    string ans = "APPROVED";
    for (int i=0; i<N; i++) {
        if (A[i]%2==0) {
            if (A[i]%3!=0 and A[i]%5!=0) {
                ans = "DENIED";
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n;

	std::cin >> n;
	
	vll c(n), s(n), f(n);
	vll x(n+1,0);
	rep(i, 1, n) {
		std::cin >> c[i] >> s[i] >> f[i];
		x[i] += c[i] + s[i];
		rep(j, 1, i) {
			if (s[i] > x[j]) {
				x[j] = s[i] + c[i];
			}
			else {
				ll cnt = ((x[j] - s[i]) / f[i]);
				if ((x[j] - s[i]) % f[i] != 0) {
					cnt++;
				}

				x[j] = s[i] + cnt*f[i] + c[i];
			}
		}
	}

	repeq(i, 1, n) {
		std::cout << x[i] << endl;
	}

	return 0;
}


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

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;

    if(a == b && b ==c)
        cout << "1" << endl;
    else if( (a==b && b !=c) || (b==c && c !=a ) || (c==a && a !=b ))
        cout << "2" << endl;
    else
        cout << "3" << endl;
   return 0;
}

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


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		ArrayList<String> list = new ArrayList<String>();
		for(int i=0; i<num;i++)
			list.add(scan.next());
		scan.close();
		InsertionSort insSort = new InsertionSort(num);
		insSort.loadSequence((String[])list.toArray(new String[0]));
		insSort.sort();
		System.out.println(insSort);
//ss.loadSequence((String[])list.toArray(new String[0]));
	}

}

class InsertionSort extends SortingNumbers{
	public InsertionSort(int n){
		super(n);
	}

	@Override
	public void sort(){
		for(int i=1; i<this.length;i++){
			System.out.println(this);
			comparable key = sortList.get(i);
			int j=i-1;
			for(; j>=0 ;j--){
				if(sortList.get(j).compValue()<key.compValue())
					break;
				sortList.set(j+1,sortList.get(j));
			}
			sortList.set(j+1, key);
		}
	}
}

class SelectionSort extends SortingNumbers{
	public SelectionSort(int n){
		super(n);
	}
	@Override
	public void sort(){
		for(int i=0; i<this.length;i++){
			int minIndex=i;
			for(int j=i; j<this.length;j++){
				if(sortList.get(j).compValue()<sortList.get(minIndex).compValue())
					minIndex = j;
			}
			if(i!=minIndex)
				swap(i,minIndex);
		}
	}	
}


interface comparable{
	int compValue();
}
class numbers implements comparable{
	Integer num;
	public numbers(String str){
		num = Integer.parseInt(str);
	}
	@Override
	public int compValue(){
		return num;
	}
	@Override
	public String toString(){
		return num.toString();
	}
}
class SortingNumbers extends Sorting{
		public SortingNumbers(int n){
		super(n);
	}
	@Override
	public void loadSequence(String[] str){
		for(int i=0; i<this.length;i++)
			sortList.add(new numbers(str[i]));
	}
	@Override
	public void sort(){};
}

class cards implements comparable{
	char type;
	Integer number;
	public cards(String str){
		type = str.charAt(0);
		number = Integer.parseInt(str.substring(1,str.length()));		
	}
	public int compValue(){
		return number;
	}
	@Override
	public String toString(){
		return type + number.toString();
	}
}
abstract class Sorting{
	int swapTimes;
	int length;
	ArrayList<comparable> sortList;
	public Sorting(int n){
		swapTimes=0;
		length=n;
		sortList = new ArrayList<comparable>();
	}
	
	@Override
	public String toString(){
		String tmp = "";
		for(int i=0; i<length; i++)
			tmp = tmp + " " + sortList.get(i);
		return tmp.trim();
	}
	void swap(int i, int j){
		swapTimes++;
		comparable tmp = sortList.set(i,sortList.get(j));
		sortList.set(j,tmp);
	}
	abstract public void loadSequence(String[] str);
	abstract public void sort();
}

Measured memory_bytes: 40824
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	int s=0;
	cin>>a>>b>>c>>d;
	if(a>=b)
	s+=b;
	else
	s+=a;
	if(c>=d)
	s+=d;
	else
	s+=c;
	cout<<s;
	return 0;
}

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

typedef long long ll;
using namespace std;

ll mod=1e9+7;

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int flag;
int main(){
    io();
    string s;
    cin >> s;
    
    int n = s.size();
    if(n % 2) {
        cout << "No";return 0;
    }
    else {
        for(int i = 0; i < n; i++) {
            if(i % 2 and s[i] == 'i')
                continue;
            else if(i % 2 == 0 and s[i] == 'h')  continue;
            else
                flag = 1;
        }
    }
    if(flag)    cout << "No";
    else    cout << "Yes";


}


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

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

char s[11];

int main(void){
	string in;
	cin >> in;
	int i = 0;
	for(char c : in){
		if(c == 'B'){
			s[i-1] = '\0';
			if(i > 0)
				i--;
		}else{
			s[i] = c;
			i++;
		}
	}
	cout << s << endl;
	return 0;
}


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


int main(int argc, char const *argv[])
{	
	string s;
	cin>>s;
	// if (s[0]='?'){s[0]='D';}
	for(int i=0;i<s.length();++i){
		if(s[i]=='?'){
			s[i]='D';
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
 
using namespace std;
 
using ll=long long;
 
const ll maxn=100005;
 
ll dp[101][maxn+1];
 
int main()
{
  	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  
    ll n,W;
    cin>>n>>W;
    vector<pair<ll,ll>>v;
    for(int i=0;i<n;i++)
    {
        ll w,va;
        cin>>w>>va;
        v.push_back({w,va});
    }
 
    for(ll j=1;j<=maxn;j++)
    {
        dp[0][j]=(ll)(1e18);
    }
 
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=maxn;j++)
        {
 
            if(j>=v[i-1].second)
 
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1].second]+v[i-1].first);
 
            else
 
                dp[i][j]=dp[i-1][j];
 
        }
    }
 
    ll ans=0;
 
    for(ll j=1;j<=maxn;j++)
    {
        if(dp[n][j]<=W)
            ans=max(ans,j);
    }
 
    cout<<ans<<endl;
}

Measured memory_bytes: 79232
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int a, b, c;
int t[5];

int main() {
	while(scanf("%d %d %d", &a, &b, &c) != EOF) {
		t[1] = a, t[2] = b, t[3] = c;
		sort(t + 1, t + 4);
		printf("%d\n", t[1] + t[2]);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
LL a,b,c,k;
int main() {
  ios::sync_with_stdio(false);
  cin>>a>>b>>c>>k;
  LL d=0;
  if(k>=a)k-=a,d+=a;
  else return cout<<k,0;
  if(k>=b)k-=b;
  else return cout<<d,0;

  d-=min(k,c);
  cout<<d;
 	return 0;
}

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

int main(){
    int H,W = 0;
    cin >> H >> W;
    int ans = 0;
    for(int i = 0; i < H; i++){
        string S;
        cin >> S;
        for(auto c:S){
            if(c=='#'){
                ++ans;
            }
        }
    }
    if(ans == H+W-1){
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << 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 x = sc.nextInt();
		int y = sc.nextInt();

		if(y%2==0) {
			if(x*4 >= y && x*2 <= y){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 27072
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			System.out.println(Math.max(A + B, Math.max(A + (A - 1), B + (B - 1))));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
  int X, A, n;

  scanf("%d", &X);
  scanf("%d", &A);
  if (X < A)
  {
    n = 0;
  }else
  {
    n = 10;
  }
  
  printf("%d", n);
  return 0;
}


Measured memory_bytes: 128
from sys import stdin

def main():
    N, H, W = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ans = 0
    for a, b in AB:
        ans += a >= H and b >= W
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3316
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  int n ;
  cin >> n  ; 
  string s ;
  cin >> s ;
  char c ;
  for(int i=0;i<s.size();i++){
    c = ((s[i]+n)<='Z' ? s[i]+n : s[i]+n-('Z'-'A'+1));
	printf("%c",c) ;
  }
   printf("\n") ;
  
//cout << char(s[0]+1) <<  s[0]+3 << endl ; 


 return 0 ;
}  


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int bingo[][] = new int[3][3];
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				bingo[i][j] = scan.nextInt();
			}
		}
		
		int n = scan.nextInt();
		for(int h=0;h<n;h++) {
			int in_num = scan.nextInt();
			for(int i=0;i<3;i++) {
				for(int j=0;j<3;j++) {
					if(bingo[i][j] == in_num) {
						bingo[i][j] = -1;
					}
				}
			}
		}
		
		for(int i=0;i<3;i++) {
			if(bingo[i][0] == -1 && bingo[i][1] == -1 && bingo[i][2] == -1) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		
		for(int i=0;i<3;i++) {
			if(bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i] == -1) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		
		if((bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] == -1) || (bingo[2][0] == -1 && bingo[1][1] == -1 && bingo[2][0] == -1)) {
			System.out.println("Yes");
			System.exit(0);
		}
		
		System.out.println("No");
		
	}
	
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define loop(n) for(int i=0; i<n; i++)
int n,m,x;
vector<int> A[(int)15];
int C[(int)15];
int maxsum=1e10;
int sum;
int check[(int)20]={0};
void func(int index)
{
     if(index==n)
     {
          bool che=true;
          for(int i=0;i<m;i++)
          {
               if(check[i]<x)
               {
                    che=false;
                    break;
               }
          }
          if(che)
          {
               maxsum=min(sum,maxsum);
               //cout<<sum<<"\n";
               return;
          }
          else{
               return;
          }
     }
     else
     {
          for(int i=index;i<n;i++)
          {
               sum+=C[i];
               for(int j=0;j<m;j++)
	          {
	               check[j]+=A[i][j];
	          }
	          func(i+1);
	          sum-=C[i];
	          for(int j=0;j<m;j++)
	          {
	               check[j]-=A[i][j];
	     
               }
               func(i+1);
          }
     }
     return;
}
void solve()
{
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
	     cin>>C[i];
	     for(int j=0;j<m;j++)
	     {
	          int a;
	          cin>>a;
	          A[i].pb(a);
	     }
	}
	
	for(int i=0;i<n;i++)
	{
	     sum=C[i];
	     for(int j=0;j<m;j++)
	     {
	          check[j]+=A[i][j];
	     }
	     func(i+1);
	     for(int j=0;j<m;j++)
	     {
	          check[j]-=A[i][j];
	     }
	}
	if(maxsum!=1e10)
	cout<<maxsum;
	else cout<<"-1";
	return;
}
int32_t main() 
{ 
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0; 
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll a,b,n;
  cin>>a>>b>>n;
  ll x=min(n,b-1);
  x=(a*x)/b;
  cout<<x;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int cnt = N;
  vector<int>b(N);
  vector<int>ans;
  for ( int i = 0; i < N; i++ ) cin >> b[i];

  while(1) {

    int x = -1;
    for ( int i = b.size()-1; i >= 0; i-- ) {
      if ( b[i] <= cnt && b[i] == i+1 ) {
	x = b[i];
	ans.push_back(b[i]);
	b.erase(b.begin()+i);
	cnt--;
	break;
      }
    }
    if ( x == -1  ) {
      cout << -1 << endl;
      return 0;
    }
    if ( b.size() == 0 ) break;
  }
  reverse(ans.begin(),ans.end());
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
string S;
  cin >>S;
  bool answer=false;
  if(S.at(0)=='9') {
answer=true;
  }
if (S.at(1) =='9') {
answer=true;
}
  if(answer) {
cout <<"Yes" << endl;
  }
else {
cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000100
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
int h[100100];
int dp[100100];
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++)cin >> h[i];
	for(int i=0;i<N;i++)dp[i]=INF;
	dp[0]=0;
	for(int i=1;i<N;i++){
		for(int j=1;j<=K;j++){
			if(i-j>=0)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];
int cal[110];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    cin>>S+1;

    for(int i=1;i<=n;i++){
        if(S[i]=='R')cal[0]++;
        else if(S[i]=='G')cal[1]++;
        else cal[2]++;
    }

    for(int i=1;i<=n;i++){

        for(int j=1;j<i;j++){
            if((i+j)>n)break;
            if(S[i+j]==S[i-j])continue;
            if((S[i+j]^S[i])&&(S[i-j]^S[i])){
                cnt++;
            }
        }
    }


    ll res = cal[0];

    res*=cal[1];
    res*=(ll)cal[2];


    res-=cnt;

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL A, B, C, K;

int main(void) {
    cin >> A >> B >> C >> K;
    cout << (A - B) * (K % 2 ? -1 : 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using ll=long long int;

ll n,a,b;

int main() {
    std::cin>>n>>a>>b;
    if((a<=b&&n>1)||(a==b&&n==1))
        std::cout<<b*(n-1)+a-a*(n-1)-b+1;
    else
        std::cout<<0<<std::endl;
    return 0;
}

Measured memory_bytes: 256