akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n, k;
    cin >> n >> k;
    vs64 s(n + 1);
    s[0] = 0;
    s64 a;
    rep (i, n)
    {
        cin >> a;
        s[i + 1] = s[i] + a;
    }

    vs64 A;
    s64 maxA = 0;
    rep (l, n)
    {
        for (int r = l + 1; r <= n; ++r)
        {
            A.push_back(s[r] - s[l]);
            maxA = MAX(maxA, s[r] - s[l]);
        }
    }

    s64 t = 0;
    while (((s64)1 << t) <= maxA) ++t;
    s64 x = 0;
    while (t >= 0)
    {
        s64 y = (s64)1 << t;
        int cnt = 0;
        rep (i, A.size())
        {
            if ((A[i] & (x + y)) == (x + y)) ++cnt;
        }
        if (cnt >= k) x = x + y;
        --t;
    }

    cout << x << "\n";
    return 0;
}



Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N, K; cin >> N >> K;
int ans = 1;

rep(i, 0, N){
    if (ans * 2 < ans + K) ans *= 2;
    else ans += K;
}


cout << ans << endl;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A___Station_and_Bus
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            if (S == "AAA" || S == "BBB")
            {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int n,L;
  cin >> n >> L;
  vector<string> v(n);
  rep(i,n) cin >> v[i];
  sort(v);
  rep(i,n) cout << v[i];
  cout << endl;
}

Measured memory_bytes: 256
using System;

namespace _14_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            //????´¢???????????????
            string searchWord = Console.ReadLine();
            //?§??????????????????¢???
            int foundIndex = s.IndexOf(searchWord);
            while (0 <= foundIndex)
            {
                //???????????£??????????????¨?????????
                Console.WriteLine(foundIndex);
                //?¬????????´¢????§???????
                int nextIndex = foundIndex + 1;
                if (nextIndex < s.Length)
                {
                    //?¬???????????????¢???
                    foundIndex = s.IndexOf(searchWord, nextIndex);
                }
                else
                {
                    //???????????§????´¢????????¨???????????????
                    break;
                }
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9820
def main():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1,N):
        L = list(set(S[:i]))
        R = list(set(S[i:]))
        cnt = 0
        for l in L:
            if l in R:
                cnt += 1
        ans = max(ans, cnt)
    print(ans)

main()

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll n;
    cin>>n;
    string str;
    cin>>str;
    ll ct=0,i=0;
    while(str[i]=='.'&&i<n)
    {
        ct++;
        i++;
    }

    ll w=0,b=0;
    fr(i,0,n)
    {
        if(str[i]=='.')
            w++;
        else
            b++;
    }
    w-=ct;
    ct=0;
    ll j=n-1;
    while(str[j]=='#'&&j>=0)
    {
        ct++;
        j--;
    }
    b-=ct;
    ll ans=min(b,w);
    w=0,b=0;
    fr(i,0,n)
    {
        if(str[i]=='.')
            w++;
        else
            b++;
    }
    ll bc=0,wc=0;
    fr(i,0,n)
    {
        if(str[i]=='.')
            wc++;
        else
            bc++;
        ll x=w-wc;
        x+=bc;
        ans=min(ans,x);
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 720
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int q = sc.nextInt();
		TreeSet<Long> tsS = new TreeSet<Long>();
		TreeSet<Long> tsT = new TreeSet<Long>();
		/*
		tsS.add(Long.MAX_VALUE);
		tsS.add(Long.MAX_VALUE - 1);
		tsS.add(Long.MIN_VALUE);
		tsS.add(Long.MIN_VALUE + 1);
		tsT.add(Long.MAX_VALUE);
		tsT.add(Long.MAX_VALUE - 1);
		tsT.add(Long.MIN_VALUE);
		tsT.add(Long.MIN_VALUE + 1);
		*/
		long[] x = new long[q];
		for(int i = 0; i < a; i++){
		    tsS.add(sc.nextLong());
		}
		for(int i = 0; i < b; i++){
		    tsT.add(sc.nextLong());
		}
		for(int i = 0; i < q; i++){
		    x[i] = sc.nextLong();
		}
		// 計算
		long[] result = new long[q];
		for(int i = 0; i < q; i++){
		    long here = x[i];
		    Long rS = tsS.higher(here);
		    Long lS = tsS.lower(here);
		    Long rT = tsT.higher(here);
		    Long lT = tsT.lower(here);
		    Long rSrT = (rS == null ? null : tsT.higher(rS));
		    Long rSlT = (rS == null ? null : tsT.lower(rS));
		    Long lSrT = (lS == null ? null : tsT.higher(lS));
		    Long lSlT = (lS == null ? null : tsT.lower(lS));
		    Long rTrS = (rT == null ? null : tsS.higher(rT));
		    Long rTlS = (rT == null ? null : tsS.lower(rT));
		    Long lTrS = (lT == null ? null : tsS.higher(lT));
		    Long lTlS = (lT == null ? null : tsS.lower(lT));
		    result[i] =
		        min(dist(here, rS, rSrT),
		        min(dist(here, rS, rSlT),
		        min(dist(here, lS, lSrT),
		        min(dist(here, lS, lSlT),
		        min(dist(here, rT, rTrS),
		        min(dist(here, rT, rTlS),
		        min(dist(here, lT, lTrS),
		        dist(here, lT, lTlS))))))));
		}

		// 出力
		for(int i = 0; i < q; i++){
		    System.out.println(result[i]);
		}
        
	}
	static long dist(long here, Long first, Long second){
	    if(first == null || second == null) return Long.MAX_VALUE;
	    return abs(first - here) + abs(second - first);
	}
}


