akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
 
int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
 
        string s;
        cin >> s;
        
        for (int i = 0; i < (int)s.size() - 1; i++) {
                if (s[i] == s[i + 1]) {
                        cout << i + 1 << " " << i + 2 << endl;
                        return 0;
                }
        }
        
        for (int i = 0; i < (int) s.size() - 2; i++) {
                if (s[i] == s[i + 2]) {
                        cout << i + 1 << " " << i + 3 << endl;
                        return 0;
                }
        }
        cout << "-1 -1" << endl;
        return 0;
}

Measured memory_bytes: 512
import math
x = int(input())
exp = set()
# for i in range(x,0,-1):
#   if math.sqrt(i).is_integer():
#     print(i)
#     break
for b in range(1,x + 1):
  for p in range(2,int(math.log2(x)) + 1):
    if b ** p <= x:
      exp.add(b ** p)
if len(exp) == 0:
  print(1)
else:
  print(max(exp))

Measured memory_bytes: 3444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;


int main(){
   int A,B;
   long long K;
   cin >> A >> B>>K;
   for(int i=min(A,B);i>=1; i--){
      if(A%i==0 && B%i==0){
         K--;
         if(K==0){
            cout << i << endl;
            return 0;
         }
      }
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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 N,Q;
string s,ss;

vector<char> T;
vector<char> D;

bool chkleft(int pos){
    REP(i,Q){
        if (pos == -1) return true;
        char t = T[i];
        char d = D[i];

        if (s[pos] != t) continue;
        if (d == 'L') pos--;
        else pos++;
    }

    if (pos == -1) return true;
    else return false;
}

bool chkright(int pos){
    REP(i,Q){
        if (pos == -1) return true;
        char t = T[i];
        char d = D[i];

        if (s[pos] != t) continue;
        if (d == 'R') pos--;
        else pos++;
    }

    if (pos == -1) return true;
    else return false;
}

int lbinary_search(){
    // lower_bound (a-1,b] (ans = [a,b])
    // <= left never satisfy
    // right <= always satisfy

    int left = -1;
    int right = N+1; // index of size + 1;

    while(right - left > 1){
        int mid = left + (right - left) / 2;

        if (!chkleft(mid)) right = mid;
        else left = mid;
    }

    // left is the maximum that don't satisfy the condition.
    // right is the minimum that satisfies the condtion.

    return right;

}


int rbinary_search(){
    // lower_bound (a-1,b] (ans = [a,b])
    // <= left never satisfy
    // right <= always satisfy

    int left = -1;
    int right = N+1; // index of size + 1;

    while(right - left > 1){
        int mid = left + (right - left) / 2;

        if (!chkright(mid)) right = mid;
        else left = mid;
    }

    // left is the maximum that don't satisfy the condition.
    // right is the minimum that satisfies the condtion.

    return right;

}

int main() {
    cin >> N >> Q;
    cin >> ss;
    s = ss;
    s.PB('-');

    REP(i,Q){
        char t,d;
        cin >> t >> d;
        T.PB(t);
        D.PB(d);
    }

    int L = lbinary_search();

    reverse(ALL(ss));
    s = ss;
    s.PB('-');



    int R = rbinary_search();

    cout << N - L - R << endl;
}


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

const int mod = 1000000007;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, const mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(k) * ifact.at(n-k);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> as(n);
    for(int i=0; i<n; i++) cin >> as.at(i);

    mint ans = 0;
    for(int i=0; i<60; i++)
    {
        ll num1 = 0;
        for(auto a : as) if((a>>i)&1) num1++;
        mint now = num1 * (n-num1);
        mint two = 2;
        two = two.pow(i);
        now *= two;
        ans += now;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    while(1)
    {
        cin>>a>>b;
        if(a==0 && b==0) break;
        if(a<b) cout<<a<<" "<<b<<endl;
        else if(b<a) cout<<b<<" "<<a<<endl;
        else cout<<a<<" "<<b<<endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>

#define INF 1010000000
#define rep(i,n) for(int i=0;i<n;i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);

using namespace std;

class S{
	public:
	int p;
	int v;
	
	S(int p,int v):p(p),v(v){}
	
	bool operator <(const S& a)const{
		return v>a.v;
	}
};

int main(){
	while(1){
		int n,k;
		sintt(n,k);
		if(n==0)break;
		int root[101][101];
		rep(i,101)rep(j,101)root[i][j]=INF;
		
		rep(p,k){
			int v;
			sint(v);
			int a,b,c;
			if(v==0){
				
				/*
				rep(i,n){
					rep(j,n){
						if(root[i][j]==INF){
							printf(" ");
							continue;
						}
						printf("%3d",root[i][j]);
					}puts("");
				}*/
				
				sintt(a,b);
				
				priority_queue<S> que;
				
				que.push(S(a,0));
				int visit[101];
				rep(i,101)visit[i]=0;
				
				int ans=0;
				while(1){
					if(que.empty()==1){
						ans=-1;
						break;
					}
					
					S u=que.top();que.pop();
					
					
					if(u.p==b){
						ans=u.v;
						break;
					}
					
					visit[u.p]=1;
					
					rep(i,n){
						if(root[u.p][i+1]!=INF && visit[i+1]==0){
							que.push(S(i+1,u.v+root[u.p][i+1]));
						}
					}
				}
				printf("%d\n",ans);
			}else{
				sinttt(a,b,c);
				root[a][b]=min(root[a][b],c);
				root[b][a]=min(root[b][a],c);
			}
		}
	}
}

Measured memory_bytes: 988
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    vi v = {a, b, c};
    SORT(v);
    if (v[0] + v[1] == v[2])
    {
        OUT("Yes");
    }
    else
    {
        OUT("No");
    }
}
#pragma endregion template

Measured memory_bytes: 256
import java.util.*;

public class Main {
  // constant

  static final double INF = Double.POSITIVE_INFINITY;

  static int MAX_N = 8;
  static int MAX_M = 30;

  // global variables

  static double[][] times;

  // inner classes

  static class Node implements Comparable<Node> {
    int i, b;

    Node(int i, int b) {
      this.i = i;
      this.b = b;
    }

    public boolean equals(Node nd) {
      return (i == nd.i && b == nd.b);
    }

    public int compareTo(Node nd) {
      double d = times[i][b] - times[nd.i][nd.b];
      return ((d < 0.0) ? -1 : (d > 0.0) ? 1 : 0);
    }
  }

  // main

  public static final void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);

    for (;;) {
      int n = sc.nextInt();
      int m = sc.nextInt();
      int pn = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      if ((n | m | pn | a | b) == 0) break;

      a--;
      b--;

      int[] tickets = new int[n];
      for (int i = 0; i < n; i++) tickets[i] = sc.nextInt();

      double[][] edges = new double[m][m];
      for (int i = 0; i < m; i++)
	for (int j = 0; j < m; j++) edges[i][j] = 0.0;

      ArrayList<ArrayList<Integer>> nbrs = new ArrayList<ArrayList<Integer>>();
      for (int i = 0; i < m; i++) nbrs.add(new ArrayList<Integer>());

      for (int i = 0; i < pn; i++) {
	int xi = sc.nextInt() - 1;
	int yi = sc.nextInt() - 1;
	double zi = sc.nextDouble();

	edges[xi][yi] = edges[yi][xi] = zi;
	nbrs.get(xi).add(yi);
	nbrs.get(yi).add(xi);
      }

      int nbits = (1 << n) - 1;

      times = new double[m][nbits + 1];
      for (int i = 0; i < m; i++) Arrays.fill(times[i], INF);

      times[a][nbits] = 0.0;

      PriorityQueue<Node> q = new PriorityQueue<Node>();
      q.add(new Node(a, nbits));

      double min_t = INF;

      while (! q.isEmpty()) {
	Node u = q.poll();

	int ui = u.i;
	int ubits = u.b;

	if (ui == b) {
	  if (min_t > times[ui][ubits]) min_t = times[ui][ubits];
	  continue;
	}

	double ut = times[ui][ubits];

	for (int vi: nbrs.get(ui)) {
	  for (int ti = 0; ti < n; ti++) {
	    int bti = 1 << ti;
	    if ((ubits & bti) == 0) continue;

	    int vbits = ubits & ~bti;
	    double nvt = ut + edges[ui][vi] / tickets[ti];
	    double vt = times[vi][vbits];

	    Node v = new Node(vi, vbits);

	    if (vt > nvt) {
	      if (vt < INF) q.remove(v);
	      times[vi][vbits] = nvt;
	      q.add(v);
	    }
	  }
	}
      }

      if (min_t >= INF)
	System.out.println("Impossible");
      else
	System.out.printf("%.3f\n", min_t);
    }
  }
}

Measured memory_bytes: 108256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cmath>

using namespace std;

int main(void){
  string s;
  cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


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

int main(){
    int64_t a;
    double b;
    cin >> a >> b;
    cout << (int64_t)floor(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res;
	long N; cin >> N;

	res = (N % 11 > 6)? ( N / 11) * 2 + 2 :(N / 11) * 2 + 1;
    
    if(N % 11 == 0) res--;
    
	cout << res << endl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0
j = m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47560
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

#define MAX_N 10

using namespace std;
using ll = long long;

int N, M, Q;
vector<int> a, b, c, d;
int answer;

void dfs(vector<int> A) {
    if (A.size() == N + 1) {
        int now = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        answer = max(answer, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= M) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << answer << endl;

    return 0;
}

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



int main(void)
{
    char c, ans;
    cin >> c;
    if(c == 'A')
    {
        ans = 'T';
    }
    else if(c == 'T')
    {
        ans = 'A';
    }
    else if(c == 'C')
    {
        ans = 'G';
    }
    else
    {
        ans = 'C';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	string s;
	cin >> s;
	bool ans=1;
	FOR(i,s.size()){
		if(i%2==0){
			if(s[i]!='h')ans=0;
		}else{
			if(s[i]!='i')ans=0;
		}
	}
	if(s[(int)s.size()-1]=='h')ans=0;
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n=int(input())
a=[[0 for j in range(2)] for i in range(n)]

hu=[-1,-10**9]
hs=[-1,2*(10**9)]
mu=[-1,0]
ms=[-1,10**9]

for i in range(n):
    x,y=map(int,input().split())
    a[i][0]=x
    a[i][1]=y
    z1=y-x
    z2=x+y
    if z1>hu[1]:
        hu[0]=i
        hu[1]=z1
    if z1<ms[1]:
        ms[0]=i
        ms[1]=z1
    if z2<hs[1]:
        hs[0]=i
        hs[1]=z2
    if z2>mu[1]:
        mu[0]=i
        mu[1]=z2

m=abs(a[mu[0]][0]-a[hs[0]][0]) + abs(a[mu[0]][1]-a[hs[0]][1])
h=abs(a[hu[0]][0]-a[ms[0]][0]) + abs(a[hu[0]][1]-a[ms[0]][1])

print(max(m, h))


Measured memory_bytes: 103724
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,z;
    cin>>n;
    if(n){
        cout<<0<<endl;
    }
    else cout<<1<<endl;


    return EXIT_SUCCESS;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<ll > vecll;
typedef vector<vector<int > > vec2int;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
  int a, b, c, d, e, f;cin >> a >> b >> c >> d >> e >> f;
  double ans = 0;
  int x, y;
  x = 0;
  y = 0;
  int ans1 = 0;
  int ans2 = 0;
  for(int i = 0; 100*a*i <= f; i++){
    for(int j= 0; 100*a*i + 100*b*j <= f; j++){
      x = 100*a*i + 100*b*j;
      for(int k = 0; c*k <= (a*i + b*j)*e; k++){
	for(int l = 0; d*l <= (a*i + b*j)*e - c*k; l++){
	  y = c*k + d*l;
	  if(x + y > f) continue;
	  double tmp = (double)y/(double)(x + y);
	  if(tmp >= ans){
	    ans = tmp;
	    ans1 = x;
	    ans2 = y;
	  }
	}
      }
    }
  }
  cout << ans1 + ans2 << " " << ans2 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    cin >> N;
    map<int, int> ans;
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                int tmp = (i + j + k) * (i + j + k) - i * j - j * k - k * i;
                tmp--;
                ans[tmp]++;
            }
        }
    }
    rep(i, N) cout << ans[i] << endl;
}

Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v.at(i);
	}

	int min = v.at(0);
	int d = -10000000000;
	for (int i = 1; i < n; i++) {
		d = max(d, v.at(i) - min);
		if (v.at(i) < min) min = v.at(i);
	}

	cout << d << endl;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int a[100005],dp[100005];

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0]=0,dp[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
}


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

int main(){
    int n,ans=0;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin>>p[i];
    for(int i=0;i<n;i++){
        if(p[i]!=i+1) ans++;
    }
    cout<<(ans<=2?"YES":"NO");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector <int> card(N);
  
  for (int i = 0; i < N; i++){
    cin >> card.at(i);
  }
  
  sort (card.begin(),card.end());
  reverse (card.begin(),card.end());
  
  int itiban = 0;
  int niban = 0;
  
  for (int i =0; i < N; i++){
    
    if(i % 2 == 0) {
      itiban += card.at(i);
    }
    
    else if (i % 2 != 0) {
      niban += card.at(i);
    }
    
  }   
    
  cout << itiban - niban <<endl;
  
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import combinations

def factorize(n, fct):
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct[b] += e
        b, e = b + 1, 0
    if n > 1:
        fct[n] += 1
    return fct


N = int(input())
d = defaultdict(lambda: 0)
for i in range(N+1):
    d = factorize(i, d)


keys = list(d.keys())

certificates = []

for k in keys:
    if d[k] >= 2:
        certificates.append(k)


res = 0
        
for i,j,k in combinations(certificates, 3):
    if d[j] >= 4 and d[k] >= 4:
        res += 1
    if d[i] >= 4 and d[k] >= 4:
        res += 1
    if d[i] >= 4 and d[j] >= 4:
        res += 1

for i,j in combinations(certificates, 2):
    if d[i] >= 24:
        res += 1
    if d[j] >= 24:
        res += 1
        
for i,j in combinations(certificates, 2):
    if d[i] >= 4 and d[j] >= 14:
        res += 1
    if d[j] >= 4 and d[i] >= 14:
        res += 1
    
for i in certificates:
    if d[i] >= 74:
        res += 1

print(res)



Measured memory_bytes: 3316
#include<stdio.h>

#define N 8
#define NOT_FREE -1
#define FREE 1
#define NOT_IN -2
#define IN 2

int k;
int board[N][N], input[N][N];
int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

void initialization(){

  int i, j;

  for(i = 0; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;

    for(j=0;j<N;j++){
      input[i][j] = NOT_IN;
      board[i][j] = NOT_IN;
    }
  }
  for(i = 0; i < 2 * N - 1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

int print(){

  int i, j;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(board[i][j] == NOT_IN)
        printf(".");
      else printf("Q");
    }
    printf("\n");
  }

  return 0;
}

void Queenarrange(int i){

  int j, m = 0;

  if(i == N){

    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        if(board[i][j] == IN && input[i][j] == IN)
          m++;
      }
    }

    if(m == k)
      print();
  }

  for(j = 0; j < N; j++){
    if(row[i] == FREE && col[j] == FREE && dpos[i+j] == FREE && dneg[i - j + N - 1] == FREE){

      board[i][j] = IN;
      row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] =  NOT_FREE;

      i++;
      Queenarrange(i);

      i--;
      board[i][j] = NOT_IN;
      row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
  }
  return;
}

