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

using namespace std;
int n,ans=1,k; 
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(k>=ans) ans+=ans;
		else ans+=k;
	}
	cout<<ans;
	return 0;
}


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

typedef long long unsigned ll;

using namespace std;



int ct[16],a[16][16],b[16][16];
int N;

int get_bits(int x){
    int ct=0;
    while(x){
        if(x&1) ct++;
        x>>=1;
    }

    return ct;
}
int main(){

    

    cin>>N;
    for(int i=0;i<N;i++){
        cin>>ct[i];
        for(int j=0;j<ct[i];j++){
            cin>>a[i][j]>>b[i][j];
            a[i][j]--;
        }
    }

    int ret=-1;
    bool flag;
    for(int choice=0;choice<(1<<N);choice++){

        flag = false;
        for(int i=0;i<N;i++){
            if( ((choice>>i) & 1) == 0) continue;

            for(int j=0;j<ct[i];j++){
                if(  ((choice>>a[i][j]) & 1)   != b[i][j] ) flag=true;

                if(flag) break;
            }

            if(flag) break;
        }

        if(!flag) ret=max(ret, get_bits(choice));
    }
    
    cout<<ret<<endl;
    return 0;
}



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

using namespace std;
using i64 = std::int_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 N, D, A;
  cin >> N >> D >> A;
  vector<i64> X(N), H(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> H[i];
  }
  vector<int> idx(N);
  for (int i = 0; i < N; i++) {
    idx[i] = i;
  }
  sort(idx.begin(), idx.end(), [&](int a, int b) { return X[a] < X[b]; });

  vector<i64> NX(N), NH(N);
  for (int i = 0; i < N; i++) {
    NX[i] = X[idx[i]], NH[i] = H[idx[i]];
  }
  X = NX, H = NH;

  i64 res = 0;
  vector<i64> CS(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (CS[i] < H[i]) {
      int k = upper_bound(X.begin(), X.end(), X[i] + 2 * D) - X.begin();
      int cnt = (H[i] - CS[i] + A - 1) / A;
      CS[i] += A * cnt;
      CS[k] -= A * cnt;
      res += cnt;
    }
    CS[i + 1] += CS[i];
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

typedef pair<ll, ll> P;

int main() {
    int n;
    cin >> n;
    vector<ll> s(n);
    rep(i, n)cin >> s[i];

    int q;
    cin >> q;
    int count = 0;
    rep(i, q) {

        int t;
        cin >> t;

        if (*lower_bound(s.begin(), s.end(), t) == t) {
            count++;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 3560
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG A, B, K;
    cin >> A >> B >> K;
    if (A >= K)
    {
        cout << A - K << ' ' << B << endl;
    }
    else
    {
        LLONG rem = K - A;
        cout << 0 << ' ' << max(B - rem, 0LL) << endl;
    }
}

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

int main()
{
        vector<string> s;
        while (1) {
                string st;
                cin >> st;
                if (st == "0") break;
                s.push_back(st);
        }
        int num = s.size();
        for (int i = 0; i < num; ++i) {

                int len = s[i].length();
                int ans = 0;
                for (int j = 0; j < len; ++j) {
                        char c = s[i][j];
                        ans += (c - '1' + 1);
                }
                cout << ans << endl;


        }


}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

// const ll mod = static_cast<int>(1e9 + 7);





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

	vector<double> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	double ans = 0;

	double tmp = 0;
	for (const auto ai : a) {
		tmp += 1.0 / ai;
	}
	ans = 1.0 / tmp;

	printf("%.9f\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000050
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    bool valid=0;
    pll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i].ff>>a[i].ss;
        if(i>=2){
            if(a[i].ff!=a[i].ss) continue;
            if(a[i-1].ff!=a[i-1].ss) continue;
            if(a[i-2].ff!=a[i-2].ss) continue;
            valid=1;
        }
    }
    if(valid) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d,fw,cnt=0;
	cin>>n>>d;
	fw=2*d+1;
    while(1){
        n-=fw;
        cnt++;
        if(n<=0) break;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 105
using namespace std;
 
struct P {int v, t;} de[MAX], in[MAX];
bool lessv (const P &x, const P &y){return x.v < y.v;}
int n;

int main(){
  int n, i, j, a, ti[MAX], maxv[40005];
  double ans = 0;
  scanf("%d", &n);
  ti[0] = 0;
  for(i = 0; i < n; i++){
    scanf("%d", &a);
    ti[i+1] = a*2 + ti[i];
  }
  j = 0;
  for(i = 0; i < n; i++){
    scanf("%d", &a);
    for(; j <= ti[i+1]; j++) maxv[j] = a*2;
    de[i] = {ti[i] + a*2, ti[i]};
    in[i] = {ti[n] - ti[i+1] + a*2, ti[i+1]};
  }
  de[n] = {ti[n], ti[n]};
  in[n] = {ti[n], 0};
  sort(de, de+n+1, lessv);
  sort(in, in+n+1, lessv);
  j = 0;
  for(i = 0; i <= n; i++){
    if(de[i].t < j) continue;
    for(; j <= de[i].t; j++) maxv[j] = min(maxv[j], de[i].v - j);
  }
  j = ti[n];
  for(i = 0; i <= n; i++){
    if(in[i].t > j) continue;
    for(; j >= in[i].t; j--) maxv[j] = min(maxv[j], in[i].v - ti[n] + j);
  }
  for(i = 0; i <= ti[n]; i++){
    ans += maxv[i];
  }
  printf("%f\n", ans/4);
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    vector<int>s(n);
    int sum = 0;
    rep(i,n){
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(),s.end());
    if(sum%10){
        cout << sum << endl;
        return 0;
    }else{
        rep(i,n){
            if((sum-s[i])%10){
                cout << sum-s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n; cin >> n;
    int MAXA = 1e6+10;
    bool covered[MAXA] = {0};

    set<int> a; 
    fo(i, n) {
        int ai; cin >> ai;
        if (a.count(ai) && !covered[ai]) {
            for (int k = ai; k < MAXA; k += ai) {
                covered[k] = 1;
            }
        }   
        else a.insert(ai);
    }

    int ans = 0;
    for (int x: a) {

        if (!covered[x]) {
            ans++;
            for (int i = x; i < MAXA; i += x) {
                covered[i] = 1;
            }
        }

    }
    cout << ans;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();

		int ec = 0;
		for (int i = 0; i < s.length(); i++) {
			if ('E' == s.charAt(i))
				ec++;
		}

		int cc = ec;
		if ('E' == s.charAt(0)) cc--;
		int min = cc;
		for (int i = 0; i < s.length() - 1; i++) {
			if ('W' == s.charAt(i))
				cc++;
			if ('E' == s.charAt(i + 1))
				cc--;
			min = Math.min(min, cc);
		}

		System.out.println(min);

	}

}


Measured memory_bytes: 27092
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
A=[]
for x in T:
    if x == 's':
        A.append('r')
    if x == 'p':
        A.append('s')
    if x == 'r':
        A.append('p')

for i in range(K,N):
    if A[i-K] == A[i]:
        A[i] = 'x'

ans = 0
for x in A:
    if x == 's':
        ans += S
    if x == 'p':
        ans += P
    if x == 'r':
        ans += R
print(ans)

Measured memory_bytes: 46320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[100],i,k=0;
    memset(a,0,sizeof a);
    char c;
    while(scanf("%c",&c)==1)
    {
        if(c!=' ')
        {
            if(c<97)
            {
                c=c+32;
            }
            a[c-'a']++;
        }
    }
    for(i=0;i<26;i++)
    {
        printf("%c : %d\n",i+97,a[i]);
    }
}



Measured memory_bytes: 3196
#include <iostream>
using namespace std;
int main()
{
	 int a,b,c;
	 while (cin >>a)
	 {
	 	b=a%10;
	 	c=a/10;
	 	if(b==9||c==9) cout <<"Yes"<<endl;
	 	else cout <<"No"<<endl;
	 	
	 	
	 }
	
	
	return 0; 
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int n; ll k; cin>>n>>k;
   vector<int> a(n);
   rep(i,0,n)cin>>a[i],a[i]--;
   map<int,int> used; int cur=0,idx=0;
   while(1){
      if(used.count(cur))break;
      used[cur]=idx; cur=a[cur]; idx++;
   }
   int loop=idx-used[cur];
   if(used[cur]<=k){
      k-=used[cur]; k%=loop; k+=used[cur];
   }
   int res=0; idx=0;
   while(1){
      if(idx==k){
         cout<<res+1<<endl;
         return 0;
      } res=a[res]; idx++;
   }
   return 0;
}

Measured memory_bytes: 13224
#include<stdio.h>
int main()

{
	int a, b, c, i, o;
	o = 0;
	scanf("%d %d %d", &a, &b, &c);

	for (i = a; i <= b; i++)
	{
		if (c % i == 0)
			o++;
	}
	
	printf("%d\n", o);


	return(0);

}

Measured memory_bytes: 596
import math
n,a,b=map(int,input().split())
H=[]
for i in range(n):
  H.append(int(input()))
def f(k):
  count=0
  for i in range(n):
    count+=math.ceil(max(0,H[i]-k*b)/(a-b))
  if count<=k:
    return True
  else:
    return False
left,right=1,10**9
while left<right:
  k=(left+right)//2
  if f(k):
    right=k
  else:
    left=k+1
print(left)

Measured memory_bytes: 7068
from math import cos, sin, pi


def make_koch_curve(N, n1, n2):
    s = ((2 * n1[0] + n2[0]) / 3, (2 * n1[1] + n2[1]) / 3)
    t = ((n1[0] + 2 * n2[0]) / 3, (n1[1] + 2 * n2[1]) / 3)
    u = ((t[0] - s[0])*cos(pi/3) - (t[1] - s[1])*sin(pi/3) + s[0],
         (t[0] - s[0])*sin(pi/3) + (t[1] - s[1])*cos(pi/3) + s[1])
    if N == 0:
        return
    make_koch_curve(N-1, n1, s)
    print(*s)
    make_koch_curve(N-1, s, u)
    print(*u)
    make_koch_curve(N-1, u, t)
    print(*t)
    make_koch_curve(N-1, t, n2)


def main():
    N = int(input())
    n1 = (0., 0.)
    n2 = (100., 0.)
    print(*n1)
    make_koch_curve(N, n1, n2)
    print(*n2)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(long.Parse).ToArray();
        var m = ReadLine().Split().Select(long.Parse).ToArray();
        var t = long.Parse(ReadLine());
        if(n[0] > m[0])
        {
            var temp = n[0];
            n[0] = m[0];
            m[0] = temp;
        }
        if(n[1] <= m[1])
            WriteLine("NO");
        else if(n[1] * t + n[0] < m[1] * t + m[0])
            WriteLine("NO");
        else
            WriteLine("YES");
    }
}


Measured memory_bytes: 19092
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	// "strings"
	// "strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintf(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func Max(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func Min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
func main() {
	con := NewConsole()
	defer con.Flush()

	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	max := Max(Max(a, b), c)
	min := Min(Min(a, b), c)
	con.Printf("%d %d\n", min, max)
}


Measured memory_bytes: 1180
#include <stdio.h>

int main(void){

  int n,k;
  scanf("%d\n%d", &n, &k);
  int number = 1;
  for (int i = 0; i < n; i++) {
    if (number < k) {
      number *= 2;
    } else {
      number += k;
    }
  }
  printf("%d\n", number);

  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     String  n = sc.next();
     char[] alpha = n.toCharArray();
     char check = 'A';
     char Check = 'Z';
     if(check<=alpha[0] && alpha[0]<=Check){
       System.out.println('A');
     }else{
       System.out.println('a');
     }

   }
}


Measured memory_bytes: 35564
import math
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
A.sort()

D = defaultdict(int)

AM = A[-1]
dp = [True]*(AM)

for x in A:
  if dp[x-1]:
    temp = 2 * x
    while temp <= AM:
      dp[temp-1] = False
      temp += x

for x in A:
  if dp[x-1]:
    D[x] += 1

ans = len([i for i in D if D[i] == 1])

print(ans)

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

const int maxn = 1<<18+1;
int ivalue[maxn];
int value[maxn];
int P[maxn];

const int mod = 1e9+7;
int mul(int a,int b){
    long long t = 1ll*a*b;
    return t - t/mod*mod;
}
int add(int a,int b){
    a+=b;
    if(a>=mod)  a-=mod;
    return a;
}
int sub(int a,int b){
    a-=b;
    if(a<0) a+=mod;
    return a;
}

int main(){
    ios::sync_with_stdio(false);
    int H;
    cin>>H;
    for(int i=(1<<H-1);i<(1<<H);++i)
        cin>>P[i], P[i]+=(1<<H-1)-1, ivalue[i] = i;
    int ans = 0;
    for(int i=(1<<H-1)-1;i>=1;--i){
        int sum = 0;
        int L = i*2, R = i*2+1;
        int x = L, y = R, z;
        while((x*2)<(1<<H)) x*=2;
        while((y*2)<(1<<H)) y*=2;
        z = y + y - x;
        for(int j = x; j < y; ++j){
            int p = P[j], v = ivalue[j];
            while(p){
                v = mul(v,p);
                value[p] = add(value[p],v);
                p/=2;
            }
            ivalue[j] = mul(ivalue[j], i );
        }
        for(int j = y; j < z; ++j){
            int p = P[j], v = ivalue[j], t = 0;
            while(p){
                sum = add(sum,mul(sub(value[p],mul(t,p)),v));
                v = mul(v,p);
                t = value[p];
                p/=2;
            }
            ivalue[j] = mul(ivalue[j], i );
        }
        ans = add(ans,mul(i,sum));
        for(int j =x; j < y; ++j){
            int p = P[j];
            while(p){
                value[p]=0;
                p/=2;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
typedef long long li;
const int N = 1e5 + 10;
int n;
int a[N],b[N],c[N];
int dp[N][3];
int k;

int main(){

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

		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1 ; i < n ; ++i){

		dp[i][0] = max(dp[i-1][1] + a[i] ,dp[i-1][2] + a[i]);
		dp[i][1] = max(dp[i-1][0] + b[i] ,dp[i-1][2] + b[i]);
		dp[i][2] = max(dp[i-1][0] + c[i] ,dp[i-1][1] + c[i]);
	}
	n--;
	cout<<max(dp[n][0] , max(dp[n][1],dp[n][2]))<<endl;
}

Measured memory_bytes: 2560
s = input()
l = 0
r = len(s)-1
ans = 0
while l < r:
    while (s[l] == 'x'or s[r] == 'x') and l < r:
        if s[l] != s[r]:
            ans += 1
        if s[l] == 'x':
            l += 1
        if s[r] == 'x':
            r -= 1
    if s[l] != s[r]:
        break
    l += 1
    r -= 1
else:
    print(ans)
    exit()
print(-1)


Measured memory_bytes: 40944
a, b, x = gets.split.map(&:to_f)

if x <= a*a*b/2.0
  l = x*2.0/(a*b)
  tann = Math.atan(b/l)
  puts tann/(Math::PI)*180.0
else
  l = (x*1.0-(a*a*b/2.0))*2.0/(a*a)
  tann = Math.atan((b-l)/a)
  puts tann/(Math::PI)*180.0
end

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

typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)
 
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)
#define trav(a, x) for(auto& a : x)
 
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)
 
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


int main()
{
    string s;
    cin >> s;
    int head = -1,tail = 0;
    for(int i = 0;i<s.size();i++)
    {
        if(s[i] == 'A' && head == -1)
        {
            head = i;
        }
        if(s[i] == 'Z')
            tail = i;
    }
    cout << (tail - head + 1) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=10000000000LL;
ll r197(ll n){
	return n%1000000007;
}

typedef pair<int,int>P;

typedef pair<int,P>Pa;
vector<int> v[100001];
bool b[100005]={};
struct edge{
	int score;
	int num;
};
int n;
int k;
int p[103];
int dp[100005][2];
int reg(int m,bool s){
	if(dp[m][s]!=-1)return dp[m][s];
	bool t=!s;
	rep(i,0,n){
		if(m<p[i])break;
		if(reg(m-p[i],!s)==s)t=s;
	}
	return dp[m][s]=t;

}
int main() {
	cin>>n>>k;
	rep(i,0,k+1){
		rep(j,0,2)dp[i][j]=-1;
	}
	rep(i,0,n){
		cin>>p[i];
	}
	if(reg(k,1))cout<<"First"<<endl;
	else cout<<"Second"<<endl;

	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 10;
ll inf = 1e18;
ll n, W, w[N], v[N], ans, d[N];
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);

    cin >> n >> W;
    for(int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        d[i] = -inf;
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = W; j >= 0; j--)
        {
            if(d[j] >= 0 && j + w[i] <= W)
            {
                d[j + w[i]] = max(d[j + w[i]], d[j] + v[i]);
                ans = max(ans, d[j + w[i]]);
            }

        }
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 10000
#define Q 500
int main(){
  int i,n,q,j,S[N],T[Q],AI=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j]==T[i]){
	AI++;
	break;
      }
    }
  }
  printf("%d\n",AI);
  
  
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
main(){
	int a[4],ar[3],n=2;
	while(n--){
	scanf("%d%d%d%d",a,a+1,a+2,a+3);
	ar[n]=*a+a[1]+a[2]+a[3];
	}
	printf("%d\n",*ar>ar[1]?*ar:ar[1]);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    int l=1,r=n;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        l=max(l,a[i]);
        r=min(r,b[i]);
    }
    cout<<max(0,r-l+1)<<endl;
    return 0;
}


