akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1400

int dp[MAX][MAX], G[MAX][MAX];

int  getLargestSquare(int H, int W) {
	int maxWidth = 0;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++) {
			dp[i][j] = (G[i][j] + 1) % 2;
			maxWidth |= dp[i][j];
		}
	}
	for (int i = 1; i < H; i++){
		for (int j = 1; j < W; j++) {
			if (G[i][j]) {
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				maxWidth = max(maxWidth, dp[i][j]);
			}
		}
	}
	return maxWidth * maxWidth;
}

int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++)cin >> G[i][j];
	}
	cout << getLargestSquare(H, W) << endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int si = s.size() - 1;
  
  if (s.at(si) == 's') {
    s.push_back('e');
    s.push_back('s');
  }
  else if (s.at(si) != 's') s.push_back('s');
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        string S;
        cin >> S;
        int ans = 0;
        rep(i, 3) {
                if (S[i]=='1')
                        ans++;
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if((e-a)<=k)cout<<"Yay!\n";
	else cout<<":(\n";
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(){
    int a[4];
    int b[4];
    int used[10];
    int hits, blows;
    
    while (scanf("%d %d %d %d",&a[0], &a[1], &a[2], &a[3]) != EOF){
        scanf("%d %d %d %d",&b[0], &b[1], &b[2], &b[3]);
        hits = blows = 0;
        for (int i=0; i<10; i++) used[i]=0;
        for (int i=0; i<4; i++) used[a[i]]++;
        for (int i=0; i<4; i++){
            if (used[b[i]]){
                if (b[i] == a[i]) hits++;
                else blows++;
            }
        }
        printf("%d %d\n", hits, blows);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

void printD( deque<int>& a ){
}

int main() {

    int N;
    Scd(N);

    ll K;
    Scll(K);

    vi A(N);  //input
    vector<set<int>> B(200001);//place
    vector<set<int>> C(200001);//place

    Rep(i,N){
        Scd(A[i]);
        B[A[i]].insert(i);
        C[A[i]].insert(i);
    }

    deque<int> ans;
    int t = 0;
    int n = 1;
    int k = 1;
    do{
        n = A[t];
        auto it = B[n].upper_bound(t);
        if( it == B[n].end() ){
            it = B[n].upper_bound(-1);
            k++;
        }
        t = *it;
        t++;
    }while( t%N );

    t = 0;
    n = 1;
    int tk = K%k;
    k = 0;
    do{
        n = A[t];
        auto it = C[n].upper_bound(t);
        if( it == C[n].end() ){
            it = C[n].upper_bound(-1);
            k++;
            if( tk == k ) break;
        }
        t = *it;
        t++;
    }while( t%N );

    for( ; t < N; t++ ){
        n = A[t];
        auto it = C[n].upper_bound(t);
        if( it != C[n].end() ){
            t = *it;
        }else{
            ans.push_back(A[t]);
        }
    }

    Rep(i,ans.size()){
        printf("%d%c", ans[i], i == ans.size()-1 ? 10 : ' ' );
    }


    return 0;
}


/*

1231231

231
1
31
^



*/




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

typedef struct node_ node;

struct node_{
    int x;
    node *before;
    node *next;
};

class list{
    node* head;
    node* tail;
public:
    list(){
        head = NULL;
        tail = NULL;
    }
    void insertX(int n);
    void deleteX(int n);
    void deleteFirst();
    void deleteLast();
    void show();
};

void list::insertX(int n){
    node *tmp = new node;
    if(head)head->before = tmp;
    else tail = tmp;
    tmp->before = NULL;
    tmp->next = head;
    tmp->x = n;
    head = tmp;
}

void list::deleteX(int n){
    if(!head)return;
    if(head->x==n){
        deleteFirst();
        return;
    }
    node *ptr=head->next;
    while(ptr->x!=n){
        ptr=ptr->next;
        if(!ptr)return;
    }
    ptr->before->next = ptr->next;
    if(ptr->next)ptr->next->before=ptr->before;
    else tail = ptr->before;
    delete ptr;
}

void list::deleteFirst(){
    if(!head)return;
    if(head==tail){
        delete head;
        head = NULL;
        tail = NULL;
    }else{
        head = head->next;
        delete head->before;
        head->before = NULL;
    }
}

void list::deleteLast(){
    if(!tail)return;
    if(tail==head){
        delete tail;
        head = NULL;
        tail = NULL;
    }else{
        tail = tail->before;
        delete tail->next;
        tail->next = NULL;
    }
}

void list::show(){
    node *tmp = head;
    while(tmp){
        printf("%d",tmp->x);
        if(tmp->next)printf(" ");
        tmp = tmp->next;
    }
    printf("\n");
}

int main(){
    list ob;
    int i, n, x;
    char command[12];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",command);
        if(strcmp(command,"insert")==0){
            scanf("%d",&x);
            ob.insertX(x);
        }else if(strcmp(command,"delete")==0){
            scanf("%d",&x);
            ob.deleteX(x);
        }else if(strcmp(command,"deleteFirst")==0){
            ob.deleteFirst();
        }else if(strcmp(command,"deleteLast")==0){
            ob.deleteLast();
        }else{
            printf("else.\n");
        }
    }
    ob.show();
    return 0;
}



Measured memory_bytes: 33924
# Collatz Problem
def f(n):
    if n % 2 == 0: return n/2
    else: return 3*n + 1

n = int(input())
past_values = []
iter = 1
while n not in past_values:
    past_values.append(n)
    n = f(n)
    iter += 1

print(iter)
    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int arr[3];
int main()
{
    long long int a,b,c,i,j,k,l,m,t,n;
    for(i=0;i<3;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+3);
    cout<<arr[0]+arr[1]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
 
public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }
 
     long nextLong(){
          return Long.parseLong(next());
     }
 
     double nextDouble(){
          return Double.parseDouble(next());
     }

     String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
 
 }  
   
    static  Fast f=new Fast();
    static PrintWriter out = new PrintWriter(System.out);


    static void readArray(int a[]) 
      {
        
        for (int i=0;i<a.length;i++ ) a[i]=f.nextInt();
        
      }
    
    
     
  public static void main(String[] args)throws Exception{
  //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
         
 
        //StringBuilder res=new StringBuilder();

         int n=f.nextInt();
  
       
       // while(t-->0){
          int d1[]=new int[n];
          int d2[]=new int[n];
          for (int i=0;i<n ;i++ ) {
            d1[i]=f.nextInt();
            d2[i]=f.nextInt();
          }
          
          int count=0;
          for (int i=0;i<n ;i++ ) {
            if (count==3) {
              break;
            }

            if (d1[i]==d2[i]) {
              count++;
              continue;
            }

            count=0;

          }

          
      //  }
          if (count==3)
          out.println("Yes");
          else 
          out.println("No");

   
        

        out.close();
 
}
}

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

