akhauriyash/Code-Regression huggingface dataset:
def parseSpaceDivideIntArgs(arg):
    tmpArr = arg.split()
    ret = []
    for s in tmpArr:
        ret.append(int(s))
    return ret


instr = input()
# instr = "1 2 3"

instrSpl = parseSpaceDivideIntArgs(instr)
a = instrSpl[0]
b = instrSpl[1]
c = instrSpl[2]

if a < b & b < c:
    print("Yes")
else:
    print("No")



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

int n;
int a[100];

int rec(int l, int r) {
  if (r == l) return 0;
  int mni = min_element(a + l, a + r) - a;
  int mn = a[mni];  
  int sum = mn;
  for (int i = l; i < r; ++i) {
    a[i] -= mn;
  }
  sum += rec(l, mni);
  sum += rec(mni + 1, r);
  return sum;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << rec(0, n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int n,k; cin >> n >> k;
    ll a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    ll b[n]; b[0] = 0;
    for(int i = 1;i < n;i++){
        ll x = LLONG_MAX;
        for(int j = max(0,i-k);j < i;j++){
            x = min(x,b[j]+abs(a[i]-a[j]));
        }
        b[i] = x;
    }
    cout << b[n-1];
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int n=0,i=0,k=0;
  scanf("%d",&n);
  k=n;
  while(k!=0){
  i+=k%10;
  k/=10;
  }
  if(n%i==0){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1728
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(b'-'+readline().rstrip(),'S1')
Q = int(readline())
query = map(int,read().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

def F(K):
    x = cumD.copy(); x[K:] -= cumD[:-K]
    x *= isM
    x[K+1:] -= isD[1:-K] * (cumM[K:-1] - cumM[:-K-1])
    return (x.cumsum() * isC).sum()

print('\n'.join(str(F(K)) for K in query))

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

int main()
{
  //vector<bool> close(1<<(5*5), false);
  vector<int> close((1<<(5*5))/32, 0);
  vector<int> cls(1000000);

  for (int n; scanf("%d", &n), !(n==0); ){

    vector<vector<int> > pats(33);
    vector<vector<int> > tmp(n, vector<int>(n, 0));

    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	for (int k=i; k<n; k++){
	  for (int l=j; l<n; l++){
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=1;
	    int bd=0;
	    for (int a=0; a<n; a++){
	      for (int b=0; b<n; b++){
		bd=(bd<<1)|tmp[a][b];
	      }
	    }
	    pats[__builtin_clz(bd)].push_back(bd);
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=0;
	  }
	}
      }
    }

    int bd=0;
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	int t; scanf("%d", &t);
	bd=(bd<<1)|t;
      }
    }

    int cls_cnt=0, cls_cur=0;
    close[bd>>5]|=(1<<(bd&31));
    cls[cls_cnt++]=bd;
    for (;;){
      int dep=cls[cls_cur]>>25;
      int cbd=cls[cls_cur]&0x1ffffff;
      cls_cur++;
      const vector<int> &ps=pats[__builtin_clz(cbd)];
      int sz=ps.size();
      for (int i=0; i<sz; i++){
	int nbd=cbd^ps[i];
	if (close[nbd>>5]&(1<<(nbd&31)))
	  continue;
	close[nbd>>5]|=(1<<(nbd&31));
	cls[cls_cnt++]=((dep+1)<<25)|nbd;
	if (nbd==0){
	  for (int i=0; i<=dep; i++)
	    printf("myon");
	  puts("");
	  goto _exit;
	}
      }
    }
  _exit:;
    {
      int i=0;
      for (; i+3<cls_cnt; i+=4){
	close[(cls[i+0]&0x1ffffff)>>5]=0;
	close[(cls[i+1]&0x1ffffff)>>5]=0;
	close[(cls[i+2]&0x1ffffff)>>5]=0;
	close[(cls[i+3]&0x1ffffff)>>5]=0;
      }
      for (; i<cls_cnt; i++)
	close[(cls[i]&0x1ffffff)>>5]=0;
    }
  }
  return 0;
}

