akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String input = br.readLine();
			if(input.equals("0")){
				break;
			}
			Integer result = 0;
			for(int i = 0; i < input.length(); i++){
				result += Character.getNumericValue(input.charAt(i));
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 16916
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>

using namespace std;
 
int main(){
    string S;
    map<char, int> D;
  
    cin >> S;

    for(int i = 0; i < S.size(); i++){
        if(D[S[i]] == 1){
            cout << "no" << endl;
            exit(0);
        }else{
            D[S[i]]++;
        }
    }

    cout << "yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi 2*acos(0.0)
#define MOD 1000000007
#define N 100001
#define SZ 100000
int main()
{
    ll n,ans=0,i,temp=1;
    map<ll,int>mp;
    cin>>n;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            temp=i;
            //cout<<i<<" ";
            while(n%temp==0)
            {
                ans++;
                n/=temp;
                //cout<<temp<<" ";
                temp*=i;
            }
        }
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }
        }
    }
    //puts("");
    if(n>1)
        ans++;
    //cout<<n<<endl;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    long long n, a, b, prev, curr, ret = 0ll;
    std::cin >> n >> a >> b >> prev;
    for (auto i = 1ll; i < n; i++) {
        std::cin >> curr;
        ret += std::min(b, (curr - prev) * a);
        prev = curr;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len = s.length();
	int mark = 0;
	for (int i = 0; i <= len - 1; i++)
	{
		if (s[i] == s[i + 1] && i + 1 < len)
		{
			mark = 1;
			cout << i + 1 << " " << i + 2 << endl;
			break;
		}
		else if (s[i] == s[i + 2] && i + 2 < len)
		{
			cout << i + 1 << " " << i + 3 << endl;
			mark = 1;
			break;
		}
	}
	if (mark == 0)
		cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3732
import numpy as np
import sys

N = int(input())
b = list(map(int, input().split()))
ans = [0] * N

for i in range(N, 0, -1):
    if i in b[:i-1]:
        print(-1)
        sys.exit()
    for j in range(i, 0, -1):
        if j == b[j - 1]:
            ans[i - 1] = j
            del(b[j - 1])
            break

for i in ans:
    print(i)

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main() {
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll l = n/gcd(n, m)*m;
    ll g = gcd(n, m);
    bool j = true;
    lrep(i, 0, g){
        if(s[i*l/m]!=t[i*l/n])j = false;
    }
    if(j)cout << l << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3744
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define M_PI 3.14159265358979
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main()
{
	int N;
	cin >> N;
	vector<int> L(N, 0);
	rep(i, N) {
		cin >> L[i];
	}

	sort(L.rbegin(), L.rend());
	int ans = 0;

	for (int i = 0; i < (N - 2); ++i) {
		for (int j = i + 1; j < (N - 1); ++j) {
			for (int k = j + 1; k < N; ++k) {
				if (L[i] < L[j] + L[k]) {
					ans += 1;
				}
			}
		}
	}

	cout << ans << endl;
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int N, T, A, H;
    cin >> N;
    cin >> T >> A;

    int ans = 1;
    double dif, min = 500;
    int i;
    for (i = 1; i <= N; i++)
    {
        cin >> H;
        dif = A - (T - H * 0.006);
        if (dif < 0)
        {
            dif = -dif;
        }
        if (min > dif)
        {
            min = dif;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template<int MOD>
struct ModInt {
  ll x;
  ModInt():x(0){}
  ModInt(ll x):x((x%MOD+MOD)%MOD){}
  int getMod() { return MOD; }
  ModInt operator-() const { return ModInt(0) - *this;}
  ModInt& operator+=(const ModInt& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator-=(const ModInt& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator*=(const ModInt& a){ (x*=a.x)%=MOD; return *this;}
  ModInt operator+(const ModInt& a)const{ return ModInt(*this) += a;}
  ModInt operator-(const ModInt& a)const{ return ModInt(*this) -= a;}
  ModInt operator*(const ModInt& a)const{ return ModInt(*this) *= a;}
  bool operator<(const ModInt& a)const{ return x < a.x;}
  bool operator==(const ModInt& a)const{ return x == a.x;}
  ModInt pow(ll t) const {
    if (!t) return 1;
    ModInt a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  friend istream & operator >> (istream & in, ModInt & v) {
    ll x;
    in >> x;
    v.x = x;
    return in;
  }
  friend ostream & operator << (ostream & out, ModInt<MOD> const & v) {
    out << v.x;
    return out;
  }
};
const int MOD = 1000000007;
using mint = ModInt<MOD>;

int main() {
  int n; cin >> n;
  vector<mint> A(n);
  loop(i,0,n) cin >> A[i];
  vector<mint> acc(n+1);
  acc[0] = 0;
  loop(i,0,n) acc[i+1] = acc[i] + A[i];

  mint ans = 0;
  loop(i,0,n-1) {
    ans += A[i] * (acc[n]-acc[i+1]);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> g(h);
  vector<int> dy = {1, 0, -1, 0};
  vector<int> dx = {0, 1, 0, -1};
  int nm = 0;
  vector<int> cnt(4);
  for (int i = 0; i < h; ++i) {
    cin >> g[i];
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (g[i][j] == '#') {
        ++nm;
        for (int k = 0; k < 4; ++k) {
          int ni = i + dy[k];
          int nj = j + dx[k];
          if (ni >= 0 && ni < h) {
            if (nj >= 0 && nj < w) {
              if (g[ni][nj] == '#') {
                ++cnt[k];
              }
            }
          }
        }
      }
    }
  }
  if (nm == (h + w - 1) && cnt[0] == h - 1 && cnt[1] == w - 1) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;

int main(void) {
	int n, m;
	int x, y;
	int a[51], b[51], c[51], d[51], mini[51],flag[51] ;
	cin >> n >> m;
	FOR(i, 1, n) {
		cin >> a[i] >> b[i];
	}
	FOR(i, 1, m) {
		cin >> c[i] >> d[i];
	}
	FOR(i, 1, n) {
		FOR(t, 1, m) {
			x = abs(a[i] - c[t]);
			y = abs(b[i] - d[t]);
			if (t == 1) {
				mini[i] = x + y;
				flag[i] = 1;
			}
			if (mini[i] > x + y) {
				mini[i] = x + y;
				flag[i] = t;
			}
		}
	}
	FOR(i, 1, n) {
		cout << flag[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests, vector<int>&last, vector<int>&satis, int beg) {
  //vector<int> contests(d);
  //vector<int> last(26, 0);
  for (int i = 0; i < 26; i++) last[i] = 0;
  int sat = (beg == 0) ? 0 : satis[beg-1];
  //int sat = 0;
  //makecontest(s, c, last, contests);

  for (int i = 0; i < d; i++) {
    //cout << d << " " << i << endl;
    last[contests[i]-1] = i+1;
    if (i < beg) continue;
    sat += s[i][contests[i]-1];
    for (int j = 0; j < 26; j++) {
      sat -= c[j] * (i+1 - last[j]);
    }
    //cout << sat << endl;
    satis[i] = sat;
  }
  return sat;
}

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

  int d;
  cin >> d;
  vector<int> c(26);
  for (int i = 0; i < 26; i++) cin >> c[i];
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<int> contests(d);
  //for (int i = 0; i < d; i++) cin >> contests[i];
  for (int i = 0; i < d; i++) {
    int mx = 0, ct;
    for (int j = 0; j < 26; j++) {
      mx = max(mx, s[i][j]);
      if (mx == s[i][j]) ct = j+1;
    }
    contests[i] = ct;
  }
  
  vector<int> last(26, 0);
  vector<int> satis(d, 0), rec(d);
  int sc = score(d, s, c, contests, last, satis, 0);
  for (int i = 0; i < d; i++) rec[i] = satis[i];
  //cout << sc << endl;
  for (int p = 0; p < 200000; p++) {
    srand(p);
    int day = rand() % d;
    int q = rand() % 26;
    //cout << day << " " << q << endl;
    int old = contests[day];
    contests[day] = q + 1;
    int ts = score(d, s, c, contests, last, satis, day);
    //cout << ts << endl;
    if (ts < sc) {
      contests[day] = old;
      for (int i = day; i < d; i++) satis[i] = rec[i];
      continue;
    }
    sc = ts;
    for (int i = day; i < d; i++) rec[i] = satis[i];
    //cout << sc << endl;
  }
  //cout << sc << endl;

  for (int i = 0; i < d; i++) cout << contests[i] << endl;
}


Measured memory_bytes: 3696
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
int main(){
  int M, D;
  int i, j, k, l;
  int X[100], Y[99], tmp[2];
  int ans =0;
  scanf("%d %d", &M, &D);
  for(i=0; i<M; i++) X[i]=i+1;
  for(i=0; i<D; i++) Y[i]=i+1;
  for(i=3; i<M; i++){
    for(j=1; j<D; j++){
      tmp[0]=Y[j]/10;
      tmp[1]=Y[j]%10;
      if(X[i] == tmp[0] * tmp[1] && tmp[1] != 1 && tmp[0] != 1) ans++;
    }
  }
   printf("%d", ans);
}

Measured memory_bytes: 128
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=3005;
const double EPS=1e-9;

double p[SIZE],dp[SIZE][SIZE];

int main(){
	/*main function start*/
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",p+i);
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++) for(int j=0;j<=i;j++){
		if(j>0) dp[i][j]+=dp[i-1][j-1]*p[i];
		if(j<i) dp[i][j]+=dp[i-1][j]*(1-p[i]); 
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++) ans+=dp[n][i];
	printf("%.12lf",ans);
	return 0;
}


Measured memory_bytes: 68992
#include <stdio.h>
int main(void)
{
    char o[500], e[500], ans[1000];
    int i=0, j=0, k=0, roop=1, cnto=0, cnte=0, cnt=0;
    scanf("%s", o);
    scanf("%s", e);
    while(o[i]!='\0'){
        cnto++;
        i++;
        cnt++;
    }
    i=0;
    while(e[i]!='\0'){
        cnte++;
        i++;
        cnt++;
    }
    i=0;
    if(cnto-cnte==0){
        while(e[i]!='\0'){
            if(roop%2==0){
                ans[k]=e[i];
                i++;
            }
            else{
                ans[k]=o[j];
                j++;
            }
            k++;
            roop++;
        }
    }
    else{
         while(o[j]!='\0'){
            if(roop%2==0){
                ans[k]=e[i];
                i++;
            }
            else{
                ans[k]=o[j];
                j++;
            }
            k++;
            roop++;
        }
    }
    ans[k]='\0';
    printf("%s\n", ans);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   int w = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int aw= a+ w;
    int bw= b + w;
    if(bw>a && aw>b){
      System.out.println(0);
    }else if(Math.abs(b-aw)<Math.abs(a-bw)){
      System.out.println(Math.abs(b-aw));
    }else{
      System.out.println(Math.abs(a-bw));
    }
  }
}


Measured memory_bytes: 21972
#include <iostream>
 
int main()
{
  long long N, result = 1;
  std::cin >> N;

  for(long long i = N / 2; i > 0; i--)
  {
    if(i * i <= N)
    {
      result = i * i;
      break;
    }
  }

  std::cout << result;
  return 0;
}

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

using namespace std;

int main(){

    int alpha[26]={};
    char ch, a;

    while( cin >> ch){
        if(ch == '\n'){break;}
        if('A' > ch){continue;}
        else if('Z' >= ch){alpha[ch-'A']++;}
        else if('a' > ch){continue;}
        else if('z' >= ch){alpha[ch-'a']++;}        
    }

    for(int i=0; i< 26;i++){
        a = i + 'a';
        cout << a << " : " << alpha[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb(a) push_back(a)
const int N = 2e5 + 10;
int n; char s[N];

struct edge{ int to, pre; } e[N << 1]; int u[N], l = 0;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int f[N], g[N], high[N], low[N];
void dfs(int x, int fa) {
	if (s[x] == '1') low[x] = 0; else low[x] = n;
	reg(i,x) if (v != fa) {
		dfs(v, x), 
		f[x] = max(f[x], f[v] + 1), 
		low[x] = min(low[x], max(f[v] + 1, low[v] + 1));
	}
}

int a[N];
void dfs2(int x, int fa) {
	int mx = g[x], mxa = 0, mx1 = 0;
	reg(i,x) if (v != fa) {
		if (f[v] + 1 >= mx) mx1 = mx, mx = f[v] + 1, mxa = v;
		else if (f[v] + 1 > mx1) mx1 = f[v] + 1;
	}
	reg(i,x) if (v != fa) {
		if (v == mxa) g[v] = mx1 + 1, low[v] = min(low[v], max(low[x] + 1, mx1 + 1));
		else g[v] = mx + 1, low[v] = min(low[v], max(low[x] + 1, mx + 1));
	}
	high[x] = max(f[x], g[x]) - 1;
	high[x] = min(high[x], mx1 + 1);

	reg(i,x) if (v != fa) dfs2(v, x);
}

int main() {
	scanf("%d",&n);
	rep(i,1,n - 1) {
		int a, b; scanf("%d%d",&a,&b);
		ins(a, b), ins(b, a);
	}
	scanf("%s",s + 1);
	dfs(1,0);
	dfs2(1,0);
	LL ans = 1;
	rep(i,1,n) if (low[i] <= high[i]) ans += high[i] - low[i] + 1;
	printf("%lld\n",ans);
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

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

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N, M; cin >> N >> M;
	print((1900 * M + 100 * (N - M)) * pow(2, M));
}

Measured memory_bytes: 256
def chmax_a(l,B,C,i):
	return max(B+l[i][1],C+l[i][2])

def chmax_b(l,A,C,i):
	return max(A+l[i][0],C+l[i][2])

def chmax_c(l,A,B,i):
	return max(B+l[i][1],A+l[i][0])

if __name__=='__main__':
	N=int(input())
	happiness=[]
	for i in range(N):
		cost=list(map(int,input().split()))
		happiness.append(cost)
	answers=[]
	A=0
	B=0
	C=0
	for i in range(N-1,-1,-1):
		a=chmax_a(happiness,B,C,i)
		b=chmax_b(happiness,A,C,i)
		c=chmax_c(happiness,A,B,i)
		A=a
		B=b
		C=c
	print(max(A,B,C))

Measured memory_bytes: 30592
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	ll N, A, B, C, D;
	bool flg = false;
	cin >> N >> A >> B >> C >> D;
	for(int i = 1; i < N-1; i++) {
		ll ab, ba;
		ab = i;
		ba = N-1 -i;
		if(A + ab * C <= B + ba * D && B + ba * C <= A + ab * D)
			flg = true;
		if(A - ab * C >=  B - ba * D && B - ba * C >= A - ab * D)
			flg = true;
	}
	if(flg)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int X,N;
  cin>>X>>N;
  int P[N],CNT[300];
  REP(i,300) CNT[i]=0;
  REP(i,N){
    cin>>P[i];
    CNT[P[i]+100]++;
  }
  
  int ans=-100,T=X+100;
  REP(i,300){
    if(CNT[i]==0 && abs(i-100-X)<T){
      T=abs(i-100-X);
      ans=i-100;
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 3632
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

constexpr ll lim = 1000000000000000ll;

int main()
{
	using namespace std;
	using std::cin;

	ll h;
	cin >> h;

	ll ans{};

	for (ll i = 1; h > 0; i *= 2)
	{
		ans += i;
		h /= 2;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int S ;
  cin >> S ;
  int H , J , I ;
  H = S / 100 ;
  S = S % 100 ;
  J = S / 10 ;
  S = S % 10 ;
  I = S / 1 ;
  cout << H + J + I << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef long double ld;
//----head----
char str[2][60];
const ll mod=1e9+7;
int main()
{
	int n;
	scanf("%d%s%s",&n,str[0],str[1]);
	ll ans;
	if(str[0][0]==str[1][0])ans=3;
	else ans=6;
	rep(i,1,n)
	{
		if(str[0][i-1]==str[1][i-1])ans=ans*2%mod;
		else if(str[0][i]!=str[0][i-1]&&str[0][i]!=str[1][i])ans=ans*3%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n,mx = 0;
    cin >> n;
    map<string,int> mp;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    for (auto i:mp) {
        mx = max(mx,i.second);
    }
    vector<string> kouho = {};
    for(auto i:mp){
        if(i.second == mx){
            kouho.push_back(i.first);
        }
    }
    sort(kouho.begin(),kouho.end());
    for (int i = 0; i < kouho.size(); ++i) {
        cout << kouho[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 26868
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF (1e10+5)
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define FRL(i,a,n) for(i=a;i<n;i++)
#define FR(i,n) FRL(i,0,n)
#define RFRL(i,n) for(i=n;i>=0;i--)
#define MOD 1000000007
#define fill(a) memset(dp,a,sizeof(dp));

using namespace std;

typedef long long int  ll;

typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector< pair<ll,ll> > vpi;
typedef set<ll> st;
typedef map<ll,ll> mp;
typedef unordered_map<ll,ll> ump;

template< class T>
T minn(T a,T b)
{
	return (a>b)?b:a;
}
template< class T>
T maxx(T a,T b)
{
	return (a>b)?a:b;
}


void FILE_OP()
{
	#ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("output2.txt", "w", stdout);
    #endif
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void SOLVE()
{

	
	ll tt,m,i,j,k,a,b,c,d,l,r;
	//cin>>tt;
	tt=1;
	//fill(-1)
	ll n,W;
    
    //ll dp[100010];
	while(tt--)
	{
		string s;
		cin>>s;
		cin>>n;
		string ch;
		ll cnt=0,pre=0;
		string str1="",str2="";
		while(n--)
		{
			cin>>a;
			if(a==1)
				pre=1;
			if(a==2)
			{
				
				cin>>b>>ch;
				//cout<<b<<ch<<"\n";
				if((cnt%2)==1)
				{
					if(b==1)
						b=2;
					else
						b=1;
				}
				
				if(b==1)
					str1=ch+str1;
				else
					str2=str2+ch;
					//cout<<ch+s<<"\n";
				
				//cout<<b<<ch<<"\n";
			}
			else
				cnt++;

			
		}
		//cout<<cnt<<"\n";
		s=str1+s;
		s=s+str2;
		l=s.length();
		if(cnt%2)
		{
			for(i=l-1;i>=0;i--)
				cout<<s[i];
			cout<<"\n";
		}
		else
		{
			for(i=0;i<=l-1;i++)
				cout<<s[i];
			cout<<"\n";	
		}


		
		
	}


		
}

int main()
{
	FAST_IO
	//FILE_OP();
	SOLVE();
	
	return 0;
}


Measured memory_bytes: 1300
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i=1;
		int a;
		while(true){
			if(i%3==0){
				System.out.printf(" %d", i);
			}else{
				a=i;
				while(true){ 
					if(a%10==3){
					System.out.printf(" %d", i);
					break;
					}
					a/=10;
					if(a==0){
						break;
					}
				}
			}
			if(i==n){
				System.out.println();
				break;
			}
			i++;

		}
	}
}

Measured memory_bytes: 38696
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> hana(n);
    vector<int> hana1(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        hana[i]=x;
        hana1[i]=x;
    }
    sort(hana1.begin(),hana1.end());
    int count=0;
//    cout <<hana1[n]<<endl<<endl;
    
    for(int i=1;i<=hana1[n-1];i++){
        bool hantei=0;
        for(int j=0;j<n-1;j++){
            if(hantei){
                if(hana[j]>=i){
                    hantei=1;
                    
                }else{
                    hantei=0;
                    count++;
                  //  cout <<"OK"<<endl;
                }
            }else{
                if(hana[j]>=i){
                    hantei=1;
                    //cout<<"大きい"<<hana[j]<<endl;
                }else{
                    hantei=0;
                }
            }
          //  cout<<hantei<<endl;
        }
        
        if(hantei){
                count++;
            }else{
                 if(hana[n-1]>=i){
                    count++;
                    //cout<<"大きい"<<hana[j]<<endl;
                }
            }
     //  cout << count <<endl;
     // cout<<endl;
    }
    cout << count <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double total;
  vector<double> a(N);
  //vector<double> b(N);
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
    total+=1/a[i];
  }
  cout<<1/total<<endl;
}
  

Measured memory_bytes: 3804
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
int main(){
	int n;
	cin>>n;
	int out=0;
	rep(i,n){
		int t=i+1;
		if(t%2==0)continue;
		int cnt=0;
		loop(j,1,t+1)if(t%j==0)cnt++;
		if(cnt==8)out++;
	}
	
	cout<<out<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int>>
#define mii map<int,int>
#define ll long long
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)
 
using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
ll modpow(ll x,int y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%mod2;
		y=y>>1;
		x=x*x%mod2;
	}
	return res;
}
ll ncr(int n,int r)
{
	ll f1=1,f2=1;
	loop(i,n-r+1,n+1)
	f1=f1*i%mod;
	loop(i,1,r+1)
	f2=f2*i%mod;
	return f1*modpow(f2,mod-2)%mod;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}









void solve()
{
	int x;
	cin>>x;
	if(x>=30)
	cout<<"Yes";
	else
	cout<<"No";
	
}

int main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	//cin>>t;
	while(t--)
	{
		//cout<<"Case #"<<z+1<<": ";
		solve();
		cout<<"\n";
	}
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
  a+=b; c+=d;
  if(a==c) cout<<"Balanced";
  else if(a>c) cout<<"Left";
  else cout<<"Right";
	
	return 0;
}


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

int main() {
  char S;
  int ans=0;

  for(int i=0; i<4; i++){
    cin >> S;
    if(S=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }

    cout << ans << endl;
  
return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int m=max(max(a,b),c);
	int sum=a+b+c;
	if(m*3%2==sum%2){
		cout<<(m*3-sum)/2;
	}else{
		cout<<((m+1)*3-sum)/2;
	}
	cout<<'\n';
}

Measured memory_bytes: 256
// Problem : D - Knapsack Queries on a tree
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define N 100005

void solve(){
    int n;
    cin>>n;
    vi w(n), v(n);
    for(int i=0;i<n;i++) cin>>v[i]>>w[i];
    int limit = min(n,512);
    vector<vi> dp(limit,vi(N));
    for(int i=0;i<N;i++) dp[0][i] = (i >= w[0] ? v[0] : 0);
    for(int i=1;i<limit;i++){
        int par = (i-1)/2;
        for(int j=0;j<N;j++){
            dp[i][j] = dp[par][j];
            if(j >= w[i]) dp[i][j] = max(dp[i][j], dp[par][j-w[i]]+v[i]);
        }
    }
    int q;
    cin>>q;
    while(q--){
        int u,l;
        cin>>u>>l;
        u--;
        vi nodes;
        while(u >= limit){
            nodes.pb(u);
            u = (u-1)/2;
        }
        int ans = 0;
        for(int mask=0;mask<(1<<(sz(nodes)));mask++){
            int curW = 0;
            int curV = 0;
            for(int i=0;i<sz(nodes);i++){
                if(mask & (1<<i)){
                    curW += w[nodes[i]];
                    curV += v[nodes[i]];
                }
            }
            if(curW <= l) ans = max(ans, dp[u][l-curW] + curV);
        }
        cout<<ans<<'\n';
    } 
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 206472
from collections import Counter

n = int(input())
a = [int(item) for item in input().split()]
a.sort()
ca = Counter(a)
max_a = a[-1] 

ans = 0
for item in a[::-1]:
    if ca[item] == 0:
        continue
    for i in range(31, 0, -1):
        inv = (1 << i) - item
        if inv < 0 or inv > max_a:
            continue
        if item == inv:
            if ca[inv] > 1:
                ans += 1 
                ca[inv] -= 2
                break
        else:
            if ca[inv] > 0:
                ans += 1 
                ca[inv] -=1
                ca[item] -=1
                break
print(ans)

Measured memory_bytes: 33216
#include<iostream>
#include<vector>
using namespace std;
int A[100010];
int partition(int p, int r);
int main()
{
	int n;
	cin >> n;
	for(int i=0; i<n; i++)
		scanf("%d", &A[i]);
	int basis = partition(0, n-1);
	for(int i=0; i<n; i++)
	{
		if(!i) 
			cout << A[i];
		else if(i == basis)
			printf(" [%d]",A[i]);
		else 
			printf(" %d",A[i]);
	}
	cout << endl;
	return 0;
}
int partition(int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for(int j=p; j<r; j++)
	{
		if(A[j] <= x)
		{
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}



Measured memory_bytes: 3496
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
        if (data.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        if (data.at(i) <= 1000000000000000000 / ans) {
            ans *= data.at(i);
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
NT = input()
N, T = NT.split(" ")

mincost = 1001
mintime = 1001
for i in range(int(N)):

    ct = input()
    c, t = ct.split(' ')
    if int(t) <= int(T) and int(c) < mincost:
        mincost = int(c)
        mintime = int(t)

if mincost == 1001:
    print('TLE')
else:
    print(mincost)

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

int main(){
	int e, y;
	const int Y = 1868;
	cin >> e >> y;
	switch(e){
		case 0:
			if(y<=1911) cout << "M" << y-1867 << endl;
			else if(y<=1925) cout << "T" << y - 1911<<endl;
			else if(y <=1988) cout<<"S"<<y-1925<<endl;
			else cout<<"H"<<y-1988<<endl;
			break;
		case 1:
			cout<<y+1867<<endl;
			break;
		case 2:
			cout<<y+1911<<endl;
			break;
		case 3:
			cout<<y+1925<<endl;
			break;
		case 4:
			cout<<y+1988<<endl;
	}
	return 0;
}


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

int main() {
  int N;
  int H[110];
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> H[i];

  int hotel = 1;
  int max = H[0];
  for (int i = 1; i < N; ++i) {
    if (H[i] >= max) {
      ++hotel;
      max = H[i];
    }
  }
  cout << hotel << endl;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000000]={false};


void makeERA(){
    for(int i=2;i<10000001;i++){
        if(era[i]!=true)continue;
        for(int j=2;;j++){
            if(i*j<=10000000)
                era[i*j]=false;
            else break;
        }
    }
    era[2]=true;
}




int main(){
    for(int i=0;i<10000000;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        
        for(int i=n;i>=0;i--){
            if(era[i-8] && era[i-6] && !era[i-4] && era[i-2] && era[i]){
                cout<<i<<endl;
                break;
            }
        }
    }
    
    
    return 0;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

vs32 pfac(101);

void prime_factorization(int x)
{
    for (int i = 2; i * i <= x; ++i)
    {
        while (x % i == 0)
        {
            ++pfac[i];
            x /= i;
        }
    }
    ++pfac[x];
}

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

    int n;
    cin >> n;

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

    int a, b, c, d, e;
    a = b = c = d = e = 0;
    for (int i = 2; i <= n; ++i)
    {
        if (pfac[i] >= 74) ++a;
        else if (pfac[i] >= 24 && pfac[i] < 74) ++b;
        else if (pfac[i] >= 14 && pfac[i] < 24) ++c;
        else if (pfac[i] >= 4 && pfac[i] < 14) ++d;
        else if (pfac[i] >= 2 && pfac[i] < 4) ++e;
    }
    b += a;
    c += b;
    d += c;
    e += d;
    int ans = a + b * (e - 1) + c * (d - 1) + d * (d - 1) / 2 * (e - 2);
    cout << ans << "\n";
    return 0;
}



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

int main() {
  int array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;
  
  cout << array[K-1] << endl;
}

Measured memory_bytes: 256
use strict;
use warnings;
package Scc;
sub new{
	return bless[map[],1..$_[1]],$_[0];
}
sub add_edge{
	my$self=shift;
	push@{$self->[$_[0]]},$_[1];
}
sub scc_ids{
	my$self=shift;
	my$now_ord=0;
	my$group_num=0;
	my@low;
	my@ord=(-1)x@{$self};
	my@ids;
	my@visited;
	my$dfs;
	$dfs=sub{
		my$v=shift;
		$low[$v]=$ord[$v]=$now_ord++;
		push@visited,$v;
		for my$to(@{$self->[$v]}){
			if($ord[$to]==-1){
				$dfs->($to);
				$low[$v]=$low[$to]if$low[$v]>$low[$to];
			}
			else{
				$low[$v]=$ord[$to]if$low[$v]>$ord[$to];
			}
		}
		if($low[$v]==$ord[$v]){
			my$u=-1;
			while($u!=$v){
				$u=pop@visited;
				$ord[$u]=@{$self};
				$ids[$u]=$group_num;
			}
			$group_num++;
		}
	};
	for(0..$#ord){
		$dfs->($_)if$ord[$_]==-1;
	}
	$_=$group_num-1-$_ for@ids;
	return($group_num,\@ids);
}
sub scc{
	my$self=shift;
	my($group_num,$ids)=$self->scc_ids();
	my@groups=map[],1..$group_num;
	for(0..$#{$ids}){
		push@{$groups[$ids->[$_]]},$_;
	}
	return\@groups;
}
package TwoSat;
push @TwoSat::ISA,qw(Scc);
sub new{
	return$_[0]->SUPER::new($_[1]*2);
}
sub add_clause{
	my$self=shift;
	$self->add_edge(2*$_[0]+!$_[1],2*$_[2]+!!$_[3]);
	$self->add_edge(2*$_[2]+!$_[3],2*$_[0]+!!$_[1]);
}
sub satisfiable{
	my$self=shift;
	my$ids=($self->scc_ids())[1];
	my@answer;
	for(0..@{$ids}/2-1){
		return 0 if$ids->[2*$_]==$ids->[2*$_+1];
		$answer[$_]=$ids->[2*$_]<$ids->[2*$_+1];
	}
	return(1,\@answer);
}
package main;
my($N,$D)=split$",<>;
my$twosat=TwoSat->new($N);
my@p;
for(1..$N){
	my($x,$y)=split$",<>;
	push@p,[$x,$y];
}
for my$i(0..$N-1){
	for my$j($i+1..$N-1){
		$twosat->add_clause($i,1,$j,1)if abs$p[$i][0]-$p[$j][0]<$D;
		$twosat->add_clause($i,1,$j,0)if abs$p[$i][0]-$p[$j][1]<$D;
		$twosat->add_clause($i,0,$j,1)if abs$p[$i][1]-$p[$j][0]<$D;
		$twosat->add_clause($i,0,$j,0)if abs$p[$i][1]-$p[$j][1]<$D;
	}
}
my($isok,$answer)=$twosat->satisfiable();
if($isok){
	print"Yes",$/;
	for(0..$N-1){
		print$p[$_][$answer->[$_]],$/;
	}
}
else{
	print"No",$/;
}


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

mod = 10 ** 9 + 7
N = 100000

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

#階乗計算
kai = [1, 1]
rev_kai = [1, inv_t[1]]
for i in range(2, N):
	kai.append(kai[-1] * i % mod)
	rev_kai.append(rev_kai[-1] * inv_t[i] % mod)

# コンビネーション計算
def cmb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    else:
        return kai[n] * rev_kai[r] * rev_kai[n-r] % mod

d = {}

# n1個 X n2個 X n3個
n1 = 0
n2 = 0
n3 = 0

for i, ai in enumerate(a):
    if ai not in d:
        d[ai] = i
    else:
        n1 = d[ai]
        n2 = i - d[ai] - 1
        n3 = n - i
        break

for i in range(1, n+2):
    ans = 0
    # Xを選ばない
    ans += cmb(n-1, i)
    # Xを2回選ぶ
    ans += cmb(n-1, i-2)
    # Xを1回選ぶ かつ Xの間からは選ばない
    ans += cmb(n-1-n2, i-1)
    # Xを1回選ぶ かつ Xの間から一つ以上選ぶ
    if i >= 2 and i <= n:
        ans += 2 * (cmb(n2+n1+n3, i-1) - cmb(n1+n3, i-1))

    print(ans % mod)


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

const long long MOD = 998244353;

void solve(long long N, long long S, std::vector<long long> A)
{
    // dp[i][j]: i個目まで選んだ状態の合計がj
    vector<vector<ll>> dp(N + 1, vector<ll>(S + 1));

    dp[0][0] = 1;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= S; j++) {
            dp[i + 1][j] = dp[i][j] * 2 % MOD;
            // 選ぶ
            if (j - A[i] >= 0) {
                dp[i + 1][j] += dp[i][j - A[i]];
                dp[i + 1][j] %= MOD;
            }
        }
    }

    cout << dp[N][S] << endl;
}

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


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

int main(){
	long long int N, Q;
	cin >> N >> Q;
	long long int i;
	char s[N];
	long long int l[Q], r[Q];
	for(i=1; i<=N; i++){
		cin >> s[i];
	}
	for(i=1; i<=Q; i++){
		cin >> l[i] >> r[i];
	}
	
	
	//先にどこがflgかを見てから各々の範囲で合計
	int num=0;
	int flg[N]={0};
	for(i=1; i<N; i++){
		if(s[i]=='A' && s[i+1]=='C'){
			num++;
		}
		flg[i+1] = num;
	}
	for(i=1; i<=Q; i++){
		cout << flg[r[i]]-flg[l[i]] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[20];
string sa;

void check(int n,int cnt=0,int m=-1){
	int i,j;
	if(n==cnt){
		for(i=0;i<n;i++){
			sa[i]=(char)((int)'a'+t[i]);
		}
		cout<<sa<<endl;
		return;
	}
	for(i=0;i<=m+1;i++){
		t[cnt]=i;
		check(n,cnt+1,max(i,m));
	}
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	sa.resize(n);
	check(n);
}

Measured memory_bytes: 1536