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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;
const double pi = M_PI;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double min = h*60+m;
    double t_m = pi*m/30;
    double t_h = pi*min/360;
    double t = abs(t_m - t_h);

    cout << fixed << setprecision(15) << sqrt(a*a + b*b - 2*a*b*cos(t)) << endl;

}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    bool flag = true;
    int T = 0,X = 0,Y = 0;
    for(int i = 0;i < n;i++)
    {
        int t,x,y;
        cin >> t >> x >> y;
        if((t - T) < (x - X) + (y - Y))
        {
            flag = false;
        }
        else if(((t - T) - (x - X) - (y = y)) % 2 == 1)
        {
            flag = false;
        }
    }
    if(flag)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

void trace(int A[],int N){
    int i;
    for(i = 0;i < N;i++){
        if(i > 0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int j,i,v;
    for(i = 1;i<N;i++){
        v = A[i];
        j = i-1;
        while(j >=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
    }
}
int main(void){
    int N,i,j;
    int A[100];
    
    scanf("%d",&N);
    for(i = 0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}



Measured memory_bytes: 3208
N = int(input())
A = list(map(int, input().split()))

ans = 0


def func(A, flag):
    l = [0]*N
    ans = 0
    acc = 0
    for i in range(N):
        l[i] = A[i]
    for i in range(0, N):
        acc = acc+l[i]
        if i % 2 == flag:
            if acc >= 0:
                l[i] = l[i] - (1 + acc)
                ans += 1+acc
                acc = -1
        else:
            if acc <= 0:
                l[i] = l[i]+(1-acc)
                ans += 1-acc
                acc = 1
    return ans


print(min(func(A, 0), func(A, 1)))


Measured memory_bytes: 14468
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

int f[4000][4000];
const int mod = 998244353;

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    f[a][b] = 1;
    for (int i = a; i <= c; i++)
        for (int j = b; j <= d; j++) {
            if (i == a && j == b) continue;
            //f[i][j] = f[i][j - 1] * i + f[i - 1][j] * j - f[i - 1][j - 1] * ((i - 1) * (j - 1));
            f[i][j] = (((ll)f[i][j - 1] * i + (ll)f[i - 1][j] * j - (ll)f[i - 1][j - 1] * ((ll)(i - 1) * (j - 1))) % mod + mod) % mod;
        }
    cout << f[c][d] << endl;
    return 0;
}


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

int main(void){
    ll h, w, k;
    cin >> h >> w >> k;
    string s[h];
    for(ll i = 0; i < h; i++)
        cin >> s[i];
    vector<vector<ll>> d(h, vector<ll>(w, -1));
    queue<p> que;
    vector<p> c;
    ll rest = h*w;
    ll count = 1;
    vector<bool> ok(h, false);
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(s[i][j]=='#'){
                d[i][j] = count;
                c.push_back(p(i,j));
                count++;
                ok[i] = true;
            }
        }
    }
    for(ll i = 0; i < c.size(); i++){
        que.push(c[i]);
        while(!que.empty()){
            p check = que.front();
            que.pop();
            ll a = check.first, b = check.second;
            for(ll i = 0; i < 2; i++){
                ll sb = b + dx[i];
                if(d[a][sb]!=-1) continue;
                d[a][sb] = d[a][b];
                que.push(p(a, sb));
            }
        }
    }
    vector<p> e;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(d[i][j]!=-1) e.push_back(p(i, j));
        }
    }
    for(ll i = 0; i < e.size(); i++){
        //cout << i << endl;
        //cout << e[i].first << " " << e[i].second << endl;
        que.push(e[i]);
        while(!que.empty()){
            p check = que.front();
            que.pop();
            ll a = check.first, b = check.second;
            for(ll i = 0; i < 2; i++){
                ll sa = a + dx[i];
                if(sa < 0 || sa >= h) continue;
                if(d[sa][b]!=-1) continue;
                d[sa][b] = d[a][b];
                que.push(p(sa, b));
            }
        }
    }
    for(ll i =0; i < h; i++){
        for(ll j = 0; j < w; j++)
            cout << d[i][j] << " ";
        cout << endl;
    }
    return 0;
}


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