Measured memory_bytes: 8920
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    string str;
    cin>>str;
    int n=str.size();

    char p=str[0];
    int cnt=0;
    for (int i = 1; i < n; i++) {
        if(p!=str[i]){
            cnt++;
            p=str[i];
        }
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
L = set()
R = set()
for i in range(m):
    l, r = map(int, input().split())
    L.add(l)
    R.add(r)
if min(R) >=  max(L):
    num = min(R) - max(L) + 1
else:
    num = 0
print(num)


Measured memory_bytes: 18784
#include <stdio.h>

int main() {
	int ans = 0;
	char s[5], t[5];
	scanf("%s %s", s, t);
	for (int i = 0; i < 3; i++)
		if (s[i] == t[i])
			ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;i=N)for(++d,F=1;i--;)u[i]<d&&(j=A[I[i]][i])&&u[F&=2,--j]<d&&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j];printf("%d",F*d-1);}

Measured memory_bytes: 4224
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cassert>
#include <numeric>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef long long ll;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef vector<int> vec;
#define fi first
#define se second
/* */
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
#define forEach(i, s) for(auto i=begin(s);i!=end(s);i++)
#define for_each_n(i, s, n) for(auto i=begin(s),_5=next(i,n);i!=_5;i++)
#define pb push_back
#define mp make_pair

/* special */
#define Mem(x) memset(x,0,sizeof(x))
#define GET_MACRO(_0,_1,_2,_3,_NAME,...) _NAME
/* */
#define rep(...)  GET_MACRO(_0,##__VA_ARGS__,rep3,rep2,rep1,rep0)(__VA_ARGS__)
	#define rep3(i,a,b) for(int i=(a);i<(b);++i)
	#define rep2(i,a) for(int i=0;i<(a);++i)
	#define rep1(a) rep2(_,a)
	#define rep0()	while(1)
#define callOnce if([]{static int i=-1;i++;return !i;}())


/* input */
namespace my{
	#define out(x) cout<<(x)<<endl
	inline int in(int &x) {return scanf("%d",&x);}
	inline int in(double &x) {return scanf("%lf",&x);}
	inline int in(ll &x) {return scanf("%lld",&x);}
	inline int in(int &x,int &y) {return scanf("%d %d",&x,&y);}
	inline int in(int &x,int &y,int &z) {return scanf("%d %d %d",&x,&y,&z);}
	inline int in(char s[]) {return scanf("%s",s);}
	inline int in(char &c) {return scanf("%c",&c);}
}

using namespace my;

/* debug */
#ifndef ONLINE_JUDGE
	#define D0()
	#define D1(x) {cout<<" ";cout.width(5);cout<<(x);}
	#define D2(x,y) {D1(x)D1(y)}
	#define D3(x,y,z) {D2(x,y)D1(z)}
	#define Dset(...) for(auto i : __VA_ARGS__ ) D1(i) //std::size()
	#define Darr1(x,fir) for(auto _7 = begin(x),_6=next(begin(x),fir);_7!=_6;++_7) D1(*_7)
	#define Darr2(x,fir,sec) for(auto _8=begin(x),_9=next(begin(x),fir);_8!=_9;++_8){ Darr1((*_8),sec)D()}
	#define D(...) {cout<<#__VA_ARGS__<<" ";GET_MACRO(_0,##__VA_ARGS__,D3,D2,D1,D0)(__VA_ARGS__);cout<<endl;}
	#define Da(...)  {cout<<#__VA_ARGS__;D()GET_MACRO(""##__VA_ARGS__,UNUSED,Darr2,Darr1,Dset)(__VA_ARGS__)D()}
#endif // ONLINE_JUDGE

// template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
#define pow2(X) (1<<(X))
#define gcd __gcd
#define lcm(a,b) ((a)/gcd(a,b)*(b))
ll mod=1e9+7;
inline ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x3f3f3f3f;//0x3f
const int NINF=0xcfcfcfcf;//0xcf
const int maxn=1e9+10;
int n,t,T,x,H,W,p,y,v;
char a[110][110];
bool visH[110];
bool visW[110];
int main(){

	cin>>H>>W;
	rep(i,H)rep(j,W){
		cin>>(a[i][j]);
	}
	
	rep(i,H) {
		int flag=1;
		rep(j,W) {
			if(a[i][j]=='#') flag=0;
		}
		if(flag){
			visH[i]=1;
		}
	}

	rep(j,W) {
		int flag=1;
		rep(i,H) {
			if(a[i][j]=='#') flag=0;
		}
		if(flag){
			visW[j]=1;
		}
	}
	rep(i,H){
		if(visH[i]) continue;
		rep(j,W){
			if(visW[j]) continue;
			printf("%c",a[i][j]);
		}
		printf("\n");
		
	}

}


