akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
		}
		long[] sum = new long[n];
		sum[n-1] = a[n-1];
		for(int i = n-2;i >= 0;i--){
			sum[i] = (sum[i+1] + a[i]) % MOD;
		}
		long ans = 0;
		for(int i = 0;i < n-1;i++){
			ans += a[i]*sum[i+1]%MOD;
		}
		System.out.println(ans%MOD);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


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

int main(){
	int n, b, f, r, v;
	int count[4][3][10]={0};
	int i, j, k;;
	
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		count[b -1][f -1][r - 1] += v;
	}
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				cout << " " << count[i][j][k];
			}
			cout << endl;
		}
		if(i < 3){
			cout << "####################" << endl;
		}
	}
		
	
	return 0;	
}

Measured memory_bytes: 3088
card=[list(map(int,input().split())) for i in range(3)]
n=int(input())
at=[[False for i in range(3)] for j in range(3)]
for i in range(n):
    num=int(input())
    for j in range(3):
        for h in range(3):
            if num==card[j][h]:at[j][h]=True
for i in range(3):
    if False not in at[i]:print('Yes');exit()
for j in range(3):
    if False not in (at[0][j],at[1][j],at[2][j]):print('Yes');exit()
if False not in (at[0][0],at[1][1],at[2][2]) or False not in (at[0][2],at[1][1],at[2][0]):print("Yes");exit()
print("No")

Measured memory_bytes: 3064
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int z = int.Parse(array[0]) * int.Parse(array[1]);
            int x = (int.Parse(array[0]) * 2) + (int.Parse(array[1]) * 2); 
            Console.WriteLine(z + " " + x);
        }
    }
}

Measured memory_bytes: 9044
//#define LOCAL

#include <cstdio>

#define MAX 10000
#define NIL -1
struct Node { int parent, left, right; };
Node T[MAX]; int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL) h1 = setHeight(T[u].left)+1;
	if(T[u].right != NIL) h2 = setHeight(T[u].right)+1;
	return H[u] = h1>h2?h1:h2;
}

int getSibling(int u) {
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
	if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: parent = %d, sibling = %d, ", u, T[u].parent, getSibling(u));
	int deg = 0;
	if(T[u].left != NIL) ++deg;
	if(T[u].right != NIL) ++deg;
	printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);
	if(T[u].parent == NIL) printf("root\n");
	else if(T[u].left==NIL && T[u].right==NIL) printf("leaf\n");
	else printf("internal node\n");
}

int main()
{
	#ifdef LOCAL
		freopen("E:\\Temp\\input.txt", "r", stdin);
		freopen("E:\\Temp\\output.txt", "w", stdout);
	#endif

	int i, v, l, r, root = 0;
	scanf("%d", &n);
	for(i=0; i<n; ++i) T[i].parent = NIL;
	for(i=0; i<n; ++i) {
		scanf("%d%d%d", &v, &l, &r);
		T[v].left = l, T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}

	for(i=0; i<n; ++i)
		if(T[i].parent == NIL) root = i;
	setDepth(root, 0); setHeight(root);

	for(i=0; i<n; ++i) print(i);

	return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int s, w;
    cin>>s>>w;
    cout<<(s<=w ? "unsafe" : "safe")<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h> 
using namespace std; 
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pll pair<lli,lli>
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,a,n) for(lli i=a;i<(n);i++)
#define frj(j,a,n) for(lli j=a;j<(n);j++)
#define frx(i,a,n) for(lli i=a;i>(n);i--)
#define frxj(j,a,n) for(lli j=a;j>(n);j--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define db(x) cout << "[ " << x << " ]" << endl;
#define dbarr(arr,a,n) {fr(i,0,n) cout<<arr[i]<<" "; cout<<endl;}

