akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,b;
    cin >> n>> k;
    int sum=0;
    for(int i=0;i<n;i++){
        cin >>b;
        int distA = 2 * b;
        int distB = 2 * (k-b);
        if (distA > distB){
            sum += distB;
        }else{
            sum += distA;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A,B,C,D,E;
int main() {
	cin>>A>>B>>C>>D>>E;
	int R=0;
	if(A>0)R=(B-A)*E;
	if(A<0)R=(0-A)*C+D+B*E;
	if(A==0)R=D+B*E;

	cout<<R<<endl;


	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <deque>

using namespace std;

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

	deque <int> d;
	int n;
	string cmd;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> cmd;
		if (cmd == "insert"){
			int x;
			cin >> x;
			d.push_front(x);
		}
		else if (cmd == "delete"){
			int x;
			cin >> x;
			for (deque<int>::iterator i = d.begin(); i != d.end(); i++){
				if (*i == x){
					d.erase(i);
					break;
				}
			}
		}
		else if (cmd == "deleteFirst"){
			d.pop_front();
		}
		else{
			d.pop_back();
		}
	}
	for (deque<int>::iterator i = d.begin(); i != d.end() - 1; i++){
		cout << *i << " ";
	}
	cout << d.back() << endl;

return 0;
}

Measured memory_bytes: 5312
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N, M;
    cin >> N >> M;
    vec<vec<pair<int, int>>> G(N, vec<pair<int, int>>());
    rep(i, M) {
        int L, R, D;
        cin >> L >> R >> D;
        --L, --R;
        G[L].push_back({R, D});
        G[R].push_back({L, -D});
    }
    vec<int> Dist(N, (int)-1e9);
    bool ans = true;


    function<void(int, int, int)> dfs = [&](int i, int par, int d) {
        Dist[i] = d;
        for (auto e : G[i]) {
            int next = e.first;
            int dist = e.second;
            if (next == par) {
                if (Dist[next] != d + dist) ans = false;
                continue;
            }
            if (Dist[next] == (int)-1e9) dfs(next, i, d + dist);
            else if (Dist[next] != d + dist)
                ans = false;
        }
    };

    rep(i, N) {
        if (Dist[i] != (int)-1e9) continue;
        dfs(i, -1, 0);
    }

    cout << ((ans) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  DV(Pif,int,3,N,0);
  rep(i,0,N)cin >> Pif[0][i] >> Pif[1][i] >> Pif[2][i];
  rep(i,0,101)rep(j,0,101){
    map<int,int>mp;
    rep(k,0,N)if(Pif[2][k]!=0)mp[abs(i-Pif[0][k])+abs(j-Pif[1][k])+Pif[2][k]]++;
    if(mp.size()==1){
      flag=1;
      for(auto v:mp)num=v.first;
      rep(k,0,N)if(Pif[2][k]!=max(0LL,num-abs(i-Pif[0][k])-abs(j-Pif[1][k])))flag=0;
      if(flag){
        cout << i << " " << j << " " << num << endl;
        return 0;
      }
    }
  }
}


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

int main(){
	string a,b ;
	cin >> a >> b ;
	string s ;
	if(a.size()<b.size()) s = "LESS" ;
	else if(a.size()>b.size()) s = "GREATER" ;
	else if(a<b) s = "LESS" ;
	else if(a>b) s = "GREATER" ;
	else s = "EQUAL" ;
	cout << s << endl ;
}


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

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
    map<int,int> ma;
    REP(i,0,N) ma[A[i]]++;
    bool c=false;
    for(auto x : ma){
        if(x.second>1) c=true;
    }
    if(c) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

     if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(int n){
ll ans = 1 ;
for(int i = 1 ; i <= n ; ++i)
    ans *= i ;
return ans ;
}
int main()
{
    FastInputOutput() ;
    int n ;
    cin >> n ;
    ll ans = n * 800 ;
    ll t = n / 15 ;
    t *= 200 ;
    cout << ans - t << endl ;

}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 20592
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   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) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int MOD = (int)1e9 + 7;

inline int mul(int a, int b) {
   return int(1ll*a*b % MOD);
}
inline int add (int a, int b) {
   return (a + b)%MOD;
}

struct Mat {
   int n;
   static const int mxn = 55;
   int M[mxn][mxn];