Measured memory_bytes: 256
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << 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 maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, x,sum=0,sums=0;
    cin >> n >> m >> x;
    vector<int> a(n+1);
    for(int i = 0; i < m; ++i) {
        int k; cin >> k;
        a.at(k)=1;
    }
    for(int i = x; i <= n; ++i) {
        sum += a.at(i);
    }
    for(int i = x; i >= 0; --i) {
        sums += a.at(i);
    }
    cout << min(sum,sums) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){


ll n;
cin>>n;

cout<< (n+1)/2<<endl;




return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


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

using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int) (v).size()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define pb push_back
#define mp make_pair

using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int inf = 0x3f3f3f3f;
constexpr ll MOD = 1000000007LL;
constexpr double tol = 1e-8;

void buff() { ios::sync_with_stdio( false ); cin.tie(nullptr); }

constexpr int ms = 405;
long long dp[ms][ms];

int main() 
{
    buff();
    int n;
    cin >> n;
    vector< long long > A(n);
    vector< long long > ACC(n + 1, 0 );
    for(int i = 0; i < n; ++i) cin >> A[i];
    
    partial_sum( all(A), ACC.begin() + 1 );
    
    auto range_sum = [&] (int l, int r ) { return ACC[r] - ACC[l - 1]; };

    for(int len = 2; len <= n; ++len)
    {
        for(int st = 1; st + len - 1 <= n; ++st)
        {
            int nd = st + len - 1;
            dp[st][nd] = LLONG_MAX;
            for(int mid_point = st; mid_point < nd; ++mid_point )
            {
                long long left_sum = range_sum(st, mid_point);
                long long right_sum = range_sum( mid_point + 1, nd );
                dp[st][nd] = min( dp[st][nd],
                                  dp[st][mid_point] + dp[mid_point + 1][nd] +
                                  left_sum + right_sum );
            }
        }
    }

    cout << dp[1][n] << '\n';

    return 0;
}



Measured memory_bytes: 1536
#include <stdio.h>

#define MAX 52

struct card {
  char suit;
  int num;
};

int suit_to_int(char c) { 
  switch (c){
  case 'S' : return 0;
  case 'H' : return 1;
  case 'C' : return 2;
  case 'D' : return 3;
  default : return -1;
  }
}

char suits[4] = { 'S', 'H', 'C', 'D' };

struct card show(int k) {
  struct card card;
  card.num = k % 13 + 1;
  card.suit = suits[k / 13];
  return card;
} 

int read(struct card card) {
  return suit_to_int(card.suit) * 13 + (card.num - 1); 
}

void print_card(struct card card) {
  printf("%c %d\n", card.suit, card.num);
}

int main(void) {
  int i, n, taro_has[MAX] = {0};
  struct card t;
  scanf("%d\n", &n);
  for (i = 0; i < n; i++) {
    scanf("%c %d\n", &t.suit, &t.num);
    taro_has[read(t)] = 1; 
  }
  for (i = 0; i < MAX ; i++) {
    if (!(taro_has[i])) print_card(show(i));
  }
  return 0;
}



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

#define int long long
const int MOD = 1000000007LL;

const int sqrtN = 512;

struct SqrtDecomposition{
    int N, K;
    vector<int> data;
    vector<int> bucketmax;
    SqrtDecomposition(int n) : N(n){

        //切り上げ(K := バケット数, sqrtN := バケットサイズ)
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(K * sqrtN, 0);
        bucketmax.assign(K, 0);
    }

    void update(int x, int y){
        int k = x / sqrtN;
        int maxVal = data[x] = y;
        int sum = 0;
        for (int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
            maxVal = max(maxVal, data[i]);
        }

        bucketmax[k] = maxVal;
    }

    //[x, y)
    int find(int x, int y){
        
        int maxVal = 0;
        
        for(int k = 0; k < K; k++){
            
            int l = k * sqrtN;
            int r = (k + 1) * sqrtN;
            if(r <= x || y <= l) continue;

            if(x <= l && r <= y) maxVal = max(maxVal, bucketmax[k]);
            else{
                for(int i = max(x, l); i < min(y, r); i++){
                    maxVal = max(maxVal, data[i]);
                }
            }
        }

        return maxVal;
    }

    
};