Measured memory_bytes: 4420
/*
It's been a long day without you, my friend
And I'll tell you all about it when I see you again
We've come a long way from where we began
Oh I'll tell you all about it when I see you again
When I see you again
When I see you again
*/
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
using namespace std;
 

 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;
 
const int mod = 1e9+7;
 
int sod(int n){int sum=0;while(n>0){sum+=n%10;n/=10;}return sum;}
 
int dig(int n){if(n==0)return 1;int cnt=0;while(n>0){n/=10;cnt++;}return cnt;}
 
int divs(int n){int cnt=0;for(int x=1;x*x<=n;x++){if(n%x==0){cnt++;if(n/x!=x)cnt++;}}return cnt;}
 
int isprime(int n){if(n<2)return false;for(int x=2;x*x<=n;x++)if(n%x==0)return false;return true;}
 
int power(int x,unsigned int y,int p=mod){int res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

bool pal(string s){int l=0,r=s.size()-1;while(l<r){if(s[l++]!=s[r--])return false;}return true;} 

bool isSquare(int n){
    int root = sqrt(n);
    return (root*root == n);
}
const int inf = 1e18;




int32_t main(){
    FAST;

    int n;  cin >> n;

    cout << ( pal(to_string(n)) == true ? "Yes" : "No") << endl;

    return 0;
}
 
 
 

// const int N = 1e6;
// bool prime[N+3];
// vi primes;
// void sieve(){
 
//   memset(prime , true , sizeof prime );
 
//   prime[0] = false , prime[1] = false;
//   prime[2] = true;
 
//   for(int x=2;x*x<=N;x++){
//     if(prime[x] == true){
//       for(int i=x*x;i<=N;i+=x)
//         prime[i] = false;
//     }
//   }

//   //for(int x=0;x<N;x++)
//   //  if(prime[x])
//   //      primes.pb(x);
 
// } 


// const int N = 1e6+50;
// int spf[N+11];
 
// void SPF(){
 
// 	spf[1] = 1; 
  
//     for (int i = 2; i <= N; i++) 
//     { 
//         if (spf[i] == 0) 
//         { 
//             spf[i] = i; 
  
//             for (int j = 2*i; j <= N; j += i) 
//                 if (spf[j] == 0) 
//                    spf[j] = i; 
//         } 
//     } 
// }
 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,i,max,min;
    long long sum=0;
    int a[100000];
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
        sum=sum+a[i];
        if(i==1){
            max=a[i];
            min=a[i];
        }
        else{
            if(max<a[i]){
                max=a[i];
            }
            if(min>a[i]){
                min=a[i];
            }
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)
 
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  ll o = v - w;
  ll p = abs(b - a);
  for (ll i = 0; i < t; i++) {
    p -= o;
    if (p <= 0) {
      cout << "YES" << '\n';
      return 0;
    }
  }
  cout << "NO" << '\n';
}

