akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;
                          
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
    ll n,m;
    cin >> n >> m;
    vector <ll> a, b;
    for (int i = 0; i < n; i++) {
     	ll x;
     	cin >> x;
     	a.pb(x);
    }
    for (int j = 0; j < n; j++) {
     	ll x;
     	cin >> x;
     	b.pb(x);
    }
    sort(all(a));
    sort(all(b));
    reverse(all(b));
    ll left = 0, right = 1e13;
    while (right - left > 1) {
    	ll mid = (left + right)/2;
    	ll temp = 0;
    	for (int i = 0; i < n; i++) {
    		if (a[i]*b[i] >= mid) {
    			temp += (a[i] - mid/b[i]); 	
    		}
    	}
    	if (temp <= m) {
    	 	right = mid;
    	}
    	else {
    	 	left = mid;
    	}
    }
    ll temp = 0;
    	for (int i = 0; i < n; i++) {
    		if (a[i]*b[i] >= left) {
    			temp += (a[i] - left/b[i]); 	
    		}
    	}
    	if (temp <= m) {
    	 	cout << left;
    	 	re 0;
    	}
    	else {
    cout << left + 1;
    }	
    re 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    for(int i = 0;i < 5;++i){
        int x;
        cin >> x;
        if(x == 0){
            cout << i+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3564
n, k = map(int, input().split())
s = input()
s = "_" + s + "_"

count = 0
for i in range(1, n+1):
  if s[i] == s[i-1] == "R" or s[i] == s[i+1] == "L":
    count += 1

print(min(n-1, count + k*2))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long

int dp[3005][3005];
string s1,s2;

int solve(int idx1,int idx2){
    if(idx1>=s1.size()||idx2>=s2.size()) return dp[idx1][idx2]=0;
    int &ans=dp[idx1][idx2];
    if(ans!=-1) return ans;
    if(s1[idx1]==s2[idx2]){
        return ans=1+solve(idx1+1,idx2+1);
    }
    else return ans=max(solve(idx1,idx2+1),solve(idx1+1,idx2));
    return ans;
}

int32_t main(){
    memset(dp,-1,sizeof(dp));
    cin>>s1>>s2;
    // cout<<solve(0,0)<<"\n";
    int l=solve(0,0);
    string ans;
    int i=0,j=0;
    while(ans.size()<l){
        if(dp[i+1][j]==dp[i][j]) i=i+1;
        else if(dp[i][j+1]==dp[i][j]) j=j+1;
        else if(dp[i+1][j+1]==dp[i][j]-1) ans.push_back(s1[i]),i=i+1,j=j+1;
    }
   
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 71040
N = int(input())
A = list(map(int, input().split()))

ans = [0] * N

# enumerate関数
# enumerate(イテラブル)
# 前の変数には0, 1, 2, ...のように0から開始して1ずつ増える数が入る
# 後ろの変数にはイテラブルの要素が入る
# enumerate関数は(番号, イテラブルの要素)というtupleを作るので
# それをアンパックして前の変数と後ろの変数に代入している
for i, a in enumerate(A):
    ans[a-1] = i+1

# アスタリスクをつけると中身だけを出力できる
# 細かい原理はよくわからん
# listだけでなくtupleでもできる
print(*ans)

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

int main()
{
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  int xmin = x - r;
  int ymin = y - r;
  int xmax = x + r;
  int ymax = y + r;
  if(xmin < 0 || w < xmax || ymin < 0 || h < ymax) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  bool a=true;
  H.at(0)--;
  if(N>=2){
    for(int i=1;i<N-1;i++){
      if(H.at(i)-1>=H.at(i-1) && H.at(i)-1<=H.at(i+1)){
        a=true;
        H.at(i)--;
      }
      else if(H.at(i)>=H.at(i-1) && H.at(i)<=H.at(i+1)){
        a=true;
      }
      else{
        a=false;
        break;
      }
    }
  }
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>

using namespace std;

const long long mod = 998244353;

const int MA = 1100100;

long long fact[MA], ifact[MA];
long long is[MA];

inline long long mul(long long a, long long b){
	return (a * b) % mod;
}

long long C(int n, int k){
	long long tmp = fact[n];
	tmp = mul(tmp, ifact[k]);
	tmp = mul(tmp, ifact[n - k]);
	return tmp;
}

long long iC(int n, int k){
	long long tmp = ifact[n];
	tmp = mul(tmp, fact[k]);
	tmp = mul(tmp, fact[n - k]);
	return tmp;
}
	

long long ways(int a, int b){
	return C(a + b, a);
}

long long iways(int a, int b){
	return iC(a + b, a);
}

void init(){
	fact[0] = 1;
	for(int i = 1; i < MA; ++i){
		fact[i] = mul(fact[i - 1], i);
	}
	is[1] = 1;
	for(int i = 2; i < MA; ++i){
		int k = mod / i;
		int r = mod % i;
		long long tmp = is[r] * (-k);
		tmp %= mod;
		if(tmp < 0) tmp += mod;
		is[i] = tmp;
	}
	ifact[0] = 1;
	for(int i = 1; i < MA; ++i){
		ifact[i] = mul(ifact[i - 1], is[i]);
	}
}

int N, M;

long long solve(){
	if(N < M) swap(N, M);
	long long ans = 0;
	for(int i = 0; i < M; ++i){
		int a = N - M + i;
		int b = i;
		long long tmp = ways(a, b);
		int c = M - i;
		long long tmp2 = ways(c, c);
		long long cur = mul(tmp, tmp2);
		ans += cur;
		if(ans > mod) ans -= mod;
	}
	if(ans % 2 == 0) ans /= 2;
	else ans = (ans + mod) / 2;
	long long iden = iways(N, M);
	ans = mul(ans, iden);
	ans += N;
	ans %= mod;
	ans += mod;
	ans %= mod;
	return ans;
}

int main(){
	scanf("%d%d", &N, &M);
	init();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 26112
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-9;//-14
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl n;
double m;

void input_var(){
    cin >> n >> m;
}
//-------------------------------------------------------------------------------


signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl a = (m + EPS) * 100;
    cout << (intl)(n * a / 100) << endl;
    return 0;
}

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

int main() {
  int X,Y;
  cin >> X >> Y;
  if (Y - 2*X >= 0 && (Y - 2*X)%2 == 0 && 4*X - Y >= 0 && (4*X - Y)%2 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
  int A,B; cin >>A >>B;
  bool flag=false;
  if (  (A+B)%3==0
      || A%3==0
      || B%3==0   ) flag=true;
  if (flag) cout <<"Possible" <<endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>
#include<utility>
#define inf 0x3f3f3f3f
#define lowbit(x) (x&-x)
typedef long long ll;

const int maxn=1e6+5;
const int mod=1e9+7;

using namespace std;
typedef pair<int,int>P;
int n;
int a[maxn];
int b[maxn];

void f(int x)
{
    for(int i=1;i*i<=x;i++)
    {
        if(x%i==0)
        {
            if(i*i==x)
                a[x]++;
            else
                a[x]+=2;
        }
    }
}

int main()
{
    for(int i=1;i<=1000000;i++)
        f(i);
    for(int i=1;i<=maxn;i++)
        b[i]=b[i-1]+a[i-1];
    scanf("%d",&n);
    printf("%d\n",b[n]);
}


Measured memory_bytes: 11044
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<char> A){rep(i,A.size()){cout << A[i];}cout << endl;}
void print(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << endl;}

int main(){
    int s;
    cin >> s;
    vector<int> n(4);
    rep(i,4){
        n[n.size()-1-i] = s%10;
        s /=10 ;
    }
    int a = n[0],b = n[1],c = n[2],d = n[3];
    rep(i,1 << 3){
        bitset<3> op(i);//1なら+ 0なら-
        int sum = a;
        vector<char> ans(3);
        if (op.test(0)){sum += b;ans[0] = '+';}
        else {sum -= b;ans[0] = '-';}
        if (op.test(1)){sum += c;ans[1] = '+';}
        else {sum -= c;ans[1] = '-';}
        if (op.test(2)){sum += d;ans[2] = '+';}
        else {sum -= d;ans[2] = '-';}
        if (sum == 7){
            cout << a << ans[0] << b << ans[1] << c << ans[2] << d << "=" << 7;
            exit(0);
        }
    }
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    cout << 360 / __gcd(x, 360) << '\n';
    return 0;
}


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

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

Measured memory_bytes: 1024
import java.io.*;

class Main {
    public static void main(String[] arg)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str = br.readLine();
            if(str.equals("0"))break;
            int sum = 0;
            for(int i=0;i<str.length();i++){
                sum = sum + Integer.parseInt("" +str.charAt(i));
            }
            System.out.println(sum);
        }
    }
}

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

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i = 0;i<n;i++)
    cin >> v[i];
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  for(int i = 0 ;i<n;i++)
  {
    for(int j = 1;j<=k;j++)
    {
      if(i+j < n)
      	dp[i+j] = min(dp[i+j],dp[i] + abs(v[i+j] - v[i])); 
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll n, y;
  cin >> n >> y;
  for(ll a = 0; a <= n; a++) {
    for(ll b = 0; b <= n - a; b++) {
      ll c = n - a - b;
      if(a * 10000 + b * 5000 + c * 1000 == y) {
	printf("%lld %lld %lld\n", a, b, c);
	return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  int n;
  cin >> n;
  vvi cnt(50, vi(26, 0));
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, s.size()) { cnt[i][s[j] - 'a']++; }
  }
  vi tmp(26, 0);
  rep(x, 26) {
    rep(i, n) {
      if (i == 0) {
        tmp[x] = cnt[i][x];
      } else {
        tmp[x] = min(tmp[x], cnt[i][x]);
      }
    }
  }
  rep(x, 26) {
    while (tmp[x] > 0) {
      cout << string(1, 'a' + x);
      tmp[x]--;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

bool dp[100][100][50000];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    vector<vector<int>> a(h,vector<int>(w));
    vector<vector<int>> b(h,vector<int>(w));
    rep(i,h)rep(j,w) cin>>a[i][j];
    rep(i,h)rep(j,w) cin>>b[i][j];
    int off=20000;
    dp[1][0][off]=true;
    dp[0][1][off]=true;
    vector<int> dx={1,0},dy={0,1};
    rep(i,h+1)rep(j,w+1)for(int k=-20000;k<=20000;k++){ 
        int now=off+k;
        if(!dp[i][j][now]) continue; 
        rep(l,2){
            int nx=i+dx[l],ny=j+dy[l];
            if(1<=nx && nx<=h && 1<=ny && ny<=w){
                dp[nx][ny][now+a[nx-1][ny-1]-b[nx-1][ny-1]]=true;
                dp[nx][ny][now+b[nx-1][ny-1]-a[nx-1][ny-1]]=true;
            }
        }
    }
    int ans=INF;
    for(int k=-20000;k<=20000;k++){
        if(dp[h][w][off+k]){
            chmin(ans,abs(k));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 391552
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef pair<int, int> II;

int main(int argc, char* argv[]) {

#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, t = -1;
		cin >> n >> t;
		if (n <= 0 || t < 0) return 0;
		vector<II> v(n);
		for (int i = 0; i < n; ++i) {
			cin >> v[i].first >> v[i].second;
		}
		sort(v.begin(), v.end());
		int ans = 0;
		vector<int> dp(t + 1, -1);
		dp[0] = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = t - 1; j >= 0; --j) {
				if (dp[j] >= 0) {
					ans = max(ans, dp[j] + v[i].second);
				}
				int k = j - v[i].first;
				if (k >= 0 && dp[k] >= 0) {
					dp[j] = max(dp[j], dp[k] + v[i].second);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char b;
vector<char> en{'A', 'C', 'G', 'T'};
int main() {
    cin >> b;
    if(b == en.at(0)) cout << en.at(3) << endl;
    else if(b == en.at(1)) cout << en.at(2) << endl;
    else if(b == en.at(2)) cout << en.at(1) << endl;
    else cout << en.at(0) << endl;
}

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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    for (int i = n; i <= m; ++i) {
        if (m % i == 0) {
            cout << m / i << endl;
            exit(0);
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

ll a,b;

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	a=rd(); b=rd();
	if(a*b <= 0){
		puts("Zero"); return 0;
	}
	if(a > 0){
		puts("Positive"); return 0;
	}
	if((b-a+1)%2 == 0) puts("Positive");
	else puts("Negative");
	return 0;
}//Faze


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

int main() {
	int n;
	scanf("%d", &n);
	
	int st = 0, ed = 1, ans = 0;
	for(bool f = true; ed<=n; f = !f) {
		st = ed; ed *= 10;
		if(f) ans += min(ed-1, n) - st + 1;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define INF 1e9+7
using namespace std;
typedef long long int ll;


int main() {

	int a, b;
	cin >> a >> b;


	if (a%b == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int res=s.size();
  string ans=s;
  int p=res-k;
  if(res<=k) cout << ans << endl;
  else {
    for(int i=0;i<p;++i) {
      ans.pop_back();
    }
    ans+="...";
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
n, *a = map(int, open(0).read().split())

unko = 2
unti = 2
for i in reversed(a):
    unko = unko // i * i + i - 1
    unti = (unti + i - 1) // i * i
if unti >= unko:
    print(-1)
else:
    print(unti, unko)


Measured memory_bytes: 19992
import java.util.Scanner;
 
class Main {
    public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int a,p,maxap;
 
	a = sc.nextInt();
	p = sc.nextInt();
 
	maxap = (3*a + p) /2;
 
	System.out.println(maxap);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string s;
    cin >> s;
    vector<bool> c(26);
    vector<bool> tmp(26);
    int n = s.length();
    for (int l = 1; l < n+1; l++) {
        fill(ALL(c), true);
        for (int i = 0; i < n-l+1; i++) {
            fill(ALL(tmp), false);
            for (int j = 0; j < l; j++) {
                tmp[s[i+j] - 'a'] = true;        
            }
            for (int j = 0; j < 26; j++) {
                if(!tmp[j]) c[j] = false;
            }
        }   

        for (int i = 0; i < 26; i++) {
            if(c[i]){
                printf("%d\n", l-1);
                return 0;
            }
        }

    }

}

Measured memory_bytes: 3680
N=int(input())
d=list(map(int, input().split()))

cumsum = 0
for n in range(N):
    cumsum += d[n]
sub_cumsum = 0
ans = 0
for n in range(N):
    sub_cumsum += d[n]
    ans += d[n] * (cumsum-sub_cumsum)
print(ans)


Measured memory_bytes: 3060
import collections
n=int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
c = collections.Counter(prime_factorize(n))
cc=list(c.keys())
def countcheck(x):
  a=0
  aa=0
  b=[1]
  while x>=a:
    a+=b[-1]
    c=b[-1]+1
    b.append(c)
    if x>=a:
      aa+=1
    
  return aa

ans=0

for x in range(len(cc)):
  dd=cc[x]
  d=c[dd]
  e=countcheck(d)
  ans+=e
  
print(ans)

Measured memory_bytes: 9264
#include <bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
void GetSol()
{
    string s;
    cin >> s;
    int cnt = 0, f = 0;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == s[i + 1] && s[i] == 'R')
            cnt++;
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'R')
            f = 1;
    }
    if (cnt != 0)
        cout << cnt + 1 << endl;
    else if (f == 1 && cnt == 0)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << cnt << endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        GetSol();
    }
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(void){
    for (int i = 0; i < 1000; i++){
        int a, b;
            cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        for (int j = 0; j < a; j++){
            for (int k = 0; k < b; k++){
                cout << "#";
                if (k == b - 1)
                    cout << endl;
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;
const ll N = 500005;
ll n,a,b; 
void solve(){
	
}
int main(){  
	cin.tie(0); 
    ios::sync_with_stdio(false);
	int T,m,k,sum=0;
	/*scanf("%d",&T); 
	while(T--){
		//solve();	
		
	}*/
	scanf("%lld%lld%lld",&n,&a,&b);
	ll ans=0;
	ans+=n/(a+b)*a;
	n%=(a+b);
	ans+=min(n,a);
	printf("%lld",ans);
	return 0;
}


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

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    //a b c
    rep(i, k){
        if(a >= c) {
            c *= 2;
        }
        else if(b >= c){
            c *= 2;
        } 
        else if(a >= b) {
            b *= 2;
        }
        else break;
    }
  // cout << a << " " << b << " " << c << endl;
    if(c > b && b > a && c > a) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	double a,d,ans=0;
	cin>>N>>a>>d;
	while(N){
		ans+=a+(N-0.5)*d;
		double na=(a*(2*N+2)+5*d)/(2*N);
		double nd=d*(N+2)/N;
		a=na,d=nd;
		N--;
	}
	printf("%.12f\n",ans);
}


Measured memory_bytes: 256
def MI(): return map(int, input().split())
H,W,K=MI()
Map=[input() for _ in range(H)]
ans=0
for gyou in range(1<<H):
  for retsu in range(1<<W):
    count=0
    for i in range(H):
      for j in range(W):
        if (gyou>>i)&1 and (retsu>>j)&1:
          if Map[i][j]=='#':
            count+=1
    if count==K:
      ans+=1
print(ans)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A==B) cout << C << endl;
  else if(A==C) cout << B << endl;
  else cout << A << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll h,w;cin >> h >>w;
    vector<vector<char>> grid(h,vector<char>(w));
    ll count=0;
    rep(i,h){
        rep(j,w){
            cin >> grid[i][j];
            if(grid[i][j]=='.')count++;
        }
    }
    queue<pl> que;
    que.push(mp(0,0));
    vvl dist(h,vl(w,-1));
    dist[0][0]=0;
    while(!que.empty()){
        pl v=que.front();
        que.pop();
        rep(i,4){
            ll nx=v.se+dx[i],ny=v.fi+dy[i];
            if(nx<0||ny<0||nx>=w||ny>=h)continue;
            if(grid[ny][nx]=='#')continue;
            if(dist[ny][nx]!=-1)continue;
            dist[ny][nx]=dist[v.fi][v.se]+1;
            que.push(mp(ny,nx));
        }
    }
    if(dist[h-1][w-1]==-1)cout << -1 <<endl;
    else cout << count-1-dist[h-1][w-1] <<endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort()
S=[0]
for i in range(N):
    S.append(S[i]+A[i])

lose=0
for i in range(N-1):
    if S[i+1]*2<A[i+1]:
        lose=i+1
print(N-lose)

Measured memory_bytes: 14320
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c,d,min1,min2;
    cin>>a>>b>>c>>d;
    min1=max(a,c);
    min2=min(b,d);
    if(c>=b)
    {
        cout<<0<<endl;
        return 0;
    }
    if(min2>=min1)
    cout<<min2-min1<<endl;
    else
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int s[] = new int[n+1];

		int cnt = 0;
		for(int i = 0; i < n; i++) {
			int val = Integer.parseInt(sc.next());
			if(val > n) {
				cnt++;
				continue;
			}

			s[val]++;
		}
		int sum = cnt;
		for(int i = 0; i < 100000; i++) {
			if(s[i] < i) {
				cnt += s[i];
			} else if(s[i] > i) {
				cnt += s[i] - i;
			}
			sum += s[i];

			if(n - sum < i) {
				cnt += n - sum;
				break;
			}
		}
		System.out.println(cnt);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

}


Measured memory_bytes: 35520
import java.util.*;

class Main {

    Main(){
        Scanner SC = new Scanner(System.in);
        int A = Integer.parseInt(SC.next());
        int B = Integer.parseInt(SC.next());
        int M = Integer.parseInt(SC.next());

        int A_MIN = Integer.MAX_VALUE, B_MIN = Integer.MAX_VALUE, Total_MIN = Integer.MAX_VALUE;

        int[] A_Cost = new int[A];
        for(int i=0;i<A;i++){
            A_Cost[i] = Integer.parseInt(SC.next());
            A_MIN = Math.min(A_MIN, A_Cost[i]);
        }

        int[] B_Cost = new int[B];
        for(int i=0;i<B;i++){
            B_Cost[i] = Integer.parseInt(SC.next());
            B_MIN = Math.min(B_MIN, B_Cost[i]);
        }

        Total_MIN = A_MIN + B_MIN;

        int x,y,c;
        for(int i=0;i<M;i++){
            x = Integer.parseInt(SC.next()) - 1;
            y = Integer.parseInt(SC.next()) - 1;
            c = Integer.parseInt(SC.next());

            Total_MIN = Math.min(Total_MIN, A_Cost[x] + B_Cost[y] - c);
        }

        System.out.println(Total_MIN);
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


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

const int N = 2200;
int n, ans = 0;
int a[N];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

int main() {
	n = read();
	for(int i = 1; i <= n; ++i)	a[i] = read();
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j)
			for(int k = j + 1; k <= n; ++k) {
				if(a[j] + a[k] > a[i] && a[i] + a[j] > a[k])	ans++;
				if(a[i] + a[j] <= a[k])	break;
			}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

using namespace std ;

const int N=2e6+10 ;
const int inf=1e9 ;

int f[N] ;

struct Node
{
	int v , p ;
	Node* ls ;
	Node* rs ;
	Node ():v(inf),p(0),ls(NULL),rs(NULL) {}
	void pushup ()
	{
		v=min(ls->v,rs->v);
		if ( v==rs->v ) p=rs->p;
		if ( v==ls->v ) p=ls->p;
	}
};
Node pool[N<<1] ;
Node* rt ;
inline Node* newNode ()
{
	static int cnt=0 ;
	return &pool[++cnt];
}

inline Node* build ( int l , int r )
{
	Node* x=newNode();
	x->p=l;
	if ( l==r ) return x ;
	int mid=(l+r)>>1 ;
	x->ls=build(l,mid),
	x->rs=build(mid+1,r),
	x->pushup();
	return x ;
}

inline void update ( Node* x , int l , int r , int p , int d )
{
	if ( l==r )
	{
		x->v=d;
		return ;
	}
	int mid=(l+r)>>1 ;
	if ( p<=mid ) update(x->ls,l,mid,p,d);
	else update(x->rs,mid+1,r,p,d);
	x->pushup();
	return ;
}
inline int query ( Node* x , int l , int r , int a , int b )
{
	if ( a<=l && r<=b ) return x->p ;
	int mid=(l+r)>>1 , v=inf , res=inf , t ;
	if ( b>mid )
		t=query(x->rs,mid+1,r,a,b),
		v=min(v,f[t]),
		res=(v==f[t]?t:res);
	if ( a<=mid )
		t=query(x->ls,l,mid,a,b),
		v=min(v,f[t]),
		res=(v==f[t]?t:res);
	return res ;
}

int from[N] ;
char S[N] ;
int n , m ;

inline void Print ( int x )
{
	if ( x==0 ) return ;
	Print(from[x]);
	printf("%d ",x-from[x]);
}

int main ()
{
	int i ;
	scanf(" %d %d %s ",&n,&m,S);
	for ( i=1 ; i<=n ; i++ ) f[i]=inf;
	rt=build(0,n);
	update(rt,0,n,0,0),f[0]=0;
	for ( i=1 ; i<=n ; i++ )
		if ( S[i]=='0' )
			from[i]=query(rt,0,n,max(0,i-m),i-1),
			f[i]=(( from[i]!=inf && f[from[i]]!=inf )?f[from[i]]+1:inf),
			update(rt,0,n,i,f[i]);
		else f[i]=from[i]=inf;
	// for ( i=1 ; i<=n ; i++ )
	// 	printf("%d ",from[i]); puts("");
	if ( f[n]!=inf ) Print(n);
	else puts("-1");
	return 0 ;
}


Measured memory_bytes: 100864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int H, W;  cin >> H >> W;
    char C[H][W];
    rep(i, H) {
        rep(j, W) {
            cin >> C[i][j];
        }
    }

    rep(i, 2*H) {
        rep(j, W) {
            cout << C[i/2][j];
        }
        cout << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> a(m);
    ll sum = 0;
    rep(i, m){
        cin >> a[i];
        sum += a[i];
    }
    if(sum <= n)cout << n - sum << endl;
    if(sum > n)cout << -1 << endl;
}



Measured memory_bytes: 3708
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    int w;
    cin >> w;
    
    rep(i, s.size())if(i%w == 0)cout << s[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 50;
const ll MOD = 998244353;

char s[N];

int main() {
	cin>>s;
  if(s[2] == s[3] && s[4] == s[5]) {
  	cout<<"Yes"<<endl;
  	}else {
  	cout<<"No"<<endl;
  }

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }
 
bool f[26];
 
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n=sz(s);
  rep(i,n){
    int m=s[i]-'a';
    f[m] = true;
  }
 
  if(n<26){
    rep(i,26){
      if(!f[i]){
        s+='a'+i;
        break;
      }
    }
      cout << s << endl;
  }
  else if(s=="zyxwvutsrqponmlkjihgfedcba") cout << "-1" << endl;
  else {
    string t=s;
    next_permutation(all(s));
    rep(i,n){
      cout << s[i];
      if(s[i]!=t[i]) break;
    }
    cout << endl;
  }
 
  return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 200010

typedef long long ll;
using namespace std;

int n, H[maxn], A[maxn], num;
ll fen[maxn];
vector<int> tran;

void build() {
    FOR(i, 1, n)
        tran.push_back(H[i]);
    sort(tran.begin(), tran.end());
    tran.resize(distance(tran.begin(), unique(tran.begin(), tran.end())));
    num = tran.size();
}
inline void update(const int &id,const ll &val) {
    for(int i=id; i<=num; i+=(i&(-i)))
        fen[i] = max(fen[i], val);
}
inline ll get(const int &id) {
    ll tres = 0;
    for(int i=id; i; i-=(i&(-i)))
        tres = max(tres, fen[i]);
    return tres;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
    FOR(i, 1, n) cin >> H[i];
    FOR(i, 1, n) cin >> A[i];
    build();
    memset(fen, 0, sizeof(fen));
    FOR(i, 1, n) {
        int id = lower_bound(tran.begin(), tran.end(), H[i]) - tran.begin();
        update(id+1, get(id) + A[i]);
    }
    cout << get(num);
	return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int> 
#define X first
#define Y second
int MOD = 1e9 + 7;

lli mymod (lli A) {
    A %= MOD;
    if (A < 0) A += MOD;
    return A;
}

int main () {
    int n, k;
    cin >> n >> k;
    int a[n];
    fop (i,0,n) cin >> a[i];
    vector <lli> dp(k+1), pre(k+1); // n people with <= k candies
    fop (i,0,k+1) {
        if (i <= a[0]) dp[i] = 1;
    }
    fop (i,1,n) {
        swap(dp, pre);
        fop (j,1,k+1) pre[j] = (pre[j] + pre[j-1]) % MOD;
        fop (j,0,k+1) {
            if (j - a[i] - 1 < 0) dp[j] = pre[j];
            else dp[j] = mymod(pre[j] - pre[j-a[i]-1]);
        }
    }
    cout << dp[k] << endl;
}

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

char S[4];
int main(void){
  cin>>S;
  int a=(S[0]-'0')*10+(S[1]-'0');
  int b=(S[2]-'0')*10+(S[3]-'0');
  bool A=false,B=false;
  if(a>0&&a<13) A=true;
  if(b>0&&b<13) B=true;
  if(A&&B) cout<<"AMBIGUOUS"<<endl;
  else if(A) cout<<"MMYY"<<endl;
  else if(B) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[3010][3010];

ll topdown(ll *arr,ll l,ll r)
{
    if(l>r)
    {
        dp[l][r]=0;
        return 0;
    }
    if(dp[l][r]!=-1)
    {
        return dp[l][r];
    }
    ll op1=arr[l]+min(topdown(arr,l+1,r-1),topdown(arr,l+2,r));
    ll op2=arr[r]+min(topdown(arr,l,r-2),topdown(arr,l+1,r-1));
    dp[l][r]=max(op1,op2);
    return dp[l][r];
}

int main()
{
    ll n=0,sum=0;
    cin>>n;
    ll *arr= new ll[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<2*topdown(arr,0,n-1)-sum;
    return 0;
}

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

int b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		cin >> b;
		if(b == 0) return 0;
		int m = 1e9, n = 0;
		for(int i=1; i*i<=2*b; ++i){
			if(2 * b % i != 0) continue;
			int c = 2 * b / i;
			if(i % 2 != c % 2){
				int s = (i + c - 1) / 2;
				int t = (i - c + 1) / 2;
				if(s > t) swap(s, t);
				if(s > 0 && s < m){
					m = s;
					n = t;
				}
				s = (c + i - 1) / 2;
				t = (c - i + 1) / 2;
				if(s > t) swap(s, t);
				if(s > 0 && s < m){
					m = s;
					n = t;
				}
			}
		}
		cout << m << " " << n - m + 1 << "\n";
	}
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,c;
  cin >> n >> c;
  vec x(n+2),v(n+2);
  for(ll i=1;i<n+1;i++){
    cin >> x[i] >> v[i];  
  }
  x[n+1]=c;

  vec s1(n+1),s2(n+1);
  for(ll i=0;i<n;i++){
    s1[i+1]=s1[i]+v[i+1]-(x[i+1]-x[i]);
    s2[i+1]=s2[i]+v[n-i]-(x[n+1-i]-x[n-i]);
  }

  vec m1(n+1),m2(n+1);
  for(ll i=0;i<n;i++){
    m1[i+1]=max(m1[i],s1[i+1]);
    m2[i+1]=max(m2[i],s2[i+1]);
  }

  vec t1(n+1),t2(n+1);
  for(ll i=1;i<n+1;i++){
    t1[i]=s1[i]-x[i];
    t2[i]=s2[i]-(c-x[n+1-i]);
  }


  ll ans=0;
  for(ll i=0;i<=n;i++){
    ans=max(ans,t1[i]+m2[n-i]);
    ans=max(ans,t2[i]+m1[n-i]);
  }

  cout << ans << endl;
  //cout << t1[2] << " " << m2[2] << endl;

  //for(ll i=0;i<n+1;i++)cout << t2[i] << " ";


}

Measured memory_bytes: 9600
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;




int n, m, dp[N], a, b, c;

main () {
	cin >> n >> m;
	forn (mask, 1, (1 << n) - 1)
		dp[mask] = INF;

	while (m--) {
		cin >> a >> b;
		int mask = 0;
		while (b--) {
			cin >> c;
			--c;
			mask |= (1 << c);
		}	
		
		for (int nMask = mask; nMask; nMask = (nMask - 1) & mask)
			dp[nMask] = min(dp[nMask], a);			
	}	

	forn (mask, 1, (1 << n) - 1) 
		for (int nMask = mask; nMask; nMask = (nMask - 1) & mask) 
			dp[mask] = min(dp[mask], dp[nMask] + dp[mask ^ nMask]);		


	if (dp[(1 << n) - 1] == INF)
		dp[(1 << n) - 1] = -1;
	cout << dp[(1 << n) - 1] << endl;		
}
                        

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();

		for (int i = y / 10000 ; i >= 0 ; i--) {
			if (y >= 10000 * i) {
				int n2 = n - i;
				int y2 = y - 10000 * i;
				if (y2 == 0 && n2 == 0) {
					finish(i,0,0);
				}
				for (int k = n2 ; k >= 0 ; k--) {
					int n3 = n2 - k;
					int y3 = y2 - 5000 * k;
					if (n3 * 1000 == y3) {
						finish(i,k,n-i-k);
					}
				}
			}
		}
		finish(-1,-1,-1);
	}

	private static void finish(int a, int b, int c) {
		System.out.println(a + " " + b + " " + c);
		System.exit(0);
	}
}

Measured memory_bytes: 21972
#include<iostream>

using namespace std;

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

    while(n!=0)
    {
        int digi1 = n%10;
        if(digi1==7)
        {
            cout << "Yes" << endl;
            break;
        }
        n = n/10;
        if(n==0 && digi1 != 7){
            cout << "No" << endl;
            break;
        }
        //cout << digi1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, m = map(int, readline().split())
    INF = int(1e5)+1
    mx = -1
    mi = INF 
    for _ in range(m):
        l, r = map(int, readline().split())
        mx = max(l, mx)
        mi = min(r, mi)
    ans = mi-mx+1
    if ans<0: 
        print(0)
        return
    print(mi-mx+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n,m;
  cin>>n>>m;
  int cnt[33]={};
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
	 int a;
	 cin>>a;
	 cnt[a]++;
    }
  }
  int ans=0;
  for(int i=1;i<=m;i++){
    ans+=(n==cnt[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256