akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    ll h,w;cin>>h>>w;
    vector<ll> a(h),b(w);
    for(int i=0;i<h;i++)cin>>a[i];
    for(int i=0;i<w;i++)cin>>b[i];
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    ll i1=0,i2=0;
    ll ans=1;
    for(ll i=h*w;i>=1;i--){
        if(i1<h&&i==a[i1]){
            if(i==b[i2]){
                i2++;
            }else{
                ans*=i2;   
            }
            i1++;
        }else if(i2<w&&i==b[i2]){
            ans*=i1;
            i2++;
        }else{
            ans*=(i1*i2)-(h*w-i);
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
}   


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

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

typedef pair<int, int> pii;

using namespace std;

void buildFail(const string& t, vector<int>& fail) {
	int m = t.size();
	fail.resize(m + 1);
	int j = -1;
	fail[0] = -1;
	for (int i = 1; i <= m; ++i) {
		while (j >= 0 && t[j] != t[i - 1]) j = fail[j];
		fail[i] = ++j;
	}
}

void match(const string& s, const string& t, vector<int>& res) {
	vector<int> fail;
	buildFail(t, fail);
	int n = s.size(), m = t.size();
	for (int i = 0, k = 0; i < n; ++i) {
		while (k >= 0 && t[k] != s[i]) k = fail[k];
		++k;
		if (k >= m) {
			res.emplace_back(i - m + 1);
			k = fail[k];
		}
	}
}
int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	vector<int> res;
	match(s, t, res);
	for (int x : res)
		cout << x << '\n';
	return 0;
}


Measured memory_bytes: 8852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,h;
    cin>>n>>h;
    int a[n],b[n];
    int ma=0;
    int mat=-1;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]>ma){
            ma=a[i];
            mat=i;
        }
    }
    vector<int> v;
    for(int i=0;i<n;i++){
        if(i==mat)  continue;
        if(b[i]>ma)
            v.pb(b[i]);
    }
    sort(v.rbegin(),v.rend());
    int ans=0;

    if(v.size()>0){
        for(int i=0;i<v.size();i++){
            if(b[mat]>v[i]){
                h-=b[mat];
                b[mat]=0;
                ans+=1;
            }
            if(h<=0) break;
            h-=v[i];
            ans+=1;
            if(h<=0) break;
        }
    }
    if(h>0){
        if(b[mat]>ma){
            ans+=1;
            h-=b[mat];
        }
        if(h>0){
            ans+=(h/ma);
            if(h%ma!=0)
                ans+=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1660
# coding: utf-8

# https://atcoder.jp/contests/abc115
# 10:59 giveup


def main():
    N, X = map(int, input().split())

    p = [None] * (N+1)
    p[0] = 1
    for i in range(N):
        p[i+1] = 2*p[i] + 1

    whole = [None] * (N+1)
    whole[0] = 1
    for i in range(N):
        whole[i+1] = 2*whole[i] + 3

    def rec(N, X):
        if N == 0:
            if X == 1:
                return 1
            else:
                return 0

        if X <= 1:
            return 0

        elif X <= 1 + whole[N-1]:
            return rec(N-1, X-1)

        elif X <= 1 + whole[N-1] + 1:
            return p[N-1] + 1

        elif X <= 1 + whole[N-1] + 1 + whole[N-1]:
            return p[N-1] + 1 + rec(N-1, X-(1+whole[N-1]+1))

        else:
            return p[N-1] + 1 + p[N-1]

    ans = rec(N, X)

    return ans


print(main())


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

int main() {
  string S;
  cin >> S;
  if(S[0] != S[1] && S[1] != S[2] && S[2] != S[3]){
    cout << "Good" << endl;
    return 0;
  }
  cout << "Bad" << endl;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			double[][] cost = new double[n][n];
			for(int i=0;i<n;i++) Arrays.fill(cost[i], Integer.MAX_VALUE);
			
			double[] x = new double[n];
			double[] y = new double[n];
			double[] z = new double[n];
			double[] r = new double[n];
			for(int i=0;i<n;i++){
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
				z[i] = sc.nextDouble();
				r[i] = sc.nextDouble();
				for(int j=i-1;j>=0;j--){
					double a = Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
					cost[i][j] = Math.max(0, a-r[i]-r[j]);
					cost[j][i] = cost[i][j];
				}
			}
				
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(0);
			double sum = 0;
			double q;
			int s = 0;
			int p;
			for(int i=1;i<n;i++){
				q = Integer.MAX_VALUE;
				for(int j=0;j<i;j++){
					p = list.get(j);
					for(int k=0;k<n;k++){
						if(list.contains(k)==false && q>cost[p][k]){
			  				q = cost[p][k];
							s = k;
						}
					}
				}
				list.add(s);
			 	sum += q;
			}
			
			System.out.printf("%.3f\n", sum);
		}	
	}	
}

