akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[114514],b[114514];
lint c[114514],cap[114514];
int ch[114514];
bool ng[114514];
vector<pint> gr[114514];
int n;
void dfs(int v,int u){
	ch[v]=1;
	rep(i,gr[v].size()){
		pint p=gr[v][i];
		if(p.se==u) continue;
		dfs(p.fi,p.se);
		ch[v]+=ch[p.fi];
	}
	if(u>=0) cap[u]=min(ch[v],n-ch[v]);
}
int main()
{
	cin>>n;
	rep(i,n-1){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;b[i]--;
		gr[a[i]].pb(mp(b[i],i));
		gr[b[i]].pb(mp(a[i],i));
	}
	dfs(0,-1);
	//rep(i,n-1) cout<<a[i]<<' '<<b[i]<<' '<<c[i]<<' '<<cap[i]<<endl;
	rep(i,n){
		if(gr[i].size()==1) continue;
		lint su=0,ma=0;int maj;
		rep(j,gr[i].size()){
			pint p=gr[i][j];
			su+=cap[p.se];
			if(ma<cap[p.se]) maj=p.se,ma=cap[p.se];
		}
		//cout<<i<<' '<<ma<<' '<<su<<' '<<maj<<endl;
		if(ma*2>su){
			rep(j,gr[i].size()){
				pint p=gr[i][j];
				if(p.se!=maj) ng[p.se]=true;
			}
		}
	}
	lint out=0,ma2=1145141919;
	rep(i,n-1){
		out+=2*cap[i]*c[i];
		if(!ng[i]) ma2=min(ma2,c[i]);
		//if(ng[i]) cout<<a[i]<<' '<<b[i]<<endl;
	}
	cout<<out-ma2<<endl;
}


Measured memory_bytes: 14336
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	double a = sc.nextDouble();
    double b = sc.nextDouble();
	System.out.println(a/b);
  }
}

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

int main() {
	vector<int> v;
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	sort(v.begin(), v.end());
	printf("%d", v[0]);
	printf(" ");
	printf("%d", v[1]);
	printf(" ");
	printf("%d", v[2]);

	cout << endl;
	return 0;
}

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