signed main(){

    int n; cin >> n;
    vector<int> h(n);
    vector<int> a(n);
    map<int, int> m; //h -> index
    for(int i = 0; i < n; i++){
        cin >> h[i];
        m[h[i]] = i;
    }

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

    //最後が高さ i の時の最高価値
    vector<int> dp1(n + 1, 0);
    dp1[1] = a[m[1]];

    //最後の index が i の時の最高価値
    SqrtDecomposition decomp(n + 2);
    decomp.update(m[1], a[m[1]]);
        //else cout << decomp.find(x, y + 1) << endl;
    
    
    for(int i = 2; i <= n; i++){
        dp1[i] = decomp.find(0, m[i]) + a[m[i]];
        decomp.update(m[i], dp1[i]);
        //cout << i << " " << dp1[i] << endl;
    }

    int ans = 0;
    for(int i = 0; i <= n; i++) ans = max(ans, dp1[i]);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int M, N, D;
  bool matrix[625][626];

  while(cin >> M >> N >> D, M) {
    for(int i = 0; i < N * M; i++) {
      cin >> matrix[i][N * M];
    }

    for(int i = 0; i < N; i++) {
      for(int j = 0; j < M; j++) {
        for(int k = 0; k < N; k++) {
          for(int l = 0; l < M; l++) {
            matrix[i * M + j][k * M + l] = abs(i - k) + abs(j - l) == D;
          }
        }
        matrix[i * M + j][i * M + j] = 1;
      }
    }

    for(int i = 0; i < N * M; i++) {
      int pos = -1;
      for(int j = i; j < N * M; j++) {
        if(matrix[j][i]) pos = j;
      }
      if(pos == -1) continue;
      swap(matrix[pos], matrix[i]);
      for(int j = 0; j < M * N; j++) {
        if(i == j) continue;
        if(matrix[j][i] == 1) {
          for(int k = 0; k <= M * N; k++) {
            matrix[j][k] ^= matrix[i][k];
          }
        }
      }
    }
    bool flag = true;
    for(int i = 0; i < M * N; i++) {
      if(matrix[i][M * N] && !matrix[i][i]) flag = false;
    }
    cout << flag << endl;
  }
}

Measured memory_bytes: 3320
import sys
input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))

if __name__ == '__main__':
    main()


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

int main(){
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  
  if(m1 != m2){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }

}

Measured memory_bytes: 256
// abc113d
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
const int mod = 1e9 + 7;