Measured memory_bytes: 53952
def rotation(s, t):
    l = len(s)
    j = 0
    while True:
        jj = True
        for i in range(len(s)):
            if s[(i + j) % l] != t[i]:
                jj = False
                break
        if jj:
            return 'Yes'
        j += 1
        if j == l:
            break
    return 'No'

s = input()
t = input()

print(rotation(s, t))


Measured memory_bytes: 3060
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
int a,b,c;
int cnt5=0,cnt7=0;
cin>>a>>b>>c;
if(a==5) cnt5++;
  else if(a==7) cnt7++;
if(b==7) cnt7++;
  else if(b==5) cnt5++;
  if(c==5) cnt5++;
  else if(c==7) cnt7++;
if(cnt5==2&&cnt7==1){
	cout<<"YES"<<endl;
}else cout<<"NO"<<endl;
    return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int N; cin >> N;
    vector<LL> A(N);
    REP(i, N) cin >> A[i];

    int cnt = 0;
    vector<LL> B(N);
    LL m = LL(1e9);
    LL res = 0;
    REP(i, N) {
        if (A[i] < 0) ++cnt;
        LL tmp = abs(A[i]);
        res += tmp;
        m = min(m, tmp);
    }

    if (cnt % 2 == 1) {
        res -= m * 2;
    }

    cout << res << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
S = input()
y, x = set(), set()
for c in S:
    if c == 'N' or c == 'S':
        y.add(c)
    else:
        x.add(c)

print(('No', 'Yes')[len(y) % 2 == 0 and len(x) % 2 == 0])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <LL, LL> pLL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 131075;

int n, par[MAXN], l[MAXN], r[MAXN], a[MAXN], siz[MAXN], cnt[MAXN];
vector <pLL> v[MAXN];
LL dep[MAXN];
bool ans;

inline void Dfs(int x)
{
	dep[x] = dep[par[x]] + a[x];
	if (l[x])
		Dfs(l[x]), Dfs(r[x]), siz[x] = siz[l[x]] + siz[r[x]] + 1, v[x].resize(min(siz[l[x]], siz[r[x]]) << 1);
	else
		siz[x] = 1, v[x].resize(1);
}

inline void Dfs(int x, LL lim)
{
	if (!ans)
		return ;
	if (l[x])
	{
		int L = l[x], R = r[x];
		LL s = 1LL << 60;
		Dfs(L, lim), Dfs(R, lim), cnt[x] = 0;
		if (!ans)
			return ;
		if (cnt[L] > cnt[R])
			swap(L, R);
		for (int i = 0, j = cnt[R] - 1; i < cnt[L] && ~j; i ++)
		{
			while (~j && v[R][j].xx + v[L][i].xx > lim + (dep[x] << 1))
				j --;
			if (!i && !~j)
				return (void)(ans = 0);
			if (~j)
				v[x][cnt[x] ++] = mp(v[L][i].yy, v[R][j].yy), v[x][cnt[x] ++] = mp(v[R][j].yy, v[L][i].yy);
		}
		sort(v[x].begin(), v[x].begin() + cnt[x]);
		int t = cnt[x]; cnt[x] = 0;
		for (int i = 0; i < t; i ++)
			if (v[x][i].yy < s)
				s = v[x][i].yy, v[x][cnt[x] ++] = v[x][i];
	}
	else
		v[x][0] = mp(dep[x], dep[x]), cnt[x] = 1;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	LL L = 0, R = 0, ret = 0;
	n = Read();
	for (int i = 2; i <= n; i ++)
	{
		par[i] = Read(), R += a[i] = Read();
		if (l[par[i]])
			r[par[i]] = i;
		else
			l[par[i]] = i;
	}
	Dfs(1);
	while (L <= R)
	{
		LL mid = L + R >> 1;
		ans = 1;
		Dfs(1, mid);
		if (ans)
			ret = mid, R = mid - 1;
		else
			L = mid + 1;
	}
	return printf("%lld\n", ret), 0;
}


Measured memory_bytes: 43264
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int dis[100010], par[100010];
int flag = 1;

int find(int x){
    if(par[x] == x){
        return x;
    }else{
        int r = find(par[x]);
        dis[x] = dis[par[x]] + dis[x];
        par[x] = r;
        return par[x];
    }
}