using namespace std;

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

    uint64_t ans = 0;
    int firstb = 0;
    bool foundb = false;
    for(int i = 0; i < S.length() - 1; ++i)
    {
        if(S[i] == 'B')
        {
            firstb = i;
            foundb = true;
            break;
        }
    }

    if(foundb)
    {
        int w = 0;
        for(int i = firstb + 1; i < S.length(); ++i)
        {
            if(S[i] == 'W')
            {
                ans += i - firstb - w;
                w++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1336
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Min(a, b int) int {
  if a < b { return a }
  return b
}

func main() {
  N := NextInt()
  cnt := 0
  A := make([]int, N)
  for i := range A {
    A[i] = NextInt()
  }
  for i, _ := range A {
    if i < N - 1 && 0 < A[i] % 2 && 0 < A[i + 1]{
      cnt += 1
      A[i]--
      A[i + 1]--
    }
    cnt += A[i] / 2
  }
  Write(cnt)
  Output()
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pie 3.142857143
#define ll long long int
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fv(i,a) for(auto i:a)
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)

void solve()
{
	int n, k;
	cin >> n >> k;
	int h[n];
	fr(i, 0, n)
	cin >> h[i];
	vi d(n, 1e9 + 5);
	d[0] = 0;
	fr(i, 0, n)
	{
		fr(j, i + 1, i + k + 1)
		{
			if (j < n)
			{
				d[j] = min(d[j], d[i] + abs(h[j] - h[i]));
			}
		}
	}
	cout << d[n - 1] << endl;

}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}


	return 0;
}

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


void merge(int[],int,int,int);
void Sort(int[],int,int);


int count = 0;

int main()
{
  int i,n,S[500000];
  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      scanf("%d",&S[i]);
    }
  Sort(S,0,n);
  for(i = 0;i < n;i++)
    {
      if(i >0) printf(" ");
      printf("%d",S[i]);
    }
  printf("\n");
  printf("%d\n",count);
  return 0;
}
void merge(int S[],int left,int mid,int right)
{
  int i,j,k,n1,n2;
  int *L,*R;
  n1 = mid - left;
  n2 = right - mid;
  L = (int *)malloc(sizeof(int)*(n1 + 1));
  R = (int *)malloc(sizeof(int)*(n2 + 1));
  for(i = 0;i <= n1 - 1;i++)
    {
      L[i] = S[left + i];
    }
  for(i = 0;i <= n2 - 1;i++)
    {
      R[i] = S[mid + i];
    }
  L[n1] = R[n2] = 2000000000;
  i = 0;
  j = 0;
  for(k = left;k <= right - 1;k++)
    {
      count++;
      if(L[i] <= R[j])
	{
	  S[k] = L[i];
	  i++;
	} else
	{
	  S[k] = R[j];
	  j++;
	}
    }
  free(L);
  free(R);
}
void Sort(int S[],int left,int right)
{
  int i,mid;
  if(left + 1 < right)
    {
      mid = (left + right) / 2;
      Sort(S,left,mid);
      Sort(S,mid,right);
      merge(S,left,mid,right);
    }
    
}
	  



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

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

    int answer=0;
    rep(i,0,n){
        answer+=i+1;
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

f_side = 0
s_side = 0
t_side = 0

triangle_cnt = 0

if n < 3:
    print(triangle_cnt)
else:
    for first in range(n - 2):
        f_side = l[first]
        for second in range(first+1, n - 1):
            s_side = l[second]
            for third in range(second+1, n - 0):
                t_side = l[third]
                if f_side != s_side and f_side != t_side and s_side != t_side:
                    if f_side+s_side > t_side and s_side+t_side > f_side and f_side+t_side > s_side:
                        triangle_cnt += 1

    print(triangle_cnt)


Measured memory_bytes: 9196
#include<stdio.h>
long long int min(long long int x,long long int y){
  long long int ans;
  if(x<y){
    ans=x;
  }else{
    ans=y;
  }
  return ans;
}
int main(void){
  long long int n,a,b;
  scanf("%lld %lld %lld",&n,&a,&b);
  long long int c=a+b;
  long long int ans=a*(n/c);
  ans+=min(n%c,a);
  printf("%lld\n",ans);
  return 0;
}

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

int main(void){
	int n,i;
	vector<int> x;
	vector<int> y;
	cin >> n;
	for (i = 0; i < n; i++){
		int temp;
		cin >> temp;
		x.push_back(temp);
	}
	y = x;
	sort(y.begin(), y.end());
	for (i = 0; i < n; i++){
		if (x[i] < y[n / 2]){
			cout << y[n / 2] << endl;
		}
		else
			cout << y[n / 2 - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
import java.io.*;
import java.math.*;
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner r = new Scanner(System.in);
		int n;
		int x,y,b,p;
		double salex,saley;
		double saleans,ans;
		n = r.nextInt();
		while(true){
			x = r.nextInt();
			y = r.nextInt();
			b = r.nextInt();
			p = r.nextInt();
			salex = (double)x * 0.8;
			saley = (double)y * 0.8;
			ans = x*b + y *p;
			if(b < 5) b =5;
			if(p < 2) p =2;
			saleans = salex*b + saley*p;
			System.out.println((int)Math.min(ans,saleans));
			n--;
			if(n == 0) break;
		}	
	}
}

Measured memory_bytes: 23284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll ans = 0;
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            while(A[i]>1&&A[i]%2==0){
                A[i]/=2;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
for i in range(4):
    a,b = map(int,input().split())
    if a == 1:
        print(6000*b)
    elif a == 2:
        print(4000*b)
    elif a == 3:
        print(3000*b)
    elif a == 4:
        print(2000*b)
    else:
        pass
    


Measured memory_bytes: 5596
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
dist=float('inf')
ans=0
for i in range(n):
    temp=t-0.006*h[i]
    if dist>abs(a-temp):
        dist=abs(a-temp)
        ans=i+1
print(ans)

Measured memory_bytes: 3064
/*input
abracadabra
*/

#include <bits/stdc++.h>
using namespace std;

#define mx 100005
#define ll long long
#define MOD 1000000007
int cnt[200];
int main()
{
	string st;
	cin >> st;
	for(int i = 0; i<st.length(); i++)
	{
		cnt[st[i]] ++;
	}
	int n = st.length();
	ll ans = 0;
	for(char ch : st)
	{
		cnt[ch]--;
		n--;
		ans += 0ll + n - cnt[ch];
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){

  int n,i,j;
  int ans[10];

  while(scanf("%d",&n)!=EOF){
    j=0;
    for(i=512;i>0;i/=2){
      if(n>=i){
        n-=i;
        ans[j]=i;
        if(n==0) break;
        j++;
      }
    }
    for(i=j;i>0;i--){
      printf("%d ",ans[i]);
    }
    printf("%d\n",ans[0]);
  }
  return 0;
}


Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }
    int ans = 100000000;
    for(int i = 0; i < (1 << D); i++){
        int s = 0;
        int num = 0;
        int max = -1;
        for(int j = 0; j < D; j++){
            if(i >> j & 1){
                s += 100 * (j+1) * p[j] + c[j];
                num += p[j];
            }else{
                max = j;
            }
        }
        if(s < G){
            int s1 = 100*(max+1);
            int need = (G - s + s1 - 1)/s1;
            if(need >= p[max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(){
  long long A, B; cin >> A >> B;
  long long C = gcd(A,B);
  
  cout << A*B/C << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int n, k, x, y;

    scanf("%d %d %d %d", &n, &k, &x, &y);

    int sum = 0;
    for(int i = 0; i < n; ++i){
        if(i < k){
            sum += x;
        }else{
            sum += y;
        }
    }

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

    return 0;
}


Measured memory_bytes: 1716
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
from collections import deque

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())

ans = 1
tops = deque([A[0]])
tops_cnt = 1
for i in range(1,N):
    # print(tops)
    swap_i = bisect.bisect_left(tops,A[i])
    if swap_i:
        # print("hoge",swap_i-1)
        tops[swap_i-1] = A[i]
    # for max_i in range(tops_cnt):
    #     if tops[max_i] < A[i]:
    #         tops[max_i] = A[i]
    #         break
    else:
        tops.appendleft(A[i])
        ans += 1
        tops_cnt += 1

print(ans)


Measured memory_bytes: 11216
*A,N  = map(int,open(0).read().split())
ans = 0
ans += (N//2)*min(A[0]*8,A[1]*4,A[2]*2,A[3])# 2x
ans += (N%2)*min(A[0]*4,A[1]*2,A[2])# 1x

print(ans)

Measured memory_bytes: 9092
n,x = map(int, input().split())
a = list(map(int, input().split()))

ans = sum(a)

b = [a[i] for i in range(n)]
for i in range(1,n):
    c = [b[j] for j in range(n)]
    for k in range(n):
        b[k] = min(c[k],c[k-1])
    ans = min(ans, sum(b)+i*x)
print(ans)

Measured memory_bytes: 44892
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;

    constexpr int inf = 1 << 30;

    string str1, str2;
    string s;
    cin >> s; str1 = "-" + s;
    cin >> s; str2 = "-" + s;

    vec<vec<int>> dp(str1.size(), vec<int>(str2.size(), inf));

    //初期化
    for (int i = 0; i < str1.size(); ++i) dp[i][0] = i;
    for (int i = 0; i < str2.size(); ++i) dp[0][i] = i;

    for (int i = 1; i < str1.size(); ++i)
        for (int j = 1; j < str2.size(); ++j)
        {
            dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1), dp[i - 1][j - 1] + (str1[i] == str2[j] ? 0 : 1));
        }

    cout << dp[str1.size() - 1][str2.size() - 1] << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 6872
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

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

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

typedef long long ll;

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

  int max = 0;
  int cnt = 0;

  ll now;
  ll h;
  cin >> now;

  for(int i=1; i<n; i++){
    cin >> h;

    if(now >= h){
      cnt++;
    } else {
      if(cnt > max) max = cnt;
      cnt = 0;
      if(n - i < max) break;
    }

    now = h;
  }
      
  if(cnt > max) max = cnt;

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            sum += a[i];
        }
        long min = sum;
        long asum = 0;
        for (int i = 0; i < n - 1; i++) {
            asum += a[i];
            sum -= a[i];
            min = Math.min(min, Math.abs(sum - asum));
        }
        System.out.println(min);
    }

}


Measured memory_bytes: 81332
n = int(input())
a = list(map(int,input().split()))
ans = "APPROVED"
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 6 != 0 and a[i] % 10 != 0:
            ans = "DENIED"
            break
print(ans)

Measured memory_bytes: 3064
//ACGT;
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[5]={0},ma=0,h=0;
	string s;
	cin>>s;
	for(int t=0;t<s.size();t++)
	{
		if(s[t]=='A'||s[t]=='C'||s[t]=='G'||s[t]=='T')
		{
			a[h]++;
		}
		else
		{
			if(s[t-1]=='A'||s[t-1]=='C'||s[t-1]=='G'||s[t-1]=='T')
			{
				h++;
			}
			continue;
		}
	}
	for(int t=0;t<5;t++)
	{
		if(a[t]>ma)
		{
			ma=a[t];
		}
	}
	cout<<ma;
	return 0;
}

Measured memory_bytes: 256
# ABC087 C - Candies
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
ans = 0
for i in range(n):
    t = sum(a1[0:i+1]) + sum(a2[i:])
    ans = max(ans,t)
print(max(ans,sum(a1)))

Measured memory_bytes: 3060
import Control.Monad
import Control.Applicative
import Data.Monoid
import Data.Maybe
import Data.List

data Dat = Num Int | X deriving (Show, Eq)
data Lattice a = Value a | Top | Bot deriving (Eq, Show)
type FinRange a = (Lattice a, Lattice a)
newtype Range a = Range { getRange :: Maybe (FinRange a) } deriving (Eq, Show)

instance Ord a => Ord (Lattice a) where
    compare (Value x) (Value y) = compare x y
    compare Bot Bot = EQ
    compare Top Top = EQ
    compare Bot _ = LT
    compare _ Top = LT
    compare _ _   = GT

between :: Ord a => a -> a -> Range a
between x y = if x < y then Range $ Just (Value x, Value y) else Range Nothing
lesthan x   = Range $ Just (Bot, Value x)
grtthan x   = Range $ Just (Value x, Top)
none        = Range Nothing
total       = Range $ Just (Bot, Top)

appendRange :: Ord a => FinRange a -> FinRange a -> Range a
appendRange (x, y) (x', y')
    | y < x' || y' < x  = none
    | otherwise         = Range $ Just (max x x', min y y')

instance Ord a => Monoid (Range a) where
    mempty = total
    mappend (Range (Just a)) (Range (Just b)) = appendRange a b
    mappend _ _ = none

makePair :: [Dat] -> [(Dat, Dat)]
makePair [] = []
makePair (x:xs) = snd $ foldl (\ (a, l) b -> (b, l ++ [(a,b)])) (x, []) xs

imap :: (Int -> a -> b) -> [a] -> [b]
imap f = zipWith f (from 0)
    where from n = n:(from (n + 1))

hoge :: Dat -> Dat -> Range Int
hoge (Num n) (Num m) = if n < m then total else none
hoge X (Num n) = lesthan n
hoge (Num n) X = grtthan n
hoge X X = none

solve :: [Dat] -> String
solve xs = case mconcat . imap f . makePair $ xs of
    Range Nothing -> "none"
    Range (Just (Value x, Value y))
        | y - x < 2  -> "none"
        | y - x == 2 -> show (x + 1)
        | otherwise  -> "ambiguous"
    _ -> "ambiguous"
    where f i (x,y) = if even i then hoge x y else hoge y x

fromString :: String -> Dat
fromString "x" = X
fromString n   = Num . read $ n

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    when (n /= 0) $ do
      dats <- fmap fromString . words <$> getLine :: IO [Dat]
      putStrLn . solve $ dats
      main

Measured memory_bytes: 5432
N = int(input())
S = input()
E = []
W = []
k = 0
for i in range(N):
  if S[i] == 'E':
    k += 1
  E.append(k)
l = 0
for i in range(N):
  if S[N-i-1] == 'W':
    l += 1
  W.append(l)
W.reverse()
ME = E[N-1]
MW = W[0]
ans = float('inf')
for i in range(N):
  if ans >= ME-E[i]+MW-W[i]:
    ans = ME-E[i]+MW-W[i]
print(ans)

Measured memory_bytes: 67836
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int X;

  cin >> X;

  for (int i=1; i*100<=X; i++) {
    int r = X - i * 100;
    if (r <= i * 5) {
      puts("1");
      return 0;
    }
  }

  puts("0");

  return 0;
}


