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

#define inf 2000000009

typedef long long ll; 

int grid[505][505]; 

struct Shubh{
	int x1,y1,x2,y2; 
};

int main(){
	int h,w; cin>>h>>w; 
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>grid[i][j]; 
		}
	}
	vector<Shubh> ans; 
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(grid[i][j]%2==1){
				ans.push_back({i,j,i,j+1}); 
				grid[i][j]--; 
				grid[i][j+1]++; 
			}
		}
		if(grid[i][w-1]%2==1 && i<h-1){
			ans.push_back({i,w-1,i+1,w-1}); 
			grid[i+1][w-1]++; 
			grid[i][w-1]--; 
		}
	}
	cout<<ans.size()<<endl; 
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].x1+1<<" " <<ans[i].y1+1<<" " <<ans[i].x2+1<<" " <<ans[i].y2+1<<endl; 
	}
}

Measured memory_bytes: 5232
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int n;
vector<int> e[114514];
int dfs(int cur, int par)
{
    int len = e[cur].size();
    if (par != -1) {
        len--;
    }
    vector<int> s;
    for (auto to : e[cur]) {
        if (to == par)
            continue;
        s.push_back(dfs(to, cur));
    }
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    int ans = 0;
    rep(i, s.size())
    {
        int j = s[i];
        ans = max(ans, j + i + 1);
    }
    if (len == 0)
        ans = 0;
    // cout << "CUR= " << cur;
    // cout << "ANS= " << ans << endl;
    return ans;
}
int main()
{
    int b, c;
    cin >> n;
    rep(i, n - 1)
    {
        cin >> b;
        b--;
        c = i + 1;
        e[c].push_back(b);
        e[b].push_back(c);
    }
    cout << dfs(0, -1) << endl;
}


Measured memory_bytes: 15488
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int a,b,c,d;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> a >> b >> c >> d;
  if(abs(c -a) <= d){
    cout << "Yes" << endl;
  }
  else{
    if(abs(b-a) <= d && abs(c-b) <= d){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main(args: Array<String>) {
    val (n, k) = readLongList()
    val res = if (n < k) {
        n.coerceAtMost(k - n)
    } else {
        val a = n % k
        a.coerceAtMost(k - a)
    }
    println(res)
}


Measured memory_bytes: 37680
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) {
    cout <<"Yes"<< endl;
  }
  else if (b == c && b != a) {
    cout <<"Yes"<< endl;
  }
  else if (a == c && a != b) {
    cout <<"Yes"<< endl;
  } else {
    cout <<"No"<< endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
 int a, b, x, res;
 cin>>a>>b>>x;
 res=x-a;
 if(res<0) cout<<"NO";
 else if(res == 0) cout<<"YES";
 else if(res<=b) cout<<"YES";
 else cout<<"NO"; 
}

Measured memory_bytes: 256
while True:
 
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 or j == 0 or j == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
 
    print() #データセットの区切り


Measured memory_bytes: 7000
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int K, N;
  cin >> K >> N;
  
  vector<int> A(N);
  for (int i=0; i<A.size(); i++) {
    cin >> A.at(i);
  }
 
  //家間の距離を算出
  vector<int> B;
  for (int i=1; i<A.size(); i++) {
    B.push_back(A.at(i)-A.at(i-1));
  }
  //最終地点から1点目までの距離を追加
  B.push_back(K-A.at(A.size()-1)+A.at(0));
 
  //ソート後、最大距離は除いて加算
  sort(B.begin(), B.end());
  int dist = 0;
  for (int i=0; i<B.size()-1; i++) dist += B.at(i);
  cout << dist << endl;
}

Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<string>
class DICE {
private:
	 int label[6];
public:
	//?????????????????????
	DICE();
	void RotateLabel(char DIRECTION);
	int ReturnTopLabel(void);
	};
