akhauriyash/Code-Regression huggingface dataset:
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)
	writer := bufio.NewWriter(os.Stdout)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)

	for i := 1; i < 11110 && n > 0; i++ {
		x := i*5 + 1
		if isPrime(x) {
			fmt.Fprint(writer, x)
			n--
			if n > 0 {
				fmt.Fprint(writer, " ")
			}
		}
	}
	fmt.Fprintln(writer, "")

	writer.Flush()
}

func isPrime(x int) bool {
	for i := 2; i < x/2+1; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 640
N,K = map(int,input().split())
D = list(map(int,input().split()))
D = [x for x in range(0,10) if x not in D]
n = len(str(N))
K = 10 - K

def bi(x):
    o = [0]*n
    c = 0
    while x > 0:
        o[c] = x % K
        x //= K
        c += 1
    return o

m = int(str(min(filter(lambda x:x,D)))+str(min(D))*n)

for i in range(K**n):
    o = bi(i)
    j = int(''.join([str(D[x]) for x in o]))
    if N <= j:
        m = min(m,j)

print(m)

Measured memory_bytes: 3064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    t,a=INTM()
    hs=LIST()
    ct=0
    ans=100000000000
    for i,h in enumerate(hs):
        temp=t-h*0.006
        #print(temp)
        if abs(a-ans)>=abs(a-temp):
            ans=temp
            ct=i
    print(ct+1)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class BCraneAndTurtle {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int x,y;
        cin>>x>>y;
        int a=2*x-(y/2);
        if (((a*2+(x-a)*4)==y)&&a>=0&&(x-a)>=0)
            cout<<"Yes";
        else
            cout<<"No";

	}
};


int main() {
	BCraneAndTurtle solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int r, g, b, n, res;

int main(){
    cin >> r >> g >> b >> n;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            Int rem = n - i*r - j*g;
            if(rem >= 0 && rem % b ==0)res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            long N = long.Parse(S.Split(' ')[0]);
            long K = long.Parse(S.Split(' ')[1]);
            long Q = long.Parse(S.Split(' ')[2]);
            long[] score = new long[N];
            for (int i = 0; i < Q; i++)
            {
                long winner = long.Parse(Console.ReadLine());
                score[winner - 1]++;
            }
            for (int i = 0; i < N; i++)
            {
                if ((Q - score[i]) < K) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }
//            Console.Read();
        }
    }
}

Measured memory_bytes: 18140
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        String S = sc.next();
        
        if(S.length() <= K){
            System.out.println(S);
        }else{
            S = S.substring(0,K) + "...";
            System.out.println(S);
        }

        sc.close();

    }
    
}

Measured memory_bytes: 38484
import java.util.*;

public class Main {
    static class Pair implements Comparable<Pair>{
        int d =0;
        int idx =0;
        Pair(int x , int y){
            this.d = x;
            this.idx = y;
        }
        @Override
        public int compareTo(Pair o) {
            return  this.d-o.d;
        }

    }

    static class Trio implements Comparable<Trio>{
        int x=0;
        int s=0;
        int t=0;
        Trio(int x , int s , int t){
            this.x = x;
            this.s = s;
            this.t = t;
        }
        @Override
        public int compareTo(Trio o) {
            int xd = this.x - o.x;
            int sd = this.s - o.s;
            int td = this.t - o.t;
            return xd != 0 ? xd :
                    sd !=0 ? sd :
                            td;
        }

    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();// ins
        int Q = sc.nextInt();//Q people

        int[][] constructs = new int[N][4];
        for (int i = 0; i < N; i++) {
            int s = sc.nextInt();int t = sc.nextInt();int x = sc.nextInt();
            constructs[i]=new int[]{x ,s-x, t-x};
        }