Measured memory_bytes: 256
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        for (int c = 1; c < 10; c++){
            for (int d = 1; d < 10; d++){
                String c1 = String.valueOf(c);
                String d1 = String.valueOf(d);
                String e1 = String.valueOf(c*d);
                String f1 = c1 + "x" + d1 + "=" + e1;
                System.out.println(f1);
                
            }
        }
        
    }
}

Measured memory_bytes: 16860
#include<iostream>
#include<vector>
#include<algorithm>
#include <cfenv>
#include <cmath>
#include <map>
#include <cassert>
#include <limits>
typedef  long long ll;

const int MAX = 1000000007;
const int MOD = 1000000007;

using namespace std;


int main() {
	int n,point=0,pl,pm;
	ll ansl = 0, ansm = 0;
	int ans = std::numeric_limits<int>::max();
	vector<int>x;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		point += tmp;
	}
	int min = *std::min_element(x.cbegin(), x.cend());
	int max = *std::max_element(x.cbegin(), x.cend());
	for (int i = min; i <= max; i++) {
		ll dis = 0;
		for (auto var : x) {
			dis += pow(var - i, 2);
		}
		if (ans > dis)ans = dis;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  char c;cin>>c;
  if(c>='a')cout<<'a'<<endl;
  else cout<<'A'<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stack>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;

double sum;
stack <double> s;

void calc(string tmp)
{
	double o1, o2;
	if (tmp == "+"){
		o2 = s.top(); s.pop();
		o1 = s.top(); s.pop();
		s.push(o1+o2);
	}
	else if (tmp == "-"){
		o2 = s.top(); s.pop();
		o1 = s.top(); s.pop();
		s.push(o1-o2);
	}
	else if (tmp == "*"){
		o2 = s.top(); s.pop();
		o1 = s.top(); s.pop();
		s.push(o1*o2);
	}
	else if (tmp == "/"){
		o2 = s.top(); s.pop();
		o1 = s.top(); s.pop();
		s.push(o1/o2);
	}
	return;
}

int main(void)
{
	string str, tmp;
	while (getline(cin, str)){
		while (!s.empty()) s.pop();
		stringstream ss(str);
		while (ss >> tmp){
			if (tmp == "+" || tmp == "-" || tmp == "*" || tmp == "/"){
				calc(tmp);
			}
			else s.push(atof(tmp.c_str()));
		}
		printf("%.6lf\n", s.top());
	}
	
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000009
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
signed main()
{   
    fastio();
    int t=1;
//    cin>>t;
    while(t--)
    { 
      int n,k;
      cin>>n>>k;
      int c=0;
      int a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
          if(a[i]>=k)
          c++;
      }
      cout<<c;
    }
}

    
// 🍪 🍪 🍪


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

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

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t; 
    //cin>>t;
    t=1;
    while(t--){
        string s,t;
        cin>>s>>t;
        ll n = s.length();
        ll m = t.length();
        ll dp[n+1][m+1]={0};
        rep(i,0,n){
            rep(j,0,m){
                if(i==0 || j==0){dp[i][j]=0;}
                else{
                    if(s[i-1]==t[j-1]){dp[i][j] = 1+dp[i-1][j-1];}
                    else{dp[i][j] = max(dp[i-1][j],dp[i][j-1]);}
                }
            }
        }
        // cout<<dp[n][m]<<"\n";
        ll i=n, j=m; string h;
        while(i>0 && j>0){
            if(s[i-1]==t[j-1]){
                h.pb(s[i-1]); i--; j--;
            }
            else{
                if(dp[i][j] == dp[i-1][j]){
                    i--;
                }
                else{
                    j--;
                }
            }
        }
        reverse(h.begin(),h.end());
        cout<<h;
    }
}