int main(){
    int x;
    scanf("%d",&x);
    int amari=x%100;
    int aa=x/100;
    if(x%105==0){
        printf("1\n");
        return 0;
    }
    else if(amari!=0){
        int amari2=amari%5;
        int g=amari/5;
        int a=1+g;
        if(aa>=a) printf("1\n");
        else printf("0\n"); 
    }
    else{
        printf("1\n");
    }
    
    

}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;

    vector<int> a(n+1), b(n+1);
    for(int i = 1; i <= n; i++) a[i] = b[i] = n;
    ll black = ll(n-2)*(n-2);
    int h = n, w = n;
    while(q--){
        int t, x;
        cin >> t >> x;
        if(t == 1){
            if(x < w){
                for(int i = x; i < w; i++){
                    b[i] = h;
                }
                w = x;
            }
            black -= b[x] - 2;
        }
        else{
            if(x < h){
                for(int i = x; i < h; i++){
                    a[i] = w;
                }
                h = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << endl;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define pqueue priority_queue
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    int N;
    cin>>N;
    int sum=0;
    int amari=N%500;
    sum+=(N/500)*1000;
    sum+=(amari/5)*5;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
		String s[]=bu.readLine().split(" ");
		int x=Integer.parseInt(s[0]),y=Integer.parseInt(s[1]),z=Integer.parseInt(s[2]);
		x=x^y^(y=x);
		x=x^z^(z=x);
		System.out.print(x+" "+y+" "+z);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair

ll N;
ll p[200005];
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;
rep(i,N) cin>>p[i];
ll pm=INF;
rep(i,N){
	if(pm>=p[i]) pm=p[i];
	if(pm>=p[i]) ans++;
}
cout<<ans<<endl;

}
	

Measured memory_bytes: 5188
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int max = 0;
		int count = 0;
		for (char c : arr) {
		    if (c == 'R') {
		        count++;
		        max = Math.max(max, count);
		    } else {
		        count = 0;
		    }
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 35612
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    dif=[a[i]-i for i in 1:n]
    sort!(dif)
    if n%2==1
        b=dif[div(n,2)+1]
    else
        b=div(dif[div(n,2)]+dif[div(n,2)+1],2)
    end
    ans=0
    for i in 1:n
        ans+=abs(dif[i]-b)
    end
    println(ans)
end
main()

Measured memory_bytes: 127492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuilder sb = new StringBuilder(s);
		final String d = "dream";
		final String eer = "eraser";
		final String ee = "erase";
		final String er = "er";
		boolean ok = true;
		boolean AfterDream = false;
		while(sb.length()!=0) {
			if(sb.length() >= 5&&sb.substring(0, 5).equals(d)) {
				sb.delete(0, 5);
				AfterDream = true;
				continue;
			} else 	if(sb.length() >= 6&&sb.substring(0, 6).equals(eer)) {
				sb.delete(0, 6);
			} else if(sb.length() >= 5&&sb.substring(0, 5).equals(ee)) {
				sb.delete(0, 5);
			} else if(AfterDream==true&&sb.length() >= 2 &&sb.substring(0, 2).equals(er)) {
				sb.delete(0, 2);
				AfterDream = false;
			} else {
				ok = false;
				break;
			}
			AfterDream = false;
		}
		System.out.println(ok ? "YES" : "NO");
	}
}

Measured memory_bytes: 29152
#include<stdio.h>
int main(){
  long long n,m,i,a,b,s=0,c;
  scanf("%lld %lld",&n,&m);
  scanf("%lld",&a);
  if(a>m){
    s+=a-m;
    a=m;
  }
  while(--n){//printf("%d\n",s);
    scanf("%lld",&b);
    c=0;
    if(a+b>m)c=a+b-m;
    s+=c;
    a=b-c;
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

// 二項係数計算
long long 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;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int a,b,c; cin >> a >> b >> c;
  if (a<=c && c<=b){cout << "Yes";}
  else {cout<<"No";}

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] card = br.readLine().split(" ");
            int alice = Integer.parseInt(card[0]);
            int bob = Integer.parseInt(card[1]);
            String str = alice == bob ? "Draw" : alice == 1 ? "Alice" : bob == 1 || alice < bob ? "Bob" : "Alice";
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  string s;
  cin>>s;
  int n = int(s.size());
//  cout << n << endl;
  int ans(0),tmp(0);
  for (int i(n-1);i>=0;i--){
    int now = (s[i]-'0') + tmp;
    //cout << now << endl;
    if (now == 10){
      tmp = 1;
    }else if (now == 5){
      ans += 5;
      if (i != 0 && s[i-1]-'0' >= 5){
        tmp = 1;
      }else{
        tmp = 0;
      }
    }else if (now >= 6){
      ans += (10 - now);
      tmp = 1;
    }else{
      ans += now;
      tmp = 0;
    }
  }
  if (tmp) ans++;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1412
#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=5005,mod[]={1000000007,1000000009},B=31;
int pw[2][N],inv[2][N];
int add(int x,int y,int id)
{
  x+=y;
  if(x>=mod[id]) x-=mod[id];
  if(x<0) x+=mod[id];
  return x;
}
int mult(int x,int y,int id)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod[id]) tmp%=mod[id];
  return tmp;
}
int pow1(int x,int y,int id)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x,id);
      x=mult(x,x,id);
      y>>=1;
    }
  return ans;
}
int h[2][N],cnt[N];
ii calc(int i,int j)
{
  if(i==0) return mp(h[0][j],h[1][j]);
  return mp(mult(inv[0][i],add(h[0][j],-h[0][i-1],0),0),mult(inv[1][i],add(h[1][j],-h[1][i-1],1),1));
}
map<ii,vi> m;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  rep(j,0,2)
    {
      pw[j][0]=inv[j][0]=1;
      rep(i,1,N)
	{
	  pw[j][i]=mult(pw[j][i-1],B,j);
	  inv[j][i]=pow1(pw[j][i],mod[j]-2,j);
	}
    }
  int n;
  string s;
  cin>>n>>s;
  int sum[]={0,0};
  rep(i,0,n)
    {
      int d=(int)(s[i]-'a'); d++;
      cnt[d-1]++;
      rep(j,0,2)
	{
	  sum[j]=add(sum[j],mult(d,pw[j][i],j),j);
	  h[j][i]=sum[j];
	}
    }
  bool ok2=false;
  rep(i,0,26) ok2|=(cnt[i]>1);
  if(!ok2)
    {
      cout<<0<<endl;
      return 0;
    }
  int low=1,high=n/2;
  while(low<high)
    {
      m.clear();
      int mid=(low+high+1)>>1;
      rep(i,0,n)
	{
	  if(i+mid-1==n) break;
	  ii curr=calc(i,i+mid-1);
	  m[curr].pb(i);
	}
      bool ok=false;
      for(auto it:m)
	{
	  if(sz(it.se)==1) continue;
	  if(it.se[0]+mid-1<it.se.back()) ok=true;
	}
      if(ok) low=mid;
      else high=mid-1;
    }
  cout<<low<<endl;
  return 0 ;
}