void unite(int x, int y, int z){
    int fx = find(x);
    int fy = find(y);

    if(fx == fy){
        if(abs(dis[x] - dis[y]) != z){
            flag = 0;
        }
    }else{
        par[fy] = fx;
        dis[fy] = dis[x] + z - dis[y];
    }
}

int main(void){

    int N, M;

    scanf("%d%d", &N, &M);

    for(int i = 0; i < N; i++){
        par[i] = i;
    }
    
    for(int i = 0; i < M; i++){
        int l, m, d;
        scanf("%d%d%d", &l, &m, &d);
        unite(l, m, d);
    }

    if(flag == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  dump(s);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
ll powmod(ll N, ll P, ll M) {   // Calc N^P mod M ()
    if(P == 0) return 1;
    if(P%2 == 0) {
        ll t = powmod(N, P/2, M);
        return t*t%M;
    }
    return N*powmod(N, P-1, M)%M;
} 


int main() {
    ll N;
    cin >> N;

    map<string,ll> vote;
    rep(i, N) {
        string S;
        cin >> S;
        vote[S]++;
    } 

    ll maxcnt = 0;
    for(const auto& x : vote) {
        maxcnt = max(maxcnt, x.second);
    }

    for(const auto& x : vote) {
        if(maxcnt == x.second) {
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 25216
def sum_of_floor(n,m,a,b):
    ans = 0
    if a >= m:
        ans += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ans += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = (y_max * m - b)
    if y_max == 0: 
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += sum_of_floor(y_max, a, m, (a - x_max % a) % a)
    return ans

for _ in range(int(input())):
    n,m,a,b = map(int, input().split())
    ans = sum_of_floor(n,m,a,b)
    print(ans)


Measured memory_bytes: 75864
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++) {
cin>>A[i];
  }
  ll k=(N+1)/2;
  ll sum=0;
  ll s;
  if(k%2==0) {
s=1;
  }
  else {
s=-1;
  }
  ll t=s;

  
  for(ll i=0;i<k-1;i++) {
    sum+=A[i]*s;
    s*=-1;
  }
  
  for(ll i=N-1;i>=k;i--) {
sum+=A[i]*t;
    t*=-1;
  }
  
    
  ll x;
  if(k%2==0) {
x=(sum-A[k-1])/2;
  }
  else {
x=(A[k-1]-sum)/2;
  }

  cout<<2*x<<" ";
  for(ll i=1;i<N;i++) {
    x=A[i-1]-x;
    cout<<2*x<<" ";
  }
  cout<<endl;
}

  
 
  
  

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

#define N_MAX 102
#define K_MAX 100002

using namespace std;

const int MOD = 1e9+7;

int n, k;

int a[N_MAX];

int dp[N_MAX][K_MAX];
int sdp[N_MAX][K_MAX];

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for(int i = 0; i <= k; i++)
        sdp[0][i] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= k; j++)
        {
            dp[i][j] = sdp[i - 1][j];
            if(j - a[i] - 1 >= 0)
                dp[i][j] -= sdp[i - 1][max(0, j - a[i] - 1)];
            if(dp[i][j] >= MOD)
                dp[i][j] -= MOD;
            if(dp[i][j] < 0)
                dp[i][j] += MOD;
            sdp[i][j] = sdp[i][j - 1] + dp[i][j];
            if(sdp[i][j] >= MOD)
                sdp[i][j] -= MOD;
        }
    cout << dp[n][k] << "\n";
    return 0;
}


Measured memory_bytes: 79488
#include <stdio.h>
#include <stdlib.h>

struct card {
    char suit;
    int num;
};

void swap (struct card *, struct card *);
void print_a (struct card *, int);
int equal_a (struct card *, struct card *, int);
void bubble_sort (struct card *, int);
void selection_sort (struct card *, int);

int main (void) {
    int n;
    struct card *a, *b;
    char ch;

    scanf ("%d%c", &n, &ch);
    a = (struct card *) malloc (sizeof(struct card) * n);
    b = (struct card *) malloc (sizeof(struct card) * n);
    for (int i=0; i<n; i++) {
        scanf ("%c%d%c", &a[i].suit, &a[i].num, &ch);
        b[i].suit = a[i].suit;
        b[i].num = a[i].num;
    }

    bubble_sort (a, n);
    selection_sort (b, n);

    print_a (a, n);
    printf ("Stable\n");
    print_a (b, n);
    if (equal_a (a, b, n)) printf ("Stable\n");
    else printf ("Not stable\n");

    free(a);
    free(b);

    return 0;
}

void swap (struct card *a, struct card *b) {
    struct card t;
    t.suit = a->suit;
    t.num = a->num;
    a->suit = b->suit;
    a->num = b->num;
    b->suit = t.suit;
    b->num = t.num;
}

void print_a (struct card *a, int n) {
    for (int j=0; j<n; j++) {
        if (j==n-1) printf ("%c%d\n",a[j].suit, a[j].num);
        else printf ("%c%d ", a[j].suit, a[j].num);
    }
}

int equal_a (struct card *a, struct card *b, int n) {
    int i=0;
    int res=0;
    for (; i<n; i++) {
        if (!(a[i].suit==b[i].suit && a[i].num==b[i].num)) break;
    }
    if (i==n) res=1;
    return res;
}

void bubble_sort (struct card *a, int n) {
    for (int i=0; i<n; i++) {
        for (int j=n-1; j>i; j--) {
            if (a[j].num<a[j-1].num) {
                swap (a+j, a+j-1);
            }
        }
    }
}

void selection_sort (struct card *a, int n) {
    for (int i=0; i<n; i++) {
        int mini=i;
        for (int j=i; j<n; j++) {
            if (a[j].num<a[mini].num) mini=j;
        }
        if (i!=mini) {
            swap (a+i, a+mini);
        }
    }
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
      std::cin.tie(NULL);
      long long int n,m,k;
      std::cin >>n>>m>>k;
      std::vector<long long int> a(n);//size
      std::vector<long long int> b(m);//size

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

      for(int i=0;i<m;i++)
        std::cin >>b[i];

//by using perfix sum
std::vector<long long int> aSUM(n+1);//size
std::vector<long long int> bSUM(m+1);//size
int count=0;
      for(int i=0;i<n;i++)
          aSUM[i+1] =aSUM[i]+a[i];

     for(int i=0;i<m;i++)
          bSUM[i+1] =bSUM[i]+b[i];

      //0 60 and so on
      for(int i=0;i<=n;i++){
        long long int other = k-aSUM[i];
         if(other<0)
           continue;
        //here get the position of other from bSum
        int l = lower_bound(bSUM.begin(),bSUM.end(),other)-bSUM.begin();
        if(l>m || bSUM[l]>other)
           --l;
      count = std::max(count,i+l);
     }
     std::cout << count << '\n';
return 0;
}


Measured memory_bytes: 9504
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n:usize,
    }

    let mut sayying = vec![];

    for _ in 0..n {
        input!{
            a:usize,
            xy:[(usize,usize);a]
        }
        sayying.push(xy);
    }

    let mut max = 0;
    for i in 0..2u32.pow(n as u32) {
        let s = format!("{:0>1$b}", i, n);
        let s =  s.chars().collect::<Vec<char>>();
        let mut mujun = false;
        let mut cnt = 0;
        for (i, &v) in s.iter().enumerate() {
             //iについて矛盾かないか
            if v == '1' {
                for (x, y) in &sayying[i] {
                    if (s[x-1] as i32 - 48) != (*y  as i32) {
                        mujun = true;
                        break;
                    }
                }
                cnt += 1;
            }
        }

        if !mujun{
            max = max!(cnt, max);
        }
    }

     println!("{}", max);
}