Measured memory_bytes: 70656
# include <cstdio>
# include <iostream>
using namespace std;
int main ()
{
  int n,flag=0;
  cin>>n;
  for (int i=0;i<=25;++i)
     {
       for (int j=0;j<=15;++j)
	        if (4*i+7*j==n)
			  {
			    flag=1;
				break;	
			  }	
	 } 
   if (flag==1)
     printf ("Yes\n");
   else
     printf ("No\n");
} 

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	int n, a; cin >> n >> a;
	ll dp[n+5][2550];
	memset(dp,0ll,sizeof dp);
	rep(i,1,n) {
		int x; cin >> x;
		per(j,i,2) rep(k,1,2500-x)
			dp[j][k+x] += dp[j-1][k];
		++dp[1][x];
	}
	ll res = 0ll;
	rep(i,1,n) res += dp[i][i*a];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1408
def examA():
    S = SI()
    T = SI()
    N = len(S)
    ans = "No"
    for i in range(N):
        cur = S[i:] + S[:i]
        #print(cur)
        if cur==T:
            ans = "Yes"
    print(ans)
    return

def examB():
    H, W = LI()
    S = [SI()for _ in range(H)]
    flag = True
    ans = 0
    print(ans)
    return

def examC():
    L, R = LI()
    ans = inf
    if R-L>=3000:
        R = L+3000

    for l in range(L, R + 1):
        for r in range(l+1, R + 1):
            now = (l*r) %2019
            ans = min(ans,now)
    print(ans)
    return