Measured memory_bytes: 896
let n = Int(readLine()!)!
let sortedrArray = readLine()!.characters.split{$0 == " "}.map{Int(String($0))!}.sort{$1 < $0}
var aliceTotal = 0
var bobTotal = 0
var aliceTurn = true
for i in sortedrArray {
    if(aliceTurn) {
        aliceTotal += i
    } else {
        bobTotal += i
    }
    
   aliceTurn = !aliceTurn
}

print(aliceTotal - bobTotal)


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

#define FORu(i, start, n) for (ll i = start; i < (ll)(n); i++)
#define FORd(i, start, n) for (ll i = start; i > (ll)(n); i--)

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

ll gcd(ll a, ll b) { //greatest common divisor
  if(b == 0)  return a;
  return gcd(b, a%b);
}
ll nCr(ll n, ll r) { // combinations
  ll C[r+1]; memset(C, 0, sizeof(C)); C[0] = 1;
  FORu(i,1,n+1){ 
    FORd(j,min(i,r),0){
      C[j] = C[j] + C[j-1];
    }
  }
  return C[r];
}
bool isPrime(ll n) {//check if prime
  if(n<=1) return false;
  if(n==2) return true;
  if(n%2==0) return false;
  ll m = sqrt(n);
  for (ll i=3; i<=m; i+=2) {
    if (n%i==0){
      return false;
    }
  }
  return true;
}

