akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
 
char c[15][15],d[15],e[15];
int i,m,n;
 
inline bool dfs2(int x)
{
    if (x>m)
        return true;
    if (e[x])
        return dfs2(x+1);
    else
    {
        int t=0,r=0;
        for (int i=x;i<=m;i++)
            if (! e[i])
                t++;
        for (int i=x;i<=m;i++)
            if (! e[i])
            {
                e[x]=i,e[i]=x,r=1;
                for (int j=1;j<=n;j++)
                    if ((c[j][x]!=c[d[j]][i]) || (c[d[j]][x]!=c[j][i]))
                    {
                        r=0;
                        break;
                    }
                if(i==x){
                    if(r&&(t&1)&&dfs2(x+1))return true;
                }
                else{
                    if(r){
                        if(dfs2(x+1))return true;else return false;
                    }
                }
                /*if ((r) && ((t&1) || (i!=x)) && (dfs2(x+1)))
                    return true;
                else if(i!=x)return false;*/
                e[x]=0,e[i]=0;
            }
    }
    return false;
}
 
inline bool dfs1(int x)
{
    if (x>n)
        return dfs2(1);
    if (d[x])
        return dfs1(x+1);
    else
    {
        int t=0;
        for (int i=x;i<=n;i++)
            if (! d[i])
                t++;
        for (int i=x;i<=n;i++)
            if (! d[i])
            {
                d[x]=i,d[i]=x;
                if (((t&1) || (i!=x)) && (dfs1(x+1)))
                    return true;
                d[x]=0,d[i]=0;
            }
    }
    return false;
}

int main()
{
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++)
        scanf("%s",c[i]+1);
    if (dfs1(1))
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 3e5 + 233;
int n, a[N], id[N];
int main(void) {
	read(n);
	rep (i, n) read(a[i]), id[a[i]] = i;
	set <int> S;
	lo ans = 0;
	rep (i, n) {
		auto it = S.lower_bound(id[i]);
		int l = 0, r = n + 1;
		if (it != S.end()) r = *it;
		if (it != S.begin()) l = *--it;
		ans += 1LL * i * (id[i] - l) * (r - id[i]);
		S.insert(id[i]);
	}
	cout << ans << "\n";
   
}


Measured memory_bytes: 11136
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n,r;
    n=in.nextInt();
    r=in.nextInt();
    if(n>=10)
    {
      System.out.println(r);
      System.exit(0);
    }
    else
    {
      r=r+(100*(10-n));
      System.out.println(r);
    }
  }
}

Measured memory_bytes: 21716
N = int(input())
T = N
KISU = 26
Y = []
A = [chr(ord('a') + i) for i in range(26)]
ans = ''
S1 = 0
S1 = 25 if S1 == 0 else S1
while True:
  if T == 0:
    break
  S1 = (T % KISU)
  S1 = 26 if S1 == 0 else S1
  Y.append(S1)
  if S1 == 26:
    T -= 1
  T = T//KISU
for n in Y[::-1]:
  ans += A[n - 1]