def examD():
    T = ["dream", "dreamer", "erase", "eraser"]
    S = SI()
    ans = "NO"
    t = ""
    for s in S[::-1]:
        t += s
        if t[::-1] in T:
            t = ""
    if t=="":
        ans = "YES"
    print(ans)
    return

def examE():
    N = 50
    K = I()
    base = K//N
    A = [base+i for i in range(N)]
    rest = K%N
    for i in range(rest):
        A[-i-1] += 1
    print(N)
    print(" ".join(map(str,A)))
    return

def examF():
    L = I()

    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    string S;
    cin>>N>>S;
    vector<pair<char,int>> s;
    int cnt=1;
    //l=左に置く'('の数,la='('の数。 (の個数を左から足していく。右へなぞるときに)が現れるたびに-1する。0になったらlにほしいので足してあげる
    int l=0,la=0;
    rep(i,N){
        if(S[i]==')'){
            if(!la) l++;
            else la--;
        }else{
            la++;
        }
    }
    rep(i,l) cout<<'(';
    rep(i,N) cout<<S[i];
    rep(i,la) cout<<')'; 
}

Measured memory_bytes: 256
n,m=[int(x) for x in input().split()]
isA,atob=[0]*n,[n+1]*n
for _ in [0]*m:
    ai,bi=[int(x) for x in input().split()]
    isA[ai-1]=1
    atob[ai-1]=min(atob[ai-1],bi-1)
