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

class Problem {
    private int N;
    private double sum;

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

        sum = 0.0;
        for (int i = 0; i < N; i++) {
            double x = sc.nextDouble();
            String u = sc.next();
            if (u.equals("JPY")) {
                sum += x;
            } else {
                sum += 380000.0 * x;
            }
        }
    }

    double solve() {
        return sum;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 24788
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
var AtCoder;
(function (AtCoder) {
    var abc115;
    (function (abc115) {
        var Program = /** @class */ (function () {
            function Program() {
            }
            /**
             * in
             *  25
             * out
             *  Christmas
             */
            Program.prototype.main = function (inp) {
                var days = {
                    '22': 'Christmas Eve Eve Eve',
                    '23': 'Christmas Eve Eve',
                    '24': 'Christmas Eve',
                    '25': 'Christmas',
                };
                console.log(days[inp]);
            };
            return Program;
        }());
        var prg = new Program();
        prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
    })(abc115 = AtCoder.abc115 || (AtCoder.abc115 = {}));
})(AtCoder || (AtCoder = {}));


Measured memory_bytes: 7500
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
int S[405][405];
int pow(int a,int b,int mod)
{
    int ans = 1;
    while (b)
    {
        if (b&1) ans = (1ll * ans * a) % mod;
        a = (1ll * a * a) % mod;
        b /= 2;
    }
    return ans;
}
const int mod = 1e9 + 7;
int dp[405][405];
int a[405];
int b[405];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    for (int i = 1;i <= 400;++i)
        for (int j = 0;j <= 400;++j)
            S[i][j] = (pow(i,j,mod) + S[i-1][j]) % mod;
    function < int(int , int , int) > get = [&](int l,int r,int k)
    {
        return (1ll * mod + S[r][k] - S[l-1][k]) % mod;
    };
    int n,C;
    fi>>n>>C;
    for (int i = 1;i <= n;++i) fi>>a[i];
    for (int j = 1;j <= n;++j) fi>>b[j];
    for (int i = 0;i <= C;++i)
        dp[1][i] = get(a[1],b[1],i);
    for (int i = 2;i <= n;++i)
    {
        for (int l = 0;l <= C;++l)
            for (int r = l;r <= C;++r)
                dp[i][r] = (dp[i][r] + 1ll * dp[i-1][l] * get(a[i],b[i],r - l)) % mod;
    }
    fo << dp[n][C] << '\n';
    return 0;
}




Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

vector<int> G[100010];

int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  rep(i, m) { int a, b;
  cin >> a >> b;
  a--, b--;
  G[b].pb(a), G[a].pb(b);
  }
  vector<int> dist(n, -1);
  queue<int> q;
  q.push(0);
  dist[0] = 0;

  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(auto p: G[now]){
      if (dist[p] != -1) continue;
      dist[p] = dist[now] + 1;
      q.push(p);
    }
  }
  puts("Yes");
  for(int i=1; i<n; i++){
    int rec = dist[i];
    for(auto p: G[i]){
      if(rec==dist[p]+1) {
        cout << p+1 << endl;
        break;
      }
    }
  }
  
  //show(dist);
  return 0;
}