   Mat(int n_) {
      n = n_;
      for (int i = 0; i < n; ++i)
         for (int j = 0; j < n; ++j)
            M[i][j] = 0;
   }

   Mat operator*(const Mat &other) {
      Mat prod(n);
      for (int i = 0; i < n; ++i)
         for (int j = 0; j < n; ++j)
            for (int k = 0; k < n; ++k)
               prod.M[i][j] = add(prod.M[i][j], mul(M[i][k], other.M[k][j]));
      return prod;
   }

   Mat pow(ll k) {
      Mat waste(n), ans(n); // ans is identity matrix
      for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j)
      {
         if (i == j) ans.M[i][j] = 1;
         waste.M[i][j] = M[i][j];
      }

      while (k) {
         if (k & 1) {
            ans = ans * waste;
         }
         waste = waste * waste;
         k >>= 1;
      }
      return ans;
   }
};

const int N = 55;
int n;
ll k;
int edge[N][N];

void solve() {
   Mat G(n);
   for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
         G.M[i][j] = edge[i][j];

   int total = 0;
   G = G.pow(k);
   for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
         total = add(total, G.M[i][j]);
   cout << total << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n >> k;
   for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
         cin >> edge[i][j];
   solve();

   return EXIT_SUCCESS;
}


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

using namespace std;

static const int INF = 1e9 + 7;

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

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

int h, w, k;

map<pair<int, int>, long long> dp;

long long dfs(int now, int x) {
	if (now == h) return x == k - 1;
	auto status = make_pair(now, x);
	if (dp.count(status)) return dp[status];
	long long res = 0;
	for (int i = 0; i < 1 << (w - 1); i++) {
		bool check = true;
		for (int j = 0; j < w - 2; j++) {
			if ((i >> j & 1) && (i >> (j + 1) & 1)) {
				check = false;
				break;
			}
		}
		if (check) {
			if (0 < x && (i >> (x - 1) & 1)) {
				res += dfs(now + 1, x - 1);
				res %= INF;
			}
			else if (x + 1 < w && ((i >> x) & 1)) {
				res += dfs(now + 1, x + 1);
				res %= INF;
			}
			else {
				res += dfs(now + 1, x);
				res %= INF;
			}
		}
	}
	return dp[status] = res;
}

void hawawa()
{
	cin >> h >> w >> k;

	cout << dfs(0, 0) << "\n";
}


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


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int mod = pow(10, 9) + 7;



