akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<string> vec(2);
    cin >> vec.at(0) >> vec.at(1);
    vector<string> original = vec;
    sort(vec.begin(), vec.end());
    if (vec == original){
        if (vec.at(0) == vec.at(1)){
            cout << "=" << endl;
        }
        else{
            cout << "<" << endl;
        }
    }
    else{
        cout << ">" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int judge(int num)
{
	int i;
	
	if (num < 2){
		return (0);
	}
	if (num == 2){
		return (1);
	}
	if (num % 2 == 0){
		return (0);
	}
	for (i = 3; i * i <= num; i += 2){
		if (num % i == 0){
			return (0);
		}
	}
	return (1);
}

int main(void)
{
	int n, num;
	int ct = 0, i;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d", &num);
		if (judge(num)){
			ct++;
		}
	}
	
	printf("%d\n", ct);
	return (0);
}


Measured memory_bytes: 2112
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll K;
ll A[100000];

int main(){
    cin>>K;
    rep(i,K) cin>>A[i];

    ll inf=2, sup=2;
    for(int i=K-1;i>=0;i--){
        if(sup/A[i]-(inf-1)/A[i]<=0){
            cout<<-1<<endl;
            return 0;
        }
        //cout<<i<<endl;
        inf=((inf-1)/A[i]+1)*A[i];
        sup=sup/A[i]*A[i]+A[i]-1;

    }

    cout<<inf<<' '<<sup<<endl;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m, r, a[10], cost[205][205], d[205], b[205][205];
const int INF = 1000000007;
bool used[205];

void dijkstra(int s) {
	fill(d, d+n, INF);
	fill(used, used+n, false);
	d[s] = 0;
	
	while (true) {
		int v = -1;
		FOR(u, n) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;
		FOR(u, n) {
			if (d[u] > d[v] + cost[v][u]) {
				d[u] = d[v] + cost[v][u];
			}
		}
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> r;
	FOR(i, r) {
		cin >> a[i];
		a[i]--;
	}
	MEM(cost, INF);
	FOR(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		cost[x-1][y-1] = c;
		cost[y-1][x-1] = c;
	}
	MEM(b, INF);
	FOR(i, r) {
		dijkstra(a[i]);
		FOR(j, n) b[a[i]][j] = d[j];
	}
	vector<int> v(r);
	FOR(i, r) v[i] = i;
	int mi = INF;
	do {
		int ret = 0;
		FOR(i, r-1) ret += b[a[v[i]]][a[v[i+1]]];
		mi = min(mi, ret);
	} while (next_permutation(ALL(v)));
	cout << mi << endl;
	// cout << b[0][2]  << " " << v[1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int A, P;
	cin >> A >> P;
	int X = 3 * A + P;
	int ans = X / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BMultiplication2 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<ll> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      ll ret = 1;
      rep(i, n) {
        if (a[i] == 0) {
          cout << 0 << endl;
          return;
        }
      }

      rep(i, n) {
        if (ret > (1e+18)/a[i]) {
          cout << -1 << endl;
          return;
        }
        ret *= a[i];
      }
      if (ret > ll(1e+18)) {
        cout << -1 << endl;
        return;
      }

      cout << ret << endl;
    }
};

signed main() {
  BMultiplication2 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int A, B, K;


int main(void) {
    cin >> A >> B >> K;
    int max_ = max({A, B});
    int min_ = min({A, B});
    int ans[100];
    int cnt = 0;
    for ( int i = 0; i < min_; i++ ) {
        if ( (max_ % (min_-i) == 0) && (min_ % (min_-i) == 0) ) {
            ans[cnt] = min_-i;
            cnt += 1;
        }
    }
    cout << ans[K-1] << endl;
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  int count = 0;
  for(int i = 0; i < n; i += 2) {
    if(a.at(i) % 2 == 1) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3508
def main():
    #1. input
    a, b = map(int, input().split())
    
    ans = 0
    
    #2. from A to B
    for i in range(a, b+1):
        #2.1. judge if the number is palindromic
        if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]):
            ans = ans+1
        
    #3. output
    print(ans)


if __name__ == '__main__':
    main()

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMAX(a,b) (a)=max((a),(b))
#define CHMIN(a,b) (a)=min((a),(b))

#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

int main(){
	int x;
	cin>>x;
	if(x==1){
		puts("Hello World");
	}else{
		int a,b;
		cin>>a>>b;
		cout<<(a+b)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n,k,s = map(int, input().split())
if s == 10**9:
    ansl = []
    for i in range(n):
        if i < k:
            ansl.append(s)
        else:
            ansl.append(1)
    print(*ansl)

else:
    ansl = []
    for i in range(n):
        if i < k:
            ansl.append(s)
        else:
            ansl.append(10**9)
    print(*ansl)

Measured memory_bytes: 83900
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d",&a, &b, &c);
	if(a==b+c || b==a+c || c==a+b){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int n, i; 
  string a, b;
  
  cin >> n >> a >> b;
  
  for (i=0; i<n; i++) 
  {
    cout << a[i] << b[i];
  }
  return 0;
}

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

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

  if(s.size()<=k){
    cout << s;
    return 0;
  }

  if(s.size()>k){
    for(int i=0; i<k; ++i){
      cout << s[i];
    }
  }
  cout << "..." << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll h, w;
    cin >> h >> w;
    string s[h];
    for(ll i = 0; i < h; i++)
        cin >> s[i];
    ll count = 0;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(s[i][j]=='.') count++;
        }
    }
    vector<vector<ll>> dist(h, vector<ll>(w,-1));
    queue<p> que;
    que.push(p(0,0));
    dist[0][0] = 1;
    while(!que.empty()){
        p check = que.front();
        ll x = check.first, y = check.second;
        que.pop();
        for(ll i = 0; i < 4; i++){
            ll a = x+dx[i]; ll b = y+dy[i];
            if(a<0 || b<0 || a>=h || b>=w) continue;
            if(s[a][b]=='#' || dist[a][b]!=-1) continue;
            que.push(p(a,b));
            dist[a][b] = dist[x][y]+1;
        }
    }
    if(dist[h-1][w-1]!=-1)
        cout << count-dist[h-1][w-1] << endl;
    else
        cout << -1 << 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;
typedef long long ll;
typedef long long int lli;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int x,y;
	cin >> x >> y;
	
	string ans = "No";
	rep(i, x+1) {		//i:鶴2，x-i:亀4
		if (y == 2 * i + 4 * (x - i)) {
			ans = "Yes";
			break;
		}
	}

	cout << ans << endl;



}

Measured memory_bytes: 3620
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

ans = 0
1.upto(n) do |i|
  if i % 3 != 0 && i % 5 != 0
    ans += i
  end
end
puts ans


Measured memory_bytes: 14616
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 1

def fib(n):
    if dp[n] > 0:
        return dp[n]
    
    dp[n] = fib(n - 1) + fib(n - 2)
    return dp[n]

print(fib(N))
    


Measured memory_bytes: 6092
#include<bits/stdc++.h>
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int a[100];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	rep(i, n) {
		if (i)printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		rep(i, n) {
			if (i)printf(" ");
			printf("%d", a[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3148
#!/usr/bin/env python3
import math

def main():
    A, B = map(int, open(0).read().split())
    L = min(A//(0.08), B//(0.10))
    U = max((A + 1)//(0.08), (B + 1)//(0.10))

    flag = False
    for i in range(int(L), int(U) + 1):
        if (math.floor(i * 0.08) == A) and (math.floor(i * 0.10) == B):
            print(i)
            flag = True
            break
    
    if not flag:
        print(-1)


main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long cntA = 0;
		long cntB = 0;

		if (a > 0) {
			cntA = cntYksu(a-1,x);
		}
		cntB = cntYksu(b,x);
		System.out.println(cntB - cntA);
	}

	public static long cntYksu(long num, long x) {
		return (num / x) + 1;
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
char S[100002];
int main(){
  int i, k;
  N = rd(S);
  k = 0;
  for(i=0;i<N;i+=2){
    S[k++] = S[i];
  }
  S[k] = '\0';
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N;
// char S[100002];
// {
//   int i, k;
//   rd(S@N);
// 
//   k = 0;
//   for(i=0;i<N;i+=2) S[k++] = S[i];
//   S[k] = '\0';
//   wt(S);
// }


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int b,a,r,x,i;
    
scanf("%d",&x);
scanf("%d",&a);
scanf("%d",&b);
x=x-a;
for(i=0;;i++){
x=x-b;
if(x<b){
break;
}
}
printf("%d\n",x);


return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main(){
    ll h, w;
    cin >> h >> w;

    ll ans = INF;
    ll p1, p2, p3;
    for (ll i = 1; i < h; i++){
        p1 = i * w;
        if(h-i>=2){
            if((h-i)%2==0){
                p2 = (h - i) / 2 * w;
                ans = min(ans, abs(p1 - p2));
            }
            else{
                p2 = (h - i + 1) / 2 * w;
                p3 = (h - i - 1) / 2 * w;
                ll pmax = max({p1, p2, p3});
                ll pmin = min({p1, p2, p3});
                ans = min(ans, abs(pmax - pmin));
            }
        }

        if(w%2==0){
            p2 = (h - i) * w / 2;
            ans = min(ans, abs(p1 - p2));
        }
        else{
            p2 = (h - i) * (w + 1) / 2;
            p3 = (h - i) * (w - 1) / 2;
            ll pmax = max({p1, p2, p3});
            ll pmin = min({p1, p2, p3});
            ans = min(ans, abs(pmax - pmin));
        }
    }

    for (ll i = 1; i < w; i++){
        p1 = i * h;
        if(w-i>=2){
            if((w-i)%2==0){
                p2 = (w - i) / 2 * h;
                ans = min(ans, abs(p1 - p2));
            }
            else{
                p2 = (w - i + 1) / 2 * h;
                p3 = (w - i - 1) / 2 * h;
                ll pmax = max({p1, p2, p3});
                ll pmin = min({p1, p2, p3});
                ans = min(ans, abs(pmax - pmin));
            }
        }

        if(h%2==0){
            p2 = (w - i) * h / 2;
            ans = min(ans, abs(p1 - p2));
        }
        else{
            p2 = (w - i) * (h + 1) / 2;
            p3 = (w - i) * (h - 1) / 2;
            ll pmax = max({p1, p2, p3});
            ll pmin = min({p1, p2, p3});
            ans = min(ans, abs(pmax - pmin));
        }
    }

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

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif


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

	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[3])
		cout << "Good";
	else
		cout << "Bad";

	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

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

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    double R,G;
    cin>>R>>G;
    double ans;
    ans = 2*G - R;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int a, b;
string s;
int main()
{
	cin >> a >> b;
	cin >> s;

	bool flag = true;
	REP(i, 0, s.size()) {
		if (i == a) {
			if (s[i] != '-') {
				flag = false;
				break;
			}
		}
		else {
			if (s[i] == '-') {
				flag = false;
				break;
			}
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

vector<bool> starts_with(string s, string t, long long x) {
    int n = (int)s.size(), m = (int)t.size();
    long long prime = 1000000007;
    auto mod = [&](long long a) {
        return (a % prime + prime) % prime;
    };
    x = mod(x);
    if (x == 0) {
        x = 1;
    }
    function<long long (long long, long long)> pow = [&](long long a, long long r) {
        if (r == 0) return 1LL;
        long long y = pow(a, r/2);
        long long z = mod(y * y);
        return r % 2 == 1 ? mod(a * z) : z;
    };
    long long inv_x = pow(x, prime-2);
    long long t_sig = 0LL;
    long long x_pow = 1; // x_pow = x^i during the loop
    for (int i = 0; i < m; ++i) {
        t_sig = mod(t_sig + x_pow * t[i]);
        x_pow = mod(x_pow * x);
    }
    x_pow = 1;
    long long s_sig = 0LL;
    for (int i = 0; i < m; ++i) {
        s_sig = mod(s_sig + x_pow * s[i%n]);
        x_pow = mod(x_pow * x);
    }
    vector<bool> equal(n, false);
    for (int i = 0; i < n; ++i) {
        equal[i] = t_sig == s_sig;
        s_sig = mod(s_sig + x_pow * s[(i+m)%n] - s[i]);
        s_sig = mod(s_sig * inv_x);
    }
    return equal;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
    string s, t;
    cin >> s >> t;
    int n(s.size()), m(t.size());
    vector<bool> equal(n, true);
    for (int k = 0; k < 1; ++k) { // doing only 1 check
        vector<bool> equal_check = starts_with(s, t, rng());
        for (int i = 0; i < n; ++i) {
            equal[i] = equal[i] && equal_check[i];
        }
    }
    bool cycle_found = false;
    vector<int> color(n, -1);
    vector<int> max_length(n, -1);
    function<void (int, int)> dfs = [&](int i, int c) {
        color[i] = c;
        if (!equal[i]) {
            max_length[i] = 0;
            return;
        }
        int j = (i + m) % n;
        if (color[j] == c) {
            cycle_found = true;
        }
        if (color[j] == -1) {
            dfs(j, c);
        }
        max_length[i] = 1 + max_length[j];
    };
    for (int i = 0; i < n; ++i) {
        if (max_length[i] == -1) {
            dfs(i, i);
        }
    }
    if (cycle_found) {
        cout << -1 << endl;
    } else {
        cout << *max_element(max_length.begin(), max_length.end()) << endl;
    }
    return 0;
}


Measured memory_bytes: 29232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    string s;
    cin>>s;
    int mx=0;
    int cnt=0;
    for(auto i:s)
    {
        if(i=='R')cnt++;
        else
        {
            mx=max(mx,cnt);
            cnt=0;
        }
    }
    mx=max(mx,cnt);
    cout<<mx<<endl;
}



Measured memory_bytes: 3652
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var n = Read();
        var W = Read();
        var dp = Enumerable.Repeat(long.MaxValue / 2, 100001).ToArray();
        dp[0] = 0;
        for (int i = 0; i < n; i++)
        {
            var w = Read();
            var v = Read();
            for (int j = dp.Length - v - 1; j >= 0; j--) dp[j + v] = Min(dp[j + v], dp[j] + w);
        }
        for (int i = dp.Length - 1; i >= 0; i--)
            if (dp[i] <= W)
            {
                Console.WriteLine(i);
                return;
            }
    }

    static readonly TextReader In = Console.In;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static int Read()
    {
        int res = 0;
        int next = In.Read();
        while (48 > next || next > 57) next = In.Read();
        while (48 <= next && next <= 57)
        {
            res = res * 10 + next - 48;
            next = In.Read();
        }
        return res;
    }
}


Measured memory_bytes: 13664
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<utility>
#include<string>
#include<string.h>
#include<queue>
#include<stack>
#include<math.h>
#include<array>
#include<algorithm>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int n,m;
    ll a;
    scanf("%d%d",&n,&m);
    priority_queue<double> que;
    REP(i,n){
        scanf("%lld",&a);
        que.push((double)a);
    }
    REP(i,m){
        double a = que.top();
        que.pop();
        a /=2;
        que.push(a);
    }
    ll ans=0;
    while(!que.empty()){
        double a=que.top();
        que.pop();
        ans += (int)a;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    stack <int> s;
    int i;
    if(n==0)
    cout<<0<<endl;
    else
    {
        while(n!=0)
        {
           i=abs(n%(-2));
           s.push(i);
           n=(n-i)/(-2);
        }
    }
    while(!s.empty())
    {
        cout<<s.top();
        s.pop();
    }
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,h,w,ans=0,cnt=0,tmp;
int main(){
  cin >> h >> w;
  string s[h];
  bool yoko[h],tate[w];
  for(int i=0;i<w;i++){
    tate[i]=true;
  }
  for(int i=0;i<h;i++){
    yoko[i]=true;
  }
  for(int i=0;i<h;i++){
    cin >> s[i];
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        yoko[i]=false;
        break;
      }
    }
  }

  for(int i=0;i<w;i++){
    for(int j=0;j<h;j++){
      if(s[j][i]=='#'){
        tate[i]=false;
        break;
      }
    }
  }

  for(int i=0;i<h;i++){
    if(yoko[i]==true){
      continue;
    }
    cnt=0;
    for(int j=0;j<w;j++){
      if(tate[j]==false){
        cout << s[i][j];
        cnt++;
      }
    }
    if(cnt){
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        g = new ArrayList[n];

        for (int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }

        for (int i=0; i<m; i++){
            int u = sc.nextInt()-1;
            int v = sc.nextInt()-1;
            g[u].add(v);
        }

        prev = new int[n][n];
        dist = new int[n][n];
        int ucycle = -1; int dmin = n+1;

        for (int i=0; i<n; i++){
            Arrays.fill(prev[i], -1);
            Arrays.fill(dist[i], -1);
            int d = bfs(i);
            if (0 < d && d < dmin){
                ucycle = i;
                dmin = d;
//                break;
            }
        }
        if (ucycle==-1){
            System.out.println(-1);
        }
        else{
            StringBuilder sb = new StringBuilder();
            sb.append(dmin+"\n");
            ArrayList<Integer> list = new ArrayList<>();
            int i = prev[ucycle][ucycle];
            while (i!=ucycle){
                list.add(i);
                i = prev[ucycle][i];
            }
            list.add(ucycle);
            Collections.reverse(list);
            for (int v: list){
                sb.append((v+1)+"\n");
            }
            System.out.println(sb.toString());
        }



    }

    static ArrayList<Integer>[] g;
    static int[][] prev;
    static int[][] dist;

    static int bfs(int i){
        LinkedList<Integer> list = new LinkedList<>();
        list.add(i);
        dist[i][i] = 0;
        while (!list.isEmpty()){
            int u = list.poll();
            for (int v: g[u]){
                if (v==i){
                    prev[i][i] = u;
                    return dist[i][u]+1;
                }else if (dist[i][v]<0){
                    dist[i][v] = dist[i][u]+1;
                    prev[i][v] = u;
                    list.add(v);
                }
            }
        }
        return -1;
    }
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    string S;
    cin >> S;
    cout << (S[0] == S[1] || S[1] == S[2] || S[2] == S[3] ? "Bad" : "Good");
}

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

int main(void) {
    int D,N,ans=0;

      cin >> D>>N;

      if(D==0){
        if(N==100){
          ans = 101;
        }else{
          ans  = N;
        }
      }

      if(D==1){
        if(N==100){
          ans = 10100;
        }else{
          ans  = N*100;
        }
      }
      if(D==2){
        if(N==100){
          ans = N*10000+10000;
        }else{
          ans  = N*10000;
        }

      }

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define pq priority_queue<int,vector<int>,greater<int>>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define INF 9999999999
#define F first
#define S second
//#define int long long

using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pi> pp;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int n, m, x, y, z, add, ans, A[1010101], B[1010101];
int main() {
	cin >> n >> m;
	rep(i, n) cin >> A[i];
	sort(A, A + n);
	rep(i, n) {
		if (m >= A[i]) {
			if (i != n - 1 || A[i] == m) {
				ans++;
				m -= A[i];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

struct Node {
    Node *right;
    Node *left;
    Node *parent;
    int key;
    //int depth;
    //int parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *) malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    }
    else {
        if(z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) {
        return ;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if(u == NIL) {
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int m;
    cin >> m;
    
    for(int i = 0; i < m; i++) {
        string s;
        int n;
        cin >> s;
        if(s == "insert") {
            cin >> n;
            insert(n);
        }
        else if(s == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

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

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

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

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

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

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

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

void hawawa()
{
	int n[4], c[] = { 1, 9, 7, 4 };
	for (auto&& i : n) {
		cin >> i;
	}
	sort(begin(n), end(n));
	sort(begin(c), end(c));
	for (int i = 0; i < 4; i++) {
		if (n[i] != c[i]) {
			cout << "NO\n";
			return;
		}
	}
	cout << "YES\n";
}

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


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        String W = sc.next();
        
        int l = W.length();
        Map<String,Integer> map = new HashMap<>();
        String result = "Yes";
        if(l%2 != 1){
            for(int i=0;i<l;i++){
                String x = W.substring(i,i+1);
                if(map.get(x) == null){
                    map.put(x,1);
                }else{
                    map.put(x,map.get(x)+1);
                }
            }
            
            for(Map.Entry<String,Integer> entry : map.entrySet()){
                if(entry.getValue() % 2 == 1){
                    result = "No";
                    break;
                }
            }
        }else{
            result = "No";
        }
        System.out.println(result);
        
    }
}


Measured memory_bytes: 9684
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    int N;
    cin>>N>>S;
    
    string front=S.substr(0,N), back=S.substr(N,N);
    
    map<pair<string,string>,ll> ma;
    rep(bit,1<<N){
        string a="", b="";
        rep(i,N){
            if(bit&(1<<i)) a+=back[i];
            else b+=back[i];
        }
        reverse(all(a));
        reverse(all(b));
        ma[{a,b}]++;
    }
    
    ll res=0;
    rep(bit,1<<N){
        string a="", b="";
        rep(i,N){
            if(bit&(1<<i)) a+= front[i];
            else b+=front[i];
        }
        res+=ma[{a,b}];
    }
    cout1(res);
}

Measured memory_bytes: 87040
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
   int n,i;
   cin >> n;
   vector<int> l(n);
   int sum = 0;
   for(i = 0;i < n;++i){
       cin >> l.at(i);
       sum += l.at(i); 
    }
    sort(l.begin(),l.end());
    sum -= l.at(n-1);
    if(sum > l.at(n-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
   return 0;
}

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

int main() {
  int x;
  cin >> x;
  if (x == 7 ||
      x == 5 ||
      x == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int cnt = 0;
    int ret = 1;
    for(int i = 0;i < N - 1;i++) {
        if(vec.at(i) < vec.at(i + 1)) {
            if(cnt == 2) {
                cnt = 0;
                ret++;
            }
            else if(cnt == 0) {
                cnt = 1;
            }
        }
        else if(vec.at(i) > vec.at(i + 1)) {
            if(cnt == 1) {
                cnt = 0;
                ret++;
            }
            else if(cnt == 0) {
                cnt = 2;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
(defun println (obj) (format t "~A~%" obj))

(let ((s (read-line)))
  (println (if (or (eql (aref s 0) (aref s 1))
                   (eql (aref s 1) (aref s 2))
                   (eql (aref s 2) (aref s 3)))
               "Bad"
               "Good")))


Measured memory_bytes: 24396
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int n,q,t;
ll d[100010];
ll v[100010];
ll ans[100010];
int ef(ll x,int l,int r)
{
	int mid;
	while(l<r)
	{
		mid=(l+r+1)>>1;
		if(d[mid]>x)r=mid-1;
		else l=mid;
	}
	return l;
}
int main()
{
	scanf("%d%d",&n,&q);
	d[t=2]=n;
	for(int i=1;i<=q;i++)
	{
		ll x;
		scanf("%lld",&x);
		while(t>0&&d[t]>=x)--t;
		d[++t]=x;
	}
	v[t]=1;
	for(int i=t;i>=3;i--)
	{
		int j=i-1;
		ll zx=d[i];
		while(1)
		{
			ll x=zx-d[j],y=x/d[j];
			v[j]+=(zx/d[j])*v[i];
			zx=x-y*d[j];
			j=ef(zx,1,j);
			if(zx<=d[2])
			{
				ans[zx]+=v[i];
				break;
			}
		}
	}
	ans[d[2]]+=v[2];
	for(int i=d[2]-1;i>=1;i--)
		ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans[i]);
}

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

int main(){
    int x;
    
    cin >> x;
    int a = x/1000;
    int b = (x-a*1000)/100;
    int c = (x-a*1000-100*b)/10;
    int d = (x-a*1000-100*b-c*10);
    //cout << a << " " << b << " " << c << " " << d; 
    
    if(a == b | b==c | c ==d){
        cout << "Bad";
    }
    else{
        cout << "Good";
    }
    
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A_s = list(map(int, input().split()))
# それぞれの街に訪れた時のカウント
cache = [0]*N
# cacheの逆引き辞書
MAP = {}
# 町カーソル
i=0
# テレポーターのカウント
cnt=1
# 閉路のサイズ
rplng = 0
nolp = False
while(True):
    if(cache[i]!=0):
        rplng = cnt - cache[i]
        break
    if(cnt > K):
        nolp = True
        break
    MAP[cnt] = i+1
    cache[i] = cnt
    i = A_s[i]-1
    cnt+=1
if(nolp):
    print(i+1)
else:
    ans = MAP[(K-cnt+1)%rplng+cache[i]]
    print(ans)

Measured memory_bytes: 105604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    vin m(5),am(5),rm(5);
    rep(i,5)cin>>m[i];
    rep(i,5){
        if(m[i]%10)am[i]=(m[i]/10+1)*10;
        else am[i]=m[i];
    }
    rep(i,5){
        if(m[i]%10)rm[i]=10-m[i]%10;
        else rm[i]=0;
    }
    sort(rm.begin(),rm.end());
    int sum=0;
    rep(i,5)sum+=am[i];
    cout<<sum-rm[4]<<endl;
}

Measured memory_bytes: 256
M = dict()
M['a'] = input()
M['b'] = input()
M['c'] = input()

curr = 'a'
while len(M[curr]):
  nx = M[curr][0]
  M[curr] = M[curr][1:]
  curr = nx
print(chr(ord(curr) - ord('a') + ord('A')))

Measured memory_bytes: 3060
#include <stdio.h>

int main( void ) {
	int i, j, data[ 5 ], tmp;

	for ( i = 5; i--; scanf( "%d", data + i ) ) ;

	for ( i = 1; i < 5; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}

	for ( i = 5; i-- > 1; printf( "%d ", data[ i ] ) ) ;
	printf( "%d\n", data[ 0 ] );

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N,A,B;

int main(){
    cin>>N>>A>>B;

    ll ans=(A+B*(N-1))-(A*(N-1)+B)+1;
    ans=max(ans,(ll)0);

    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			cin >> s;
			if (s == "snuke") {
				printf("%c%d\n", j-1+'A', i);
			}
		}
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
long long n;
vector<long long> v, w, s;

class BIT {
public:
  int n;
  vector<int> bit;
  BIT(int n_) {
    n = n_;
    bit.resize(n + 1);
  }
  void add(int a, int w) {
    a += 1;
    if (a == 0 || a > n)
      return;
    for (int x = a; x <= n; x += x & -x)
      bit[x] += w;
  }
  int sum(int a) {
    if (a == 0)
      return 0;
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x)
      ret += bit[x];
    return ret;
  }
};

bool f(long long x) {
  for (int i = 0; i < n; i++) {
    w[i] = (v[i] - x) >= 0 ? 1 : -1;
  }
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + w[i];
  }
  using pll = pair<long long, long long>;
  vector<pll> p(n + 1);
  for (int i = 0; i < n + 1; i++) {
    p[i].first = i;
    p[i].second = s[i];
  }
  sort(p.begin(), p.end(), [](const pll &l, const pll &r) {
    if (l.second == r.second)
      return l.first < r.first;
    return l.second < r.second;
  });
  BIT bit(1 << 18);
  long long cnt = 0;
  for (int i = 0; i < n + 1; i++) {
    bit.add(p[i].first, 1);
    cnt += bit.sum(p[i].first);
  }
  return cnt * 2 >= n * (n + 1) / 2;
}

int main() {
  cin >> n;
  v.resize(n);
  w.resize(n);
  s.resize(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long mn = 0, mx = 1000000001;
  while (mx - mn > 1) {
    long long mm = (mn + mx) / 2;
    if (f(mm)) {
      mn = mm;
    } else {
      mx = mm;
    }
  }
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 5224
s = gets.chomp
tmp = 0
max = 0
for i in 0...s.length
  if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C'
    tmp += 1
  else
    tmp = 0
  end
  max = [max, tmp].max
  # p [tmp, s[i]]
end
puts max


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

long long lcm(long long a, long long b)
{
    long long x = a * b;
    long long ret = a % b;
    while (ret != 0)
    {
        a = b;
        b = ret;
        ret = a % b;
    }
    return x / b;
}

int main()
{
    long long A, B, C, D;
    long long Cs, Ce, Ds, De, CDs, CDe;
    long long CD, ans;
    cin >> A >> B >> C >> D;
    CD = lcm(C, D);

    Cs = (A - 1) / C;
    Ds = (A - 1) / D;
    CDs = (A - 1) / CD;

    Ce = B / C;
    De = B / D;
    CDe = B / CD;

    ans = B - A + 1 - (Ce - Cs) - (De - Ds) + (CDe - CDs);
    cout << (long long)ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;

#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int INF = 1e9+5;
using namespace std;
using ll = unsigned long long int;
const ll mod = 998244353; 

ll ncr(int n, int r = 2)
{
	ll ans = (n*(n-1))/r;
	return ans;
} 
int main()
{
	

	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock(); 
	ll a, x, n;
	cin >> a >> x >> n;
	ll b = x;
	if(b>n) b = n;
	else  b = b-1;

	ll ans = (a*b)/x ;
	cout << ans << endl;
	//time_req = clock()- time_req;cout << "Time Complexity:"<< \n'<<(float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
 }
  	

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 201001;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    c -= a + b;
    if (4 * a * b < c * c && c > 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

int main(){
  int n; cin >> n;
  vi d(n); rep(i, n) cin >> d[i];

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      ans += d[i]*d[j];
    }
  }

  std::cout << ans << '\n';
}


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

ll lcm(ll x, ll y) { return (x / __gcd(x, y)) * y; }

int main() {
  int n;
  cin >> n;
  queue<ll> que;
  for (int i = 0; i < n; i++) {
    ll temp;
    cin >> temp;
    que.push(temp);
    if (que.size() == 2) {
      ll a = que.front();
      que.pop();
      ll b = que.front();
      que.pop();
      que.push(lcm(a, b));
    }
  }
  cout << que.front() << endl;
}

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

int cc[334334];
vector<int> e[334334];
int dep[334334];

int ans[334334];

void dfs(int p, int d) {
	cc[p]--;
	dep[p] = max(dep[p], d);
	if(cc[p] <= 0) {
		for(auto i: e[p]) {
			dfs(i, dep[p] + 1);
		}
	}
}

signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cc[i] = 0;
		dep[i] = 0;
	}
	rep(i, n + m - 1) {
		int a, b;
		cin >> a >> b;
		e[a - 1].push_back(b - 1);
		cc[b - 1]++;
	}
	rep(i, n) {
		if(cc[i] == 0) {
			dfs(i, 0);
			ans[i] = 0;
			break;
		}
	}
	rep(i, n) {
		for(auto j: e[i]) {
			if(dep[i] + 1 == dep[j]) {
				ans[j] = i + 1;
			}
		}
	}
	rep(i, n) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 20096
N = gets.chomp.to_i
digit = N.to_s.length

output = 0

case digit
when 1
  output = N
when 2
  output = 9
when 3
  output = 9 + (N - 99)
when 4
  output = 9 + 900
when 5
  output = 9 + 900 + (N - 9999)
when 6
  output = 9 + 900 + 90000
end

puts output


Measured memory_bytes: 1788
N, M = map(int, input().split())
S_C_list = [[int(_) for _ in input().split()] for i in range(M)]

ans = 'a' * N

for i_s, i_c in S_C_list:
    if ans[i_s-1] == 'a' or ans[i_s-1] == str(i_c):
        ans = ans[:i_s-1] + str(i_c) + ans[i_s:]
        continue

    ans = '-1'
    break

else:
    if N == 1:
        if ans[0] == 'a':
            ans = '0'

    else:
        if ans[0] == '0':
            ans = '-1'

        elif ans[0] == 'a':
            ans = '1' + ans[1:]

if ans != '-1':
    for i, i_ch in enumerate(ans[1:], 1):
        if i_ch == 'a':
            ans = ans[:i] + '0' + ans[i+1:]

print(int(ans))

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

signed main(){
  ll h,n;cin >> h >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  for(ll i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  ll inf=10000000000;
  ll ma=*max_element(a.begin(),a.end());
  vector<ll> dp(h+1+ma,inf);dp[0]=0;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<h+1+ma;j++){
      if(dp[j]!=inf){
        if(j+a[i]<=h+ma){
          dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
        }else{
          break;
        }
      }
    }
  }
  cout << *min_element(dp.begin()+h,dp.end()) << endl;
}


Measured memory_bytes: 384
/*
 *    author:  Gary Shih
 *    created: 2020-05-03 22:38:18
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<vector<int>> dp(n + 1, vector<int>(m + 1));
  vector<vector<pair<int, int>>> prev(n + 1, vector<pair<int, int>>(m + 1));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      char cs = s[i - 1];
      char ct = t[j - 1];
      if (cs == ct) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
        prev[i][j] = {i - 1, j - 1};
      } else {
        if (dp[i - 1][j] > dp[i][j - 1]) {
          dp[i][j] = dp[i - 1][j];
          prev[i][j] = {i - 1, j};
        } else {
          dp[i][j] = dp[i][j - 1];
          prev[i][j] = {i, j - 1};
        }
      }
    }
  string ans;
  int is = n, it = m;
  while (dp[is][it]) {
    char cs = s[is - 1];
    char ct = t[it - 1];
    if (cs == ct) ans += cs;
    int nxIs = prev[is][it].first;
    int nxIt = prev[is][it].second;
    is = nxIs, it = nxIt;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
}


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

using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
#define pi acos(-1)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ve vector<ll>
#define se set<ll>
#define pll vector<pair<ll,ll>>
const string space=" ";
const ll maxx=200;
ll n,m,k,sum,faltu,t,p,i,j;
bool fg,a[maxx];
int main()
{
cin>>n>>m;
se s;
while(m--)
{
cin>>k;
while(k--)
{cin>>t;
s.insert(t);}}
cout<<n-s.size()<<endl;
    return 0;
}
    

Measured memory_bytes: 3632