bstack=n+1
ans=0
for a in range(n):
    if bstack==a:
        ans+=1
        bstack=n+1
    if isA[a]==0:
        continue
    bstack=min(bstack,atob[a])
print(ans)

Measured memory_bytes: 48984
// ref. https://img.atcoder.jp/tenka1-2017/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, k;
  cin >> n >> k;
  vector<P> ps(n);
  rep(i, n) {
    cin >> ps[i].first >> ps[i].second;
  }

  vector<ll> ks;
  ks.push_back(k);
  rep(i, 30) {
    if (k&(1ll<<i)) { // i-bit is 1 in k
      ll nk = k; // 0 at i, 1 at [0, i)
      nk &= ~(1ll<<i);
      rep(j, i) {
        nk |= 1ll<<j;
      }
      ks.push_back(nk);
    }
  }

  ll ans = 0;
  for (ll nk : ks) {
    ll now = 0;
    for (auto&p : ps) {
      if ((nk|p.first) == nk) { // p.first is in nk
        now += p.second;
      }
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define sc(a,b) scanf("%lld %lld",&a,&b) 

int main()
{
	ll a,b;
/*while(*/sc(a,b);//!=EOF)


   
  if(a==1 && b==2 || a==2 && b==1)printf("3\n");
  if(a==2 && b==3 || a==3 && b==2)printf("1\n");
  if(a==3 && b==1 || a==1 && b==3)printf("2\n");
}
//}

Measured memory_bytes: 256
def inputs(): return [int(x) for x in input().split()]
from collections import defaultdict
n,x,y = inputs()
ans = defaultdict(int)
for i in range(1,n):
    ans[i]=0
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if i<=x and y<=j:
            a = x-i+1+j-y
            ans[a]+=1
        else:
            if i<=x:
                a=min(j-i,x-i+1+y-j)
            elif y<=j:
                a = min(j-i,i-x+1+j-y)
            elif x<i and j<y:
                a = min(j-i,i-x+1+y-j)
            ans[a]+=1
for i in ans.keys():
    print(ans[i])

Measured memory_bytes: 47068
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

  vector<int> h(n);
  rep(i, n) cin >> h[i];

  bool ans = true;

  rrep(i, n - 1) {
    if(h[i] - 1 == h[i + 1]) {
      h[i]--;
    }
    if(h[i] > h[i + 1]) {
      ans = false;
      break;
    }
  }

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

  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static int[] linea = {0,1,2,0,3,6,0,2};
	public static int[] lined = {3,3,3,1,1,1,4,2};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String s = sc.next();
			char win = 'd';
			for(int i=0;i<8;i++) {
				char c = checkWin(s, linea[i], lined[i]);
				if (c != 'd' && c != 's') {
					win = c;
					break;
				}
			}
			System.out.println(win);
		}
	}

	public static char checkWin(String s,int a,int d) {
		char c = s.charAt(a);
		for(int i=1;i<3;i++) {
			char c2 = s.charAt(a+d*i);
			if (c != c2) {
				return 'd';
			}
		}
		return c;
	}
}