int main(){

  int n;
  cin >> n;

  bool ans = false;

  rep(i, 9){
    rep(j, 9){
      int num = (i + 1) * (j + 1);

      if(num == n)  ans = true;
    }
  }

  if(ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,k;

int main(){
	cin>>n>>k;
	ll t=n/k;
	t=t*t*t;
	ll s=((n-k/2))/k+1;
	s=s*s*s;
	if(n-k/2<0){
		s=0;
	}
	if(k%2==1){
		cout<<t<<endl;
	}else{
		cout<<t+s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int h, w;
int dp[15][15], c[15][15];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w;
	FOR(i, 10) FOR(j, 10) {
		cin >> c[i][j];
		dp[i][j] = c[i][j];
	}
	FOR(cnt, 100) FOR(k, 10) FOR(i, 10) FOR(j, 10) {
		dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
	}
	int ret = 0;
	FOR(i, h) FOR(j, w) {
		int a;
		cin >> a;
		if (a!=-1) {
			ret += dp[a][1];
		}
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n = 0;
  cin >> n;
  vector<int> xs;
  for (int i=0; i<n; i++) {
    int x;
    cin >> x;
    if (x%2==0)
      xs.push_back(x);
  }
  if (all_of(xs.begin(), xs.end(), [](int i){return i%3==0 || i%5==0;}))
    cout << "APPROVED" << "\n";
  else
    cout << "DENIED" << "\n";
  return 0;
}



Measured memory_bytes: 256
n = int(input())
P =[]
s = 0
for i in range(n):P.append(input().split())
P.append(P[0])
for i in range(n):s += int(P[i][0])*int(P[i+1][1]) - int(P[i][1])*int(P[i+1][0])
print(abs(s)*0.5)

Measured memory_bytes: 7660
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
ll dp[102][100002];
int main()
{

	fast
	ll n, w;
	cin >> n >> w;
	ll weight[n], value[n];
	FOR(i, n)
	{
		cin >> weight[i] >> value[i];
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			if(j-weight[i-1]>=0)
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j-weight[i - 1]] + value[i - 1]);
			else
				dp[i][j]=dp[i-1][j];

		}

	}

	
	ll Max=-1;
	for(int i=1;i<=w;i++)
	{
		Max=max(Max,dp[n][i]);
	}
	cout<<Max;

	return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  ll b;cin>>b;
  int inc=0;
  int cnt=0;
  rep(i,n-1){
    ll a;cin>>a;
    if(b<a){
      if(inc<0){
        cnt++;
        inc=0;
      }else{
        inc=1;
      }
    }else if(b>a){
      if(inc>0){
        cnt++;
        inc=0;
      }else{
        inc=-1;
      }
    }
    b=a;
  }
  cout<<cnt+1<<endl;
  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  vector<ll> dp(h + 1, INF);
  dp[h] = 0;
  rep(i, n) for (int j = h; j > 0; j--) if (dp[j] != INF) {
    int v = max(0, j - a[i]);
    dp[v] = min(dp[v], dp[j] + b[i]);
  }

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


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>
#include <atcoder/dsu.hpp>

using namespace std;
using namespace atcoder;

#define unionFind dsu

typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}


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

	int N, Q; cin >> N >> Q;
	unionFind uf = unionFind(N);
	for (int i = 0; i < Q; i++) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) {
			uf.merge(u, v);
		}
		else {
			cout << uf.same(u, v) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3908
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

namespace atcoder {

namespace {

bool check()
{
  int X, A;
  cin >> X >> A;
  return X < A;
}

} // namespace
} // namespace atcoder

int main()
{
  using namespace atcoder;
  cout << (check() ? 0 : 10);
}


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

int main(void){
    int N, L, maxn{0}, sum{0};
    cin >> N;
    for(int i{0}; i<N; ++i){
        cin >> L;
        if(L>maxn){
            maxn = L;
        }
        sum += L;
    }

    if(maxn<sum-maxn)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int N;
long long W, w[110], v[110], dp[110][100010];
int main(){
  cin>>N >>W;
  
  for(int i=0;i<N;i++)cin>>w[i] >>v[i];
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j>=w[i]){
        dp[i+1][j]=max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
      }
      dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
    }
  }
  
  cout<<dp[N][W]<<endl;
  return 0;
}

Measured memory_bytes: 79360
#include<stdio.h>