Measured memory_bytes: 3584
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

ll dp[110000];

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

    int N;
    cin >> N;
    rep(i, 110000) dp[i] = N;
    dp[0]                = 0;
    rep(i, N) {
        for(int pow6 = 1; i + pow6 <= N; pow6 *= 6) {
            chmin(dp[i + pow6], dp[i] + 1);
        }
        for(int pow9 = 1; i + pow9 <= N; pow9 *= 9) {
            chmin(dp[i + pow9], dp[i] + 1);
        }
    }
    COUT(dp[N]);
}


Measured memory_bytes: 1152
import math

def divisor(num):
    if num < 0:
        return 0
    if num == 1:
        return [1, ]

    divisor_list = [1, ]
    divisor_list_r = [num, ]

    i = 2
    while i * i <= num:
        if num % i == 0:
            divisor_list.append(i)
        i += 1

    return divisor_list

N = int(input())
divisor_list = divisor(N)
ans = 0
for i in divisor_list:
    tmp = (N - i) // i
    if tmp == 0:
        continue
    if i // tmp > 0:
        continue
    ans += tmp

print(ans)


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

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (a >= 3200)
            {
                Console.WriteLine(s);
            }
            else
                Console.WriteLine("red");
            Console.ReadKey();
        }
    }
}


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