Measured memory_bytes: 2272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> isok(1000010, 0);
    for(int i = 0; i < n; i++) isok[a[i]]++;
    int ans = 0;
    vector<int> yaku;
    for(int i = 1; i < 1010; i++){
        if(isok[i] >= 1){
            if(yaku.size() == 0){
                yaku.push_back(i);
            }else{
                bool isadd = true;
                for(int j = 0; j < yaku.size(); j++){
                    if(i % yaku[j] == 0){
                        isadd = false;
                        break;
                    }
                }
                if(isadd) yaku.push_back(i);
            }
            if(isok[i] == 1) ans++;
            for(int j = 2; i*j < 1000005; j++){
                isok[i*j] = 0;
            }
        }
    }
    for(int i = 1010; i < 1000005; i++){
        if(isok[i] >= 1){
            for(int j = 2; i*j < 1000005; j++){
                isok[i*j] = 0;
            }
            if(isok[i] == 1) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8008
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x,t;
   
   string s;
   cin>>s;
   if(s=="ABC"){
   	cout<<"ARC";
   }
   else{
   	cout<<"ABC";
   }
   
   
   
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
int main()
{
  

  int N;
  cin >> N;

  int sum=0;
  int a,b,c;
  
  for(a=1;a<N;a++)
  {
    for(b=1;b<N;b++)
    {
      if(a*b<N)
      {
        sum++;
      }
      else
      {
        break;
      }
    }
  }

  cout << sum <<endl;
  return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

def main():
    N = ii()
    a,g,c,t=0,1,2,3
    MOD = 10**9+7

    dp = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(110)]

    def ok(j,k,l):
        f = True
        for x,y,z in [(j,k,l),(j,l,k),(k,j,l)]:
            f = f and not (x == a and y == g and z == c)
        return f


    for j in range(4):
        for k in range(4):
            for l in range(4):
                if not ok(j,k,l): continue
                dp[3][j][k][l] = 1
    
    ans = 0
    for i in range(3,N):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for c_char in range(4):
                        if not ok(k,l,c_char): continue
                        elif j == a and c_char == c and (k == g or l == g): continue
                        dp[i+1][k][l][c_char] += dp[i][j][k][l] % MOD

    # print(dp)
    for j in range(4):
            for k in range(4):
                for l in range(4): 
                    ans += dp[N][j][k][l]  % MOD


    print(ans % MOD)



if __name__ == "__main__":
    main()

Measured memory_bytes: 75308
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	bool operator<(const struct Info &arg) const{
		if(row != arg.row){
			return row < arg.row;
		}else{
			return col < arg.col;
		}
	};
	int row,col;
};

struct Data{
	Data(int arg_row,int arg_col,int arg_height){
		row = arg_row;
		col = arg_col;
		height = arg_height;
	}
	bool operator<(const struct Data &arg) const{
		return height < arg.height;
	};

	int row,col,height;
};

struct Shishimaru{
	vector<Info> info;
};

int H,W;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
int memo[1000][1000],table[1000][1000];
Shishimaru shishimaru[1000][1000];

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}

