akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,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;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int ans=0;
int n;
int keta;

void dfs(int now,int dt ,int c_3,int c_5 ,int c_7){
    if(dt<=keta){
        if(now<=n&&c_3>0&&c_5>0&&c_7>0){
            ans++;
        }
    }
    if(dt>keta) return;
    dfs(now*10+3,dt+1,c_3+1,c_5,c_7);
    dfs(now*10+5,dt+1,c_3,c_5+1,c_7);
    dfs(now*10+7,dt+1,c_3,c_5,c_7+1);
}

int main (){
    cin >> n;
    keta=(int)log10(n)+1;
    dfs(0,0,0,0,0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
S = list(input())

r_cnt = S.count("R")
g_cnt = S.count("G")
b_cnt = S.count("B")

total = r_cnt * g_cnt * b_cnt
diff = 0

for i in range(1,N+1):
    for j in range(i+1,N+1):
        k = 2*j - i
        if k > N:
            break
        if S[i-1] != S[j-1] and S[j-1] != S[k-1] and S[k-1] != S[i-1]:
            diff += 1
print(total -diff)



Measured memory_bytes: 68180
N = int(input())
A = list(input().split())
B = A[:]

def bubbleSort(A, N):
    flag = 1
    
    while flag:
        flag = 0
        for i in range(N-1, 0, -1):
            if A[i][1] < A[i-1][1]:
                temp = A[i]
                A[i] = A[i-1]
                A[i-1] = temp
                flag = 1
    return " ".join(map(str, A))
    
bubbleSort(A, N)
print(bubbleSort(A, N))
print("Stable")

def selectionSort(A, N):
    for j in range(N):
        C = []
        for i in range(N):
            C.append((A[i][1]))
            
        idx = C[j:].index(min(C[j:])) + j
        
        if A[idx][1] < A[j][1]:
            temp = A[j]
            A[j] = A[idx]
            A[idx] = temp

    return " ".join(map(str, A))

print(selectionSort(B, N))
if bubbleSort(A, N) == selectionSort(B, N):
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5612
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>

using namespace std;
//#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 1; i <= N; i++)
	{
		if (i % 2 == 1)cnt++;
	}
	double ans = (double)cnt / N;
	cout << ans;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力を取得
S = int(input())

# 求解処理


def combinations_count(n: int, r: int) -> int:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


A = S // 3
B = S % 3
ans = 0
while A > 0:
    ans += combinations_count(B + A - 1, B)
    A -= 1
    B += 3
ans %= 10**9 + 7

# 結果出力
print(ans)


Measured memory_bytes: 9208
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

void how_many_decendable(const vector<vector<ll>>&tree,vector<ll>&res,ll from,ll parent)
{
    res[from]=0;
    for(auto c:tree[from]){
        if(c!=parent){
            how_many_decendable(tree,res,c,from);
            res[from]=max(res[from],res[c]+1);
        }
    }
}
void tree_distance(const vector<vector<ll>>&tree,vector<ll>&res,ll from,ll parent,ll dist=0)
{
    res[from]=dist;
    for(auto c:tree[from]){
        if(c!=parent){
            tree_distance(tree,res,c,from,dist+1);
        }
    }
}
void get_parent(const vector<vector<ll>>&tree,vector<ll>&res,ll from,ll parent)
{
    for(auto c:tree[from]){
        if(c!=parent){
            get_parent(tree,res,c,from);
        }
    }
    res[from]=parent;
}
int main()
{
    ll n=in(),u=in()-1,v=in()-1;
    vector<vector<ll>>tree(n);
    for(ll i=0;i<n-1;++i){
        ll a=in()-1,b=in()-1;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<ll>decendable_root_v(n);how_many_decendable(tree,decendable_root_v,v,-1);
    vector<ll>dist_from_v(n);      tree_distance(tree,dist_from_v,v,-1);
    vector<ll>parent_root_v(n);    get_parent(tree,parent_root_v,v,-1);
    ll ans=-1;
    for(
        ll up=0,upto=u;
        up<dist_from_v[upto];
        ++up,upto=parent_root_v[upto]
    ){
        ans=max(ans,dist_from_v[upto]+decendable_root_v[upto]-1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 14592
import math
S = list(input())
r = [0] * len(S)
r_count = 1
l_count = 0
pre_s = "R"
for i,s in enumerate(S[1:len(S)]):
    #print(i,s)
    if s == "R":
        if l_count > 0:
            # calc
            r[i-l_count+1] = math.floor(r_count/2) + math.ceil(l_count/2)
            r[i-l_count] = math.ceil(r_count/2) + math.floor(l_count/2)
            r_count = 1
            l_count = 0
        else:
            r_count = r_count + 1
    else:
        l_count = l_count + 1
    #

i = len(S)-1
#calc
r[i-l_count+1] = math.floor(r_count/2) + math.ceil(l_count/2)
r[i-l_count] = math.ceil(r_count/2) + math.floor(l_count/2)
#print
print(int(r[0]),end="")
for i in r[1:len(r)]:
    print(" ",end="")
    print(int(i),end="")
print()

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

int64_t power(int64_t x,int64_t y,int64_t mod){
	int64_t result=1;
	while(y>0){
		if(y&1) result=result*x%mod;
		x=x*x%mod;
        y>>=1;
	}
	return result;
}


void solve(){
    int d,s,mod=1e9+7,sum=0;
    cin >> d;
    vector<int> l(d);
    rep(i,0,d){
        cin >> l[i];
        sum+=l[i];
    }
    cin >> s;

    auto f=[&](int x){
        return power(x,d,mod);
    };

    static int dp[300][2][90001];
    rep(i,0,300) rep(j,0,2) rep(k,0,90001) dp[i][j][k]=-1;
    function<int(int,int,int)> rec=[&](int i,int c,int k){
        if(dp[i][c][k]!=-1) return dp[i][c][k];
        dp[i][c][k]=0;
        if(i==d-1){
            if(c==1){
                dp[i][c][k]=(-f(k)+mod)%mod;
                if(k-l[i]>=0) dp[i][c][k]=(dp[i][c][k]+f(k-l[i])+mod)%mod;
            }else{
                dp[i][c][k]=(f(k)+mod)%mod;
                if(k-l[i]>=0) dp[i][c][k]=(dp[i][c][k]-f(k-l[i])+mod)%mod;
            }
            return dp[i][c][k];
        }
        dp[i][c][k]=rec(i+1,c,k);
        if(k-l[i]>=0) dp[i][c][k]=(dp[i][c][k]+rec(i+1,(c+1)%2,k-l[i]))%mod;
        return dp[i][c][k];
    };
    cout << rec(0,0,s) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 214128
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong(), h = 0;
		for(int i = 1; i < b - a; i++) {
			h += i;
		}
		System.out.println(h - a);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int N, max = 0, sum = 0;
		int a[] = new int[100];

		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();

		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			sum = sum + a[i];

			if(max < a[i]) {
				max = a[i];
			}
		}

		if(max < sum - max) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}

Measured memory_bytes: 23764
package main

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


func solveFromFile() int{
    var nu int
    scanner := bufio.NewScanner(os.Stdin)
    file, err := os.Open(os.Args[1])
    if err != nil {
      log.Fatalf("failed opening file: %s", err)
    }
    scanner = bufio.NewScanner(file)
    scanner.Scan()
    tempstr := scanner.Text()
	  n, err2 := strconv.Atoi("123")
    nu = n
    nu = nu +321
    if err2 != nil {
      log.Fatalf("failed opening file: %s", err2)
      
    }

    defer file.Close()
    scanner.Scan()
    return solution(tempstr, scanner.Text())
}

//========== Implement Algorithm =======================
func solution(num1 string, num2 string) int{
  if num1 == string(num2[:len(num2)-1]){
    return 1
  }
  return 0
}

func main() {

//================== Variables used ====================
  var num1,num2 string 
  var ret int
//======================================================

  if len(os.Args) >=2{
//============== Get return value from File ============
    ret = solveFromFile()


  }else{
//============== Get return value from STDIN ===========
    fmt.Scan(&num1)
    fmt.Scan(&num2)
    ret = solution(num1,num2)
  }

//================== OUTPUT ============================
  if ret==1 {
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
  
}

Measured memory_bytes: 1884
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    s = read()
    t = read()
    print("Yes" if t[:-1] == s else "No")
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()


Measured memory_bytes: 8872
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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;}

template< class Abel > struct UnionFind {
  vector< int > par;
  vector< int > rank;
  vector< Abel > diff_weight;
  
  UnionFind(int n = 1, Abel SUM_UNITY = 0) {
    init(n, SUM_UNITY);
  }

  void init(int n = 1, Abel SUM_UNITY = 0) {
    par.resize(n); rank.resize(n), diff_weight.resize(n);
    for(int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      diff_weight[i] = SUM_UNITY;
    }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    // 累積和をとる
    int r = root(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = r;
  }

  Abel weight(int x) {
    // 経路圧縮をする
    root(x);
    return diff_weight[x];
  }

  Abel diff(int x, int y) {
    return weight(y) - weight(x);
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  // weight(x) - weight(y) = wとなるようにmerge
  bool merge(int x, int y, Abel w) {
    // xとyそれぞれについてrootとの重み付き補正
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if (rank[x] == rank[y]) {
      ++rank[x];
    }
    par[y] = x;

    // xがyの大和になるので、xとyの差分をdiff_weight[y]に記録
    diff_weight[y] = w;
    return true;
  }
};

signed main() {
  INIT;
	VAR(int,n,m);
  UnionFind<int> uf(202020);
  bool ok=true;
  REP(i,m) {
    VAR(int,l,r,d);
    if(uf.issame(l,r)) {
      ok &= (uf.diff(l,r) == d);
    } else {
      uf.merge(l,r,d);
    }
  }
  OUT((ok?"Yes":"No"))BR;
  
  return 0;
}


Measured memory_bytes: 4992
Scanf.scanf "%d" (fun n ->
    let nei = Array.make n [] in
    let rev = Array.make n [] in
    for i = 1 to n - 1 do
        Scanf.scanf " %d" (fun a ->
            let a = a - 1 in
            nei.(i) <- a :: nei.(i);
            rev.(a) <- i :: rev.(a)
        )
    done;
    let rec depth node =
        if rev.(node) = [] then 0 else (
            let children = Array.of_list @@ List.fold_left (fun acc v -> (depth v, v) :: acc) [] rev.(node) in
            Array.sort (fun a b -> compare b a) children;
            let k = Array.length children in
            let rec loop i acc =
                if i = k then acc else loop (i + 1) (max acc (i + 1 + fst children.(i)))
            in
            loop 0 0
        )
    in
    Printf.printf "%d\n" @@ depth 0
)

Measured memory_bytes: 24512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int main() {
    int N; cin >> N;
    set<int> st;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;
    return 0;
}

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

const int INF = 1001001001;

int main(){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n,p;
    string s;
    cin >> n >> p >> s;
    long long ans = 0;
    if(p == 2 || p == 5){
        for(int i=0; i<n; i++){
            if((s[i] - '0') % p == 0) ans += (i+1);
        }
        cout << ans << endl;
        return 0;
    }
    unordered_map<int,int> resm;
    int cur = 0;
    int digit = 1;
    resm[cur]++;
    for(int i=n-1; i>=0; i--){
        cur += ((s[i]-'0')*digit) % p;
        cur %= p;
        ans += resm[cur];
        resm[cur]++;
        digit = (digit * 10) % p;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int i,n,l[11],max=0,sum=0;
  cin>>n;
  for(i=0;i<n;i++){
	cin>>l[i];
    sum+=l[i];
    if(l[i]>max){
		max=l[i];
    }
  }

  if(2*max<sum){
	printf("Yes");
  }else{
	printf("No");
  }
}
  


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419191919;
ll N, M; 

vector<vector<ll > > G;
vector<vector<ll > > path;

//ワーシャルフロイドでひょいっと

bool warshall(){
    //中継点に関して
    for(ll reley = 0; reley < N; reley++){
        for(ll from = 0; from < N; from++){
            for(ll to = 0; to < N; to++){
                //中継した方がコストがかからないか否か
                //小さい順からコストが自明に決まっていく
                if(G[from][to] > G[from][reley] + G[reley][to]){
                    //負の辺対策 INFINITY＋INFINITYはマイナスになるので
                    //たまに最短距離を更新してしまう. 
                    if(G[from][reley] != INF && G[reley][to] != INF){
                        G[from][to] = G[from][reley] + G[reley][to];
                        //fromからtoへ到達する最短経路上のfromの1つ前の位置
                        path[from][to] = path[from][reley];
                    }
                }
            }

            //負の閉路がある時
            if(G[from][from] < 0){
                cout << "NEGATIVE CYCLE" << endl;
                return false;
            }
        }
    }

    return true;
}

vector<ll > get_path(ll start, ll end){
    vector<ll > ans;
    //endに向けて進んでいく中継地があれば拾っていく
    for(ll i = start; i != end; i = path[i][end]){
        cout << i << endl;
        ans.push_back(i);
    }
     ans.push_back(end);
    return ans;
}

int main(){

    //頂点数と辺の数
    ll H, W;
    cin >> H >> W;

    N = 10;

    G.assign(N, vector<ll >());
    path.assign(N, vector<ll >());
    
    //初期化
    for(ll i = 0; i <= 9; i++){
        for(ll j = 0; j <= 9; j++){
            if(i == j){
                //自分から自分へ
                G[i].push_back(0);
            }else{
                G[i].push_back(INF);
            }
            path[i].push_back(j);
        }       
    }

    //辺入力
    for(ll i = 0; i <= 9; i++){
        for(ll j = 0; j <= 9; j++){
            ll w; cin >> w;
            //有向か無向かでコメントアウト　多重辺も防止
            G[i][j] = min(G[i][j], w);
            //G[j][i] = min(G[j][i], w);
        }
    }

    //実行
    if(warshall() == false){
        return 0;
    }


    ll ans = 0;
    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            ll t; cin >> t;
            if(t == 1 || t == -1) continue;
            ans += G[t][1];
        }
    }

    cout << ans << endl;

}

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

string s, t;

string rotate(string str) {
    str += str[0];
    str.replace(0, 1, "");
    return str;
}

int main() {
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        if (s == t) {
            cout << "Yes";
            break;
        }
        s = rotate(s);
    }
    if (s != t) cout << "No" << endl;
}


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

typedef long long ll;

vector<vector<int> > adjList;
int n, m;
vector<int> dp;

int backtrack(int node){
    int &ret = dp[node];
    if (ret != -1) return ret;

    ret = 0;
    for (int i=0;i<(int)adjList[node].size();++i){
        int child = adjList[node][i];
        ret = max(ret, backtrack(child) + 1);
    }
    return ret;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x, y;
    cin>>n>>m;
    dp.assign(n+1, -1);
    adjList.assign(n+1, vector<int>());

    for (int i=0;i<m;++i) {
        cin>>x>>y;
        adjList[x].push_back(y);
    }

    int ans = 0;
    for (int i=1;i<=n;++i){
        ans = max(ans, backtrack(i));
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 8192
#include<cstdio>
#include<cstring>
#include<iostream>
#define ll long long
using namespace std;
template <typename T>
void read(T &x) {
	x = 0;int f = 1;
	char c = getchar();
	for (;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	x *= f;
}
const int N = 2000050;
int a[N], n;
inline bool sm(int i,int k) {
	return a[i] < k && a[i+1] < k;
}
inline bool bi(int i,int k) {
	return a[i] >= k && a[i+1] >= k;
}
bool check(int x) {
	for (int i = 0;i < n-1; i++) {
		if (sm(n-i-1, x) || sm(n+i, x)) return false;
		if (bi(n-i-1, x) || bi(n+i, x)) return true;
	}
	return a[1] >= x;
}
int main() {
	read(n);
	for (int i = 1;i <= 2*n-1; i++) read(a[i]);
	int l = 1, r = 2 * n-1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid + 1;
		else r = mid - 1;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1024
from itertools import accumulate

N, K, *P = map(int, open(0).read().split())

E = [(p + 1) for p in P]

A = [0] + list(accumulate(E))

print("{:.8f}".format(max(A[i + K] - A[i] for i in range(N - K + 1)) / 2))


Measured memory_bytes: 29232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int a, p;cin >> a >> p;
    int ans;
    ans = (a*3+p)/2;
    cout << ans << endl;

}


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

int main(){

    int N;
    
    std::cin >> N;
    
    bool flag = true;
    int pt = 0, px = 0, py = 0;
    while(N--){
        int t, x, y;
        std::cin >> t >> x >> y;
        int dis = abs(x - px) + abs(y - py);
        
        if(dis > t - pt || abs(dis - (t - pt)) % 2 == 1){
            flag = false;
        }
        pt = t, px = x, py = y;
    }
    if(flag){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int N,p[100];

int main(){
	while(cin>>N){
		rep(i,N)cin>>p[i];
		sort(p,p+N);
		int ans=0;
		rep(i,N)ans+=p[i]*(N-i);
		cout<<ans<<endl;
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int dfs(int v, int n, bool visited[nmax]) {
  bool all_visited=true;
  for(int i = 0; i < n; ++i) {
    if(visited[i] == false) all_visited = false;
  }
  if(all_visited) return 1;

  int ret = 0;
  for(int i = 0; i < n; ++i) {
    if(graph[v][i] == false) continue;
    if(visited[i]) continue;
    visited[i] = true;
    ret += dfs(i, n, visited);
    visited[i] = false;
  }

  return ret;
}

int main() {
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int a, b; cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }

  bool visited[n];
  for(int i = 0; i < n; ++i) {
    visited[i] = false;
  }
  visited[0] =true;

  cout << dfs(0, n, visited) << endl;

  return 0;
}

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 n, m; 
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m){
        cin >> p[i].first >> p[i].second;
    }

    rep(x,1000){
        int keta = 1;
        int nx = x/10;
        vector<int> vec(1, x%10);
        nx = x/10;
        while(nx > 0){
            keta++;
            vec.push_back(nx%10);
            nx /= 10;
        }
        if(keta != n) continue;
        bool ok = true;
        reverse(vec.begin(), vec.end());
        rep(i, m){
            if(vec[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x <<endl;
            return 0;
        }
    }

    cout << -1 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>
using namespace std;

long gcd(long c, long d)
{
	if (c < d)
	{
		unsigned long tmp = c;
		c = d;
		d = c;
	}

	return gcd(d, c % d);
}

struct Task
{
	int a;
	int b;
	bool operator<(const Task& another)
	{
		return b < another.b;
	}
};

int main(void)
{
	int n;
	cin >> n;
	vector<Task> tasks(n);
	int max_deadlie = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> tasks[i].a >> tasks[i].b;
		if (max_deadlie > tasks[i].b)
		{
			max_deadlie = tasks[i].b;
		}
	}

	sort(tasks.begin(), tasks.end());

	int time = 0;
	bool over = false;
	for (int i = 0; i <n; i++)
	{
		time += tasks[i].a;
		if (time > tasks[i].b)
		{
			over = true;
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>

int main(){
    int n;scanf("%d",&n);int A[n];
    for(int i=0;i<n;i++)scanf("%d",&A[i]);
    int q;scanf("%d",&q);
    int ans=0;
    for(int j=0;j<q;j++){
        int target;scanf("%d",&target);
        int t_m=0,t_M=n-1,t_mid;
        while(t_M>t_m+1){
            t_mid=(t_M+t_m)/2;
            if(target<=A[t_mid]){
                t_M=t_mid;
            }
            else if(target>A[t_mid]){
                t_m=t_mid;
            }
        }
        if(target==A[t_mid] || target==A[t_m] || target==A[t_M])ans+=1;
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
    int n, p;
    cin >> n >> p;
    int x;
    int odd = 0;
    int even = 0;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (x % 2) odd++;
        else even++;
    }
    long long ans = 0;
    vector<long long> oddCr(odd + 1);
    oddCr[0] = 1;
    for (int i = 0; i < odd; i++){
        oddCr[i+1] = oddCr[i] * (odd - i) / (i + 1);
    }
    for (int i = p; i <= odd; i += 2){
        ans += oddCr[i] * pow(2, even);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<int> S(M),C(M);
    for(int i=0;i<M;i++) cin >> S[i] >> C[i];
    vec<int> beki(N+2,1);
    for(int i=1;i<=N+1;i++) beki[i] = beki[i-1]*10;

    auto keta = [&](int n,int i){
        string s = to_string(n);
        return s[i-1]-'0';
    };

    for(int i=beki[N-1]-(N==1);i<beki[N];i++){
        bool ok = true;
        for(int j=0;j<M;j++) ok &= keta(i,S[j])==C[j];
        if(ok){
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    print('x'*len(s))





if __name__ == "__main__":
    main()

Measured memory_bytes: 5440
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
const int N = 100001; 



void solve(){
    int n;cin>>n;
    vi a(n);
    int sum;
    rep(i,0,n){
    	cin>>a[i];
    	if(i==0)sum=a[i];
    	else sum=sum^a[i];
    }
    rep(i,0,n){
    	cout<<(sum^a[i])<<" ";
    }
    // rep(i,0,n){
    // 	int ans=a[i];
    // 	rep(j,i+1,n){
    // 		// cout<<(a[i]^a[j])<<endl;
    // 		ans=ans^a[j];
    // 	}
    // 	cout<<ans<<endl;
    // }

    return ;
}
     
signed main(){
    IOS;

    int t=1;
    // cin>>t;
    rep(i,0,t){
        solve();
        cout<<"\n";
    //   cout<<" * "<<t<<"\n";
    }
//    return 0;
}

Measured memory_bytes: 4792
dice = input().split()
cmd = input()
for i in range(len(cmd)):
    if cmd[i] == 'E':
        dice[0], dice[3], dice[5], dice[2] = dice[3], dice[5], dice[2], dice[0]
    elif cmd[i] == 'W':
        dice[0], dice[2], dice[5], dice[3] = dice[2], dice[5], dice[3], dice[0]
    elif cmd[i] == 'S':
        dice[0], dice[4], dice[5], dice[1] = dice[4], dice[5], dice[1], dice[0]
    elif cmd[i] == 'N':
        dice[0], dice[1], dice[5], dice[4] = dice[1], dice[5], dice[4], dice[0]

print(dice[0])



Measured memory_bytes: 5572
#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--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int q,a,b,c,d,s[100010]={},t[100010]={};
string ss,tt;

//項書換えだ〜、わーい。 多分合流性はあるので'A'の数でア

int main(){
	cin >> ss >> tt >> q;
	
	REP(i,0,ss.size()) s[i+1]=s[i]+(ss[i]=='A'?1:2);
	REP(i,0,tt.size()) t[i+1]=t[i]+(tt[i]=='A'?1:2);

	REP(i,0,q){
		cin >> a >> b >> c >> d;
		cout << ((s[b]-s[a-1])%3==(t[d]-t[c-1])%3?"YES":"NO") << endl;
	}			
	
	return 0;
}
	


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)




void solve(){
  int p,q,r;
  cin >> p >> q >> r;
  int a ;
  a = max(max(p,q), r);
  cout << p+q+r-a << endl;
}

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


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

int main() {
  int N;
  cin >> N;
  int A[N], B[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    cin >> B[i];
    if(A[i] - B[i] > 0) {
      ans += A[i] - B[i];
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    if n == 1:
        ans = 0
    else:
        mod = pow(10, 9)+7
        ans = (mod + pow(10, n, mod) + pow(8, n, mod) - 2*pow(9, n, mod)) % mod
    print(ans)
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 9172
a, b, c = map(int, input().split())
k = int(input())
if b <= a:
    while b <= a:
        b *= 2
        k -= 1
if c <= b:
    while c <= b:
        c *= 2
        k -= 1
if k >= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61580
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
}

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

using namespace std;
#define lint long long
#define P pair<int, int>

const lint mod = 1E9 + 7;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    
    lint dp[H + 1][W + 2];
    
    memset(dp, 0, sizeof dp);
    dp[0][1] = 1LL;
    
    int bt = (1 << (W - 1));
    
    vector<lint> lis;
    for(int i = 0; i < bt; ++i){
        bool flag = false;
        lint num = i;
        num <<= 1;
        for(int j = 1; j < W + 1; ++j){
            if(((num >> (j - 1)) & 1) && ((num >> j) & 1)){
                flag = true;
                break;
            }
        }
        
        if(flag){
            continue;
        }
        
        lis.push_back(num);
    }
    
    
    for(int i = 0; i < H; ++i){
        for(auto e : lis){
            
            for(int k = 1; k < W + 1; ++k){
                if((e >> (k - 1)) & 1){
                    dp[i + 1][k - 1] += dp[i][k];
                    dp[i + 1][k - 1] %= mod;
                } else if((e >> k) & 1){
                    dp[i + 1][k + 1] += dp[i][k];
                    dp[i + 1][k + 1] %= mod;
                } else {
                    dp[i + 1][k] += dp[i][k];
                    dp[i + 1][k] %= mod;
                }
                
            }
        }
    }
    cout << dp[H][K] << endl;
}

Measured memory_bytes: 256
def find(x): #xの根を求める
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y): #xとyの属する集合の併合
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y): #xとyが同じ集合に属するかの判定
    return find(x) == find(y)

def size(x): #xが属する集合の個数
    return -par[find(x)]

N,M,K = map(int, input().split())
par = [-1]*(N+1)
fri = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
    unite(a,b)

bro = [[] for i in range(N+1)]
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

ans = [0]*N
for i in range(1,N+1):
    ans[i-1] = size(i)-1
    for f in fri[i]:
        if same(f,i): ans[i-1] -= 1
    for b in bro[i]:
        if same(b,i): ans[i-1] -= 1

# print(par)
ans = list(map(str,ans))
print(" ".join(ans))

Measured memory_bytes: 50824
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	ans = [0 for i in range(N)]
	for x in range(1,100+1):
		for y in range(1,100+1):
			for z in range(1,100+1):
				tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x

				if tmp <= N:
					ans[tmp-1] += 1

	for i in ans:
		print(i)




#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 79508
n, k = map(int, input().split())

# kのべき乗でnを超える最大の冪数を求める
# 最大の冪数から順にとり尽くしていく
# 再帰で書ける？

def max_beki(number, k):
    beki = 0
    while k**beki <= number:
        beki += 1
    return beki

res = []
waru_kazu = k**(max_beki(n, k) - 1)
while waru_kazu >= 1:
    shou = n//waru_kazu
    res.append(str(shou))
    n -= shou*waru_kazu
    waru_kazu /= k

print(len(res))

Measured memory_bytes: 9188
const main = (input) => {
  input = input.trim().split('\n')

  const [n, m] = input[0].split(' ').map(Number)
  const arr = input[1].split(' ').map(Number)

  const homework = arr.reduce((a, b) => a + b, 0)

  return console.log(n - homework >= 0 ? n - homework : -1)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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



int main() {
 int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> w(N);
  for(int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
    w.at(a.at(i)-1) += 1;
    w.at(b.at(i)-1) += 1;
  }
  for(int i=0;i<N;i++){
    cout << w.at(i) << endl;
  }
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int x, y; cin >> x >> y;
    cout << x+y/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

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);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/
vvll tree;
vpll dp; // first -> white
vll col;
void dfs(ll x){
    col[x]=1;
    for(auto y : tree[x]){
        if(col[y]==0) {
            dfs(y);
            dp[x].first = (dp[x].first*((dp[y].first+dp[y].second)%mod))%mod;
            dp[x].second = (dp[x].second*dp[y].first)%mod;
        }
    }
}

int main(){
    _cin;
    // cout << setprecision(22);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n;
    tree.assign(n,{});
    dp.assign(n,{1,1});
    col.assign(n,0);
    fo(i,n-1){
        cin >> x >> y;
        x--;y--;
        tree[x].pb(y);
        tree[y].pb(x);
    }
    dfs(0);
    cout << (dp[0].first + dp[0].second)%mod;
}
 return 0;      
}

Measured memory_bytes: 12288
#include <iostream>
#include <deque>
#include <vector>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>

#define i64 long long
#define ui64 unsigned long long
#define REP(i,n) for(int (i)=0;(i)<(n);i++)
#define REP2(i,k,n) for(int (i)=(k);(i)<(n);i++)
#define MDIST(a,b) abs(a-b)
#define DIST(a,b) sqrt((a)*(a)+(b)*(b))
#define ATCODER 1000000007
using namespace std;
 
////////////////////////

int main(){
  int n,t,e;
  cin >> n >> t >> e;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if((t%a[i])<=e||(t/a[i]*a[i]+a[i])<=(t+e)){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> v(N),C(N);
    rep(i,N) cin >> v[i];
    rep(i,N) cin >> C[i];

    int ans = 0;
    rep(i,N) ans += max(v[i]-C[i],0);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define chmax(a,b) a=(a>b?a:b)

int main(){
    char S[15];
    scanf("%s", S);
    int tmp = 0, ans = 0;
    rep(i, 0, strlen(S)){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            tmp++;
        }else{
            tmp = 0;
        }
        chmax(ans, tmp);
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1704
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int[][] skills = new int[n][m];
		int[] cost = new int[n];
		for (int i = 0; i < n; i++) {
			cost[i] = sc.nextInt();
			for (int j = 0; j < m; j++) {
				skills[i][j] = sc.nextInt();
			}
		}

		int maxMaskN = 1 << n;
		int ans = Integer.MAX_VALUE;
		for (int mask = 0; mask < maxMaskN; mask++) {
			int[] learn = new int[m];
			int total = 0;
			for (int i = 0; i < n; i++) {
				// chosen
				if (((mask >> i) & 1) == 1) {
					total += cost[i];
					for (int j = 0; j < m; j++) {
						learn[j] += skills[i][j];
					}
				}
			}
			if (isValid(learn, x)) {
				ans = Math.min(ans, total);
			}
		}
		if (ans == Integer.MAX_VALUE) {
			ans = -1;
		}
		System.out.println(ans);
	}

	private static boolean isValid(int[] arr, int k) {
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] < k) {
				return false;
			}
		}
		return true;
	}
}
 
 
 
 
 
 
 
 
 
 


Measured memory_bytes: 37132
#include<stdio.h>
struct dice{
    int side[10];
    int temp;
    char order[110];
};
int main(void){
    struct dice d;
    int i;
    for(i=1;i<=6;i++)
        scanf("%d",&d.side[i]);
    scanf("%s",d.order);
    for(i=0;d.order[i]!='\0';i++){
        switch(d.order[i]){
            case 'N' :
                d.temp=d.side[1];
                d.side[1]=d.side[2];
                d.side[2]=d.side[6];
                d.side[6]=d.side[5];
                d.side[5]=d.temp;
                break;
            case 'S' :
                d.temp=d.side[1];
                d.side[1]=d.side[5];
                d.side[5]=d.side[6];
                d.side[6]=d.side[2];
                d.side[2]=d.temp;
                break;
            case 'W' :
                d.temp=d.side[1];
                d.side[1]=d.side[3];
                d.side[3]=d.side[6];
                d.side[6]=d.side[4];
                d.side[4]=d.temp;
                break;
            default :
                d.temp=d.side[1];
                d.side[1]=d.side[4];
                d.side[4]=d.side[6];
                d.side[6]=d.side[3];
                d.side[3]=d.temp;
                break;
        }
    }
    printf("%d\n",d.side[1]);
    return 0;
}

Measured memory_bytes: 596
import itertools

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

s = ''
t = ''

for i in range(n):
    s += str(p[i]-1)
    t += str(q[i]-1)

li = list(itertools.permutations(range(n)))
li2 = []

for i in range(len(li)):
    x = ''
    for j in range(n):
        x += str(li[i][j])
    li2.append(x)

for i in range(len(li2)):
    if li2[i] == s:
        counts = i
    if li2[i] == t:
        countt = i

print(abs(counts - countt))


Measured memory_bytes: 10868
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let r: f64 = read();
    println!("{}", r * 2.0 * 3.14);
}


Measured memory_bytes: 2200