        Arrays.sort(constructs, new Comparator<int[]>() { // sort construcions by start date
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1] - o2[1];
            }
        });


        TreeSet<int[]> sortedByEndTime= new TreeSet<>(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[2]==o2[2]?o1[0] - o2[0]  :o1[2] - o2[2];
            }
        });
        TreeSet<int[]> sortedByDistance= new TreeSet<>( (o1,o2) -> o1[0]==o2[0] ? o1[1]-o2[1]: o1[0]-o2[0]);


        StringBuilder sb = new StringBuilder();
        int idx = 0;
        for (int i = 0; i < Q; i++) {

            int d= sc.nextInt();

            while(idx < constructs.length && constructs[idx][1] <= d ){ //  Starttme <= d
                sortedByEndTime.add(constructs[idx]);
                sortedByDistance.add(constructs[idx]);
                idx++;
            }

            while( !sortedByEndTime.isEmpty() &&  sortedByEndTime.first()[2] <= d ) { //  Endttme >= d remove
                int[]  construct = sortedByEndTime.pollFirst();
                sortedByDistance.remove(construct);
            }

            if(sortedByDistance.isEmpty()){
                sb.append(-1).append('\n');
//                System.out.println("-1");
            }else{
                int[] closestConstru = sortedByDistance.first();
                sb.append(closestConstru[0]).append('\n');
//                System.out.println(closestConstru[0]);
            }
//            sortedByDistance.clear();
//            sortedByEndTime.clear();
        }

        System.out.println(sb.toString());
      
    }}

Measured memory_bytes: 208188
#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[200005];
int b[128];
int d[200005];
string s;
char c[200005];

