akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;


 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    long sum = 0;
    for(int i = 0; i < n; i++){
      sum += sc.nextInt();
    }
    System.out.println(sum/n);


  }
 
  
 
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 18892
#include<bits/stdc++.h>
using namespace std;
#define de(x) cout<<#x<<" = "<<x<<endl
const int N=1e2+7;
const double eps=1e-6;
int wa1[N],wa2[N],wa[9*N];
bool suger[3007];
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    for(int i=1;i<=30;i++){
        wa1[i]=a*i*100;
        wa2[i]=b*i*100;
    }
    int p=0;
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            wa[p]=wa1[i]+wa2[j];
            p++;
        }
    }
    sort(wa,wa+p);
    for(int i=0;i<=1500;i++){
        for(int j=0;j<=1500;j++){
            if( i*c+j*d<=3000 )suger[i*c+j*d]=1;
        }
    }
    double lim=1.0*e/100,mx=0;
    int ans1=100*a,ans2=0;
    for(int i=3000;i>=0;i--){
        if(!suger[i])continue;
        for(int j=1;j<p;j++){
            if(1.0*i/wa[j]-lim>eps )continue;
            else if(wa[j]+i<=f) {
                if(1.0*i/wa[j]>mx){
                    ans1=wa[j];
                    ans2=i;
                    mx=1.0*i/wa[j];
                }
            }
        }
    }
    printf("%d %d\n",ans1+ans2,ans2);
}



Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int gate[100010];

