akhauriyash/Code-Regression huggingface dataset:
n, a_array = readlines.map(&:chomp)
n = n.to_i
a_array = a_array.split(' ').map(&:to_i)

result = Rational(1, a_array[0])

(1..(n-1)).each do |i|
  result += Rational(1, a_array[i])
end
puts Rational(1, result).to_f

Measured memory_bytes: 1788
cards = [[False for i in range(13)] for j in range(4)]
mark = ['S','H','C','D']
a = int(input())

for i in range(a):
    all = input().split() 
    char = all[0]
    num = int(all[1])
    if 'S' == char[0]:
        cards[0][num-1] = True;
    if 'H' == char[0]:
        cards[1][num-1] = True;
    if 'C' == char[0]:
        cards[2][num-1] = True;
    if 'D' == char[0]:
        cards[3][num-1] = True;

for j in range(4):
    for k in range(13):
        if cards[j][k] == False:
            print('{} {}'.format(mark[j], k+1))
    
    
    


Measured memory_bytes: 5604
N = int(input())
H = list(map(int,input().split()))
ans = 0
can = 0
for i in range(N-1):
  if(H[i] >= H[i+1]):
    can += 1
  else:
    if(ans < can):
      ans = can
    can = 0
if(ans < can):
  ans = can
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = max({a*c, b*d, a*d, b*c});
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# import itertools
# from operator import attrgetter, itemgetter
# import math

