akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a==b) {
			System.out.println(a*2);
		}
		else if(a>b){
			System.out.println((a)+max(a-1,b));
		}
		else {
			System.out.println((b)+max(b-1,a));
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
int H, W, N;
int main(){
    std::cin >> H >> W >> N;
    int result = 0;
    int W_n = 0, H_n = 0;
    while(result < N){
        std::max((W-H_n), (H-W_n));
        if((W-H_n) > (H-W_n) && W > W_n){
            W_n++;
        }else{
            H_n++;
        }
        result = (W-H_n)*W_n + (H-W_n)*H_n;
    }
    printf("%d\n", W_n+H_n);
    return 0;
}

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

int main(){

	double r, are, circ;

	cin >> r;

	are = r * r * 3.141592653589;
	circ = r * 2 * 3.141592653589;

	cout << fixed << are << " " << circ << "\n";

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int a, b;
  cin >> a >> b;
  int p = 1;
  REP(i,a) p *= 100;
  if(b == 100) ++b;
  cout << p*b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
 

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

	ll N,Q;
	string s;
	cin >> N >> Q;
	cin >> s;
	ll cnt[N+1]={};
	FOR(i,1,N){
		if(s[i-1]=='A'&&s[i]=='C')cnt[i]++;
		cnt[i]+=cnt[i-1];
	}
	FOR(i,0,Q){
		ll l,r;
		cin >> l >> r;
		l--;r--;
		cout << cnt[r] - cnt[l] << endl;
	}
}

Measured memory_bytes: 1872
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	a, b := scanInt64(), scanInt64()

	c, d := 4-a%4, (b+1)%4

	ans := int64(0)

	for i := int64(0); i < c; i++ {
		ans = ans^(a+i)
	}

	for i := int64(0); i < d; i++ {
		ans = ans^(b-i)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
/**
 *      ABC 71 A
 *      author  : kyomukyomupurin
 *      created : 
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, a, b; cin >> x >> a >> b;
    abs(x - a) > abs(x - b) ? cout << 'B' : cout << 'A';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int a = 0, i = 0;
  char S[200000] = {0}, T[200000] = {0};
  scanf("%s%s", S, T);
  while (T[i]) {
    if (S[i]!=T[i]) {
      a = a + 1;
    }
    i++;
  }
  printf("%d", a);
  return 0;
}

Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,ind;
    cin>>n;
    int a[n],b[n];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ind=a[i];
        b[ind]=i;
    }
    for(i=1;i<=n;i++)
        cout<<b[i]<<" ";
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>

class Dice{
    public:
    int a[7];//up,flont,right,left,back,down
    void roll(char d);
};

void Dice::roll(char d){
    int tmp;
    if(d=='N'){
        tmp=a[1];
        a[1]=a[2];
        a[2]=a[6];
        a[6]=a[5];
        a[5]=tmp;
    }
    else if(d=='S'){
        tmp=a[1];
        a[1]=a[5];
        a[5]=a[6];
        a[6]=a[2];
        a[2]=tmp;
    }
    else if(d=='W'){
        tmp=a[1];
        a[1]=a[3];
        a[3]=a[6];
        a[6]=a[4];
        a[4]=tmp;
    }
    else if(d=='E'){
        tmp=a[1];
        a[1]=a[4];
        a[4]=a[6];
        a[6]=a[3];
        a[3]=tmp;
    }
}

int main(void){
    int i;
    Dice dice;
    std::string s;
    
    for(i=1;i<7;i++){
        std::cin>>dice.a[i];
    }
    std::cin>>s;
    
    int l=s.length();
    for(i=0;i<l;i++){
        dice.roll(s[i]);
    }
    
    std::cout<<dice.a[1]<<std::endl;
}


Measured memory_bytes: 3168
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;

  int64_t Ans = N * (N - 1) / 2;
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 998_244_353;

fn main() {
    let n = scan!(usize);
    let vs = scan!(usize;n);
    let s: usize = vs.iter().sum();
    let max = *vs.iter().max().unwrap() as usize;

    let mut dp = vec![vec![0; n * max + 1]; n + 1];
    dp[0][0] = 1;
    for (i, &v) in vs.iter().enumerate() {
        for j in 0..dp[i].len() {
            if j >= v {
                dp[i + 1][j] += 2 * dp[i][j] + dp[i][j - v];
            } else {
                dp[i + 1][j] += 2 * dp[i][j]
            }
            dp[i + 1][j] %= MOD
        }
    }

    let num = dp[n]
        .iter()
        .enumerate()
        .filter(|&(i, _)| 2 * i >= s)
        .fold(0, |sum, (_, &num)| (sum + num) % MOD) as i64;

    let mut total = 1;
    for _ in 0..n {
        total *= 3;
        total %= MOD
    }

    let mut dp2 = vec![vec![0; n * max + 1]; n + 1];
    dp2[0][0] = 1;
    for (i, &v) in vs.iter().enumerate() {
        for j in 0..dp2[i].len() {
            if j >= v {
                dp2[i + 1][j] += dp2[i][j] + dp2[i][j - v];
            } else {
                dp2[i + 1][j] += dp2[i][j]
            }
            dp2[i + 1][j] %= MOD
        }
    }

    let num2 = dp2[n]
        .iter()
        .enumerate()
        .filter(|&(i, _)| 2 * i == s)
        .fold(0, |sum, (_, &num)| (sum + num) % MOD) as i64;

    println!(
        "{}",
        (((total + 3 * num2) % MOD - (3 * num) % MOD) + MOD) % MOD % MOD
    );
}


Measured memory_bytes: 618748
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
using namespace std;
typedef long long ll;


int main()
{
	ll n,cnt=0,ans=0;
	cin >> n;
	vector<string>s(n);
	rep(i,n)cin >> s[i];
	rep(i,n)sort(s[i].begin(), s[i].end());
	sort(s.begin(), s.end());
	s.push_back("#");
	rep(i,n) {
		cnt++;
		if (s[i] != s[i + 1]) {
			ans += cnt * (cnt - 1) / 2;
			cnt = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    bool d[10];
    for(int i = 0; i < k; i++){
        char dd;
        cin >> dd;
        d[dd-'0'] = true;
    }
    while(true){
        string s = to_string(n);
        for(char i : s) {
            if(d[i -'0']){
                goto E;
            }
        }
        cout << n << endl;
        break;
        E:;
        n++;
    }

    return 0;
}


Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S,T; cin >> S >> T;
    vector<string> ans;
    if(S.size() < T.size()) cout << "UNRESTORABLE" << endl;
    else {
        for(int i = 0; i <= S.size()-T.size(); i++) {
            string S_ = S;
            int count = 0;
            //cout << S_ << endl;
            for(int j = 0; j < T.size(); j++) {
                if(S_.at(i+j) == '?') S_.at(i+j) = T.at(j);
                else if(S_.at(i+j) != T.at(j)) break;
                count++;
            }
            if(count == T.size()) {
                for(int i = 0; i < S.size(); i++) if(S_.at(i) == '?') S_.at(i) = 'a';
                ans.push_back(S_);
            }
        }
        sort(ans.begin(),ans.end());
        if(ans.size() == 0) cout << "UNRESTORABLE" << endl;
        else cout << ans.at(0) << endl;
    }
}



Measured memory_bytes: 256
fun main(args:Array<String>){
    val s = readLine()
    when (s) {
        "SAT" -> {
            println(1)
        }
        "FRI" ->{
            println(2)
        }
        "THU" ->{
            println(3)
        }
        "WED" ->{
            println(4)
        }
        "TUE" ->{
            println(5)
        }
        "MON" ->{
            println(6)
        }
        else ->{
            println(7)
        }
    }
}

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

int main(){
  int n, k;
  cin>>n >>k;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin>>p[i];
  sort(p.begin(), p.end());
  int ans=0;
  for(int i=0;i<k;i++)ans+=p[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3556
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let n = read int
    let p :: ps =
        List.map (fun _ -> read int) [1..n]
        |> List.sortDescending
    p / 2 + List.sum ps
    |> printfn "%i"
    0

Measured memory_bytes: 14940
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int H,W;
char S[22][22];

int DFS(int x, int y, int max){

    return 0;
}


int main(void) {

    int a,b,c,d; cin>>a>>b>>c>>d;

    if(abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }else if(abs(a-b)<=d && abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

bool f() {

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


	if(occ.size() == 1)
		return occ[0] == n;
	if (n % 3 != 0)
		return false;
	vector<int> v;
	for (auto e : occ) {
		if (e.second % (n / 3))
			return false;
		for (int i = 0; i < e.second / (n / 3); ++i)
			v.push_back(e.first);
	}
	assert(v.size() == 3);
	assert(is_sorted(v.begin(), v.end()));
	do {
		if (v[2] == (v[0] ^ v[1]))
			return true;
	} while (next_permutation(v.begin(), v.end()));

	return false;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	cout << (f() ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,D,R1,R2;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	R1=A*B;
	R2=C*D;
	if(R1>R2)
		printf("%d",R1);
	else
   printf("%d",R2);
	return 0;
	}

Measured memory_bytes: 256
def main():
    n, x, y = (int(i) for i in input().split())

    x -= 1
    y -= 1
    # assume vertices are numbered [0, n)

    cts = [0] * n
    for i in range(n):
        for j in range(i+1,n):
            dist = min(j-i, abs(x-i) + 1 + abs(y-j),
                    abs(i-y) + 1 + abs(x-j))
            cts[dist] += 1

    for i in range(1, n):
        print(cts[i])
main()


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a , b;
  cin >> a >> b;
  string s;
  vector<string> hash;
  for(int i = 0; i < a ;i++){
    cin >> s;
    hash.push_back(s);
  }
  string t="";
  sort(hash.begin(),hash.end());
  for(int i = 0; i < a ; i++){
    t+=hash[i];
  }
  cout<<t;
}

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

int divisorsofnumbersfrom1toN(int n)
{
	int ans=0;
		
	for(int i=1;i<=sqrt(n);i++)
	{
		for(int j=i;j<=n;j+=i)
		{
			
			ans++;
			
			if(j/i!= i && j/i>sqrt(n))
			ans++;	
		}
	}
	
	return ans;
}

int solve()
{
	int n;
	cin>>n;
	int div=divisorsofnumbersfrom1toN(n-1);
	return div;
	
}
int main()
{
	cout<<solve();
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	for(int i=0; i<12; i++){
		char c;
		cin >> c;
		cout << c;
		if(i == 3){
			cout << ' ';
		}
	}
	puts("");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

template<class T,class U>
ostream& operator<<(ostream& ost, const pair<T,U> &p) {
    ost << "(" << p.first << ", " << p.second << ")";
    return ost;
}

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> last;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(m,M) cin >> c[m];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(d,D) rep(m,M) cin >> s[d][m];

    set<State> cur_states = {{0, vector<int>(M, -1), {}}};
    size_t SIZE = 900;

    rep(d,D) {
        set<State> nxt_states;
        for (auto &cur_itr : cur_states) {
            State state = cur_itr;
            ll minus_score = 0;
            rep(i,M) {
                minus_score -= c[i] * (d - state.last[i]);
            }
            rep(m,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][m] + minus_score + c[m] * (d - state.last[m]);
                nxt_state.last = state.last;
                nxt_state.last[m] = d;
                nxt_state.types = state.types;
                nxt_state.types.push_back(m);
                
                nxt_states.insert(nxt_state);
                if (nxt_states.size() > SIZE) {
                    nxt_states.erase(nxt_states.begin());
                }
            }
        }

        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states.begin()->types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    double sum=0,x;
    scanf("%d",&n);
    double a[n];
    for(i=0; i<n; i++)
    {
        scanf("%lf",&a[i]);

    }
    for(i=0;i<n;i++)
    {
        sum= sum+(1/a[i]);
    }
    x=1/sum;
    printf("%lf",x);

    return 0;
}





Measured memory_bytes: 256
n = int(input())
edge = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
visited = [0]*n
visited[0] = 1
visited[n-1] = 1
visited_all = [1]*n
nextF = edge[0]
nextS = edge[n-1]
black = 1
white = 1
while visited != visited_all:
    l = []
    for f in nextF:
        if visited[f] == 0:
            visited[f] = 1
            black += 1
            for x in edge[f]:
                l.append(x)
            nextF = l
    l = []
    for s in nextS:
        if visited[s] == 0:
            visited[s] = 1
            white += 1
            for y in edge[s]:
                l.append(y)
            nextS = l
if black > white:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 22984
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
#define MOD 1000000007

int n, a, b;


int main() {
	cin >> n >> a >> b;
	cout << min(a*n, b) << 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;
const ll mod = 1e9+7;

int g[15][15];//正直者かどうか

int main(){
  int n,y;
  cin >> n >> y;
  vector<int> bill_count(3,-1);
  for(int i=0;i <= n;++i){
    for(int j=0; (j+i) <= n;++j){
       ll cash = (10000 * i) + (5000 * j) + (1000 * (n-i-j));
      if(y == cash){ 
        bill_count[0] = i;
        bill_count[1] = j;
        bill_count[2] = n-i-j;      
      }   
    }
  }
  rep(i,3) cout << bill_count[i] << ((i == 2) ? "\n": " ") ;
}

Measured memory_bytes: 256
from collections import deque
DVSR = 1000000007
def LI(): return [int(x) for x in input().split()]
H,W=LI()
MP=[input() for _ in range(H)]
MEMO=[[(-1,0)]*W for _ in range(H)]
MEMO[0][0] = (0,1)
QU=deque([])

QU.append((0,0,0))
IT=[(1,0),(0,1)]
while QU:
    i,j,cost = QU.popleft()
    cost+=1
    pat = MEMO[i][j][1]
    for dy, dx in IT:
        ny, nx = i+dy, j+dx
        if ny < H and nx < W and MP[ny][nx] == '.':
            cost2, pat2 = MEMO[ny][nx]
            if cost2 == -1:
                MEMO[ny][nx] = (cost, pat)
                QU.append((ny,nx,cost))
            elif cost2 == cost:
                _pat = (pat+pat2)%DVSR
                MEMO[ny][nx] = (cost,_pat)

print(MEMO[H-1][W-1][1])

Measured memory_bytes: 88780
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int x;
	cin >> x;
	if (x == 0) cout << 1 << endl;
	else cout << 0 << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

const int MAX = 2000010;

ll fac[MAX], finv[MAX], inv[MAX];

void init_ncr() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll ncr(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll npr(ll val1, ll val2) {
  ll c = ncr(val1, val2);
  return c * fac[val2] % MOD;
}

ll cache25[MAX];
void init_cache25() {
  ll c = 1;
  for (ll i = 0; i < MAX; i++) {
    cache25[i] = c;
    c = (c * 25) % MOD;
  }
}

ll cache26[MAX];
void init_cache26() {
  ll c = 1;
  for (ll i = 0; i < MAX; i++) {
    cache26[i] = c;
    c = (c * 26) % MOD;
  }
}

int main() {
  init_ncr();
  init_cache25();
  init_cache26();

  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  string str;
  cin >> str;

  ll len = str.length();

  ll ans = 0;

  ll total_len = len + N;

  // N回操作する
  // len:元の文字列の長さ
  // total = N + len

  for (ll i = 0; i <= N; i++) {
    // cout << "i:" << i << endl;
    ll rest = N - i;
    ll count = ncr(rest + len - 1, len - 1);

    // cout << "(count):" << count << endl;
    // cout << "rest:" << rest << endl;

    count = count * cache25[rest];
    count %= MOD;
    count = count * cache26[i];
    count %= MOD;

    // cout << "count:" << count << endl;

    ans += count;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 83476
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int H,W;
i64 A,B;

int fie[1010][1010];
bool able[1010][1010];


int sx,sy;
int gx,gy;

int main() {
  cin >> H >> W >> A >> B;
  for(int i = 0;i < H;i++) {
    string s;
    cin >> s;
    for(int j = 0;j < W;j++) {
      if(s[j] == 's') {
        sx = i;
        sy = j;
      }
      else if(s[j] == 'g') {
        gx = i;
        gy = j;
      }
      else if(s[j] == '*') {
        fie[i][j] = -1;
      }
      else if(s[j] == '#') {
        fie[i][j] = 1;
      }
    }
  }
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      bool OK = true;
      for(int x = max(0, i - 1);x <= min(H - 1, i + 1);x++) {
        for(int y = max(0, j - 1);y <= min(W - 1, j + 1);y++) {
          if(fie[x][y] == -1) OK = false;
        }
      }
      if(OK) {
        able[i][j] = true;
      }
    }
  }

  using P = pair<i64,pair<int,int>>;

  vector<vector<i64>> dist(H, vector<i64>(W, 1e18));

  priority_queue<P,vector<P>,greater<P>> que;

  dist[sx][sy] = 0;
  que.push({dist[sx][sy], {sx, sy}});

  int dd[] = {1, 0, -1, 0};

  while(!que.empty()) {
    int x = que.top().second.first;
    int y = que.top().second.second;
    i64 d = que.top().first;
    que.pop();

    if(dist[x][y] < d) continue;

    for(int c = 0;c < 4;c++) {
      int i = x + dd[c];
      int j = y + dd[c ^ 1];
      if(0 <= i && i < H && 0 <= j && j < W && (fie[i][j] == 0 || fie[i][j] == -1)) {
        if(dist[i][j] > d + A) {
          dist[i][j] = d + A;
          que.push({dist[i][j], {i , j}});
        }
      }
    }
    if(able[x][y]) {
      for(int i = max(0, x - 1);i <= min(H - 1, x + 1);i++) {
        for(int j = max(0, y - 1);j <= min(W - 1, y + 1);j++) {
          if(i == x && j == y) continue;
          int cc = abs(i - x) + abs(j - y);
          if(dist[i][j] > d + A * cc + B) {
            dist[i][j] = d + A * cc + B;
            que.push({dist[i][j], {i , j}});
          }
        }
      }
    }
  } 
  if(dist[gx][gy] == 1e18) {
    cout << "INF" << endl;
  }
  else {
    cout << dist[gx][gy] << endl;
  }
}



Measured memory_bytes: 15700
#include <stdio.h>

int main(void) {
	int H, W;
	while (scanf("%d%d", &H, &W) == 2 && (H|W) != 0) {
		int i, j;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) putchar(i == 0 || j == 0 || i == H - 1 || j == W - 1 ? '#' : '.');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int main(void){
    unsigned long long x;
    scanf("%llu", &x);
    unsigned long long ans;
    unsigned long long total = 0;
    if (x % 11 == 0){
        ans = x / 11 * 2;
    }else{
        ans = x / 11 * 2;
        x %= 11;
        if (x > 6){
            ans += 2;
        }else{
            ans++;
        }
    }


    printf("%llu\n", ans);



    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(){
    int y,m,d;
    cin>>y>>m>>d;
    vector<int> h={31,4,30};
    if(h<vector<int>{y,m,d}){
        cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
    }
    else cout<<"HEISEI "<<y<<" "<<m<<" "<<d<<endl;
}
int main(){
    string s;
    while(cin>>s,s!="#")solve();
    return 0;
}


Measured memory_bytes: 3080
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
int sumVector (const std::vector<int>& v){ //int配列計算
    int sum = 0;
    rep(i, v.size()) sum += v.at(i);
    return sum; 
}
int main(void){
    int N, M;
    cin >> N;
    std::vector<string> s(N);
    rep(i, N) cin >> s[i];
    cin >> M;
    std::vector<string> t(M);
    rep(i, M) cin >> t[i];
    std::vector<int> money(N);
    rep(i,N){
        rep(j, N){
            if(s[i] == s[j]) money[i]++;
        }
        rep(j, M){
        if(s[i] == t[j]) money[i]--;
        } 
        
    }
    sort(money.begin(),money.end(), std::greater<int>());
    money[0] = max(money[0],0);
    cout << money[0];
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        ll k;
                        cin>>k;
                        ll ans=0;
                        rep(i,1,k+1)
                                rep(j,1,k+1)
                                        rep(l,1,k+1)
                                                ans+=__gcd(i,__gcd(j,l));
                                        cout<<ans;

                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans;
}

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

using LL = long long;
using PLL = pair<LL, LL>;
const LL INF = 1e18;
LL sum(LL n) {
	return (n * (n - 1)) / 2;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

	LL n, x, d; cin >> n >> x >> d;
	if (d == 0) {
	    if (x == 0) {
	        cout << "1\n";
	    } else {
            cout << n+1 << endl;
	    }
	    return 0;
	}
	LL ad = llabs(d);

	vector<pair<LL, PLL>> ranges;
	ranges.emplace_back(0, PLL(0, 0));
	for (int i = 1; i <= n; ++i) {
		LL rem = (i * x) % ad;
		LL q = (i * x - rem) / d;
		LL lo = sum(i);
		LL hi =	sum(n) - sum(n - i);
		ranges.emplace_back(rem, PLL{q + lo, q + hi});
	}
	sort(ranges.begin(), ranges.end());
	LL prv = -1;
	LL ans = 0, lo = -INF, hi = -INF - 10;
	for (auto& e: ranges) {
		if (e.first != prv) {
			ans += max(0ll, hi - lo + 1);
			lo = -INF, hi = -INF - 10;
			prv = e.first;
		}

		LL clo, chi; tie(clo, chi) = e.second;
		if (clo > hi) {
			ans += max(0ll, hi - lo + 1);
			lo = clo, hi = chi;
		} else {
			hi = max(hi, chi);
		}
	}
	ans += max(0ll, hi - lo + 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8432
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>

using namespace std;

int main(){
    int n;
    scanf("%d\n", &n);
    vector<tuple<string, int, int> > x;
    x.resize(n);
    for(int i = 0; i < n; ++i){
        string s;
        getline(cin, s);
        int p = s.find(' ');
        int v = stoi(s.substr(p, s.size() - p));
        x.at(i) = make_tuple(s.substr(0, p), -v, i);
    }
    sort(x.begin(), x.end());
    for(auto &v : x){
        printf("%d\n", get<2>(v) + 1);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)

typedef unsigned long ul;
using namespace std;

ul n;
ul times[5];

void solve() {
    ul mina = min(times[0], min(times[1], min(times[2], min(times[3], times[4]))));
    ul ans = 5;
    if (n % mina == 0) {
        ans += n / mina - 1;
    } else {
        ans += (n / mina);
    }
    cout << ans;
}

int main() {
    cin >> n;
    REP(i, 5) {
        cin >> times[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
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; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
ul N,cnt2[5],v[5],ans,f,i;
string S;
void combination(int now,int cnt,int goal){
  if(cnt==goal){
    ul tmp=1;
    for(int i=0;i<5;i++){
      if(v[i]&&cnt2[i])tmp*=cnt2[i];
      else if(v[i]&&!cnt2[i])return;
    }
    ans+=tmp;
    return;
  }
  for(int i=now;i<5;i++){
    if(!(f&(1<<i))){
      v[i]=1;
      f|=(1<<i);
      combination(i+1,cnt+1,goal);
      v[i]=0;
      f&=~(1<<i);
    }
  }
}

inline void solve(){
  IN(N);
  REP(i,N){
    IN(S);
    if(S[0]=='M')cnt2[0]++;
    if(S[0]=='A')cnt2[1]++;
    if(S[0]=='R')cnt2[2]++;
    if(S[0]=='C')cnt2[3]++;
    if(S[0]=='H')cnt2[4]++;
  }
  combination(0,0,3);
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main() {
	long n,m,i,j,k,ans,cur,res,jud,l,r;
	string s;
	cin >> s >> k;
	ans=0; jud=0; res=0;
	n=s.size();
	if(s[n-1]==s[0]) jud=1;
	for(i=0; i<n; i++){
		if(s[i]!=s[0]) break;
	}
	if(i==n){
		cout << (n*k)/2; return 0;
	}
	
	l=0; r=n-1;
	if(jud==1){
		i=1; cur=2;
		while(s[i]==s[0]){
			cur++; i++;
		}
		l=i;
		i=n-2;
		while(s[i]==s[0]){
			cur++; i--;
		}
		r=i;
		
		ans+=(cur/2)*(k-1);
		ans+=l/2;
		ans+=((n-1)-r)/2;
	}
	
	i=l;
	while(i<=r){
		cur=1;
		if(s[i]==s[i+1]){
			while(s[i]==s[i+1]){
				i++; 
				cur++;
			}
			ans+=(cur/2)*k;
		}
		i++;
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  ll h, w, a, b; cin >> h >> w;
  vector<vector<ll> > v(h, vector<ll>(w));
  vector<pair<pair<int, int>, pair<int, int> > > ans;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> v[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    if(i % 2 == 0){
      for(int j = 0; j < w; j++){
        if(v[i][j] % 2 == 1){
          if(j + 1 < w){
            a = i;
            b = j + 1;
          }
          else{
            if(i + 1 >= h) break;
            a = i + 1;
            b = w - 1;
          }
          v[i][j]--;
          v[a][b]++;
          ans.push_back(make_pair(make_pair(i, j), make_pair(a, b)));
        }
      }
    }
    else{
      for(int j = w - 1; j >= 0; j--){
        if(v[i][j] % 2 == 1){
          if(j - 1 >= 0){
            a = i;
            b = j - 1;
          }
          else{
            if(i + 1 >= h) break;
            a = i + 1;
            b = 0;
          }
          v[i][j]--;
          v[a][b]++;
          ans.push_back(make_pair(make_pair(i, j), make_pair(a, b)));
        }
      }
    }
  }
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i].first.first + 1 << " " << ans[i].first.second + 1 << " " << ans[i].second.first + 1 << " " << ans[i].second.second + 1 << endl;
  }
  return;
}

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


Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 1e5+2;
int n,a[MAX],b[MAX],c[MAX];
ll S[MAX];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);
    int cur = 1;
    for(int i=1;i<=n;i++){
        while(c[cur]<=b[i] && cur<=n) cur++;
        S[i] = S[i-1]+(ll)(n-cur+1);
    }
    cur = 1;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        while(b[cur]<=a[i] && cur<=n) cur++;
        ans += (S[n]-S[cur-1]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  ld l; cin >> l;
  cout << fixed << setprecision(8) << pow(l/3, 3) << endl; 
  return 0;
}

Measured memory_bytes: 512
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
d = list( map(int, input().split()) )
MOD = 998244353

c = Counter(d)

def count(c, iter):
    if c[0] != 1 or d[0] != 0:
        return 0

    res = 1
    for i in range(2, iter+2):
        for _ in range(c[i]):
            res *= c[i-1]%MOD
        res %= MOD
    return res%MOD

res = count(c, max(d))
print(res)

Measured memory_bytes: 62116
# coding: utf-8
n = int(input())
points = [[0, 0, 0]]
for i in range(n):
    points.append(list(map(int, input().split())))

def can_exist(before_point, after_point):
    def_t = after_point[0] - before_point[0]
    def_x = after_point[1] - before_point[1]
    def_y = after_point[2] - before_point[2]
    def_total = abs(def_x) + abs(def_y)
    if def_total <= def_t and def_total % 2 == def_t % 2:
        return True
    else:
        return False

out = 'Yes'
for i in range(n):
    if can_exist(points[i], points[i+1]):
        continue
    else:
        out = 'No'
        break

print(out)

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

typedef long long int ll;

int main()
{
    string s;
    cin >> s;
    
    if(s.size() % 2 != 0){
        cout << "No";
        return 0;
    }
    for(ll i = 0;i < s.size() - 1;i = i + 2){
        if(s[i] != 'h' || s[i + 1] != 'i'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    
    return 0;
}


Measured memory_bytes: 256
import math


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

    A_deg = (360 / 12) * H + (((360 / 12) / 60) * M)
    B_deg = (360 / 60) * M

    Ax = math.sin(math.radians(A_deg)) * A
    Ay = math.cos(math.radians(A_deg)) * A
    Bx = math.sin(math.radians(B_deg)) * B
    By = math.cos(math.radians(B_deg)) * B

    print(math.sqrt((Ax - Bx) ** 2 + (Ay - By) ** 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,k; cin >> n >> k;
	vector<int> a(n); rep(i,n) cin >> a[i];
	rep(i,n) if(a[i] >= k) a[i] = 0;
	sort(rall(a));
	while(!a.empty() && a.back() == 0) a.pop_back(), n--;
	vector<vector<int>> dp(n+1,vector<int>(k+1,0));
	dp[0][0] = 1;
	rep(i,n){
		rep(j,k+1){
			dp[i+1][j] = dp[i][j];
			if(j-a[i] >= 0) dp[i+1][j] += dp[i][j-a[i]];
		}
	}
	vector<vector<int>> ep(n+1,vector<int>(k+1,0));
	rep(j,k+1) ep[n][j] = 1;
	rep(i,n+1) ep[i][0] = 1;
	ll ans = 0;
	for(ll i=n-1; i>=0; i--){
		bool flag = true;
		rep(j,k-a[i]){
			if(dp[i][j] && ep[i+1][k-j-1] - ep[i+1][k-a[i]-1-j]){
				flag = false;
				break;
			}
		}
		REP(j,k-a[i],k) if(dp[i][j]) flag = false;
		if(flag) ans++;
		rep(j,k){
			ep[i][j+1] = ep[i][j] + ep[i+1][j+1] - ep[i+1][j];
			if(j+1-a[i]==0) ep[i][j+1]++;
			else if(j+1-a[i]>0) ep[i][j+1] += ep[i+1][j+1-a[i]]-ep[i+1][j-a[i]];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 195968
#!/usr/bin/env python3

def main():
    N = int(input())
    a = list(map(int, input().split()))

    INF = 1 << 60
    a_sum = [0] * (N + 1)
    for i in range(N):
        a_sum[i + 1] = a_sum[i] + a[i]
    ans = INF
    for i in range(1,N):
        ans = min(ans, abs(a_sum[i] - (a_sum[N] - a_sum[i])))
    print(ans)


if __name__ == "__main__":
    main()


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

int sum_digit(int n){
    int sum = 0;
    while(n > 0)
    {
        sum += n % 10;
        n /= 10;
    }

    return sum;

}

int main() {
    int n = 0;

    cin >> n;

    
int a = sum_digit(n);
    
    if(n % a == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a, b;
    cin>> a>> b;
    if(a>b)
        swap (a, b);

    cout << string (b, (a+ '0'));
    nl;

    return 0;
}




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

int main()
{
    int n, pt, px, py;
    cin >> n;
    pt = px = py= 0;
    while(n--){
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(x-px) + abs(y-py);
        if(t-pt < d || (t-pt-d)%2 ==1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256