DICE::DICE() {
	for (unsigned int i = 0; i < 6; ++i) {
		std::cin >> label[i];
	}
}
void DICE::RotateLabel(char DIRECTION) {
	if (DIRECTION == 'N') {
		std::swap(label[5], label[4]);
		std::swap(label[4], label[0]);
		std::swap(label[1], label[0]);
	}
	if (DIRECTION == 'S') {
		std::swap(label[1], label[0]);
		std::swap(label[4], label[0]);
		std::swap(label[5], label[4]);


	}
	if (DIRECTION == 'E') {
		std::swap(label[5], label[2]);
		std::swap(label[2], label[0]);
		std::swap(label[0], label[3]);


	}
	if (DIRECTION == 'W') {
		std::swap(label[0], label[3]);
		std::swap(label[2], label[0]);
		std::swap(label[5], label[2]);
	}
}
int DICE::ReturnTopLabel(void) {
	return label[0];
}
int main(void) {
	DICE dice1 = DICE();
	std::string InputAction;
	std::cin >> InputAction;
	for (unsigned int i = 0; i < InputAction.size(); ++i) {
		dice1.RotateLabel(InputAction[i]);
	}
	std::cout << dice1.ReturnTopLabel() << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3220
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

void solve()
{ 
  int a,b,c,d;
  cin >> a >> b >> c>> d;
  int cnt=1;
  while(1)
  {
      if(cnt&1)
      {
          c-=b;
          if(c<=0)
          {
              cout <<"Yes\n";return;
          }
      }
      else
      {
          a-=d;
          if(a<=0)
          {
              cout <<"No\n";return;
          }
      }
      cnt++;
  }
  
   return;
}

signed main()
{
  FAST
  int T=1;
  //  cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3612
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K, kari;
	cin >> N >> K;

	int k = N - K;
	int A[100000];
	char kotae[800000], *it = kotae;

	if (k <= K) {
		rep(i, k) cin >> A[i];
		rep(i, K - k) cin >> kari;
		rep(i, k) {
			cin >> kari;
			if (kari > A[i]) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
		}
	}
	else if (K == 1) {
		int mae;
		cin >> mae;
		rep(i, k) {
			cin >> kari;
			if (kari > mae) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
			mae = kari;
		}
	}
	else {
		rep(i, K) cin >> A[i];
		int kazu = k / K;
		int amari = k % K;
		rep(j, kazu) rep(i, K) {
			cin >> kari;
			if (kari > A[i]) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
			A[i] = kari;
		}
		rep(i, amari) {
			cin >> kari;
			if (kari > A[i]) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
		}
	}

	fwrite(kotae, 1, it - kotae, stdout);


	Would you please return 0;
}

Measured memory_bytes: 4304
#include <iostream>
using namespace std;
 
int main() {
  int N, check, counter;
  check=0;
  counter=0;
  cin >>N;
  int high[N];
  for(int i=0;i<N;i++){
    cin >>high[i];
  }  
  for(int j=1;j<N;j++){
    if(high[j]-high[j-1] < -1){
      check=1;
      goto Fin;
    }
    else if(high[j]-high[j-1] == -1){
      if(counter==0){
        counter = 1;
      }
      else{
        check=1;
        goto Fin;
      }
    }
    else if(high[j]-high[j-1] > 0){
      counter=0;
    }
  }
    
    Fin:
    if(check==0){
     cout <<"Yes" <<endl;
    }
    if(check==1){
     cout <<"No" <<endl; 
    }
  return 0;
  }

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<long long> v;
	for (int i=0; i<n; ++i) {
		long long a;
		cin >> a;
		v.push_back(a);
	}
	long long snuke_ = accumulate(v.begin(), v.end(), (long long) 0);
	long long raccoon = 0;
	long long res = LLONG_MAX;
	for (int i=n-1; i>0; --i) {
		long long a = v[i];
		snuke_ -= a;
		raccoon += a;
		res = min(res, abs(snuke_-raccoon));
	}
	cout << res << endl;
}

Measured memory_bytes: 2420
#!/usr/bin/env ruby

n = gets.chomp.to_i


def search_cake(n)
  f = (100 / 4).floor
  s = (100 / 7).floor
  (0..f).each do |fn|
    (0..s).each do |sn|
      if(fn + sn == 0)
      elsif (n % (fn * 4 + sn * 7) == 0)
        return 'Yes'
      end
    end
  end
  return 'No'
end

result = 'No'
if (n < 4)
  result = 'No'
elsif (n % 4 == 0 || n % 7 == 0)
  result = 'Yes'
else
  result = search_cake(n)
end

puts result

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ll long long
#define MOD 1000000007
#define ull unsigned long long int
#define db double
#define fi first
#define se second
#define pb push_back
#define vec vector<ll>
#define pr pair<ll,ll>
#define pq priority_queue<ll,vector<ll>, compare_queue >
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define GS(s)   string s; getline(cin,s);
#define lll __int128_t
#define endl "\n"
#define Next cout.flush()

struct compare_queue
{
    bool operator()(const ll& a, const ll& b)
    {
        return a>b;
    }
};

ll gcd(ll u,ll v)
{
	if(v==0)
	return u;
	
	else
	return gcd(v,u%v);
}

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2); 
    p = (p * p); 

    return (y%2 == 0)? p : (x * p); 
} 

    // ll power(ll x,ll y){
    //     ll i;
    //     ll ans=1;
    //     for(i=0;i<y;i++){
    //         ans=ans*x;
    //     }
    //     return ans;
    // }