vector<Info> recursive(int row,int col,int depth){

	if(memo[row][col] != -1){
		return shishimaru[row][col].info;
	}

	vector<Info> sum,catcher;

	int adj_row,adj_col;

	for(int i = 0; i < 4; i++){
		adj_row = row + diff_row[i];
		adj_col = col + diff_col[i];

		if(rangeCheck(adj_row,adj_col) == false || table[adj_row][adj_col] > table[row][col])continue;

		catcher = recursive(adj_row,adj_col,depth+1);

		for(int k = 0; k < catcher.size(); k++){
			sum.push_back(catcher[k]);
		}
		catcher.clear();
	}

	if(sum.size() == 0){
		memo[row][col] = 0;
		if(depth > 0){
			shishimaru[row][col].info.push_back(Info(row,col));
			sum.push_back(Info(row,col));
		}
		return sum;
	}

	sort(sum.begin(),sum.end());

	int pre_row = sum[0].row,pre_col = sum[0].col;
	shishimaru[row][col].info.push_back(sum[0]);

	for(int i = 1; i < sum.size(); i++){
		if(sum[i].row != pre_row || sum[i].col != pre_col){
			shishimaru[row][col].info.push_back(sum[i]);
		}
		pre_row = sum[i].row;
		pre_col = sum[i].col;
	}

	memo[row][col] = shishimaru[row][col].info.size();

	return shishimaru[row][col].info;
}

int main(){

	scanf("%d %d",&H,&W);

	priority_queue<Data> Q;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d",&table[row][col]);
			Q.push(Data(row,col,table[row][col]));
			memo[row][col] = -1;
		}
	}

	while(!Q.empty()){
		if(memo[Q.top().row][Q.top().col] == -1){
			recursive(Q.top().row,Q.top().col,0);
		}
		Q.pop();
	}

	int ans = 0;
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			if(memo[row][col] > 1){
				ans++;
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 114832
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string S;
    cin>>S;
    int keta = S.size();
    vi Mod(keta), BekiMod(keta), rest(2019);
    rest[0]++;
    Mod[keta-1] = S.back() - '0';
    BekiMod[keta-1] = 1;
    for(int i = S.size()-2; i >= 0; i--){
        BekiMod[i] = (BekiMod[i+1] * 10) % 2019;
    }
    for(int i = S.size()-2; i >= 0; i--){
        int digit = S[i] - '0';
        Mod[i] = (BekiMod[i] * digit + Mod[i+1]) % 2019;
    }
    REP(i, 0, keta){
        rest[Mod[i]]++;
    }
    long ans = 0;
    REP(i, 0, 2019) ans += rest[i] * (rest[i]-1) / 2; 
    cout << ans << endl;
}