ll dp[101][10];
int main() {
  int h,w,k; cin >> h >> w >> k;
  dp[0][0] = 1;
  rep(i, h) {
    rep(j, w) {
      rep(mask, 1<<(w-1)) {
        bool ok = true;
        rep(bit, w-2) {
          if ((mask >> bit)& 1 && (mask >> (bit+1)) & 1) ok = false;
        }
        if (!ok) continue;
        int nj = j;
        if ((mask >> j) & 1) nj++;
        else if ((mask >> (j - 1)) & 1 && j > 0) nj--;
        (dp[i+1][nj] += dp[i][j]) %= mod;
      }
    }
  }
  printf("%lld\n", dp[h][k-1]);
  return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI = acos(-1);

int main(){
  int n,m;
  cin >>n>>m;
  vector<int> A(m);
  rep(i,m) cin >>A[i];
  int wday=0;
  rep(i,m) wday +=A[i];
  int hday =n-wday;
  if (hday <0)cout << -1 ;
  else cout <<hday;
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,s,dp[2*100001][2];

ll solve(ll arr[],int idx,int prev)
{
  if(idx>=n) return 0;
  if(dp[idx][prev]!=-(1e9 +7)) return dp[idx][prev];
  if(prev==0)
  {
    return dp[idx][prev]=max(arr[idx]+solve(arr,idx+2,0),arr[idx+1]+solve(arr,idx+2,1));
  }
  else
  {
    return dp[idx][prev]=arr[idx+1]+solve(arr,idx+2,1);
  }
}

int main()
{


    cin>>n;
    ll arr[n],sum=0;
    map<ll,ll> mp;
    for(int i=0;i<n-1;i++) 
      {
        cin>>arr[i];
        mp[arr[i]]++;
      }
    for(int i=1;i<=n;i++) cout<<mp[i]<<endl;
}

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

using namespace std;

using ll = long long;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    vector<pair<ll, ll>> nikola;
    for(ll i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(ll i = 0; i < m; ++i){
        ll b, c;
        cin >> b >> c;
        nikola.push_back(make_pair(c, b));
    }
    sort(nikola.begin(), nikola.end());
    reverse(nikola.begin(), nikola.end());
    ll ans = 0, cur = 0;
    for(ll i = 0; i < n; ++i){
        if(nikola[cur].first > v[i] && nikola[cur].second > 0){
            ans += nikola[cur].first;
            nikola[cur].second--;
        }else if(nikola[cur].second == 0 && cur < m){
            cur++;
            if(i == n - 1){
                ans += v[i];
                break;
            }
            i--;
        }else{
            ans += v[i];
        }
    }
    cout << ans;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,l;
    vector<LL> dp;
    Problem(int n):n(n),dp (n+1){};
    long long modpow(long long a, long long n,long long mod=MOD){
        long long i=1,ret=1,p=a;
        while(i<=n){
            if(i&n) ret=(ret*p)%mod;
            i=(i<<1);
            p=(p*p)%mod;
        }
        return ret;
    }
    void solve(){
        string s;
        cin >> s;
        l=s.length();
        dp[0]=1;
        for(int i=0; i<n; ++i){
            vector<LL> dp2(n+1);
            for(int j=0; j<=n; ++j){
                dp2[max(0,j-1)]+=dp[j];
                if(j<n)dp2[j+1]+=dp[j]*2;
            }
            for(int i=0; i<=n; ++i){
                dp2[i]%=MOD;
            }
            swap(dp,dp2);
        }
        cout << dp[l]*modpow(2,(MOD-2)*l)%MOD <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 100000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    string S;
    cin >> N >> S;
    vector<P>sum(N+1);
    int A = 0,B = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == '#') {
            A++;
            sum[i+1].first = sum[i].first+1;
            sum[i+1].second = sum[i].second;
        }
        else {
            B++;
            sum[i+1].second = sum[i].second+1;
            sum[i+1].first = sum[i].first;
        }
    }
    if(A == N || B == N) {
        cout << 0 << endl;
        return 0;
    }
    int ans = INF;
    for(int i = 0; i < N; i++) {
        int cnt = sum[i+1].first;
        cnt+=(B-sum[i+1].second);
        ans = min(ans,cnt);
    }
    ans = min(ans,A);
    ans = min(ans,B);
    // . . . . . . # # # # # #
    cout << ans << endl;
}


Measured memory_bytes: 6764
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int D,T,S;
  cin >> D >> T >> S;

  if(D<=T*S) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll n;
    cin >> n;
    primeFactors(n);
    ll ans = 0;
    for (auto x : cnt) {
        ll k = 1;
        while ((x.second * 2) / (k * (k + 1)) >= 1) {
            k++;
        }
        ans += (k - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int,input().split()))
    
    from collections import defaultdict
    B = defaultdict(int)
    
    for i in A:
        B[i] += 1
    ans = 0
    for i in B:
        if B[i] < i:
            ans += B[i]
        else:
            ans += (B[i]-i)
    print(ans)
    
main()

Measured memory_bytes: 64936
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int X;
    cin >> X;
    long long res = 0;
    for(int i = 2; i * i <= X; i++) {
        for(int j =2; pow(i,j) <= X;j++){
          res = max(res,(long long)pow(i,j));
        }
    }
  if(res==0) res = 1;
    cout << res << endl;
}


Measured memory_bytes: 384
n = int(input())
a=[]
b=[]
for _ in range(n):
    aa,bb = map(int,input().split())
    a.append(aa)
    b.append(bb)
cnt = max(a)-min(a)+1
cnt += a[b.index(max(b))]-1
cnt += b[a.index(max(a))]
print(cnt)


Measured memory_bytes: 11300
from math import floor, ceil
from itertools import chain

# 入力
H, W = map(int, input().split())