int main() {
    ll N,M; cin >> N >> M;

    for(int i=0; i<=M+1; i++){
        gate[i]=0;
    }

    for(int i=0; i<M; i++){
        int l, r; cin >> l >> r;
        gate[l]++;
        gate[r+1]--;
    }

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

    int ans=0;
    for(int i=1; i<=N; i++){
        if(gate[i]==M){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
co = list(map(int,input().split()))
N = co[0]
K = co[1]
sunuke = [0 for i in range(N)]
for i in range (K):
    d = int(input())
    A =  list(map(int,input().split()))
    for j in range(d):
        sunuke[A[j]-1] +=1
ans = 0      
for i in range(N):
    if sunuke[i] == 0:
          ans += 1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

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

#define fst first
#define snd second

using namespace std;

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

vector<PII> G[3030];
int d[3030];

int main(void){
	int N, M, K;
	cin >> N >> M >> K;
	REP(i, M){
		int a, b, l;
		cin >> a >> b >> l;
		a--; b--;
		G[a].push_back({l, b});
		G[b].push_back({l, a});
	}
	fill(d, d+N, INF);
	REP(i, K){
		int s;
		cin >> s;
		s--;
		d[s] = 0;
		priority_queue<PII, vector<PII>, greater<PII> > pq;
		pq.push({0, s});
		while(pq.size()){
			PII p = pq.top(); pq.pop();
			int v = p.second;
			if(d[v] < p.first) continue;
			REP(i, G[v].size()){
				if(d[G[v][i].second] > d[v] + G[v][i].first){
					d[G[v][i].second] = d[v] + G[v][i].first;
					pq.push({d[G[v][i].second], G[v][i].second});
				}
			}
		}
	}
	int res = 0;
	REP(i, N){
		res = max(res, d[i]);
		REP(j, G[i].size()){
			if(i == j) continue;
			res = max(res, (d[i]+d[G[i][j].second]+G[i][j].first+1)/2);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 5868
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#define pb push_back
#define mkp make_pair
using namespace std;

const int maxn = 200005;
typedef long long ll;

int n;
int da[maxn];
int st[maxn],top;
int tl[maxn],tr[maxn];

ll f(int l,int r)
{
    return (ll)(l+1)*(r+1);
}
int main()
{
    ll res = 0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",da+i);
    top = 0;
    for(int i=1;i<=n;i++)
    {
        while(top&&da[i]<da[st[top]])
            top--;
        tl[i] = (top?st[top]+1:1);
        st[++top] = i;
    }
    top = 0;
    for(int i=n;i>=1;i--)
    {
        while(top&&da[i]<da[st[top]])
            top--;
        tr[i] = (top?st[top]-1:n);
        st[++top] = i;
    }
    for(int i=1;i<=n;i++)
        res += da[i]*f(i-tl[i],tr[i]-i);
    printf("%lld\n",res);

}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n;
	string s;
	cin >> n >> s;
	bool f = true;
	rep(i, n / 2) {
		if(s[i] != s[i + n / 2]) f = 0;
	}
	if(n % 2 != 0) f = 0;
	yorn(f);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string ,int > m; 
long long ans;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		string ss;
		cin>>ss;
		sort(ss.begin(),ss.end());
		ans+=m[ss];
		m[ss]++; 
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 11136
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
if n % 2 == 0:
    print(n)
else:
    print(2*n)

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MAXN = 303;
int n;
int a[MAXN];
ll dp[MAXN][MAXN];

ll solve(int idx, int moves) {
    ll& res = dp[idx][moves];
    if (res != -1)
        return res;

    res = 1e18;
    for (int rem = 0; rem <= moves; ++rem) {
        int p = idx - rem - 1;
        if (p < 0) {
            res = 0;
            break;
        } else {
            res = min(res, max(0, a[p] - a[idx]) + solve(p, moves - rem));
        }
    }

    return res;
}

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

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

    if (k == n) {
        cout << 0 << '\n';
        return 0;
    }

    memset(dp, -1, sizeof(dp));
    ll cost = 1e18;
    for (int i = 0; i < n; ++i) {
        int after = n - i - 1;
        if (after <= k)
            cost = min(cost, a[i] + solve(i, k - after));
    }

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


Measured memory_bytes: 1024
class Node
  attr_reader :val, :child
  attr_accessor :d, :f
  def initialize(i, child)
    @val = i
    @child = child
    @d = -1
  end
end

class Graph
  attr_accessor :node
  def initialize(n)
    @node = Array.new(n)
  end
  def breadth_first_search
    @node[0].d = 0
    q = [0]
    ii = 1
    loop do
      break if q.size == 0
      next_q = []
      q.each{|i|
        @node[i].child.each{|ch|
          if @node[ch-1].d < 0 then
            @node[ch-1].d = ii
            next_q << ch-1
          end
        }
      }
      q = next_q
      ii += 1
    end
  end
  def print
    @node.size.times{|i|
      puts "#{@node[i].val} #{@node[i].d}"
    }
  end
end

n = gets.to_i
graph = Graph.new(n)
n.times{
  i, *child = gets.split.map(&:to_i)
  child.shift
  graph.node[i-1] = Node.new(i, child)
}

graph.breadth_first_search
graph.print

Measured memory_bytes: 8764
import java.util.Scanner;
import java.util.Stack;

public class Main {
    static int h;
    static int w;
    static int c;
    static int ans;
    static int count;
    static int[] color_order;
    static int[][] map;
    static int[][] tmp;

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

        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int m = sc.nextInt();
            int s = sc.nextInt();
            if (h == -1 && m == -1 && s == -1)
                break;
            int sum = 3600 * h + 60 * m + s;
            {
                int rest = 7200 - sum;
                int nh = rest / 3600;
                rest %= 3600;
                int nm = rest / 60;
                rest %= 60;
                int ns = rest;
                System.out.printf("%02d:%02d:%02d\n", nh, nm, ns);
            }
            {
                int rest = 7200 - sum;
                rest *= 3;
                int nh = rest / 3600;
                rest %= 3600;
                int nm = rest / 60;
                rest %= 60;
                int ns = rest;
                System.out.printf("%02d:%02d:%02d\n", nh, nm, ns);
            }
        }
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
static const int N=100;

int main(){
    int n,a[N+1],b[N+1][N+1];
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i-1] >> a[i]; 
    }
    
    for(int i=1;i<=n;i++) b[i][i]=0;
    for(int k=2;k<=n;k++){
        for(int i=1;i<=n-k+1;i++){
            int j=i+k-1;
            b[i][j]=(1<<21);
            for(int m=i;m<=j-1;m++){
                b[i][j]=min(b[i][j],b[i][m]+b[m+1][j]+a[i-1]*a[m]*a[j]);
            }
        }
    }
    
    cout << b[1][n] << endl;
    return 0;
}



Measured memory_bytes: 3088
while true
  n,m = gets.split(" ").map{|s| s.to_i}
  break if n==0 && m==0
  nw = Array.new(n){gets.to_i}
  se = Array.new(m){gets.to_i}

  lnw,lse = [],[]
  
  for i in 1..n  #????????????????????????
    x = nw[0..i-1].inject(:+)
    for j in 0..n-i #?????????????????????????????????
      lnw[x].nil? ? lnw[x] = 1 : lnw[x] += 1
      x += nw[i+j]-nw[j] if j<n-i
    end
  end

  for i in 1..m
    y = se[0..i-1].inject(:+)
    for j in 0..m-i
      lse[y].nil? ? lse[y] = 1 : lse[y] += 1
      y += se[i+j]-se[j] if j<m-i
    end
  end
  
  ans = 0
  for k in [nw.min,se.min].max..[lnw.size,lse.size].min-1
    ans += lnw[k]*lse[k] if !lnw[k].nil? && !lse[k].nil? 
  end

  puts ans
end

Measured memory_bytes: 32064
use proconio::input;
use proconio::marker::{Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}

use std::collections::VecDeque;

fn main() {
    input!{
        n: usize,
        mut c: Chars,
    }
    let mut ans = 0;
    let mut bufr = VecDeque::new();
    let mut bufw = VecDeque::new();
    for i in (0..n).rev() {
        if c[i] == 'R' {
            bufr.push_back(i);
        }
    }
    for i in 0..n {
        if c[i] == 'W' {
            bufw.push_back(i);
        }
    }
    loop {
        let mut flag = 0;
        for i in bufw.iter().rev() {
            if *i < n-1 {
                if c[*i+1] == 'R' {
                    c.swap(bufw.pop_front().unwrap(), bufr.pop_front().unwrap());
                    flag = 1;
                    ans += 1;
                    break;
                }
            }
        }
        if flag == 0 {
            println!("{}", ans);
            return;
        }
    }
}


Measured memory_bytes: 4696
import java.util.Scanner;

public class Main {


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

			while(sc.hasNext()) {
				int n = sc.nextInt();
					if (n == 0) {
						break;
					}

				boolean[] arr = new boolean[n + 1];
				int limit = (int)Math.sqrt(arr.length);
				prime(arr, limit, n);
			}
		sc.close();


	}

	private static void prime(boolean[] arr, int limit, int n) {
		for (int j = 2 ; j <= limit; j++) {
			for(int k = 2; k * j < arr.length; k++) {
				arr[k * j] = true;
			}
		}
		arr[0] = arr[1] = true;

		for (int i = n; i > 2; i--) {
			if (arr[i] == false && arr[i - 2] == false) {
				System.out.printf("%d %d\n", i - 2, i);
				break;
			}
		}
	}
}


Measured memory_bytes: 83676
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    if(A < C){
      if(B <= C){
        System.out.println(0);
      }else if(D <= B){
        System.out.println(D - C);
      }else{
        System.out.println(B - C);
      }
    }else if(A > C){
      if(D <= A){
        System.out.println(0);
      }else if(B <= D){
        System.out.println(B - A);
      }else{
        System.out.println(D - A);
      }
    }else{
      if(B <= D){
        System.out.println(B - A);
      }else{
        System.out.println(D - C);
      }
    }

  }
}


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

int main(){
    long W, a, b;
    cin >> W >> a >> b;
    if(a > b)swap(a, b);
    if(b <= a + W)return 0 & puts("0");
    cout << b - (a + W) << endl;
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	
	int h,w;
	
	while(cin >> w >> h,h|w){
		vector<vector<int>> v(h*w);
		REP(i,h){
			REP(j,w-1){
				int tmp;cin >> tmp;
				if(tmp == 0){
					v[i*w+j].PB(i*w+j+1);
					v[i*w+j+1].PB(i*w+j);
				}
			}
			if(i != h-1)REP(j,w){
				int tmp;cin >> tmp;
				if(tmp == 0){
					v[i*w+j].PB((i+1)*w+j);
					v[(i+1)*w+j].PB(i*w+j);
				}
			}
		}
		vector<ll> dist(h*w);
		REP(i,w*h)dist[i] = INF;
		dist[0] = 0;
				
		queue<pair<int,int>> q;
		q.push(MP(0,-1));
		
		while(!q.empty()){
			auto now = q.front();q.pop();
			REP(i,v[now.FI].size()){
				if(v[now.FI][i] == now.SE)continue;
				if(dist[v[now.FI][i]] > dist[now.FI]+1){
					dist[v[now.FI][i]] = dist[now.FI] + 1;
					q.push(MP(v[now.FI][i],now.FI));
				}
			}
		}
		
		if(dist[h*w-1] == INF){
			cout << 0 << endl;
		}
		else{
			cout << dist[h*w-1]+1 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3144
import java.util.*;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int x1=sc.nextInt();
        int y1=sc.nextInt();
        int x2=sc.nextInt();
        int y2=sc.nextInt();
        int y=y2-y1;
        int x=x2-x1;
        System.out.println((x2-y)+" "+(y2+x)+" "+ (x1-y) +" "+ (y1+x));
    }
}



Measured memory_bytes: 22740
#include<iostream>
using namespace std;
#define MAX 100000
#define NIL -1

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

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].parent == NIL) cout << "root, ";
  else if (T[u].left == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for (i = 0, c = T[u].left; c != NIL; i++, c = T[c].right) {
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p) {
  D[u] = p;
  if(T[u].right != NIL) rec(T[u].right, p);
  if(T[u].left != NIL) rec(T[u].left, p + 1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for(i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;

  for(i = 0; i < n; i++) {
    cin >> v >> d;
    for(j = 0; j < d; j++) {
      cin >> c;
      if(j ==0) T[v].left = c;
      else T[l].right = c;
      l = c;
      T[c].parent = v;
    }
  }

  for(i = 0; i < n; i++) {
    if(T[i].parent == NIL) r = i;
  }

  rec(r, 0);

  for(i = 0; i < n; i++) print(i);

  return 0;
}


Measured memory_bytes: 7768
#include<cstdio>
#include<iostream>
using namespace std;
void solve(int a,int b,int c,int d)
{
    for(int i=0;i<=1;i++)
    {
        for(int j=0;j<=1;j++)
        {
            for(int k=0;k<=1;k++)
            {
                int tmp=(i==0)?a-b:a+b;
                tmp+=(j==0)?(-c):c;
                tmp+=(k==0)?(-d):d;
                if(tmp==7)
                {
                    cout<<a;
                    if(i==0) cout<<"-";
                    else cout<<"+";
                    cout<<b;
                    if(j==0) cout<<"-";
                    else cout<<"+";
                    cout<<c;
                    if(k==0) cout<<"-";
                    else cout<<"+";
                    cout<<d<<"="<<"7"<<endl;
                    return;
                }
            }
        }
    }
    return;
}
int main()
{
    char s[10];
    cin>>s;
    solve(s[0]-'0',s[1]-'0',s[2]-'0',s[3]-'0');
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int x=0;
      Scanner scanner = new Scanner(System.in);
      x = scanner.nextInt();
      scanner.close();
      int x1 = (int)(x/1000);
      int x2 = (int)((x-x1*1000)/100);
      int y1 = (int)(x/100);
      int y2 = (int)((x-x1*1000)/10);
      int y3 = x-x1*1000-x2*100;
      // System.out.println(y1);
      // System.out.println(y2);
      // System.out.println(y3);
      if (y1%11==0 || y2%11==0 || y3%11==0) {
         System.out.println("Bad");
      } else {
         System.out.println("Good");
      }
   }
}


Measured memory_bytes: 23124
use io::*;
use std::collections::BTreeSet;

fn sum(n: i64) -> i64 {
    if n == 0 {
        0
    } else {
        n % 10 + sum(n / 10)
    }
}

fn main() {
    if false {
        let mut v: Vec<f64> = vec![];

        for i in 1..10000001 {
            v.push(i as f64 / sum(i) as f64);
        }

        let mut cur_min = v[v.len() - 1];
        for i in (0..v.len()).rev() {
            if v[i] <= cur_min {
                println!("{}", i + 1);
                cur_min = v[i];
            }
        }

        return;
    }

    let con = read_string();
    let mut sc = Scanner::new(&con);

    let k: usize = sc.next();

    let mut cands = vec![];

    let mut ofs = 1;
    let mut nine = 0;
    let mut ss = BTreeSet::new();
    for keta in 0..16 {
        for i in 1..10000i64 {
            if let Some(t) = i.checked_mul(ofs) {
                if let Some(v) = t.checked_add(nine) {
                    if !ss.contains(&v) {
                        cands.push(v);
                        ss.insert(v);
                    }
                }
            }
        }
        ofs *= 10;
        nine = nine * 10 + 9;
    }

    cands.sort();

    let mut v: Vec<f64> = vec![];

    for &c in cands.iter() {
        v.push(c as f64 / sum(c) as f64);
    }

    let mut cur_min = v[v.len() - 1];
    let mut ans = vec![];
    for i in (0..v.len()).rev() {
        if v[i] <= cur_min {
            ans.push(cands[i]);
            cur_min = v[i];
        }
    }

    ans.reverse();
    for i in 0..k {
        println!("{}", ans[i]);
    }
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 14588
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

class UnionFind {
public:
    int N;
    std::vector<int> parent;
    UnionFind(int n) : N(n), parent(N, -1) {
    }
    void Union(int a, int b) {
        a = root(a);
        b = root(b);
        int sizea = size(a);
        int sizeb = size(b);
        if (sizea > sizeb) {
            int temp = a;
            a = b;
            b = temp;
        }
        parent[b] += parent[a];
        parent[a] = b;
    }
    int root(int a) {
        if (parent[a] < 0) return a;
        return parent[a] = root(parent[a]);
    }
    int size(int a) {
        return -parent[root(a)];
    }
    bool Find(int a, int b) {
        return root(a) == root(b);
    }
};

struct edge {
    int a;
    int b;
    int c;
    bool operator<(const edge &rhs) const {
        return c < rhs.c;
    }
    edge(int a_, int b_, int c_) : a(a_), b(b_), c(c_) {

    }
};

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

    UnionFind uf(N);
    std::vector<edge> e;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int c;
            cin >> c;
            if (c == -1) continue;
            e.push_back((edge){i, j, c});
        }
    }

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

    int ans = 0;
    for (int i = 0; i < e.size(); i++) {
        if (!uf.Find(e[i].a, e[i].b)) {
            uf.Union(e[i].a, e[i].b);
            ans += e[i].c;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define f first
#define s second
//#define int long long
#define st string
#define int long long
#define dear_crush int32_t main()
#define bari_ja return 0
#define forn(i, n) for (int i = 0; i < n; i++)
#define INF 1e9+5

dear_crush
{
/*
string str;

cin >> str;

	bool flag = true;

for(int i=1; i<str.size(); i++){

	if (str[i-1]!=str[i]) {
		flag = false;
	}
}

if (flag==false) {

	std::cout << "YES" << '\n';
}

else
std::cout << "NO" << '\n';

*/

int n, a, b;

std::cin >> n>>a>>b;

int s = a+b;

int r = n/s;

int re = n%s;

if(re>=a)
{
std::cout <<a*r+a << '\n';
}
else
std::cout << a*r+re << '\n';

bari_ja;
}


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

int main()
{
	string s;
	char falseChar = '0';
	cin >> s;

	int changeNum = 0;
	for_each(s.begin(), s.end(), [&](char& c) {
		if (c == falseChar)++changeNum;
		falseChar = (falseChar == '0' ? '1' : '0');
		});
	if (changeNum * 2 > s.length())changeNum = s.length() - changeNum;
	cout << changeNum << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
struct edge
{
    int to;
    int cost;
};
vector<vector<edge>> G;
vi color;
void dfs(int u, int col)
{
    color[u] = col;
    rep(i, G[u].size())
    {
        edge v = G[u][i];
        if (color[v.to] == 0)
        {
            if (v.cost % 2 == 0)
            {
                dfs(v.to, col);
            }
            else
            {
                dfs(v.to, -col);
            }
        }
    }
}
int main()
{
    int n;
    cin >> n;
    color.resize(n);
    G.resize(n);
    rep(i, n - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    dfs(0, 1);
    rep(i, n)
    {
        if (color[i] == 1)
        {
            cout << '0' << endl;
        }
        else
        {
            cout << '1' << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8192
/**
*    author:  yuya1234
*    created: 24.06.2020 15:55:37
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s,t;
    cin>>s>>t;

    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());

    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

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

int n,x,y,tt;

int main()
{
	cin>>n;
	while(n--)
	{
		int t,xx,yy;
		cin>>t>>xx>>yy;
		if(abs(x-xx)+abs(y-yy)>t-tt||(abs(x-xx)+abs(y-yy)-(t-tt))%2) {cout<<"No";return 0;}
		tt=t;x=xx;y=yy;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    double x1, y1, x2, y2;
    double X, Y, dis;
    cin >> x1 >> y1 >> x2 >> y2;
    X=(x2-x1)*(x2-x1);
    Y=(y2-y1)*(y2-y1);
    dis= sqrt( X+ Y);
    printf("%f\n", dis);
    return 0;
}

    


Measured memory_bytes: 3280
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

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

	int N;
	long A, B;
	int[] r;// nutrition value
	int[] s;// deliciousness value
	int[] sum;

	void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextLong();
		B = sc.nextLong();
		r = new int[N];
		s = new int[N];
		sum = new int[N];
		for (int i = 0; i < N; ++i) {
			r[i] = sc.nextInt();
			s[i] = sc.nextInt();
		}
		for (int i = N - 1; i >= 0; --i) {
			sum[i] = (i + 1 < N ? sum[i + 1] : 0) + s[i];
		}
		solve();
	}

	void solve() {
		boolean[] num = new boolean[151];
		num[0] = true;
		for (int v : s) {
			for (int i = 150; i >= 0; --i) {
				if (num[i])
					num[i + v] |= num[i];
			}
		}
		ArrayList<Integer> lis = new ArrayList<>();
		for (int i = 0; i <= 150; ++i) {
			if (num[i])
				lis.add(i);
		}
		long diff = A - B;
		int high = lis.size();
		int low = 0;
		while (high - low > 1) {
			int middle = (high + low) / 2;
			if (diff >= f(lis.get(middle), 0, false)) {
				low = middle;
			} else {
				high = middle;
			}
		}
		System.out.println(lis.get(low) + " " + (sum[0] - lis.get(low)));
	}

	HashMap<List<Integer>, Long> map = new HashMap<>();

	long f(int p, int k, boolean f) {
		if (p <= 0) {
			return -Long.MAX_VALUE / 16;
		} else if (p > sum[k]) {
			return Long.MAX_VALUE / 16;
		}
		if (k == N - 1) {
			if (sum[k] >= p)
				return -Long.MAX_VALUE / 16;
			else
				return Long.MAX_VALUE / 16;
		}
		if (map.containsKey(toList(p, k, f))) {
			return map.get(toList(p, k, f));
		}
		long ret = Long.MAX_VALUE / 16;
		// f????????°A-B<=0??§???????????¨???????¨????????????????????????°????????????
		if (!f) {
			long zeta = f(sum[k] - p + 1, k, true);
			ret = Math.max(1, 2 - zeta);
		}
		long xi = f(sum[k + 1] - (p - s[k]) + 1, k + 1, false);
		ret = Math.min(ret, 1 + (-xi - r[k]));
		map.put(toList(p, k, f), ret);
		return ret;
	}

	List<Integer> toList(int p, int k, boolean f) {
		List<Integer> lis = new ArrayList<>();
		lis.add(p);
		lis.add(k);
		lis.add(f ? 1 : 0);
		return lis;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 53956
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"

void solve() {
    int ans = 0;
    int n; cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i ++) cin >> arr[i];
    int curr = 0;
    for(int i = 0; i < n; i ++) {
        if((arr[i] > curr)) {
            curr = arr[i];
            continue;
        }
        else {
            ans += (curr - arr[i]);
        }
    }
    cout << ans << endl;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4772
#include<stdio.h>
int main(void) {

	long long int n;
	long long int x[5];
	long long int min = 1000000000000000;

	scanf("%lld", &n);
	for (int i = 0; i < 5; i++) {
		scanf("%lld", &x[i]);
		if (x[i] < min)min = x[i];
	}

	if ((n%min) == 0)printf("%lld\n", n / min + 4);
	else(printf("%lld\n", n / min + 5));

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	int ans = 0;
	for(int i = 0; i < s.size(); ++i) {
		if( s[i] == '2' ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    int n;
    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        int c = 0;
        int j = std::sqrt(i);
        if (j > 1)
        {
            for (int x = 1; x < j; ++x)
            {
                for (int y = 1; y < j; ++y)
                {
                    int k = -3*(x*x) -3*(y*y) - 2*x*y + 4*i;
                    if (k > 0)
                    {
                        float z = (-1*(x+y) + std::sqrt(k)) / 2;
                        if (ceilf(z) == z && z > 0)
                        {
                            c++;
                        }
                    }
                }
            }
        }
        cout << (c) << endl;
    }

    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
int main()
{
	fast;ll t;t=1;
	while(t--)
	{
		ll n;
		cin>>n;
		if(n>=30){cout<<"Yes\n";}
		else{cout<<"No\n";}
	}
}

Measured memory_bytes: 3648
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
ma = A[0]
for i in range(1,n):
    if ma < A[i]:
        A[i] -= 1
    if ma <= A[i]:
        ma = A[i]
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 21976
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int used[4][4];
int main() {
    vector<vector<int>> edge(4);
    REP(i, 3) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    REP(i, 4) {
        if(edge[i].size() == 3) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    std::string S; std::cin >> S;
    int ans(0), cnt(0);
    for(int i(0); i < 3; ++i){
        if(S[i] == 'R') ++cnt;
        else{
            chmax(ans, cnt); cnt = 0;
        }
    }
    chmax(ans, cnt);
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3616
from fractions import gcd


def count(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x = x // 2
    return ans


N, M = map(int, input().split(' '))
a = list(map(lambda x: int(x) // 2, input().split(' ')))

lcm, div2 = a[0], count(a[0])
flag = True

for i in range(1, N):
    lcm = lcm // gcd(lcm, a[i]) * a[i]
    if count(a[i]) != div2:
        flag = False

if flag:
    print((M // lcm + 1) // 2)
else:
    print(0)

Measured memory_bytes: 16316
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

a,b = nn()
c,d = b.split('.')
a,b = int(a),int(c)*100+int(d)

print(a*b//100)

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

#define all(c) c.begin(),c.end()
typedef long long ll;
vector< int > sticks;
int n;

int Bsearch(int sum,int left,int right){
    int index = -1;
    while(left<=right){
        int mid = left + (right-left)/2;
        if(sticks[mid] <= sum)  right = mid - 1;
        else{
            left = mid+1;
            index = mid;
        }
    }
    return index;
}

int main()
{
    //freopen("in.txt","r",stdin);
    int left,right;
    ll cnt = 0;

    cin >> n;

    sticks.resize(n);

    for(int i=0;i<n;i++)    cin >> sticks[i];

    sort(all(sticks),greater< int >());

    for(int i=0;i<n-2;i++){
        left = i+1,right=n-1;
        while(left<right){
            right = Bsearch(sticks[i]-sticks[left],left+1,right);
            if(right == -1)break;
            cnt += right - left;
            left++;
        }
    }

    cout << cnt << endl;
    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int A, B;
    std::cin >> A >> B;

    std::cout << max({A + B, A - B, A * B}) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,a[200001],m1=0,m2=-1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=m1)
		{
			m2=m1; 
			m1=a[i];		
		}
		else if(a[i]>m2)
		{
			m2=a[i];
		}
	}
//	cout<<m1<<m2;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==m1)
		{
			cout<<m2<<endl;
		}
		else
		{
			cout<<m1<<endl;
		}
	}
}


Measured memory_bytes: 2432
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector< vector< pair<int, int> > > G(N);
    for(int i=0; i+1<N; i++) {
        int u, v, w; cin >> u >> v >> w;
        u--, v--, w %= 2;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }

    vector<int> color(N);
    auto dfs = [&](auto&& self, int cur, int par) -> void {
        for(auto e : G[cur]) {
            int to, w; tie(to, w) = e;
            if(to == par) continue;
            color[to] = color[cur] ^ w;
            self(self, to, cur);
        }
    };

    dfs(dfs, 0, -1);
    for(int i=0; i<N; i++) cout << color[i] << endl;
    return 0;
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int N;
    cin >> N;
    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]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}





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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n;
    int ans=1e9;
    cin>>n;

    
    for(ll i = 1; i*i <= n; i++)
    {
        if(n%i!=0) continue;
        ll x = i;
        ll y = n/x;
        int xcnt=0,ycnt=0;
        
        while(x>0){
            x/=10;
            xcnt++;
        }
        while(y>0){
            y/=10;
            ycnt++;
        }
        ans=min(ans, max(xcnt,ycnt));
    }
    
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

string s;

string AKI = "AKIHABARA";

int dfs(int i ,string & build){
  if(i == AKI.size()){
    if(s == build) return 1;
    else return 0;
  }
  if(AKI[i] == 'A'){
    build.push_back('A');
    int temp = dfs(i + 1,build);
    build.pop_back();
    temp |= dfs(i + 1,build);
    return temp;
  }
  else{
    build.push_back(AKI[i]);
    int temp = dfs(i + 1,build);
    build.pop_back();
    return temp;
  }
}

int main(){
  cin >> s;
  string b = "";

  if(dfs(0,b)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int x,y,z;
int n,r;

scanf("%d%d%d",&x,&y,&z);
n = x/(y+z);
r = x%(y+z);
if(r>=z){
	printf("%d\n",n);
}else{
	printf("%d\n",n-1);

}
return 0;
}

Measured memory_bytes: 128