# from numba import jit

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    s = input()

    if len(set(s)) != 3:
        print(0)
        sys.exit()

    from collections import Counter

    cntr = Counter()
    ans = 0

    for i, ch in enumerate(s):
        cntr[ch] += 1
        if ch == "R":
            ans += cntr["G"] * cntr["B"]
        if ch == "G":
            ans += cntr["R"] * cntr["B"]
        if ch == "B":
            ans += cntr["R"] * cntr["G"]

        for j in range(1, i // 2 + 1):
            p = s[i - j]
            pp = s[i - j * 2]
            if ch != p and p != pp and pp != ch:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68744
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int S[1000];
int top;
int pop();
void push(int);
int main(){

  int top=0;
  int a,b;
  char anos[1000];
  
  while(scanf("%s",anos)!=EOF){

      
   

    if(anos[0]=='+'){
      a=pop();
      b=pop();      
      push(a+b);
    }

    else if(anos[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }

    else if(anos[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else {
      push(atoi(anos));
    }
  }


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

  return 0;

}

int pop(){

  return S[top--];

}

void push(int x){

   top++;
   S[top]=x;

 }

Measured memory_bytes: 548
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M,cnt = 0; cin >> N >> M;
    VI A(N);
    REP(i, N) {
        cin >> A[i];
    }
    vector<PII> BC(M);
    REP(i, M) {
        cin >> BC[i].second >> BC[i].first;
    }
    A.emplace_back(-INF);
    BC.emplace_back(PII(-INF, 0));
    sort(ALL(BC), greater<PII>());
    sort(ALL(A),greater<int>());
    ll ans = 0;
    int i = 0, j = 0;
    while (cnt < N) {
        if (A[i] >= BC[j].first) {
            ans += A[i];
            cnt++;
            i++;
        }
        else {
            if (cnt + BC[j].second <= N) {
                ans += (ll)BC[j].first * BC[j].second;
                cnt += BC[j].second;
            }
            else {
                ans += (ll)BC[j].first * (N - cnt);
                cnt = N;
            }
            j++;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 2168
S = input()

a = int(S[:2])
b = int(S[2:])
if 1 <= b <= 12 and 1 <= a <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
int ps4[4][2]={0,1,0,-1,1,0,-1,0};
int ps8[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
inline int min(int a,int b,int c) {return min(a,min(b,c));}
inline int max(int a,int b,int c) {return max(a,max(b,c));}
inline int min(int a,int b,int c,int d){return min(min(a,b,c),d);}
inline int max(int a,int b,int c,int d){return max(max(a,b,c),d);}
//struct Edge{int p, next, w;}edge[maxn];
//inline add_edge(int u, int v, int w){edge[cnt]=Edge{v,head[u],w}; head[u]=cnt++;}
const int N=100005;
///Code begin..................................................................

string s;
vector<pair<char,int>>v;

int main ()
{
    int ans=0;
    cin>>s;
    for (int i=0; i<s.length(); ++i) {
        if (s[i]!='x') v.pb(mp(s[i],i));
    }
    for (int i=0; i<v.size(); ++i) {
        if (v[i].first!=v[v.size()-i-1].first) {puts("-1"); return 0;}
    }
    if (v.size()==0) {puts("0"); return 0;}
    if (v.size()%2==0) {
        int p1=v.size()/2-1, p2=p1+1;
        p1=v[p1].second, p2=v[p2].second;
        while (p1>=0) {
            if (p2>=s.length()) --p1, ++ans;
            else if (s[p1]==s[p2]) --p1, ++p2;
            else if (s[p1]=='x') --p1, ++ans;
            else ++p2, ++ans;
        }
        if (p2<s.length()) ans+=s.length()-p2;
    }
    else {
        int p=v.size()/2, p1=v[p].second-1, p2=v[p].second+1;
        while (p1>=0) {
            if (p2>=s.length()) --p1, ++ans;
            else if (s[p1]==s[p2]) --p1, ++p2;
            else if (s[p1]=='x') --p1, ++ans;
            else ++p2, ++ans;
        }
        if (p2<s.length()) ans+=s.length()-p2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1528
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = Counter(v[::2]).most_common()
v2 = Counter(v[1::2]).most_common()
v1.append((0,0))
v2.append((0,0))
ans = n
if v1[0][0]==v2[0][0]:
    ans -= max(v1[0][1]+v2[1][1],v1[1][1]+v2[0][1])
else:
    ans -= v1[0][1]+v2[0][1]
print(ans)

Measured memory_bytes: 65004
#include<stdio.h>
int main(){
  int c,d[30][30],p[30][3]={},i,j,k,n,x,y,r=1<<29;
  scanf("%d%d",&n,&c);
  for(i=0;i<c;i++)for(j=0;j<c;j++)scanf("%d",&d[i][j]);
  for(i=0;i<n;i++)for(j=0;j<n;j++){scanf("%d",&k);p[k-1][(i+j)%3]++;}
  for(i=0;i<c;i++)for(j=0;j<c;j++)for(k=0;k<c;k++)if(i!=j&&j!=k&&k!=i){
    y=0;for(x=0;x<c;x++)y+=d[x][i]*p[x][0]+d[x][j]*p[x][1]+d[x][k]*p[x][2];
    r=y<r?y:r;
  }
  printf("%d",r);
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
#define int long long

int N;
string S[200000];

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) cin >> S[i];

  set<string> s;
  for(int i=0; i<N; i++) s.insert(S[i]);

  cout << s.size() << endl;
}


Measured memory_bytes: 25472
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int h,w;
string s[101];

int main(){
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}
	
	bool b[100] = {0}, bb[100] = {0};
	for(int i = 0; i < 100; i++){
		int c = 0;
		for(int j = 0; j < w; j++){
			if(s[i][j] == '#') c++;
		}
		if(c == 0) b[i] = 1;
		c = 0;
		for(int j = 0; j < h; j++){
			if(s[j][i] == '#') c++;
		}
		if(c == 0) bb[i] = 1;
	}
	
	for(int i = 0; i < h; i++){
		if(b[i]) continue;
		for(int j = 0; j < w; j++){
			if(bb[j]) continue;
			cout << s[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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

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

int main(){
    int n; cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    if(n == 1) {
        cout << t[0] << endl;
        return 0;
    }
    ll ans = lcm(t[0],t[1]);
    for(int i = 2; i < n; ++i){
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1505;
struct lpl{
	int x[5];
//	friend bool operator < (lpl a, lpl b) {
//		return a.x[1] == b.x[1] ? (a.x[2] == b.x[2] ? (a.x[3] == b.x[3] ? a.x[4] < b.x[4] : a.x[3] < b.x[3]) : a.x[2] < b.x[2]) : a.x[1] < b.x[1];
//	}
}ini[maxn];
int n, c[5];
map<lpl, long long> mp;
long long ans;

inline bool operator < (lpl A, lpl B){
	if(A.x[1] == B.x[1]){
		if(A.x[2] == B.x[2]){
			if(A.x[3] == B.x[3]) return A.x[4] < B.x[4];
			else return A.x[3] < B.x[3];	
		}
		else return A.x[2] < B.x[2];	
	}
	else return A.x[1] < B.x[1];
}

inline lpl move(lpl A){
	lpl ret;
	ret.x[1] = A.x[2];
	ret.x[2] = A.x[3];
	ret.x[3] = A.x[4];
	ret.x[4] = A.x[1];
	return ret;
}

inline void ins(lpl A, long long val){
	for(int i = 1; i <= 4; ++i){
		A = move(A); mp[A] += val; 
	}
}

inline void putit(){
	scanf("%d", &n);  lpl lin;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= 4; ++j) scanf("%d", &ini[i].x[j]); 
		ins(ini[i], 1);
	}
}

inline void calc(int a, int b){
	lpl A = ini[a], B = ini[b];
	for(int p = 1; p <= 4; ++p){
		B = move(B);
		lpl up, down, qian, hou;
		up.x[1] = A.x[2]; up.x[2] = A.x[1]; up.x[3] = B.x[1]; up.x[4] = B.x[4];
		down.x[1] = A.x[3]; down.x[2] = A.x[2]; down.x[3] = B.x[4]; down.x[4] = B.x[3];
		qian.x[1] = A.x[4]; qian.x[2] = A.x[3]; qian.x[3] = B.x[3]; qian.x[4] = B.x[2];
		hou.x[1] = A.x[1]; hou.x[2] = A.x[4]; hou.x[3] = B.x[2]; hou.x[4] = B.x[1];

//		up.x[1] = A.x[1]; up.x[2] = B.x[2]; up.x[3] = B.x[1]; up.x[4] = A.x[2];
//		down.x[1] = A.x[3]; down.x[2] = B.x[4]; down.x[3] = B.x[3]; down.x[4] = A.x[2];
//		qian.x[1] = A.x[2]; qian.x[2] = B.x[1]; qian.x[3] = B.x[4]; qian.x[4] = A.x[3];
//		hou.x[1] = B.x[2]; hou.x[2] = A.x[1]; hou.x[3] = A.x[4]; hou.x[4] = B.x[3];	
		
		if(!mp[up] || !mp[down] || !mp[qian] || !mp[hou]) continue;
		long long ret = 1;
		ret *= mp[up]; ins(up, -1);
		ret *= mp[down]; ins(down, -1);
		ret *= mp[qian]; ins(qian, -1);
		ret *= mp[hou]; ans += ret;
		ins(up, 1); ins(down, 1); ins(qian, 1);
	}
}

inline void workk(){
	for(int i = 1; i <= n; ++i){
		ins(ini[i], -1);
		for(int j = i + 1; j <= n; ++j){
			ins(ini[j], -1); calc(i, j); ins(ini[j], 1);
		}
		ins(ini[i], 1);
	}
	cout << ans / 3;
}

int main()
{
	//freopen("lpl.in", "r", stdin);
	putit();
	workk();
	return 0;
}

Measured memory_bytes: 25344
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t,m=0,k=0,n=0;
    cin>>t;
    for(int i=0;i<t;i++){
        int a;
        cin>>a;
        if(a%4==0){
            n++;
        }
        else if(a%2==0){
            k++;
        }
        else m++;
    }
    if(n>=m-(k==0)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b, c;
   cin >> a >> b >> c;
   cout << max(c - max(a - b, 0), 0) << endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(string.Join("", Console.ReadLine().Select(e => char.IsUpper(e) ? char.ToLower(e) : char.ToUpper(e))));
        }

        /*private static bool IsInput(out int[] arr)
        {
            var s = Console.ReadLine();
            if (s == "0 0") { arr = null; return false; }

            arr = s.Split(' ').Select(int.Parse).ToArray();
            return true;
        }
        // */
    }
}


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

#define pb push_back
#define se second
#define fi first

using namespace std;

typedef long long ll;

string s, t;
int ans;

int main(){
    cin >> s >> t;
    for(int i = 0; i < 3; i++)
        if(s[i] == t[i])
            ans++;
    cout << ans;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [['#'] * (w + 2)] + [['#'] + list(input()) + ['#'] for i in range(h)]\
    + [['#'] * (w + 2)]
p = [[1, 1]]
d = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '.':
            d += 1
s[1][1] = '#'
k = 0
while [h, w] not in p:
    k += 1
    g = []
    for i in range(len(p)):
        x, y = p[i][0], p[i][1]
        if s[x-1][y] == '.':
            s[x-1][y] = 'Q'
            g.append([x-1, y])
        if s[x+1][y] == '.':
            s[x+1][y] = 'Q'
            g.append([x+1, y])
        if s[x][y+1] == '.':
            g.append([x, y+1])
        if s[x][y-1] == '.':
            s[x][y-1] = 'Q'
            g.append([x, y-1])
    else:
        p = g
        if len(p) == 0:
            print(-1)
            break
else:
    print(d - k - 1)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a,b,c,l[10],ans=1e10,k,x,y,z,s;
  cin>>n>>a>>b>>c;
  fr(i,n) cin>>l[i];
  fr(i,1<<(2*n)){
    x=0;y=0;z=0;
    k=0;
    fr(j,n){
      s=(i>>(2*j))%4;
      if(s==0){
        if(x>0) k+=10;
        x+=l[j];
      }
      if(s==1){
        if(y>0) k+=10;
        y+=l[j];
      }
      if(s==2){
        if(z>0) k+=10;
        z+=l[j];
      }
    }
    if(x==0||y==0||z==0) continue;
    k+=abs(x-a)+abs(y-b)+abs(z-c);
    ans=min(k,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import Data.Text as T
import Data.Text.IO as TIO
import Data.Monoid

main = do
  input <- TIO.getLine
  let h = T.head input
      l = T.last input
      len = T.pack .show $ (T.length input - 2)
  TIO.putStr $ h `cons`  len `snoc`  l 


Measured memory_bytes: 508
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

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

signed main()
{
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 1; i <= N; i++)
	{
		int n = yakusu(i).size();
		if (n == 8 && i % 2 == 1)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}

//int N;
//int X[200001];
//int Y[200001];
//char C[200001];
//
//set<int> s[400001];
//
//signed main()
//{
//	cin >> N;
//	REP(i, N) cin >> X[i] >> Y[i] >> C[i];
//
//	int mi = LLONG_MAX;
//
//	for (int i = 0; i < N; i++)
//	{
//		if (C[i] == 'D')
//		{
//			s[X[i]].insert(Y[i]);
//		}
//	}
//
//	for (int i = 0; i < N; i++)
//	{
//		if (C[i] == 'U')
//		{
//			auto it = s[X[i]].upper_bound(Y[i]);
//			if (it != s[X[i]].end())
//			{
//				int sub = *it - Y[i];
//				mi = min(mi, sub);
//			}
//		}
//	}
//
//	cout << mi << endl;
//}



Measured memory_bytes: 3164
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	ans := ""
	p := ""
	for _, c := range s {
		t := string(c)
		if p != t {
			ans += t
		}
		p = t
	}

	fmt.Println(len(ans))
}


Measured memory_bytes: 8832
import numpy as np

n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))
arr = np.array([list(map(int, input().split())) for _ in range(n)])

result = (arr * b).sum(axis=1) + c
print(np.where(result > 0)[0].shape[0])

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll dp[2020][2020];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<pll> A(n);
    rep(i,n){
        ll a; cin>>a;
        A[i] = mp(a,i);
    }
    sort(rall(A));
    rep(i,n)rep(j,i+1){
        chmax(dp[i+1][j+1], dp[i][j]+A[i].fi*abs(A[i].se-j));
        chmax(dp[i+1][j], dp[i][j]+A[i].fi*abs(n-1-(i-j)-A[i].se));
    }
    ll ans=0;
    // rep(i,n+1){
    //     rep(j,n+1){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<"\n";
    // }
    rep(i,n) chmax(ans, dp[n][i]);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 26352
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
l,r,d = readInts()
print(r//d - (l-1)//d)


Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>
#include <numeric>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); }
	ul lcm(const ul &a,const ul &b) { return (a/gcd(a,b))*b; } // a/gcd(a,b)*b <=> (a*b)/gcd(a,b)
	std::vector<bool> eratosthenes(const ul &n)
	{
		std::vector<bool> prime_candidate(n,true);
		prime_candidate[0] = prime_candidate[1] = false;
		for(ul i = 2;i*i < n;++i)
		{
			if(!prime_candidate[i]) continue;
			for(ul j = 2;i*j < n;++j) prime_candidate[i*j] = false;
		}
		return prime_candidate;
	}
	ll rho_method(const ll &n)
	{
		auto f = [&](const ll &xi){ return (xi*xi+1)%n; };
		ll x = 2, y = 2, d = 1;
		while(d == 1)
		{
			x = f(x);
			y = f(f(y));
			d = lamlib::gcd(lamlib::abs(x-y),n);
		}
		return d;
	}
	// 素因数分解(試し割)
	std::vector<ll> prime_factorization_trial(const ll &n)
	{
		ll num = n;
		std::vector<ll> prime;
		for(ll i = 2;i*i <= n;++i)
		{
			while((num%i) == 0)
			{
				prime.emplace_back(i);
				num /= i;
			}
		}
		if(num > 1) prime.emplace_back(num);
		return prime;
	}

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	ll k;
	std::cin >> k;

	std::string s;
	std::cin >> s;

	if(s.length() <= k) std::cout << s << std::endl;
	else std::cout << s.substr(0,k) << "..." << std::endl;

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int c = 0;
  if(a != 1 && b != 1){
    c = 1;
  }
  else if(a != 2 & b != 2){
    c = 2;
  }
  else{
    c = 3;
  }
  cout << c << endl;
}
  

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

int main()
{
  int N;
  cin >> N;
  
  int a = N / 1000;  //千の位
  int b = (N % 1000) / 100;   //百の位
  int c = (N % 1000 % 100) / 10;   //十の位
  int d = (N % 1000 % 100) % 10;
  
  if (a == b && a == c)
  {
  cout << "Yes" << endl;
  }
  else if (b == c && b == d)
  {
  cout << "Yes" << endl;
  }
  else
  {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Checkpoints
            var line = ReadLine();
            int n = line[0];
            int m = line[1];

            var students = new List<List<int>>();
            var checkpoints = new List<List<int>>();

            for(int i = 0; i < n; i++)
            {
                var c = ReadLine();
                students.Add(c);
            }

            for (int i = 0; i < m; i++)
            {
                var c = ReadLine();
                checkpoints.Add(c);
            }

            foreach(var student in students)
            {
                int min = int.MaxValue;
                int num = 0;

                for(int i = 0; i < m; i++)
                {
                    int distance = CalcDistance(student, checkpoints[i]);

                    if (distance < min)
                    {
                        min = distance;
                        num = i + 1;
                    }
                }

                Console.WriteLine(num);
            }
        }

        static int CalcDistance(List<int> student, List<int> checkpoint)
        {
            return Math.Abs(student[0] - checkpoint[0]) + Math.Abs(student[1] - checkpoint[1]);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
K,T=map(int,input().split())
A=list(map(int,input().split()))

if T==1:
  print(A[0]-1)
  exit()
  
ans=abs(A[0]-A[1])-1
k=A[0]+A[1]
for i in range(2,T):
  if ans>=A[i]:
    ans-=A[i]
  else:
    ans=max(A[i]-k-1,0)
  k+=A[i]  

print(ans)

Measured memory_bytes: 3064
module.exports=function(t){var r={};function i(n){if(r[n])return r[n].exports;var e=r[n]={i:n,l:!1,exports:{}};return t[n].call(e.exports,e,e.exports,i),e.l=!0,e.exports}return i.m=t,i.c=r,i.d=function(t,r,n){i.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,r){if(1&r&&(t=i(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var e in t)i.d(n,e,function(r){return t[r]}.bind(null,e));return n},i.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(r,"a",r),r},i.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},i.p="",i(i.s=0)}([function(t,r,i){"use strict";var n=i(1);i(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,i){"use strict";var n=i(3),e=i(5);t.exports=function(t){var r=new n(t);e(r)}},function(t,r,i){"use strict";var n=i(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,i){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,i){"use strict";var n=i(6);t.exports=function(t){for(var r=t.in(),i=t.in(),e=new n(r),s=r,o=0;o<i;o++){var u=t.in()-1,a=t.in()-1;t.in();e.isSameGroup(u,a)||s--,e.unite(u,a)}console.log(s)}},function(t,r,i){"use strict";t.exports=class{constructor(t){this.N=t,this.par=new Array(this.N),this.rank=new Array(this.N);for(var r=0;r<this.N;r++)this.par[r]=r,this.rank[r]=0}find(t){return this.par[t]==t?t:this.par[t]=this.find(this.par[t])}unite(t,r){var i=this.find(t),n=this.find(r);i!=n&&(this.rank[i]<this.rank[n]?this.par[i]=n:(this.par[n]=i,this.rank[i]==this.rank[n]&&this.rank[i]++))}isSameGroup(t,r){return this.find(t)==this.find(r)}}}]);


Measured memory_bytes: 37608
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int n, k, h[100001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>h[i];
    int dp[n];
    fill(dp, dp+n, 0);
    dp[0] = 0;
    for(int i=1; i<n; i++){
        int ans = INT_MAX;
        for(int j=1; j<=k && i-j>=0; j++){
            ans = min(ans, dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i] = ans;
    }
    cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int n,m,x;
int c[12],a[12][12],p[12];

int ans = -1;

void dfs(int cur, int sum)
{
	if(cur >= n) {
		int suc = 1;
		for(int i = 0; i < m; ++i) if(p[i] < x) suc = 0;
		if(suc) {
			if(ans == -1) ans = sum;
			else ans = min(ans,sum);
		}
		return;
	}

	dfs(cur + 1, sum);
	for(int i = 0; i < m; ++i) p[i] += a[cur][i];
	dfs(cur + 1, sum + c[cur]);
	for(int i = 0; i < m; ++i) p[i] -= a[cur][i];
}


int main()
{
	fastIO;
	cin >> n >> m >> x;
	rep(i,0,n) {
		cin >> c[i];
		rep(j,0,m) cin >> a[i][j];
	}
	dfs(0,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

from collections import defaultdict
def factorize(n: int) -> dict:
    f = defaultdict(int)
    tmp_n = n
    p = 2
    while tmp_n > 1 and p * p < n:
        while tmp_n % p == 0:
            f[p] += 1
            tmp_n = tmp_n // p
        p += 1 if p == 2 else 2

    if tmp_n != 1:
        f[tmp_n] += 1
    return f

a, b = map(int, input().split())
factors = factorize(GCD(a, b))

ans = len(factors) + 1

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<ll,ll> mp;
ll dp[200000];
int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> h(n);
  for(int i=0;i<n;i++)cin>>h.at(i);
  fill(dp,dp+n,inf);
  dp[0]=0;
  for(int i=0;i<n;i++){
      for(int j=1;j<=k&&i+j<n;j++){
          dp[i+j]=min(dp[i+j],dp[i]+abs(h.at(i)-h.at(i+j)));
      }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = double;
const ld eps = 1e-9;

int adiv(int a) {
	map<int,int>mp;
	int num(a);
	for (int i = 2; i <= a; ++i) {
		while (num%i == 0) {
			mp[i]++;
			num/=i;
		}
	}
	int anum=0;
	for (auto m : mp) {
		anum-=m.first;
	}
	anum+=2*prev(mp.end())->first;
	return anum;
}

int main() {
	while (true) {

		int A, B; cin >> A >> B;
		if(!A)break;
		A = adiv(A);
		B = adiv(B);
		if (A>B)cout << "a" << endl;
		else cout << "b" << endl;

	}
	return 0;
}


Measured memory_bytes: 2992
import sys

def primeTable(n):
    list = [True for _ in range(n+1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i+i
            while j<= n:
                list[j] = False
                j += i
        i += 1

    table = [i for i in range(n+1) if list[i] and i >= 2]
    return table

lines = sys.stdin.readlines()
primeList = primeTable(999999)

for line in lines:
    inp = int(line)
    primes = list(filter(lambda n:n>=2 and n<=inp, primeList))
    num = len(primes)
    print (num)

Measured memory_bytes: 18420
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(true){
	int  hito,ten;
	
		cin>>hito;
		if(hito == 0)break;
		float hai[hito];
		float a = 0;
		float heikin;
		for(int i = 0;i<hito;i++){
			cin>>hai[i];
			
		}
		float zenbu = 0;
		for(int i = 0;i<hito;i++){
			zenbu += hai[i];
			
		}
		zenbu /=  hito;
		for(int i = 0;i<hito;i++){
			a += (hai[i]-zenbu)*(hai[i]-zenbu);
		}
		a /= hito;
	printf("%.10f\n",sqrt(a));
	}
	//return 0;
}


Measured memory_bytes: 3288
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"reflect"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func isMember(target int, ints []int) bool {
	for i := range ints {
		if ints[i] == target {
			return true
		}
	}
	return false
}

func _perm(f func([]int), n, m int, xs []int) {
	if len(xs) == m {
		f(xs)
	} else {
		for i := 0; i <= n; i++ {
			if !isMember(i, xs) {
				_perm(f, n, m, append(xs, i))
			}
		}
	}
}

func permutation(f func([]int), n, m int) {
	_perm(f, n, m, make([]int, 0, m))
}

func printArray(target []int) {
	for i := range target {
		if i == len(target)-1 {
			fmt.Printf("%d\n", target[i])
		} else {
			fmt.Printf("%d ", target[i])
		}
	}
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	store := make([][]int, 0)
	// fmt.Println(store)
	var i int
	printPermutation := func(xs []int) {
		// fmt.Print(xs)
		// fmt.Println()
		store = append(store, make([]int, 0))
		store[i] = append(store[i], xs...)
		// fmt.Println(store)
		i++
	}
	permutation(printPermutation, n-1, n)
	// fmt.Println(store)
	for i := range store {
		for j := range store[i] {
			store[i][j]++
		}
	}
	// fmt.Println(store)
	for i := range store {
		if reflect.DeepEqual(store[i], a) {
			if i-1 >= 0 {
				printArray(store[i-1])
			}
			printArray(store[i])
			if i+1 < len(store) {
				printArray(store[i+1])
			}
		}
	}
}


Measured memory_bytes: 68440
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
S = sorted(S)
T = sorted(T)
reg = 0
count = 0
for i in range(q):
    for j in range(reg, n):
        if T[i] > S[j]:
            reg = j
        elif T[i] == S[j]:
            reg = j
            count += 1
            break
        else:
            break
print(count)


Measured memory_bytes: 16708
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

string str;
int now;

int E();
int T();
int F();
int N();

int E(){
  int t = T();
  if(t==INF) return INF;
  while(str[now+1]=='+' || str[now+1]=='-'){
    if(str[now+1]=='+'){
      now++;
      int p = T();
      if(p==INF) return INF;
      else t = t+p;
    }
    if(str[now+1]=='-'){
      now++;
      int p = T();
      if(p==INF) return INF;
      else t = t-p;
    }
  }
  return t;
}

int T(){
  int f = F();
  if(f==INF) return INF;

  if(str[now+1]=='*'){
    now++;
    int g = T();
    if(g==INF) return INF;
    else return f*g;
  }
  return f;
}

int F(){
  int n;
  switch(str[now+1]){
    case '0':
    case '1':
      n=N();
      if(n==INF) return INF;
      else return n;
    case '-':
      now++;
      n=F();
      if(n==INF) return INF;
      else return -n;
    case '(':
      now++;
      n = E();
      if(str[now+1]!=')' || n==INF) return INF;
      now++;
      return n;
    default:
      return INF;
  }
}

int N(){
  if(str[now+1]=='0'){
    now++;
    return 0;
  }
  if(str[now+1]!='1') return INF;
  now++;
  int res=1;
  while(str[now+1]=='1' || str[now+1]=='0'){
    now++;
    res = res*2 + str[now] - '0';
  }
  return res;
}

int main(){
  string s;
  cin>>s;
  set<char> m, mm;
  string moji = "=+-*()01";
  sort(all(moji));

  rep(i,s.size()){
    bool found=false;
    rep(j,moji.size()) if(s[i]==moji[j]){
      mm.insert(s[i]);
      found=true;
    }
    if(!found) m.insert(s[i]);
  }

  if(m.size()>moji.size()){
    cout<<0<<endl;
    return 0;
  }

  int ans=0;
  do { //next_permutation moji
    string newstr(s);

    auto itr = m.begin();
    rep(i, m.size()){
      rep(j, newstr.size()) if(newstr[j]==*itr){
        newstr[j] = moji[i];
      }
      itr++;
    }

    int idx = newstr.find('=');
    if(idx>0 && idx<newstr.size()-1){ // not ('=' is not found or at the head of string)
      str = newstr.substr(0, idx) + '\0';
      now = -1;
      int l = E();

      if(l!=INF && now==idx-1){
        str = newstr.substr(idx+1) + '\0';
        now = -1;
        int r= E();

        if(now==str.size()-2 && r==l) ans++;
      }
    }

    reverse(moji.begin()+m.size(), moji.end());

  } while(next_permutation(all(moji)));

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3204
n=int(input())
satis=[]

for i in range(n):
  A=list(map(int,input().split()))
  satis.extend(A)

tempA=satis[0]
tempB=satis[1]
tempC=satis[2]
if n > 1:
  for i in range(n-1):
    tempA2=satis[3*i+3]+max([tempB,tempC])
    tempB2=satis[3*i+4]+max([tempA,tempC])
    tempC2=satis[3*i+5]+max([tempA,tempB])
    tempA=tempA2
    tempB=tempB2
    tempC=tempC2
  print(max([tempA,tempB,tempC]))
else:
  print(max([tempA,tempB,tempC]))

Measured memory_bytes: 15072
from heapq import*
L,R=[],[]
B=t=0
Q,*E=open(0)
for e in E:
  if' 'in e:_,a,b=map(int,e.split());t^=1;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c
  else:print(-L[0],B-L[0]*t)

Measured memory_bytes: 28628
#include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;

int d[1111];
int w[1111];
int memo[1111][1111];
int n, m;

int solve(int a, int b){

  if(a == n) return 0;
  if(b == m) return INF;
  if(memo[a][b]) return memo[a][b];
  int ret = 0;
  ret += min(solve(a+1, b+1)+d[a]*w[b], solve(a, b+1));

  return memo[a][b] = ret;
}

int main(){

  cin >> n >> m;

  for(int i=0;i<n;i++) cin >> d[i];
  for(int i=0;i<m;i++) cin >> w[i];

  cout << solve(0, 0) << endl;

}

Measured memory_bytes: 5320
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	long long int x,y,z,d,r[10001];
	int n,i;
	while(cin >> x >> y >> z) {
		if (x+y+z==0) break;
		cin >> n;
		for (i=0;i<n;i++) cin >> r[i];
        d=min(x*x+z*z,min(x*x+y*y,y*y+z*z));
        for (i=0;i<n;i++) if (4*r[i]*r[i]>d) cout << "OK" << endl; else cout << "NA" << endl;
	} 
    return 0;
	}

Measured memory_bytes: 1164
#include <stdio.h>
static double q, h, s, d, n;
double f(double cost, double size) {
    return cost / size;
}
int main(void) {
    long sum = 0;
    scanf("%lf%lf%lf%lf%lf", &q, &h, &s, &d, &n);
    if (f(s, 1) <= f(d, 2))
        d = 2 * (long)s;
    if (f(h, 0.5) <= f(s, 1))
        s = 2 * (long)h;
    if (f(h, 0.5) <= f(d, 2))
        d = 4 * (long)h;
    if (f(q, 0.25) <= f(h, 0.5))
        h = 2 * (long)q;
    if (f(q, 0.25) <= f(s, 1))
        s = 4 * (long)q;
    if (f(q, 0.25) <= f(d, 2))
        d = 8 * (long)q;
    while (n >= 2) {
        sum += (long)d;
        n -= 2;
    }
    while (n >= 1) {
        sum += (long)s;
        n -= 1;
    }
    while (n >= 0.5) {
        sum += (long)h;
        n -= 0.5;
    }
    while (n >= 0.25) {
        sum += (long)q;
        n -= 0.25;
    }
    printf("%ld\n", sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<(a+b+1)/2;


  return 0;

}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	ll sum{0}, r{0};
	ll res{0};
	REP(l, N)
	{
		while (r < N && !(sum & A[r]))
			sum ^= A[r++];

		res += (r - l);

		if (r == l) ++r;
		else sum ^= A[l];
	}

	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 4708
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){

  int n,s[101],v[13],flag,count;
  
  scanf("%d",&n);
  
  while(n != 0){
    fill(s,s+101,0);
    
    count = 0;
    for(int i=0;i<n;i++){
      scanf("%d",&v[i]);
      s[v[i]]++;
    }
    
    while(1){
      flag = 0;
      for(int i=0;i<n;i++){
	if(v[i] != s[v[i]]){
	  v[i] = s[v[i]];
	  flag++;
	}
      }
      
      if(flag == 0) break;
      
      fill(s,s+101,0);
      for(int i=0;i<n;i++){
	s[v[i]]++;
      }
      
      count++;
    }
    printf("%d\n",count);
    for(int i=0;i<n;i++){
      if(i != n-1) printf("%d ",v[i]);
      else printf("%d\n",v[i]);
    }
    scanf("%d",&n);
  }
  
  return (0);
}

Measured memory_bytes: 2672
import math
A,B,H,M=map(int,input().split())
hun = 5.5*(H*60+M)
while hun >= 360:
    hun = hun-360
if hun >= 180:
    hun = 360-hun
kotae = math.sqrt((A*A)+(B*B)- (2*A*B*(math.cos(math.radians(hun)))))
print(kotae)

Measured memory_bytes: 9448
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    long long x, k, d;

    cin >> x >> k >> d;

    if (abs(x) /d> k ) {
        cout << abs(x) - k * d << endl;
       
    }
    else {
        long long a = abs(x) % d;
        long long b = abs(x) / d;

        if ((k - b) % 2 == 0) {
            cout << abs(x)-b*d << endl;
        }
        else {
            cout << d - (abs(x) - b * d) << endl;
        }
    }
  //  cout << 1000000000000*2200000000000 << endl;

    return 0;
}



Measured memory_bytes: 3612
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
H, W = ri_()
S = [list(rs()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        cnt = 0
        if S[i][j] == '#':
            continue
        for dx in [-1, 0, 1]:
            for dy in [-1, 0, 1]:
                if not 0 <= i + dy < H or not 0 <= j + dx < W:
                    continue
                if S[i + dy][j + dx] == '#':
                    cnt += 1
        S[i][j] = str(cnt)
for s in S:
    print(''.join(s))


Measured memory_bytes: 65260
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long 
# define INF 1000005
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}

const int SIZE = 1<<21;
int fac[SIZE],inv[SIZE];
int C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
   
    fac[0]=1;
    for(int i=1;i<SIZE;i++)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=power(fac[SIZE-1],MOD-2,MOD);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
void ADD(int& x,int y){x=(x+y)%MOD;if(x<0)x+=MOD;}
int32_t main()
{
    c_p_c();
    build();
    int k;
    string s;
     cin>>k>>s;
    int n=s.size();
    int ans=0;
    for(int i=0;i<=k;i++){
        int temp=(power(26,i,MOD)*power(25,k-i,MOD))%MOD;
        temp=(temp*C(n+k-i-1,n-1))%MOD;
        ans=(ans+temp)%MOD;
    }
   cout<<ans;
   
 
    
 
 
 
    
      return 0;
       }
        
        
 
        
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        

        

Measured memory_bytes: 36960
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=Integer.parseInt(sc.next());
        int B=Integer.parseInt(sc.next());
        int C=Integer.parseInt(sc.next());
        int X=Integer.parseInt(sc.next());
        int ans=0;
        for (int a=0;a<=A;a++){
            for (int b=0;b<=B;b++){
                for (int c=0;c<=C;c++){
                    if (a*500+b*100+c*50==X){
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23380
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


N = int(input())
S,T = inpl_str()


ans = list()

for _ in range(N):
    ans.append(S[_])
    ans.append(T[_])

print("".join(ans))




Measured memory_bytes: 3952