Measured memory_bytes: 17140
import Numeric

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine :: IO [Double]
  if n < k
    then print . (/n)              . sum . map ((0.5^) . ceiling . logBase 2 . (k/)) $ [1..n]
    else print . (/n) . (+(n-k+1)) . sum . map ((0.5^) . ceiling . logBase 2 . (k/)) $ [1..(k-1)]


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

vector<ll> divisor(ll n) {
    vector<ll> r;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            r.push_back(i);
            if (i * i != n)
                r.push_back(n / i);
        }
    }
    sort(r.begin(), r.end());
    return r;
}

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

    ll a, b;
    cin >> a >> b;
    vector<ll> s, t;
    s = divisor(a);
    t = divisor(b);

    vector<ll> st;
    set_intersection(s.begin(), s.end(), t.begin(), t.end(),
                     inserter(st, st.end()));
    ll ans = 1, x = 1;
    rep(i, 1, st.size()) {
        if (__gcd(x, st[i]) == 1) {
            ans++;
            x *= st[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n,m = gets.chomp.split(' ').map{|n| n.to_i}
a = []
b = []
c = []
d = []
C = 10 ** 9 

n.times do |i|
  a[i], b[i] = gets.chomp.split(' ').map{|n| n.to_i}
end

m.times do |i|
  c[i], d[i] = gets.chomp.split(' ').map{|n| n.to_i}
end

distance = Array.new(n)
n.times do |i|
  cheack = C
  m.times do |ci|
    ds_tmp = (a[i] - c[ci]).abs + (b[i] - d[ci]).abs
    if ds_tmp < cheack
      distance[i] = ci + 1
      cheack = ds_tmp
    end
  end
end

distance.each do |i|
  puts i
end 


Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n, k; 
string s;
 
void solve() { 
    cin >> n >> k >> s;    
    int lst = s[0];
    vector<int> type; 
    for (int i = 1; i < n; ++i) {
        if (lst == s[i]) {
            continue; 
        } else if (lst == 'L') {
            type.pb(1);
        } else {
            type.pb(-1); 
        }           
        lst = s[i]; 
    }
    if (lst == 'L') {
        type.pb(1);         
    } else {
        type.pb(-1); 
    }
    int ans = 0; 
    ans = type.size(); 
    for (int i = 1; i < type.size(); i += 2) {
        if (k) {
            if (i != (int)type.size() - 1) {
                ans -= 2;
            } else {
                ans -= 1;
            }
            --k;                           
        }
    }
    cout << n - ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 1480
// https://atcoder.jp/contests/abc131/tasks/abc131_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a%b)
    }
}

fn solve(n: i64, c: i64, d: i64) -> i64 {
    n - n/c - n/d + n/(c*d/gcd(c,d))
}

fn main() {
    input! {
        a: i64, b: i64, c: i64, d: i64
    };

    println!("{}", solve(b, c, d) - solve(a-1, c, d));
}


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


int main(){
  char x,y;
  cin >> x >> y;
  if(x<y){
    cout <<"<" << endl;
  }
  else if(x>y){
    cout <<">" << endl;
  }
  else{
    cout <<"=" << endl;
  }
  }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = Integer.parseInt(sc.next());
		long total=0;
		for(int i=1;i<=num;i++) {
			if(i%3==0||i%5==0) {
				continue;
			}
			total+=i;
		}
		System.out.println(total);
	}

}


