akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;

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

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

vector<string> split(const string& src, const char* delim = ":") {
    vector<string> vec;
    string::size_type len = src.length();
    
    for (string::size_type i = 0, n; i < len; i = n + 1) {
        n = src.find_first_of(delim, i);
        if (n == string::npos) {
            n = len;
        }
        vec.push_back(src.substr(i, n - i));
    }
    
    return vec;
}

bool lengthComp(const std::string& x, const std::string& y) {
    return x.length() < y.length();
}

int main(int argc, char *argv[]){
    //ll result = 0;
    ll N;
    cin >> N;
    vector<tuple<string, ll, ll>> rest;
    rep(i, N){
        string s;
        ll p;
        cin >> s >> p;
        p = -p;
        rest.push_back(tie(s, p, i));
    }
    sort(ALL(rest));
    
    rep(i, N){
        cout << get<2>(rest[i])+1 << endl;
    }
    
    //cout << result << endl;
}


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

int main() {
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
#define N 100005


int main(){
   
   list <char> s;
   string f;
   cin>>f;
   int n  = size(f);
   for(int i=0;i<n;i++)
   {
   	  s.push_back(f[i]);
   }
   ll q;
   cin>>q;
   int flag = 1 ;         
   while(q--)
   {
   	    int t;
   	    cin>>t;
   	    if(t==1)
   	    {
             flag = 1-flag;
   	    }
   	    else
   	    {
            int f;
            char x;
            cin>>f>>x;
            f = f%2;           // f = 0 , end

            f = f^flag;

            if(f) 
            {
                s.push_back(x);
            }
            else
            {
                s.push_front(x);
            }

   	    }
   	   
   }

   string ans;
   for(auto it:s) ans.pb(it);
   	if(!flag)
   	{
   		 reverse(all(ans));
   	}
   	cout<<ans<<endl;
}



Measured memory_bytes: 10500
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=ans=0
for i in range(n):
    a=list(map(int,input().split()))
    for o in range(m):
        count+=a[o]*b[o]
    if count+c>0:
        ans+=1
    count=0

print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std ;
int main()
{
int a[10] ;
while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]>>a[8]>>a[9]){
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10-1;j++)
        {
            if(a[j+1]>a[j])
            {
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
        cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl;  
  }
    
}

Measured memory_bytes: 1160
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}




int main() {
	ll K;
	cin >> K;
	cout << 50 << endl;
	vector<ll> A(50, 49+K/50);
	rep(i, K % 50) {
		rep(j, 50) {
			if (j == i)A[j] += 50;
			else A[j]--;
		}
	}
	rep(i, 50) {
		cout << A[i] << " ";
	}
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v;
  for(int i = 0; i < n; i++){
    int data = i + 1;
    int count = 0;
    while(data % 2 == 0){
      data /= 2;
      count++;
    }
    v.push_back(count);
  }
  
  auto iter = max_element(v.begin(), v.end());
  size_t index = distance(v.begin(), iter);
  
  cout << index + 1 << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    L = [int(a) for a in input().split()]

    ans = 0

    for i in range(len(L) - 2):
        for j in range(i + 1, len(L) - 1):
            for k in range(j + 1, len(L)):
                if L[i] < L[j] + L[k] and L[j] < L[i] + L[k] and L[k] < L[i] + L[j] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
n,k = map(int,input().split())
ans = 0
def two(x,y):
    for i in range(0,10**9):
        if x >= y:
            return i
        x *= 2
        
for i in range(1,n+1):
    tmp = 1/n
    pro = two(i,k)
    if pro:
        tmp *= (1/2)**pro
    else:
        pass
    ans += tmp
print(ans)

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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int H,W,K;
    cin>>H>>W>>K;
    char arr[H][W];
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        cin>>arr[i][j];
    }
    int ans=0;
    for(int r=0;r< pow(2,H);r++)
    {
        
        for(int c=0;c < pow(2,W); c++)
        {
            int b=0;
            for(int ri=0; ri<H; ri++)
            {
                
                for(int ci=0;ci<W;ci++)
                {
                    if(((r & 1<<ri)==0) && ((c & 1<<ci)==0))
                    {
                        if(arr[ri][ci]=='#')
                        b++;
                    }
                }
            }
            if(b==K)
            ans++;
        }
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,t,a[1000];
    float s,to=0;
    cin>>t;
    for(i=0;i<t;i++){
        cin>>a[i];
        s=1/(a[i]*1.00);
        to+=s;
    }
    cout<<1/to;
    return 0;
}


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

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