Measured memory_bytes: 5132
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
using namespace std;
int solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='A'){
			if(i+2<n && s[i+1]=='B' && s[i+2]=='C')
				cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

Measured memory_bytes: 3644
n = gets.to_i
buckets = (0..5).map{ [] }
$<.each{|s|
	s.chomp!
	buckets[s.size] << s
}

buckets.shift while buckets[0].empty?

a = buckets.shift.sort
if a.size >= 3
	puts a[0..3].combination(2).map{|s1, s2|
		[s1 + s2, s2 + s1]
	}.flatten.sort[2]
else
	buckets.shift while buckets[0].empty?
	b = buckets[0].sort
	if a.size == 2
		puts [a[0] + b[0], b[0] + a[0]].min
	else #a.size == 1
		if b.size >= 2
			puts b[0..[2, b.size-1].min].map{|x|
				[a[0] + x, x + a[0]]
			}.flatten.sort[2]
		else #b.size == 1
			buckets.shift while buckets[0].empty?
			c = buckets[0].sort
			puts [a[0] + c[0], c[0] + a[0]].min
		end
	end
end

Measured memory_bytes: 6260
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int n,m;
	cin >> n >> m;
	VI a(m);
	rep(i, m) cin >> a[i];
	sort(all(a));

	VI b(m-1);
	rep(i, m-1) {
		b[i] = a[i + 1] - a[i];
	}

	sort(all(b));
	int ans = 0;
	rep(i, m - n) {
		ans += b[i];
	}
	cout << ans << endl;

	

	
}


 

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  
  for(int i=0;i<H;i++){
    cin >> a[i];
  }

    for(int i=0;i<W+2;i++){
      cout << "#" ;
    }
    cout << endl;
  for(int j=0;j<H;j++){

    cout << "#"  << a[j] << "#" << endl ;
  }
    


    for(int i=0;i<W+2;i++){
      cout << "#" ;
    }  
      cout << endl;

}

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

typedef long long ll;
const ll mod=1e9+7;
const int N=200000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll a[N];
int main()
{
    Run();
    int n;
    cin>>n;
    map<ll,ll>mp;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
		ll x;
        cin>>x;
		mp[x]++;
		sum+=x;
    }
    int q;
    cin>>q;
    while(q--){
		ll a,b;
		cin>>a>>b;
		sum-=mp[a]*a;
		sum+=mp[a]*b;
		mp[b]+=mp[a];
		mp[a]=0;
		cout<<sum<<endl;
    }
}


Measured memory_bytes: 9416
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// 木の直径
template<typename T>
struct Diameter {
private:
    struct edge {
        int to; T cost;
    };

    vector<vector<edge>> G;

    // (最遠点までのコスト,最遠点)
    pair<T, int> dfs(int v, int p) {
        pair<int, int> res = {0,v};
        for (auto &e : G[v]) {
            if (e.to == p) continue;
            auto d = dfs(e.to, v);
            if (res.first < d.first + e.cost) {
                res.first = d.first + e.cost;
                res.second = d.second;
            }
        }
        return res;
    }
public:
    vector<int> highest;
    void dfs_2(int v, int p, int h) {
        highest[v] = max(highest[v], h);
        for (auto &e : G[v]) {
            if (e.to == p) continue;
            dfs_2(e.to, v, h + e.cost);
        }
    }

    Diameter(int V) {
        G.resize(V);
        highest.resize(V, 0);
    }

    // 無向辺を張る
    void add_edge(int v, int u, T cost) {
        G[v].push_back({u,cost});
        G[u].push_back({v,cost});
    }

    void build() {
        auto p = dfs(0, -1);
        auto q = dfs(p.second, -1);
        dfs_2(p.second, -1, 0);
        dfs_2(q.second, -1, 0);
    }
};