// ll modInverse(int a, int m) 
// { 
//     if(a==1){return 1;}
//     return power(a, m-2, m); 
// } 
  



// // // #define MAX 1000000
// int primes[100009],cnt=0;
// // vector<int> factors[1000009];
// char str[1000009];
// void pre()
// {
//     // calcualting primes
//     int n=100000;
//     for(int i=2; i*i<=n; i++)
//         if(str[i]==0)
//             for(int j=i; j*i<=n; j++)
//                 str[i*j]=1;
//     for(int i=2; i<=n; i++)
//         if(str[i]==0)primes[cnt]=i,cnt++;
// }


// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
// vector<ll> getFactorization(ll x) 
// { 
//     vector<ll> ret; 
//     while (x != 1) 
//     { 
//         ret.push_back(spf[x]); 
//         x = x / spf[x]; 
//     } 
//     return ret; 
// } 

// C:\Users\A\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\lambda


// ll getPow(ll n,ll k){
//     double f=log((double)n);
//     double g=log((double)k);
//     f=f/g;
//     return (ll)f;
// }

void Function(){
ll a,b,c,d;
cin >> a >> b >> c >> d;

ll ans=a*c;
ans=max(ans,a*d);
ans=max(ans,b*c);
ans=max(ans,b*d);

cout << ans << endl;

}


int main(){ 
fast;
ll t=1,i=0,j=0,k,h;
 //pre();
// cin >> t;
for(h=1;h<=t;h++){

Function();

}


return 0;

}

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

using namespace std;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long
#define pii pair<int, int>
#define fi first
#define se second

const int N = 2e5 + 7, inf = 1e9 + 1;

vector<pii> a;
vector<int> rem;
int n, t;

bool cmp(const pii &x, const pii &y)
{
    return x.fi * (y.se + 1) > y.fi * (x.se + 1);
}

int dp[N][33];

signed main()
{
    fastio;
    cin >> n >> t;
    for (int i = 1; i <= n; ++i)
    {
        int x, y;
        cin >> x >> y;
        if (x == 0)
            rem.push_back(y);
        else
            a.push_back({x, y});
    }
    sort(begin(rem), end(rem));
    sort(begin(a), end(a), cmp);
    n = a.size();
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= 32; ++j)
        {
            dp[i][j] = inf;
        }
    }
    for (int i = 0; i <= n; ++i)
    {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= min(i, 32ll); ++j)
            if (i == j)
            {
                dp[i][j] = min({inf, dp[i - 1][j - 1] + 1 + a[i - 1].fi * (dp[i - 1][j - 1] + 1) + a[i - 1].se});
            }
            else
            {
                dp[i][j] = min({inf, dp[i - 1][j], dp[i - 1][j - 1] + 1 + a[i - 1].fi * (dp[i - 1][j - 1] + 1) + a[i - 1].se});
            }
    int maxans = 0;

    for (int j = 0; j <= 32; ++j)
    {
        if (dp[n][j] <= t)
        {
            int res = j, now = dp[n][j];
            for (int i = 0; i < rem.size(); ++i)
                if (now + rem[i] + 1 <= t)
                    now += rem[i] + 1, ++res;
            maxans = max(maxans, res);
        }
    }
    // for (int i = 1; i <= n; ++i)
    // {
    //     for (int j = 1; j <= n; ++j)
    //     {
    //         cout << dp[i][j] << " \n"[j == n];
    //     }
    // }
    cout << maxans;

    return 0;
}

/* input

*/

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L


typedef long long ll;

const ll MOD =1e9+7;

vector<string> vis;

void dfs(string str){
    vis.push_back(str);
    string temp=str;
    for(int i=1;i<str.size();++i){
        if(str[i]!='+'&&str[i-1]!='+'){
            str.insert(i,1,'+');
        }
        if(find(ALL(vis),str)==vis.end()) dfs(str);
        str=temp;
    }
}