print(ans)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int N, C;
	cin >> N >> C;
	vector<int> s(N), t(N), c(N);
	rep(i,N) cin >> s[i] >> t[i] >> c[i];

	map<int, int> start, end;
	//　同じチャンネルだったら、撮り終わった瞬間撮り始めることが出来る。
	map<P, int> kaburi;
	rep(i,N){
		start[s[i]]++;
		end[t[i]]++;
		kaburi[{s[i], c[i]}]++;;
	}
	vector<int> lucky(100010,0);
	rep(i,N){
		if(kaburi[{t[i],c[i]}]){
			// 同じチャンネルで、時刻t[i]に終わるものがある
			lucky[t[i]] ++;
			//cout << "t = " << t[i] << " is lucky " << endl;
		}
	}
	
	int num = 0;
	int use = 0;
	for(int i = 1; i <= 100010; i++){
		if(start[i]){
			// start[i]台使いたい。今使えるのはnum-use;
			if(lucky[i]){
				start[i] -= lucky[i];
				end[i] -= lucky[i];
			}
			if(num-use>=start[i]){
				use += start[i];
			} else {
				//start[i] - use台足りない
				num += (start[i] + use) - num;
				use = num;
			}
		} else {
			// 時刻 i に始まるのが無いなら何もしない
		}
		if(end[i]){
			// 時刻 i に終わるのがあるなら、
			use -= end[i];
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int ans = 0;
  rep(i,N) {
    int cnt = 1;
    while(i<N-1 && A[i] == A[i+1]) {
      cnt++;
      i++;
    }
    ans += cnt/2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long h;
    long long n;
    cin >> h >> n;
    int result = 0;
    long long a;
    for(long long i = 0; i < n; i++){
        cin >> a;
        result = result + a;
    }
    if(result >= h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
t_hp, t_atk, a_hp, a_atk = [int(i) for i in input().split()]
 
while t_hp > 0 and a_hp > 0 :
  a_hp -= t_atk
  if a_hp <= 0 :
    break
  t_hp -= a_atk
if t_hp <= 0 :
  print('No')
else :
  print('Yes')

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

int main()
{
	LL n;
	cin >> n;
	vector<LD> p(n);

	for (auto &e : p) {
		cin >> e;
	}

	vector<vector<LD>> mat(n, vector<LD>(n+1, (LD)(0)));

	mat[0][0] = 1- p[0];
	mat[0][1] = p[0];

	for (LL i = 1; i < n; ++i) {
		for (LL j = 0; j <= i+1; ++j) {
			if (j == 0) {
				mat[i][j] = mat[i-1][j]*(1-p[i]);
			}
			else {
				mat[i][j] = mat[i-1][j-1]*(p[i]) + mat[i-1][j]*(1-p[i]);
			}
		}
	}

	LD ans = 0;

	for (LL i = n/2+1; i < n+1; ++i) {
		ans += mat[n-1][i];
	}
	cout << fixed << setprecision(10) << ans << "\n";
}

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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int a[n], b[n], c[n - 1];
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n - 1; ++i) cin >> c[i];
	int ans = 0;
	int prev = a[0];
	for (int i = 0; i < n; ++i) {
		ans += b[a[i] - 1];
		if (a[i] - prev == 1) ans += c[prev - 1];
		prev = a[i];
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

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

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

template <typename T>
struct SegmentTree {
  using F = function<T(T, T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f, T ti) : f(f), ti(ti) {}

  void init(int n_) {
    n = 1;
    while (n < n_)
      n <<= 1;
    dat.assign(n << 1, ti);
  }

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

  void set_val(int k, T x) {
    dat[k += n] = x;
    while (k >>= 1)
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
  }

  // [a, b)
  T query(int a, int b) {
    T vl = ti, vr = ti;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1)
        vl = f(vl, dat[l++]);
      if (r & 1)
        vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

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

  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  auto f = [](ll a, ll b) {
    if (a == INT_MAX)
      return b;
    else if (b == INT_MAX)
      return a;
    else
      return gcd(a, b);
  };
  SegmentTree<ll> seg(f, INT_MAX);
  seg.build(A);

  ll ans = 0;
  rep(i, N) {
    ll origin = A[i];
    ll change = (i ? A[0] : A[1]);
    seg.set_val(i, change);
    chmax(ans, seg.query(0, N));
    seg.set_val(i, origin);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	char a[4];
	rep(i,0,4){
		cin >> a[i];
	}
	bool pt = true;
	rep(i,1,4){
		if(a[i-1] == a[i]){
			pt = false;
		}
	}
	if(pt){
		cout << "Good" << endl;
	}else{
		cout << "Bad" << endl;
	}
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: n, i
  integer, allocatable :: l(:)
  read (*, *) n
  allocate (l(n))
  read (*, *) l(:)
  if (maxval(l) * 2 < sum(l)) then
    print "(a)", "Yes"
  else
    print "(a)", "No"
  end if
end program main


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
string s,a,b;
ll n,ans,rans;
ll f(string s,string t){
    ll cnt=0,kot=0;
    for(int i=0;i<s.size();i++){
        if(s[i]==t[i])cnt++;
        else{
            kot=max(kot,cnt);
            cnt=0;
        }
    }
    kot=max(kot,cnt);
    return kot;
}
int main(void){
    cin>>n>>s;
    for(ll i=1LL;i<n;i++){
        a=s.substr(i,n-i);
        b=s.substr(0,n-i);
        ans=min(i,f(a,b));
        rans=max(rans,ans);
    }
    cout<<rans<<endl;
}


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

using namespace std;

typedef long long ll;
int f[200050];
int main()
{
  ios::sync_with_stdio(false);
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int k=min(j-i,abs(x-i)+abs(y-j)+1);
            f[k]++;
        }
    }
    for(int i=1;i<n;i++)
        cout <<f[i] << endl;
    return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2+m*(m-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import System.IO

main = do
  n <- readLn :: IO Int
  s <- query 0
  ans <- upperBound s 0 n
  print ans

--[lb, ub)
upperBound :: Int -> Int -> Int -> IO Int
upperBound s lb ub
  | ub - lb == 1 = return lb
  | otherwise = do
    let mid = div (lb + ub) 2
        s' = if (odd $ mid - lb) then negate s else s
    flag <- judge s lb mid
    if flag
      then upperBound s' mid ub
      else upperBound s lb mid

judge :: Int -> Int -> Int -> IO Bool
judge s l x = do
  m <- query x
  if odd $ x-l
    then return $ s /= m
    else return $ s == m

query :: Int -> IO Int
query i = do
  putStrLn $ show i
  hFlush stdout
  s <- getLine
  case s of
    "Vacant" -> return 0
    "Male" -> return 1
    "Female" -> return $ negate 1


Measured memory_bytes: 1104
def sieve(N):#エラトステネスの篩
    prime = [0]*(N+1)
    isprime = [True]*(N+1)
    isprime[0]=isprime[1] = False
    num = 0
    for p in range(2,N+1):
        if isprime[p]:
            prime[num] = p
            num += 1
            for j in range(2*p,N+1,p):
                isprime[j] = False
    return prime
from bisect import bisect_left as bl
from bisect import bisect_right as br
lis = sieve(10**5)
prime = set(lis)-{0}
for i in range(len(lis)):
    if lis[i] != 0:
        if (lis[i]+1)//2 in prime:continue
        else:lis[i] = 0
    else:continue
Q = int(input())
lis = set(lis)-{0}
lis = sorted(tuple(lis))
for _ in range(Q):
    l,r = map(int,input().split())
    t = bl(lis,l)
    s = br(lis,r)
    tmp = s-t
    print(tmp)



Measured memory_bytes: 5324
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  _ <- getLine                                                                                                                                        
  s <- getLine                                                                                                                                        
  let w = length . filter (=='.') $ s                                                                                                                 
  print $ minimum $ map (uncurry (+)) $ solve 0 w s                                                                                                   
                                                                                                                                                      
solve :: Int -> Int -> String -> [(Int,Int)]                                                                                                          
solve a b [] = [(a,b)]                                                                                                                                
solve a b (x:xs)                                                                                                                                      
  | x == '.' = (a,b) : solve a (b-1) xs                                                                                                               
  | x == '#' = (a,b) : solve (a+1) b xs 

Measured memory_bytes: 14844
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let a: u32 = iter.parse();
    let b: u32 = iter.parse();
    let c: u32 = iter.parse();
    let count = if c < b / a { c } else { b / a };

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

Measured memory_bytes: 4352
N=input()
a=input().split()
list1=[]
for item in a :
  list1.append(int(item))
flag=True
for item in list1 :
  if item%2==0 :
    if not (item%3==0 or item%5==0) :
      flag=False
      break
  
if flag :
  print('APPROVED')
else :
  print('DENIED')

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#include <bits/stdc++.h>

// Defination {{{
#define PI pair<int, int>
#define mk make_pair
#define reg register
#define ll long long
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)
#define per(i, a, b) for(reg int i = a; i >= b; --i)
#define pb push_back
// }}}

using namespace std;

int min(reg int a, reg int b) { return a < b ? a : b; }
int max(reg int a, reg int b) { return a > b ? a : b; }

template<typename T> void read(T &x) {
    x = 0; reg char ch = getchar(); reg int f = 1;
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') ch = getchar();
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= f;
}

#define N 100005

char s[N], t[N];
vector<int> pos[50];

int main() {
    scanf ("%s", s + 1);
    scanf ("%s", t + 1);
    int lens = strlen(s + 1), lent = strlen(t + 1);
    rep (i, 1, lens) {
        pos[s[i] - 'a' + 1].push_back(i);
    }
    rep (i, 1, 26) pos[i].push_back(lens + 1);
    int now = 0;
    ll len = 0;
    rep (i, 1, lent) {
        int id = t[i] - 'a' + 1;
        now = *lower_bound(pos[id].begin(), pos[id].end(), now + 1); 
        if (now == lens + 1) {
            now = 0;
            now = *lower_bound(pos[id].begin(), pos[id].end(), now + 1); 
            if (now == lens + 1) {
                puts("-1");
                return 0;
            }
            len += lens;
        }
    }
    len += now;
    cout << len << endl;
    return 0; 
}

/*
 _____  ____    _____
|__  / |  _ \  |__  /
  / /  | |_) |   / / 
 / /_  |  _ <   / /_ 
/____| |_| \_\ /____|

 _____________________________________ 
< E.cpp is created by zrz who is weak >
 ------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
int n,a[1010];
int main(){
	cin>>n;
	fo(i,0,n)cin>>a[i];
	sort(a,a+n);
	int x=0;
	fo(i,0,n-1)x+=a[i];
	if(x>a[n-1])cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define dd double
using namespace std;

int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int l,r,d;
  cin>>l>>r>>d;
  int count=0;
  while(l<=r){
  	if(l%d==0){
  		count++;
	}
	l++;
  }
  
  cout<<count<<endl;
  return 0;
}

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

long long int n, a, b;

int main(){
	scanf("%lld %lld %lld", &n, &a, &b);
	if(n>1&&a<=b) printf("%lld\n", a+b*(n-1)-b-a*(n-1)+1);
	else if(n==1&&a==b) printf("1\n");
	else printf("0\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int N, L;
  cin >> N >> L;
  int azi = (N * (N-1))/2 + N * L;
  if (L > 0) cout << azi - L << endl;
  else if (L + N - 1 < 0) cout << azi - (L + N - 1) << endl;
  else cout << azi << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
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 / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

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

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,h,m;

	cin >> a >> b >> h >> m;

	
	long double rad = M_PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

	long double ans = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);
	
	cout << fixed << setprecision(12);
	cout << sqrtl(ans) << endl;

	
		
	



}
	

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

int main() {

//    priority_queue<int> que;

    int N, K;
    cin >> N >> K;
//    vector<int> numbers(N, 0);
    string S;
    cin >> S;
    char prev_c = 'L';
    int face_count = 0;
    for(int i=0;i<N;i++){
        if(prev_c == 'R' && S.at(i) == 'L'){
            face_count += 2;
        }
        prev_c = S.at(i);
    }
    int X = face_count / 2;
    int Y = 0;
    if(S.at(0) == 'L'){
        Y++;
    }
    if('R' == S.at(N-1)){
        Y++;
    }
    if(K <= X){
        X -= K;
        cout << N - (X * 2 + Y) ;
    } else{
        cout << N - 1;
    }
}


Measured memory_bytes: 512
N = int(input())
As = list(map(int,input().split()))
counts = []
now = As[0]
count = 1
for a in range(1,len(As)):
    if As[a]==now:
        count+=1
        if a == len(As)-1:
            counts.append(count)
    else:
        counts.append(count)
        count =1
        now = As[a]
print(sum([i//2 for i in counts]))

Measured memory_bytes: 3064
/*
  AOJ 2058 
  Title:Moduic Squares
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>
#define N 5

int wild[10],used[11],wild_cnt;


int compare(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int next_perm(int a[],int n)
{
  int i,j,p,min_,min_p,wk;

  if(a[n-2]<a[n-1])
    {
	wk=a[n-1];
	a[n-1]=a[n-2];
	a[n-2]=wk;
	return(-1);
    }


  for(i=n-1;i>=1;i--)
    if(a[i]>a[i-1])
      {
	p=a[i-1];
	min_=INT_MAX;
	for(j=i;j<n;j++)
	  if(a[j] > p && min_ > a[j])
	    {
	      min_=a[j];
	      min_p=j;
	    }
	wk=a[min_p];
	a[min_p]=a[i-1];
	a[i-1]=wk;
	qsort(&a[i],n-i,sizeof(int),compare);
        return(-1);
      }
 
  return(0);
}

dump(int x[],int n)
{
  int i;

  for(i=0;i<n;i++)
    printf("%d|",x[i]);
  printf("\n");
}

int check_modulo_square(int a[9])
{
  int s;

  s=(a[0]+a[1]+a[2]) % a[9];

  if(s!=(a[3]+a[4]+a[5])%a[9])
    return(0);
  if(s!=(a[6]+a[7]+a[8])%a[9])
    return(0);
  if(s!=(a[0]+a[3]+a[6])%a[9])
    return(0);
  if(s!=(a[1]+a[4]+a[7])%a[9])
    return(0);
  if(s!=(a[2]+a[5]+a[8])%a[9])
    return(0);
  if(s!=(a[0]+a[4]+a[8])%a[9])
    return(0);
  if(s!=(a[2]+a[4]+a[6])%a[9])
    return(0);
  return(-1);
}

main()
{
  int i,j,a[10],square[10],n,count;

  while(1)
    {
      memset(wild,0,sizeof(wild));
      memset(used,0,sizeof(used));
      memset(a   ,0,sizeof(a));


      wild_cnt=0;
      for(i=0;i<10;i++)
	{
	  scanf("%d",&n);
	  if(n==-1)
	    goto END;
	  if(n==0)
	    {
	      wild[wild_cnt]=i;
	      wild_cnt++;
	    }
	  else
	    used[n]=1;
	  square[i]=n;
	}
      for(i=1,j=0;i<=10;i++)
	if(!used[i])
	  a[j++]=i;
      count=0;
      do
	{
	  for(i=0;i<wild_cnt;i++)
	    square[wild[i]]=a[i];
	  //dump(square,10);
	  if(check_modulo_square(square))
	    count++;
	}
      while(next_perm(a,wild_cnt));
      printf("%d\n",count);
    }
 END:
    return(0);
}

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

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define LL           long long
#define cnd tree[idx]
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define MAX 400005
#define Val first
#define lazy second
#define F first
#define S second

typedef pair<LL,LL> pii;

const LL INF = (LL)10000000000000000;
pii tree[4*MAX];

void update_node(int idx, int b, int e,LL v)
{
    cnd.Val += v;
    cnd.lazy += v;
}

void lazy_update(int idx, int b, int e)
{
    int m = (b+e)>>1;

    update_node(lnd, b, m, cnd.lazy);
    update_node(rnd, m + 1, e, cnd.lazy);

    cnd.lazy = 0;
}

LL query(int idx, int b, int e, int st, int en)
{
    if(st > e || en < b ) return INF;
    if(st <= b && en >= e) return tree[idx].Val;

    lazy_update(idx, b, e);

    int m = (b+e)>>1;

    LL lf = query(lnd, b, m, st, en);
    LL rg = query(rnd, m + 1, e, st, en);

    //cnd.Val = min(tree[lnd].Val, tree[rnd].Val);
    return min(lf, rg);
}

void update(int idx, int b, int e, int st, int en,LL v)
{
    if(st > e || en < b ) return;
    if(st <= b && en >= e)
    {
        update_node(idx, b, e, v);
        return;
    }

    lazy_update(idx, b, e);

    int m = (b+e)>>1;
    update(lnd, b, m, st, en, v); update(rnd, m + 1, e, st, en, v);
    cnd.Val = min(tree[lnd].Val, tree[rnd].Val);
}

LL dp[MAX], prin, lolo;
vector<pii> mat[MAX];

int main()
{
    ios::sync_with_stdio(false);
    //inf;
    int n, m, l, r, c;

    cin >> n >> m;
    FOR(i,0,m-1)
    {
        cin >> l >> r >> c; prin += c;
        mat[r].push_back( {l, c} );
    }

    int base = 1;
    while(base <= n) {base *= 2;}

    FOR(i,1,n + 1)
    {
        dp[i] = query(1, 0, base, 0, i - 1);

        for(auto x : mat[i])
             update(1, 0, base, 0, x.F - 1, x.S);

        update(1, 0, base, i, i, dp[i]);
    }

    cout << prin - dp[n + 1] << endl;

    return 0;
}


Measured memory_bytes: 29056
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle;
    angle = fmod((h * 60 + m) * 5.5, 360);
    double c_sq =
        a * a + b * b - 2 * a * b * cos(angle * 3.1415926535898 / 180);

    printf("%.11f", sqrt(c_sq));

    return 0;
}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
#define MAXN 100005

using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	int n;
	double a[110],s=0;
	cin>>n;
	for ( int i=1;i<=n;i++ ){
		cin>>a[i];
		s+=1/a[i];
	}
	s= 1/s;
	printf ("%.5lf",s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
  long long int dp[n+1][w+1];
  
  
  vector<int>wt(n);
  vector<int>v(n);
  for(int i=0;i<n;i++)
    cin>>wt[i]>>v[i];
   for(int i=0;i<=n;i++)
     for(int j=0;j<=w;j++){
       if(i==0||j==0)
         dp[i][j]=0;
       else if(j>=wt[i-1])
         dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+v[i-1]);
       else
         dp[i][j]=dp[i-1][j];
     }
  cout<<dp[n][w];
  return 0;
}
       
 
 
  
  

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

int main()
{
	uint64_t N;
	cin >> N;
	if(N % 2 != 0){
		cout << 0;
	} else {
		uint64_t res;
		N = N / 2;
		while(N != 0){
			N /= 5;
			res += N;
		}
		cout << res;
	}
	return 0;
}


Measured memory_bytes: 256
// AOJ 0364: Dungeon
// 2017.12.20

#include <stdio.h>

int max[100001];
char buf[30], *p;

int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int w, h, n, x, y, ans;

	fgets(p=buf, 30, stdin);
	w = in(), h = in(), n = in();
	while (n-- > 0) {
		fgets(p=buf, 20, stdin);
		x = in(), y = in();
		if (y > max[x]) max[x] = y;
	}

	ans = 0x7fffff;
	x = w, y = 0; while (x--) {
		if (x+y < ans) ans = x+y;
		if (max[x] > y) y = max[x];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2172
fun main(args: Array<String>) {
    readLine()!!
    val a = readLine()!!.split(" ").map(String::toInt)
    var minCost = Int.MAX_VALUE
    for (i in -100..100) {
        val cost = a.sumBy {
            val temp = it - i
            temp * temp
        }
        if (cost < minCost) {
            minCost = cost
        }
    }
    println(minCost)
}


Measured memory_bytes: 37996
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    vl h(n);
    cin>>h;
    ll c=0;
    rep(i,n){
        if(k<=h[i]) c++;
    }
    puta(c);
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int n, tmp, maximum = -BIG_NUM, minimum = BIG_NUM;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			n = Integer.parseInt(br.readLine());
			for (int i=0; i<n; i++) {
				tmp = Integer.parseInt(br.readLine());
				maximum = Math.max(maximum, tmp-minimum);
				minimum = Math.min(minimum, tmp);
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println(maximum);

	}

}



Measured memory_bytes: 42136
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=1e6+5;
const int P=998244353;
const int Gi=(P+1)>>1;
long long a[N],f[N],sum,inv;
long long fsp(long long x,int y){
	long long ans=1;
	while(y){
		if(y&1)	ans=ans*x%P;
		x=x*x%P,y>>=1;
	}
	return ans;
}
int n;
void fwt(long long *d,int f){
	for(int i=1;i<n;i<<=1)
		for(int j=0;j<n;j+=i<<1)
			for(int k=0;k<i;k++){
				long long x=(d[j+k]+d[i+j+k])%P;
				long long y=(d[j+k]-d[i+j+k]+P)%P;
				if(f)	x=x*Gi%P,y=y*Gi%P;
				d[j+k]=x,d[i+j+k]=y;
			}
}
int main(){
	n=1<<read();
	for(int i=0;i<n;i++)	a[i]=read(),sum+=a[i];
	a[0]=P-sum+a[0],sum=fsp(sum,P-2),f[0]=n-1;
	for(int i=0;i<n;i++)	a[i]=a[i]*sum%P;
	for(int i=1;i<n;i++)	f[i]=P-1;

	fwt(f,0),fwt(a,0),inv=fsp(n,P-2);
	for(int i=0;i<n;i++)	f[i]=f[i]*fsp(a[i],P-2)%P;
	fwt(f,1);
	long long k=P-f[0];
	for(int i=0;i<n;i++)	printf("%lld\n",(f[i]+k)%P);
	return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

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

  map<char, int> m;
  int tmp;
  rep(i, n){
    cin >> tmp;
    if(tmp%4==0) m['g']++;
    else if(tmp%2==0) m['n']++;
    else m['u']++;
  }

  string ans = "Yes";
  if(m['g']<m['u']) ans="No";
  if(m['n']==0 && m['g']+1==m['u']) ans = "Yes";
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int num=0;
        for(int j=1; j*j<=i; j++)
            for(int k=1; k*k<=i; k++)
            {
                int tmp,tmp1;
                tmp=4*i-3*j*j-3*k*k-2*j*k;
                if(tmp<0)
                    continue;
                tmp1=sqrt(tmp);
                if(tmp1*tmp1!=tmp)
                    continue;
                if((tmp1-j-k)%2==0&&(tmp1-j-k)/2>=1)
                    num++;
            }
        printf("%d\n",num);
    }
    return 0;
}


Measured memory_bytes: 3692
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
ll val[200000];
int main() 
{

  fast();
  

    ll n,k,q;
    cin >> n >> k >> q;
    f(i,1,n+1)
    {
      val[i]=0;
    }
    ll x;
    f(i,0,q)
    {
      cin >> x;

      val[x]++;
    }
  
    f(i,1,n+1)
    {
     
      ll c=val[i]+k-q;
      if(c>0)
      {
        cout<<"Yes\n";
      }
      else 
      cout<<"No\n";  
    }
    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
      }

 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,ans=0,ans1=0;
	string s;
	cin>>n>>s;
	for(int i=0; i<n; i++) {
		s[i]=='D'?ans--:ans++;
		ans1=max(ans,ans1);
	}
	cout<<ans1<<endl;
}

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

void toS(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[4];
  d[1] = dt[0];
  d[2] = dt[2];
  d[3] = dt[3];
  d[4] = dt[5];
  d[5] = dt[1];
}

void toN(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[1];
  d[1] = dt[5];
  d[2] = dt[2];
  d[3] = dt[3];
  d[4] = dt[0];
  d[5] = dt[4];
}

void toW(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[2];
  d[1] = dt[1];
  d[2] = dt[5];
  d[3] = dt[0];
  d[4] = dt[4];
  d[5] = dt[3];
}

void toE(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[3];
  d[1] = dt[1];
  d[2] = dt[0];
  d[3] = dt[5];
  d[4] = dt[4];
  d[5] = dt[2];
}

void turnR(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[0];
  d[1] = dt[3];
  d[2] = dt[1];
  d[3] = dt[4];
  d[4] = dt[2];
  d[5] = dt[5];
}

int main(void) {
  int d[6]={0};
  rep(i, 6) cin >> d[i];

  int q;
  cin >> q;

  int top, front;
  rep(i, q) {
    cin >> top >> front;

    if(d[2] == top) toW(d);
    else if(d[3] == top) toE(d);
    rep(j, 6) {
      if(d[0] != top) toS(d);
    }

    rep(j, 6) {
      if(d[1] != front) turnR(d);
    }

    cout << d[2] << endl;
  }
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
    lli n,p;
    string s;
    cin >> n >> p >> s;
    vector<int> ss;
    for(char c: s){
        ss.push_back(c-'0');
    }
    lli ans = 0;
    if(p==2 or p==5){
        vector<vector<lli>> dp(n+1, vector<lli>(p, 0));
        lli nzcnt = 0;
        for(int i=0; i<n; i++){
            nzcnt++;
            if(ss[i]%p == 0) ans+=nzcnt;
        }
    }else{
        ss.push_back(0);
        reverse(ss.begin(), ss.end());
        vector<lli> acc(n+1, 0);
        lli pow10 = 1;
        for(int i=0; i<n; i++){
            acc[i+1] = (acc[i] + pow10*ss[i+1]%p) %p;
            pow10 = 10*pow10 %p;
        }
        map<lli, lli> subs;
        for(int i=0; i<n+1; i++){
            ans += subs[acc[i]];
            subs[acc[i]]++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int N,K;
	cin >> N >> K;
	int A[N];
	for(int i=0;i<N;i++)
		cin >> A[i];
	int ans=(int) ceil((double)(N-1)/(K-1));
	cout << ans << endl;


}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;
set<string> S;
 
void Work()
{
    int lens = s.size();
    int lent = t.size();
    for(int i = 0; i < lens; i++)
    {
        if(s[i] == '?' || s[i] == t[0])//如果字符相等
        {
            string tmp = s;              //构造判断子串之前的字符
            for(int j = 0; j < i; j++)
                if(tmp[j] == '?')
                    tmp[j] ='a';    
            bool can = false;
            for(int j = 0; j < lent; j++)    //判断是否为子串
            {
 
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j])  //字符匹配
                    break;
                tmp[i+j] = t[j];
                if(j == lent - 1) can = true;
            }
            if(can)
            {
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';//处理匹配后的字符
                S.insert(tmp);  //压入容器
            }
        }
    }
    if(S.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << *S.begin() << endl;
}
int main()
{
    cin >> s >> t;
    Work();
    return 0;
}



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

struct UnionFind {
  vector<int> par; // parentが誰か
  
  UnionFind(int n) : par(n, -1) {} // parentの初期化
  
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  
  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  
  UnionFind uf(N);

  vector<set<int>> ForB(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b; 
    a--; b--;
    ForB[a].insert(b);
    ForB[b].insert(a);
    uf.unite(a, b);
  }
  for (int i = 0; i < K; i++) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    if (!uf.issame(c, d)) continue;
    ForB[c].insert(d);
    ForB[d].insert(c);
  }
  
  
  for (int i = 0; i < N; i++) {
    int ans = uf.size(i) - 1;
    ans -= ForB[i].size();
    cout << ans << " ";
  }
  cout << endl;
  
}

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

#define ll long long

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll g[201][201], k, ans = 0;
	cin >> k;
	for (int i=1; i<=200; i++) {
		for (int j=1; j<=200; j++) {
			g[i][j] = __gcd(i, j);
		}
	}
	for (int i=1; i<=k; i++) {
		for (int j=1; j<=k; j++) {
			for (int z=1; z<=k; z++) {
				ans += g[z][g[i][j]];
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;

ll A[200010] = {};
//int dA[200010] = {};
ll B[200010] = {};
//int tA[200010] = {};



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

  ll preans = 0;

  for(int i=1;i<=N;i++){
    int a; cin>>a;
    A[a]++;
    B[i] = a;
  }

  for(int i=1;i<=N;i++){
    preans += A[i] * (A[i] - 1) / 2;
  }

  for(int k=1;k<=N;k++){
    //ll de = 0;
    ll now = B[k];
    ll kosuu = A[now] - 1;
    ll other = preans - A[now]*(A[now]-1)/2;

    if(kosuu >= 2)     other += kosuu * (kosuu -1 ) /2;




    cout<<other<<endl;


  }




  return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int d = a / b, r = a % b;
    double f = (double)a / b;
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
 //   system("pause");
    return 0;
}


Measured memory_bytes: 3236
import java.util.Scanner;

public class Main {

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

        final String S = sc.next();

        int max = 0;

        for (int i = 0; i < S.length(); i++) {
            int cnt = 0;
            for (int j = i; j < S.length(); j++) {
                final char cj = S.charAt(j);
                if (!isACGT(cj)) {
                    break;
                }
                cnt++;
            }
            max = Math.max(max, cnt);
        }

        System.out.println(max);
    }

    private static boolean isACGT(final char c) {
        return c == 'A' || c == 'C' || c == 'G' || c == 'T';
    }
}


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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    ll k,s;
    cin >> k >> s;
    ll ans=0;
    for(ll x=0;x<=k;x++)
    {

        for(ll y=0;y<=k;y++)
        {

            ll z=s-(x+y);
            if(z>=0 && z <=k) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int X,N;
    string S;
    cin >> X >> N;
    map<int, int>nums;
    rep(i, -101, 102){nums[i]++;}
//    cin >> N >> K;
//    vector<int> A(N);
    rep(i, 0, N){
        int tmp;
        cin >> tmp;
        nums[tmp]--;
    }
    int v = 102;
    int ans = 102;
    for (auto& s : nums){
        if (!s.second) continue;
       
        int tmpv = abs(s.first-X);
        if(v>tmpv){
            v = tmpv;
            ans = s.first;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,k;
  int l[50];
  int max;

  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> l[i];

  sort(l,l+n,greater<int>());
  for(int i=0;i<k;i++){
    max +=l[i];
  }
  cout << max << endl;
}


Measured memory_bytes: 256