# ある1ピースを i*W または j*W となるように切ったときのS_max - S_minをすべて求める
ans = min(
    max(a, b, c) - min(a, b, c)
    for a, b, c in chain(
        (
            (i * W, (H - i) * floor(W / 2), (H - i) * ceil(W / 2))
            for i in range(1, H)
        ),
        (
            (i * W, floor((H - i) / 2) * W, ceil((H - i) / 2) * W)
            for i in range(1, H)
        ),
        (
            (j * H, (W - j) * floor(H / 2), (W - j) * ceil(H / 2))
            for j in range(1, W)
        ),
        (
            (j * H, floor((W - j) / 2) * H, ceil((W - j) / 2) * H)
            for j in range(1, W)
        ),
    )
)

# 出力
print(ans)

Measured memory_bytes: 3188
N = int(input())
#a,b = map(int,input().split())

ans = 1e6
for i in range(N+1):
  cnt = 0
  # 6の倍数で支払う金額がi
  S = i
  while(S>0):
    x = S % 6
    cnt += x
    S = S // 6
  # 9の倍数で支払う金額は残り
  S = N - i
  while(S>0):
    x = S % 9
    cnt += x
    S = S // 9
  ans = min(ans, cnt)

print(ans)

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int N;
  cin >> N;
  vector<vector<int>> a(N);
  rep(i, N) rep(j, N - 1) {
    int k;
    cin >> k;
    k--;
    a[i].push_back(k);
  }
  rep(i, N) reverse(a[i].begin(), a[i].end());
  dumpv(a, N);
  set<P> q;
  function<void(int)> scan = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      dump("scan", i, j);
      if (j > i) swap(i, j);
      q.insert(P(i, j));
    }
  };
  rep(i, N) scan(i);
  int ans = N * (N - 1) / 2;
  for (int d = 0; d < N * (N - 1) / 2; d++) {
    // dump(a, q);
    if (!q.size()) {
      ans = d;
      break;
    }
    // sort(q.begin(), q.end());
    // q.erase(unique(q.begin(), q.end()), q.end());
    set<P> q2;
    swap(q2, q);
    for (P p : q2) {
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (P p : q2) {
      int i = p.first, j = p.second;
      scan(i);
      scan(j);
    }
  }
  dump(ans, a);
  rep(i, N) {
    if (a[i].size() != 0) {
      dump(i, a[i]);
      cout << -1 << endl;
      return;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 4352
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

ll dp[N], pref[N][2];

ll solve(int n, int bound, bool parity);

int main() {
	fast_cin();
	int n, m; string s;
	cin >> n >> m >> s;
	s += (s.back() ^ 'R' ^ 'B');
	vector<int> parts;
	int cur = 1;
	for (int i = 1; i <= m; ++i) {
		if (s[i] != s[i - 1]) {
			parts.pb(cur);
			cur = 1;
		} else {
			++cur;
		}
	}
	int bound = parts[0] + (1 - (parts[0] & 1));
	for (int i = 2; i + 1 < parts.size(); i += 2) {
		if (parts[i] & 1) {
			bound = min(bound, parts[i]);
		}
	}
	if (parts.size() == 1) {
		cout << (solve(n, n, false) + 1) % mod << '\n';
	} else {
		cout << solve(n, bound, true) << '\n';
	}
}

ll solve(int n, int bound, bool parity) {
	dp[0] = 1;
	pref[0][0] = 1;
	if (!parity) {
		pref[0][1] = 1;
	}
	for (int i = 1; i <= n; ++i) {
		int lo = max(0, i - bound - 1), hi = i - 2;
		if (lo <= hi) {
			dp[i] = pref[hi][hi & 1] - (lo > 0 ? pref[lo - 1][hi & 1] : 0);
			dp[i] += mod;
			dp[i] %= mod; 
		}
		pref[i][0] = pref[i - 1][0];
		pref[i][1] = pref[i - 1][1];
		pref[i][i & 1] += dp[i];
		pref[i][i & 1] %= mod;
		if (!parity) {
			pref[i][(i + 1) & 1] = pref[i][i & 1];
		}
		// cout << i << ' ' << dp[i] << '\n';
	}
	ll ans = dp[n];
	for (int i = 1; i < n and i <= bound; ++i) {
		int lo = max(i, n + (i - 1) - bound) - i, hi = n - i - 1;
		if (lo <= hi) {
			ans += pref[hi][n & 1] - (lo > 0 ? pref[lo - 1][n & 1] : 0);
			ans += mod;
			ans %= mod;
		}
	}
	return ans;
}

Measured memory_bytes: 5576
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
x=n//min(l)
if min(l)!=1:
    print(5+x)
else:
    print(4+x)


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

int main(void){
    char ch;
    while(((ch = cin.get()) != 'EOF') && (ch != '\n')){
        if(islower(ch)) ch = toupper(ch);
        else if(isupper(ch)) ch = tolower(ch);
        cout << ch;
    }
    cout << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    string s; cin >> s;
    string ans = "";
    rep(i, s.size()){
        if(s[i] == 'B'){
            if(ans.size()) ans.erase(ans.size()-1, 1);
        }
        else ans += s[i];
    }
    cout << ans << endl;
}


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

int main()
{
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    int c[s.size()];
    for(int i=0;i<s.size();i++){
        c[i] = 0;
            switch (s[i])
            {
            case 'A':
                c[i] = 1;
                break;
            case 'T':
                c[i] = 1;
                break;
            case 'C':
                c[i] = 1;
                break;
            case 'G':
                c[i] = 1;
                break;
            default:
                break;
            }
        
    }
    for(int j=0;j<s.size();j++){
        if(c[j] == 0){
            a = 0;
        }
        else if(c[j] == 1){
            a++;
            if(a>=b){
                b = a;
            }
        }
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    }
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt), * )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(a:i32, b:i32, c:i32);
    let r = c - (a - b);
    if r > 0 {
        println!("{}", c - (a - b));
    }
    else {
        println!("{}", 0);
    }
}

Measured memory_bytes: 4352
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package here;

/**
 *
 * @author sokumar
 */
import java.util.*;
import java.io.*;
public class Main {
    static ArrayList<Integer> []hs;
    static boolean []vis;
    static int []level;
    static int []indegree;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        
            int n = sc.nextInt();
            int m = sc.nextInt();
            hs = new ArrayList[n+1];
            level = new int[n+1];
            indegree = new int[n+1];
            for(int i=1;i<=n;i++)
            {
                hs[i] = new ArrayList<>();
            }
            for(int i=0;i<m;i++)
            {
                int u = sc.nextInt();
                int v = sc.nextInt();
                hs[u].add(v);
                indegree[v] += 1;
            }
            Queue<Integer> q = new LinkedList<>();
            for(int i=1;i<=n;i++)
            {
                if(indegree[i]==0)
                    q.add(i);
            }
            while(!q.isEmpty())
            {
                int j = q.poll();
                for(int i=0;i<hs[j].size();i++)
                {
                    indegree[hs[j].get(i)]--;
                    level[hs[j].get(i)] = Math.max(level[j]+1, level[hs[j].get(i)]);
                    if(indegree[hs[j].get(i)]==0)
                        q.add(hs[j].get(i));
                }
            }
            int max = Integer.MIN_VALUE;
            for(int i=1;i<=n;i++)
            {
                max = Math.max(max, level[i]);
            }
            w.println(max);
            
            
        w.close();
    }
    
    
}