Measured memory_bytes: 117668
#include <iostream>

using namespace std;

int main(void) {
    uint64_t N,sum = 0;
    uint64_t l3, l5, l15, n15;

    cin >> N;

    l3 = (N / 3) * 3;
    l5 = (N / 5) * 5;
    l15 = (N / 15) * 15;

    sum = (N * (N + 1)) / 2;

    sum -= ((N / 3) * (3 + l3)) / 2;
    sum -= ((N / 5) * (5 + l5)) / 2;
    sum += ((N / 15) * (15 + l15)) / 2;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3592
//#include "bits/stdc++.h"

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	double a, b, C;
	cin >> a >> b >> C;

	double S, L, h;
	S = 0.5 * a * b * sin(M_PI * C / 180);
	L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(M_PI * C / 180));
	h = 2 * S / a;

	cout << fixed << setprecision(6);
	cout << S << endl;
	cout << L << endl;
	cout << h << endl;
	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



Measured memory_bytes: 3480
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16
 
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

vi spf(1000001,0),lpf(1000001,0);

void solve()
{
    int n,m,t,i,k,r,l,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T; 
    int d;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    int gcd=a[0];
    bool setwise=false;
    rep(i,0,n)
    {
        gcd=__gcd(a[i],gcd);
    }
    if(gcd==1) setwise=true;
    map<int,int> cnt,cnt2;
    bool pairwise=true;
    rep(i,0,n) 
    {
        cnt[spf[a[i]]]++;
        cnt2[lpf[a[i]]]++;
        if(cnt[spf[a[i]]]>1&&a[i]!=1) pairwise=false;
        if(a[i]!=1&&cnt2[lpf[a[i]]]>1) pairwise=false;
    }
    if(pairwise) cout<<"pairwise coprime";
    else if(setwise) cout<<"setwise coprime";
    else cout<<"not coprime";
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    for(int i=1;i<1000001;i++)
    {
        if(i==1) {spf[i]=1;lpf[i]=1;continue;}
        if(!spf[i])
        {
            spf[i]=i;
            for(int j=i*i;j<1000001;j+=i) spf[j]=i;
        }
        lpf[i]=i/spf[i];
        if(lpf[i]==1) lpf[i]=i;
    }
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 43780
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;
ll l = 1000000000;

int main(){
    ll n; cin >> n;
    vll p(n);
    rep(i, 0, n){
        cin >> p[i];
    }
    vll sum(n);
    rep(i, 0, n){
        sum[p[i]-1] = l-n+i;
    }
    vll a(n), b(n);
    ll f = 1;
    rep(i, 0, n){
        a[i] = f;
        f += n;
        b[i] = sum[i] - a[i];
    }
    rep(i, 0, n){
        prt(a[i]); prt(" ");
    }
    prt(endl);
    rep(i, 0, n){
        prt(b[i]); prt(" ");
    }
}



Measured memory_bytes: 3876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 599) {
			System.out.println(8);
		} else if (x <= 799) {
			System.out.println(7);
		} else if (x <= 999) {
			System.out.println(6);
		} else if (x <= 1199) {
			System.out.println(5);
		} else if (x <= 1399) {
			System.out.println(4);
		} else if (x <= 1599) {
			System.out.println(3);
		} else if (x <= 1799) {
			System.out.println(2);
		} else if (x<= 1999) {
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 35832
package main

import "fmt"

func main() {
	mp := make(map[string]int)
	var n, m int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		mp[s]++
	}
	fmt.Scan(&m)
	for i := 0; i < m; i++ {
		var s string
		fmt.Scan(&s)
		mp[s]--
	}

	max := 0
	for _, v := range mp {
		if v > max {
			max = v
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!

a,b,c=map(int,input().split())
i=0
p=max(a,b,c)
while True:
    if p%2!=(a+b+c)%2:
        p+=1
    else:
        break
print((3*p-(a+b+c))//2)

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

typedef long long LL;

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

    vector<pair<LL, int> > dvs;//配对<质数, 幂次>

    //质因数分解
    for (LL i=2; i*i<=n; i++) {
        if (0==n%i) {
            dvs.push_back(make_pair(i, 0));
            while (0==n%i) {
                dvs.back().second++;
                n /= i;
            }
        }
    }
    if (n>1) {
        dvs.push_back(make_pair(n, 1));
    }

    //遍历
    int ans = 0;
    for (pair<LL, int> &p : dvs) {
        int i;
        for (i=1; (i+1)*i/2<=p.second; i++);
        i--;
        ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
from math import log2

N,K = [int(i) for i in input().split()]
prob = 0
for i in range(1,N+1):
    j = 0
    while 2**(j) * i < K:
        j += 1
    prob += (1/N) * (0.5)**j
    # print((1/N) * (0.5)**j, j)
print(prob)

Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int  a[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
string s;
cin>>s;
for(int i=0;i<s.size();i++)cout<<"x";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

map<string, bool> m;

string rev(string str) {
	reverse(str.begin(), str.end());
	return str;
}
int cnt2(string s) {
	if (m.find(s) != m.end()) return 0;
	m[s] = true;
	return 1;
}
int cnt(string s1, string s2) {
	return cnt2(s1+s2) + cnt2(s2+s1);
}
int count(string s1, string s2) {
	return cnt(s1, s2) + cnt(rev(s1), s2) + cnt(s1, rev(s2)) + cnt(rev(s1), rev(s2));
}
int f() {
	m.clear();
	string str; cin >> str;
	int ret = 0;
	for (int i = 1; i < str.size(); ++i) {
		ret += count(str.substr(0, i), str.substr(i, str.size()-i));
	}
	return ret;
}

int main() {
	int N; cin >> N;
	for (int t = 0; t < N; ++t) {
		cout << f() << endl;
	}
}

Measured memory_bytes: 1308
M = int(input())
d = [0] * M
c = [0] * M
for i in range(M):
    d[i], c[i] = map(int, input().split())

# print(d)
# print(c)

D = 0
S = 0
for i in range(M):
    D += c[i]
    S += d[i] * c[i]

# print(D, S)
print((D - 1) + (S - 1) // 9)


Measured memory_bytes: 47448
line = list(map(int,input().split()))
N = line[0]
M = line[1]
i=0
if M==0:
    print(N)
else:
    numbers = list(map(int,input().split()))
    while True:
        if bool(N-i in numbers)==0:
            print(N-i)
            break
        elif bool(N+i in numbers)==0:
            print(N+i)
            break
        i+=1

Measured memory_bytes: 9140
require 'set'

ok_set = Set.new %w(A T C G)

STDIN.each do |line|
  line.chomp!
  max_len = 0
  cnt = 0
  line.each_char do |ch|
    if ok_set.member?(ch)
      cnt += 1
      max_len = cnt if cnt > max_len
    else
      cnt = 0
    end
  end
  STDOUT.puts max_len
end

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

using namespace std;
#define ll long long
int main()
{
   int n;
   cin>>n;
   map<ll,ll>mp,mp1;
   ll ans=0;
   for (int i=0;i<n;i++)
   {
       ll a;
       cin>>a;
       ans+=mp[i-a];
       ans+=mp1[a+i];
       mp[a+i]++;
       mp1[i-a]++;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 48872
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long A[200001];

int main(){
	ios::sync_with_stdio(0);
	int N;
	long long count=0,now=0,l,r=0;
	cin>>N;
	for(int i=0;i<N;++i)cin>>A[i];
	for(l=0;l<N;++l){
		while(r<N&&(now^A[r])==now+A[r]){
			now^=A[r++];
			++count;
		}
		count+=r-l-1;
		now^=A[l];
	}
	cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int n,ans;
void dfs(long long x,int a,int b,int c){
    if(x>n)
        return ;
    if(a&&b&&c)
        ans++;
    dfs(10*x+3,a+1,b,c);
    dfs(10*x+5,a,b+1,c);
    dfs(10*x+7,a,b,c+1);
}
int main(){
    scanf("%d",&n);
    dfs(0,0,0,0);
    printf("%d\n",ans);


}


Measured memory_bytes: 256
def main():
	import sys
	input=sys.stdin.readline
	n=int(input())
	xy=[]
	node=[[]for _ in range(n)]
	for i in range(n):
		x,y=map(int,input().split())
		xy.append((i,x,y))
	xy.sort(key=lambda x:x[1])
	for i in range(len(xy)-1):
		node[xy[i][0]].append((abs(xy[i][1]-xy[i+1][1]),xy[i+1][0]))#dis,num
		node[xy[i+1][0]].append((abs(xy[i][1]-xy[i+1][1]),xy[i][0]))#dis,num
	xy.sort(key=lambda x:x[2])
	for i in range(len(xy)-1):
		node[xy[i][0]].append((abs(xy[i][2]-xy[i+1][2]),xy[i+1][0]))#dis,num
		node[xy[i+1][0]].append((abs(xy[i][2]-xy[i+1][2]),xy[i][0]))#dis,num
	from heapq import heappop,heappush
	visited=[False]*n
	visited[0]=True
	pq=[]
	for x in node[0]:
		heappush(pq,(x[0],x[1]))
	ans=0
	for _ in range(n-1):
		while True:
			u=heappop(pq)
			if visited[u[1]]==False:
				break
		ans+=u[0]
		pre_dis=u[0]
		u_dis=u[0];u_num=u[1]
		ans+=abs(u_dis-pre_dis)
		visited[u_num]=True
		for x in node[u_num]:
			x_dis=x[0];x_num=x[1]
			if visited[x_num]==False:
				heappush(pq,(x_dis,x_num))
	print(ans)
if __name__ == '__main__':
	main()

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  cin >> n;

  int tmp = 0;
  rep (i, 1, n + 1)
    if (i & 1)
      tmp++;
  cout << (double)tmp / n << endl;




	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string s;
    cin >> s;
    int count[30] = {};
    for (int i = 0; i < s.size(); i++) {
        count[s[i] - 'a']++;
    }
    for (int i = 0; i <= 'z' - 'a'; i++) {
        if (count[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double t = 0;
    for(int i = 0;i<n;i++){
      t += 1/sc.nextDouble();
    }
    System.out.println(1/t);
  }
}


Measured memory_bytes: 38060
nm = gets.split(" ").map{|a| a.to_i}
n = nm[0]
m = nm[1]
xyz =[]
for i in (0..n-1)
xyz[i] = gets.split(" ").map{|a| a.to_i}
end


def sumsum(mm,nn,oo,i,j,k)
    if i != 0 then
      mm = -mm
    end
    if j != 0 then
      nn = -nn
    end
    if k != 0 then
      oo = -oo
    end
    return mm + nn + oo
end


def xyzsort(ary,i,j,k,nn)
  a=[]
  for l in (0..nn-1)
  a[l] = sumsum(ary[l][0],ary[l][1],ary[l][2],i,j,k)
  end
return a.sort
end

max = 0
array =[]

for i in(0..1)
  for j in(0..1)
    for k in(0..1)
array.push(xyzsort(xyz,i,j,k,n))
end
end
end
for j in (0..7)
  num = 0
for i in(1..m)
  num += array[j][-i]
end
if max < num
  max = num
end
end

puts max


Measured memory_bytes: 2040
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    if(x==1&&y==1){
       cout << 1000000 << endl;
       return 0;
    }
    int ans = 0;
    int t = x;
    if(t==3){
        ans+= 100000;
    }else if(t==2){
        ans+=200000;
    }else if(t==1){
        ans+=300000;
    }
    t = y;
    if(t==3){
        ans+= 100000;
    }else if(t==2){
        ans+=200000;
    }else if(t==1){
        ans+=300000;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
suu = list(
    "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(
        ", "
    )
)
k = int(input())
print(suu[k - 1])


Measured memory_bytes: 2940
#define DEBUG 0
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
#define pb push_back
#define all(v) v.begin(), v.end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define INF (1LL << 60)
#if DEBUG
#define dump(v1) dump_1(#v1, v1)
#define dump2(v1, v2) dump_2(#v1, v1, #v2, v2)
#define dump3(v1, v2, v3) dump_3(#v1, v1, #v2, v2, #v3, v3)
#else
#define dump(v1)
#define dump2(v1, v2)
#define dump3(v1, v2, v3)
#endif
#if DEBUG
template <typename T> void dump_1(const string &n1, const T &v1)
{
    cerr << n1 << ": " << v1 << endl;
}
template <typename T1, typename T2>
void dump_2(const string &n1, const T1 &v1, const string &n2, const T2 &v2)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << endl;
}
template <typename T1, typename T2, typename T3>
void dump_3(const string &n1, const T1 &v1, const string &n2, const T2 &v2,
            const string &n3, const T3 &v3)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << "  " << n3 << ": "
         << v3 << endl;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v)
{
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v)
{
    os << "(" << get<0>(v) << ", " << get<1>(v) << ", " << get<2>(v) << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "[";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "]";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "}";
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << it->first << ":" << it->second;
    }
    os << "}";
    return os;
}
#endif // DEBUG
void Yes(void) { cout << "Yes" << endl; }
void No(void) { cout << "No" << endl; }
void YES(void) { cout << "YES" << endl; }
void NO(void) { cout << "NO" << endl; }
template <typename T> void print(const T &v) { cout << v << endl; }
//---------------------------------------------------------

void solve()
{
    ll a, b;
    string op;
    cin >> a >> op >> b;
    if (op == "+") {
        print(a + b);
    }
    else {
        print(a - b);
    }
}

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


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

using namespace std;

const int MOD = 1000000007;
int n;
int arr[200100], lst[200100], D[200100];
vector<int> lis[200100];

int main() {
    int i;

    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&arr[i]);
    memset(lst,-1,sizeof(lst));

    for (i=0;i<n;i++) {
        D[i]=(i?D[i-1]:1);
        if (~lst[arr[i]]&&lst[arr[i]]!=i-1) {
            D[i]=(D[i]+D[lst[arr[i]]])%MOD;
        }
        lst[arr[i]]=i;
    }
    printf("%d\n",D[n-1]);

    return 0;
}


Measured memory_bytes: 7296
#include<iostream>

using namespace std;
int main()
{
	long long int money{};
	long long int max = 0,g1 = 0, g2 = 0;

	cin >> money;
	g1 = money / 500;
	money -= g1 * 500;
	g2 = money / 5;
	money -= g2 * 5;
	max = g1 * 1000 + g2 * 5;
	cout << max;
}

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

using namespace std;

typedef long long ll;
typedef long double K;
typedef pair<int, int> pii;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int inf = 2000000000;

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

    int a, b; 
    cin >> a >> b; 
    cout << (b >= a ? "unsafe" : "safe");
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  int total = A * A * B;
  double ans;
  if (X * 2 >= total) {
    // 半分以上の水
    double air = total - X;
    // A * A * A * tanθ * .5
    double tanTheta = air / (A * A * A * .5);
    ans = atan(tanTheta) * 180 / M_PI;
  } else {
    // A * B * B * tanθ * 0.5
    double tanTheta = X / (A * B * B * .5);
    ans = 90 - atan(tanTheta) * 180.0 / M_PI;
  }
  printf("%.8f\n", ans);
  return 0;
}

Measured memory_bytes: 4008
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, P;
	string S;
	vector<pair<pair<string, int>, int> > PP;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S >> P;
		PP.push_back({ { S, 1000 - P }, i + 1 });
	}
	sort(PP.begin(), PP.end());
	for (int i = 0; i < N; i++) {
		cout << PP[i].second << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long K = sc.nextLong();
    
    if(K <= A){
      A -= K;
    }else{
      B -= (K - A);
      A = 0;
      if(B < 0) B = 0;
    }
    System.out.println(A + " " + B);
  }
}


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

int main()
{
    int count = 0;
    string num;
    cin >> num;

    for (int i = 0; i < (int)num.size(); ++i)
    {
        if (num[i] == '1')
        {
            count++;
        }
        else
        {
        }
    }
    cout << count;
}

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

int main(){
  int N, D; cin >> N >> D;
  int X[N][D];
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> X[i][j];
    }
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int sum = 0;
      for(int k=0; k<D; k++){
        sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      if(sum == int(sqrt(sum)) * int(sqrt(sum))){
        ans++;
      }
    }
  }
  cout << ans << endl;
  
 return 0; 
}


Measured memory_bytes: 256
N, W = map(int, input().split())
app = [list(map(int, input().split())) for i in range(N)]

data = [[] for i in range(4)]

for w, v in app:
    if w == app[0][0]:
        data[0].append(v)
    elif w == app[0][0] + 1:
        data[1].append(v)
    elif w == app[0][0] + 2:
        data[2].append(v)
    elif w == app[0][0] + 3:
        data[3].append(v)

for i in range(4):
    data[i].sort(reverse=True)

for i in range(4):
    for j in range(len(data[i])-1):
        data[i][j+1] += data[i][j]

for i in range(4):
    data[i].append(0)
    data[i].sort()

ans = 0
for a in range(len(data[0])):
    for b in range(len(data[1])):
        for c in range(len(data[2])):
            for d in range(len(data[3])):
                if a * app[0][0] + b * (app[0][0]+1) + c * (app[0][0]+2) + d * (app[0][0]+3) <= W:
                    ans = max(ans, data[0][a] + data[1][b] + data[2][c] + data[3][d])

print(ans)

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int n; cin >> n;
    int ans = 0;

    REPI(i, n + 1){
        ans += i;
    }
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		long p = 1;
		long mod = 1000000007;
		for(var i=0;i<N;i++){
			p = p * (i+1) % mod;
		}
		Console.WriteLine(p);
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N;
  cin>>N;
  vector<ll>H(N);
  rep(i,N){
    cin>>H[i];
  }
ll sum=0;
  ll vast=0;
  for(ll i=0;i<N-1;i++){
    if(H[i]>=H[i+1]){
      sum++;
    }
        else{
vast=max(vast,sum);
          sum=0;
        }
if(i==N-2){
  vast=max(vast,sum);
    }
  }

       cout<<vast<<endl;
       }



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> idx(n+1);
  rep(i,n) idx[a[i]]=i+1;
  
  multiset<int>st;
  st.insert(0);
  st.insert(0);
  st.insert(n+1);
  st.insert(n+1);
  //番兵
  
  ll ans = 0;
  for(int p=n;p>=1;p--){
    auto it = st.lower_bound(idx[p]);
    ll r1 = *it;
    
    it++;
    ll r2 = *it;
    
    it--;
    it--;
    ll l1 = *it;
    
    it--;
    ll l2 = *it;
    
    ll c = (r1-idx[p])*(l1-l2) + (r2-r1)*(idx[p]-l1);
    ans += c*p;
    
    st.insert(idx[p]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8712
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using ll = long long;
using namespace std;
int main() {
  	ll n, a, b;
  	cin >> n >> a >> b;
  	if (n*a > b) {
      	cout << b << endl;
    } else {
      	cout << n*a << endl;
    }
  
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 3e5;
LL boxes[N+1];
LL ans[N+1];
int main()
{
    LL n, a, b; cin >> n >> a >> b;
    if(!(a+b-1 <= n && n <= a*b))
        cout<<-1<<endl;
    else
    {
        boxes[a-1] = b;
        for(int i = 0; i < a-1; i++)
            boxes[i] = 1;

        for(int total = a+b-1, i = 0; total < n; total++, i = (i+1)%(a-1))
            boxes[i]++;

        int ctr = 0;
        for(int j = 0; j < a; j++)
        {
            for(int t = 0; t < boxes[j]; t++)
                ans[ctr+boxes[j]-t] = ctr+t;
            ctr += boxes[j];
        }
        for(int i = 1; i <= n; i++)
            cout<<ans[i]+1<<" ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long n,k;
long long fac[200010],inv[200010];
long long quick_pow(long long a,long long b)
{
	long long ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
long long C(long long x,long long y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	cin>>n>>k;
	fac[0]=1;
	inv[0]=1;
	for(int i=1;i<=n;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		inv[i]=quick_pow(fac[i],mod-2);
	}
	long long ans=1;
	int temp=min(n-1,k);
	for(long long i=1;i<=temp;i++)
	{
		long long sum=C(n,i);
		long long x=n-i;
		long long y=C(n-1,n-x);
		ans=(ans+sum*y%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll cnt=0;
    ll max_num = 0;
    for (int i=0; i<n; i++){
        cin >> a[i];
        ll s = a[i];
        if (s < max_num){
            cnt += max_num - s;
        }
        max_num = max(max_num,s);


    }
    cout << cnt << endl;
    


    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // Tenka1 Programmer Beginner Contest 2019 B - *e**** ********e* *e****e* ****e**
  int N; cin >> N;
  string S; cin >> S;
  int K; cin >> K;
  string ans = "", p = S.substr(K-1, 1);
  REP(i, N){
    if(S[i] != S[K-1]){
      ans += "*";
    }else{
      ans += p;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    char s[800];
    int a[200];
    int i=0,p=-1;
    cin.getline(s,800);
    while(s[i]!='\0')
    {
        if(s[i]==' ')
        {
            ++i;
        }
        else if(s[i]=='+')
        {
            a[p-1] += a[p];
            --p;
            ++i;
        }
        else if(s[i]=='-')
        {
            a[p-1] -= a[p];
            --p;
            ++i;
        }
        else if(s[i]=='*')
        {
            a[p-1] *= a[p];
            --p;
            ++i;
        }
        else
        {
            a[p+1] = atoi(&s[i]);
            ++p;
            while(s[i]<='9'&&s[i]>='0')
                ++i;
        }
    }
    cout<<a[0]<<endl;
    return 0;
}

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

int n,h[100005],dp[100005];

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)    scanf("%d",h+i);
    dp[1] = max(h[1],h[0])-min(h[1],h[0]);
    for(int i=2;i<n;++i)
        dp[i] = min(dp[i-1]+max(h[i],h[i-1])-min(h[i],h[i-1]) , dp[i-2]+max(h[i],h[i-2])-min(h[i],h[i-2]));
    printf("%d",dp[n-1]);
    return 0;
}


Measured memory_bytes: 1024
import math
#minH=6deg/min
#HrH=30deg/hr=0.5degree/min
    ##angle by minH=6*M
    ##angle by HrH=30*H
    ##angle=abs(minH-HrH)
A,B,H,M=map(int,input().strip().split())
minH=6*M
HrH=0.5*(H*60+M)
Ang=abs(HrH-minH)
#print(math.cos((math.pi/180)*Ang))
Ans=math.sqrt(A**2+B**2-2*A*B*math.cos((math.pi/180)*Ang))
Ans=str(Ans)
if "." in Ans:
    intg=Ans.split(".")[0]
    decimal=Ans.split(".")[1]
    if len(decimal)<9:
      print(intg+"."+decimal+"0"*(9-len(decimal)))
    else:
      print(intg+"."+decimal[:9])
else:
   print(Ans+"."+"0"*9)

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

const int N = 200010;

char str1[N], str2[N];
int n;

int main() {

    int n1, n2, x1, x2;
    scanf("%d%d%d", &n1, &n2, &n);
    scanf("%d%d", &x1, &x2);
    scanf("%s%s", str1 + 1, str2 + 1);

    bool f = 1;
    int L = 0, R = n1 + 1;
    for(int i = n; i >= 1; i--) {

        if(str2[i] == 'L' || str2[i] == 'R') {

        }
        else if(str2[i] == 'D') {
            L = std::max(L - 1, 0);
        }
        else {
            R = std::min(R + 1, n1 + 1);
        }

        if(str1[i] == 'L' || str1[i] == 'R') {

        }
        else if(str1[i] == 'D') {
            R = R - 1;
        }
        else {
            L = L + 1;
        }
        if(L + 1 >= R) {
            f = 0;
            break;
        }

    }
    if(x1 <= L || R <= x1) {
        f = 0;
    }
    L = 0, R = n2 + 1;
    for(int i = n; i >= 1 && f; i--) {

        if(str2[i] == 'U' || str2[i] == 'D') {

        }
        else if(str2[i] == 'L') {
            R = std::min(R + 1, n2 + 1);
        }
        else {
            L = std::max(L - 1, 0);
        }

        if(str1[i] == 'U' || str1[i] == 'D') {

        }
        else if(str1[i] == 'L') {
            L = L + 1;
        }
        else {
            R = R - 1;
        }
        if(L + 1 >= R) {
            f = 0;
            break;
        }

    }
    if(x2 <= L || R <= x2) {
        f = 0;
    }
    if(f) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector<ll> jbefore(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        jbefore[i] = jbefore[i - 1] + (s[i - 1] == 'J');
    }
    vector<ll> iafter(n + 1, 0);
    for(int i = n - 1; i >= 0; i--) {
        iafter[i] = iafter[i + 1] + (s[i] == 'I');
    }
    vector<ll> jobefore(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        jobefore[i] = jobefore[i - 1] + (s[i - 1] == 'O' ? jbefore[i] : 0);
    }
    vector<ll> oiafter(n + 1, 0);
    for(int i = n - 1; i >= 0; i--) {
        oiafter[i] = oiafter[i + 1] + (s[i] == 'O' ? iafter[i] : 0);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'O') {
            ans += jbefore[i] * iafter[i];
        }
    }
    ll best = 0;
    for(int i = 0; i <= n; i++) {
        best = max({best, oiafter[i], jbefore[i] * iafter[i], jobefore[i]});
    }
    cout << ans + best << endl;
    return 0;
}



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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 1e6 + 5, MOD = 1e9 + 7 , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
int g[3][3];
bool mark[3][3];
map<int,vector<pii> >mp;
int main(){

    fastio;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>g[i][j];
            mp[g[i][j]].pb(pii(i,j));
        }
    }
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        for(pii p: mp[x]) mark[p.ff][p.ss] = true;
    }

    bool ok = false;
    if(mark[0][0] && mark[0][1] && mark[0][2]) ok = true;
    if(mark[1][0] && mark[1][1] && mark[1][2]) ok = true;
    if(mark[2][0] && mark[2][1] && mark[2][2]) ok = true;

    if(mark[0][0] && mark[1][0] && mark[2][0]) ok = true;
    if(mark[0][1] && mark[1][1] && mark[2][1]) ok = true;
    if(mark[0][2] && mark[1][2] && mark[2][2]) ok = true;

    if(mark[0][0] && mark[1][1] && mark[2][2]) ok = true;
    if(mark[2][0] && mark[1][1] && mark[0][2]) ok = true;

    cout<< (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
//ProblemC.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemC.cpp

int main(int argc, char* argv[])
{
	OPENOJIO;

	string s;
	int k;

	ip >> s >> k;

	for (int i = 0; i < s.size() - 1; ++i) {
		if (s[i] == 'a'
			|| 'z' - s[i] >= k) {
			continue;
		}

		k -= 'z' - s[i] + 1;
		s[i] = 'a';
	}

	s[s.size() - 1] = (s[s.size() - 1] - 'a' + k) % 26 + 'a';
	op << s << endl;

	return 0;
}
/***************************************************************/


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e6+10;

int main(){
	LL a,b;
	cin>>a>>b;
	LL sum=b;
	while(b){
		a*=10;
		b/=10;
	}
	sum+=a;
	if((LL)sqrt(sum) == sqrt(sum)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

const int N = 1005;

int n, m, k;
char c[11][N];

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }

    int ans = 1e9;

    for (int mask = 0; mask < (1 << n); mask++) {
        int p[11];
        memset(p, 0, sizeof(p));
        int last = 0, ret = 0;
        for (int i = 0; i < n; i++) {
            if ((mask >> i) & 1)
                last = i, ret++;
            p[i + 1] = last + 1;
        }
        int s[11][N];
        memset(s, 0, sizeof(s));
        int mx = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                int val = c[j][i] - '0';
                s[ p[j] ][ i ] += val;
                mx = max(mx, s[ p[j] ][i]);
            }
        }
        if (mx > k) continue;
        for (int i = 1; i <= m; i++) {
            bool ok = 1;
            for (int j = 1; j <= n; j++) {
                if (s[j][i] + s[j][i - 1] > k)
                    ok = 0;
            }
            if (ok) {
                for (int j = 1; j <= n; j++) {
                    s[j][i] += s[j][i - 1];
                }
            } else {
                ret++;
            }
        }
        ans = min(ans, ret);
    }

    cout << ans << endl;
}


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


class dice {
public:
	dice(int* a) {
		set(a[0], a[1], a[2], a[3], a[4], a[5]);
	}
	dice(int& a, int& b, int& c, int& d, int &e, int& f) {
		set(a, b, c, d, e, f);
	}
	void turn(int n) {
		if (n < 4)
		{
			turndice(n);
			return;
		}
		switch (n)
		{
		case 'N':
			turndice(0);
			break;
		case 'E':
			turndice(1);
			break;
		case 'S':
			turndice(2);
			break;
		case 'W':
			turndice(3);
			break;
		}

	}

	void turn(const char* str)
	{
		for (size_t i = 0; str[i] != '\0' ; i++)
		{
			turn(str[i]);
		}
	}

	int getcurrent(int n = 0) { return label[n]; }

	int topfronttoright(const int & top, const int & front) {
		char n3[] = { "NES" };
		const char ne[][3] = { "N","N","N","E","EE" };

		for (size_t i = 0; i < 6; i++)
		{
			if (top == getcurrent())
				for (size_t j = 0; j < 4; j++)
				{
					if (front == getcurrent(1))
					{		
						return  getcurrent(2);
					}
					turn(n3);
				}
			turn(ne[i]);
		}

		return 0;
	}

private:

	int label[6];

	void set(int& a, int& b, int& c, int& d, int &e, int& f) {
		label[0] = a; 
		label[1] = b; 
		label[2] = c; 
		label[3] = d; 
		label[4] = e; 
		label[5] = f; 
	}
	void turndice(int n)
	{
		int m = (n > 1) ? n - 2 : n + 2;
		int f[] = { 1, 3, 4, 2 };
		int tmp;

		tmp = label[0];
		label[0] = label[f[n]];
		label[f[n]] = label[5];
		label[5] = label[f[m]];
		label[f[m]] = tmp;
	}

};

#define B

#ifdef B

int main(void)
{
	int label[6];
	int n;
	for (auto &a : label)
	{
		cin >> a;
	}
	dice d(label);
	cin >> n;
	vector<int> ans(n);
	for (auto &a : ans)
	{
		int top, frnt;
		cin >> top >> frnt;
		a = d.topfronttoright(top, frnt);
	

	}

	for (auto a : ans)
	{
		cout << a << endl;
	}
	return 0;
}

#endif // B

Measured memory_bytes: 3108