typedef long long ll;

int main(){
  string str;
  cin >> str;
  sort(str.begin(), str.end());
  if(str[0]==str[1] && str[1]!=str[2] && str[2]==str[3]) cout << "Yes"<<endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 256
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(i8[:],i8[:],i8,i8)')
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 16
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


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

ans=0

for i in reversed(range(1,N+1)):
    if A[i]<B[i-1]:
        ans+=A[i]
        B[i-1]=B[i-1]-A[i]
        A[i]=0
    else:
        ans+=B[i-1]
        A[i]=A[i]-B[i-1]
        B[i-1]=0

    if A[i-1]<B[i-1]:
        ans+=A[i-1]
        B[i-1]=B[i-1]-A[i-1]
        A[i-1]=0
    else:
        ans+=B[i-1]
        A[i-1]=A[i-1]-B[i-1]
        B[i-1]=0
    
print(ans)

Measured memory_bytes: 24088
#include <iostream>
#include <math.h>
#define PI 3.14159265
using namespace std;

int main() {
//    freopen("in.txt", "r", stdin);
    int n;
    int x[1002], y[1002];
    double r1, r2, r3, rf, sum, tmp;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> y[i];
    }

    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += pow(abs(x[i] - y[i]), 1);
    }
    r1 = pow(sum, 1.0 / 1);

    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += pow(abs(x[i] - y[i]), 2);
    }
    r2 = pow(sum, 1.0 / 2);

    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += pow(abs(x[i] - y[i]), 3);
    }
    r3 = pow(sum, 1.0 / 3);

    sum = 0;
    rf = -1;
    for (int i = 0; i < n; ++i) {
        if (rf < (tmp = abs(x[i] - y[i]))) {
            rf = tmp;
        }
    }

    printf("%.6lf\n%.6lf\n%.6lf\n%.6lf\n", r1,r2,r3,rf);
}