ll calc(string str){
    string temp="";
    ll sum=0;
    for(int i=0;i<str.size();++i){
        if(str[i]=='+'){
            sum+=stoll(temp);
            temp="";
            continue;
        }
        else{
            temp+=str[i];
        }
    }
    sum+=stoll(temp);
    return sum;
}

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

    string str;
    cin>>str;
    dfs(str);
    ll sum=0;
    for(auto u:vis){
        sum+=calc(u);
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
from sys import exit
def q(l):
    print("?",end=" ")
    for i in l:
        print(i,end=" ")
    print("")
    ret=input()
    if ret=="-1":
        exit(0)
    return ret=="Red"

n=int(input())
res=[None for i in range(n*2+1)]
if n==1:
    if q([1]):
        res=[None,"R","B"]
    else:
        res=[None,"B","R"]
else:
    a=[i for i in range(1,(n+1)//2)]
    b=[i for i in range((n+1)//2,n+1)]
    c=[i for i in range(n+1,(n+1)//2+n+1)]
    d=[i for i in range((n+1)//2+n+1,n*2+1)]
    ab=q(a+b)
    ac=q(a+c)
    if ab and ac:
        #a red d blue
        toadd=b
        rr=a
        bb=d
    elif ab and not ac:
        #b red c blue
        toadd=a
        rr=b
        bb=c
    elif not ab and ac:
        #c red b blue
        toadd=a
        rr=c
        bb=b
    elif not ab and not ac:
        #d red a blue
        toadd=c
        rr=d
        bb=a
    else:
        pass
    blim=0
    rlim=len(rr)
    while rlim-blim>1:
        en=(blim+rlim)//2
        if q(toadd+rr[:en]+bb[en:]):
            rlim=en
        else:
            blim=en
    arr=toadd+rr[:blim]+bb[blim+1:]
    for i in range(1,2*n+1):
        if i in arr:
            continue
        if q(arr+[i]):
            res[i]="R"
        else:
            res[i]="B"
    half=[]
    rcnt=0
    bcnt=0
    for i in range(1,2*n+1):
        if res[i]=="R":
            if rcnt<(n-1)//2:
                half.append(i)
                rcnt+=1
        elif res[i]=="B":
            if bcnt<(n-1)//2:
                half.append(i)
                bcnt+=1
    for i in range(1,2*n+1):
        if res[i]==None:
            ret=q(half+[i])
            if ret:
                res[i]="R"
            else:
                res[i]="B"
print("!",end=" ")
for c in res[1:]:
    print(c,end="")
print("",flush=True)

Measured memory_bytes: 3660
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	const int mod = 1e9+7;
	const int maxn = 1111;
	inline int qpow(R int a,R int b){
		R int ret=1;
		for(;b;b>>=1){
			if(b&1)ret=1ll*ret*a%mod;
			a=1ll*a*a%mod;
		}
		return ret;
	}
	int f[maxn][maxn];
	int n,a,b,c,d;
	int fac[maxn],ifac[maxn]; 
	int main(){
		read(n);read(a);read(b);read(c);read(d);
		for(R int i=*fac=1;i<maxn;++i){
			fac[i]=1ll*i*fac[i-1]%mod;
		}
		ifac[maxn-1]=qpow(fac[maxn-1],mod-2);
		for(R int i=maxn-2;~i;i--){
			ifac[i]=1ll*(i+1)*ifac[i+1]%mod;
		}
		for(R int i=0;i<maxn;++i){
			if(ifac[i]!=qpow(fac[i],mod-2))Debug;
		}
		f[a-1][0]=1;
		for(R int i=a;i<=b;++i){
			for(R int j=0;j<=n;++j){
				if(!f[i-1][j])continue;
				(f[i][j]+=f[i-1][j])%=mod;
				for(R int k=c,limk=Min((n-j)/i,d)+1;k<limk;++k){
					(f[i][j+i*k]+=1ll*f[i-1][j]*fac[n-j]%mod*ifac[n-j-i*k]%mod*qpow(ifac[i],k)%mod*ifac[k]%mod)%=mod;
				}
			}
		}
		cout<<f[b][n];
		return 0;
	}
}
int main(){
	return Night::main();
}

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

void solve(std::vector<std::string> s){
    cout << (char)toupper(s[0][0]) << (char)toupper(s[1][0]) << (char)toupper(s[2][0]) << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::vector<std::string> s(3);
    for(int i = 0 ; i < 3 ; i++){
        std::cin >> s[i];
    }
    solve(std::move(s));
    return 0;
}


Measured memory_bytes: 256
/*input
2
4
5 7 2
4 6 1
1 5 2
6 8 1
4
1 2 1
1 2 1
1 2 1
1 2 1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  string str;
  cin >> str;
  int ans = 0;
  for (int i = 0; i < n; ) {
    char c = str[i];
    while (i < n && str[i] == c) i++;
    ans++;
  }
  cout << ans << endl;

  return 0;
} 


Measured memory_bytes: 512
# https://atcoder.jp/contests/abc082/tasks/abc082_b

import itertools
import collections
import bisect

def main():
    s = input()
    t = input()
    s = ''.join(sorted(s))
    t = ''.join(sorted(t, reverse=True))
    # print(s)
    # print(t)
    print("Yes" if s < t else "No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define cont continue;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define mp make_pair
#define endl '\n'


typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7
const double PI = 3.14159265358979323846264;
const pi steps[] = {{1, 0}, {0, 1}, { -1, 0}, {0, -1}, {1, -1}, {1, 1}, { -1, -1}, { -1, 1}}; //for (auto [dx,dy] : steps)
//const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

// template<typename... T>
// void read(T&... args) {
// 	((cin >> args), ...);
// }

// template<typename... T>
// void write(T&&... args) {
// 	((cout << args << " "), ...);
// }

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define sz(a) (int)((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define ip_arr(a,n)   for(int i=0;i<n;i++) cin>>a[i];
#define op_arr(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<"\n"; cout<<endl;
#define fill_arr(arr,n,i) fill(arr,arr+n,i)
#define fill_vec(v,n,i) fill(v.begin(),v.begin()+n,i);
#define sortv(a) sort(a.begin(),a.end())

void fio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void setUpLocal()
{
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Documents/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Documents/CP/output.txt", "w", stdout);
#else
#define cerr if(0) cerr
#endif
}

const int maxN = (int)1e6 + 7;
// vi gp[gp_size];
// int vis[gp_size];
// int cnt[gp_size];

void solve()
{

	int n, k; cin >> n >> k;
	vi v(n);
	ip_arr(v, n);

	int dp[n]; // cost of reaching n

	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);


	for (int pos = 2; pos < n; pos++)
	{
		//int cost1 = dp[i - 1] + abs(v[i] - v[i - 1]); //prevCostToReach(i-1) + newCost
		//int cost2 = dp[i - 2] + abs(v[i] - v[i - 2]);
		int minCost = INF;
		for (int i = 1; i <= k and (pos - i) >= 0 ; i++)
		{
			int curCost = dp[pos - i] + abs(v[pos] - v[pos - i]);
			//deb(curCost);
			minCost = min(minCost, curCost);
		}

		dp[pos] = minCost;
	}

	cout << dp[n - 1] << endl;

}

int32_t main()
{
	fio();
	//setUpLocal();
	return solve(), 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

typedef struct _mou{
	ll h,l;
}mou;

int main(){
	int n;
	cin >> n;
	
	if(n == 1){
		ll t,a;
		cin >> t >> a;
		if( t == a ) cout << 1 << endl;
		else cout << 0 << endl;
		ret 0;
	}

	vector<mou> vt(n);

	

	rep(i,0,n){
		ll t;
		cin >> t;
		if( i == 0 ){
			vt[i].h = t;
			vt[i].l = t;
		}
		else{
			if( vt[i-1].h < t ){
				vt[i].h = t;
				vt[i].l = t;
			}
			else{
				vt[i].h = t;
				vt[i].l = 1;
			}
		}
	}

	/*
	cout << "vt" << endl;
	cout << "h:";
	rep(i,0,n) cout << vt[i].h << " ";
	cout << endl;
	cout << "l:";
	rep(i,0,n) cout << vt[i].l << " ";
	cout << endl;
	*/
	vector<mou> va(n);

	ll tmp[n];
	rep(i,0,n) cin >> tmp[i];
	
	rrep(i,n-1,0){
		ll a;
		a = tmp[i];

		if( i == n-1 ){
			va[i].h = a;
			va[i].l = a;
		}
		else{
			if( va[i+1].h < a ){
				va[i].h = a;
				va[i].l = a;
			}
			else{
				va[i].h = a;
				va[i].l = 1;
			}
		}
	}

	/*
	cout << "va" << endl;
	cout << "h:";
	rep(i,0,n) cout << va[i].h << " ";
	cout << endl;
	cout << "l:";
	rep(i,0,n) cout << va[i].l << " ";
	cout << endl;
	*/

	vector<mou> v(n);
	rep(i,0,n){
		if( vt[i].h == vt[i].l ){
			if( va[i].h < vt[i].h ){
				cout << 0 << endl;
				ret 0;
			}
			v[i].h = vt[i].h;
			v[i].l = vt[i].l;
		}
		else if(va[i].h == va[i].l){
			if( vt[i].h < va[i].h ){
				cout << 0 << endl;
				ret 0;
			}
			v[i].h = va[i].h;
			v[i].l = va[i].l;
		}
		else{
			v[i].h = min( vt[i].h , va[i].h );
			v[i].l = 1;
		}
	}
	
	/*
	cout << "v" << endl;
	cout << "h:";
	rep(i,0,n) cout << v[i].h << " ";
	cout << endl;
	cout << "l:";
	rep(i,0,n) cout << v[i].l << " ";
	cout << endl;
	*/

	ll ans = 1;
	rep(i,0,n){
		ans *= v[i].h - v[i].l + 1;
		ans %= mod;
	}

	cout << ans << endl;

	ret 0;
}

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

int main() {
    string S;
    cin >> S;
    int A = 0;
    int B = 0;

    if (S.at(0) == '0') {
        if (S.at(1) != '0') {
            A += 1;
        }
    } 

    if (S.at(0) == '1') {
        if (S.at(1) == '0' || S.at(1) == '1' || S.at(1) == '2'){
            A += 1;
        }
    }
    

    if (S.at(2) == '0') {
        if (S.at(3) != '0') {
            B += 1;
        }
    } 

    if (S.at(2) == '1') {
        if (S.at(3) == '0' || S.at(3) == '1' || S.at(3) == '2') {
            B += 1;
        }
    }

    if (A == 0 && B == 0) {
        cout << "NA" << endl;
    }
    if (A == 0 && B == 1) {
        cout << "YYMM" << endl;
    }
    if (A == 1 && B == 0) {
        cout << "MMYY" << endl;
    }
    if (A == 1 && B == 1) {
        cout << "AMBIGUOUS" << endl;
    }
}


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

#include <string>

int main(int argc, char const *argv[])
{
  string s;
  cin >> s;
  int cnt = 0;
  if(s[0] == 'R'){
    cnt++;
    if(s[1] == 'R'){
      cnt++;
      if(s[2] == 'R'){
        cnt++;
      }
    }
  }
  else{
    if(s[1] == 'R'){
      cnt++;
      if(s[2] == 'R'){
        cnt++;
      }
    }
    else{
      if(s[2] == 'R'){
        cnt++;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	int r, d, x;
 	cin >> r >> d >> x;
 	vector<int> ans;
 	ans.push_back(r*x-d);
 	for (int i = 1; i < 10; i++){
 		ans.push_back(r*ans[i-1]-d);
 	}
 	for (int i = 0; i < 10; i++){
 		cout << ans[i] << endl;
 	}
 	return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    //printf("%d %d\n",(c+b-1)/b , (a+d-1)/d);
    if((c+b-1)/b <= (a+d-1)/d) cout << "Yes" << endl;
    else cout << "No" << endl;
}	 

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;



int main(){

    long a,b,gcd;
    cin >> a >> b;
    if(b>a){
        int tmp = b;
        b = a;
        a = tmp;
    }
    while(b!=0){
        int tmp2 = a;
        a = b;
        b = tmp2%b;
        // cout << a << " " << b << endl;
    }

    cout << a << endl;

    return 0;
}



Measured memory_bytes: 3084
import math

numbers = []
n = raw_input()
for i in range(int(n)):
    input_num = raw_input()
    numbers.append(int(input_num))

count = 0
for num in numbers:
    prime_frag = True
    for i in range(2, int(math.sqrt(num)) + 1):
        if num % i == 0:
            prime_frag = False
            break
    if prime_frag:
        count += 1
print count

Measured memory_bytes: 6940
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<string>
using namespace std;
 
int main(void){
  string n;
  cin>>n;
  int sum=0,num=stoi(n);
  for(int i=0;i<n.length();i++){
    sum+=n[i]-'0';
  }
  if(num%sum==0) 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 p[52];
   for (int i=1;i<=n;i++)
   cin>>p[i];
   int sum=0;
   for (int i=1;i<=n;i++)
       if (p[i]!=i) sum++;
    if (sum==0||sum==2)
      cout<<"YES"<<endl;
      else 
      cout<<"NO"<<endl;
   return 0;
}


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


#define INF 1000000000000

signed main() {
   int n,q;
   cin>>n;
   int a[n];
   rep(i,n)cin>>a[i];
   cin>>q;
   int m[q];
   rep(i,q)cin>>m[i];
   vector<string>ans(q);
   rep(i,q){ans[i]="no";}
   for(int bit=0;bit<(1<<n);++bit){
     int sum=0;
     rep(i,n){
       if(bit & (1<<i)){
         sum+=a[i];
       }
     }
     rep(j,q){if(sum==m[j]){ans[j]="yes";}}
   }
   rep(i,q){
     cout<<ans[i]<<endl;
   }
}



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

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

    long long b[n-1];

    for(long long i = 0; i < n-1; i++){
        cin >> b[i];
    }

    long long sum = 0;
    for(long long i = 0; i < n; i++){
        if(i == 0){
            sum += b[i];
            continue;
        }

        if(i == n-1){
            sum += b[i-1];
            continue;
        }

        sum += min(b[i-1], b[i]);
    }
    cout << sum << endl;
    return 0;
}

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

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int a,b,c;scanf("%d%d%d",&a,&b,&c);
   int sum=a;
   for(int i = 0;i < 100000;i++){
      if(sum%b==c){
         //printf("%d %d %d %d\n",a,b,c,a*i%b);
         printf("YES\n");
         return 0;
      }
      sum+=a;
   }
   printf("NO\n");
   return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A == B){
    if(A == C){
      printf("No");
      return 0;
    }
   	else{
      printf("Yes");
      return 0;
    }
  }
  if(A == C){
    if(A==B){
      printf("No");
      return 0;
    }
    else{
      printf("Yes");
      return 0;
    }
  }
   if(B == C){
    if(A == B){
      printf("No");
      return 0;
    }
    else{
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <vector>

using namespace std;

int main() {

	long n, t;
	cin >> n >> t;

	long ba = 0;
	long stop = 0;
	long start = 0;
	long sum = 0;
	for (long i = 0; i < n; i++) {
		long a;
		cin >> a;

		if (start<=a && a <= stop) {
			stop = a + t;
		}
		else {
			sum += stop - start;
			start = a;
			stop = a + t;
		}

	}
	sum += stop - start;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  ll A, B, C;
  while (cin >> A >> B >> C) {
    ll res = min(A + B + 1, C) + B;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#define max_T 50
#define max_P 10

using namespace std;

int cmp(const void *,const void *);

int main(void){
	for(int M,T,P,R;cin >> M >> T >> P >> R,M;){
		int solve[max_T][3]={0};
		for(int i=0;i<T;i++)
			solve[i][0]=i+1;

		int p_min[max_T][max_P]={0};
		for(int m,t,p,j,i=0;i<R&&cin >> m >> t >> p >> j;i++){
			p_min[t-1][p-1]+=j?20:m;
			if(!j){
				solve[t-1][1]++;
				solve[t-1][2]+=p_min[t-1][p-1];
			}
		}

		qsort((void *)solve,T,sizeof(solve[0]),cmp);

		for(int i=0;i<T;i++)
			cout << solve[i][0] << (i<T-1?solve[i][1]!=solve[i+1][1]||solve[i][2]!=solve[i+1][2]?",":"=":"");
		cout << endl;
	}
}

int cmp(const void *a,const void *b){
	int *s[2]={(int *)a,(int *)b},ret;

	if(s[0][1]>s[1][1])
		ret=-1;
	else if(s[0][1]<s[1][1])
		ret=1;
	else
		if(s[0][2]<s[1][2])
			ret=-1;
		else if(s[0][2]>s[1][2])
			ret=1;
		else
			ret=s[0][0]>s[1][0]?-1:1;

	return ret;
}

Measured memory_bytes: 1180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int tmp = Integer.parseInt(sc.next());
            a[i] = tmp;
        }
        int start = n;
        int ans = 0;
        int i = 0;
        while (start > 0) {
            ans++;
            if (i == 0) {
                start -= k;
            } else {
                start -= k - 1;
            }
            i++;
        }
        System.out.println(ans);
    }
}

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

const int N = 100005;
const long long INF = 1e18;

int n, m;
int l[N], r[N], c[N];
vector <int> lef[N], rig[N];
long long smallest[N];
long long dis[N];

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

    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> l[i] >> r[i] >> c[i];
        lef[l[i]].push_back(i);
        rig[r[i]].push_back(i);
    }
    
    multiset <long long> ms;
    for (int i = 1; i <= n; ++i) {
        for (int &id : rig[i-1]) {
            ms.erase(ms.find(smallest[id]));
        }
        if (i != 1) {
            if (!ms.empty()) {
                dis[i] = *(ms.begin());
            } else {
                dis[i] = INF;
            }
        }
        for (int &id : lef[i]) {
            smallest[id] = min(INF, dis[i] + c[id]);
            ms.insert(smallest[id]);
        }
    }

    if (dis[n] >= INF) {
        cout << -1 << endl;
    } else {
        cout << dis[n] << endl;
    }
}

Measured memory_bytes: 13824
#include <iostream>
#include <vector>

int main(void){
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<char>> A(H + 2, std::vector<char>(W + 2, '#'));

    for (int i=1; i<H+1; ++i){
        for(int j=1; j<W+1; ++j){
            char a;
            std::cin >> a;
            A.at(i).at(j) = a;
        }
    }

    for (int i=0; i<H+2; ++i){
        for (int j=0; j<W+2; ++j){
            std::cout << A.at(i).at(j);
        }
        std::cout << std::endl;
    }

    return 0;
}


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

using namespace std;

#define endl '\n'

int main(){

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

  int l,r,d;

  cin >> l >> r >> d;

  l--;

  cout << (r/d) - (l/d) << endl;

  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s, t;
	cin >> s >> t;
	t.erase(t.size() - 1);
	if (s == t) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll X, Y;
    cin >> X >> Y;
    ll now = X;
    ll ans = 0;
    while (now <= Y) {
        now *= 2;
        ans++;
    }

    cout << ans << endl;
}

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

int main(){
    long long H,W,x,y;
    cin >> W>>H>>x >> y;
    cout <<setprecision(10)<< (long double) (H* W)/2.0 << " ";
    if(2*x==W&&2*y==H){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
const int maxn = 1e5 + 10;
int p[maxn], q[maxn], r[maxn];
int cmp(int &x, int &y)
{
    return x > y;
}
int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    for (int i = 1; i <= a; i++)
        cin >> q[i];
    for (int i = 1; i <= b; i++)
        cin >> p[i];
    for (int i = 1; i <= c; i++)
        cin >> r[i];
    sort(q + 1, q + 1 + a, cmp);
    sort(p + 1, p + 1 + b, cmp);
    sort(r + 1, r + 1 + c, cmp);
    vector<int> v;
    for (int i = 1; i <= x; i++)
        v.push_back(q[i]);
    for (int i = 1; i <= y; i++)
        v.push_back(p[i]);
    sort(v.begin(), v.end());
    int len = v.size();
    int cnt = 0;
    for (int i = 1; i <= c; i++)
    {
        if (r[i] > v[i - 1])
            v[i - 1] = r[i];
        else
            break;
    }
    ll ans = 0;
    for (int i = 0; i < v.size(); i++)
        ans += v[i];
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;


const int tam=100005;
const ll MOD=1000000007;
ll inv[tam];
ll fac[tam];
ll finv[tam];
int is[tam];

void prec(){
    inv[1]=1;
    fac[0]=fac[1]=1;
    finv[1]=finv[0]=1;
    int i;
    fi(i,2,tam){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll)i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll nck(int x,int y){
    if(y>x) return 0;
    return fac[x]*(finv[y]*finv[x-y]%MOD)%MOD;
}

int  main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[tam];
    int l,r;
    f(n+1){
        cin>>a[i+1];
        if(is[a[i+1]]!=0){
            l=is[a[i+1]];
            r=i+1;
        }
        is[a[i+1]]=i+1;
    }
    prec();
//    make();
    f(n+1){
        ll ans=nck(n+1,i+1);
        ans-=nck(l+n-r,i);
        ans=(MOD+(ans%MOD))%MOD;
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
    int H, N;
    cin >> H >> N;
    vector<int>A(N), B(N);
    for (int i = 0; i<N; i++) {
        cin >> A[i] >> B[i];
    }
    vector<vector<int>> data(N + 1, vector<int>(H + 1, 2147483647));
    for (int i = 0; i<N; i++) {
        for (int j = 0; j <= H; j++) {
            if (j - A[i]<=0) {
                data[i + 1][j] = min(data[i][j], B[i]);
            }
            else {
                data[i + 1][j] = min(data[i][j], data[i + 1][j - A[i]] + B[i]);
            }
        }
    }

    cout << data[N][H] << endl;
    return 0;
}

Measured memory_bytes: 39424
n,k,q = map(int,input().split())
points = []
for i in range(n):
	points.append(k-q)
for i in range(q):
	points[int(input())-1]+=1
for i in range(n):
	if points[i]>0:
		print("Yes")
	else:
		print("No")

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

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();
            return X >= 30 ? "Yes" : "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans=0;
    rep(i,k){
        ans+=a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        System.out.println(solve(in));
        
      }
      
      public static String solve(Scanner in) {
        int A= in.nextInt();
        int B = in.nextInt();
        int C= in.nextInt();

        Map<Integer, Integer> checker = new HashMap<>();
        checker.put(A, checker.getOrDefault(A, 0) + 1);
        checker.put(B, checker.getOrDefault(B, 0) + 1);
        checker.put(C, checker.getOrDefault(C, 0) + 1);

        for (int c: checker.keySet()) {
            if (checker.get(c) == 2) return "Yes";
        }
        return "No";
      }
      
    
}

Measured memory_bytes: 21588