akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

/**
 * https://abc057.contest.atcoder.jp/tasks/abc057_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		Point[] s = new Point[N];
		Point[] p = new Point[M];
		for(int i=0; i<N; i++) s[i] = new Point(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
		for(int i=0; i<M; i++) p[i] = new Point(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
		sc.close();
		
		int[] ans = new int[N];
		for(int i=0; i<N; i++){
			long min = Long.MAX_VALUE;
			for(int j=0; j<M; j++){
				long d = Math.abs(s[i].x-p[j].x)+Math.abs(s[i].y-p[j].y);
				if(min>d){
					min = d;
					ans[i] = j+1;
				}
			}
		}
		
		for(int a:ans) System.out.println(a);
		

	}
	
	static class Point{
		int x;
		int y;
		Point(int x, int y){
			this.x = x;
			this.y = y;
		}
	}

}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int num[10000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>n;
	cin>>sa;
	LL t[3]={0};
	for(i=0;i<n;i++){
		if(sa[i]=='R')t[0]++,num[i]=1;
		if(sa[i]=='G')t[1]++,num[i]=10;
		if(sa[i]=='B')t[2]++,num[i]=100;
	}
	LL s=t[0]*t[1]*t[2];
	for(i=0;i<n;i++){
		for(j=1;i+2*j<n;j++){
			if(num[i]+num[i+j]+num[i+j*2]==111)s--;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3640
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,C = inputs()
stc = [inputs() for i in range(N)]
stc = sorted(stc,key=lambda x:x[1])
stc = sorted(stc,key=lambda x:x[2])
ans = [0]*(10**5+2)
for i in range(N):
    s,t,c, = stc[i]
    if i>0 and c==stc[i-1][2] and s==stc[i-1][1]:
      ans[s+1]+=1
      ans[t+1]-=1
      continue
    ans[s]+=1
    ans[t+1]-=1
ans = list(accumulate(ans))
print(max(ans))

Measured memory_bytes: 23724
#include <bits/stdc++.h> 
using namespace std;
int main()
{
int K,A,B,m,n;
cin>>K;
cin>>A;
cin>>B;
m=A/K;
n=B/K;
if((A%K)!=0 && (B%K)!=0)
{
    if((n-m)>=1)
    cout<<"OK";
    else
    cout<<"NG";
}
if((A%K)==0 || (B%K)==0)
{
    if((n-m)>=0)
    cout<<"OK";
    else
    cout<<"NG";
}
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#define INFTY 1001001001

int S[500100]={0};
int n,cnt=0;

void merge(int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    int *L = new int[n1 + 1], *R = new int[n2 + 1];

    for (int i = 0; i < n1; ++i)
    {
        L[i] = S[left + i];
    }

    for (int i = 0; i < n2; ++i)
    {
        R[i] = S[mid + i];
    }

    L[n1] = INFTY;
    R[n2] = INFTY;
    int i = 0, j = 0;
    for (int k = left; k < right ; ++k)
    {
        if (L[i] <= R[j])
        {
            S[k] = L[i];
            ++i;
        }
        else
        {
            S[k] = R[j];
            ++j;
        }
        ++cnt;
    }
    delete[] L,R;
}

void mergeSort(int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(left,mid);
        mergeSort(mid,right);
        merge(left,mid,right);
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>S[i];
    }

    mergeSort(0,n);
    for(int i=0;i<n;++i){
        cout<<S[i];
        if(i!=n-1){
            cout<<" ";
        }
        else{
            cout<<"\n";
        }
    }
    cout<<cnt<<"\n";
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s;
    cin >> s;

    int cnt = 0;
    int len = s.size();
    for (int i = 1; i < len; i++) {
        if (s[i-1] != s[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
use std::cmp::{max,min};
fn main() {
    let n = rv::<usize>()[0];
    let mut s = Vec::with_capacity(n);
    for _ in 0..n {
        s.push(rl().trim_right().bytes().map(|x|(x-b'0')as i32).collect::<Vec<_>>());
    }
    for i in 0..n { for j in 0..n { if i!=j && s[i][j]==0 {
        s[i][j]=INF;
    }}}
    for k in 0..n { for i in 0..n { for j in 0..n {
        s[i][j]=min(s[i][j],s[i][k]+s[k][j]);
    }}}
    let mut d = vec![0;n];
    for i in 0..n {
        let mut p=i;
        for j in 0..i { if s[i][j]<INF {
            p=j;
            break;
        }}
        for j in i..n { if s[i][j]<INF {
            if s[i][j]==1 {
                for k in j+1..n { if s[i][k]<INF {
                    if s[i][k]==s[j][k] {
                        println!("-1");
                        return;
                    }
                }}
            }
            d[p]=max(d[p],s[i][j]+1);
        }}
    }
    println!("{}",d.into_iter().sum::<i32>());
}
const INF: i32=std::i32::MAX/2;
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4476
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	var s string
	dict := map[string]int{}
	maxCount := 1
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		if _, ok := dict[s]; ok {
			dict[s] = dict[s] + 1
			if maxCount < dict[s] {
				maxCount = dict[s]
			}
		} else {
			dict[s] = 1
		}
	}
	slice := []string{}
	for key, val := range dict {
		if val == maxCount {
			slice = append(slice, key)

		}
	}
	sort.Strings(slice)
	for i := 0; i < len(slice); i++ {
		fmt.Println(slice[i])
	}

}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x,y; cin >> x >> y;
    for(int i=0;i<=x;i++){
        int j=x-i;
        if(i*4+j*2 == y){
            out("Yes");
            return 0;
        }
    }
    out("No");
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N,K;
    double p[200010];
    int num;
    double sum=0;
    double ans=0;

    scanf("%d",&N);
    scanf("%d",&K);

    for(int i=0;i<N;i++){
        scanf("%d",&num);
        p[i]=(num+1)*(num/2.0)/num;
    }

    sum=0;
    for(int i=0;i<K;i++){
        sum+=p[i];
    }
    ans=sum;

    for(int i=1;i<=N-K;i++){
        sum=sum-p[i-1]+p[i+K-1];
        if(ans<sum){
            ans=sum;
        }
    }

    printf("%lf",ans);

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n , x , y , z , ans=0;
	cin >> n ;
	int i , j ;
	for( i=1 ; i<=n ; i++ ){
		cin >> x >> y >> z ;
		ans=0;
		j=0;
		if( x*x+y*y== z*z )
			ans ++ ;
		if( y*y+z*z== x*x )
			ans++;
		if( z*z+x*x==y*y )
			ans++;
		if( ans!=0)
			cout <<"YES" << endl;
		else cout <<"NO"<< endl;
	}
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	headString, tailString := s[:2], s[2:]
	head, _ := strconv.Atoi(headString)
	tail, _ := strconv.Atoi(tailString)
	if (head == 0 && tail > 12) || (head > 12 && tail == 0) || (head == 0 && tail == 0) {
		fmt.Println("NA")
	} else if head <= 12 && head > 0 && tail <= 12 && tail > 0 {
		fmt.Println("AMBIGUOUS")
	} else if head <= 12 && head > 0 {
		fmt.Println("MMYY")
	} else if tail <= 12 && tail > 0 {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}

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

int main() {
  string S;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else if(S=="Rainy"){
    cout<<"Sunny"<<endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<PP> v;
  set<ll> s;
  rep(i,n){
    ll a,b;cin >>a  >> b;
    v.push_back(mp(a,mp(b,1)));
  }
  rep(i,n){
    ll a,b;cin >>a  >> b;
    v.push_back(mp(a,mp(b,0)));
  }
  sort(all(v));
  ll ans = 0;
  rep(i,2*n){
    auto tmp = v[i];
    if(v[i].second.second){
      s.insert(v[i].second.first);
    }else{
      auto it = s.lower_bound(v[i].second.first);
      if(it!=s.begin()){
        ans++;
        s.erase(--it);
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
puts S[0..N-8-1].join("")

Measured memory_bytes: 3836
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int l;
	cin>>l;
	string s,t;
	cin>>s>>t;
	if(s+t>t+s)swap(s,t);
	int n=s.size(),m=t.size();
	for(int i=l/n;i>=0;i--){
		if((l-i*n)%m==0){
			rep(j,i)cout<<s;
			rep(j,(l-i*n)/m)cout<<t;
			break;
		}
	}
	cout<<endl;
}










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

using namespace std;

int main (){
  string S;
  cin >> S;

  if(S == "SUN") cout << 7 << endl;
  if(S == "MON") cout << 6 << endl;
  if(S == "TUE") cout << 5 << endl;
  if(S == "WED") cout << 4 << endl;
  if(S == "THU") cout << 3 << endl;
  if(S == "FRI") cout << 2 << endl;
  if(S== "SAT") cout << 1 << endl;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,k; cin>>n>>k;
  int max = (n-1)*(n-2)/2;
  if (k > max) {
    cout << -1 << endl;
    return;
  }

  int m = n-1 + max-k;
  cout << m << endl;
  for (int i=2; i<=n; i++) {
    printf("%d %d\n", 1,i);
  }
  int now = max;
  for (int i=2; i<n; i++) {
    for (int j=i+1; j<=n; j++) {
      if (now > k) {
        printf("%d %d\n", i,j);
        now--;
      } else {
        return;
      }
    }
  }

}

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


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int K;
int N;
const LL inf=1LL<<40;
const int L=3e5+10;
LL f[L];
int main() {
	scanf("%d%d",&K,&N);
	if (K%2==0){
		printf("%d",K/2);
		for(int i=1;i<N;i++){
			printf(" %d",K);
		}
		puts("");
		return 0;
	}

	LL p=1;
	f[0]=1;
	for(int i=1;i<=N;i++){
		p*=K;
		if(p>inf){
			p=inf;
		}
		if(f[i-1]+p>inf){
			f[i]=inf;
		}
		else{
			f[i]=f[i-1]+p;
		}
	}

	LL v=0;
	if(N%2==0){
		v--;
	}
	auto sp="";
	for(int n=N;n>0;n--){
		//cerr << f[n] << ", " << f[n]+v << endl;
		//assert(f[n]==inf||((f[n]+v)%2==0&&0<=f[n]+v&&f[n]+v<2*f[n]));
		if(f[n]+v==0){
			break;
		}
		if(n==1){
			printf("%s%d",sp,(int)(f[n]+v)/2);
			break;
		}
		if(f[n-1]==inf){
			printf("%s%d",sp,K/2+1);
			v--;
		}
		else{
			LL r=((K-1)*f[n-1]+v-1)/(2*f[n-1]);
			while((K-1)*f[n-1]+v-1-2*r*f[n-1]>=f[n-1])
			{
				r++;
			}
			while((K-1)*f[n-1]+v-1-2*r*f[n-1]<-f[n-1])
			{
				r--;
			}
			v=(K-1)*f[n-1]+v-1-2*r*f[n-1];
			printf("%s%d",sp,(int)r+1);
			//cerr << v << ", " << r << endl;
		}

		sp=" ";
	}
	puts("");

	return 0;
}



Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int[] nums = new int[101];
			while (nums[0] != 2) {
				int num = in.nextInt();
				nums[num] += 1;
			}
			String s = "NG";
			if (nums[1] % 2 == 1 && nums[2] % 2 == 1) {
				s = "OK";
				for (int i = 3; i <= 100; i++) {
					if (nums[i] % 2 == 1) {
						s = "NG";
						break;
					}
				}
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 19284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define mem(a) memset(a,0,sizeof(a))
#define mems(a) memset(a,-1,sizeof(a))
#define SZ size
#define SET setprecision
ll a[10005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //////////////////////////////////////////
    ll i,j,x,y,n,m,z,sz,p,q,r,tc;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    z=1000;
    y=0;
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            y++;
            a[i]=z--;
        }
    }
    cout<<y<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

double T[2][102], V[102], max_s[2 * 200 * 100 + 1];

int main() {
    int N, t, times = 0;
    cin >> N;
    FOR(i, 1, N + 1)  {
        cin >> t;
        T[0][i] = times;
        times += 2 * t;
        T[1][i] = times;
    }
    FOR(i, 1, N + 1) cin >> V[i];
    T[0][N + 1] = T[1][N + 1] = times;

    fill(max_s, max_s + 2 * 200 * 100 + 1, 1000);
    REP(i, times + 1) REP(j, N + 2) {
        if (i < T[0][j])       max_s[i] = min(max_s[i], V[j] + (T[0][j] - i) / 2);
        else if (i <= T[1][j]) max_s[i] = min(max_s[i], V[j]);
        else                   max_s[i] = min(max_s[i], V[j] + (i - T[1][j]) / 2);
    }

    double ans = 0;
    REP(i, times) ans += (max_s[i] + max_s[i + 1]) / 4;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string s , t;
  cin >> s >> t;
  if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0])cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


Measured memory_bytes: 256
n= int(input())
a= [int(i) for i in input().split()]
pref=[0]*n
m = 10**9+7
pref[0] = a[0]%m
for i in range(1,n):
    pref[i] =  (pref[i-1]+a[i])%m
m = 10**9+7
ans = 0
#print(pref)
for i in range(n-1):
    ans+= (a[i]%m *((pref[n-1]-pref[i])%m))%m
    ans = ans%m
print(ans)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, K;
int D[11];

int main() {
   cin >> N >> K;
   rep (i, K) {
      cin >> D[i];
   }

   ll num = N;
   while (1) {
      string s = to_string(num);

      bool f = true;
      for (int i = 0; i < K; i++) {
         if (count(all(s), D[i]+'0')) {
            f = false;
            num++;
            break;
         }
      }

      if (f) {
         cout << num << endl;
         return 0;
      }
   }

   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int x = sc.nextInt();
        	int y = sc.nextInt();
        	int s = sc.nextInt();
        	if(x+y+s==0) {
        		break;
        	}
        	int max = 0;
        	for(int i=1; i<1000; i++) {
        		for(int j=1; j<1000; j++) {
        			if(Math.floor((i*(100+x)/100 + j*(100+x)/100)) == s) {
        				max = Math.max((int)Math.floor((i*(100+y)/100 + j*(100+y)/100)), max);
        			}
        		}
        	}
        	System.out.println(max);
        }
    }
}


Measured memory_bytes: 28976
S = set(input())
NS = {"N", "S"}
EW = {"E", "W"}

if(len(S)%2 != 0):
    print("No")
else:
    if(len(S) == 4):
        print("Yes")
    else:
        if(NS == S or EW == S):
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3060
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n;
    cout<<(n+(n*n)+(n*n*n))<<NL;


    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3576
while True:
    num = list(map(int,input().split()))
    if(num[0] == 0 and num[1] == 0): break
    c = 0
    for i in range(1,num[0] - 1):
        for j in range(i+1,num[0]):
            for k in range(j+1,num[0]+1):
                if(i+j+k == num[1]): c += 1
    
    print(c)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  ll ans=INF;

  ll x;
  ll cnt;
  rep(i,n){
    cin>>x;
    cnt=0;
    while(x%2==0){
      x/=2;
      cnt++;
    }
    chmin(ans,cnt);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

int main(){
  int i,j,k,n,u,v;
  int Adj[MAX+1][MAX+1];
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	Adj[i][j] = 0;
      }
    }
  
    for(i=1;i<=n;i++){
      scanf("%d%d",&u,&k);
      for(j=1;j<=k;j++){
	scanf("%d",&v);
	Adj[i][v] = 1;
      }
    }

  for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(j) printf(" ");
	printf("%d",Adj[i+1][j+1]);
      }
      printf("\n");
      }


 return 0;
}




Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
/*int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}*/
bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(y.second==x.second)
        return y.first<x.first;
    return y.second<x.second;
}*/
int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        int n=s.length();
        if(s[n-1]=='s')s+="es";
        else s+="s";
        cout<<s<<"\n";
    }

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    rep(i,n){
        if(ans>(ll)1e18/a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4064
import sys
sys.setrecursionlimit(100000)
from math import floor
n,x=map(int,input().split())
ans=0
def f(x,y):
    if y%x==0:
        return (y//x-1)*2*x+x
    return 2*x*(y//x)+f(y%x,x)
print(n+f(min(x,n-x),max(x,n-x)))

Measured memory_bytes: 3060
use proconio::input;

struct UnionFindTree<T: Ord + Copy> {
    parents: Vec<T>,
}

impl<T: Ord + Copy + From<usize> + Into<usize> + Eq> UnionFindTree<T> {
    fn new(n: usize) -> UnionFindTree<T> {
        UnionFindTree {
            parents: (0..n).map(|i| i.into()).collect(),
        }
    }

    fn root(self: &mut Self, x: T) -> T {
        if self.parents[x.into()] == x {
            x
        } else {
            let r = self.root(self.parents[x.into()]);
            self.parents[x.into()] = r;
            r
        }
    }

    fn same(self: &mut Self, x: T, y: T) -> bool {
        self.root(x) == self.root(y)
    }

    fn unite(self: &mut Self, x: T, y: T) {
        let x = self.root(x);
        let y = self.root(y);
        if x != y {
            self.parents[x.into()] = y;
        }
    }
}

fn solve(n: usize, xy: &[(i32, i32)]) -> i32 {
    let mut xs = xy
        .iter()
        .enumerate()
        .map(|(i, &(x, _))| (x, i))
        .collect::<Vec<_>>();
    let mut ys = xy
        .iter()
        .enumerate()
        .map(|(i, &(_, y))| (y, i))
        .collect::<Vec<_>>();
    xs.sort();
    ys.sort();
    let mut e = xs
        .iter()
        .zip(xs.iter().skip(1))
        .map(|(&(x1, i), &(x2, j))| (x2 - x1, i, j))
        .chain(
            ys.iter()
                .zip(ys.iter().skip(1))
                .map(|(&(y1, i), &(y2, j))| (y2 - y1, i, j)),
        )
        .collect::<Vec<_>>();
    e.sort();
    let mut u = UnionFindTree::<usize>::new(n);
    let mut r = Vec::new();
    for &(d, i, j) in e.iter() {
        if !u.same(i, j) {
            r.push((d, i, j));
            u.unite(i, j);
        }
    }
    r.iter().map(|&(d, _, _)| d).sum()
}

fn main() {
    input! {
        n: usize,
        xy: [(i32, i32); n],
    }
    let r = solve(n, &xy);
    println!("{}", r);
}


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

int main(){
	int n;
	int min=1000000, max=-1000000;
	long sum=0;
	cin >> n;
	for(int i=0; i<n; i++){
		int in;
		cin >> in;
		if(in<min) min = in;
		if(in>max) max = in;
		sum += in;
	}
	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int mod = 1000000007;
struct mint {
  // https://github.com/atcoder-live/library/blob/master/mint.cpp
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime inv
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) { cin >> A[i]; }
  mint ans(1);
  vector<int> color(3);
  REP(i, N) {
    int tmp = 0;
    REP(j, 3) {
      if (A[i] == color[j]) tmp++;
    }
    ans.x = (ans * tmp).x;
    REP(j, 3) {
      if (A[i] == color[j]) {
        color[j]++;
        break;
      }
    }
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  rep(i,0,n)cin >> d[i];
  m = -1;
  l = 0;
  // int p = 0;
  rep(i,0,n){
    if(l == 1){
      m = i;
      // p++;
      break;
    }
    l = d[l]-1;
  }
  // if(p == 0 && l == 1)m = n;
  print(m);
  return 0;
}

Measured memory_bytes: 1024
prime = []
for i in range(2, 1001):
	prime.append(i)

i = 0
while i < len(prime):
	if prime[i] < 32: break
	j = i + 1
	while j < len(prime):
		if prime[j] % prime[i] == 0:
			prime.pop(j)
		else:
			j = j + 1
	i = i + 1

primecount = []
for i in range(0, len(prime)):
	primecount.append(0)

N = int(raw_input())

for i in range(1, N+1):
	m = i
	j = 0
	while m >= prime[j]:
		if m % prime[j] == 0:
			primecount[j] = primecount[j]+1
			m = m / prime[j]
		else:
			j = j + 1

cnt = 1
for i in range(0, len(primecount)):
	cnt = cnt * (primecount[i]+1)

print cnt % 1000000007

Measured memory_bytes: 2696
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    stack<char>s ;
    string str,m;
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(str[i]!='B')
           s.push(str[i]);
        else{
            if(!s.empty())
               s.pop();
        }
    }
    
    while (!s.empty()) 
    { 
       m+= s.top(); 
        s.pop(); 
    } 
    reverse(m.begin(),m.end()); 
    cout<<m;
    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
                        
            var mae = s.Substring(0, (s.Length) / 2).ToCharArray();
            var ushiro = s.Substring((s.Length + 2 - 1) / 2, s.Length - (s.Length + 2 - 1) / 2).Reverse().ToArray();

            var count = 0;
            for (int i = 0; i < mae.Length; i++)
            {
                if (mae[i] != ushiro[i]) count++;
            }

            Console.WriteLine(count);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13268
# 2019-11-12 13:20:54(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    t, x = [int(i) for i in sys.stdin.readline().split()]
    print(t / x)




if __name__ == "__main__":
    main()


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//s.find(w[i])==string::npos
//findの使い方

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,x[100000],y[100000],t[100000],xcmp=0,ycmp=0;

string s,w;

vector<int> z;

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

	cin >> n;
	rep(i,n){
	    cin >> t[i] >> x[i] >> y[i];
	    if(t[i]<x[i]+y[i]){
	        cout << "No" << endl;
	        return 0;
	    }
	   if(i==0){
	       xcmp=x[i];
	       ycmp=y[i];
	       cnt=xcmp+ycmp;
	       if((t[i]-cnt)%2==0){
	           continue;
	       }
	       else{
	           cout << "No" << endl;
	           return 0;
	       }
	   }
	   else{
	       xcmp=x[i]-x[i-1];
	       ycmp=y[i]-y[i-1];
	       if(xcmp<0){
	           xcmp*=-1;
	       }
	       if(ycmp<0){
	           ycmp*=-1;
	       }
	       cnt=xcmp+ycmp;
	       if((t[i]-t[i-1]-cnt)%2==0){
	           continue;
	       }
	       else{
	           cout << "No" << endl;
	           return 0;
	       }
	   }
	}
	cout << "Yes" << endl;
	
return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define test ll t; cin>>t; while(t--)
int main() {
	fast;
	int i,l,c=0;
	string s;
	cin>>s;
	l=s.length();
	for(i=0;i<l/2;i++){
	    if(s[i]!=s[l-i-1])
	     c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, list(input()))
# print(a, b, c, d)

def add(x, y):
    return x + y


def sub(x, y):
    return x - y

for op1 in [('+', add), ('-', sub)]:
    for op2 in [('+', add), ('-', sub)]:
        for op3 in [('+', add), ('-', sub)]:
            result = op3[1](op2[1](op1[1](a, b), c), d)
            if result == 7:
                print(str(a) + op1[0] + str(b) + op2[0] + str(c) + op3[0] + str(d) + '=7')
                exit(0)



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

int main(){
string s,t;
cin >>s>>t;

for(int i=0;i<s.length();i++){

if(s==t){
cout<<"Yes" << endl;
return 0;
}
rotate(s.begin(),s.end()-1,s.end());

}

cout<<"No" << endl;
}

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

int main() {
	int n,a[101];
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	for ( int i = 0; i < n; i++ ) {
		cout << a[n - i -1];
		if ( i != n - 1 ) cout << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3136
import math

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice)))
continius_probability = lambda rolls: (1 / 2) ** rolls
dice_probablility = lambda N: 1 / N

answer = 0
for dice in range(1, N + 1):
    answer += continius_probability(num_of_rolls(dice, K))
answer *= dice_probablility(N)

print(answer)


Measured memory_bytes: 3444
import math

input_line = [int(i) for i in input().split()]
a = input_line[0]
b = input_line[1]

price_a_min = math.ceil(a / 0.08)
price_a_max = math.ceil((a + 1) / 0.08)
price_b_min = math.ceil(b / 0.1)
price_b_max = math.ceil((b + 1) / 0.1)

a_range = {i for i in range(price_a_min, price_a_max)}
b_range = {i for i in range(price_b_min, price_b_max)}

both_range = a_range & b_range

ans = -1
for i in sorted(both_range):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        ans = i
        break
    else:
        continue
print(ans)


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n;
  cin >> n;
  
  map<int, int> number;
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    number[a] += 1;
  }

  queue<int> q;
  int maxCount = 0;
  int count = 0;
  int prevVal = -100;
  for(auto val:number){
    if(prevVal != val.first-1){
      count = 0;
      queue<int>().swap(q);
    }
    count += val.second;
    q.push(val.second);
    if(q.size()>3){
      count -= q.front();
      q.pop();
    }
    maxCount = max(maxCount,count);
    prevVal = val.first;
  }
  
  cout << maxCount << endl;
  return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int64_t> l(n+1);
    l.at(0) = 2;
    l.at(1) = 1;
    for (int i = 2; i <= n; i++) {
        l.at(i) = l.at(i-1) + l.at(i-2);
    }

    cout << l.at(n) << endl;
    return 0;

}

Measured memory_bytes: 3628
N = int(input())
num = [int(i) for i in input().split()]
coment = 'Yes'

if N == 1:
  coment = 'Yes'
  
elif N == 2:
  if num[1] - num[0] < -1:
    coment = 'No'
    
else:
  for i in range(N-2):
    if num[i+1] - num[i] < -1:
      coment = 'No'
      break
    elif num[i+1] - num[i] < 0:
      for j in range(N-2-i):
        if num[i+2+j] - num[i+1] < 0:
          coment = 'No'
          break
        elif num[i+2+j] - num[i+1] > 0:
          break
          
print(coment)

Measured memory_bytes: 14704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
//
//class UnionFind {
//private:
//    int sz;
//    vector<int> par, size_;
//public:
//    UnionFind(){}
//    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
//        iota(par.begin(), par.end(), 0);
//    }
//    int find(int x){
//        if(par[x] == x) return x;
//        else return par[x] = find(par[x]);
//    }
//    void unite(int x, int y){
//        x = find(x); y = find(y);
//        if(x == y) return;
//        if(size_[x] < size_[y]) swap(x,y);
//        par[y] = x;
//        size_[x] += size_[y];
//    }
//    int size(int x){
//        x = find(x);
//        return size_[x];
//    }
//    bool same(int x, int y){
//        return find(x) == find(y);
//    }
//};
//void no(){
//    cout << "Impossible" << endl;
//    exit(0);
//}
//int main(){
//    cin.tie(nullptr);
//    ios::sync_with_stdio(false);
//    int n, m;
//    cin >> n >> m;
//    vector<vector<int>> g(n);
//    vector<int>a(n);
//    rep(i,n)cin >> a[i];
//    rep(i,m){
//        int x, y;
//        cin >> x >> y;
//        x--;y--;
//        g[x].push_back(y);
//        g[y].push_back(x);
//    }
//    if(m == n - 1){
//        cout << 0 << endl;
//        return 0;
//    }
//    if(n / 2 < n - m - 1){
//        no();
//    }
//}
int main(){
    int n, m;
    cin >> n >> m;
    vector<ll>a(m);
    rep(i,m)cin >> a[i];
    ll ans = 0;
    rep(i,m)ans += a[i];
    cout << max(-1LL, n - ans) << endl;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> dist(n, -1);
  queue<int> que;

  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int nv : g[v]) {
      if (dist[nv] != -1) continue;
      dist[nv] = v;
      que.push(nv);
    }
  }
  // for (int i = 1; i < n; i++) {
  //   if (dist[i] == -1) {
  //     cout << "No" << endl;
  //      return 0;
  //   }
  // }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << dist[i] + 1 << endl;
  }

  // rep(i, n) {
  //   rep(j, g[i].size()) cout << g[i][j] << ", ";
  //   cout << endl;
  // }
  return 0;
}

Measured memory_bytes: 10144