int main()
{
    cin>>s;
    n = s.size();
    s = '.' + s;
    for(char i = 'a'; i <= 'z'; i++)
    {
        b[i] = n + 1;
    }
    for(int i = n; i >= 0; i--)
    {
        char mj;
        int mn = 1e9;
        for(char j = 'a'; j <= 'z'; j++)
        {
            if(a[b[j]] < mn)
            {
                mn = a[b[j]];
                mj = j;
            }
        }
        a[i] = mn + 1;
        c[i] = mj;
        d[i] = b[mj];
        b[s[i]] = i;
    }
    int now = 0;
    string ans;
    ans.clear();
    while(a[now] != 0)
    {
        ans.push_back(c[now]);
        now = d[now];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2368
using System;
using System.Collections.Generic;

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp


public class Test
{
	public static void Main()
	{

		  string[] str1 = Console.ReadLine().Split(' ');
		  int n = int.Parse(str1[0]); 
		  double k = double.Parse(str1[1]); 

		double[] a = new double[n];
		for(int i=0; i<n; i++){
			a[i] = double.Parse(Console.ReadLine());
		}
		  //Console.WriteLine("改行あり N = {0} P = {1} Ai = {2}", n, p, a);
		  Console.WriteLine(calc3(n,k,a));
		
		
	}

  public static int calc1(int n,double k,double[] a) {
	  double[] ra = new double[n];
	  double[] rb = new double[n];
	  bool[] pass = new bool[n+1];
	  for(int l=1;l<=n; l++){
		pass[l] = false;
		for(int i=0;i<=(n-l); i++){
			if(l==1) {
				ra[i] = a[i];
			} else {
				ra[i] = rb[i]*a[l+i-1];
			}
			if(ra[i] < k) pass[l] = true;
		}
		rb = ra;
	  }
	
	  int ret = 0;
	  for(int l=n;0<l; l--){
		if(pass[l]) {
			ret = l;
			break;
		}
	  }

	  return ret;
  }
  
  public static int calc3(int n,double k,double[] a) {
	  double[] lp = new double[n+1];
	  double[] rp = new double[n+1];
	  for(int i=0; i<=n; i++) {
		if((i<n)&&(a[i]<0.005)) return n;
//		lp[i] = (i==0) ? 1.0 : (lp[i-1]*a[i-1]);
//		rp[i] = (i==0) ? 1.0 : (rp[i-1]*a[n-i]);
		lp[i] = (i==0) ? 0.0 : (lp[i-1]+Math.Log(a[i-1]));
		rp[i] = (i==0) ? 0.0 : (rp[i-1]+Math.Log(a[n-i]));
	  }
	  if(k<0.005) return 0;
//	  double prod = lp[n]/(k+0.005);
	  double prod = lp[n]-Math.Log(k+0.005);
	  
	  double[] lp_max = new double[n+1];
	  double[] rp_max = new double[n+1];
	  int nmax = n;
	  for(int i=0; i<=n; i++) {
		nmax = n-i;
		if(i==0) {
			lp_max[0] = lp[0];
			rp_max[0] = rp[0];
		} else {
			lp_max[i] = (lp_max[i-1]<lp[i])? lp[i] : lp_max[i-1];
			rp_max[i] = (rp_max[i-1]<rp[i])? rp[i] : rp_max[i-1];
		}
		if(prod < (lp_max[i]+rp_max[i])) break;
	  }


	  for(int l=nmax;0<l; l--){
		int q = n-l;
		for(int i=0;i<=q; i++){
//			if(prod < (lp[i]*rp[q-i])) return l;
			if(prod < (lp[i]+rp[q-i])) return l;
		}
	  }

	  return 0;
  }



}



Measured memory_bytes: 14424
mod = 998244353
n = int(input())
d = list(map(int,input().split()))

ans = 1
if d[0] != 0 or sum(d) < n - 2 or sum(d) > (n * (n - 1) // 2) + 1:
    print(0)
else:
    l = [0] * (max(d) + 1)
    for i in range(n):
        l[d[i]] += 1

    if l[0] != 1:
        print(0)
    else:
        for j in range(1, len(l)):
            if l[j] == 0:
                ans = 0
                break
            else:
                x = l[j - 1] ** l[j] % mod
                ans *= x
                ans %= mod
        print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "RESORT"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const int mod = 1e9 + 7;
using namespace std;
const int N = 5005;
ll n, m, a[N], b[N], ma[N][N], k, T, tong, d[N][N], ans, t, s;
;
bool ck;

inline void sol()
{
	for(int i = 1; i <= 5; i ++)cin >> a[i];
	for(int i = 1; i <= 5; i ++)
    {
        if(a[i] == 0)
        {
            cout << i;
            break;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
    sol();

}
/*
3 11
4 1 3 7 8
5 2 3 4 5 6
4 11 10 9 8
4 9
*/


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

const int MOD = 1000000007;
const int64_t INF = 1LL << 60;

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

    string ans = "No";
    while (N >= 0) {
        if (N % 4 == 0) {
            ans = "Yes";
            break;
        }
        N -= 7;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
t=int(input())
count = 0
flag = False
for test in range(t):
    a,b = map(int,input().split())
    if a==b:
    	count+=1
    	if count==3:
    		flag=True
    else:
    	count=0

if flag:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9188
#include <stdio.h>
#include <string.h>

int main() {
  int K;
  char str[101];
  scanf("%d %[^\n]",&K, str);
  int len = strlen(str);

  if(len <= K) {
    printf("%s", str);
  }
  else {
    for(int i = 0; i < K; i++) {
      printf("%c", str[i]);
    }
    printf("...");
  }

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int len=s.length();
    int cnt=0,now=-1;
    for(int i=0;i<n;i++)
    {
        if(now!=s[i]-'a')
        {
            cnt++;
            now=s[i]-'a';
        }
    }
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 512
/* Question 1
Queue using array
Abhishek Trivedi
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,l,k,p;
  cin>>n;
  int a[n],b[n];
  l=0;
  k=0;
  
  for(i=0;i<n;i++)
  cin>>a[i]>>b[i];
  for(i=0;i<n;i++)
  {
      if(a[i]==b[i]){
         k=k+1;
      }
     else if(a[i]!=b[i])
      {   if(k<3){
          k=0;
      }
      else
      k=k;
      }
  }
  if(k>=3)
  cout<<"Yes"<<endl;
  else
  cout<<"No";
  
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  sort(A.begin(),A.end());
  A.push_back(MOD);

  ll ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int val=A[i]+A[j];
      int z=lower_bound(A.begin(),A.end(),val)-A.begin();
      z=N-z;
      ans+=(N-1-j-z);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  double t,x;
  cin>>t>>x;
  cout<<t/x<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  
  int ans=0;
  int n=s.size();
  rep(i,n){
    if(i%2==0&&s[i]=='0')ans++;
    if(i%2==1&&s[i]=='1')ans++;
  }
  
  int tmp=0;
  rep(i,n){
    if(i%2==0&&s[i]=='1')tmp++;
    if(i%2==1&&s[i]=='0')tmp++;
  }
  chmin(ans,tmp);
  cout(ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;


int main(){
	int n, a;
	int flag = -1, next = 1e9 + 7 , ans = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i ++ ){
		scanf("%d",&a);
		if(a <= next){
			next = a;
			flag ++ ;
		}
		else{
			next = a;
			ans  = max(ans, flag);
			flag = 0;
		}
	}
	ans = max(ans, flag);
	cout << ans << endl;
	
		
	return 0;
}

Measured memory_bytes: 256
N = int(input())
def two(n):
    res = []
    if n%2 == 0:
        m = n//2
        for i in range(m):
            res.append(i*6+2)
            res.append(i*6+4)
        return res      
def three(n):
    res = []
    if n%2 == 0:
        m = n//2
        for i in range(m-1):
            res.append(i*6+3)
            res.append(i*6+6)
        if m%2 == 0:
            res.append(m*6-3)
            res.append(m*6)
        else:
            res.append(m*6)
            res.append(m*6+6)
    else:
        m = n//2
        if m%2 == 0:
            for i in range(m):
                res.append(i*6+3)
                res.append(i*6+6)
            res.append(m*6+6)
        else:
            for i in range(m):
                res.append(i*6+3)
                res.append(i*6+6)
            res.append(m*6+3)
    return res
import sys
if N == 3:
    ans = [22, 3, 5]
    print(*ans)
    sys.exit()
if N == 4:
    ans = [2, 4, 3, 9]
    print(*ans)
    sys.exit()
if N == 6:
    ans = [2, 4, 3, 6, 9, 12]
    print(*ans)
    sys.exit()
a = N//2
b = N-a
if a%2 != 0:
    if b%2 != 0:
        a+=1
        b-=1
    else:
        a, b = b, a
ans = two(a)
ans+=three(b)
print(*ans)




        




Measured memory_bytes: 42736
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int g = 0;
    int na = 0;
    if(A==5){
        g++;
    }else if(A==7){
        na++;
}
    if(B==5){
        g++;
    }else if(B==7){
        na++;
}
    if(C==5){
        g++;
    }else if(C==7){
        na++;    
    }
    
    if(g==2 && na==1){
    System.out.println("YES");
    }else{
    System.out.println("NO");    
    }
}
    }

Measured memory_bytes: 35820
#include<stdio.h>

int main(){
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);

    int sum;
    if(op=='+'){
        sum=a+b;       
    }else{
        sum=a-b;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 1720
import math
N,K=map(int,input().split())

times_dic = {}
for i in range(1,N+1):
  times = 0
  if i < K:
    times = math.ceil(math.log2(K/i))

  if times not in times_dic:
    times_dic[times] = 1
  else:
    times_dic[times] += 1
  
prob=0  
for times in times_dic:
  prob += 0.5**times*times_dic[times]/N
print(prob)


Measured memory_bytes: 3060
N = int(input())
S = input()

ss1 = S[1:].count('E')
ss = ss1

for i in range(1, N):
  ss1 = ss1 + (S[i-1]=='W') - (S[i]=='E')
  if ss1 < ss:
    ss = ss1
  
print(ss)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    vector<int>N(4);
    vector<int>A={1,4,7,9};
    rep(i,4){
        cin>>N[i];
    }
    sort(N.begin(),N.end());
    if(N==A){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[100],t[100],b[100];
    cin>>s>>t>>b;
    cout<<(char)(s[0]-32)<<""<<(char)(t[0]-32)<<""<<(char)(b[0]-32);
    return 0;
}
     
   




Measured memory_bytes: 3644
N = int(input())
a,b = map(int,input().split())
arr = sorted(list(map(int,input().split())))

import bisect
first = 0
second = 0
third = 0
first = bisect.bisect_right(arr,a)
second = bisect.bisect_right(arr,b) - first
third = N -second - first
print(min(first,second,third))

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Rally
            int N = int.Parse(Console.ReadLine());
            var X = ReadLine();
            int ans = int.MaxValue;

            for(int i = 0; i <= 100; i++)
            {
                int sum = 0;

                foreach(var x in X)
                {
                    sum += (int)Math.Pow(x - i, 2);
                }

                ans = Math.Min(ans, sum);
            }

            Console.WriteLine(ans);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, D] = string_to_int(inputs[0])
    counter = -D
    num_person = 0
    is_just_increase = False
    for i in range(N):
        is_just_increase = False
        if counter == D:
            counter = -D
            num_person += 1
            is_just_increase = True
        else:
            counter += 1
    if not is_just_increase:
        num_person += 1
    return num_person


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3436
n,m=gets.split.map(&:to_i)
s=n.times.map{gets.to_i}

s.sort!
a=s[-1]-s[0]
for i in 0..s.length-m
    v=s[i+m-1]-s[i]
    if v<a
    a=v
    end
end

p a


Measured memory_bytes: 4016
MODE = "stdio"
require 'matrix'

tmp = Array.new

class Integer
  def divisor_list2
    return [1] if self == 1
    (1..Math.sqrt(self).to_i).select do |i|
      self%i == 0
    end.map {|e| [e, self/e]}.flatten.uniq.sort
  end
end

if(defined? MODE)
  tmp = STDIN.read.split("\n")
else
  iotmp = "\
  2 4 2
  ".split("\n")
  iotmp.each{|s|
    tmp << s.strip
  }
end


class Range
  def initialize(a,b,c)
    @a = a
    @b = b
    @c = c
  end

  def display
    if (@a<@b)&&(@b<@c)
      puts "Yes"
    else
      puts "No"
    end
  end
end


a,b,c = tmp[0].split(" ").map(&:to_i)

range = Range.new(a,b,c)

range.display

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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k << " " << b << endl;
  }else if(b>=(k-a)){
    cout << 0 << " " << b-k+a << endl;
  }else{
    cout << 0 << " " << 0 << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 1000
#define MIN(a,b) ((a) < (b) ? (a) : (b))

typedef struct heap{
	int *a;
	int num;
}heap;

void swap(int a[],int x,int y){
	int temp=a[x];
	a[x]=a[y];
	a[y]=temp;
	return;
}

void heap_up_reconst(heap H){
	int i=H.num-1;
	
	while(i>0){
		if(i%2==0){
			if(H.a[i] > H.a[i/2-1]){
				swap(H.a,i,i/2-1);
				i=i/2-1;
			}
			else break;
		}
		else {
			if(H.a[i] > H.a[i/2]){
				swap(H.a,i,i/2);
				i=i/2;
			}
			else break;
			
		}
	}
	
	return;
	
}

void heap_down_reconst(heap H){
	int i=0;
	
	while(i<H.num){
		
		if(i*2+1 > H.num-1 && i*2+2 >H.num-1)break;/*子なし*/
		
		else if(i*2+1==H.num-1){/*子1つ*/
			if(H.a[i] < H.a[i*2+1]){
				swap(H.a,i,i*2+1);
				i=H.num;
			}
			else break;;
		}
		
		else if(i*2+1 <= H.num-1 && i*2+2 <= H.num-1){/*子2つ*/
			if(H.a[i*2+1] >= H.a[i*2+2] && H.a[i*2+1] > H.a[i]){
				swap(H.a,i,i*2+1);
				i=i*2+1;
			}
			
			else if(H.a[i*2+1] < H.a[i*2+2] && H.a[i*2+2] > H.a[i]){
				swap(H.a,i,i*2+2);
				i=i*2+2;
			}
			
			else break;
		}
		
	}
	
	return;
	
}

int main(){
	int n,q;
	int i,x,y,com;
	heap H[N];
	
	scanf("%d %d",&n,&q);
	
	for(i=0;i<n;i++){
		H[i].a=malloc(sizeof(int)*q);
		H[i].num=0;
	}
	
	for(i=0;i<q;i++){
		scanf("%d %d",&com,&x);
		
		if(com==0){
			scanf("%d",&y);
			H[x].a[H[x].num++]=y;
			heap_up_reconst(H[x]);
		}
		
		if(com==1)if(H[x].num!=0)printf("%d\n",H[x].a[0]);
		
		if(com==2){
			if(H[x].num!=0){
				swap(H[x].a,0,H[x].num-1);
				H[x].num--;
				heap_down_reconst(H[x]);
			}
		}
		
	}
	
	return 0;
	
}


Measured memory_bytes: 6488
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        String S = in.s();
        final int len = S.length();
        int Q = in.i();
        boolean forward = true;
        LinkedList<Character> list = new LinkedList<>();
        for(int i = 0; i < len; i++){
            list.add(S.charAt(i));
        }
        for(int i = 0; i < Q; i++){
            String[] s = in.ss();
            int T = Integer.parseInt(s[0]);
            if(T == 1){
                forward = !forward;
            } else {
                int F = Integer.parseInt(s[1]);
                char c = s[2].charAt(0);
                if(forward && F == 2 || !forward && F == 1){
                    list.add(c);
                } else {
                    list.addFirst(c);
                }
            }
        }
        char[] ans = new char[list.size()];
        if(forward){
            int i = 0;
            for(char c : list){
                ans[i++] = c;
            }
        } else {
            int i = ans.length-1;
            for(char c : list){
                ans[i--] = c;
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 66816
n=gets.to_i
a=gets.split.map(&:to_i).sort
c=(a.inject(:+).to_f/n).round
s=a[0]
m=a[-1]
x=1000000
y=1000000
c.upto(m){|i|w=a.map{|j|(i-j)**2}.inject(:+)
  if x>w
    x=w
  else
    break
  end
  }
c.downto(s){|i|w=a.map{|j|(i-j)**2}.inject(:+)
  if y>w
    y=w
  else
    break
  end
  }
puts [x,y].min


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int n;
int a[MAX], b[MAX], c[MAX];
LL bBuf[MAX];

int main(void) {
    scanf("%d", &n);
    REP(i, n) scanf("%d", a + i);
    REP(i, n) scanf("%d", b + i);
    REP(i, n) scanf("%d", c + i);
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    REP(i, n) {
        bBuf[i + 1] = n - (upper_bound(c, c + n, b[i]) - c);
        //DEBUG(bBuf[i])
    }
    REP(i, MAX - 1) bBuf[i + 1] += bBuf[i];
    LL ans = 0;
    REP(i, n) {
        int bIdx = upper_bound(b, b + n, a[i]) - b;
        ans += (bBuf[MAX - 1] - bBuf[bIdx]);
        //DEBUG(bIdx)
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    }

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>

int main(){

  double sum, x, h;
  while(1){

    scanf("%lf %lf",&x, &h);

    if(x == 0 && h == 0){
      break;
    }

    sum = x * x + 2 * x * sqrt(h*h+x*x/4);

    printf("%f\n",sum);

  }


  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	set<int> ss;
	int ans = true;
	REP(i, N) {
		int A;
		scanf("%d", &A);
		if (ss.find(A) != ss.end()) ans = false;
		ss.insert(A);
	}
	puts([&] {
		return ans;
	}() ? "YES": "NO");
	return 0;
}


Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

ll factorial(int n){
	ll res = 1;
	for(int i=1;i<=n;i++){
		res = (res * i) % INF;
	}

	return res;
}

int main(void){
	int n;
	cin>>n;
	
	ll ans = factorial(n);

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 256
calChange :: [Int] -> Int -> Int
calChange [] _ = 0
calChange _ 0 = 0
calChange (c:t) p = p `div` c + calChange t (p `mod` c)

main::IO()
main = do
  price <- fmap ((1000 -) .read) getLine :: IO Int
  if price == 1000 then return ()
  else do print(calChange [500, 100, 50, 10, 5, 1] price)
          main



Measured memory_bytes: 3640
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 10, M = 1e3 + 10;
const int INF = INT_MAX;
const db PI = acos(-1);

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    string s;
    int n, k;
    cin >> n >> k >> s;
    s[k - 1] -= ('A' - 'a');
    cout << s << "\n";
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int start_index = -1;
    int end_index = 0;
    for (size_t i = 0; i < s.size(); ++i) {
        if (start_index != -1 && s[i] == 'Z') {
            end_index = i;
        }
        if (start_index == -1 && s[i] == 'A') start_index = i;
    }
    cout << end_index - start_index + 1<< endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 640
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

Measured memory_bytes: 9188
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1186&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	
	int H,W;
	int dia; //Diagonal : 対角線
	pair<int,int> rect; //rectangle : 長方形

	while(cin >> H >> W && H && W)
	{
		dia = H*H + W*W;
		rect.first = 151; rect.second = 151;
		bool found=false;

		int tmpDia=0;
		REP(h,1,151)
		{
			REP(w,h+1,151)
			{
				if(h > H && h != H)
				{
					tmpDia = h*h + w*w;
					if(dia == tmpDia){
						if(h < rect.first){ found=true; rect.first=h; rect.second=w; }
					}
				}
			}
		}

		int nowDia=0;
		if(!found)
		{
			REP(h,1,151)
			{
				REP(w,h+1,151)
				{
					tmpDia = h*h + w*w;
					nowDia = rect.first*rect.first + rect.second*rect.second;
					if(dia < tmpDia && tmpDia < nowDia)
					{
						rect.first = h; rect.second = w;
					}
				}
			}
		}

		cout << rect.first << " " << rect.second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
double d,x;
int main()
{
	scanf("%d %lf %lf",&n,&x,&d);
	int m=2*n;
	double ans=0;
	while(m)
	{
		ans+=(2.0*x+(1.0*m-1.0)*d)/2.0;
		x=((1.0*m+2.0)*x+5.0*d)/(1.0*m);
		d=(1.0*m+4.0)*d/(1.0*m);
		m-=2;
	}
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main() {
	char x[4] = { 'A','C','G','T' };
	cin >> S;
	vector<int> a(S.size(),0);
	int ans = 0;
	for (int j = 0; j < 4; j++) {
		if (x[j] == S[0]) {
			a[0] = 1;
		}
	}
	for (int i = 1; i < S.size(); i++) {
		for (int j = 0; j < 4; j++) {
			if (x[j] == S[i]) {
				a[i] = a[i - 1] + 1;
			}
		}
	}
	cout << *max_element(a.begin(),a.end()) << endl;
}


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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    vector<int> ans(n+1);
    
    vector<int> tmp(n+1);
    
    vector<int> aans;
    
    for (int i = n; i >= 1; i--){
        ans[i] = tmp[i] ^ a[i];
        if(ans[i]){
            for (int j = 1; j * j <= i; j++){
                if(i%j != 0)continue;
                int a1 = j;
                int a2 = i/j;
                tmp[a1] ^= 1;
                if(a1 != a2 && a2 != i){
                    tmp[a2] ^= 1;
                }
            }
        
            aans.push_back(i);
        }
    }
    
    reverse(aans.begin(), aans.end());
    
    cout << aans.size() << "\n";
    for (int i = 0; i < aans.size(); i++){
        cout << aans[i] << " \n"[i == aans.size() - 1];
    }
    
    
    
    
    
    return 0;
}


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

vector<vpl> G(101010);

vl bfs(ll s, ll n){
	vl d(n,-1);
	d[s] = 0;
	queue<ll> q;
	q.push(s);
	while(!q.empty()){
		ll u = q.front(); q.pop();
		for(auto v : G[u]){
			if(d[v.first] == -1){
				d[v.first] = d[u] + v.second;
				q.push(v.first);
			}
		}
	}
	return d;
}

int main(){
	ll n; cin >> n;
	rep(i,n-1){
		ll u,v,d; cin >> u >> v >> d;
		G[u].emplace_back(v,d);
		G[v].emplace_back(u,d);
	}
	auto d = bfs(0,n);
	auto dist = bfs(max_element(all(d)) - d.begin(), n);
	cout << *max_element(all(dist)) << "\n";
}


Measured memory_bytes: 12520
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    double a, b, c;
    cin >> a >> b >> c;
    double lhs = a + b + (2*sqrt(a)*sqrt(b));
    if (lhs < c) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

using namespace std;

int check(int a,int b,int c)
{
    if(a==7)
    {
        if(b==5&&c==5)return 1;
    }
    else if(b==7&&c==5||b==5&&c==7)return 1;
    return 0;
}
int main()
{
    int a,b,c;
    int flag;
    cin>>a>>b>>c;
    flag=check(a,b,c);
    if(flag)cout<<"YES";
    else cout<<"NO";
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 S, W;
    cin >> S >> W;
    string res = S <= W? "unsafe" : "safe";
    cout << res << endl;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll i,j,x,n;
    cin>>x>>n;
    vector<ll> p(n);
    map<ll,ll> mp;
    for(i=0;i<n;i++) cin>>p[i],mp[p[i]]++;
    ll cur = x;
    while(mp[cur] > 0) cur--;
    ll left = cur;
    cur = x;
    while(mp[cur] > 0) cur++;
    ll right = cur;
    // cout<<left<<" "<<right<<"\n";
    if(abs(left-x) <= abs(right-x)) cout<<left;
    else cout<<right;
}

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

using namespace std;

typedef long long ll;

void FASTIO() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
}

int main() {
	FASTIO();
	double n; scanf("%lf",&n);
	printf("%.10lf",(n/(3.0000000000))*(n/(3.0000000000))*(n/(3.0000000000)));
	return 0;
}

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

int main() {
    int A,B,C;
    cin >>A>>B>>C;
    int mx =max(A,max(B,C));
    int mn =min(A,min(B,C));
    cout << mx-mn <<endl;

}

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

int main(){
    string S;
    cin >> S;
    int n = S.length();
    long number = stol(S);
    int num[100];
    for (int i = 0; i < n; i++){
        num[n - 1 - i] = number % 10;
        number = number/10;
    }

    long sum[10000] = {};
    for (int bit = 0; bit < (1 << n - 1); bit++){
        //cout << bit << endl;
        vector<int> save;
        long hoge = num[0];
        for (int j = 1; j < n; j++){
            if(bit & (1 << j - 1)){
                save.push_back(hoge);
                hoge = num[j];
            }
            else{
                hoge = hoge * 10 + num[j];
            }
        }
        vector<int>::iterator itr;
        if (!save.empty()){
            for (itr = save.begin(); itr != save.end(); itr++){
                sum[bit] += *itr;
            }
        }
        sum[bit] += hoge;
    }
    /*for (int bit = 0; bit < (1 << n - 1); bit++){
        cout << sum[bit] << endl;
    }*/
    long total = 0;
    for (int bit = 0; bit < (1 << n - 1); bit++){
        total += sum[bit];
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 384