//==============================================================================

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int a, b; cin >> a >> b;
    //initialize series
    int arr[999];
    arr[0] = 1;
    FORu(i,1,999){
      arr[i] = arr[i-1] + (i+1); 
    }
    int diff = b - a;
    cout << arr[diff-1] - b << endl;
    return 0;
}


Measured memory_bytes: 256
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int A, B;

int main() {
    cin >> A >> B;

    cout << max(0, A-2*B) << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
//ノート　isupperで大文字の判定　islowerで小文字の判定
int main(){
    string s;
    std::cin >> s;
    bool q=1,w=0;
    rep(i,s.size()){
        if(q){
            if(s[i]=='C')q=0;
            
        }
        else{
            if(s[i]=='F')w=1;
            
        }
    }
    if(w)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;


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

    vector<int> a;
    int temp;
    double all = 0;

    for (int i = 0; i < n; i++) {
        cin >> temp;
        all += temp;
        a.push_back(temp);
    }

    int num = 0;

    for (int i = 0; i < n; i++) {
        if (all / (4 * m) <= a[i]) {
            num++;
        }
    }

    if (num >= m) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int x, y;
    cin >> x >> y;
    rep (i, x + 1) {
        int a = 0;
        a = 2 * i + 4 * (x - i);
        if (a == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int e,f;
  if(a>=b) e = b;
  else e = a;
  if(c>=d) f = d;
  else f = c;
  
  cout << e+f;
  return 0;
}

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

typedef long long LL;

constexpr long long INFLL = 1e18;

using namespace std;

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

    cout << n.at(0) << n.at(1) << n.at(2) << endl;

    return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define int     long long
using namespace std;
const   int mx = 1e4+9, INF = 1e4+9;
int     N, M, num[mx], low[mx], F[mx], cou = 0, res = 0;
vector  <int> A[mx];
stack   <int> Q;

void        DFS(int u){
    num[u] = low[u] = ++cou;
    Q.push(u);
    for (int i=0; i<A[u].size(); ++i){
        int v = A[u][i];
        if (num[v]){
            low[u] = min(low[u] , num[v]);
        }
        else{
            DFS(v);
            low[u] = min(low[u] , low[v]);
        }
    }

    if (low[u] == num[u]){
        res++;
        int v = Q.top();
        Q.pop();
        num[v] = low[v] = INF;
        F[v] = res;
        while (v != u){
            v = Q.top();
            Q.pop();
            num[v] = low[v] = INF;
            F[v] = res;
        }
    }
}

void        solve(){
    cin>>N>>M;
    int u, v;
    for (int i=1; i<=M; ++i){
        cin>>u>>v;
        A[u].push_back(v);
    }

    for (int i=1; i<=N; ++i){
        if (num[i] == 0)    DFS(i);
    }

    int T;
    cin>>T;
    while (T--){
        cin>>u>>v;
        if (F[u] == F[v])   cout<<1<<"\n";
        else    cout<<0<<"\n";
    }
}

#undef  int
int         main(){
#define int     long long
    solve();
    return 0;
}



Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int a=s.length();
    if(a>n)
    {
        for(int i=0;i<n;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    else
        cout<<s<<endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	priority_queue<int> q;
	rep(i, n) q.push(a[i]);
	int mx = q.top();
	q.pop();
	int mx2 = q.top();

	rep(i, n) {
		if (a[i] == mx) cout << mx2 << endl;
		else cout << mx << endl;
	}

}

Measured memory_bytes: 3316
N,C,K = map(int,input().split())
lisT = [int(input()) for _ in range(N)]

lisT.sort()
teiin = C
limit = K
timeup = 0
passengers = C
buscnt = 0
for i in range(N):
    if lisT[i] > timeup or passengers==0:
        timeup = lisT[i] + K
        passengers = C
        buscnt += 1
        passengers -= 1
    else:
        passengers -= 1

print(buscnt)





Measured memory_bytes: 7484
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100005]={0};
int main(void)
{
	int i,n,first=0,second=-1;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;++i)
	{
		if(a[i]==a[i-1])
		{
			if(a[i]>first)
			{
				second=first;
				first=a[i];
				++i;
			}
			else if(a[i]>second)second=a[i],++i;
		}
	}
	printf("%lld\n",1LL*first*second);
	return 0;
}


Measured memory_bytes: 640
import java.math.BigDecimal
import java.math.RoundingMode
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val p = (0 until n).map { sc.next().toLong() }
    println(problem153d(n, k, p))
}

fun problem153d(n: Int, k: Int, p: List<Long>): String {
    fun computeFactorial(n: Long): Long {
        var sum = 0L
        for (i in 1..n) {
            sum += i
        }
        return sum
    }
    val list = Array(n + 1) { BigDecimal(0) }
    for (i in 0 until n) {
        val pi = p[i]
        list[i + 1] = list[i].add(BigDecimal(computeFactorial(pi)).divide(BigDecimal(pi), 8, RoundingMode.DOWN))
    }
    var res = BigDecimal(0)
    for (i in 0..n - k) {
        val v = list[k + i] - list[i]
        if (res < v) res = v
    }
    return res.toString()
}

Measured memory_bytes: 90596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    string s1, s2;
    s1 = to_string(a);
    s2 = to_string(b);
    s1 += s2;
    b = stoi(s1);
    int ans = sqrt(b);
    if(ans * ans == b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;    
    return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string a;
  cin >> a;
  string ans="No";
  if('a'+'b'+'c'==a[0]+a[1]+a[2])
    ans="Yes";
  pri(ans);

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ull> vull;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;


#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORDOWN(i, a, b) for(int i = a; i >= b; --i)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
//mt19937 rnd(150);



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

    //  freopen("goat5.in", "r", stdin);
    //  freopen("goat5.out","w", stdout);

    int d,t,s;
    cin>> d >> t >> s;

    if (s* t >= d)
        cout << "Yes";
    else
        cout << "No";




    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int a[1000], n, i, j, k, v;
  scanf("%d", &n);
  for(k = 0; k < n; k++)
    {
      scanf("%d",&a[k]);
    }
  for(k = 0; k < n-1; k++)
    {
      printf("%d ",a[k]);
    }
  printf("%d\n", a[n-1]);
  for(i = 1; i < n; i++)
    {
      v = a[i];
      j = i - 1;
      while (j >= 0 && a[j] > v)
	{
	  a[j+1] = a[j];
	  j--;
	  a[j+1] = v;
	}
      for(k = 0; k < n-1; k++)
	{
	  printf("%d ",a[k]);
	}
      printf("%d\n", a[n-1]);
    }
  return 0;
}



Measured memory_bytes: 2136
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        

        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            var vals = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToList();
            var N = vals[0];
            var A= Console.ReadLine().Split(' ').
                Select(x => -long.Parse(x)).ToList();
            A.Sort();
            var ans = A.Take((N +1)/ 2).Sum(x => -2 * x);
            ans += A[0];
            if (N % 2 == 1)
            {
                ans += A[N / 2];
            }



            Console.WriteLine(ans);
            Console.Out.Flush();
        }
        　




    }
}