const int N = 2e5 + 5;

int n, m, k, par[N], a[N], b[N];
map <pii, int> mp;

int root(int v) {
	return ((par[v] == v)? v : par[v] = root(par[v]));
}

void merge(int v, int u) {
	v = root(v), u = root(u);
	if(v == u)
		return;
	par[v] = u;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k >> m;
	for (int i = 0; i < n; i++)
		par[i] = i;
	for (int i = 0; i < k; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		merge(v, u);
	}
	for (int i = 0; i < n; i++)
		a[i] = root(i);
	for (int i = 0; i < n; i++)
		par[i] = i;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		merge(v, u);
	}
	for (int i = 0; i < n; i++) {
		b[i] = root(i);
		mp[make_pair(a[i], b[i])]++;
	}
	for (int i = 0; i < n; i++)
		cout << mp[make_pair(a[i], b[i])] << " ";
	cout << "\n";
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N ; cin >> N;
	string str;
	cin >> str;
	
	vector<int> left(26, 0);
	vector<int> right(26,0);

	for(auto c : str) 
	{
		++right[c - 'a'];
	}
	
	int ret = 0;
	int tmp = 0;
	for(auto c : str)
	{
		int n1 = ++left[c - 'a'];
		int n2 = --right[c - 'a'];

		if(n1 == 1 && n2 > 0)
			++tmp;
		else if(n1 > 1 && n2 == 0)
			--tmp;
		ret = max(ret, tmp);
	}
	cout << ret;
	return 0;
}


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

        signed main() {
            int n;
            cin>>n;
            int p[n],q[n];
            for(int i=0;i<n;i++)cin>>p[i];
            for(int i=0;i<n;i++)cin>>q[i];
            int pn=0,qn=0;
            int m=1;for(int i=0;i<n;i++)m*=(i+1);
            for(int i=0;i<n;i++){
                m/=(n-i);
                pn+=m*(p[i]-1);
                qn+=m*(q[i]-1);
            //    cerr<<qn<<' '<<pn<<endl;
                for(int j=i+1;j<n;j++){
                    if(p[j]>p[i])p[j]--;
                    if(q[j]>q[i])q[j]--;
                }
            }
            
            cout<<abs(qn-pn);
         return 0;

        }


Measured memory_bytes: 256
#include<bits/stdc++.h>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  vector<ll> dp(n + 1);
 
  for(int i = 0; i < m; i++){
    int lost; cin >> lost;
    a[lost] = 1;
  }

  if(a[n - 1] == 1) dp[n - 1] = 0;
  else dp[n - 1] = 1;
  dp[n] = 1;
  for (int i = n - 2; i >= 0; i--)
  {
    if(a[i] == 1){
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
  }
  
  cout << dp[0] << endl;
}


Measured memory_bytes: 1408
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))
ans, diff = 0, 10**9
for i, h in enumerate(H):
  temp = t - h*0.006
  if abs(a - temp) < diff:
    diff = abs(a - temp)
    ans = i+1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

vector<ll> len;
vector<ll> np;

ll solve(ll n, ll x){
    if(n == 0){
        return (ll)(x > 0);
    }

    if(x < len.at(n - 1) + 2){
        return solve(n - 1, x - 1);
    }else if(x == len.at(n - 1) + 2){
        return np.at(n - 1) + 1;
    }else{ // x < len.at(n) - 1
        return np.at(n - 1) + 1 +
            solve(n - 1, x - len.at(n - 1) - 2);
    }
}

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

    len.resize(n + 1, 0);
    np.resize(n + 1, 0);
    len.at(0) = 1;
    np.at(0) = 1;
    for(int i = 1; i <= n; ++i){
        len.at(i) = 2 * len.at(i - 1) + 3;
        np.at(i) = 2 * np.at(i - 1) + 1;
    }

    cout << solve(n, x) << endl;
    return 0;
}


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