Measured memory_bytes: 10224
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;

	cin >> s;
	int n = s.size() - 1;

	long long sum = 0;
	for (int i = (1 << n) - 1; i >= 0; i--) {
		int tmp = i;
		int prev = 0;

		for (int j = 0; j < n; j++) {
			if (tmp & (1 << j)) {
				int to = j + 1;
				sum += stoll(s.substr(prev, to - prev));
				prev = to;
			}
		}
		sum += stoll(s.substr(prev));
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
const double BMI_OVER=25.0;
typedef long double ld;
int main(){ _;
  int id;
  ld weight,height;
  while(scanf("%d,%Lf,%Lf",&id,&weight,&height)!=-1){
    if(weight/(height*height)>=BMI_OVER)
      cout<<id<<endl;
  }
}

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

int main(){
  int a,b,c,max=0,maxh;;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    if(c>max){
      max=c;
      maxh=b;
    }else if(max==c&&maxh>b){
      max=c;
      maxh=b;
    }
  }
  cout<<maxh<<" "<<max<<endl;
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	lli n;
	cin>>n;
	vector<lli>h(n);
	fr(i,n)
	cin>>h[i];
	lli ans=0;
	lli mx=h[0];
	for(lli i=1;i<n;i++)
	{
		mx=max(mx,h[i]);
		ans+=max(0ll,mx-h[i]);

	}
	cout<<ans<<endl;
	
	
	
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int r;cin>>r;
  cout << r*r << endl;

}


Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aaa := getIntList(scanner)
	sum := 0
	for i := 0; i < n; i++ {
		for aaa[i]%2 == 0 {
			aaa[i] >>= 1
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 2304
//basic setting
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	//  i/o setting

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s;
	cin >> s ;
	cout << s.substr(0, 3) << endl;

}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;

void trace(int x[], const int N)
{
    int k;
    for(k=0; k<N-1; k++)
    {
        cout<<x[k]<<" ";
    }
    cout<<x[k]<<endl;
}
static const int LEN=100;

void insertsort(int x[],const int N)
{
    for(int i=1; i<N; i++)
    {
        int j=i-1;
        int v=x[i];
        while(j>=0&&x[j]>v)
        {
            x[j+1]=x[j];
            j--;
        }
        x[j+1]=v;
        trace(x,N);
    }
}
int main()
{
    int x[LEN];
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cin>>x[i];
    trace(x,n);
    insertsort(x,n);
    return 0;
}



Measured memory_bytes: 3084
import fractions
from decimal import *
A,B,C,D=map(int, input().split())

sumC=0
if A%C==0:
  div = 0
else:
  div = -(A%C)+C
  
if A+div <= B:
  first = A+div
  sumC = Decimal(B-first)//Decimal(C) + 1
  
sumD=0
if A%D==0:
  div = 0
else:
  div = -(A%D)+D
if A+div <= B:
  first = A+div
  sumD = Decimal(B-first)//Decimal(D) + 1
  
sumCD=0
f=fractions.gcd(C,D)
f2=C*D//f
if A%f2==0:
  div = 0
else:
  div = -(A%f2)+f2
if A+div <= B:
  first = A+div
  sumCD = Decimal((B-first))//Decimal(f2) + 1
print(B-A+1-(sumC+sumD-sumCD))

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

int main() {
//   int n, p;
//   cin >> n >> p;
  string s;
  cin >> s;
  int n = s.length();
  int p = 2019;
  
  if (10%p == 0) { // 2,5
    ll ans = 0;
    rep(r,n) {
      if ((s[r]-'0') % p == 0) {
        ans += r+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % p;
    d[i] = (d[i+1]+a) % p;
    ten *= 10; ten %= p;
  }
  vector<int> cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4452
#include <iostream>
#include <vector>

int main()
{
    int a;
    std::cin >> a;
    int b = a/1000%10 ,c = a/100%10,d = a/10%10,e=a%10;

    std::vector<std::pair<int, std::string>> first;
    std::vector<std::pair<int, std::string>> second;
    std::vector<std::pair<int, std::string>> third;
    first.push_back(std::pair<int, std::string>(b+c,std::to_string(b) + "+" + std::to_string(c)));
    first.push_back(std::pair<int, std::string>(b-c,std::to_string(b) + "-" + std::to_string(c)));

    for(std::pair<int, std::string> i : first){
        second.push_back(std::pair<int, std::string>(i.first+d,i.second+"+"+std::to_string(d)));
        second.push_back(std::pair<int, std::string>(i.first-d,i.second+"-"+std::to_string(d)));
    }

    for(std::pair<int, std::string> i : second){
        third.push_back(std::pair<int, std::string>(i.first+e,i.second+"+"+std::to_string(e)));
        third.push_back(std::pair<int, std::string>(i.first-e,i.second+"-"+std::to_string(e)));
    }

    for(std::pair<int, std::string> i : third){
        if(i.first == 7){
            std::cout<<i.second + "=7"<<std::endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=7+1e9,maxn=5+2e4;
typedef unsigned long long ll;
ll dp[maxn];
ll qpow(ll a,ll p){
	ll ans=1,tmp=a;
	while(p){
		if(p&1)
			ans=ans*tmp%inf;
		tmp=tmp*tmp%inf;
		p>>=1;	
	}
	return ans;
}
ll C(ll m,ll n){
	return dp[n]*qpow(dp[m]*dp[n-m]%inf,inf-2)%inf;
}
int main(){
	ll n,k;
	cin>>n>>k;
	//BLUE:C(i-1,k-1);RED:C(i,n-k+1);T0TAL:C(i,k-1)*C(i,n-k+1)
	//5 3
	//1:C(0,2)*C(1,3)=3;2:C(1,2)*C(2,3)=2*3=6;C(2,2)*C(3,3)=1
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(ll i=1;i<=2005;i++)
		dp[i]=dp[i-1]*i%inf;
	/*
	for(ll i=1;i<=2000;i++)
		cout<<"dp["<<i<<"]="<<dp[i]<<endl;		
	*/
	for(ll i=1;i<=k;i++){
		if(i-1>n-k)
			cout<<"0\n";
		else	
			cout<<C(i-1,k-1)*C(i,n-k+1)%inf<<endl;
	}
		
}


Measured memory_bytes: 3760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j,N,M=4;
  cin>>N;
  string s;
  cin>>s;
  map<ll,ll> v;
  rep(j,M){
    v[-1]=j%2;
    v[0]=j/2%2;
    rep1(i,N+1){
      if(s[i-1]=='o'){
        if(v[i-1]){
          v[i]=v[i-2];
        }else{
          v[i]=v[i-2]^1;
        }
      }else{
        if(v[i-1]){
          v[i]=v[i-2]^1;
        }else{
          v[i]=v[i-2];
        }
      }
    }
    if(v[0]!=v[N]||v[-1]!=v[N-1])continue;
    rep(i,N){
      printf("%s",(v[i])?"S":"W");
    }
    return 0;
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX=200001;
int fac[MAX],finv[MAX],inv[MAX];

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

int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    int N,M,K;cin>>N>>M>>K;
    COMinit();
    int ans=0;
    REP(i,N){
        REP(j,M){
            int mcost=(i*(i+1)/2+(N-i)*(N-i-1)/2)%MOD;
            int ncost=(j*(j+1)/2+(M-j)*(M-j-1)/2)%MOD;
            int cost=(mcost*M%MOD+ncost*N%MOD)%MOD;
            cost*=COM(M*N-2,K-2);
            ans+=cost;
          	ans%=MOD;
        }
    }
  	ans*=inv[2];
  	ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
import Foundation
 
let input_line = readLine()!
 
let split = input_line.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
let N = Int(input_line)!
 
var Pi = [Int]()
let input_line2 = readLine()!

let splits = input_line2.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
Pi = splits.map {Int($0)!}.sort()
print(Pi[N / 2] - Pi[N / 2 - 1])

Measured memory_bytes: 7908
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<int>s(N);
    int ans = 0;
    int answer = 0;
    rep(i, N) {
        cin >> s[i];
        if (s[i] % 10 != 0) {
            if (ans == 0)ans = s[i];
            else {
                ans = min(ans, s[i]);
            }
        }
        answer += s[i];
    }
    if (answer % 10 != 0)cout << answer << endl;
    else if (ans == 0)cout << 0 << endl;
    else cout << answer - ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
li = list(map(int,input().split()))
x = 0 #まだ未定なら0、単調増加なら1、単調減少なら-1にする
i = 0 #index
ans = 0

if n == 1:
    print(1)
    exit()

while True:
    if x == 0:
        if li[i] < li[i+1]:
            x = 1
        elif li[i] > li[i+1]:
            x = -1
        else:
            x = 0
    if x == 1:
        if li[i] > li[i+1]:
            ans += 1
            x = 0
    if x == -1:
        if li[i] < li[i+1]:
            ans += 1
            x = 0
    i += 1
    if i == n-1:
        break
print(ans+1)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(void)
{
	//逐次シミュレーション
	int N, C;
	cin >> N >> C;
	vector<vector<int>> list = vector<vector<int>>(C, vector<int>(0));
	for (int i = 0; i < N; i++)
	{
		int s, t, c;
		cin >> s >> t >> c;
		list[c-1].push_back(2*s-1);
		list[c-1].push_back(2*t);
	}
	for (int i = 0; i < C; i++)
	{
		sort(list[i].begin(), list[i].end());
		list[i].erase(unique(list[i].begin(), list[i].end()),list[i].end());
		for (int j = 1; j < list[i].size(); j += 2)
		{
			list[i][j] *= -1;
		}
	}
	//全てのvectorを統合
	list[0].reserve(N);
	for (int i = 1; i < C; i++)
	{
		list[0].insert(list[0].end(), list[i].begin(), list[i].end());
	}
	//精査
	int result = 0;
	int rec = 0;
	sort(list[0].begin(), list[0].end(), [](int l, int r) {return abs(l) < abs(r); });
	int size = list[0].size();
	for (int i = 0; i < size; i++)
	{
		if (list[0].back() < 0)
		{
			rec++;
		}
		else {
			rec--;
		}
		if (result < rec)
		{
			result++;
		}
		list[0].pop_back();
	}
	cout << result << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

template <class T>
class SegTree {
  int n;
  vector<T> data;
  T def;
  function<T(T, T)> operation;
  function<T(T, T)> update;
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return def;
    if (a <= l && r <= b){
      return data[k];
    } else {
      T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
      T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
      return operation(c1, c2);
    }
  }
  public:
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
      function<T(T, T)> _update)
      : def(_def), operation(_operation), update(_update) {
      n = 1;
      while (n < _n) {
        n *= 2;
      }
      data = vector<T>(2 * n - 1, def);
    }
    void change(int i, T x) {
      i += n - 1;
      data[i] = update(data[i], x);
      while (i > 0) {
        i = (i - 1) / 2;
        data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
      }
    }
  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }

  // 添字でアクセス
  T operator[](int i) {
    return data[i + n - 1];
  }
};

int main(){
  cout << setprecision(10);
  int N,Q;
  cin >> N >> Q;

  SegTree<long long> st(N, (1LL << 31) - 1,
                      [](long long a, long long b) { return min(a, b); },
                      [](long long a, long long b) { return b; });
  while(Q--){
    int tmp;
    cin >> tmp;
    if(tmp == 0){
      int tmp1;
      ll tmp2;
      cin >> tmp1 >> tmp2;
      st.change(tmp1, tmp2);
    } else {
      int tmp1, tmp2;
      cin >> tmp1 >> tmp2;
      cout << st.query(tmp1, tmp2+1) << endl;
    }
  }
}


Measured memory_bytes: 4960
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	string str;
	int apos, zpos;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'A') {
			apos = i;
			break;
		}
	}
	for (int i = str.size()-1; i >0; i--) {
		if (str[i] == 'Z') {
			zpos = i;
			break;
		}
	}
	cout << zpos - apos+1 << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int a, p;
	cin >> a >> p;

	cout << (a * 3 + p) / 2 << endl;



	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        int ans = (a*b >= c*d)? a*b : c*d;
        
        System.out.print(ans);
    }
}


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

using namespace std;
int main(int argc, const char * argv[]) {
    
    long n, m;
    cin >> n >> m;

    map<long, long> a;
    set<long> s;
    for (long i = 0; i < n; i++) {
        long at;
        cin >> at;
        a[at] += 1;
        s.insert(at);
    }

    for (long i = 0; i < m; i++) {

        // cout << "--" << endl;
        long b, c;
        cin >> b >> c;
        while (b>0) {
            long mi = *s.begin();
            // cout << mi << " " << a[mi] << endl;
            if (c > mi) {

                if ( a[mi] <= b ) {
                    a[c] += a[mi];
                    b -= a[mi];
                    a[mi] = 0;
                    s.erase(mi);
                }
                else {
                    a[mi] -= b;
                    a[c] += b;
                    b = 0;
                }
                s.insert(c);
            }
            else {
                break;
            }

        }

    }

    long r = 0;
    for(map<long, long>::iterator it = a.begin(), itEnd = a.end(); it != itEnd; ++it) {
        long key = (*it).first;
        long val = (*it).second;
       //  cout << key << " " << val << endl;

        r += (key*val);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
const int inf=0x3f3f3f3f;
typedef pair<ll,int>P;
priority_queue<P>pq;

int main(){
    ll sum=0,tot1,tot2=0,now;
    int x,y,a,b,c;
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    tot1=x+y;
    for(int i=0;i<a;i++)
        scanf("%lld",&now),pq.push(P(now,2));
    for(int i=0;i<b;i++)
        scanf("%lld",&now),pq.push(P(now,1));
    for(int i=0;i<c;i++)
        scanf("%lld",&now),pq.push(P(now,0));
    while(pq.size()&&tot1){
        P u=pq.top();
        pq.pop();
        if(u.second==2){
            if(!x)
                continue;
            sum+=u.first;
            x--;
            tot1--;
        }
        if(u.second==1){
            if(!y)
                continue;
            sum+=u.first;
            y--;
            tot1--;
        }
        if(u.second==0){
            sum+=u.first;
            tot1--;
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 10348
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = n;
        long ans = 753;
        boolean flag = true;
        long i = 1;
        long kotae = 100000;
        long num = 0;
        while (flag) {
            long sa = m % 1000;
            if (Math.abs(ans - sa) < kotae) {
                kotae = Math.abs(ans - sa);
                num = sa;
            }
            m = m / 10;
            if (m < 10) {
                flag = false;
            }
        }
        System.out.println(Math.abs(ans - num));
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b;
	cin >> a >> b;
	int x[100] = { 8,1,0,1,2,1,2,1,1,2,1,2,1 };
	if (x[a] == x[b])
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N;
    int a[11000];
    int i, j, k;
    int ans = 0;
    int tmpsum;

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &a[i]);
    }

    for(i=0; i<N; i++){
        tmpsum = 0;
        while(a[i]%2 == 0){
            a[i] = a[i]/2;
            tmpsum += 1;
        }
        ans += tmpsum;
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;



int main(){
   int n; cin>>n;
   //締め切りがはやいものからやっていく
   //pairがたでB基準のソート
   //どこかで締め切りすぎたらbreak
   vector<pair<ll,ll>> p(n);
    REP(i,n){
        int a,b;
        cin>>a>>b;
        p[i].first=b;
        p[i].second=a;

    }

    int time=0;
    bool ans=true;
    sort(ALL(p));
    REP(i,n){
        time+=p[i].second;//かかる時間
        if(time>p[i].first){
            ans=false;
            break;
        }
    }


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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll a,b; cin >> a >> b;
	if( abs(a-b) <= 1 ) cout << "Brown\n";
	else cout << "Alice\n";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    if(a > b) swap(a,b);
    int c = max(a-1,b-1);
    int d = max(n-a,n-b);
    int diff = b - a;
    // if(diff == 1){
    //     cout<<min({2LL,c,d})<<endl;
    //     return 0;
    // }
    int res = min(c,d);
    if(diff % 2 == 0){
        c = min(c,diff / 2);
        res = min(c,d);
    }else{
        // int x = 1 + diff / 2;
        // c = min(c,x);
        int movesReq = min({a-1,n-b});
        int ea,eb;
        ea = a;
        eb = b;
        if(movesReq == a-1){
            ea -= movesReq;
            eb -= movesReq;
        }else{
            ea += movesReq;
            eb += movesReq;
        }
        int ans = movesReq;
        a = ea;
        b = eb;
        ans += 1;
        ans += (b - a ) / 2;
        // cerr<<movesReq<<endl;
        res = min(res,ans);
    }
    cout<<res<<endl;
    return 0;
    
}



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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; ++i) cin >> a.at(i);
  
  sort(a.begin(), a.end(), greater<int>());
  int Alice = 0, Bob = 0;
  for (int i=0; i<N; ++i) {
    if (i % 2 == 0) Alice += a.at(i);
    else Bob += a.at(i);
  }
  
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int a[N],cnt[N];
vi ts,os,zs;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1)
    {
      cin>>a[i];
      int tmp=a[i],c=0;
      while(tmp%2==0)
	tmp>>=1,c++;
      cnt[i]=c;
      if(cnt[i]>=2) ts.pb(i);
      else if(cnt[i]==1) os.pb(i);
      else zs.pb(i);
    }
  if(sz(zs)>sz(ts))
    {
      if(sz(zs)==sz(ts)+1)
	{
	  if(sz(os)==0)
	    {
	      cout<<"Yes"<<endl;
	      return 0;
	    }
	}
      cout<<"No"<<endl;
      return 0;
    }
  cout<<"Yes"<<endl;
  return 0 ;
}


Measured memory_bytes: 1788
loop do
  n = gets.to_i
  break if n == 0
  arr = gets.split(' ').map(&:to_i)

  count = 0
  0.upto(n-1) do |i|
    min_idx = i
    (i+1).upto(n-1) do |j|
      min_idx = j if arr[min_idx] > arr[j]
    end

    if min_idx != i
      count += 1
      arr[i], arr[min_idx] = arr[min_idx], arr[i]
    end
  end

  puts arr.join(' ')
  puts count
end

Measured memory_bytes: 8632
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		long b = 1000;
		long c = 0;
		int[] d = new int[a];
		for(int i = 0; i < a; i++){
			d[i] = sc.nextInt();
		} 
		for(int i = 0; i < a- 1; i++){
			if(d[i] < d[i + 1]){
				c += b / d[i];
				b = b % d[i]; 
			}else if(d[i] == d[i + 1]){

			}else if(d[i] > d[i + 1]){
				b += c * d[i];
				c = 0;
			}
		}
		b += c * d[a - 1];
		System.out.println(b);
		
		
	}
}

Measured memory_bytes: 35864
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i] =map(int,input().split())