const int N = 1000010;
const int moder = 1e9 + 7;

int powermod(int a, int exp){
    int ret = 1;
    for ( ; exp > 0; exp >>= 1){
        if (exp & 1){
            ret = 1ll * ret * a % moder;
        }
        a = 1ll * a * a % moder;
    }
    return ret;
}

int fac[N];
int inv[N];
int ans[N];

int comb(int n, int m){
    if (n < m || m < 0) return 0;
    return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int main(){
    fac[0] = 1;
    for (int i = 1; i < N; ++ i){
        fac[i] = 1ll * fac[i - 1] * i % moder;
    }
    inv[N - 1] = powermod(fac[N - 1], moder - 2);
    for (int i = N - 1; i; -- i){
        inv[i - 1] = 1ll * inv[i] * i % moder;
    }
    int n;
    scanf("%d", &n);
    for (int i = 0; i <= n - 1; ++ i){
        ans[i] = 1ll * comb(i - 1, n - i - 1) * fac[i] % moder * fac[n - i - 1] % moder;
    }
    int ret = 0;
    for (int i = 1; i <= n - 1; ++ i){
        ret = (ret + 1ll * (ans[i] - ans[i - 1]) * i) % moder;
        ret += ret < 0 ? moder : 0;
    }
    printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 11904
#include <iostream>
using namespace std;
int gcd(int x, int y){
    if (x < y){
        int t;
        t = x; x = y; y = t;
    }
    
    while (y > 0){ // 余りが０になるまで
        int r;
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(void){
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;

}



Measured memory_bytes: 3112
from heapq import heapify, heappush, heappop
import math

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = [-a for a in A]
    heapify(A)

    while M:
        m = heappop(A)
        heappush(A, math.ceil(m/2))
        M -= 1
    print(-sum(A))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 14536
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b)
    {
        printf("a > b\n");
    }
    else if(a<b)
    {
        printf("a < b\n");

    }
    else
    {
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2112
def kaibunCheck(s):
  flag = True
  n = len(s)
  for i in range((n + 1) // 2):
    if s[i] != s[(i + 1) * (-1)]:
      flag = False

  return flag
        
S = input()
N = len(S)

S1 = S[:(N - 1) // 2]
S2 = S[(N + 1) // 2 :]

if kaibunCheck(S) == True and kaibunCheck(S1) == True and kaibunCheck(S2) == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N =nextInt();
		long A =nextLong();
		long B =nextLong();

		long ans = (A+(N-1)*B)-((N-1)*A+B)+1;

		System.out.println(Math.max(0, ans));

	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21332
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

A,B,C = MI()
if A == B == 5 and C == 7:
    print('YES')
elif A == C == 5 and B == 7:
    print('YES')
elif B == C == 5 and A == 7:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 61620
#include<stdio.h>
#include<string.h>
int main(){
  char c[201],n;
  int len,m,h,a,b,d,e;
  while(1){
    scanf("%s",c);
    if(strcmp(c,"-")==0)break;
    len=strlen(c);
    scanf("%d",&m);
    for(d=0;d<m;d++){
      scanf("%d",&h);
      for(a=0;a<h;a++){
	n=c[0];
	for(b=1;b<=len-1;b++){
	  c[b-1]=c[b];
	}
	c[len-1]=n;
      }
    }
    printf("%s\n",c);
  }
  return 0;
}

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

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

    int a;
    string s;
    cin >> a >> s;
    
    string ans;
    if(a >= 3200)ans = s;
    else ans = "red";
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        new Main().start();
    }

    void start() throws Exception {
        start(new Scanner(System.in));
    }

    void start(Scanner sc) throws Exception{
        int r = sc.nextInt();
        int g = sc.nextInt();
        int ans = 2 * g - r;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
#include<stdio.h>
int gcd(int a, int b);

int main(void) {
	int N,ans;
	scanf("%d", &N);
	int A[N];
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}
	ans = A[0];
	for (int i = 1; i < N ; i++) {
		ans = gcd(A[i], ans);
	}
	printf("%d\n", ans);

	return 0;
}




int gcd(int a, int b)
{
	int r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}

	return b;
}

Measured memory_bytes: 512
def bs(a,n):
    ans=0
    flag=True
    while flag:
        flag=False
        for i in range(n-1,0,-1):
            if int(a[i][1])<int(a[i-1][1]):
                a[i],a[i-1]=a[i-1],a[i]
                flag=True
                ans+=1
    return a

def ss(a,n):
    ans=0
    for i in range(n):
        m=i
        for j in range(i,n):
            if int(a[j][1])<int(a[m][1]):
                m=j
        if m!=i:
            a[i],a[m]=a[m],a[i]
            ans+=1
    return a
N=int(input())
A=list(input().split())
B=A[:]
ans1,ans2=bs(A,N),ss(B,N)
print(*ans1)
print("Stable")
print(*ans2)
print("Stable" if ans1==ans2 else "Not stable")


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int N, A, B;
long long int v[505];
long long comb[100][100];
void init()
{
    comb[0][0] = 1;
    for(int i=1; i<70; ++i)
    {
        comb[i][0] = comb[i][i] = 1;
        for(int j=1; j<i; ++j)
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
}
long long solve(int x)
{
    --x;
    int r = 0;
    int n = 0;
    for(int i=0; i<=x; ++i) if(v[x]==v[i]) ++r;
    for(int i=0; i<N; ++i)  if(v[x]==v[i]) ++n;
    return comb[n][r];
    
}
int main()
{
    init();
    scanf("%d%d%d", &N, &A, &B);
    for(int i=0; i<N; ++i) scanf("%lld", v+i);
    sort(v, v+N); reverse(v, v+N);
    double y = 0;
    for(int i=0; i<A; ++i) y += v[i];
    printf("%.12f\n", y/A);
    long long ans = solve(A);
    for(int i=A+1; i<=B; ++i)
        if(v[i-1] == v[0]) ans += solve(i);
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

ll A[300010];
ll R[100];
ll m = 0;
void check(ll X) {
	ll i = 0;
	while (X > 0) {
		R[i] += X % 2;
		X /= 2;
		i++;
	}
	m = max(m, i);
}
int main()
{
	int N; cin >> N;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		check(A[i]);
	}
	for (ll i = 0; i <= m; i++) {
		ll up = 1;
		for (ll j = 0; j < i; j++) {
			up *= 2;
			up %= mod;
		}
		ll r = N - R[i];
		R[i] %= mod;
		r %= mod;
		ans = (ans + (r * R[i]) % mod * up % mod) % mod;
	}
	cout << ans % mod << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

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

    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j  = i + 1; j < n - 1; j++) {
            int idx = lower_bound(v.begin(), v.end(), v[i] + v[j]) - v.begin();
            ans += max(0, idx - (j + 1));
        }
    }

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



Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>


using namespace std;
 
int N,M;

vector<int> a,b,V;
vector<vector<int>> memo;

int f[13];


int dp(int n, int m)
{
  int temp,A,B,c;
  
  if(memo[n][m]!=-2)
  {
    return memo[n][m];
  }
  
  temp=-1;
  
  if(dp(n-1,m)>=0)
  {
    temp=dp(n-1,m);
  }
  
  if((m|V[n])==m)
  {
    for(B=0;B<f[N];B++)
  {
    if((B|V[n])==m && dp(n-1,B)>=0)
    {
      if(temp==-1)
      {
        temp=dp(n-1,B)+a[n];
      }
      else
      {
        temp=min(temp,dp(n-1,B)+a[n]);
      }
    }
  }
  }
    memo[n][m]=temp;
    return temp;
  
}

int main()
{

  cin >> N >> M;
  a.assign(M+1,0);
  b.assign(M+1,0);
  V.assign(M+1,0);
  
  int i,j,k,num;
  f[0]=1;
  for(i=1;i<N+1;i++)
  {
    f[i]=f[i-1]*2;
  }
  
  for(i=1;i<M+1;i++)
  {
    cin >> a[i] >> b[i];

    num=0;
    for(j=0;j<b[i];j++)
    {
      cin >> k;
      k--;
      num+=f[k];
    }
    V[i]=num;
  }

  memo.assign(M+1,vector<int>(f[N],-2));
  for(i=0;i<f[N];i++)
  {
    memo[0][i]=-1;
  }
  
  for(i=0;i<M+1;i++)
  {
    memo[i][0]=0;
  }
  
  num=dp(M,f[N]-1);


    cout << num;  
  

}

Measured memory_bytes: 16384
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

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

    int A[N];
    int R[9];
    int ind;

    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<9;i++){
        R[i] = 0;
    }
    for(int i=0;i<N;i++){
        if(1<=A[i]<=4800){
            ind = A[i] / 400;
            ind = min(8, ind);
            R[ind] = R[ind] + 1;
        }
    }
    int count=0;
    for(int i=0;i<8;i++){
        if(R[i] > 0){
            count++;
        }
    }
    int ans_min = max(1, count);
    int ans_max = count+R[8];

    cout << ans_min << " " << ans_max << endl;
    return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
vector<ll> g[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, u, v, ans = 0;
    cin >> n >> m;
    vector<ll> h(n);
    for (ll &e : h)
        cin >> e;
    while (m--)
        cin >> u >> v, u--, v--, g[u].push_back(v), g[v].push_back(u);
    for (ll i = 0; i < n; i++)
    {
        for (ll e : g[i])
            if (h[e] >= h[i])
                goto lb;
        ans++;
    lb:;
    }
    cout << ans;
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    ll n,x,cnt=0;
    cin >> n >> x;
    vl a(n);
    lrp(i,n){
        cin >> a[i];
    }
    sort(a);
    lrp(i,n){
        cnt += a[i];
        if(cnt>x){
            cout << i << endl;
            return 0;
        }
    }
    if(cnt==x){
        cout << n << endl;
    }elif(cnt<x){
        cout << n-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val p = (1..n).map {
      sc.nextInt()
    }

    println(abc132b(n, p))
}

private fun abc132b(n: Int, p: List<Int>): Int {
  var count = 0
  for (i in 1 until n - 1) {
    val f = p[i - 1]
    val s = p[i]
    val t = p[i + 1]
    if (f < s && s < t) {
      count++
    } else if (f > s && s > t) {
      count++
    }
  }

  return count
}

Measured memory_bytes: 31396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  string s,t;cin >> s >> t;
  if(s.size()==t.size()){
     rep(i,s.size()){
        cout << s[i] << t[i];
     }
  }
  else{
     cout << s[0];
     rep(i,s.size()-1){
        cout << t[i] << s[i+1];
     }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  long N, K;
  long half;
  long num;
  long test;
  long ans = 0;

  scanf("%ld%ld", &N, &K);

  if(K % 2 == 0){
    half = K/2;
    num = N/K;
    test = N/half;
    test = test - num;

    if(num > 2) ans = num*(num-1)*(num-2) + num*(num-1)*3 + N/K;
    if(num == 2) ans = num*(num-1)*3 + N/K;
    if(num == 1) ans = 1;

    if(test > 2) ans += test*(test-1)*(test-2) + test*(test-1)*3 + test;
    if(test == 2) ans += test*(test-1)*3 + test;
    if(test == 1) ans += 1;


  }else{
    num = N/K;
    if(num > 2) ans = num*(num-1)*(num-2) + num*(num-1)*3 + num;
    if(num == 2) ans = num*(num-1)*3 + num;
    if(num == 1) ans = 1;
  }

  printf("%ld\n", ans);
  return 0;
}

Measured memory_bytes: 128
import numpy as np
n = int(input())
g = np.array(list(map(float,input().split())))
dp = np.zeros(n+1)
dp[0] = 1.0

for i in range(n):
  dp = np.roll(dp*g[i],1) + dp*(1-g[i])
print(sum(dp[n//2+1:]))

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

import static java.lang.Integer.parseInt;

/**
 * Jinkoki
 * PCK2013 ??¬???3
 */
public class Main {

	// 18 units
	static final String[] UNIT = {
			"",
			"Man",
			"Oku",
			"Cho",
			"Kei",
			"Gai",
			"Jo",
			"Jou",
			"Ko",
			"Kan",
			"Sei",
			"Sai",
			"Gok",
			"Ggs",
			"Asg",
			"Nyt",
			"Fks",
			"Mts",
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int m, n;
			m = parseInt(line.substring(0, line.indexOf(' ')));
			n = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((m | n) == 0) break;

			int[] num = new int[18];

			//m^1
			num[0] = m;

			//m^2 -> m^n
			for (int i = 0; i < n - 1; i++) {
				for (int j = 0; j < num.length; j++) num[j] *= m;
				for (int j = 0; j < num.length; j++) {
					if (num[j] >= 10000) {
						num[j + 1] += num[j] / 10000;
						num[j] %= 10000;
					}
				}
			}

			StringBuilder sb = new StringBuilder();
			for (int i = num.length - 1; i >= 0; i--) {
				if (num[i] > 0) sb.append(num[i]).append(UNIT[i]);
			}
			System.out.println(sb.toString());

		}//end while
	}//end main
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s = in();
    reverse(ALL(s));
    vector<string> v{"dream", "dreamer", "erase", "eraser"};
    for (auto &e : v)
    {
        reverse(ALL(e));
    }
    string t = "";
    rep(i, s.size())
    {
        t.pb(s[i]);
        for (const auto &e : v)
        {
            if (t == e)
            {
                t = "";
                break;
            }
        }
    }
    if (t.empty())
        YES;
    else
        NO;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    double a, b, h, m; cin >> a >> b >> h >> m;
    //if(h == 0) h = 12;
    //if(m == 0) m = 60;
    double kaku = abs((h*30+0.5*m) - m*6);
    //if(kaku > 180) kaku -= 180;
    double ra = kaku * (acos(-1)/180);
    double ans = a*a + b*b - (2*a*b*cos(ra));
    //if(kaku == 0) ans = abs(a-b);
    printf("%.20f\n", sqrt(ans));
    //cout << kaku << " : " << ra << endl;

    return 0;
}


Measured memory_bytes: 4148
#-*-coding:utf-8*-
#0002.rb

#?????\????????????????????????????????????
roop_limit = 200
count = 0

while input = gets do # && count < roop_limit
  #??????????????§???????????????????????£??????
  num_str = input.split(" ")
  #????????????????????????map????????¨????????¨????????????????????????????????????
  num_int = num_str.map(&:to_i)
  sum = num_int[0] + num_int[1]
  puts sum.to_s.length

  count += 1 #???????????°??????
  #200????¶????????????£??????????????????
  if count > roop_limit then
    break
    puts "200???????¶????????????????"
  end
  
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define repl(i, z, n) for(ll i = z; i < n; i++)
#define all(v) v.begin(), v.end()
#define STR(var) #var
typedef long long ll;

using namespace std;

int main(){
  vector<int> a=vector<int>(3);
  vector<int> res;
  int n;
  cin >> n;
  vector<string> s=vector<string>(n);
  repl(i,0,3) cin >> a[i];
  repl(i,0,n) cin >> s[i];
  
  if(accumulate(all(a),0)==0){
    cout << "No\n";
    return 0;
  }
  repl(i,0,n){
    int x = s[i][0]-'A';
    int y = s[i][1]-'A';
    if(i<n-1 && a[x]==1 && a[y]==1){
      bool found_x=(x==(s[i+1][0]-'A') || x==(s[i+1][1]-'A'));
      //bool found_y=(y==(s[i+1][0]-'A') || y==(s[i+1][1]-'A'));
      if(found_x){
        a[x]++;
        a[y]--;
        res.push_back(x); 
      }else{
        a[x]--;
        a[y]++;
        res.push_back(y); 
      }
    }else{
      if(a[x]<=0 && a[y] <=0){
        cout << "No\n";
        return 0;
      }
      if(a[x]<a[y]){
        a[x]++;
        a[y]--;
        res.push_back(x);
      }else{
        a[y]++;
        a[x]--;
        res.push_back(y);

      }
    } 
    //cout << a[0] << a[1] << a[2] << endl;
  }
  cout << "Yes\n";
  for(int i:res){
    cout << char(i+'A') << endl;
  }
  return 0; 
}



Measured memory_bytes: 7032
import math

def loop(string,length):
	first_str=string[0:length//2]
	if (length%2)==0:
		second_str=string[length//2:length]
	if (length%2)==1:
		second_str=string[length//2+1:length]
	second_str=second_str[::-1]
	if(first_str==second_str):
		return 1
	else:
		return 0

S=input()
N=len(S)
Astr=S[0:((N-1)//2)]
Bstr=S[((N+3)//2-1):N]

if(loop(S,N)==1) and loop(Astr,len(Astr))==1 and (loop(Bstr,len(Bstr))==1):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val s = readLine()!!

    //val s = "RSR"

    var answer = 0

    val sArray = s.toCharArray()

    sArray.forEachIndexed() { index, tenki ->
        if (tenki == 'R') {
            if (index > 0 && sArray[index - 1] != 'R') answer = 0
            answer++
        }
    }

    println("$answer")
}


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

using namespace std;

typedef long long ll;

int n,ans,s[105];

void dfs(int pos,int res){
	if(pos==n){
		if(res%10==0) ans = max(0,ans);
		else ans = max(ans,res);
		return;
	}
	dfs(pos+1,res);
	dfs(pos+1,res+s[pos]);
}

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> s[i];
		ans += s[i];	
	}
	if(ans%10==0){
		sort(s,s+n);
		int f = 0;
		for(int i=0;i<n;i++){
			if(s[i]%10!=0){
				f = 1;
				ans -= s[i];
				break;
			}
		}
		if(!f) ans = 0;
	}
	cout << ans << "\n";
    
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}

vector<int> dijkstra(const Graph &g, int s, Array &dist) {
	int n = g.size();
	assert(s < n);
	enum { WHITE, GRAY, BLACK };
	vector<int> color(n, WHITE); color[s] = GRAY;
	vector<int> prev(n, -1);
	dist.assign(n, INF); dist[s] = 0;
	using State = tuple<Weight, int, int>;
	priority_queue<State, vector<State>, greater<State>> pq; pq.emplace(0, s, -1);
	while (pq.size()) {
		Weight d; int v, u; tie(d, v, u) = pq.top(); pq.pop();
		if (dist[v] < d)continue;
		color[v] = BLACK; prev[v] = u;
		for (auto &e : g[v]) {
			if (color[e.d] == BLACK)continue;
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				pq.emplace(dist[e.d], e.d, v);
				color[e.d] = GRAY;
			}
		}
	}
	return prev;
}

vector<int> getPath(int s, int g, vector<int> prev) {
	vector<int> path;
	path.emplace_back(g);
	for (int i = g; i != s; ) {
		if (i == -1)
			return vector<int>();
		path.emplace_back(i = prev[i]);
	}
	reverse(path.begin(), path.end());
	return path;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	Graph g(N);
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b; a--, b--;
		addEdge(g, a, b);
	}
	Array dist;
	vector<int> prev = dijkstra(g, 0, dist);
	vector<int> path = getPath(0, N - 1, prev);
	int m = path.size();
	int b = path[(m - 1) / 2], w = path[(m - 1) / 2 + 1];
	dump(b, w);
	int B = 0;
	auto bfs = [&](int root) {
		vector<bool> vis(N);
		vis[w] = true;
		queue<int> q; q.emplace(root);
		while (q.size()) {
			int u = q.front(); q.pop();
			if (vis[u])continue;
			vis[u] = true;
			B++;
			for (auto &e : g[u]) {
				if (vis[e.d])continue;
				q.emplace(e.d);
			}
		}
	};
	bfs(b);
	if (B > N - B) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}
	return 0;
}

Measured memory_bytes: 9336
#include <stdio.h>
int chk[10];
int nums[] = {1, 10, 100, 1000, 10000};
int possibleNum[10];
int N;
int K;
int jari;
int idx;
int min = 0x7fff0000;

void DFS(int L, int num)
{
	int i;
	
	if (L > jari)
	{
	    if (num >= N && num < min) min = num;
	    if (num % nums[jari] >= N && num % nums[jari] < min) min = num % nums[jari];
		     
	    return;
	}

	for (i = 0; i < idx; i++)
	{
		DFS(L + 1, num + possibleNum[i] * nums[L]);
	}

}

void input(void)
{
	int i;
	int num;
	scanf("%d %d", &N, &K);

	for (i = 0; i < K; i++)
	{
		scanf("%d", &num);
		chk[num] = 1;
	}

	for (i = 0; i < 10; i++)
	{
		if (chk[i]) continue;
		possibleNum[idx++] = i;
	}
	
	num = N;
	while(num)
	{
	    jari++;
	    num /= 10;
	}


}

int main(void)
{
	input();
	DFS(0, 0);
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
a, b, c, d = map(int, input().split())
if a == 0 and b == 0 and c == 0 and d == 0:
    print(0)
else:
    if a == 0:
        a += 1
    if b == 0:
        b -= 1
    if c == 0:
        c += 1
    if d == 0:
        d -= 1
    print(max(a * c, a * d, b * c, b * d))


Measured memory_bytes: 61804
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    d = 0
    for a, b in zip(P, sorted(P)):
        if a != b:
            d += 1
    if d > 2:
        return 'NO'
    return 'YES'


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    bool AC[100000] = {};
    int Pen[100000] = {};
    int p;
    string res;
    for (int i = 0; i < M; i++)
    {
        cin >> p >> res;
        if (res == "WA")
        {
            if (!AC[p - 1]) Pen[p - 1]++;
        }else if(res == "AC")
        {
            AC[p - 1] = true;
        }
        
    }

    int sumAC = 0;
    int sumPen = 0;
    for (int i = 0; i < N; i++)
    {
        if (AC[i])
        {
            sumAC++;
            sumPen += Pen[i];
        }
        
    }
    
    cout << sumAC << ' ' << sumPen << endl;

    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
int n,m,tot,a[110];
double MIN;
signed main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) tot+=a[i];
	MIN=(tot*1.0)/(4.0*m);
	sort(a+1,a+1+n);
	int cnt=0;
	for (int i=n;i>=1;i--)
	{
		if ((double)a[i]>=MIN) cnt++;
	}
	if (cnt>=m) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> 
#define range(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i)++)
#define headprob(i,j) prob[(i)-1][(j)-1]*p[(i)]
#define tailprob(i,j) prob[(i)-1][(j)]*(1-p[(i)])
using namespace std;

int main() 
{
      int n;
      cin >> n;
      double p[n+1];
      p[0] = 0;
      range(i,1,n+1) cin >> p[i];
	double prob[n+1][n+1];
	prob[1][0] = 1 - p[1];
	prob[1][1] = p[1];
	range(i,2,n+1)
	{
	      prob[i][0] = (1-p[i])*prob[i-1][0];
	      range(j,0,i)
	      {
	            prob[i][j] = headprob(i,j)+tailprob(i,j);
	      }
	      prob[i][i] = prob[i-1][i-1]*p[i];
	}
	double s = 0;
	range(i,1+(n/2),n+1) s += prob[n][i];
	cout << setprecision(11) << s;
	return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n,k;
LL val[111];
LL best = 0;

vector<LL> vals;
void dane() {
	cin>>n>>k;
	F(i,0,n) cin>>val[i];

	F(ile_lewa,0,n+1) {
		F(ile_prawa,0,n+1) {
			LL sum = 0;
			if(ile_lewa + ile_prawa > k || ile_lewa + ile_prawa > n) {
				continue;
			}
			//cout<<"Ile lewa: "<<ile_lewa<<" "<<ile_prawa<<endl;
			vals.clear();
			//dodajemy elementy
			F(i,0,ile_lewa) {
				vals.push_back(val[i]);
				sum+=val[i];
			}
			F(i,0,ile_prawa) {
				vals.push_back(val[n-i-1]);
				sum+=val[n-i-1];
			}
			best = max(best, sum);
			//cout<<"SUM : "<<sum<<endl;
			sort(ALL(vals));
			int kroki = min((int)vals.size(),k - ile_lewa - ile_prawa);
			//poki mozna tu usuwamy najmniejszy
			F(i,0,kroki) {
				sum -= vals[i];
				best = max(best, sum);
			}
		}
	}
	cout<<best<<endl;

}    


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL N; cin >> N;
    LL ans = 0;
    LL acc = 10;

    if(N%2 == 1){
        cout << 0 << endl;
        return 0;
    }
    while(acc < 1e18){
        ans += N / acc;
        acc *= 5;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 25

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int num_rows,num_cols,dis[MAXN][MAXN],moves[4][2] = {{0,1},{1,0},{-1,0},{0,-1}},res;
char board[MAXN][MAXN];

inline void init(int r, int c){
    memset(dis,0x3f,sizeof dis);
    queue<pii> q;
    q.push(mp(r,c));
    dis[r][c] = 0;
    while(q.size()){
        int x = q.front().first, y = q.front().second; q.pop();
        res = max(res,dis[x][y]);
        for(int i=0; i<4; i++){
            int nx = x+moves[i][0], ny = y+moves[i][1];
            if(nx >= 1 && ny >= 1 && nx <= num_rows && ny <= num_cols && board[nx][ny] != '#' && dis[nx][ny] == INT_INF){
                dis[nx][ny] = dis[x][y]+1;
                q.push(mp(nx,ny));
            }
        }
    }
}

int main(){
    scanf("%d %d",&num_rows,&num_cols);
    for(int i=1; i<=num_rows; i++)
        for(int k=1; k<=num_cols; k++)
            scanf(" %c",&board[i][k]);
    for(int i=1; i<=num_rows; i++){
        for(int k=1; k<=num_cols; k++){
            if(board[i][k] == '#') continue;
            init(i,k);
        }
    }
    printf("%d\n",res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    string S; cin >> S;
    bool flag = true;

    rep(i,S.size())
    {
        if (i % 2 == 0 && S[i] == 'L') flag = false;
        if (i % 2 == 1 && S[i] == 'R') flag = false;
    }
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,b,r;
  cin>>n>>b>>r;
  ll ans=(n/(b+r))*b;
  ll rem;
  rem=n%(b+r);
  ans+=min(rem,b);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
s = input()

li = []
for i in range(len(s)):
    #print(li)
    if s[i] == "S":
        li.append(s[i])
    elif s[i] == "T":
        if len(li) >=1 and li[-1] == "S":
            li.pop()
        elif len(li) == 0 or li[0] =="T":
            li.append(s[i])
print(len(li))

Measured memory_bytes: 5092
require 'prime'

MOD = 1000000007

def pow(b, n)
  def pow_iter(a, b, n)
    if n == 0
      a
    elsif n.even?
      pow_iter(a, b * b % MOD, n / 2)
    else
      pow_iter(a * b % MOD, b, n - 1)
    end
  end
  pow_iter(1, b, n)
end

def make_factorial_array(n)
  1.upto(n) do |i|
    $fact[i] = $fact[i - 1] * i % MOD
  end
end

def make_inv_factorial_array(n)
  $inv_fact[n] = pow($fact[n], (MOD - 2)) % MOD
  (n-1).downto(1) do |i|
    $inv_fact[i] = $inv_fact[i + 1] * (i + 1) % MOD
  end
end

def combination(n, r)
  $fact[n] * $inv_fact[r] * $inv_fact[n - r] % MOD
end

n, m = gets.split.map(&:to_i)

$fact = Array.new(1000000, 1)
$inv_fact = Array.new(1000000, 1)

make_factorial_array(1000000)
make_inv_factorial_array(1000000)

ps = Prime.prime_division(m).map { |x| x[1] }
p ps.inject(1) { |a, x| a * combination(x + n - 1, x) % MOD }

Measured memory_bytes: 17660