Measured memory_bytes: 103284
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (s - i - j <= k && s - i - j >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35692
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
     dy[8] = { 1,1,0,-1,-1,-1,0,1 };

template<class T>bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    char s[4];
    cin>>s;
    Yes(s[0]==s[2]);
}

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int n[3];
    rep(0, 3) cin >> n[i];

    sort(n, n + 3);

    cout << (n[0] + (n[1] + n[2] * 10)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
vector <int> G[MAXN];
int subsz[MAXN];
int dfs(int pos, int prev, int cdep, int maxdep)
{
	subsz[pos] = 1;
	int ret = 0;
	for (int i = 0; i < G[pos].size(); ++i)
	{
		if(G[pos][i] != prev)
		{
			ret+=dfs(G[pos][i], pos, cdep+1, maxdep);
			subsz[pos]+=subsz[G[pos][i]];
		}
	}
	if(cdep > maxdep)
		return subsz[pos];
	return ret;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for (int i = 0; i < n-1; ++i)
	{
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int ans = n;
	if(k%2)
	{
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 0; j < G[i].size(); ++j)
			{
				int u = i, v = G[i][j];
				if(u > v)
					continue;
				int temp = dfs(u,v,0,(k-1)/2) + dfs(v,u,0,(k-1)/2);
				ans = min(ans, temp);
			}
		}
	}
	else
	{
		for (int i = 1; i <= n; ++i)
		{
			int temp = dfs(i,0,0,k/2);
			ans = min(ans, temp);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
int dx[8] = { -1,-1,-1,0,0,1,1,1, };
int dy[8] = { 1,0,-1,1,-1,1,0,-1 };


void solve() {
	int N; cin >> N;
	string S; cin >> S;
	vector<int>cumB(N + 1), cumW(N + 1);
	REP(i, N) {
		cumB[i + 1] += cumB[i];
		cumW[i + 1] += cumW[i];
		if (S[i] == '#')cumB[i + 1]++;
		else cumW[i + 1]++;
	}
	ll ans = 1e9;
	REP(i, N + 1) {
		int res = cumW[N] - cumW[i] + cumB[i] - cumB[0];
		ans = min(res, ans);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 3732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
vector<string>s;
vector<vector<bool>>visited;
ll h,w,white,black;
char color[2]={'#','.'};

void dfs(int x,int y,int c){
  visited[x][y]=true;
  rep(i,4){
    int nx=x+dx[i];int ny=y+dy[i];
    if(nx<0||nx>=h||ny<0||ny>=w)continue;
    if(visited[nx][ny])continue;
    if(s[nx][ny]!=color[c]){
      if(c==0)++white;
      else ++black;
      dfs(nx,ny,1-c);
    }
  }
}
void solve(){
  cin>>h>>w;
  s.resize(h);
  rep(i,h)cin>>s[i];
  ll ans=0;
  visited.resize(h,vector<bool>(w,false));
  rep(i,h)rep(j,w){
    if(s[i][j]=='#'){
      black=1;white=0;
      dfs(i,j,0);
      ans+=white*black;
    }
  }
  cout<<ans<<"\n";
  return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}

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

int main(){
    int n,i,x;
    cin>>n;
    set<int> a;
    for(i=0;i<n;i++){
        cin>>x;
        a.insert(x);
    }
    n==a.size() ? cout<<"YES" : cout<<"NO";
    return 0;

}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9 + 7;

int x, y;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y;
  int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
  if ((x+y)%3 || a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  ll D = 1, d = 1, m = min(a, b), n = a + b;
  for (int i = 0; i < m; ++i) {
    D = D * (n-i) % M;
    d = d * (i+1) % M;
  }
  // d^-1 mod M = d^M-2 mod M
  ll p = M-2, id = 1;
  while (p != 0) {
    if (p%2 == 0) {
      d = d * d % M;
      p /= 2;
    } else {
      id = id * d % M;
      p -= 1;
    }
  }
  cout << (D * id % M) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int N, Value;
    int max=0, maxl, semi=0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> Value;
        if(Value>max){
            semi = max;
            maxl = i;
            max = Value;
        } else if(Value > semi) semi = Value;
    }
    for(int i = 0; i < N; i++){
        if(i == maxl) cout << semi << endl;
        else cout << max << endl;
    }
    return 0;
}


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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

int main() {
	int A,B,C;
	cin>>A>>B>>C;
  	int maxx=max(A,B);maxx=max(maxx,C);
	int ans=A+B+C+9*maxx;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int N = 1e5+5;
vector<int> adj[N];
int max_powah[N],color[N];
void dfs(int u, int d, int c){
    if(max_powah[u] >= d)
        return;
    max_powah[u] = d;
    if(color[u] == 0)
        color[u] = c;
    for(int v : adj[u])
        dfs(v,d-1,c);
}
int main(){
    int n,m,q;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cin >> q;
    vector<int> u(q),d(q),c(q);
    for(int i = 0; i < q; ++i)
        scanf("%d %d %d",&u[i],&d[i],&c[i]);
    reverse(u.begin(),u.end());
    reverse(d.begin(),d.end());
    reverse(c.begin(),c.end());
    for(int i = 1; i <= n; ++i)
        max_powah[i] = -1;
    for(int i = 0; i < q; ++i)
        dfs(u[i],d[i],c[i]);
    for(int i = 1; i <= n; ++i){
        printf("%d\n",color[i]);
    }
}


Measured memory_bytes: 8440