ans_list=[]  
from copy import deepcopy
def dfs(x,M,N,ans):
  if len(ans)<=N:
    ans.append(x)
    if len(ans)==N:
      ans_list.append(ans)
    else:
      for i in range(x,M+1):
        tmp=deepcopy(ans)
        dfs(i,M,N,tmp)   
      
q=dfs(1,M,N,[])

f=0
for A in ans_list:
  cnt=0
  for i in range(Q):
    if A[b[i]-1]-A[a[i]-1]==c[i]:
      cnt += d[i]
  f=max(f,cnt)
  
print(f)


Measured memory_bytes: 19000
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>

using namespace std;
unsigned long long lg=1e18;
unsigned long long lghalf=lg/2;

int main(void){
    unsigned long long ans=1,n,i,temp,bef,aft;
    cin>>n;
    vector<unsigned long long> v(0);
    for(i=0;i<n;i++){
        cin>>temp;
        v.push_back(temp);
        if(temp==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(auto val:v){
        bef=ans;
        ans*=val;
        aft=ans/val;
        if(ans>lg || aft!=bef || (bef>lghalf && val!=1)){
            cout<<-1<<endl;
            return 0; 
        }  
    }
    if(ans>lg){
        cout<<-1<<endl; 
    }else{   
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4320
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std ;

int main()
{
  int N ;
  cin>>N ;
  vector<pair<int64_t,int64_t>>C ;  //期限、かかる時間
  for(int i=0;i<N;i++){
    int x,y ;
    cin>>x>>y ;
    C.push_back(make_pair(y,x)) ;
  }
  
  sort(C.begin(),C.end()) ;
  int time=0 ;
  for(int i=0;i<N;i++){
    time+=C[i].second ;
    if(time>C[i].first){
      cout<<"No"<<endl ;
      return 0 ;
    }
  } 
  cout<<"Yes"<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 6384
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl10
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(long double,a,b);
  ll ans=floor(a*b);
  p(ans);
}


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

int n, a[100], ta = 0;

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

Measured memory_bytes: 256
def bfs_graph(G, start):
    from collections import deque
    # 隣接リストを食わせる
    prev = [None] * N
    dist = [-1] * N
    que = deque([start])
    dist[start] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            prev[w] = v
            que.append(w)
    return dist, prev
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
def int_(num_str):
    return int(num_str) - 1


for _ in range(M):
    a, b = map(int_, input().split())
    graph[a].append(b)
    graph[b].append(a)
_, prev = bfs_graph(graph, 0)
print("Yes")
for i in range(1, N):
    print(prev[i]+1)

Measured memory_bytes: 95048
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try {
      Scanner scan = new Scanner(System.in);
      int n, i=0, j;
      n = Integer.parseInt(scan.next());
      int x[] = new int[n];
      ArrayList<Integer> y = new ArrayList<Integer>();
      
      while(i<n){
        x[i] = Integer.parseInt(scan.next());
        y.add(x[i]);
        i = ++i;
      }
      Collections.sort(y);

      i = 0;
      while(i<n){
        if(x[i] <= y.get((n/2)-1)){
          System.out.println(y.get(n/2));
        }else{
          System.out.println(y.get((n/2)-1));
        }
        i = ++i;
      }
      
    }
    catch (Exception e) {
      System.out.println("NG");
    }
  }
}

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

using namespace std;

int A[] = {0,1,2,3,4,5,6,7};

double X[9];
double Y[9];

int main(){
    int N;
    scanf("%d", &N);

    int divide_by = 1;
    for(int i = 0; i < N; i ++){
        scanf("%lf%lf", &X[i], &Y[i]);
        divide_by *= (i+1);
    }

    double sum = 0;
    do{
        double temp = 0;
        for(int i = 1; i < N; i ++){
            temp += sqrt(pow(X[A[i]]-X[A[i-1]],2)+pow(Y[A[i]]-Y[A[i-1]],2));
        }
        sum += temp;
    }while(next_permutation(A, A+N));

    printf("%.9f", sum/divide_by);
    return 0;
}


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

int main()
{
	using namespace std;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, min = 0, ma = 0, ans = 0, count = 0,nagax=0,nagay=0;
	int once[100020] = {}, info[100020] = {};
	std::string str,strs;
	
	bool okada = true, okada2 = true;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> once[i];
		info[once[i]]++;
	}

	if (a % 2 == 0) {
		
		for (int i = 1; i<a; i+=2) {
		
			if (info[i] != 2) {
				okada = false;
		
			}
		
		}
	}
	else {
		if (info[0] != 1) {
			okada = false;
		}
		for (int i = 2; i< a; i += 2) {
		
			if (info[i] !=2) {
				okada = false;
			
			}
			
		}

	}
	if (okada) {
		ans = 1;
		long long MOD = 1e9 + 7;
			for (int i = 0; i < a / 2; i++) {
				ans *= 2;
				ans %= MOD;
			}
			

			cout << ans <<endl;
		
	}
	else {
		cout << "0" << endl;
	}
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int,int> P;
#define F first
#define S second
string to_str(int data){
  ostringstream os;
  os << data;
  return os.str();
}
int main(){
  int64 H,W,N;
  int y,x;
  int64 sum[10] = {0};
  map<P,int>mp;
  cin >> H >> W >> N;
  while(N--){
    cin >> y >> x;
    y--;x--;
    for(int i = 2;i >= 0;i--){
      for(int j = 2;j >= 0;j--){
	if(0 <= y - i && y + 2 - i < H && 0 <= x - j && x + 2 - j < W){
	  P a;a.F = y - i;a.S = x - j;
	  if(mp.find(a) != mp.end())mp[a]++;
	  else mp[a] = 1;
	}
      }
    }
  }
  int64 cnt = 0;
  for(map<P,int>::iterator itr = mp.begin();itr != mp.end();itr++){
    sum[itr->second]++;
    cnt++;
  }
  sum[0] = (H - 2) * (W - 2) - cnt;
  for(int i = 0;i < 10;i++){
    cout << sum[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N;
  vi D(N);
  rep(i,N) cin >> D[i];
  sort(all(D));
  cin >> M;
  vi T(M);
  rep(i,M) cin >> T[i];
  sort(all(T));
  
  int a=0, b=0;
  bool chk = false;
  while(b <= M){
    if(T[b] == D[a]){a++; b++;} 
    else a++;
    if(b == M) chk = true;
    if(a == N ) break;
  }
  
  YES(chk);
  return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
	int N;
	long long sum[211111];

	cin >> N;
	sum[0] = 0;
	for(int i = 1; i <= N; i++) {
		long long A;
		cin >> A;
		sum[i] += sum[i - 1] + A;
	}

	sort(sum, sum + N + 1);

	long long l = 0;
	long long r = 0;
	long long count = 0;
	while(l <= N) {
		while(r <= N && sum[l] == sum[r]) r++;
		long long n = r - l;
		count += n*(n-1)/2;
		l = r;
	}

	cout << count << endl;

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

const string YES = "Yes";
const string NO = "No";

bool check(vector<bool> b) {
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            vector<bool> a(b.size());
            a[a.size() - 1] = i;
            a[0] = j ^ 1;
            for (int x = 1; x + 1 < b.size(); x++) {
                a[x] = a[(x - 2 + b.size()) % b.size()] ^ b[x - 1];
            }
            bool f = true;
            for (int x = 0; x < b.size(); x++) {
                if (b[x] != a[(x - 1 + a.size()) % a.size()] ^ a[(x + 1) % a.size()]) {
                    f = false;
                }
            }
            if (f)return true;
        }
    }
    return false;

}

void solve(long long N, std::vector<long long> a) {
    for (int i = 0; i < 32; i++) {
        vector<bool> x;
        for (int j = 0; j < N; j++) {
            x.push_back(a[j] >> i & 1);
        }
        if(!check(x)){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
using System;
public class Hello{
    public static void Main(){
        
        //√(c−a)ˆ^2+(d−b)^2
        
        string [] str=Console.ReadLine().Split(' ');
        double x1=double.Parse(str[0]);
        double y1=double.Parse(str[1]);
        double x2=double.Parse(str[2]);
        double y2=double.Parse(str[3]);
        
        Console.WriteLine(Math.Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    }
}



Measured memory_bytes: 15980
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
 */
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        String s=sc.nextLine();
        String ans="";
        for (int i = 0; i < s.length(); i++) {
            ans+=d(s.charAt(i));
        }
        out.println(ans);
    }
    static char d(char c){
        for (char i = 'a'; i <= 'z'; i++) {
            if(c==i)return Character.toUpperCase(i);
        }
        for (char i = 'A'; i <= 'Z'; i++) {
            if(c==i)return Character.toLowerCase(i);
        }
        return c;
    }
}


Measured memory_bytes: 31604
#include <iostream>
#include "bits/stdc++.h"
#include <vector>

using namespace std;

int main() {
	vector<int> n;
	vector<int> x;

	while (true) {
		int nin, xin;
		cin >> nin >> xin;
		if (nin == 0 && xin == 0) {
			break;
		}
		n.push_back(nin);
		x.push_back(xin);
	}

	int cnt = 0;

	for (int i = 0; i < n.size(); ++i) {
		for (int j = 1; j < n[i]; ++j) {
			for (int k = j + 1;k <= n[i]; ++k) {
				for (int l = k + 1;l <= n[i]; ++l) {
					if (j + k + l == x[i]) {
						cnt += 1;
					}
				}
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}
	return 0;
}


Measured memory_bytes: 3116