int main() {
  string S; cin>>S;
  int N=S.size();
  int K; cin>>K;
  ll dp[101][2][5];
  rep(i, 101) rep(j, 2) rep(k, 5) dp[i][j][k]=0;
  dp[0][0][0]=1;  
  rep(i, N) {
    int D=S[i]-'0';
    rep(smaller, 2) {
      rep(k, K+1) {
        for (int d=0; d<=(smaller ? 9 : D); d++) {
          if (d!=0) dp[i+1][smaller||(d<D)][k+1]+=dp[i][smaller][k];
          else dp[i+1][smaller||(d<D)][k]+=dp[i][smaller][k];
        }
      }
    }
  }
  cout<<dp[N][0][K]+dp[N][1][K]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

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

  bool tf=false;

  for(int i = 0; i < N; ++i){
    char arare;
    cin >> arare;
    if(arare=='Y')tf=true;
  }
  if(tf){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}



Measured memory_bytes: 3528
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string a,b;
int main(){
	cin>>a>>b;
 	for(int i=0;i<a.size();i++){
 		putchar(a[i]);
 		if(b[i])putchar(b[i]);
	}
	puts("");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int d = 100;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int c = 0;
    while (A % 2 == 0) {
      c++;
      A /= 2;
    }
    d = min (c, d);
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int main() {
    int n;
    const int N = 1000000;
    int dp1[1000000];
    int dp2[1000000];

    rep(i,0,N) dp1[i] = dp2[i] = i;

    int val = 1;
    for(int i = 1; val <= N; i++) {
        for(int j=0; j+val <= N; j++) {
            dp1[j+val] = min(dp1[j+val], dp1[j] + 1);
            if(val%2 == 1) dp2[j+val] = min(dp2[j+val], dp2[j] + 1);
        }
        val = i * (i+1) * (i+2) / 6;
    }

    while(cin >> n) {
        if(n == 0) break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 8972
N, M = map(int, input().split())
Inf = 10**8
Dp = [Inf]*(2**N)
Dp[0] = 0

for i in range(M): #カギiで
    a,_=map(int, input().split())
    d = sum((1<<p-1) for p in list(map(int, input().split()))) #iで開けられる宝箱の2bit表記
    for j in range(2**N):
        ope = j|d
        Dp[ope] = min(Dp[ope], Dp[j] + a)

if Dp[-1] == Inf:
    print(-1)
else:
    print(Dp[-1])

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long h = long.Parse(ReadLine());
            if (h == 1)
            {
                WriteLine(1);
                return;
            }

            int cnt = 0;
            while (h >= 2)
            {
                cnt++;
                h /= 2;
            }

            long ans = 1;
            for (int i = 1; i <= cnt; i++)
            {
                ans += (long)Pow(2, i);
            }

            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
function main()
	a = parse.(Int,readline())
	b = parse.(Int,readline())
	c = parse.(Int,readline())
	x = parse.(Int,readline())

	cnt=0
	for i=0:a
		for j=0:b
			for k=0:c
				if x == 500i+100j+50k
					cnt+=1
				end
			end
		end
	end
	println(cnt)
end

main()

Measured memory_bytes: 163064
package main

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	N := sc.NextInt()

	s := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		s[i] = int(S[i] - 'a')
	}
	for i := 0; i < len(s) - 1; i++ {
		if s[i] == 0 {
			continue
		}
		if 26 - s[i] <= N {
			N -= 26 - s[i]
			s[i] = 0
		}
	}
	p := len(s) - 1

	s[p] += N
	s[p] %= 26
	for i := 0; i < len(s); i++ {
		fmt.Print(string(s[i] + 'a'))
	}
	fmt.Println()

}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#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()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n;
    cin >> n;
    
    int sum = 0;
    REP(i, n) sum += i+1;

    cout << sum << endl;
    
}

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

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

Measured memory_bytes: 6428
N = input()
l = list(map(int,N))
i = 0
#ans = l[0] - 1 + (len(l)-1)*9 #暫定の答え

if int(N) < 9:
    ans  = int(N)

elif l.count(9) >= len(l)-1:
    if l[len(l)-1] != 9:
        spot = 8
    else:
        spot = min(l)
    ans = spot + (len(l)-1)*9

else:
    while True:
        if l[i] < 9 and i < len(l)-1:
            spot = l[i] - 1
            break
        else:
            i += 1 
    ans = spot + (len(l)-1)*9

print(ans)


Measured memory_bytes: 9108
#=============================================================================
# パナソニックコンテスト D
#=============================================================================
import sys
sys.setrecursionlimit(10**8)
N=int(input())
abc=list("abcdefghij")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)