Measured memory_bytes: 47872
#include<stdio.h>
int main(void)
{
  int i=0,j;
  char str,ch[20];

  while(scanf("%c",&str)!=EOF)
    {
      ch[i]=str;
      i++;
    }

  for(j=i-2;j>=0;j--)
    {
      printf("%c",ch[j]);
    }
  printf("\n");
  return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;
    if(s.back() == 's'){
        s += "es";
    } else {
        s += 's';
    }
    cout << s << '\n';
    return 0; 
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,cur;
    cin >> a >> b;
    cur=b+b;
    if(a>cur){
        cout << a-cur << endl;
    }
    else if(a<=cur){
        cout << 0 << endl;
    }
    else{
        cout << "error!" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll m;

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

  vector<ll> a(m);
  
  REP(i,m){
    cin >>a[i];
  }
  VSORT(a);

  cout <<a.back()-a[0]<<endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
    ::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
    for (::std::int64_t i = 2; i*i <= x; ++i) {
        if (x % i == 0) {
            res.emplace_back(i, 1);
            x /= i;
            while (x % i == 0) x /= i, res.back().second++;
        }
    }
    if (x != 1) res.emplace_back(x, 1);
    return res;
}


int main(void) {
    int64 A, B;
    cin >> A >> B;
    auto rA = primeFactors(A), rB = primeFactors(B);
    map<int64, int64> mp;
    REP(i, rA.size()) {
        mp[rA[i].fs]++;
    }
    REP(i, rB.size()) {
        mp[rB[i].fs]++;
    }
    int64 res = 0;
    for (auto &x : mp) {
        if (x.sc == 2) res++;
    }
    cout << res+1 << endl;
}


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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 200005
int n;
int fr[MN],nex[MN],vi[MN],tot=0;
int d[MN];
int a[MN];
void add(int x,int y){
	nex[++tot]=fr[x];fr[x]=tot;vi[tot]=y;
}
void dfs(int x,int fa){
	int t=0;
	for(int i=fr[x];i;i=nex[i])if(vi[i]!=fa){
		dfs(vi[i],x);if(!a[vi[i]])++t;a[x]+=a[vi[i]];
	}a[x]+=max(0,t-1);
}
int main(){
	read(n);
	for(int i=1,x,y;i<n;++i){
		read(x);read(y);++x;++y;add(x,y);add(y,x);++d[x];++d[y];
	}
	int rt=1;
	for(int i=2;i<=n;++i)if(d[i]>d[rt])rt=i;
	dfs(rt,0);
	if(n==2)++a[rt];
	cout<<a[rt];
	return 0;
}


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

bool check(long long a[],long long b[],long long x,long long n,long long k)
{
    for(int i=0; i<n; i++)
    {
        if(a[i]*b[i]>x)
            k-=(a[i]-(x/b[i]));
    }
    if(k<0) return 0;
    else return 1;
}

int main()
{
    long long n,k;
    cin>>n>>k;
    long long a[n],b[n],ans=0;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        cin>>b[i];
    sort(a,a+n);
    sort(b,b+n,greater<long long>());
    long long lo=0,hi=1e18,mid;
    while(lo<hi)
    {
        mid=(lo+hi)/2;
        if(check(a,b,mid,n,k)) hi=mid;
        else lo=mid+1;
    }
    cout<<lo<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 100010;

ll a[N];

int main() {
	int n;
	scanf("%d", &n);
	ll ans = 1;
	for(int i=1; i<=n; i++) {
		scanf("%lld", &a[i]);
		if(a[i]==0) {
			printf("0\n");
			return 0;
		}
	}
	for(int i=1; i<=n; i++) {
		if(ans<=(ll)(1e18)/a[i])
			ans *= a[i];
		else {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4488
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.size();
	if(n<=k){
		cout<<s<<endl;
	}else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     pii             pair<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)     (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int x,y;
    cin>>x>>y;

    int n,m,l;
    cin>>n>>m>>l;

    vector<int> a(n);
    for(auto& z:a)
        cin>>z;

    vector<int> b(m);
    for(auto& z:b)
        cin>>z;

    vector<int> c(l);
    for(auto& z:c)
        cin>>z;

    sort(all(a));
    reverse(all(a));
    sort(all(b));
    reverse(all(b));
    sort(all(c));
    reverse(all(c));

    int orx=x,ory=y;
    --x,--y;
    for(auto& z:c)
    {

        if(x>=0 && y>=0 && z>a[x] && z>b[y])
        {
            if(a[x]>b[y])
            {
               b[y]=z;
               --y;
            }
            else
            {
                a[x]=z;
                --x;
            }
        }
        else if(x>=0 && z>a[x])
        {
            a[x]=z;
            --x;
        }
        else if(y>=0 && z>b[y])
        {
            b[y]=z;
            --y;
        }
        else
            break;
    }

    //show(a);
    //show(b);
    //show(c);

    //cout<<x<<" "<<y<<"\n";

    int ans=accumulate(a.begin(),a.begin()+orx,0ll)+accumulate(b.begin(),b.begin()+ory,0ll);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 2560
import java.util.Scanner;



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

}

Measured memory_bytes: 26068
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			String[] s=sc.nextLine().split(",");
			double[] x=new double[4];
			double[] y=new double[4];
			for(int i=0; i<4; i++){
				x[i]=Double.parseDouble(s[i*2]);
				y[i]=Double.parseDouble(s[i*2+1]);
			}
			boolean f=true;
			int[] signs=new int[4];
			for(int k=0; k<4; k++){
				int i=(k+1)%4;
				int j=(k+3)%4;
				double vx1=x[i]-x[k];
				double vy1=y[i]-y[k];
				double vx2=x[j]-x[k];
				double vy2=y[j]-y[k];
				double det=vx1*vy2-vy1*vx2;
				if(det<-EPS){
					signs[i]=-1;
//					f=false;
//					break;
				}else
					signs[i]=1;
			}
			for(int i=0;i<3;i++)
				if(signs[i]!=signs[i+1]){
					f=false;
					break;
				}

			println(f?"YES":"NO");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    double a,b,n,ans=0,k;
    scanf("%lf %lf %lf",&a,&b,&n);

    if(n>=b)
    {
        b=(b-1)/b;
    }
    else
    {
        b=n/b;
    }
    

    ans=a*b;
    ans=floor(ans);

    printf("%.0f\n",ans);

    return 0;
}

Measured memory_bytes: 1740