Measured memory_bytes: 35720
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream> 
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
	ll n, m, sum = 0, ans = 0;
	scanf("%lld%lld", &n, &m);
	vector<ll> a(n), b(m);
	for(ll i = 0; i < n; i++) 
		cin>>a[i];
	
	for(ll i = 0; i < m; i++)
		cin>>b[i];
	
	for(ll i = 0; i < n; i++) {
		sum += a[i]*(n-i*2-1);
		sum %= mod;
	}
	for(ll i = 0; i < m; i++)
		ans = (ans % mod + b[i] % mod * (m-i*2-1) % mod * sum % mod) % mod;
	printf("%lld", ans); 
	return 0;
} 


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

N = int(input())

c = {}

for n in range(1, N+1):
    n_list = list(str(n))
    first = n_list[0]
    end = n_list[-1]
    if first + end in c:
        c[first + end] += 1
    else:
        c[first + end] = 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        if str(i) + str(j) in c and str(j) + str(i) in c:
            ans += c[str(i) + str(j)] * c[str(j) + str(i)]

print(ans)

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

int main(int argc, char const *argv[]) {
  int A, B;
  char op;
  cin >> A >> op >> B;

  switch (op) {
    case '+':
      cout << A+B;
      break;
    case '-':
      cout << A-B;
      break;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main()
{
  int a;
  std::cin >>a;
  bool flag = false;
  for(size_t i = 1; i < 10; i++)
  {
    int f = std::floor(static_cast<double>(a)/static_cast<double>(i));
    if(a%i==0 && f < 10 && !flag)
    {
      std::cout<< "Yes"<<std::endl;
      flag = true;
    }
  }
  if(!flag)
  {
    std::cout<<"No"<<std::endl;

  }
}

Measured memory_bytes: 256