Measured memory_bytes: 4404
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int a,b;
  cin >> a >> b;
  cout << a/b << " " << a%b << " ";
  cout << fixed << setprecision(10) << (double)a/b << endl;
  return 0;
}



Measured memory_bytes: 3296
import math
a,b,C = map(float,input().split())
C_rad=math.pi*C/180
print("{0:.8f}".format(math.sin(C_rad)*a*b/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C_rad))))
print("{0:.8f}".format(b*math.sin(C_rad)))


Measured memory_bytes: 5700
a,b = gets.split.map(&:to_i)
if a <= 0 && 0 <= b
  puts "Zero"
elsif a < 0 && b < 0
  if (b-a+1)%2 == 0
    puts "Positive"
  else
    puts "Negative"
  end
else
  puts "Positive"
end


Measured memory_bytes: 1788
import sys


def main():
    K = int(input())
    A, B = map(int, input().split())

    for i in range(A // K - 1, B // K + 1):
        if A <= K * i <= B:
            print('OK')
            sys.exit(0)

    print('NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61700
import           Control.Exception (assert)
import           Control.Monad     (replicateM)
import           Data.List         (sort)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  sss <- replicateM m $ do
    k : ss <- map read . words <$> getLine
    assert (length ss == k) $
      pure ss
  ps <- map read . words <$> getLine
  assert (length ps == m) $
    print $ solve n $ zip ps sss

type Switch = Int
type Parity = Int
type BulbSetting = (Parity, [Switch])
type Bulb = [Bool] -> Bool

solve :: Int -> [BulbSetting] -> Int
solve n bulbSettings =
  length $
  filter id $
  map (\state -> all ($ state) bulbs) allStates
  where
    allStates = replicateM n [False, True]
    bulbs = map makeBulb bulbSettings

makeBulb :: BulbSetting -> Bulb
makeBulb (parity, switches) state =
  length (filter id (takes (map pred (sort switches)) state)) `mod` 2 == parity

takes :: [Int] -> [a] -> [a]
takes []     _      = []
takes _      []     = []
takes (0:is) (x:xs) = x : takes (map pred is) xs
takes is     (_:xs) = takes (map pred is) xs


Measured memory_bytes: 1020
/*  4_2
    Y_Aizaki    */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265359

/* プロトタイプ宣言 */
double radian(double hour_date, double minute_date);
double handDistance(double rad_date, double len_date1, double len_date2);

int main(void){
    double len_hour, len_minute, hour, minute;
    // 時針の長さ、分針の長さ、~時、~分
    scanf("%lf%lf%lf%lf", &len_hour, &len_minute, &hour, &minute);

    double rad;
    // 針間の角度
    rad = radian(hour, minute);

    double ans;
    // answer
    ans = handDistance(rad, len_hour, len_minute);
    printf("%.10f\n", ans);

    return 0;

}

double radian(double hour_date, double minute_date){
    double rad_hour, rad_minute, rad;

    rad_hour = (PI / 6.0) * hour_date + (PI / 360.0) * minute_date;
    rad_minute = (PI / 30.0) * minute_date;
    rad = rad_hour - rad_minute;
    
    return rad;
    // radが負であったり、PIより大きい場合もあるが、後の余弦定理で用いる点で支障はない

}

double handDistance(double rad_date, double len_date1, double len_date2){
    double distance;
    distance = sqrt(pow(len_date1, 2.0) + pow(len_date2, 2.0) - 2.0 * len_date1 * len_date2 * cos(rad_date));

    return distance;
}


Measured memory_bytes: 2464
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    string str;
    cin >> str;

    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(str[i] == str[j]){
                dp[i+1][j+1] = min((ll)j - (ll)i,dp[i][j] + 1LL);
            }
        }
    }

    ll ans = 0;

    for(int i = 0; i < n+1; i++){
        for(int j = 0; j < n+1; j++){
            ans = max(ans,dp[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << a+b+c-max({a,b,c}) << endl;
	return;
}

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


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    lol min = INF;
    lol a;
    REP(i, n)
    {
        cin >> a;
        if(a < min)
        {
            min = a;
            result++;
        }
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3636
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<string>
#include<iomanip>
#include<vector>
#include<string>
#include<stack>
#include<tuple>
#include<algorithm>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()


const int dr[] = {0,1,0,-1};
const int dc1[] = {1,0,-1,0 };
const int dc2[] = { -1,0,1,0 };

vector<string> wrap(vector<string> in,char c) {
	int R = in.size();
	int C = in[0].size();
	vector<string> out(R + 2, string(C + 2, c));
	REP(i, R)REP(j, C)out[i + 1][j + 1] = in[i][j];
	return out;

}
typedef tuple<int, int, int, int> T;
inline int f(int a, int b, int c, int d) {
	return ((a * 55 + b) * 55 + c) * 55 + d;
}
int dp[55 * 55 * 55 * 55];
int main() {
	int R, C;
	while (cin >> C >> R, R + C) {
		vector<string> A(R), B(R);
		REP(i, R) {
			cin >> A[i] >> B[i];
		}
		A = wrap(A, '#');
		B = wrap(B, '#');
		int asr, asc, bsr, bsc;
		int agr, agc, bgr, bgc;

		R += 2;
		C += 2;
		REP(a, R)REP(b, C)REP(c, R)REP(d, C)dp[f(a,b,c,d)] = 0;
		REP(i, R)REP(j, C)if (A[i][j] == 'L') { asr = i, asc = j; }
		REP(i, R)REP(j, C)if (B[i][j] == 'R') { bsr = i, bsc = j; }
		REP(i, R)REP(j, C)if (A[i][j] == '%') { agr = i, agc = j; }
		REP(i, R)REP(j, C)if (B[i][j] == '%') { bgr = i, bgc = j; }
		stack<T> st;
		st.push(T(asr, asc, bsr, bsc));
		dp[f(asr, asc, bsr, bsc)] = 1;
		while (st.size()) {
			int ar, ac, br, bc;
			tie(ar, ac, br, bc) = st.top();
			st.pop();
			REP(i, 4) {
				int nar = ar + dr[i];
				int nac = ac + dc1[i];
				int nbr = br + dr[i];
				int nbc = bc + dc2[i];
				if (A[nar][nac] == '#') { nar = ar, nac = ac; }
				if (B[nbr][nbc] == '#') { nbr = br, nbc = bc; }
				if (A[nar][nac] == '%') {
					if (B[nbr][nbc] != '%')continue;
				}
				if (B[nbr][nbc] == '%') {
					if (A[nar][nac] != '%')continue;
				}
				if (dp[f(nar, nac, nbr, nbc)])continue;
				dp[f(nar, nac, nbr, nbc)]=1;
				st.push(T(nar, nac, nbr, nbc));
			}

		}
		if (dp[f(agr, agc, bgr, bgc)])cout << "Yes" << endl;
		else cout << "No" << endl;

	}
	return 0;
}

Measured memory_bytes: 53072
import itertools
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))

dp = []
for i in itertools.product([0, 1], repeat=n):
    tmp = 0
    for j in range(n):
        tmp += A[j] * i[j]
    dp.append(tmp)

for i in M:
    if i in dp:
        print('yes')
    else:print('no')


Measured memory_bytes: 43092
using System;
using System.Linq;

namespace _003_IsitaRightTriangle
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int inputCount = int.Parse (Console.ReadLine ());
			int[,] numArray = new int[inputCount, 3];

			for (int lp = 0; lp < numArray.GetLength (0); lp++)
			{
				int[] inputNum = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();
				Array.Sort (inputNum);
				numArray[lp, 0] = inputNum[0];
				numArray[lp, 1] = inputNum[1];
				numArray[lp, 2] = inputNum[2];
			}

			//process
			for (int lp = 0; lp < numArray.GetLength (0); lp++)
			{
				bool isTriangle = numArray[lp, 0] * numArray[lp, 0] + numArray[lp, 1] * numArray[lp, 1] ==
					numArray[lp, 2] * numArray[lp, 2];

				if (isTriangle)
					Console.WriteLine ("YES");
				else
					Console.WriteLine ("NO");
			}
		}
	}
}

