akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> adj[n];
    for(int i = 0; i < m ; ++i){
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        adj[a].push_back(b);
        adj[b].push_back(a);    
    }

    vector<int> parent(n, -1);
    queue<pair<int,int>> q;
    q.push({0,0});
    int cnt = 0;
    while(!q.empty()){
        auto x = q.front();
        q.pop();
        if(parent[x.first] != -1) continue;
        cnt++;
        parent[x.first] = x.second;
        for(int v : adj[x.first]){
            if(parent[v] != -1) continue;
            q.push({v, x.first});
        }
    }
    if(cnt != n) printf("No\n");
    else{
        printf("Yes\n");
        for(int i = 1; i < n ; ++i){
            printf("%d\n", parent[i]+1);
        }
    }
    return 0;
}

Measured memory_bytes: 10804
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let (a, b, c) = read_parameters::<isize>()
        .map(|xs| (xs[0], xs[1], xs[2]))
        .unwrap();

    let mut count = 0;
    for i in a..(b + 1) {
        if c % i == 0 {
            count += 1;
        }
    }
    println!("{}", count);
}



Measured memory_bytes: 5036
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		bool flag=false;
		int minv=min(a,b),maxv=max(a,b);
		int max=minv*10;
		int size=maxv*15;
		for(int i=max;i<=size;i++){
			int x=i*0.08,y=i*0.1;
			if(x==minv&&y==maxv){
				flag=true;
				printf("%d\n",i);
				break;
			}
		}
		if(!flag) printf("-1\n");
	}
}




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

int tt[20][20];
int dp[20][20][20];
int W,H;

int rec(int x,int y,int px){
	if( x < 0 || x >= W ) return 0;
	if( tt[y][x] == 1 ) return 0;
	if( tt[y][x] == 2 && x != px ) return 0;
	
	if( y >= H-1 ) return 1;
	
	
	if( dp[x][y][px] != -1 ) return dp[x][y][px];
	int ans = 0;
	if( tt[y][x] == 2 ){
		ans += rec(x,y+2,x);
	}else{
		ans += rec(x,y+1,x);
		ans += rec(x+1,y+1,x);
		ans += rec(x-1,y+1,x);
	}
	return dp[x][y][px] = ans;
}

int main(){
	while(cin >> W >> H&&(W||H)){
		memset(dp,-1,sizeof(dp));
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++)
				cin >> tt[i][j];
		}
		int ans = 0;
		for(int i = 0 ; i < W ; i++){
			ans += rec(i,0,0);
		}
		cout << ans << endl;
		//return 0;
		
	}
}

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

#define rep(i, n) for (int i=0; i<n; ++i)