int main(){
	while(1){
		char ch;
		int con=1;
		int cou=0;
		int m,n;
		int i,j;
		int ans=0;
		scanf("%d",&n);
		if(n==0)return 0;
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf(" %c",&ch);
			if(ch=='I'){
				if(con==0){
					cou++;
					if(cou==n+1){
						ans++;
						cou--;
					}
				}
				else cou=1;
				con=1;
			}
			if(ch=='O'){
				if(con==0)cou=0;
				con=0;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 600
#include<stdio.h>

int main(){
	char s[27];
	int i=0, j=0, r=0;
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		for(int j=i+1;j<27;j++){
			if(s[i]==s[j]){
				r++;
				break;
			}
		}
	}
	if(r>0){
		printf("no\n");
	} else {
		printf("yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=100005;
	const int inf=0x3f3f3f3f;
	int a[maxn]; 
	int dp[maxn];
	int n;
	int main(){
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		dp[0]=inf;
		for(int i=2;i<=n;i++)
			dp[i]=min(dp[i-1]+(abs(a[i]-a[i-1])),dp[i-2]+(abs(a[i]-a[i-2])));
		cout<<dp[n]<<endl;
	}

Measured memory_bytes: 4348
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		try (Scanner in = new Scanner(System.in)) {
			int N = in.nextInt();

			int sum = 0;
			for (int n = 1; n <= N; n++) {
				sum += n;
			}

			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 20692
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 5005 , M = 202;
int a[N] , b[N][M] , n , m;
int st[N][M] , tp[M] , s[N][M];
ll del[N];


int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,n) scanf("%d",a + i);
    rep(i,1,n+1) rep(j,1,m+1) scanf("%d",&b[i][j]);
    ll ans = 0;
    rep(j,1,m+1) ans += b[1][j] , del[1] += s[1][j] = b[1][j] , st[tp[j]++][j] = 1;
    rep(i,2,n+1){
        rep(j,1,m+1){
            del[i] += s[i][j] = b[i][j];
            while(tp[j] > 0 && b[i][j] >= b[st[tp[j] - 1][j]][j]){
                int tt = st[tp[j] - 1][j];
                del[tt] -= s[tt][j];
                tp[j]--;
            }
            if(tp[j] > 0){
                int tt = st[tp[j] - 1][j];
                del[tt] -= s[tt][j];
                del[tt] += s[tt][j] = b[tt][j] - b[i][j];
            }
            st[tp[j]++][j] = i;
        }
        //rep(k,1,i+1) printf("%lld%c",del[k]," \n"[k==i]);
        //rep(k,1,m+1) printf("%d%c",tp[k]," \n"[k==m]);
        ll tmp = 0;
        for(int j=i;j>=1;--j){
            tmp += del[j];
            if(j != i) tmp -= a[j];
            ans = max(ans , tmp);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define int unsigned long long
int sum[200003] , N , X;

signed main(){
	cin >> N >> X; int ans = 1e19;
	for(int i = 1 ; i <= N ; ++i){cin >> sum[i]; sum[i] += sum[i - 1];}
	for(int j = 1 ; j <= N ; ++j){
		int pos = N , all = j * X , cur = 3;
		while(pos > 0){
			all += (cur == 3 ? 5 : cur) * (sum[pos] - sum[max(j , pos) - j]);
			pos = max(pos , j) - j; cur += 2;
		}
		ans = min(ans , all);
	}
	cout << ans + N * X << endl; return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
#define all(x) x.begin(),x.end()
typedef pair<int,int>pii;

int p[100000];
int uni(int i){
	return p[i]!=i?p[i]=uni(p[i]):i;
}

pair<int,pii>dist(pii v,pii u){
	return {abs(v.first-u.first),{v.second,u.second}};
}

int N;
vector<pii>xi,yi;
vector<pair<int,pii>>E;

main(){
	cin>>N;
	for(int i=0;i<N;++i){
		int x,y;
		cin>>x>>y;
		xi<<(pii){x,i};
		yi<<(pii){y,i};
		p[i]=i;
	}
	sort(all(xi));
	sort(all(yi));
	for(int i=0;i<N-1;++i){
		E<<dist(xi[i],xi[i+1])<<dist(yi[i],yi[i+1]);
	}
	sort(all(E));
	long long a=0;
	for(auto e:E){
		int x=uni(e.second.first);
		int y=uni(e.second.second);
		if(x!=y){
			p[x]=y;
			a+=e.first;
		}
	}
	cout<<a;
}


Measured memory_bytes: 7528
k, n = map(int, input().split())

a = list(map(int, input().split()))

num = 0

for i in range(n):
    if num < abs(a[i] - a[i-1]):
        if not i:
            num = k - a[i-1] + a[i]
        else:
            num = a[i] - a[i-1]
        s = i
        e = i-1

if not s:
    print(a[e] - a[s])
else:
    print(k - a[s] + a[e])

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

int t[1000*1000+7];

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

int32_t main(){
	int n,k;
	cin >> n >> k;
	
	for(int i=1; i <= n; i++){
		cin >> t[i];
	}
	
	int maks = 0, Gcd = t[1];
	
	for(int i=1; i <= n; i++){
		maks = max(maks,t[i]);
		Gcd = gcd(t[i],Gcd);
	}
	
	if (maks >= k && k % Gcd == 0){
		cout << "POSSIBLE";
	}else{
		cout << "IMPOSSIBLE";
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(void){
    const long long int MOD = pow(10, 9) + 7;
    int N;
    scanf("%d", &N);
    long long int a = 1, b = 1, c = 1, ans;
    for(int i=0; i<N; i++){
        a *= 10;
        a %= MOD;
        b *= 8;
        b %= MOD;
        c *= 9;
        c %= MOD;
    }
    ans = (a + b - 2 * c) % MOD;
    if(ans < 0) ans += MOD;
    printf("%lld\n", ans);
}

Measured memory_bytes: 1732
import sys
inputs = sys.stdin.readlines()

from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))

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

using namespace std;

int main(void)
{
    int n;
    int *p;
    int count = 0;
    int max = 0;
    int min = 0;
    
    cin >> n;
    p = new int[n+1];
    for (int i=0;i<n;i++) {
        cin >> p[i];
        if (max == 0 || max <= p[i]) max =p[i];
        if (min == 0 || min >= p[i]) min =p[i];
    }

    sort(p, p+n);
    for (int i= min; i <= max; i++) {
        if (p[n/2-1] < i && p[n/2] >= i) count++;
    }
    cout << count << endl;
    delete p;
    return 0;
}


Measured memory_bytes: 888
import sys, collections

def solve():
    file = sys.stdin.readline
    N = int(file())
    A = [None] * N
    mindig = collections.defaultdict(int)
    nim = 0
    for i in range(N):
        a = int(file())
        A[i] = a
        nim ^= a
        mindig[a^(a-1)] += 1
    if nim == 0: print(0)
    else:
        nim = format(nim, "b").zfill(30)
        flip = 0
        for i in range(30):
            if int(nim[i]) != flip % 2:
                if mindig[pow(2, 30-i) - 1] == 0:
                    print(-1)
                    break
                else: flip += 1
        else: print(flip)
    return 

if __name__ == "__main__":
    solve()

Measured memory_bytes: 7236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try {
            String line;
            while (true) {
                line = br.readLine();
                int sizeOfConvertTable = Integer.parseInt(line);
                if (sizeOfConvertTable == 0) {
                    System.exit(0);
                }

                Map<String, String> convertTable = new HashMap<>();
                for (int i = 0; i < sizeOfConvertTable; i++) {
                    line = br.readLine();
                    String[] lineStrs = line.split(" ");
                    convertTable.put(lineStrs[0], lineStrs[1]);
                }

                line = br.readLine();
                int numOfTarget = Integer.parseInt(line);
                for (int i = 0; i < numOfTarget; i++) {
                    line = br.readLine();
                    System.out.print(convertTable.getOrDefault(line, line));
                }
                System.out.println("");
            }
        } catch (IOException ex) {
            ex.printStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 40816
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#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);


	ll N, M;
	cin >> N >> M;
	int A[100000];
	rep(i, N) cin >> A[i];

	sort(A, A + N);

	int L = 0;
	int R = 200001;
	while (L + 1 < R) {
		int m = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			int k = lower_bound(A, A + N, m - A[i]) - A;
			kazu += N - k;
		}
		if (kazu >= M) {
			L = m;
		}
		else R = m;
	}

	ll S[100001] = {};
	for (int i = N; i > 0; i--) {
		S[i - 1] = S[i] + A[i - 1];
	}

	ll kotae = 0;
	ll num = 0;
	int saishou = 3e5;
	rep(i, N) {
		int k = lower_bound(A, A + N, L - A[i]) - A;
		kotae += S[k];
		kotae += ll(N - k) * A[i];

		num += N - k;
		if(N != k) chmin(saishou, A[i] + A[k]);
	}
	co(kotae - (num - M) * saishou);

	Would you please return 0;
}

Measured memory_bytes: 1408
t_a_k = list(map(int,input().split()))

a = 0
b = 0

c = t_a_k[0] - t_a_k[2]

if c >= 0:
    print("{0} {1}".format(c, t_a_k[1]))
elif c < 0:
    d = c + t_a_k[1]
    if d < 0:
        print("0 0")
    else:
        print("0 {0}".format(d))

Measured memory_bytes: 3060
import sys
def input():
    return sys.stdin.readline()[:-1]
def make_sumtable():
    sumtable = [[0]*(N+1) for i in range(N+1)]
    for i in range(M):
        sumtable[L[i]][R[i]] += 1
    for i in range(1,N+1):
        for j in range(1,N+1):
            sumtable[i][j] += sumtable[i-1][j]
            sumtable[i][j] += sumtable[i][j-1]
            sumtable[i][j] -= sumtable[i-1][j-1]
    return sumtable
N,M,Q = map(int,input().split())

L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

sumtable = make_sumtable()

for i in range(Q):
    p,q = map(int,input().split())
    print(sumtable[q][q]-sumtable[q][p-1]-sumtable[p-1][q]+sumtable[p-1][p-1])


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e18 + 17;
const int maxn = 1e5 + 10;
const int maxq = 1e2 + 10;
const int alf = 26;
const ll dlm = 1e9 + 7;
const int del = 998244353 ;
const int eps = 1e-7 ;

int w[maxq],v[maxq];
ll dp[maxq][maxn];
//      n      sigma(v)
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,weig;
    cin>>n>>weig;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=1;j<maxn;j++){
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        ll we = w[i];
        ll va = v[i];
        for(ll j=0;j<maxn;j++){
            if((j-va)<0){
                dp[i][j] = dp[i-1][j];
                continue;
            }
            dp[i][j] = min(dp[i-1][j-va]+we,dp[i-1][j]);
            if(dp[i][j]<=weig){
                ans = max(ans,j);
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <map>
#include <string>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

bool cards[4][13];
int main() {
    int n;
    cin >> n;
    char tmp_mark;
    int tmp_digit, tmp_markdigit;
    
    rep(i, n) {
        cin >> tmp_mark >> tmp_digit;
        --tmp_digit;

        if (tmp_mark == 'S') cards[0][tmp_digit]  = true;
        if (tmp_mark == 'H') cards[1][tmp_digit]  = true;
        if (tmp_mark == 'C') cards[2][tmp_digit]  = true;
        if (tmp_mark == 'D') cards[3][tmp_digit]  = true;
    }

    rep(i, 4) {
        rep(j, 13) {
            if(!cards[i][j]) {
                if (i == 0) cout << 'S';
                if (i == 1) cout << 'H';
                if (i == 2) cout << 'C';
                if (i == 3) cout << 'D';
            
                cout << " " << j+1 << endl;
            }
        }
    }

}




Measured memory_bytes: 3084
#include <stdio.h>

int main(void) {

  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x < r || y < r){
    puts("No");
  } else if( x + r > W || y + r > H){
    puts("No");
  } else {
    puts("Yes");
  }


  return 0;
}


Measured memory_bytes: 2100
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = 0
    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        ans += i
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10380
while True:
    try:
        a,b,c,d,e,f = map(int,input().split())
    except:
        break

    A = a*e - b*d
    x = (e*c - b*f)/A
    y = (a*f - d*c)/A
    # 出力の体裁を整え、-0.00を0.00にするため+0する
    print("{:.3f} {:.3f}".format(x+0,y+0))


Measured memory_bytes: 5616
import numpy as np
A = np.array([list(map(int,input().split())) for i in range(3)])
N = int(input())
b = [int(input()) for i in range(N)]
B = np.array([[0]*3 for i in range(3)])
for _ in b:
    for t in range(3):
        for y in range(3):
            if A[t][y] == _:
                B[t][y] = 1
ans = "No"
for i in range(3):
    if all(B[i] == [1,1,1]):
        ans ="Yes"
    if all(B[:,i] == [1,1,1]):
        ans ="Yes"
if B[0,0] == 1 and B[1,1] == 1 and B[2,2] == 1:
    ans ="Yes"
if B[2,0] == 1 and B[1,1] == 1 and B[0,2] == 1:
    ans ="Yes"
print(ans)
        

Measured memory_bytes: 12220
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    int N; cin >> N;
    vector<ll> A(N), B(N), C(N); 
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];
    
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll countA = 0;
        auto lower_itr = lower_bound(A.begin(), A.end(), B[i]);
        if(lower_itr == A.end()){
            countA = N;
        }else{
            countA = distance(A.begin(), lower_itr);
        }
        
        ll countC = 0;
        auto upper_itr = upper_bound(C.begin(), C.end(), B[i]);
        if(upper_itr == C.end()){
            countC = 0;
        }else{
            countC = C.size() - distance(C.begin(), upper_itr);
        }
        
        ans += countA * countC;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;


int main() {
  int n,m;
  cin >> n >> m;
  int a = m/n;
  for(int i = a; i > 1 ; i--) {
    if(m % i == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}


Measured memory_bytes: 256
singles = {}
doubles = {}
used = [0 for i in range(1000)]
N = int(input())
S = input()
out = 0
for i in range(N):
  ordn = ord(S[i])-ord('0')
  for d in doubles:
    if used[d*10+ordn]==0:
      used[d*10+ordn]=1
      out+=1
  for s in singles:
    doubles[s*10+ordn]=1
  singles[ordn]=1
print(out)

Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = min(a[0], b[0])
b[0] -= min(a[0], b[0])
for i in range(1, n):
    if b[i-1] > 0:
        cnt += min(a[i], b[i-1])
        a[i] -= b[i-1]
    if a[i] > 0:
        cnt += min(a[i], b[i])
        b[i] -= min(a[i], b[i])
cnt += min(a[-1], b[-1])
print(cnt)


Measured memory_bytes: 18476
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    string S,T, output;

    cin >> n >> S >> T;
    for(int i = 0; i < S.length(); i++) {
        output += S[i];
        output += T[i];
    }
    cout << output << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
#include<algorithm> 
typedef long long int ll;
#define tcase int t; cin>>t; while(t--)
#define pii pair<int,int>
#define si set<int>
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define vc vector<char>
#define vvi vector<vector<int>>
#define nl '\n'
#define mkp make_pair
#define rep(i, m, n) for(ll i=m ; i<n ; i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define pb push_back
#define p push
#define sz(anything) anything.size()
#define first(anything) anything.begin()
#define last(anything) anything.end()
#define all(anything) anything.begin(), anything.end() 
#define allr(anything) anything.rbegin(), anything.rend()
#define MAX 5000
#define fix(number,dp) fixed<<setprecision(dp)<<number
#define show(s) for(auto x : s){cout<<x<<' ';}
#define showpair(s) for(auto x : s){cout<<x.first<<x.second;}
#define no cout<<"NO";
#define yes cout<<"YES";
//Mêmes couleurs qu'avant mais moins de lumière
using namespace std;

  
int main() 
{ 
	int a; cin>>a;
	(a)? cout<<0: cout<<1;
	
	return 0;

}

Measured memory_bytes: 3600
n, k = gets.split.map(&:to_i)
hs = []
n.times do
  hs << gets.to_i
end

hs.sort!

min = 10000000000000
0.upto(n - k) { |left|
  right = left + k - 1
  min = [hs[right] - hs[left], min].min
}

p min


Measured memory_bytes: 6064
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <algorithm>
#include <functional>
#include <cstring>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

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

	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S') {
			if (cnt < 0)cnt = 0;
			cnt++;
		}
		else {
			if (cnt > 0) {
				ans++;
				cnt--;
			}
		}
	}

	cout << s.size() - 2 * ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, k;
    cin >> n >> k;
    vs64 s(n + 1);
    s[0] = 0;
    s64 a;
    rep (i, n)
    {
        cin >> a;
        s[i + 1] = s[i] + a;
    }

    s64 ans = 0;
    int r = 0;
    map<s64, int> m;
    rep (l, n)
    {
        while (r <= n && r - l < k)
        {
            ++m[(s[r] - r) % k];
            ++r;
        }
        ans += --m[(s[l] - l) % k];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,p; cin >> n >> p;
    auto a = prime_factor(p);
    int ans = 1;
    for(auto x:a){
        REP(i,x.second/n) ans*=x.first;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[False]*n
ans[0]=True
co=[1]*n
for i in range(m):
  x,y=map(int,input().split())
  ans[y-1]|=ans[x-1]
  co[x-1]-=1
  co[y-1]+=1
  if co[x-1]==0:ans[x-1]=False
print(ans.count(True))

Measured memory_bytes: 10276
import sys
from itertools import accumulate
import bisect

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M, K = inm()
A = inl()
B = inl()


def solve():
    acum = accumulate(A)
    bcum = list(accumulate(B))
    ans = 0
    for i, b in enumerate(bcum):
        if b <= K:
            ans = i + 1
    for i, x in enumerate(acum):
        if x > K:
            break

        j = bisect.bisect_right(bcum, K - x)
        s = i + 1 + j
        if ans < s:
            ans = s

    return ans


print(solve())


Measured memory_bytes: 41636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    String op = sc.next();
    int B = sc.nextInt();
    int ans = A + B;
    if(op.equals("-")) ans = A - B;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
// abc132c.cpp : Divide the Problems
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

#define DMAX 100000

int main(){
  int N; in(N);

  vi D(DMAX+1);
  int dmax=0;
  rep(i,N){
    int d; in(d);
    D[d]++;
    dmax = max(dmax, d);
  }

  int i;
  int c=0;
  for(i=1;i<=dmax;i++){
    c+=D[i];
    if(c>=N/2) break;
  }

  if(i>dmax){
    oute(0);
    return 0;
  }
  if(c>N/2){
    oute(0);
    return 0;
  }

  c=0;
  upto(j,i+1,dmax+1,1){
    if(D[j]==0) c++;
    if(D[j]>0){ c++; break; }
  }
  oute(c);

}

Measured memory_bytes: 640