Measured memory_bytes: 9652
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	string a,b;
	cin >> a >> b;
	(a[0] == b[2] && a[1] == b[1] && a[2] == b[0])?cout << "YES" : cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=1e9+7;
using namespace std;
lli t,n,u,x,y,m;
const lli N = 100001;
int main(){
    fast
     t=1;
   // cin>>t;
    while(t--){
        cin>>n;
        lli dp[n+10];
        memset(dp,0,sizeof dp);
        dp[0]=1;
        for(int i=3;i<=n;++i){
            for(int j=3;j<=i;++j)
                dp[i]=(dp[i]+dp[i-j])%mod;
        }
        cout<<dp[n]<<endl;
        
    }
}

Measured memory_bytes: 3656
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<pll> uft;

ll parent(ll a){
    return uft[a].F==a?a:uft[a].F=parent(uft[a].F);
}

void merge(ll p,ll c){
    if(parent(p)==parent(c)){return;}
    uft[parent(p)].S+=uft[parent(c)].S;
    uft[parent(c)].F=parent(p);
}



int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> X(n);
    for(auto &I:X){cin>>I;}
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    
    uft.resize(n+m);
    for(int i=0;i<n;i++){
        uft[i]={i,X[i]};
    }
    for(int i=0;i<m;i++){
        uft[i+n]={i+n,0};
    }
    
    vector<pair<ll,pll>> edge(m);
    for(auto &I:edge){
        cin>>I.S.F>>I.S.S>>I.F;
        I.S.F--; I.S.S--;
    }
    sort(edge.begin(),edge.end());
    
    vector<pll> children(m,{-1,-1});
    vector<bool> used(m,false);
    
    for(int i=0;i<m;i++){
        if(parent(edge[i].S.F)==parent(edge[i].S.S)){continue;}
        used[i]=true;
        if(parent(edge[i].S.F)>=n && uft[parent(edge[i].S.F)].S<edge[parent(edge[i].S.F)-n].F){
            children[i].F=parent(edge[i].S.F)-n;
        }
        if(parent(edge[i].S.S)>=n && uft[parent(edge[i].S.S)].S<edge[parent(edge[i].S.S)-n].F){
            children[i].S=parent(edge[i].S.S)-n;
        }
        merge(i+n,edge[i].S.F);
        merge(i+n,edge[i].S.S);
    }
    
    if(uft[parent(0)].S<edge[parent(0)-n].F){
        queue<ll> Q;
        Q.push(parent(0)-n);
        while(!Q.empty()){
            ll w=Q.front(); Q.pop();
            used[w]=false;
            if(children[w].F!=-1){Q.push(children[w].F);}
            if(children[w].S!=-1){Q.push(children[w].S);}
        }
    }
    
    ll ans=0;
    for(int i=0;i<n;i++){
        uft[i]={i,X[i]};
    }
    for(int i=0;i<m;i++){
        if(used[i]){
            ans++;
            merge(edge[i].S.F,edge[i].S.S);
        }
    }
    for(int i=0;i<m;i++){
        if(!used[i]){
            if(parent(edge[i].S.F)==parent(edge[i].S.S) && uft[parent(edge[i].S.S)].S>=edge[i].F){
                ans++;
            }
        }
    }
    cout<<m-ans<<endl;
    
    
    
    return 0;
}


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

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

    vector<pair<int, bool>> ans1(N, (make_pair(0, false)));
    bool ans2 = true;
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        if (N != 1 && s == 1 && c == 0) {
            ans2 = false;
        }
        else if (ans1.at(s - 1).second && ans1.at(s - 1).first != c) {
            ans2 = false;
        }
        else {
            ans1.at(s - 1) = make_pair(c, true);
        }
    }

    if (N != 1 && ans1.at(0).first == 0) {
        ans1.at(0).first = 1;
    }

    if (ans2) {
        for (int i = 0; i < N; i++) {
            cout << ans1.at(i).first;
        }
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

end = []
start = []

if s[0] == "1":
	start.append(0)
else:
	#仮想的な1の区間を作る
	start.append(0)
	end.append(0)

for i in range(n-1):
	if s[i] == "1" and s[i+1] == "0":
		end.append(i)
for i in range(1, n):
	if s[i-1] == "0" and s[i] == "1":
		start.append(i)

if s[-1] == "1":
	end.append(n-1)
else:
	#仮想的な1の区間を作る
	start.append(n-1)
	end.append(n-1)

ans = 0

"""print(start, end, ans)
print(len(start), len(end), ans)"""

for j in range(len(start) - k):
	temp = end[j+k] - start[j] + 1 
	if temp > ans:
		ans = temp

if len(start) <= k:
	ans = n

print(ans)


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define int ll

int32_t main(){
    FAST
    int n; cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int ans = arr[n - 1]/2;
    for(int i = 0; i < n - 1; i++){
        ans += arr[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3528
H, W = map(int, input().split())

# 上下左右に余分に1マスとっとく
square = [[0 for _ in range(W)] for _ in range(H)]

for row in range(H):
	S = list(map(str, input()))
	for column in range(W):
		if S[column] == "#":
			# 下駄をはかせるの忘れない
			square[row][column] = -1
			
for row in range(H):
	done = [False for _ in range(W)]
	for column in range(W):
		if square[row][column] == -1: continue
		if done[column]: continue
		l = 1
		while column + l <= W - 1:
			if square[row][column + l] == -1: break
			l += 1
		for i in range(column, column + l):
			square[row][i] += l
			done[i] = True
			
for column in range(W):
	done = [False for _ in range(H)]
	for row in range(H):
		if square[row][column] == -1: continue
		if done[row]: continue
		l = 1
		while row + l <= H - 1:
			if square[row + l][column] == -1: break
			l += 1
		for i in range(row, row + l):
			square[i][column] += l
			done[i] = True

ret = 0			
for row in range(H):
	for column in range(W):
		ret = max(ret, square[row][column] - 1)
		
		
print(ret)

Measured memory_bytes: 97244
#include <bits/stdc++.h>
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    mp::cpp_int n = 1;
    cin >> n;
    if (n % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int n,x,c[100010],mas;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	mas=0;
	for(int i=0;i<n;i++){
		cin>>x;
		c[x]++;
		c[x+1]++;
		if(x!=0)c[x-1]++;
//		cout<<mas<<"asd\n";
	}
	for(int i=0;i<=100001;i++)if(c[i]>mas)mas=c[i];
	cout<<mas<<"\n";
}
//100010

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

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 gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];
bool visited[8];


int main() {
	ll n, a, b, x[100000], ans = 0;
	std::cin >> n >> a >> b;
	for (int i = 0;i < n;i++) {
		std::cin >> x[i];
	}
	for (int i = 0;i < n - 1;i++) {
		ans += min((x[i + 1] - x[i])*a, b);
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1024
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

struct Edge {
    int to;
};
using Graph = vector<vector<Edge> >;
// 深さ優先探索
vector<bool> seen;  // 探索したか記録
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            dfs(G, e.to);
        }
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back({b-1});
        G[b-1].push_back({a-1});
    }
    seen.assign(n, false);  // 初期化
    int cnt = 0; 
    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            cnt++; // dfsした回数をカウント
        }
    }
    cout << cnt-1 << endl;
    return 0;
}