lli power(lli x, lli y, lli p) 
{ 
    lli res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

int main() {
    fast
    lli p=1e9+7;
    lli n;
    cin>>n;
    // cout<<power(8,n,p)<<endl;
    lli ans=(power(10LL,n,p)+power(8LL,n,p)-(2LL)*power(9LL,n,p)+3*p)%p;
    cout<<ans;
}

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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  map< string, int > st;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    string x;
    cin >> x;
    st[x]++;
    chmax(ret, st[x]);
  }
  for(auto &p : st) {
    if(p.second == ret) cout << p.first << endl;
  }
}




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

int c[100009];
bool vs[100009], evs[100009];
vector<pair<int, int> > v[100009], ans;

void dfs(int n)
{
	vs[n] = true;
	for (int i = 0; i < v[n].size(); i++) {
		int ei = v[n][i].second;
		if (evs[ei]) continue;
		evs[ei] = true;
		int tn = v[n][i].first;
		if (vs[tn]) {
			ans.push_back(make_pair(n, tn));
			c[n]++;
			continue;
		}
		dfs(tn);
		if (c[tn] % 2) 
			ans.push_back(make_pair(tn, n));
		else {
			ans.push_back(make_pair(n, tn));
			c[n]++;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		v[a].push_back(make_pair(b, i)); v[b].push_back(make_pair(a, i));
	}
	if (m % 2) {
		cout << -1 << '\n';
		return 0;
	}
	dfs(1);
	for (int i = 0; i < m; i++)
		cout << ans[i].first << " " << ans[i].second << '\n';
	return 0;
}

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

const int mod=998244353,N=10000010;
int n,jc[N],inv[N],ans,sum[N];

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int C(int a,int b)
{
	if (a<b||b<0) return 0;
	return 1ll*jc[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
	jc[0]=1;
	for (int i=1; i<N; i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[N-1]=quickmi(jc[N-1],mod-2);
	for (int i=N-1; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	scanf("%d",&n),ans=quickmi(3,n),sum[n>>1]=1;
	for (int i=(n>>1)-1,nw=2; i; i--,nw=(nw+nw>=mod?nw+nw-mod:nw+nw)) 
		sum[i]=(sum[i+1]+1ll*nw*C(n>>1,i))%mod;
	for (int i=(n>>1),nw=1; i; i--,nw=(nw+nw>=mod?nw+nw-mod:nw+nw))
		ans=(ans+2ll*(mod-nw)*C(n>>1,i)%mod*sum[(n>>1)+1-i])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 98944
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    double d;
    scanf("%lf", &d);
    printf("%.20lf\n", max(d*sqrt(2), (int)d+1.0));
}


Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
using namespace std;
int main(){
	string str;
	map<char,int> A;
	A['I'] = 1;
	A['V'] = 5;
	A['X'] = 10;
	A['L'] = 50;
	A['C'] = 100;
	A['D'] = 500;
	A['M'] = 1000;
	A['E'] = -1;
	while(cin >> str){
	    int ans = 0;
	    str += "E";
        for(int i = 0; str[i] != 'E'; i++){
            if(A[str[i]] < A[str[i+1]]){
                ans -= A[str[i]];
            }
            else{
                ans += A[str[i]];
            }
        }
        cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
/**
 *    author:  Mohamad Milhem
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)
int here[1000005];
int maxx;


void fact(int v){



	for (int i = 2 ; i <= sqrt(v); i++){
		if (v % i == 0){
			here[i]++;
			maxx = max(maxx , here[i]);
			while(v%i == 0){
				v/=i;
			}
		}
	}

	if (v == 1)return;

	here[v]++;
	maxx = max(maxx , here[v]);


}




void solve(){
	int n;
	cin >> n;
	vector<int> v(n);

	lp(i , 0 , n){
		cin >> v[i];
	}

	maxx = 0;

	lp(i , 0 , n){
		fact(v[i]);
	}


	if (maxx == n){
		cout << "not coprime" << endl;
	}
	else if (maxx <= 1 ){
		cout << "pairwise coprime" << endl;
	}
	else {
		cout << "setwise coprime" << endl;
	}

}



int main()
{
    FAST;
    int t;
    t = 1;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 10868
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String ord = Integer.toString(N);	

		for (int i = 0; i <= ord.length() / 2; i++) {
			if (ord.charAt(i) != ord.charAt(ord.length() - 1 - i)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22996
import java.util.*;

class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer V[] = new Integer[N];
        for (int i=0; i<N; i++){
          V[i] =sc.nextInt();
        }
        Integer C[] = new Integer[N];
        for (int i=0; i<N; i++){
          C[i] =sc.nextInt();
        }
        int ans = 0;
        for (int i=0; i<N; i++) {
          int benefit = V[i] -C[i];
          if (benefit >= 0){
            ans += benefit;
          }
        }
      System.out.println(ans);
    }
}

Measured memory_bytes: 22740
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  var p = input[1].split(" ").map(i => parseInt(i));
  var ans =0;
  for(var i=1;i<n-1;i++){
    if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])){
      ans++;
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#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,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define INF 1000000001
#define MOD 1000000007

using namespace std;



class Dice {
	int num[6] = { 0,0,0,0,0,0 };
public:
	void setnum(int*);
	void roll(char);
	void ans();
	void dice2(int, int);
};

void Dice::roll(char c) {
	switch(c) {
		int tmp;
	case'N':
		tmp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = tmp;
		break;
	case'S':
		tmp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = tmp;
		break;
	case'E':
		tmp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = tmp;
		break;
	case'W':
		tmp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = tmp;
		break;
	default:
		cout << "invalid char" << endl;
	}
}

void Dice::setnum(int* a) {
	REP(i, 6) {
		num[i] = a[i];
	}
}

void Dice::ans() {
	cout << num[0] << endl;
}

void Dice::dice2(int a, int b) {
	int i=0;
	if (b == num[3]) {
		roll('E');
		roll('S');
		while(a != num[0]) {
			roll('E');
		}
	}
	else if (b == num[2]) {
		roll('W');
		roll('S');
		while (a != num[0]) {
			roll('E');
		}
	}
	else {
		while (b != num[1]) {
			roll('N');
		}
		while (a != num[0]) {
			roll('E');
		}
	}
	cout << num[2] << endl;
}

int main() {
	int a[6];
	REP(i, 6) {
		int b;
		cin >> b;
		a[i] = b;
	}
	Dice d;
	d.setnum(a);
	int q;
	cin >> q;
	REP(i, q) {
		int a, b;
		cin >> a >> b;
		d.dice2(a, b);
	}
	return 0;
}

Measured memory_bytes: 3032
import collections

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
c_values = list(c.values())
sum_all = 0
for c_value in c_values:
    sum_all += c_value*(c_value-1)//2
for i in range(n):
    sum = c[a[i]] - 1 
    print(sum_all - sum)


Measured memory_bytes: 25900
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<double> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  vector< vector<double> > v1(n+1,vector<double>(n+1));
  v1[0][0]=1.0;
  for(int i=1;i<=n;i++)
  {
      v1[i][0]=0;
  }
  for(int i=1;i<=n;i++)
  {
      v1[0][i]=(1.0-v[i-1])*v1[0][i-1];
  }
  for(int i=1;i<=n;i++)
  {
      for(int j=1;j<=n;j++)
      {
          v1[i][j]=((1.0-v[j-1])*v1[i][j-1])+(v1[i-1][j-1]*v[j-1]);
      }
  }
  double ans=0.0;
  for(int i=n;i>=(n+1)/2;i--)
  {
      ans+=v1[i][n];
  }
  cout<<fixed<<setprecision(11)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 73784
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<ll> a;
    rep(i, n){ ll tmp; cin >> tmp; a.push_back(tmp);}

    ll ans = a[0];
    rep1(i, n-1){
        ll tmp = gcd(ans, a[i]);
        ll adiv = a[i]/tmp;
        ans *= adiv;
//        cout << tmp << ":" << ans << endl;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int n, m;
	cin >> n >> m;
	
	int sum = 0;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		sum += a;
	}
	
	cout << (n - sum < 0 ? -1 : n - sum) << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int a,b,c;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26144
def resolve():
    N, A, B = map(int, input().split())
    S = input()
    Atmp = 0
    Btmp = 0
    for i in S:
        if i == 'a':
            if Atmp + Btmp < A+B:
                Atmp += 1
                print('Yes')
            else:
                print('No')
        elif i == 'b':
            if Btmp < B and Atmp + Btmp < A+B:
                Btmp += 1
                print('Yes')
            else:
                print('No')
        else:
            print('No')
resolve()


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

using namespace std;
typedef long long ll;

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

  vector<int> v[3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      int vv;
      cin >> vv;
      v[i].push_back(vv);
    }
    sort(v[i].begin(), v[i].end());
  }

  ll p = 0;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) {
    while (p < n && v[0][p] < v[1][i]) p++;
    a[i] = p;
  }
  p = n - 1;
  for (int i = n - 1; i >= 0; i--) {
    while (p >= 0 && v[2][p] > v[1][i]) p--;
    b[i] = n - 1 - p;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] * b[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
int main(){
	int N;
	cin>>N;
	int A,B;
	cin>>A>>B;
	int a[3]={};
	for(int i=0;i<N;i++){
		int c;
		cin>>c;
		if(c<=A)
			a[0]++;
		else if(c<=B)
			a[1]++;
		else
			a[2]++;
	}
	cout<<min({a[0],a[1],a[2]})<<endl;;
	return 0;
}

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

int main() {
  int n, num = 0;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    num += r - l + 1;
  }
  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    if(a==0) printf("1\n");
    else if(b==0) printf("2\n");
    else if(c==0) printf("3\n");
    else if(d==0) printf("4\n");
    else if(e==0) printf("5\n");
}


Measured memory_bytes: 1580
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int n;
    double x, ans = 0;
    string u;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x >> u;
        ans += x * (u == "BTC" ? 380000.0 : 1);
    }
    cout << setprecision(15) << ans << endl;
    return 0;
}


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

#define int long long

using namespace std;

signed main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		vector<int> cnts(n);
		for (int i = 0; i < n; i++) {
			cin >> cnts[i];
		}
		sort(cnts.begin(), cnts.end());
		if (cnts[n - 1] < 2) {
			cout << "NA" << endl;
			continue;
		}

		int remain = 0;
		for (int i = 0; i < n; i++) {
			if (cnts[i] > 0)remain++;
		}
		cout << remain + 1 << endl;
	}
}


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

int main()
{
    long long a, b, c, d;

    cin >> a >> b >> c >> d;

    long long maxValue = a * c;
    if (maxValue < a * d)
    {
        maxValue = a * d;
    }
    if (maxValue < b * c)
    {
        maxValue = b * c;
    }
    if (maxValue < b * d)
    {
        maxValue = b * d;
    }
    

    cout << maxValue << endl;
}



Measured memory_bytes: 3632
n = int(input())
a = list(map(int,input().split()))
b = list(range(n))
s = list(map(list,zip(a,b)))
s.sort(reverse=True)
s.append([0,0])
ans = [0]*n
for i in range(n):
  dif = s[i][0]-s[i+1][0]
  ans[s[i][1]] += dif*(i+1)
  if s[i+1][1]>s[i][1]:
    s[i+1][1] = s[i][1]
print(*ans,sep="\n")

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

int main() {
  int a,b;
  cin >>a>>b;
  int c=a+b,d=a*b,e=a-b;
  if (c>=d&&c>=e) {
    cout <<c<< endl;
  }
  else if(d>=c&&d>=e){
  cout <<d<< endl;
   }
  else{
    cout<<e<<endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		
		if(h==0 && w==0)break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main () {

    string S;
    cin >> S;

    int cnt = 0;
    int ans = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;

    return 0;
}

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

int main(){
    /*input*/
    string s;
    cin >> s;
    //int year = stoi(s.substr(0,3));
    int month = stoi(s.substr(5,2));
    //int day = stoi(s.substr(8,2));

    /*evaluate*/
    string ans;
    if(month > 4)
        ans = "TBD";
    else
        ans = "Heisei";

    /*output*/
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
vi to[100010];
vi v(100010);
vi c(100010);
int p=0;
void dfs(int now,int from){
    v[now]=c[p++];
    for(auto next: to[now]){
        if(next==from) continue;
        dfs(next,now);
    }
}
int main(){
    int n;cin >> n;
    rep(i,n-1){
        int a,b;cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n) cin >> c[i];
    sort(c.rbegin(),c.rend());
    int ans=0;
    rep(i,n) ans+=c[i];
    ans-=c[0];
    //rep(i,n) cout << c[i] << endl;
    cout << ans << endl;
    dfs(1,-1);
    rrep(i,n){
        cout << v[i] << " ";
    }
    cout << endl;
}

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

int main() {
    long long n;
    string ans = "";
    cin >> n;

    while(n > 0)
    {
        n--;
        ans = (char)('a' + (n % 26)) + ans;
        n /= 26;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3628
#include <cctype>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main()
{
    int N, H, Q = 0, R = 0; cin >> N >> H;
    
    vector<string> S(N);
    
    vector<int> T(N);
    vector<int> P(N, 0);
    
    for(int i = 0; i < N; i++)
    {
        cin >> S[i] >> T[i];
    }
    
    string F;
    
    for(int i = 0; i < N; i++)
    {
        int ptr = 0;
        
        while(ptr != S[i].size())
        {
            cout << "? " << S[i] << endl;
            
            cin >> F; R++;
            
            if(tolower(S[i][ptr]) == tolower(F[0]))
            {
                S[i][ptr] = '_'; ptr++; Q++;
            }
            else
            {
                P[i]++;
                
                if(P[i] > T[i])
                {
                    H--; break;
                }
            }
        }
                   
        if(H <= 0)
        {
            cout << "! Game Over" << endl; return 0;
        }
    }
    
    int r = Q * 1000 / R;
    
    printf("! Game Clear %d.%d\n", r / 10, r % 10);
    
    return 0;
}

Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >>s;
  int i,count;
  count =0;
  for(i=0;i<3;i++){
  	if(s.at(i) == '1') count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int [] b = new int[a];
		int count = 0;
		
		for(int i = 0 ; i < a ; i++) {
			b[i] = input.nextInt();
		}
		
		for(int i = 0 ; i < a - 1 ; i++) {
			for(int j = 0 ; j < a - 1 - i ; j++) {
				if(b[j] > b[j+1]) {
					int first = b[j];
					b[j] = b[j + 1];
					b[j + 1] = first;
					count += 1;
				}
			}
		}
		
		for (int i = 0 ; i < b.length ; i++) {
            System.out.print(b[i]);
            if(i != b.length-1) {
            	System.out.print(" ");
            }     
        }
		System.out.println();
		System.out.println(count);
		
	}
	

}



Measured memory_bytes: 26364
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047


void solve(){
	int n, k, x; cin >>  n >> k;
	
	int l = 0;
	FOR(i, 0, n) {
		cin >> x;
		if (x <= k - x) 
			l += x * 2;
		else
			l += (k - x) * 2;
	}
	
	cout << l << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;

int main()
{
    int N, R;
    cin >> N >> R;
    if (N >= 10)
    {
        cout << R << endl;
    }
    else
    {
        cout << 100 * (10 - N) + R << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

using namespace std;

#define MOD ((long long)1e9+7)
#define ll long long

/* コンビネーションの計算を行う */
class Combination{
public:
    /* コンストラクタ */
    Combination(ll n){
        this->n = n;
        frac = new ll[n + 1];
        inv = new ll[n + 1];
        frac[0] = 1;
        inv[0] = 1;
        for (int i = 1;i <= n;++i){
            frac[i] = frac[i - 1] * i % MOD;
            inv[i] = Inverse(frac[i]);
        }
    }
    /* デストラクタ */
    ~Combination(){
        delete[] frac;
        delete[] inv;
    }
    /* nCkの計算を行う */
    ll C(ll n,ll k){
        if (k < 0) return 0;
        if (k > n) return 0;
        return frac[n] * inv[k] % MOD * inv[n - k] % MOD;
    }
private:
    ll n;
    ll* frac; // 階乗を格納
    ll* inv; // 階乗の逆元を格納
    ll Pow(ll a,ll b){ // aのb乗の計算
        if (b == 0) return 1;
        ll temp = Pow(a,b / 2);
        if (b & 1){
            return temp * temp % MOD * a % MOD;
        }
        return temp * temp % MOD;
    }
    ll Inverse(ll a){ // aの逆元を計算
        return Pow(a,MOD - 2);
    }
};

signed main(){
    int n,k;
    cin >> n >> k;

    /* コンビネーション計算の前準備 */
    Combination c(2000);

    /*
        i = 1,2,...,kについて
            C(k-1,i-1) * C(n-k+1,i)
        が答え.
     */
     for (int i = 1;i <= k;++i){
         ll ans = c.C(k-1,i-1) * c.C(n-k+1,i) % MOD;
         cout << ans << endl;
     }

     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> p(n), a(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
    a[p[i]-1] = i;
  }

  int res = 1, cnt = 1; //操作しない数
  for(int i = 1; i < n; i++){
    if(a[i-1] < a[i]){
      res++;
    }else {
      res = 1;
    }
    cnt = max(res, cnt);
  }
  cout << n - cnt << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int c[a],d=0;
    for(int i=0;i<a;i++) cin>>c[i];
    sort(c,c+a);
    reverse(c,c+a);
    for(int i=0;i<b;i++) d+=c[i];
    cout<<d;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int n,d,x,i,j,s,a[101];

   scanf("%d%d%d",&n,&d,&x);
   for(i=0;i<n;i++)
      scanf("%d",&a[i]);
   s=0;
   for(i=0;i<n;i++){
      for(j=1;j<=d;j=j+a[i])
         s++;
   }
   printf("%d\n",s+x);
   return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int n,d;
  cin >>n>>d;
 
  cout << (n+2*d)/(2*d+1) << endl;
  
}


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

int main(int argc, char const *argv[])
{
	std::string s;
	std::string p;
	std::getline(std::cin,s);
	std::getline(std::cin,p);
	std::string ss = s + s;
	for(unsigned int i = 0 ; i < s.length() ; i ++){
		unsigned int j = 0 ;
		while(p[j] == ss[i+j]){
			j++;
			if(j == p.length()){
				std::cout << "Yes" << std::endl;;
				return 0;
			}
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 3232
#include<cstdio>

int main(){
  int a[3];
  for(int i = 0 ; i< 3 ; i++) scanf("%d" , &a[i]);
  int s;
  s = (a[0] + a[1]) *a[2] / 2;
  printf("%d\n", s );;
  return 0;
}


Measured memory_bytes: 128
m = 10**9+7
n,a,b = map(int,input().split())
def c(k):
  v = 1
  w = 1
  for i in range(k):
    v = v*(n-i)%m
    w = w*(i+1)%m
  return (v*pow(w,m-2,m)%m)
print((pow(2,n,m)-1-c(a)-c(b))%m)

Measured memory_bytes: 9112
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int x1,x2,x3,y1,y2,y3;
    int s;
    cin >> s;

    x3 = 0;
    y3 = 0;

    int left = 0,right = 1e9+1;
    while(left + 1< right){
        int mid = (left + right) / 2;
        if(mid * (mid ) >= s ) right = mid;
        else left = mid;
    }

    while(s <= (right -1) * (right-1) ) right --;

    x1 = right;
    y2 = right;

    y1 = 1;
    x2 =  (right * right  - s);
    if(x2 > 1e9){
        y2 = right -1;
        y2 = 1;
        x2 = (right * (right-1) - s );
    }

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    


}

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

int main()
{
    int k,i,counte=0,counto=0;

    cin>>k;

    for(i=1;i<=k;i++)
    {
        if(i%2==0)
            counte++;
        else
            counto++;
    }

    cout<<counte*counto<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(c>=a && c<=a+b) System.out.println("YES");
		else System.out.println("NO");

	}

}


Measured memory_bytes: 27104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N;
  cin>>N;
  
  vector<ll>A(N);
  ll dp[N][2];
  
  rep(i,N){
rep(j,2){


dp[i][j]=0;
  
}
}

  


  rep(i,N){
    cin>>A[i];
  }

  
 
  
  for(ll i=0;i<N;i++){
   if(i==0){
dp[i][0]+=A[i];
    dp[i][1]+=-A[i];
  
   }
       else{
dp[i][0]+=max(A[i]+dp[i-1][0],-A[i]+dp[i-1][1]);
    dp[i][1]+=max(A[i]+dp[i-1][1],-A[i]+dp[i-1][0]);
         
   }
    
  }

  
    cout<<dp[N-1][0]<<endl;
  
}



Measured memory_bytes: 2560
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble();
		System.out.printf("%.9f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
	}
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

ll mod = (ll)(1e9+7);

ll solve(ll x, ll cnt){
  
  ll n = x;
  ll res = 0;
  ll tmp = cnt;
  while(true){
    if(n%tmp==0){
      res ++;
      break;
    }else{
      n = n%tmp;
      tmp = __builtin_popcount(n);
      res ++;
    }
  }

  return res;
}

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

  string x;
  cin >> x;
  bool flag = false;

  ll cnt = 0;
  rep(i,n){
    if(x[i]=='1'){
      cnt ++;
    }else{
      continue;
    }
  }

  if(cnt==1){
    flag = true;
  }

  vector<ll> add(n,0);
  vector<ll> sub(n,0);
  ll base = 0;
  ll two_add = 1;
  ll two_sub = 1;
  rep(i,n){
    add[n-i-1] = two_add%(cnt+1);
    two_add *= 2;
    two_add %= cnt+1;
  }

  if(flag == false){
    rep(i,n){
      sub[n-i-1] = two_sub%(cnt-1);
      two_sub *= 2;
      two_sub %= cnt-1;
    }
  }


  ll sum_add = 0;
  ll sum_sub = 0;
  rep(i,n){
    if(x[i]=='1'){
      sum_add += add[i];
      sum_sub += sub[i];
    }else{
      continue;
    }
  }

  rep(i,n){
    // sub
    if(x[i]=='1'){
      if(flag){
        cout << 0 << endl;
        continue;
      }
      ll tmp = sum_sub;
      tmp -= sub[i];
      tmp %= cnt-1;
      // cout << sum_sub << "  " << tmp << endl;
      cout << solve(tmp,cnt-1) << endl;
    }else{ 
      // add
      ll tmp = sum_add;
      tmp += add[i];
      tmp %= cnt+1;
      // cout << sum_add << "  " <<tmp << endl;
      cout << solve(tmp,cnt+1) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if(A <= X and A + B >= X) {
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    MOD = 10**6+3

    # preprocess
    fac = [None] * (MOD+1)
    fac[0] = fac[1] = 1
    for i in range(2, MOD+1):
        fac[i] = (fac[i-1] * i) % MOD

    Q = int(input())
    for i in range(Q):
        x, d, n = map(int, sys.stdin.readline().split())

        if d == 0:
            print(pow(x, n, MOD))
            continue
        
        xd = (x * pow(d, MOD-2, MOD)) % MOD
        if xd == 0 or xd + (n-1) >= MOD:
            print(0)
            continue

        print(pow(d, n, MOD) * fac[xd+(n-1)] * pow(fac[xd-1], MOD-2, MOD) % MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 76252
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> G(n);
    vector<int> deg(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    vector<int> ans(n-1);
    auto dfs = [&](int i, int par, int col, auto &&f) -> void {
        int cnt = 1;
        for (auto &&j : G[i]) {
            if(j.first == par) continue;
            if(cnt == col) cnt++;
            ans[j.second] = cnt;
            f(j.first, i, cnt, f);
            cnt++;
        }
    };
    dfs(0, -1, -1, dfs);
    cout << *max_element(ans.begin(),ans.end()) << "\n";
    for (int i = 0; i < n-1; ++i) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main(){
int n,k;
  scanf("%d%d",&n,&k);
  vector<int> h(n);
  for(int& x : h){
  	scanf("%d",&x);
  }
  vector<int> ans(n,INF);
  ans[0]=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=min(n-1,i+k);j++) if(i+1<n) ans[j]=min(ans[j],ans[i]+abs(h[i]-h[j]));
  }
  printf("%d",ans[n-1]);
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int D = sc.nextInt();

		int[] x = new int[H*W+1];
		int[] y = new int[H*W+1];

		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				int a = sc.nextInt();
				x[a] = i;
				y[a] = j;
			}
		}

		int[] d = new int[H*W+1];
		for(int i = D+1; i <= H*W; i++) {
			d[i] = d[i-D] + Math.abs(x[i] - x[i-D]) + Math.abs(y[i] - y[i-D]);
		}

		int Q = sc.nextInt();
		for(int i = 0; i < Q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(d[r] - d[l]);
		}
	}
}


Measured memory_bytes: 99048
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
    string a, b;
    cin >> a >> b;
    a += b;
    int ab = atoi(a.c_str());
    int rt = (int) pow(ab, 0.50);
    if(rt*rt==ab)cout<<"Yes\n";
    else cout << "No\n";
    return 0;
}


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

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;}

const long long INF = 1LL << 60;

int main(void){
	int n;cin >> n;
	vector<ll> v(n+1,0),sel(n+1);
	ll sum=0;
	vector<int> A(n);
	rep(i,n){
		int a=0;cin >> a;
		A[i] = a;
		v[a]++;
	}
	vector<bool> ch(n+1,true);
	for(int i=1;i<=n;i++){
		if(ch[A[i-1]]){
			ch[A[i-1]] = false;
			sel[i] = v[A[i-1]]*(v[A[i-1]]-1)/2;
			sum += sel[i];
		}
	}
	for(int i=0;i<n;i++){
		cout << sum-(v[A[i]]-1) << endl;
	}
	return 0;
}



Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

const int maxn=2e5+10;

struct datum {int v,p,re;}z[maxn];

int n;

bool cmp1(datum a,datum b)
{
    return a.v<b.v;
}

bool cmp2(datum a,datum b)
{
    return a.p<b.p;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&z[i].v),z[i].p=i;

    sort(z+1,z+1+n,cmp1);
    for(int i=1;i<=n/2;i++)
        z[i].re=z[n/2+1].v;
    for(int i=n/2+1;i<=n;i++)
        z[i].re=z[n/2].v;

    sort(z+1,z+1+n,cmp2);
    for(int i=1;i<=n;i++)
        printf("%d\n",z[i].re);

    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 2147483647;

int  main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    for (ll i=0;i<n;++i){
        cin >> h.at(i);
    }
    vector<ll> dp(n);
    dp.at(0) = 0;
    for (ll i=1;i<n;++i){
        dp.at(i) = INF;
    }
    for (ll i=0;i<n-2;++i){
        ll cost1,cost2;
        cost1 = abs(h.at(i+1)-h.at(i))+dp.at(i);
        cost2 = abs(h.at(i+2)-h.at(i))+dp.at(i);
        dp.at(i+1) = min(dp.at(i+1),cost1);
        dp.at(i+2) = min(dp.at(i+2),cost2);
    }
    // cost1はもう一回求められる
    ll cost1 = abs(h.at(n-1)-h.at(n-2))+dp.at(n-2);
    dp.at(n-1) = min(dp.at(n-1),cost1);

    cout << dp.at(n-1) << endl;
    return 0;
}


Measured memory_bytes: 1792