int main() {
    int n; cin >> n;
    Diameter<int> G(n);
    REP(i, n - 1) {
        int s, t, w; scanf("%d %d %d", &s, &t, &w);
        G.add_edge(s, t, w);
    }
    G.build();
    REP(i, n) {
        cout << G.highest[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3936
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = scan.nextInt();
        long ans = 1000L;
        int i = 0;
        while (i < n) {
            int j = i;
            while (j + 1 < n && a[j] <= a[j + 1]) j++;
            ans += ans / a[i] * (a[j] - a[i]);
            i = j + 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35748
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,mx;
string s;
map<string,int> mp;
vector<string> ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>s,mp[s]++;
	mx=-66666;
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		if(it->second==mx)
			ans.push_back(it->first);
		if(it->second>mx)
			mx=it->second,ans.clear(),ans.push_back(it->first);
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<'\n';
	return 0;
}

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

template<class T, class E> struct LazySegmentTree {
    using F = function<T(T, T)>;
    using G = function<T(T, E)>;
    using H = function<E(E, E)>;
private : 
    int n, dep;
    const F f;
    const G g;
    const H h;
    T id1;
    E id0;
    vector<T> node;
    vector<E> lazy;

public : 
    LazySegmentTree (const F &f, const G &g, const H &h, const T &id1, const E &id0) :
        f(f), g(g), h(h), id1(id1), id0(id0) { }

    void init (int sz) {
        n = 1; dep = 0;
        while (n < sz) { n <<= 1; dep++; }
        node.resize(2*n, id1);
        lazy.resize(2*n, id0);
    }

    void build (vector<T> v) {
        const int sz = v.size();
        init(sz);
        for (int i = 0; i < sz; i++) node[i+n] = v[i];
        for (int i = n-1; i > 0; i--) node[i] = f(node[i<<1|0], node[i<<1|1]);
    }

    inline T reflect (int k) {
        return (lazy[k] == id0 ? node[k] : g(node[k], lazy[k]));
    }

    inline void eval (int k) {
        if (lazy[k] == id0) return;
        lazy[k<<1|0] = h(lazy[k<<1|0], lazy[k]);
        lazy[k<<1|1] = h(lazy[k<<1|1], lazy[k]);
        node[k] = reflect(k);
        lazy[k] = id0;
    }

    inline void thrust (int k) {
        for (int i = dep; i; i--) eval(k>>i);
    }

    inline void recalc (int k) {
        while (k >>= 1) node[k] = f(reflect(k<<1|0), reflect(k<<1|1));
    }

    void update (int a, int b, T x) {
        thrust(a += n);
        thrust(b += n-1);
        for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if (l&1) { lazy[l] = h(lazy[l], x); l++; }
            if (r&1) { --r; lazy[r] = h(lazy[r], x); }
        }
        recalc(a);
        recalc(b);
    }

    T query (int a, int b) {
        thrust(a += n);
        thrust(b += n-1);
        T vl = id1, vr = id1;
        for (int l = a, r = b+1; l < r; l >>= 1, r >>= 1) {
            if (l&1) vl = f(vl, reflect(l++));
            if (r&1) vr = f(reflect(--r), vr);
        }
        return f(vl, vr);
    }

};

int main() {
   int n, m;
   cin >> n >> m;
   vector<pair<int, long long>> dat[n];
   for (int i = 0; i < m; i++) {
       int l, r; long long a;
       cin >> l >> r >> a;
       --l; --r;
       dat[r].emplace_back(l, a);
   }
   
   auto f = [](long long a, long long b) { return max(a, b); };
   auto g = [](long long a, long long b) { return a + b; };
   LazySegmentTree<long long, long long> dp(f, g, g, 0LL, 0LL);
   dp.init(n+10);
   
   for (int r = 0; r < n; r++) {
       dp.update(r, r+1, dp.query(0, r));
       for (const auto &e : dat[r]) {
           dp.update(e.first, r+1, e.second);
       }
   }
   
   cout << dp.query(0, n) << endl;
   return 0;
}

Measured memory_bytes: 19456
using System;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var ball = ToInt32(ReadLine());
        var num = ToInt32(ReadLine());
        var coordinates = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var result = 0;
        for(var i = 0; i < ball; i++)
        {
            if (coordinates[i] < num - coordinates[i]) result += coordinates[i];
            else result += num - coordinates[i];
        }
        WriteLine(result*2);
    }
}