Measured memory_bytes: 9584
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main (){
        char N1;
        char N2;
        char N3;
        char N4;
        long long Max = 0;
        cin >> N1>>N2>>N3>>N4;

        if(N1=='+'){
            Max++;
        }else{
            Max--;
        }

        if(N2=='+'){
            Max++;
        }else{
            Max--;
        }
        if(N3=='+'){
            Max++;
        }else{
            Max--;
        }
        
       if(N4=='+'){
            Max++;
        }else{
            Max--;
        }

        cout << Max<< endl;
}


Measured memory_bytes: 256
s = list(input())

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res

print(max)

Measured memory_bytes: 3060
#include <ext/pb_ds/assoc_container.hpp> 	// Common file
#include <ext/pb_ds/tree_policy.hpp> 		// Including tree_order_statistics_node_update
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	string str;cin>>str;
	int  n=str.length();
	std::vector<int> v;
	REP(i,0,n-1)
	{
		if(str[i]=='/'){v.pb(i);}
	}
	string yr,mm,dd;
	REP(i,0,v[0]-1){yr+=str[i];}
	if(stoi(yr)<2019)
	{
		cout<<"Heisei\n";return 0;
	}
	if(stoi(yr)>2019)
	{
		cout<<"TBD\n";return 0;
	}
	REP(i,v[0]+1,v[1]-1){mm+=str[i];}
	if(stoi(mm)<4)
	{
		cout<<"Heisei\n";return 0;
	}
	if(stoi(mm)>4)
	{
		cout<<"TBD\n";return 0;
	}
	REP(i,v[1]+1,n-1){dd+=str[i];}
	if(stoi(dd)<=30)
	{
		cout<<"Heisei\n";return 0;
	}
	if(stoi(mm)>30)
	{
		cout<<"TBD\n";return 0;
	}
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int num[] = {0, 1, 2, 3, 5, 7, 8, 9};

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        long long tmp = 1;
        long long ret = 0;
        while(n > 0){
            ret += tmp * num[n%8];
            n /= 8;
            tmp *= 10;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 868
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      line = sc.nextLine();
        String s[]=line.split(" ",0);
        int a[]=new int[s.length];
        for(int i=0;i<s.length;i++){
            a[i]=Integer.parseInt(s[i]);
        }
        int max= a[0];
        int min=a[0];
 
        for (int i = 1; i < a.length; i ++) {
            max = Math.max(max, a[i]);
            min = Math.min(min, a[i]);
        }
        System.out.println(max-min);
    }
}

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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    int n,d;
    cin>>n>>d;

    vector<vector<int>> items;

    for(int i=0; i<n; i++)
    {
        vector<int> inner;
        for(int j=0; j<d; j++)
        {
            int item;
            cin>>item;
            inner.push_back(item);
        }
        items.push_back(inner);
    }
    long long res=0;
    for(int i=0; i<n; i++)
    {

        for(int j=i+1; j<n; j++)
        {

            long long sum=0;

            for(int k=0; k<d; k++)
            {
                sum+=(items[i][k]-items[j][k])*(items[i][k]-items[j][k]);

            }

            long long sqrtn=sqrt(sum);

            if(sqrtn*sqrtn==sum)
            {
                res++;
            }
        }
    }

    cout<<res<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {

        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define R(a) a=sqrt(a)
#define POW(a,b) a=pow(a,b)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    FAST;
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n){
        cin>>a[i];
    }
    ll ans=0;
    rep(i,n-1){
        if(a[i]>a[i+1]){
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans;
}



Measured memory_bytes: 5212
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> c(N);
	int A[N][M];
	int min_cost = 0;
	for (int i = 0; i < N; i++) {
		cin >> c.at(i);
		min_cost += c.at(i);
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	int cnt = 0;
	for (int bit = 0; bit < (1 << N); bit++) { // 計算量としてはO(2^N)
		set<int> s;
		for (int i = 0; i < N; i++) {
			if (bit & (1 << i)) { // iがbitに入るかどうか
				s.insert(i);
			}
		}
		int cost = 0;
		vector<int> skill(M);
		for (auto x : s) {
			for (int i = 0; i < M; i++) {
				skill.at(i) += A[x][i];
			}
			cost += c.at(x);
		}

		int flag = 1;
		for (int i = 0; i < M; i++) {
			if (skill.at(i) < X) {
				flag = 0;
			}
		}
		if (flag == 1) {
			cnt++;
			if (cost < min_cost) {
				min_cost = cost;
			}
		}
	}

	if (cnt == 0) {
		min_cost = -1;
	}
	cout << min_cost << endl;
}

Measured memory_bytes: 3640