int main(void){
  int n, x;
  cin >> n >> x;
  
  int l;
  int ans = 1, s = 0;
  rep(i, n) {
    cin >> l;
    s += l;
    if (s <= x) ans++;
    else break;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int main(){
  int n,z,w; cin >> n >> z >> w;
  vi a(n); rep(i, n) cin >> a[i];

  int ans = abs(w-a[n-1]);
  if(n>1) ans = max(ans, abs(a[n-1] - a[n-2]));

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int max=sc.nextInt();
		long w[]=new long[n];
		long v[]=new long[n];
		for(int i=0;i<n;i++)
		{
			w[i]=sc.nextLong();
			v[i]=sc.nextLong();
		}
		long dp[][]=new long[n+1][max+1];
		for(int i=0;i<=n;i++)
		{
			Arrays.fill(dp[i], -1);
		}
		long ans=rec(w,v,n,0,max,dp);
		System.out.println(ans);
				
	}

	private static long rec(long[] w, long[] v, int n, int ind,int max, long[][] dp) {
		// TODO Auto-generated method stub
		if(ind==n||max<0)
		{
			return 0;
		}
		if(dp[ind][max]!=-1)
		{
			return dp[ind][max];
		}
		long ans=0;
		long opt1=rec(w,v,n,ind+1,max,dp);
		long opt2=0;
		if(w[ind]<=max)
		{
			opt2=v[ind]+rec(w,v,n,ind+1,max-(int)(w[ind]),dp);
		}
		ans=Math.max(opt1, opt2);
		 dp[ind][max]=ans;
		return ans;
	}
}


Measured memory_bytes: 141076
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  
  for(int i = 1; i <= 9; i++){
    if(i == a) count++;
    if(i == b) count++;
    if(i == c) count++;
    
    if(count == 2){
      cout << "Yes" << endl;
      return 0;
    }
    
    count = 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
using ll = long long;

int main () {
	ll N, K;
	cin >> N >> K;
	bool ans = false;
	if (N % 2 == 0) {
		ans = K <= N/2;
	} else {
		ans = K <= (N+1)/2; 
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanInt()
	if x == 3 || x==5 || x==7 {
		fmt.Fprintln(wr, "YES")
	} else {
		fmt.Fprintln(wr, "NO")
	}
}


Measured memory_bytes: 1780
import collections


def main():
    n, d = map(int, input().split())
    k = 0
    for i in range(n):
        x, y = map(int, input().split())
        if (x ** 2 + y ** 2) <= d ** 2:
            k += 1
    print(k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 1e5 + 7;

vector<int> from[MAXN];
int result[MAXN], idx;
int dp[MAXN];

int dfs(int u)
{
    if (dp[u])
        return dp[u];
    if (from[u].empty())
        return 0;
    for (int v : from[u])
        dp[u] = max(dp[u], 1 + dfs(v));
    return dp[u];
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    idx = n;
    for (int i = 0; i != m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        from[u].push_back(v);
    }
    int mx = 0;
    for (int i = 1; i <= n; ++i)
        if (!dp[i])
            mx = max(mx, dfs(i));
    printf("%d\n", mx);
}

Measured memory_bytes: 7424
ARRAY = gets.split.map(&:to_i)
N = ARRAY[0]
M = ARRAY[1]
H = gets.split.map(&:to_i)
$a = Array.new(N, 1)
M.times do
    ab = gets.split.map(&:to_i)
    if H[ab[0] - 1] < H[ab[1] - 1]
        $a[ab[0] - 1] = 0
    elsif H[ab[0] - 1] > H[ab[1] - 1]
        $a[ab[1] - 1] = 0
    else
        $a[ab[0] - 1] = 0
        $a[ab[1] - 1] = 0
    end
end

puts $a.select{|v| v == 1}.count


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

int main(){
int n;
cin >> n;
string ans = "YES";
vector<int>a(n);

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

sort(a.begin(),a.end());

for(int i = 0;i < n-1;i++){
	if(a[i] == a[i+1])ans = "NO";
}

cout << ans <<endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

class Graph {
  protected:
    int vertex;

    Graph(int v) {
      vertex = v;
    }
};

struct Edge {
  int to;
  int cost;
};

class AdjacentListGraph : public Graph {
  protected:
    std::vector<std::vector<Edge> > list;
  public:
    AdjacentListGraph(int v): Graph(v) {
      list.resize(vertex);
    }

    virtual void push(int from, int to, int cost) = 0;
};

class DAG : public AdjacentListGraph {
  using AdjacentListGraph::AdjacentListGraph;

  private:
    std::vector<int> sorted;

  public:
    void topological_sort();

    void push(int from, int to, int cost);

    std::vector<int> get_sorted();

    bool has_closed_cycle();
};

void DAG::topological_sort() {
  std::vector<int> intoVertex(vertex, 0);
  std::queue<int> q;

  for (std::vector<Edge> vec: list) {
    for (Edge e: vec) {
      intoVertex[e.to]++;
    }
  }

  for (int i = 0; i < vertex; ++i) {
    if (intoVertex[i] == 0)
      q.push(i);
  }

  while (q.size() > 0) {
    int v = q.front();
    q.pop();
    sorted.emplace_back(v);
    for (Edge e: list[v]) {
      intoVertex[e.to]--;
      if (intoVertex[e.to] == 0)
        q.push(e.to);
    }
  }
}

void DAG::push(int from, int to, int cost = 1) {
  Edge e;
  e.to = to;
  e.cost = cost;
  list[from].push_back(e);
}

std::vector<int> DAG::get_sorted() {
  return sorted;
}

bool DAG::has_closed_cycle() {
  return (int)sorted.size() != vertex;
}

int main() {
  
  int v;
  int e;

  scanf("%d %d", &v, &e);

  DAG g = DAG(v);

  int from, to;

  for (int i = 0; i <  e; i++) {
    scanf("%d %d", &from, &to);
    g.push(from, to);
  }

  g.topological_sort();
  bool flag = g.has_closed_cycle();
  printf("%d\n", flag ? 1 : 0);
}



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

int main(){
    int n,m;
    cin>>n>>m;
    int ans[n],yes[n];
    for (int j = 0; j < n; ++j) {
        ans[j]=0;
        yes[j]=0;
    }
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        if(yes[a-1]==0){
            yes[a-1]=1;
            ans[a-1]=b;
        }
        else{
            if(ans[a-1]!=b){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    if(n==1){
        cout<<ans[0]<<endl;
        return 0;
    }
    else{
        if(yes[0]==1 && ans[0]==0){
            cout<<-1<<endl;
            return 0;
        }
        if(ans[0]==0){
            ans[0]=1;
        }
        int ANS=0;
        for (int i = 0; i < n; ++i) {
            ANS+=ans[i]*pow(10,n-i-1);
        }
        cout<<ANS<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextLong()).sorted.reverse
  var ans = a(0)
  ans += a.slice(1, (n-1)/2 + 1).sum * 2
  if (n % 2 == 1) {
    ans -= a((n-1)/2)
  }
  println(ans)
}


Measured memory_bytes: 64192
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define maxr 100005
#define maxn 300005
#define ll long long int 
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
using namespace std;

char buffer[maxr], *p1, *p2;
template <class T> void read(T& x){
	char ch = gc(); x = 0; bool f = 1;
	while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
	if (ch == '-') f = 0, ch = gc();
	while ('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + ch - '0', ch = gc();
	if (!f) x = -x;
}

int n;
int a[maxn];
ll pre[maxn];
int main(){
	read(n);
	rep(i, 1, n) read(a[i]), pre[i] = a[i] + pre[i - 1];
	int l = 1, r = 3;
	ll res = 0x3fffffff;
	rep(mid, 2, n - 2){
		while (abs(pre[l + 1] - (pre[mid] - pre[l + 1])) < abs(pre[l] - (pre[mid] - pre[l]))) l++;
		while (abs(pre[r + 1] - pre[mid] - (pre[n] - pre[r + 1])) < abs(pre[r] - pre[mid] - (pre[n] - pre[r]))) r++;
		ll mx = max(max(pre[l], pre[mid] - pre[l]), max(pre[r] - pre[mid], pre[n] - pre[r]));
		ll mi = min(min(pre[l], pre[mid] - pre[l]), min(pre[r] - pre[mid], pre[n] - pre[r]));
		res = min(res, mx - mi);
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
     int a,b;
     cin>>a>>b;
     if(a>0&&b>0) cout<<"Positive";
      else if((max(a,b)>=0&&min(a,b)<=0)||a==0||b==0) cout<<"Zero";
      else{
      	if((abs(max(a,b))-abs(min(a,b)))%2==0){
      		cout<<"Negative";
		  }
		  else cout<<"Positive";
	  }  
}

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

int main(){
    int n;
    bool flag = true;
    int tmp = 0;
    cin >> n;

    vector<int> num(n);
    vector<int> cal;
    for(int i = 0; i < n; i++){
        cin >> num[i];
        if(num[i] % 10 != 0){
            flag = false;
            cal.push_back(num[i]);
        }
    }

    if(flag){
        cout << "0" << endl;
        return 0;
    }

    sort(num.begin(), num.end());

    if((accumulate(num.begin(), num.end(), 0) % 10) != 0){
        cout << accumulate(num.begin(), num.end(), 0) << endl;
    }
    else{
        int ans = accumulate(num.begin(), num.end(), 0);
        sort(cal.begin(), cal.end());
        /*
        while(true){
            if(ans % 10 != 0 || ans == 0){
                break;
            }
            for(int i = tmp; i < cal.size() - 1; i++){
                bool flag = false;
                if((cal[i] % 10) != 0){
                    for(int j = i + 1; j < cal.size(); j++){
                        if(((cal[i] + cal[j]) % 10) == 0){
                            tmp++;
                            ans -= cal[i];
                            flag = true;
                            break;
                        }
                    }
                }
                if(flag){
                    break;
                }
            }
        }
        cout << ans << endl;
        */

       cout << ans - cal[0] << endl;
    }

    return 0;
}

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

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    int maxi = max(a,max(b,c));
    int mini = min(a,min(b,c));
    int middle = a+b+c-maxi-mini;
    if(mini+middle == maxi){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

using namespace std;

void re(int& x);

template<class T> void re(std::vector<T>& a);

void pr(int x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

typedef vector<int> vi;

#define all(v) (v).begin(), (v).end()

#define rep(i, a, b) for(int i = a; i < (b); ++i)

int n;

void solve()
{
    re(n);
    vi a(n); re(a);
    vi p(n);

    vector< pair<int, int> > vs(n);
    rep(i,0,n) vs[i] = {a[i], i};
    sort(all(vs));

    rep(i,0,n) p[vs[i].second] = i;

    rep(i,0,n) {
        if (p[i] < n/2) ps(vs[n/2].first);
        else ps(vs[n/2-1].first);
    }
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

template<class T> void re(std::vector<T>& a) { for (int i = 0; i < a.size(); i++) re(a[i]); }

void pr(int x) { printf("%d", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



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

int main() {
	int men = 700;
    string S;
  	cin >> S;
  if (S[0] == 'o')
    men += 100;
  if (S[1] == 'o')
    men += 100;
  if (S[2] == 'o')
    men += 100;
  cout << men;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (200010)
int n,Q,ans[N];
vector<int>G[N],q[N];

void dfs(int x,int fa,int sum){
	for (int i=0;i<q[x].size();i++) sum+=q[x][i];
	ans[x]=sum;
	for (int i=0;i<G[x].size();i++){
		int y=G[x][i];
		if (y==fa) continue;
		dfs(y,x,sum);
	}
}

int main(){
	scanf("%d%d",&n,&Q);
	int x,y;
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for (int i=1;i<=Q;++i){
		scanf("%d%d",&x,&y);
		q[x].push_back(y);
	}
	dfs(1,0,0);
	for (int i=1;i<=n;++i) printf("%d ",ans[i]);
}


Measured memory_bytes: 37376
import java.util.Scanner;


public class Main {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		int[][][] data = new int[4][3][10];
		for(int i = 0; i < number;i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			
			data[b-1][f-1][r-1] += v;
		}
		for(int i = 0;i < 4;i++) {
			for(int j = 0; j < 3;j++){
				for(int r = 0;r < 10;r++) {
					System.out.print(" " + data[i][j][r]);
				}
				System.out.println();
			}
			if(i != 3) {
			System.out.println("####################");
			}
		}
	}

}



Measured memory_bytes: 29672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int X, Y;
    cin >> X >> Y;
    cout << X + Y/2 << endl;
    return 0;
}

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

using namespace std;

int C(int n, int k) {
    double res = 1;
    for (int i = 1; i <= k; ++i)
        res = res * (n - k + i) / i;
    return (int)(res + 0.01);
}

int main() {
	string s;
	cin >> s;
	int n = s.length(), k;
	cin >> k;
	int ans = C(n, k) * pow(9, k), digits = 0;
	for(int i = 0; i < n && k - digits; i++) {
		int d = s[i] - '0';
		ans -= (9 - d) * C(n - (i + 1), k - digits - 1) * pow(9, k - digits - 1);
		if(d != 0) digits++;
	}	
	printf("%d", ans);
}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    
    vector<int> memo1;
    vector<int> memo2;
    double density = 0;
    int x,y;
    
    for ( int a = 0; A*a*100 <= F; a++ ) {
    for ( int b = 0; B*b*100 <= F; b++ ) {
        
        if ( !a && !b ) { continue; }
        
        if ( A*a*100 + B*b*100 <= F ) {
            memo1.push_back(A*a*100 + B*b*100);
        }
        
    }
    }
    
    for ( long long c = 0; c*C <= 1500; c++ ) {
    for ( long long d = 0; d*D <= 1500; d++ ) {
        memo2.push_back(c*C+d*D);
    }
    }
    
    for ( auto& w : memo1 ) {
    for ( auto& s : memo2 ) {
        
        if ( w+s > F ) { continue; }
        if ( ( w/100 )*E < s ) { continue; }
        
        double d = (static_cast<double>(s)*100)/(static_cast<double>(w)+static_cast<double>(s));
        
        if ( density <= d ) {
            density = d;
            x = w+s;
            y = s;
        }
    }
    }
    
    cout << x << " " << y << endl;
    
}




// int main() {
    
    // double z = -1;
    // long long x = 0;
    // long long y = 0;
    
    // long long A,B,C,D,E,F;
    // cin >> A >> B >> C >> D >> E >> F;
    
    // long long w;
    // for ( long long a = 0; a <= 30; a++ ) {
    // for ( long long b = 0; b <= 30; b++ ) {
        
        // if ( !a && !b ) { continue; }
        
        // w = 100*A*a + 100*B*b;
        
        // if ( F < w ) { continue; }
        
        // long long s = min( (A*a + B*b)*E, F-w );
        
        // long long m = 0;
        // for ( long long c = 0; c <= 1500; c++ ) {
        // for ( long long d = 0; d <= 1500; d++ ) {
            // if ( c*C+d*D > s ) { continue; }
            // m = max( m, (c*C+d*D) );
        // }
        // }
        
        // s = m;
        
        // double zs = (100*static_cast<double>(s))/(static_cast<double>(s)+static_cast<double>(w));
        
        // if ( z < zs ) {
            // x = w+s;
            // y = s;
            // z = zs;
        // }
    // }
    // }
    
    // if ( !x ) {
        // cout << A*100 << " " << 0 << endl;
    // }
    // else {
        // cout << x << " " << y << endl;
    // }
    
    // return 0;
// }

Measured memory_bytes: 10604
# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)


Measured memory_bytes: 31532
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int a,b; cin>>a>>b;
  if(a>b){
    cout<<a+a-1<<endl;
  }else if(b>a){
    cout<<b+b-1<<endl;
  }else{
    cout<<a*2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if ((h | w) == 0)
				break;
			char[][] map = new char[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] == 'A') {
						ay = i;
						ax = j;
					} else if (map[i][j] == 'B') {
						by = i;
						bx = j;
					}
				}
			}
			int[][] dp = new int[h][w];
			for (int[] dp1 : dp)
				Arrays.fill(dp1, 1 << 30);
			Deque<Point> deque = new ArrayDeque<Main.Point>();
			deque.push(new Point(ay, ax, 0));
			dp[ay][ax] = 0;
			while (!deque.isEmpty()) {
				Point p = deque.poll();
				int y = p.y;
				int x = p.x;
				int step = p.step + 1;

				for (int[] m : move) {
					int ny = y + m[0];
					int nx = x + m[1];
					if (!isOK(ny, nx))
						continue;
					if (map[ny][nx] == '#')
						continue;
					if (dp[ny][nx] <= step)
						continue;
					dp[ny][nx] = step;
					deque.offer(new Point(ny, nx, step));
				}

			}
			char[] p = scanner.next().toCharArray();
			int e;
			for (e = 0; e < 200; e++) {
				if (dp[by][bx] <= e)
					break;
				char o = p[e % p.length];
				int ny = by + (o == '2' ? 1 : 0) - (o == '8' ? 1 : 0);
				int nx = bx + (o == '6' ? 1 : 0) - (o == '4' ? 1 : 0);
				if (!isOK(ny, nx))
					continue;
				by = ny;
				bx = nx;
			}
			System.out
					.println(e < 200 ? e + " " + by + " " + bx : "impossible");
		}
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int ay, ax, by, bx, h, w;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point {
		int y, x, step;

		public Point(int y, int x, int step) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + "]";
		}

	}
}

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

#define pb push_back
#define eb emplace_back

using namespace std;

using vi = vector<int>;
using ll = long long;
using ii = pair<int, int>;


int dist[51][51];
int m[51][51];
int h,w;

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

void bfs(){
    memset(dist, -1, sizeof dist);
    queue<ii> to_visit;
    to_visit.emplace(0, 0);
    dist[0][0]=0;
    while(!to_visit.empty()){
        auto v = to_visit.front(); to_visit.pop();
        for(int i=0; i<4; ++i){
            int x=v.first+dx[i], y=v.second+dy[i];
            if(x>=0 and x<h  and y>=0 and y<w){
                if(dist[x][y]==-1 and m[x][y]==0){
                    dist[x][y]=dist[v.first][v.second]+1;
                    to_visit.emplace(x, y);
                }
            }
        }
    }
}

int main(){
    ios :: sync_with_stdio(false);
    // find minimum path
    // paint everything else
    char c;
    cin >> h >> w;
    int k=0;
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            cin >> c;
            if(c=='#') m[i][j]=1;
            else k++;
        }
    }
    // cerr << ">" << k << endl;
    bfs();
   
    // for(int i=0; i<h; ++i){
    //     for(int j=0; j<w; ++j){
    //         cerr << dist[i][j]<< " ";
    //     }
    //     cerr << "\n";
    // }

    if(dist[h-1][w-1] != -1){
        cout << k-dist[h-1][w-1]-1 << endl;
    }else{
        cout << "-1" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
from collections import deque
def main():
    n = int(input())
    tree = [[] for _ in range(n+1)]

    for i in range(n-1):
        a, b, c = map(int, input().split())
        tree[a].append([b, c])
        tree[b].append([a, c])
    q, k = map(int, input().split())
    que = deque([k])
    visit = [-1 for _ in range(n+1)]
    visit[k] = 0
    while que:
        pos = que.popleft()
        for i, j in tree[pos]:
            if visit[i] < 0:
                visit[i] = visit[pos]+j
                que.append(i)
    for i in range(q):
        x, y = map(int, input().split())
        print(visit[x]+visit[y])

if __name__=="__main__":
    main()

Measured memory_bytes: 93836
#include<stdio.h>
int main(){
  int i,n,left,right,max=0,count=0;
  scanf("%d%d",&n,&left);
  for(i=1;i<n;i++){
    scanf("%d",&right);
    if(left<right){
      if(max<count)
        max=count;
        count=0;
    }
    else
      count++;
    left=right;
  }
  if(max<count)
    max=count;
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include<stdio.h>
#include <climits>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s;
	int n, a, b;
	int i = 1, j = 0 ;
	int pass_a = 0,pass_b = 1;

	cin >> s;

	if (s[1] == 'B') {
		cout << "ARC" << "\n";
	}
	else if (s[1] == 'R') {
		cout << "ABC" << "\n";
	}
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  ll ans = INF;
  rep(i, max(x, y) * 2 + 1) {
    ll now = i * c;
    if(i / 2 < x) now += (x - i / 2) * a;
    if(i / 2 < y) now += (y - i / 2) * b;
    ans = min(ans, now);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> sum(n + 1);
  rep(i, n) {
    sum[i + 1] = sum[i] + a[i];
  }

  map<ll, int> m;
  rep(i, n + 1) {
    m[sum[i]]++;
  }
  ll ans = 0;
  for(auto &p : m) {
    ans += (ll)p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
          long[] H=cin.ArrayLong(N,0);
        bool ans=true;
        long minusone=0;
        long max=0;
        if(N>1)
        {for(int i=1;i<N;i++)
        {
          if(H[i-1]>H[i]+1){ans=false;break;}
          else if(H[i-1]==H[i]+1&&minusone<=H[i]){max=H[i-1]-1;minusone=H[i];}
          else if(H[i-1]==H[i]+1){ans=false;break;}
          else max=H[i];
        }
        }
        if(ans==true)Console.WriteLine("Yes");
      else Console.WriteLine("No");
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 27488
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W,K=MI()
    S=[[]for _ in range(H)]
    for i in range(H):
        S[i]=list(input())
        
    ans=10**10
    
    import itertools
    import bisect
    
    for ite in itertools.product([0,1], repeat=H):
        #高さ方向で全探索，0,1の切り替わりでグループを分ける
        g=[]#各グループの末尾列の番号
        cnt=[]#数えるよう,合計
        cnt2=[]#数えるよう,その列だけ
        now=-1
        for i in range(len(ite)):
            if ite[i]!=now:
                g.append(i-1)
                cnt.append(0)
                cnt2.append(0)
                now=ite[i]
        g.append(H-1)
        cnt.append(0)
        cnt2.append(0)
        temp=len(g)-2
        last=[0]#最後に追ったところを保存
        fl=0#Kを超えたら
        fl2=0#無理なとき
        for j in range(W):
            for k in range(len(cnt2)):
                cnt2[k]=0
            if fl2==1:
                break
            for i in range(H):
                if S[i][j]=="1":
                    num=bisect.bisect_left(g,i)
                    cnt[num]+=1
                    cnt2[num]+=1
                    if cnt[num]>K:
                        fl=1
                    
            if fl==1:
                for k in range(len(cnt)):
                    cnt[k]=cnt2[k]
                    cnt2[k]=0
                fl=0
                temp+=1
                last.append(j)
                if last[-1]==last[-2]:
                    temp=10**10
                    fl2=1
                    break
                
        #print(ite,temp,g,last)
        ans=min(ans,temp)
        
    print(ans)
                
                
                    
                    
                
        
        
    

main()


Measured memory_bytes: 49756
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







int N, M;
set<pair<int, int>> E;
//---------------------------------------------------------------------------------------------------
string solve() {
    rep(i, 1, N - 1) {
        if (E.count({ 0,i }) && E.count({ i, N - 1 })) return "POSSIBLE";
    }
    return "IMPOSSIBLE";
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        E.insert({ a,b });
        E.insert({ b,a });
    }

    cout << solve() << endl;
}

Measured memory_bytes: 19072
#include <iostream>
#include <string>
int main(){
  std::string s;
  int f[26]={},a=-1;
  std::cin>>s;
  for(int i=0;i!=s.size();++i)++f[s[i]-97];
  for(int i=0;i!=26;++i)if(f[i]==0){a=i;break;}
  if(a>=0)std::cout<<(char)(a+97)<<"\n";
  else std::cout<<"None"<<"\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int x, y, z; cin >> x >> y >> z;
    x -= z;
    cout << x / (y + z) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	string a,b;
	cin >> a >> b;
	cout << b << a;
	return 0;
}



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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const double eps = 1e-10;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    double d;
    cin >> n >> d;
    int ans = 0;
    while (n--)
    {
        double x, y;
        cin >> x >> y;
        double z = sqrt(x * x + y * y);
        if (d > z - eps)
        {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3788
def greatest_common_divisor(a, b)
	r = a % b
	while(!r.zero?)
	    a = b
	    b = r
	    r = a % b
  	end
  	b
end

def least_common_multiple(a, b)
	gcd = greatest_common_divisor(a, b)
	a * b / gcd
end

line = gets.chomp
a, b = line.split(' ').map(&:to_i)
puts least_common_multiple(a, b)


Measured memory_bytes: 1788
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
//const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<vector<int>>go;
vector<int>ha;
int dfs(int ter,int oya,int fuk){
	int deep=fuk;
	maxeq(ha[fuk],go[ter].size()-1);
	for(auto it:go[ter]){
		if(it==oya){continue;}
		maxeq(deep,dfs(it,ter,fuk+1));
	}
	return deep;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//直径が関係してそう(求めないけど)
	pair<int,llint>ans(9999999,999);
	llint n,i,j;cin>>n;
	go.res(n);
	ha.res(n);
	for(i=1;i<n;i++){
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(b);
		go[b].pub(a);
	}
	//n=100なので全探索余裕で間に合います
	for(i=0;i<n;i++){//一つの頂点が特別
		for(j=0;j<n;j++){ha[j]=1;}
		int deep=1+dfs(i,-1,0);
		ha[0]++;
		llint num=1;
		for(j=0;j<n;j++){num*=ha[j];}
		mineq(ans,mp(deep,num));
	}
	//2つの頂点が特別
	for(i=0;i<n;i++){
		for(auto it:go[i]){
			if(i<it){continue;}
			for(j=0;j<n;j++){ha[j]=1;}
			int deep=1+max(dfs(i,it,0),dfs(it,i,0));
			llint num=2;
			for(j=0;j<n;j++){num*=ha[j];}
			mineq(ans,mp(deep,num));
		}
	}
	cout<<ans.fir<<" "<<ans.sec<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String s = sc.next();
        boolean result = true;

        if (s.length()!=A+B+1) result = false;
        else if (s.charAt(A) != '-') result = false;
        else {
            String part1 = s.substring(0, A);
            String part2 = s.substring(A+1);
            if (!checkValid(part1) || !checkValid(part2)) result = false;
        }

        if (result) System.out.println("Yes");
        else System.out.println("No");
    }

    private static boolean checkValid(String s) {
        for (int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            if (c < '0' || c > '9') {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdlib>

using namespace std;
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int main()
{
    int s[200010];
    int p[200010];
    int n,i,a,b;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>p[i];
        s[i]=p[i];
    }
    qsort(p,n,sizeof(p[0]),cmp);
    a=n/2-1;
    b=n/2;
    a=p[a];
    b=p[b];
    for(i=0; i<n; i++)
    {
        if(s[i]<=a)
            cout<<b<<endl;

        else  //if(s[i]>=b)
            cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 3820