akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int a = scanner.nextInt() - 1;
        int b = scanner.nextInt() - 1;
        int c = scanner.nextInt() - 1;
        int d = scanner.nextInt() - 1;
        char[] s = scanner.next().toCharArray();

        boolean valid = true;
        for (int i = b + 1; valid && i < d; ++i)
            if (s[i] == '#' && s[i - 1] == '#')
                valid = false;
        if (d < c) {
            boolean find = false;
            for (int i = b; valid && i <= Math.min(n - 2, d); ++i)
                if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.')
                    find = true;
            valid = find;
        }
        for (int i = a + 1; valid && i < c; ++i)
            if (s[i] == '#' && s[i - 1] == '#')
                valid = false;
        writer.println(valid ? "Yes" : "No");
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 26068
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
ll ans  = 1;
ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}

int main(){

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

    cin >> N;
    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
    }
    sort(A.begin(),A.end());

    ll ni   = 0;
    while(ni<N){
        ll Amax = base10_9;
        Amax = Amax * base10_9 / ans;
        if(A[ni]==0){
            ans = 0;
            break;
        }
        if(Amax < A[ni]){
            ans = -1;
            break;
        }
        ans *= A[ni];

        ni++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 4272
//ITP1 - 2 - E
#include<stdio.h>
int main() {
	int i = 0, j, x[10000];

	while (10000) {
		scanf("%d", &x[i]);

		if (x[i] == 0) {
			break;
		}
		i++;
	}
	for (j = 1; j <= i; j++) {
		printf("Case %d: %d\n", j, x[j-1]);
	}

	return 0;
}

Measured memory_bytes: 636
#include <iostream>
using namespace std;
int main(){
  int n,b,f,r,v;
  cin>>n;
  int array[4][3][10]={0};
  for(;n>0;n--){
     cin>>b>>f>>r>>v;
     if(v>=0){
       array[b-1][f-1][r-1]+=v;
     }else if(v<0){
       array[b-1][f-1][r-1]-=v*(-1);
     }
  }
  for(b=0;b<=3;b++){
    for(f=0;f<=2;f++){
      for(r=0;r<=9;r++){
	cout<<" "<<array[b][f][r];
      }
	cout<<endl;
    }
    if(b!=3){
      cout<<"####################"<<endl;
    }
  }
  return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int h[3], s[3]; cin >> h[1] >> s[1] >> h[2] >> s[2];
	string ans;

	int turn = 1;

	while (true)
	{
		if (h[turn] <= 0)
		{
			if (turn == 1)
				ans = "No";
			else
				ans = "Yes";
			break;
		}

		h[3 - turn] -= s[turn];
		turn = 3 - turn;
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3660
while True:
  m, f, r = map(int, input().split())
  if m == -1 and f == -1 and r == -1:
    break
  elif m == -1 or f == -1:
    print("F")
  elif m + f >= 80:
    print("A")
  elif m + f >= 65:
    print("B")
  elif m + f >= 50:
    print("C")
  elif m + f >= 30:
    if r >= 50:
      print("C")
    else:
      print("D")
  else:
    print("F")


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

int main()
{
  int n,t,count = 0;
  cin >> n;
  vector<int> p;
  for(int i=0; i<n; i++){
    cin >> t;
    p.push_back(t);
  }
  t=p[0];
  for(int i=0; i<n; i++){
    if(t >= p[i]){
      count++;
      t=p[i];
    }
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=3e3+10;
int n,T;
typedef pair<int,int> pii;
pii a[maxn];
int dp[maxn],mx[maxn];
int main(){
    //ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    scanf("%d%d",&n,&T);
    int ans=0;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i].fi,&a[i].se);
        ans=max(ans,a[i].se);
    }
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--) mx[i]=max(mx[i+1],a[i].se);
    for(int i=1;i<=n;i++){
        for(int j=T;j>=a[i].fi;j--){
            if(dp[j-a[i].fi]+a[i].se>dp[j]){
                dp[j]=dp[j-a[i].fi]+a[i].se;
                if(j<T) ans=max(ans,dp[j]+mx[i+1]);
            }else if(j<T) ans=max(ans,dp[j]+mx[i]);
            ans=max(ans,dp[j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*7 30
7 30
8 20
9 10
10 5
1000 1
1000 1
1000 1*/

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let mut a: [i32; 3] = [read(), read(), read()];
    a.sort();
    println!("{}", a[0] + a[1]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, m;
	scanf("%d%d", &n, &m);
	int left = 1, right = n;
	while (m--) {
		int l, r;
		scanf("%d%d", &l, &r);
		left = max(left, l);
		right = min(right, r);
	}
	printf("%d\n", max(0, right - left + 1));
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var s = next(1);
  return s === "AAA" || s === "BBB" ? "No" : "Yes";
}

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


int main(){
    string s;
    cin>>s;
    rep(i,0,3)cout<<s[i];
    cout<<endl;
}

    









Measured memory_bytes: 3620
//ITP1-10-A: Distance
//2019.05.20

#include <stdio.h>
#include <math.h>

int main(void){
  double x1, y1, x2, y2;
  double distance;

  scanf("%lf %lf %lf %lf\n", &x1, &y1, &x2, &y2);

  distance = sqrt(pow(x2-x1, 2) + pow(y2-y1, 2));

  printf("%lf\n", distance);

  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(8) << w*h/2 << " ";
    if(w/2 == x && h/2 == y) cout << 1 << endl;
    else cout << 0 << endl;
}

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

using namespace std;

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

    int a = -1, b = -1, n = s.size();
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            a = i + 1;
            b = i + 2;
            goto out;
        }
    }

    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i + 2] == s[i]) {
            a = i + 1;
            b = i + 3;
            goto out;
        }
    }

out:
    cout << a << " " << b << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n[5];
	int i, j;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &n[i]);
	}
	for (i = 0; i < 5; i++){
		for (j = 0; j < i; j++){
			if (n[j] < n[i]){
				int tmp;
				tmp = n[j];
				n[j] = n[i];
				n[i] = tmp;
			}
		}
	}
	for (i = 0; i < 4; i++){
		printf("%d ", n[i]);
	}
	printf("%d\n", n[4]);
	
	return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n,m;
    cin>>n>>m;
    vll a(n),b(n),c(m),d(m);
    rep(i,0,n)cin>>a[i]>>b[i];
    rep(i,0,m)cin>>c[i]>>d[i];
    rep(i,0,n){
        ll res=INF;
        int ind=-1;
        rep(j,0,m){
            if(res>abs(a[i]-c[j])+abs(b[i]-d[j])){
                res=abs(a[i]-c[j])+abs(b[i]-d[j]);
                ind=j+1;
            };
        }
        cout<<ind<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
import sys


def solve():
    M, D = input().split()
    ans = 0
    
    if int(D) < 22:
        print(0)
        sys.exit()
    
    m, d_1, d_2 = int(M), int(D[0]), int(D[1])

    if int(M) < 4 or d_1 < 2 and d_2 < 2:
        print(0)
        sys.exit()

    for i in range(4, m+1):
        for j in range(2, d_1+1):
            for k in range(2, 10):
                if j == d_1 and k > d_2:
                    break
                if i == j * k:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

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


int main() {
    int a,b,c,k;cin>>a>>b>>c>>k;
    int sum = a+b+c;
    int cap = max(a, max(b,c));
    sum -= cap;
    rep(i,k)cap *= 2;
    
    cout << sum + cap << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

int main()
{
 int a,b;
 cin>>a>>b;
 cout<<(a+b+1)/2<<endl;
}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

typedef long long ll;

int main()
{
    ll x, y;
    cin >> x >> y;

    int ans = 0;
    ll i = y / x;
    while (i >= 1)
    {
        ans++;
        i /= 2;
    }

    cout << ans << endl;

    return 0;
}

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

int n, m;
bool f[1010];

int main() {
  int ans = 0;

  cin >> n;

  memset(f, true, sizeof(f));

  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    f[a] = false;
  }

  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    f[a] = true;
  }

  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    if (f[a]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int N; ll K;
  	cin>>N>>K;
  	vector<int> a(N);
  	rep(i,N) cin>>a[i];
  
  	vector<int> s;
  	vector<int> ord(N+1,-1);
  	int c=1, l=0;
  {
    int v=1;
    while(ord[v]==-1){
     	ord[v]=s.size();
      	s.push_back(v);
      	v=a[v-1];
    }
    c=s.size()-ord[v];
    l=ord[v];
  }
  	if(K<l) cout<<s[K]<<endl;
  	else{
     	K-=l;
      	K%=c;
      	cout<<s[l+K]<<endl;
    }
    
   
  	
}

Measured memory_bytes: 5788
#include <iostream>
using namespace std;
int main(void){
    string s;
    int cnt=0,ans=0,i;
    cin >> s;
    for(i=0;i<s.size();i++){
        if(s[i]=='A' or s[i]=='C' or s[i]=='T' or s[i]=='G') cnt++;
        else{
            ans = max(ans,cnt);
            cnt=0;
        }
    }
    ans = max(ans,cnt);
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root, *NIL;

struct Node * find(struct Node *u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[8],in[]="insert",pri[]="print";

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,in)==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,pri)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

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

int main(){
	
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(arr[2]-arr[1]);
	
	for(int i=3;i<=n;i++){
		dp[i] = min(dp[i-1]+ abs(arr[i]-arr[i-1]) , dp[i-2]+ abs(arr[i]-arr[i-2]));
	
	}

	cout<<dp[n]<<endl;
	return 0;
}

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

int main(){
    long double a,b,h,m;
    cin>>a>>b>>h>>m;

    long double x,y,theta,ans;
    x=h*30.00000000000000000000000+m*0.50000000000000000000000000;
    y=6*m;
    theta=abs(x-y);
    if(theta>=180){
        theta=360-theta;
    }
    ans=sqrt(a*a+b*b-2*a*b*cosl(3.14159265358979*theta/180));
    cout<<setprecision(20)<<ans<<endl;
    

    
}

Measured memory_bytes: 4156
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;

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

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll gcdv = gcd(a, b);
    auto f = factorize(gcdv);
    cout << f.size() + 1;
    return 0;
}


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