Measured memory_bytes: 3352
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

#define ll long long

int main(){
  list<int> card;
  int N,ans;
  cin >> N;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    card.push_back(x);
  }
  card.sort();
  card.unique();
  ans=card.size();
  if(ans%2==0){
    ans--;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int N, M;
string[100] NS, MS;

void main()
{
    N = readln.chomp.to!int;
    foreach (i; 0..N) NS[i] = readln.chomp;
    M = readln.chomp.to!int;
    foreach (i; 0..M) MS[i] = readln.chomp;

    auto ns = NS[0..N];
    auto ms = MS[0..M];

    int max_p;
    foreach (s; ns) {
        int p;
        foreach (n; ns) if (n == s) ++p;
        foreach (m; ms) if (m == s) --p;
        max_p = max(max_p, p);
    }
    writeln(max_p);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    double x = pow(double (x1 - x2), 2);
    double y = pow(double (y1 - y2), 2);
    double dis = sqrt(double (x + y));

    printf("%lf\n", dis);
    return 0;
}


Measured memory_bytes: 3296
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N = iin()
X = iln()
ans = 10**10
for i in range(1, 101):
    t = 0
    for j in range(N):
        t += (i-X[j])**2
    ans = min(ans, t)
print(ans)


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
int mod = 2;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
  int n;
  cin >> n;
  mod = n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<mint> b(n);
  combination c(n-1);
  rep(i,n) if (a[i]) {
    // add (1 - (x-i)^(n-1))
    b[0] += 1;
    mint pw = 1;
    for (int j = n-1; j >= 0; --j) {
      b[j] -= pw * c(n-1,j);
      pw *= -i;
    }
  }
  rep(i,n) {
    printf("%lld\n",b[i].x);
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair <int,int> a[100005];
int n;

bool cmp(pair<int,int> x,pair<int,int> y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++) {
        int p1,p2;
        cin >> p1 >> p2;
        a[i] = {p1-p2,p1+p2};
    }
    sort(a+1,a+n+1,cmp);
    int e = -1e9-1,cnt = 0;
    for(int i = 1;i <= n;i++) {
        if(e <= a[i].first) {
            e = a[i].second;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


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

int main(){
    char c;
    cin>>c;
    string ans;
    if(c=='A'){
        ans="T";
    }else if(c=='T'){
        ans="A";
    }else if(c=='G'){
        ans="C";
    }else{
        ans="G";
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second

int main()
{
    int n, k, a, b, m;
    cin >> n >> k;
    vector <int> D[n+1], T;
    long long MOD=1000000007, S=1;
    int K[n+1], g[n+1];
    for (int i = 0; i <= n; i++)
    {
        K[i] = 0;
        g[i] = 1;
    }
    for (int i = 0; i < n-1; i++)
    {
        cin >> a >> b;
        D[a].push_back(b);
        D[b].push_back(a);
    }
    g[1] = 0;
    T.push_back(1);
    for (int i = 0; i < T.size(); i++)
    {
        a = T[i];
        m = K[a];
        for (int y = 0; y < D[T[i]].size(); y++)
        {
            b = D[T[i]][y];
            m += K[b];
            if (g[b] == 1)
            {
                g[b] = 0;
                T.push_back(b);
            }
            K[b]++;
        }
        S *= k - m;
        S %= MOD;
    }
    cout << S;
    return 0;
}


Measured memory_bytes: 7672
#include<iostream>

using namespace std;

int main(){

	int a ,b;

	cin >> a >> b;

	if (a < b){

		cout << "a < b" << endl;

	}
	else if(a > b){

		cout << "a > b" << endl;

	}else{

		cout << "a == b" << endl;


}


	//cout << /*出力をここに入力*/ << endl;

	return 0;


}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
  int r=700;
  string s;
  cin >> s;
  if(s.at(0)=='o') r+=100;
  if(s.at(1)=='o') r+=100;
  if(s.at(2)=='o') r+=100;
  
  cout << r << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> A(H);
  map<char, int> cnt;
  for (int i = 0; i < H; i++) {
    cin >> A[i];
    for (int j = 0; j < W; j++) {
      cnt[A[i][j]]++;
    }
  }

  int group4 = (H / 2) * (W / 2), group2 = 0, group1 = 0;
  if (H % 2 == 0 || W % 2 == 0) {
    if (!(H % 2 == 0 && W % 2 == 0)) {
      group2 = (H % 2 == 0 ? H : W) / 2;
    }
  } else {
    group1 = 1;
    group2 = (H / 2) + (W / 2);
  }
  for (int i = 'a'; i <= 'z'; i++) {
    while (group4 > 0 && cnt[i] >= 4) {
      cnt[i] -= 4;
      group4--;
    }
    while (group2 > 0 && cnt[i] >= 2) {
      cnt[i] -= 2;
      group2--;
    }
    while (group1 > 0 && cnt[i] >= 1) {
      cnt[i] -= 1;
      group1--;
    }
    if (cnt[i] > 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;


vector<ll> A;
void func(ll N){
    ll tmp = N;
    A.emplace_back(N);
    for(int i=2; i*i<=N; i++){
        if(N%i==0){
            A.emplace_back(i);
            A.emplace_back(N/i);
        }
    }
    A.emplace_back(1); 
}

int main(){
    ll N, M; cin>>N>>M;
    func(M);    
    sort(A.begin(), A.end(), greater<ll>());
    ll res = 1;
    for(auto &x: A){
        if(x*N<=M){
            res = x;
            break;
        }
    }
    //cout << A << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long MAX=1LL<<60;
  vector<long long> DP(100010,MAX);
  
  DP[0]=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=i;j*=6){ DP[i]=min(DP[i],DP[i-j]+1);}
    for(int j=1;j<=i;j*=9){ DP[i]=min(DP[i],DP[i-j]+1);}
  }
  cout<<DP[N]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	
	double deg = abs(30 * h - m * 5.5);
	
	if( deg > 180.0 ) deg = 360 - deg;
	
	double ans = a * a + b * b - 2.0 * a * b * cos(deg * 4 * atan(1.0) / 180.0);
	
	printf("%.15f\n", sqrt(ans));
	
	return 0;
}


Measured memory_bytes: 4216
#include<stdio.h>
int main(){
	int c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	if(c1+c5*5+c10*10+c50*50+c100*100+c500*500>999){
		printf("1\n");
	}else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
  
    string s;
    cin>>s;
    
    int ans=0;
    
    for(int i=0;i<3;i++){
      if(s[i]=='1'){
          ans+=1;
    }
    }
    
    cout<<ans<<endl;
    return 0;
}







Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin >> n >> k;
    if(k%2==0){
        ll a = n/k;
        ll b;
        if(n>=k/2){
            b = (n-k/2)/k + 1;
        }else{
            b = 0;
        }
        cout << (ll)a*a*a + b*b*b << endl;
    }else{
        int a = n/k;
        cout <<(ll) a*a*a << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
const int INF = 1 << 30;

int main(){
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h.at(i);
    vi d(n, INF);
    d.at(0) = 0;
    rep(i, n){
        REP(j, k+1){
            if(i+j <= n-1)
            if(d.at(i+j) > d.at(i)+abs(h.at(i+j)-h.at(i))){
                d.at(i+j) = d.at(i)+abs(h.at(i+j)-h.at(i));
            }
        }
    }
    cout << d.at(n-1) << endl;
    return 0;
}

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

int main() {
#ifdef LOCAL_DEFINE
	// freopen("data.in", "rt", stdin);
	// freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<long long> pre(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i + 1];
		pre[i + 1] = pre[i] + a[i + 1];
	}
	const long long inf = 1e18;
	vector<vector<long long>> dp(n + 1, vector<long long>(n + 1));
	for(int i = n - 1; i >= 1; i--) {
		for(int j = i + 1; j <= n; j++) {
			dp[i][j] = inf;
			for(int k = i; k <= j - 1; k++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + pre[j] - pre[i - 1]);
			}
		}
	}
	cout << dp[1][n] << '\n';

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 1536
import sys

sys.setrecursionlimit(10**6)

def handling(string, letter):
    global cnt
    cnt += 1; nxt = []
    for i in range(len(string)-1):
        s1, s2 = string[i], string[i+1]
        if s1 == letter:
            nxt.append(s1)
        elif s2 == letter:
            nxt.append(s2)
        else:
            nxt.append(s1)
    if len(set(nxt)) != 1:
        handling(nxt, letter)

def main():
    global cnt
    s = list(input())
    sletter = set(s)
    if len(sletter) == 1:
        print(0)
        return
    ans = 101
    for l in sletter:
        cnt = 0
        t = s.copy()
        handling(t, l)
        ans = min(ans, cnt)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064