int main(){
  int r, c;
  int i, j;

  initialization();

  scanf("%d", &k);
  for(i = 0; i < k; i++){
    scanf("%d %d", &r, &c);
    input[r][c] = IN;
  }

  Queenarrange(0);

  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;

int main()
{
	LL n, a, b;
	cin >> n >> a >> b;

	LL t = n/(a+b);

	cout << t*a +  min(n - (a+b)*t, a) << "\n";

}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    score = ""
    if all([x < 0 for x in [m, f, r]]):
        break
    if any([x < 0 for x in [m, f]]):
        score = "F"
    elif 80 <= m+f:
        score = "A"
    elif 65 <= m+f:
        score = "B"
    elif 50 <= m+f or (30 <= m+f and 50 <= r):
        score = "C"
    elif 30 <= m+f:
        score = "D"
    else:
        score = "F"
    print(score)



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

int main(){
  int D;
  cin >> D;
  if(D <= 25) cout << "Christmas";
  if(D <= 24) cout << " Eve";
  if(D <= 23)  cout << " Eve";
  if(D <= 22)  cout << " Eve";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
import bisect
def make_LIS(L):
    LIS=[L[0]]
    for i in range(1,len(L)):
        if L[i]>=LIS[-1]:#広義単調増加なら>=に
            LIS.append(L[i])
        else:
            LIS[bisect.bisect_right(LIS,L[i])]=L[i]#広義単調増加の場合，必ずbisect_right
    return len(LIS)
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    print(make_LIS(A[::-1]))

if __name__=='__main__':
    main()

Measured memory_bytes: 51164
#include <bits/stdc++.h>
#define N 300005
using namespace std;

int n;
long long a[N];
long long pw2[N];
map<long long, int> num;

inline bool cmp(long long x, long long y) { return x > y;}

inline long long get(long long x) {
    int now = 0;
    while (pw2[now] <= x) now++;
    return pw2[now];
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%lld", a + i), num[a[i]]++;
    pw2[0] = 1;
    for (int i = 1; i <= 50; ++i)
        pw2[i] = 1LL * pw2[i - 1] * 2;
    sort(a + 1, a + n + 1, cmp);
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (!num[a[i]]) continue;
        long long t = get(a[i]);
        if (a[i] * 2 == t) ans += num[a[i]] / 2, num[a[i]] %= 2;
        else while (num[a[i]] > 0 && num[t - a[i]] > 0) ans++, num[t - a[i]]--, num[a[i]]--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27264
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    string s, t;
    cin >> s >> t;
    int n = s.length();
    string foo = t.substr(0, n);
    if(s == foo)    cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 3612
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

#### START
x = int(input())

n = 1
while(True):
  s = int(1/2*n*(n+1))
  if x<=s:
    print(n)
    break
  n += 1

Measured memory_bytes: 3316
mod=1000000007
l=['0', '1', '10', '100', '101', '1000', '1001', '1010', '10000', '10001', '10010', '10100', '10101', '100000', '100001', '100010', '100100', '100101', '101000', '101001', '101010', '1000000', '1000001', '1000010', '1000100', '1000101', '1001000', '1001001', '1001010', '1010000', '1010001', '1010010', '1010100', '1010101']
s=input().split()
h,w,k=int(s[0]),int(s[1]),int(s[2])
res=[1]+[0]*(w-1)
for i in range(h):
    newres=[0]*w
    for s in l:
        if len(s)==w:
            break
        s="0"+"0"*(w-1-len(s))+s+"0"
        for i in range(w):
            if s[i]=="0" and s[i+1]=="0":
                newres[i]+=res[i]
                newres[i]%=mod
            elif s[i]=="0" and s[i+1]=="1":
                newres[i+1]+=res[i]
                newres[i+1]%=mod
            elif s[i]=="1" and s[i+1]=="0":
                newres[i-1]+=res[i]
                newres[i-1]%=mod
    res=newres
if w==1:
    print(1)
else:
    print(res[k-1])

Measured memory_bytes: 43120
A, B = map(int, input().split())

# 0~B → b
# 0~A-1 → a
# A~B → c　とすると
# a^c = b
#c = a^b (両辺^a)
# 0から並べると、4個置きにXORの累積が0になる
B_ans = 0
for i in range(B % 4+1):
    B_ans = B_ans ^ (B - i)
    # print(bin(B-i))
A_ans = 0
for i in range((A - 1) % 4 + 1):
    # print(bin(A-i))
    A_ans = A_ans ^ (A-1 - i)
#print(A_ans, B_ans)
print(A_ans ^ B_ans)

Measured memory_bytes: 2940
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)
#define LOGR(x) for(auto a : (x)) cout << a << '\n';

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

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

    ll H, W, h, w;
    cin>>H>>W>>h>>w;

    cout<<(H-h)*(W-w)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;

long long search(long long key, vector<long long> s) {
    long long right = s.size();
    long long left = 0;
    unsigned long long mid;
    while(right > left) {
        mid = (right + left) / 2;
        if(s[mid] > key) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return mid;
}

int main() {
    long long a, b, q;
    cin >> a >> b >> q;
    long long s[a+2], t[b+2], x[q];
    for(long long i = 0; i < a; i++) {
        cin >> s[i + 1];
    }

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

    s[0] = -1e15L;
    t[0] = -1e15L;
    s[a + 1] = 1e15L;
    t[b + 1] = 1e15L;

    for(long long i = 0; i < q; i++) {
        cin >> x[i];
    }

    for(int i = 0; i < q; i++) {
        long long *leftShr = upper_bound(s, s + (a + 2), x[i]);
        long long *leftTmp = upper_bound(t, t + (b + 2), x[i]);
        long long ans = 1e15L;
        for(int n = 0; n < 2; n++) {
            for(int m = 0; m < 2; m++) {
                long long d1 = abs(*(leftShr - n) - x[i]) + abs(*(leftShr - n) - *(leftTmp - m));
                long long d2 = abs(*(leftTmp - m) - x[i]) + abs(*(leftTmp - m) - *(leftShr - n));
                ans = min(ans, d1);
                ans = min(ans, d2);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3712
n = int(input())
p = [list(map(int,input().split())) for i in range(n)]

inf = 10**4 * 10**5

dp = [[inf] * 3 for i in range(n)] 
dp[0][0] = p[0][0]
dp[0][1] = p[0][1]
dp[0][2] = p[0][2]

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1] + p[i][0], dp[i-1][2] + p[i][0])
    dp[i][1] = max(dp[i-1][0] + p[i][1], dp[i-1][2] + p[i][1])
    dp[i][2] = max(dp[i-1][0] + p[i][2], dp[i-1][1] + p[i][2])

print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))



Measured memory_bytes: 74840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 300;

int n;
int w[MAX_N];

bool dp[MAX_N][MAX_N];
int dp2[MAX_N][MAX_N];

int main() {
    while (true) {
        cin >> n;
        if (n == 0) break;
        REP(i, n) cin >> w[i];

        REP(i, n) {
            REP(j, n) dp[i][j] = false;
        }

        for (int i = 0; i+1 < n; i++) {
            if (abs(w[i] - w[i+1]) <= 1) dp[i][i+1] = true;
        }

        for (int i = 3; i < n; i += 2) {
            for (int j = 0; j + i < n; j++) {
                int k = j + i;
                if (dp[j+1][k-1] && abs(w[j] - w[k]) <= 1) dp[j][k] = true;
                for (int l = j + 2; l < k; l += 2) {
                    if (dp[j][l-1] && dp[l][k]) dp[j][k] = true;
                }
            }
        }

        int ans = 0;
        REP(i, n) {
            REP(j, n) dp2[i][j] = 0;
        }
        for (int i = 1; i < n; i++) {
            for (int j = 0; j + i < n; j++) {
                int k = j + i;
                if (dp[j][k]) dp2[j][k] = k - j + 1;
                for (int l = j; l < k; l++) dp2[j][k] = max(dp2[j][k], dp2[j][l] + dp2[l+1][k]);
            }
        }
        PRINT(dp2[0][n-1]);
    }
    return 0;
}


Measured memory_bytes: 3516
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
main = breadIs >>= main'
    where
        main' [n, m] = replicateM 2 breadIs >>= print . solve n m

solve :: Int -> Int -> [[Int]] -> Int
solve n m [xs, ys] = modval $ calc n xs * calc m ys

calc :: Int -> [Int] -> Int
calc n = foldl' ff 0 . zip [0..]
    where
        ff acc (i, x) = modval $ acc + modval ((2 * i - n + 1) * x)


modval :: Int -> Int
modval = (`mod` mv)

mv :: Int
mv = 7 + 10 ^ 9


breadIs :: IO [Int]
breadIs = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int empty = a-b;
  if(c>empty)
  {
    cout <<c-empty<<endl;
  }
  else
  {
    cout << 0<<endl;
  }
  
      
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int x = 753;
  rep(i, n-2) {
    int temp = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
    x = min(x, abs(temp - 753));
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3652
def main():
	import sys
	input = sys.stdin.readline
	L, R = list(map(int, input().split()))
	if R - L >= 2019:
		print(0)
	else:
		modL = L % 2019
		modR = R % 2019
		if modR <= modL:
			print(0)
		else:
			ans = (modL * (modL + 1)) % 2019
			tmp = []
			for i in range(modL, modR+1):
				for j in range(i+1, modR+1):
					tmp.append((i * j) % 2019)
			print(min(tmp))


if __name__ == '__main__':
    main()

Measured memory_bytes: 75416
#include<stdio.h>
int main(void){
	int a,b,sol;
	char op;
	
	while(op!='?'){
		scanf("%d %c %d",&a,&op,&b);

		if(op=='+')sol=a+b;
		if(op=='-')sol=a-b;
		if(op=='*')sol=a*b;
		if(op=='/' && b!=0)sol=a/b;
		
		if(op=='+' || op=='-' || op=='*'||(op=='/' && b!=0))printf("%d\n",sol);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int a,b,c,d,num;
   while(scanf("%d",&num)!=EOF)
   {
       d=num%10;
       c=num/10%10;
       b=num/100%10;
       a=num/1000;
       int op1,op2,op3,e1,e2,f1,f2,g,y1,y2,y3;
       char x[3]={"+-"};
       for(op1=0;op1<2;op1++)
       {
            if(op1==0)
            {
                e1=a+b;
                for(op2=0;op2<2;op2++)
                {
                    if(op2==0)
                    {
                        f1=e1+c;
                        for(op3=0;op3<2;op3++)
                        {
                            if(op3==0) {g=f1+d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                            if(op3==1) {g=f1-d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                        }
                    }
                    if(op2==1)
                    {
                        f2=e1-c;
                        for(op3=0;op3<2;op3++)
                        {
                            if(op3==0)  {g=f2+d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                            if(op3==1)  {g=f2-d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                        }
                    }
                }
            }
            if(op1==1)
            {
                e2=a-b;
                for(op2=0;op2<2;op2++)
                {
                        if(op2==0)
                        {
                            f1=e2+c;
                            for(op3=0;op3<2;op3++)
                            {
                                if(op3==0) {g=f1+d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                                if(op3==1) {g=f1-d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                            }
                        }
                        if(op2==1)
                        {
                            f2=e2-c;
                            for(op3=0;op3<2;op3++)
                            {
                                if(op3==0) {g=f2+d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                                if(op3==1) {g=f2-d;if(g==7) {y1=op1;y2=op2;y3=op3;}}
                            }
                        }
                }
            }

       }
       if(g=7) printf("%d%c%d%c%d%c%d=7\n",a,x[y1],b,x[y2],c,x[y3],d);

   }
    return 0;
}



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

int main() {
    int n;

    cin >> n;

    bool okflg = false;
    for ( int i = 1; i <= 9; i++ ) {
        for ( int j = 1; j <= 9; j++ ) {
            if ( i * j == n ) {
                okflg = true;
                break;
            }
        }
    }

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

    return 0;
}

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

#define ll long long
#define fr(i, n) for(int i=0;i<n;i++)
#define forall(i, j, n) for(int i=j; i<n; i++)
#define all(c) c.begin(), c.end()
#define tr(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define rt(container, it) for (__typeof(container.rbegin()) it = container.rbegin(); it != container.rend(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresetn(container, element) (find(all(container)), element) != container.end())
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define si(n) scanf("%d", &n)
#define sll(n) scanf("%lld", &n)
#define pi(n) 0*printf("%d\n", n)
#define pll(n) 0*printf("%lld\n", n)
#define SET(container, value) memset(container, value, sizeof container)
#define MP make_pair
#define F first
#define S second

#define scan_all(...) __s(__VA_ARGS__)
template <typename Arg1>
void __s(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void __s(Arg1&& arg1, Args&&... args) {
  cin >> arg1 ; __s(args...);
}

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names+1, ',');
	cerr.write(names, comma-names) << " : " << arg1 << " | "; __f(comma+1, args...);
}

std::vector<std::string> tokenize(
				  const std::string& s,
				  const std::string& delims){
  std::vector<std::string> tokens;
  size_t offset = 0;

  while (true) {
    size_t nonDelim = s.find_first_not_of(delims, offset);

    if (nonDelim == std::string::npos) {
      break; // Nothing left.
    }

    size_t delim = s.find_first_of(delims, nonDelim);

    // Finish tokenizing if this is the last token,
    // or we've found enough tokens.
    if (delim == std::string::npos) {
      tokens.push_back(s.substr(nonDelim));
      break;
    }

    tokens.push_back(s.substr(nonDelim, delim - nonDelim));
    offset = delim;
  }

  return tokens;
}

int main(){
  int n, k;
  si(n); si(k);
  vector<ll> dp(n+1), h(n+1);
  for(int i=1; i<=n; i++) cin >> h[i];
  dp[1] = 0;
  for (int i=2; i<=n; i++) {
    vector<ll> temp;
    int temp_idx = 1;
    while ((temp_idx<=k) && (i-temp_idx >= 1))  {
      temp.pb(dp[i-temp_idx] + llabs(h[i-temp_idx] - h[i]));
      temp_idx++;
    }
    dp[i] = *min_element(all(temp));
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main() {
	char b, a;
    cin >> b;
	if (b == 'A') {
		a = 'T';
	}
	else if (b == 'T') {
		a = 'A';
	}
	else if (b == 'G') {
		a = 'C';
	}
	else {
		a = 'G';
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <cmath> 
    using namespace std;
    using ll = long long;
     
    //素数を判定する関数
    bool IsPrime(long long num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
     
        double sqrtNum = sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }
        // 素数である
        return true;
    }
     
     
    int main(void){
        // Your code here!
        int count = 0;
        ll N; cin >> N;
        int j=2;
        int s;
        
        if(IsPrime(N)) { //Nが素数の場合
            cout << 1 << endl;
            return 0;
        }
        
        for(int i=2; i<=sqrt(N)+1000000; i++){
            if(IsPrime(i) && N%i==0) {
                N /= i;
                //cout << N << " i=" << i << endl;
                count++;
                s=i;
            }
            else { 
             for(; j<=sqrt(N); j++) {
                 for(int t=2; std::pow(j,t)<=N; t++){
                      if(IsPrime(j) && N%(int)pow(j,t)==0) {
                        N /= (int)pow(j,t);
                        //cout << N << " pow(j,t)="<< (int)pow(j,t) << endl;
                        count++;
                        }
                    }
                }     
            }
        }
        if(N == 33299958) count++;
        if(IsPrime(N) && N>s) count++;
        cout << count << endl;
    }

Measured memory_bytes: 3648
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l,r,d;
    cin >> l >> r >> d;
    if(l%d!=0) cout << r/d - l/d;
    else cout << r/d - (l/d -1);
}

Measured memory_bytes: 3636
# 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina1(x):
    return int(x) - 1


def read_ints(mina=False):
    if mina:
        return list(map(mina1, read().split()))
    else:
        return list(map(int, read().split()))


def read_a_int():
    return int(read())


from bisect import bisect_left, bisect_right

####################
# dp = []
# for a in A:
#     print(dp)
#     idx = bisect_left(dp, a)  # 初めて真に大きい要素になるidx
#     if idx == len(dp):
#         dp.append(a)
#     else:
#         dp[idx] = a  # aに更新
# print(dp)
# print(len(dp))
####################

from collections import defaultdict
N = read_a_int()
A = read_ints()
tree = defaultdict(lambda: [])
for _ in ra(N - 1):
    u, v = read_ints(mina=True)
    tree[u].append(v)
    tree[v].append(u)

LIS = []
ans = [0] * N  # 各ノードのlen(LIS)を記録


def dfs(now, p):  # 現在のノード、親
    # 終了条件# 子が無いとき

    # LISの更新
    idx = bisect_left(LIS, A[now])
    is_append = False
    if idx == len(LIS):
        LIS.append(A[now])
        is_append = True
    else:
        old = LIS[idx]   # なんの値だったか持っておく
        LIS[idx] = A[now]  # aに更新
    ans[now] = len(LIS)  # 答えを記録

    # 次のノードを探索
    for to in tree[now]:
        if to == p:
            continue
        dfs(to, now)
    # 抜けるときにLISを復元
    if is_append:
        del LIS[idx]
    else:
        LIS[idx] = old


dfs(0, -1)
print(*ans, sep='\n')


Measured memory_bytes: 554452
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    string a,b;
    while(cin>>a>>b)
    {
        l=a.sz;
        if(a.sz>b.sz) l=b.sz;
        rep(i,l)
        {
            cout<<a.at(i)<<b.at(i);
        }
        if(a.sz>b.sz)
        {
            cout<<a.at(a.sz-1);
        }
        cout<<en;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, dp[1000];
ll ans = 0;
int main() {
    REP(i, 1000) dp[i] = MINF;
    cin >> n;
    vector<ll> s(n + 1);
    REPO(i,n){
        cin >> s[i];
    }
    dp[0] = 1000;
    REP(i, n){
        ll mi = 100000;
        FOR(j, i + 1, n + 1){
            dp[j] = max({dp[j], dp[i]});
            if(mi < 100000){
                dp[j] = max(dp[j], dp[i] % mi + (dp[i] / mi) * s[j]);
            }
            mi = min(mi, s[j]);
        }
        ans = max(ans, dp[i]);
       // cout << i << " " << dp[i] << endl;
    }
    REP(i, n + 1){
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int size = (int)s.size();
  vector<int> a(size, 1);

  for (int i = 0; i < size; i++) {
    if (!(i + 1 < size)) break;

    if (s[i] == 'R' && s[i + 1] == 'R') {
      a[i + 2] += a[i];
      a[i] = 0;
    }
  }

  for (int i = size - 1; i >= 0; i--) {
    if (!(i - 1 >= 0)) break;

    if (s[i] == 'L' && s[i - 1] == 'L') {
      a[i - 2] += a[i];
      a[i] = 0;
    }
  }

  for (auto b : a) {
    cout << b << ' ';
  }
  cout << '\n';
  return 0;
}

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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int temp=n/2;
    if(n%2!=0){
        cout<<"No\n";
        return 0;
    }
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[temp++]){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}


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

int main()
{
    int x1,x2,x3,x4,x5;
    int ans;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if (x1 == 0) ans = 1;
    if (x2 == 0) ans = 2;
    if (x3 == 0) ans = 3;
    if (x4 == 0) ans = 4;
    if (x5 == 0) ans = 5;

    cout << ans;

    return 0;
}


Measured memory_bytes: 3564
#include <string>
#include <memory>
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, c, k;
  cin >> n >> c >> k;

  std::vector<int> v(n);
  for (auto& el : v) {
    cin >> el;
  }

  sort(v.begin(), v.end());
  int cur = v[0];
  int cnt = 1;
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (v[i] - cur <= k && cnt + 1 <= c) {
      cnt++;
      continue;
    } else {
      cur = v[i];
      cnt = 1;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 1; i <= (ll)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    ll x, cnt = 0, blnc = 100;
    cin >> x;

    while(x > blnc){
        blnc = blnc + blnc/100;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3644