int main()
{
    int n,x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a,a+n);

    int ans = 0;
    for(int i = 0; i < n; i++){
        x -= a[i];
        if(x <= 0 || i == n - 1){
            cout << (x == 0 ? i + 1 : i) << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
DAMS = gets.split.map(&:to_i)

def mountains(first_mountain)
  mountains = [first_mountain]
  (1...N).each do |i|
    next_mountain = (DAMS[i - 1] - mountains.last / 2) * 2
    mountains << next_mountain
  end
  mountains
end

from = (0..DAMS[0] * 2).bsearch { |first_mountain|
  mountains = mountains(first_mountain)
  (mountains.first + mountains.last) / 2 >= DAMS.last
}

puts mountains(from).join(" ")


Measured memory_bytes: 22020
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private int N;
  private int K;
 
  private long count;
 
  private void solve(Scanner sc, PrintWriter out) {
    N = sc.nextInt();
    K = sc.nextInt();
 
    count = K;
    for (int i = 1; i < N; ++i) {
      count *= K - 1;
    }
 
    out.println(count);
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 25044
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    N=[]
    for _ in range(3):
        a,b=map(int,input().split())
        N.append(a)
        N.append(b)
    N=Counter(N)
    NN=N.most_common(1)
    if NN[0][1]==3:
        print("NO")
    else:
        print("YES")


if __name__=='__main__':
    main()

Measured memory_bytes: 38512
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;

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

   vector<ll> A(N), B(N), C(N);

   rep(i, 0, N) cin >> A.at(i);
   rep(i, 0, N) cin >> B.at(i);
   rep(i, 0, N) cin >> C.at(i);

   sort(A.begin(), A.end());
   sort(B.begin(), B.end());
   sort(C.begin(), C.end());

   ll ans = 0;
   rep(i, 0, N) {
     ll a = lower_bound(A.begin(), A.end(), B.at(i)) - A.begin();
     ll c = upper_bound(C.begin(), C.end(), B.at(i)) - C.begin();
     ans += a * (N - c);
   }
   cout << ans << endl;
 }


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

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

    vector<ll> x(N, 0);
    rep (i, N) {
        if (i%2) {
            x[0] -= A[i];
        } else {
            x[0] += A[i];
        }
    }
    
    rep (i, N-1) {
        x[i+1] = 2*A[i]-x[i];
    }

    rep (i, N) {
        cout << x[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    if(x < y){
    	int tmp = x;
    	x = y;
    	y = tmp;
    }

    while(x % y != 0){
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    }
	System.out.println(y);
    
  }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,W;
vint lis[4];
signed main(){
    cin>>N>>W;

    int w,v;cin>>w>>v;
    lis[0].pb(v);
    for(int i=1;i<N;i++){
        int x,y;
        cin>>x>>y;
        lis[x-w].pb(y);
    }

    rep(i,4)sort(all(lis[i]));
    rep(i,4)reverse(all(lis[i]));
    rep(i,4)lis[i].insert(lis[i].begin(),0);
    rep(i,4){
        for(int j=0;j+1<lis[i].size();j++)lis[i][j+1]+=lis[i][j];
    }

    int ans=0;
    for(int i=0;i<lis[0].size();i++){
        for(int j=0;j<lis[1].size();j++){
            for(int k=0;k<lis[2].size();k++){
                for(int l=0;l<lis[3].size();l++){
                    if(w*i+(w+1)*j+(w+2)*k+(w+3)*l>W)continue;
                    chmax(ans,lis[0][i]+lis[1][j]+lis[2][k]+lis[3][l]);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
lst_A = list(map(int, input().split()))
lst_A.sort(reverse=True)
cur_a = -1
lst_ans = []


for i, a in enumerate(lst_A):
    if cur_a == a:
        lst_ans.append(a)
        cur_a = -1
        if len(lst_ans) == 2:
            break
    else:
        cur_a = a


ans = lst_ans[0] * lst_ans[1] if len(lst_ans) else 0
print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int r,g,b;
  cin>>r>>g>>b;
  int n = g*10+b;
  puts(n%4==0 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int x,h;
	for(;scanf("%d%d",&x,&h)&&(x||h);){
		printf("%lf\n",x*x+sqrt(pow(x/2.0,2)+pow(h,2))*(2.0*x));
	}
	return 0;
}

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

typedef long long ll;
const int MAXN = 100010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int st[MAXN], to[MAXN<<1];
int nxt[MAXN<<1], e;
inline void Add(int u, int v) {
	to[++e] = v, nxt[e] = st[u];
	st[u] = e;
}

int n, a[MAXN];
int deg[MAXN], r;
ll val[MAXN];

void dfs(int u, int fa) {
	int i;
	if(deg[u] == 1) {
		val[u] = a[u];
		return;
	}
	for(i = st[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v == fa) continue;
		dfs(v, u);
	}
	ll S = 0, K = 0;
	for(i = st[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v == fa) continue;
		S += val[v];
		K = max(K, val[v]);
		//val[u] -= val[v];
	}
	val[u] = a[u]*2-S;
	if(val[u] < 0 || S-a[u] < 0) {
		printf("NO\n");
		exit(0);
	}
	if(a[u] < K) {
		printf("NO\n");
		exit(0);
	}
}

int main() {
	int i;

	n = read();

	for(i = 1; i <= n; i++) a[i] = read();
	for(i = 1; i < n; i++) {
		int u = read(), v = read();
		Add(u, v), Add(v, u);
		deg[u]++, deg[v]++;
	}
	//for(i = 1; i <= n; i++) printf("%d ", deg[i]);
	if(n == 2) {
		if(a[1] == a[2]) printf("YES\n");
		else printf("NO\n");
		return 0;
	}

	for(r = 1; r <= n; r++) 
		if(deg[r] != 1) break;

	dfs(r, 0);
	/*printf("%d\n", r);
	for(i = 1; i <= n; i++) printf("%lld ", val[i]);
	printf("\n");*/
	if(val[r] == 0) {
		printf("YES\n");
	}
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,a[N];

int main(){
    string s;
    cin >>n >>n >>s;
    if(s[n-1] >= 'A' and s[n-1] <= 'Z') s[n-1] = 'a' + s[n-1] - 'A';
    cout <<s;
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 256
n, x = map(int,input().split())
li = list(input().split())
li = [abs(int(a)-x) for a in li]

def gcd(a,b):
    while a%b!=0:
        a,b = b,a%b
    return b
    
if n == 1:
    print(abs(li[0]))
    
elif n == 2:
    print(gcd(li[0],li[1]))
    
elif n >= 3:

    c = gcd(li[0],li[1])
    #print(c)
    for i in range(2,len(li)-1):
        c = gcd(c,li[i])
    print(c)

Measured memory_bytes: 14956
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}

ll comb(ll n, ll k)
{
    ll ans = 1;
    ll i;

    rep(i, 0, k)
    {
        ans *= n - i;
        ans %= MOD;
        ans *= power(i + 1, MOD - 2);
        ans %= MOD;
    }

    return ans;
}

int main(void)
{
    ll n, a, b;
    ll ans = 0;

    cin >> n >> a >> b;

    ans = power(2, n);

    ans = (ans - comb(n, a) - comb(n, b) - 1 + MOD * 3) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int f=0;
  while(n>0)
  {
    if(n%10==7)
      f=1;
    n/=10;

  }
  if(f==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

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

struct Rectangle {
    int h;
    int w;
    int d;

    Rectangle() : Rectangle(0,0) {}
    Rectangle(int h, int w) 
        : h(h), w(w), d(0) {
            calculate_distance();
        }
    Rectangle(Rectangle const &other) {
        this->h = other.h;
        this->w = other.w;
        this->d = other.d;
    }

    Rectangle &operator=(Rectangle const &rhs) {
        this->h = rhs.h;
        this->w = rhs.w;
        this->d = rhs.d;
        return *this;
    }

    void calculate_distance() {
        this->d = h*h + w*w;
    }
    bool is_larger_than(Rectangle &other) {
        this->calculate_distance();
        other.calculate_distance();
        if (this->d == other.d) {
            return this->h > other.h;
        }
        return this->d > other.d;
    }
};

int main(void)
{
    int h, w;
    while (std::cin >> h >> w, h) {
        Rectangle base(h,w);

        Rectangle curr;
        Rectangle min(h+2, w+2);

        int mh = std::max(base.h, base.w);
        for (curr.h = 1; curr.h <= mh; curr.h++) {
            int mw = sqrt(base.d - curr.h*curr.h) + 1;
            for (curr.w = curr.h+1; curr.w <= mw; curr.w++) {
                if (curr.is_larger_than(base) && min.is_larger_than(curr)) {
                    min = curr;
                    break;
                }
            }
        }

        std::cout << min.h << " " << min.w << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2964
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

n = int(rl())
a = list(map(int, rl().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    else:
        print(ans)

Measured memory_bytes: 40152
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

namespace math_helper
{
	template<typename value_type>
	map<value_type, int> factorization(value_type num)
	{
		map<value_type, int> factor_map;

		for (value_type factor_num = 2; factor_num * factor_num <= num; factor_num++)
		{
			if (factor_num > num) break;
			if (num % factor_num != 0) continue;

			while (num % factor_num == 0)
			{
				num /= factor_num;
				factor_map[factor_num]++;
			}
		}

		if (num != 1) factor_map[num]++;

		return factor_map;
	}
}

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

	long long N;
	cin >> N;

	int result = 0;

	map<long long, int> factor_map = math_helper::factorization<long long>(N);
	for (pair<long long, int> e : factor_map)
	{
		int cnt = 0;
		int value = 0;
		for (int i = 1; i <= e.second; i++)
		{
			value += i;
			if (value > e.second)
			{
				break;
			}

			cnt++;
		}

		result += cnt;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

const ll MOD = 998244353;

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// from https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae

const ll MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void init() {
  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;

  }
}

// n!! * k!^(-1) * ((n - k)!)^(-1)
ll comb(ll n, ll k) {
  if (n < k) return 1;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k]* finv[n - k] % MOD) % MOD;
}

ll hcomb(ll n,ll k){
	if(n==0 && k==0) return 1;
	return comb(n+k-1,k);
}

int main() {
  ll n, a, b, k;
  cin >> n >> a >> b >> k;
  init();

  ll ans = 0;
  for (ll i = 0; i <= n; ++i) {
    ll remain = k - a * i;
    if (remain % b != 0) continue;
    ll j = remain / b;
    if (j > n) continue;
    ll tmp = comb(n, i) * comb(n, j) % MOD;
    ans += tmp;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12160
#include "bits/stdc++.h"

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

using namespace std;

    int N, V;
    long long W, w[110], v[110];
    long long dp[110][100010], ans;

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

    cin >> N >> W;

    V = 0;
    for (int i = 1; i < N+1; i++)
    {
        cin >> w[i] >> v[i];
        V += v[i];
    }
    
    for (int i = 0; i <= N; i++)
    {
        for (int sum_v = 1; sum_v <= V; sum_v++)
        {
            dp[i][sum_v] = 1000000010;
        }
        
    }

    for (int i = 0; i < N; i++)
    {
        for (int sum_v = 0; sum_v <= V; sum_v++)
        {
            if(sum_v - v[i+1] >= 0){
                chmin(dp[i+1][sum_v], dp[i][sum_v - v[i+1]] + w[i+1]);
            }
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
        
    }
    
    ans = 0;

    for (int sum_v = 0; sum_v <= V; sum_v++)
    {
        if(dp[N][sum_v] <= W){
            ans = sum_v;
        }
    }
    
    cout << ans << "\n";



}


Measured memory_bytes: 80128
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    string str;
    cin>>str;
    int s;
    cin>>s;
    for(int i=0;i<s;i++)
    {
        string text;
        cin>>text;
        if(text=="print")
        {
            int a,b;
            cin>>a>>b;
            for(int t=a;t<=b;t++)
            {
                cout<<str[t];
            }
            cout<<endl;
        }
        else if(text=="reverse")
        {
            int a,b;
            cin>>a>>b;
            string str1;
            str1=str;
            for(int u=0;u<b-a+1;u++){
                str1[a+u]=str[b-u];
                
            }
            str=str1;
            
        }
        else if(text=="replace")
        {
            int a,b;
            cin>>a>>b;
            string p;
            cin>>p;
            for(int v=0;v<b-a+1;v++){
                str[a+v]=p[v];
            }
            
        }
        else continue;
    }
    return 0;
}


Measured memory_bytes: 3192
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		sc.nextLine();
		String sort = "";
		String[] anagram = new String[N];
		long count = 0;
		//文字列一つずつ並び替え
		for(int i = 0; i<N ; i++) {
			sort = sc.nextLine();
			String[] change = sort.split("");
			Arrays.sort(change);
			anagram[i] = String.join("",change);
		}
		//HashMapに一つずつ判定して入れる。重複があればカウント。
		HashMap<String,Long> checklist = new HashMap<>();
		for(int i = 0; i<N; i++) {
			if(checklist.containsKey(anagram[i])) {
				long value = checklist.get(anagram[i]);
				count+=value;
				checklist.put(anagram[i], value+1);
			}else {
				checklist.put(anagram[i],(long)1);
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 159568
antennas = [int(input()) for _ in range(5)]
k = int(input())

flag = True

for i in range(4):
    for j in range(i + 1, 5):
        if antennas[j] - antennas[i] > k:
            flag = False
            break

if flag:
    print('Yay!')
else:
    print(':(')

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

#define LL long long
#define pii pair<LL, LL>
#define mp make_pair

LL N, X, D, ans;

map<LL, vector<pii>> f;

int main()
{
	scanf("%lld %lld %lld", &N, &X, &D);
	if(D == 0)
	{
		if(X) printf("%lld", N + 1);
		else puts("1");
		return 0;
	}
	if(D < 0) X = -X, D = -D;

	for(int k = 0; k <= N; k++)
	{
		LL R = 1ll * k * X % D;
		LL l = 1ll * k * (k - 1) / 2 + 1ll * k * X / D, r = 1ll * (N - k + N - 1) * k / 2 + 1ll * k * X / D;
		if(l > r) swap(l, r);
		f[R].push_back( mp(l, r) );
	}

	for(map<LL, vector<pii>>::iterator it = f.begin(); it != f.end(); it ++)
	{
		vector<pii> num = it -> second;
		sort(num.begin(), num.end());
		LL last = -1e18;
		for(int i = 0; i < num.size(); i++)
		{
			LL l = max(last, num[i].first), r = num[i].second;
			if(l > r) continue;
			ans += r - l + 1;
			last = max(last, num[i].second + 1);
		}
	}

	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 22144
n=int(input())
dic={}
mx=0
al=[]
for i in range(n):
    a=int(input())
    al.append(a)

order=sorted(al,reverse=True)
mx1=order[0]
mx2=order[1]

for a in al:
    if a==mx1:
        print(mx2)
    else:
        print(mx1)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;


void yes(){
   cout<<"Yes";
   // exit(0);
}

void no(){
   cout<<"No";
   // exit(0);
}


int n, m;
string s, t;

int32_t main(){_
   
   cin >> s;

   int sum = 0;
   for(auto it: s){
      sum += it - '0';
      sum %= 9;
   }

   if (!sum){
      yes();
   }
   else{
      no();
   }


   return 0;
}

Measured memory_bytes: 3764
package main

import (
        "fmt"
)

func solution(s string) int {
        l := len(s)
        out := 0
        for i := 0; i <= l; i++ {
                for j := i + 1; j <= l; j++ {
                        t := s[i:j]
                        if isACGT(t) {
                                out = max(out, len(t))
                        }
                }
        }
        return out
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func isACGT(s string) bool {
        for _, r := range s {
                if r == 'A' || r == 'C' || r == 'G' || r == 'T' {
                        continue
                } else {
                        return false
                }
        }
        return true
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;   
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    int ans = 1;
    REP(i, 3){
        ans *= N;
    }
    pr(ans);
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int arr[] = new int[n];
		for(int i = 0;i < n; ++i){
			arr[i] = sc.nextInt();
		}
		long max_now = arr[0];
		int ans = 1;
		for(int i = 1;i < n; ++i){
			if(arr[i] <= max_now){
				ans++;
			}
			max_now = Math.min(max_now,arr[i]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 64952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
using pll = pair<long,long>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  ll n; cin>>n;
  int res=100;
  for(ll i=1;i*i<=n;i++) {
    if(n%i==0) res=min(res,(int)to_string(n/i).size());
  }
  cout<<res<<endl;
}


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

int m,n;
bool used[20];
vector<int> edge[20];

void solve(int h){
  if(used[h]) return;
  used[h] = true;
  for(int i=0;i<edge[h].size();i++){
    solve(edge[h][i]);
  }
  cout << h+1 << endl;
}

int main(){
  cin >> m >> n;
  for(int i=0;i<n;i++){
    int x,y; cin >> x >> y;
    x--; y--;
    edge[y].push_back(x);
  }
  memset(used,false,sizeof(used));
  for(int i=0;i<m;i++) solve(i);
}

Measured memory_bytes: 1216
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def solve(R, C, K, RCV):
    # dp[y][x][n]
    M = np.zeros((R+1, C+1), dtype=np.int64)
    for i in range(K):
        r, c, v = RCV[i]
        M[r, c] = v
    dp = np.zeros((R+1, C+1, 4), dtype=np.int64)
    for y in range(1, R+1):
        for x in range(1, C+1):
            for n in range(4):
                if n == 0:
                    dp[y, x, n] = max(
                        dp[y, x-1, 0],
                        dp[y-1, x, :].max()
                    )
                if n > 0:
                    dp[y, x, n] = max(
                        dp[y, x-1, n],
                        dp[y, x-1, n-1] + M[y, x],
                        dp[y-1, x, :].max() + M[y, x]
                    )
    ans = dp[R, C].max()
    print(ans)

numba_compile([
    [solve, "(i8,i8,i8,i8[:,:])"],
])

import sys
def main():
    R, C, K = map(int, input().split())
    RCV = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(K, 3)
    solve(R, C, K, RCV)

main()


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int k;
  cin >> k;
  sort(a, a + 3);
  for (int i = 1; i <= k; i++)
    a[2] *= 2;
  cout << a[0] + a[1] + a[2] << endl;
}

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

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    //cout << S;

    int half = S.size() / 2;
    bool repeat;
    if (half == 0) {
        repeat = false;
    }
    else {
        if ((S.size()%2) == 0) {
            repeat = true;
            for (int i=0; i<half; i++) {
                if (S[i] != S[i+half]) {
                    repeat = false;
                    break;
                }
            }
        }
        else {
            repeat = false;
        }
    }

    if (repeat == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256