Measured memory_bytes: 11220
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);

  char s[n];
  scanf("%s",s);

  int ans = 1;
  for(int i = 0;i < n-1;i ++){
    if(s[i] != s[i+1]){
      ans ++;
    }
  }
  printf("%d",ans);

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 998244353
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int dp[3005];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, s; cin>>n>>s;
    int ans=0;
    for(int i=0; i<n; i++){
    	int a; cin>>a;
    	for(int j=s; j>=1; j--){
    		if(j-a >= 0){
    			dp[j]=(dp[j]+dp[j-a])%MOD;
    		}
    	}
    	if(a <= s){
    		dp[a]+=i+1;
    		dp[a]%=MOD;
    	}
    	ans+=dp[s];
    	ans%=MOD;
    }
    cout<<ans;
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n,k;cin>>n>>k;
	set<int>s;
    while(k--){
        int d;cin>>d;
        for(int i=0;i<d;i++){
            int a;cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size()<<"\n";
}



Measured memory_bytes: 3652
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mod 1000000000000000000
#define MAXX  1e18
#define MINN -1e18

#define ll long long
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define add(a, b) (((a)%mod + (b)%mod + mod)%mod)
#define mul(a, b) (((a)%mod * (b)%mod) % mod)
#define endl cout<<"\n";
#define debug(vari) cerr<< "["<< #vari << "" << (vari) << "]";endl;
#define read(a) for(auto &i: a) cin >> i;
#define out(a)  for(auto i: a) cout << i << " ";endl
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;
vector<ll> prime(1000005, 1);
vector<ll> sieve() {
    vector<ll> p;
    prime[0] = 0, prime[1] = 0;
    for(int i=2; i<=sqrt(100005); i++) {
        if(prime[i]) {
            for(int j=2; i*j<=1000005; j++) {
                prime[i*j] = 0;
            }
        }
    }
    for(int i=2; i<100005; i++) {
        if(prime[i]) p.pb(i);
    }
    return p;
}
ll dis[2001][2001];
int main() {
    fastio
    ll x; cin >> x;
    vector<ll> sve = sieve();
    cout << *(lower_bound(all(sve), x)); 
    
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;

    UnionFind tree(N);

    for(int i = 0; i < M; i++) {
        int  x, y,z;
        cin >> x >> y>>z;
        tree.unite(x-1, y-1); // xの木とyの木を併合する
    }

    int cnt=0;
    for(int i=0;i<N;i++){
        if(!tree.same(0,i)){
            tree.unite(0, i);
            cnt++;
        }
    }

    cout << cnt+1 << endl;
    return 0;
}

Measured memory_bytes: 1536
mod=998244353
n=int(input())
from collections import Counter as co
j=list(map(int,input().split()))
l=co(j)
ll=len(l)
for i in range(ll):
    if i not in l:print(0);exit()
if l[0]>=2 or j[0]!=0:print(0);exit()
ans=1
pre=1
for k,v in sorted(l.items()):
    ans*=pow(pre,v,mod)
    ans%=mod
    pre=v
print(ans%mod)

Measured memory_bytes: 21468
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <climits>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define uset        unordered_set
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const ll N = 2e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){
	
}
void solve(){
	double a,b,h;
	int m;
	cin>>a>>b>>h>>m;
	double ff=1.0*h*30+1.0*m*0.5;
	double ss=6*m;
	double ang=1.0*fabs(ff-ss);
	ang=1.0*(ang*PI)/180;
	double ans=a*a+b*b-2*a*b*cos(ang);
	cout<<fixed<<setprecision(60)<<sqrt(ans)<<endl;
}
int main()
{
    //ios;
    int tc=1;
    //cin>>tc;
    prec();
    while(tc--)
    	solve();
    return 0; 
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	auto f = [](vector<int> &as) {
		for (auto &&a : as)
		{
			if (a % 2)
			{
				return false;
			}
			a /= 2;
		}
		return true;
	};

	int ans = 0;

	for (; f(as); ans++)
	{
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

ll N;
vector<vector<int>> edge;
vector<vector<int>> mx;
int MX=0;
int NS=0;

void dfs1(int u,int p){
  mx[u]={0,0,0};
  for(auto &v:edge[u]){
    if(v==p){continue;}
    dfs1(v,u);
    mx[u].push_back(mx[v][0]+1);
  }
  sort(mx[u].begin(),mx[u].end(),greater<int>());
  mx[u].resize(3);
}

void dfs2(int u,int p,int np){
  mx[u].push_back(np);
  sort(mx[u].begin(),mx[u].end(),greater<int>());
  mx[u].resize(3);
  pii mx1={np+1,p},mx2={1,u};
  if(mx1<mx2){swap(mx1,mx2);}
  for(auto &v:edge[u]){
    if(v==p){continue;}
    mx2=max(mx2,{mx[v][0]+2,v});
    if(mx1<mx2){swap(mx1,mx2);}
  }
  for(auto &v:edge[u]){
    if(v==p){continue;}
    if(v==mx1.S){dfs2(v,u,mx2.F);}
    else{dfs2(v,u,mx1.F);}
  }
  if(mx[u][2]==0){return;}
  //cout<<u+1<<" "<<mx[u]<<endl;
  MX=max(MX,2*mx[u][2]);
  if(mx[u][0]!=mx[u][2]){NS=max(NS,mx[u][0]+mx[u][2]);}
  else if(mx[u][2]>1){NS=max(NS,mx[u][0]+mx[u][2]-1);}
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  edge.resize(N);
  mx.resize(N);
  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs1(0,-1);
  dfs2(0,-1,0);
  for(int i=1;i<=N;i++){
    if(i<=2){cout<<1;}
    else if(i%2==0){
      if(i<=NS){cout<<0;}
      else{cout<<1;}
    }
    else{
      if(i<=max(MX,NS)){cout<<0;}
      else{cout<<1;}
    }
  }
  cout<<endl;
  //cout<<MX<<" "<<NS<<endl;

  return 0;
}



Measured memory_bytes: 23088