akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

char a[4][4];

inline void Solve () {
	//easy
	for (int i = 1; i <= 3; i ++) {
		for (int j = 1; j <= 3; j ++) {
			cin >> a[i][j];
		}
		cout << a[i][i];	
	}
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int dp[100007];

int MinFrogCost(int *a, int i, int n, int k) {

	if (i > n) return 0;
	if (dp[i] != -1) return dp[i];

	int MN = INT_MAX;
	for (int j = 1; j <= k; j++) {

		if (i + j > n) {
			if (MN == INT_MAX) {
				dp[i] = 0;
				return dp[i];
			}
			break;
		}

		int value = MinFrogCost(a, i + j, n, k);


		MN = min(MN, abs(a[i] - a[i + j]) + value);
	}
	dp[i] = MN;

	return dp[i];
}


int32_t main() {

	FASTIO;
	//IO();

	memset(dp, -1, sizeof(dp));
	int n, k; cin >> n >> k;

	int *arr = new int[n + 3];

	arr[0] = 0;
	arr[n + 1] = 0;
	arr[n + 2] = 0;
	for (int i = 1; i <= n; i++)cin >> arr[i];

	cout << MinFrogCost(arr, 1, n, k) << endl;
	// for (int i = 1; i <= n; i++) {
	// 	cout << dp[i] << " ";
	// }
	return 0;


}


Measured memory_bytes: 12948
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n;
        long maxW;
        n = sc.nextInt();
        maxW = sc.nextLong();
        long weights[] = new long[n+1];
        int values[] = new int[n+1];

        for(int i=1;i<=n;i++){
            weights[i] = sc.nextLong();
            values[i] = sc.nextInt();
        }

        int maxVal = n * 1000;
        long dp[][] = new long[n+2][maxVal+1];

        for(int i=1;i<=maxVal;i++){
            dp[n+1][i] = (long) (1e9 + 1);
        }

        for(int i=n;i>=1;i--){
            for(int j=1;j<=maxVal;j++){
                dp[i][j] = dp[i+1][j];
                if(j-values[i] >= 0){
                    dp[i][j] = Math.min(dp[i][j],weights[i]+dp[i+1][j-values[i]]);
                }
            }
        }

        long ans = 0;
        for(int i=0;i<=maxVal;i++){
            if(maxW >= dp[1][i]){
                ans = i;
            }
        }

        System.out.println(ans);

    }
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll x, a, b; cin >> x >> a >>b;
  fin(abs(x-a) < abs(x-b)?'A':'B')
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 508
#include <cstdio>
#include <ctime>

using namespace std;
using ll = long long;
clock_t s, t;
const int M = 1e7 + 10;
ll arr[M] = {0};

int main() {
    // s = clock();
    for (int i = 1; i < M; i++) {
        arr[i]++;
        for (int j = i + i; j < M; j += i) {
            arr[j]++;
        }
    }
    // t = clock();
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    int k;
    scanf("%d", &k);
    ll ans = 0;
    for (int i = 1; i <= k; i++) {
        ans += i * arr[i];
    }
    printf("%lld", ans);
    // printf("\n%lf", (double)t - s);
    return 0;
}

Measured memory_bytes: 79852
<?php 
fscanf(STDIN, "%d", $n);
$arr = array();
for ($i=1; $i <=sqrt($n) ; $i++) {
  if($n%$i == 0){
    $arr[] = ($n/$i) + $i;
  }
}
sort($arr);

echo $arr[0]-2;

 ?>

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

const LL mod=1e9+7;
LL f[105][64004],ans;

int main()
{
	LL n,N,k;
	scanf("%lld%lld",&N,&k);
	n=sqrt(N);
	for(int i=1;i<=n;++i) f[1][i]=1;
	f[1][n+1]=N/n-n;
	for(int i=n+2;i<=2*n;++i) f[1][i]=N/(2*n+1-i)-N/(2*n+2-i);
	for(int i=2;i<=k;++i) {
		LL sum=0;
		for(int j=2*n;j>=1;--j) {
			(sum+=f[i-1][2*n+1-j])%=mod;
			f[i][j]=sum*f[1][j]%mod;
		}
	}
	for(int i=1;i<=2*n;++i) (ans+=f[k][i])%=mod;
	cout<<ans%mod;
}

Measured memory_bytes: 50944
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
 ll n,m;
 cin>>n>>m;
 bool ver[n+1];
 mems(ver,true);
 ll h[n+1];
 fr(i,1,n+1)
   cin>>h[i];
 
 fr(i,0,m){
   ll u,v;
   cin>>u>>v;
   if(h[u]>h[v])
   ver[v]=false;
   else if(h[u]<h[v])
   ver[u]=false;
   else ver[u]=false ,ver[v]=false;

 }
 ll c=0;

 for(int i=1;i<=n;i++){
   if(ver[i])
   c++;
 }
 cout<<c;
}
int main()
{
    ll t=1;
  //  cin>>t;
    while(t--)
    {
     solve();
     cout<<endl;
    }
	return 0;
}

Measured memory_bytes: 4516
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N, K;

  cin >> N >> K;

  vector<ll> lst(N);

  ll sum = 0;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    sum += tmp;
    lst[i] = tmp;
  }

  vector<ll> lstdiv;
  for (ll i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      lstdiv.emplace_back(i);
      if(i * i != sum){
        lstdiv.emplace_back(sum/i);
      }
    }
  }

  ll ans = 1;
  for (size_t j = 0; j < lstdiv.size(); j++) {
    ll minop = LONG_LONG_MAX;
    vector<ll> lstmod(N);
    for (int i = 0; i < N; i++) {
      lstmod[i] = (lst[i] % lstdiv[j]);
    }  // i
    sort(lstmod.begin(), lstmod.end());
    vector<ll> lstmodacc(N);
    ll acc = 0;
    for (int i = 0; i < N; i++) {
      lstmodacc[i] = acc + lstmod[i];
      acc = lstmodacc[i];
    }

    for (int i = 0; i < N - 1; i++) {
      ll tmp = max(lstmodacc[i], lstdiv[j]*(N-i-1) - (lstmodacc[N-1] - lstmodacc[i]));
      minop = min(minop, tmp);
    }  // i
    if(minop <= K){
      ans = max(ans, lstdiv[j]);
    }
  }  // j

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char ch;
	cin>>ch;
	if(ch >= 97 && ch <= 97 + 26){
		cout<<'a'<<endl;
	}
	else
		cout<<'A'<<endl;
    return 0;
}


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

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

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

  int takahashi = (c + b - 1) / b;
  int tanaka = (a + d - 1) / d;

  if (takahashi > tanaka) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  
  return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string.h>
using namespace std;

int main(void)
{
	int dir[4]= {};
	char plan[1001]= {};

	cin>>plan;
	for(int i= 0; i < strlen(plan); i++)
	{
		switch(plan[i])
		{
		case 'N':
			dir[0]++;
			break;
		case 'E':
			dir[1]++;
			break;
		case 'S':
			dir[2]++;
			break;
		case 'W':
			dir[3]++;
			break;
		}
	}

	if((dir[0] != 0 && dir[2] == 0) || (dir[0] == 0 && dir[2] != 0))
		cout<<"No"<<endl;
	else if((dir[1] != 0 && dir[3] == 0) || (dir[1] == 0 && dir[3] != 0))
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cs: chars, // ノード数
    }

    if cs[2] == cs[3] && cs[4] == cs[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int N,M;
int dp[maxn];
int vis[maxn];
vector<int>v[maxn];

int cal(int i){
	if(vis[i])return dp[i];
	vis[i]=1;
	for(auto j:v[i]){
		dp[i]=max(dp[i],cal(j)+1);
	}
	return dp[i];
}
int main()
{
	io();
	//memset(dp,0,sizeof(dp));
	cin>>N>>M;
	int t1,t2;
	for(int i=1;i<=M;++i){
		cin>>t1>>t2;
		v[t1].emplace_back(t2);
	}
	int ans=-1;
	for(int i=1;i<=N;++i){
		ans=max(cal(i),ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int a[200000];
long long sum[200002];


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

	int n;
	cin >> n;
	map<long long, unsigned long long> m;
	vector<long long> v;
	for( int i = 0; i < n; i++ )cin >> a[i];
	sum[0] = 0;
	m[0]++;
	unsigned long long ret = 0;
	for( int i = 0; i < n; i++ )
	{
		sum[i + 1] = sum[i] + a[i];
		m[sum[i + 1]]++;
		if( m[sum[i + 1]] == 2 )v.push_back(sum[i + 1]);
	}
	for( int i = 0; i < v.size(); i++ )ret += m[v[i]] * ( m[v[i]] - 1 );
	cout << ret / 2 << endl;

	return 0;
}


Measured memory_bytes: 15104
n = int(input())
mod = 10 ** 9 + 7

def nprf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                if not j in pf:
                    pf[j] = 0
                pf[j] += 1
                i //= j
    return pf
    
cnt = 1
for v in nprf(n).values():
    cnt *= (v + 1)
    
print(cnt % mod)

Measured memory_bytes: 3060
import math

N, K = list(map(int,input().split()))

def f(x, y):
    return math.ceil(math.log2(y / x))

ans = 0
for i in range(1, min(N, K) + 1):
    temp = (0.5) ** f(i, K)
    ans += temp
ans /= N

if N > K:
    ans += (N - K) / N
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    int x=a+b;
    int y=a-b;
    int z=a*b;
    if(x>=y&&x>=z)cout<<x;
    else if(x<=y&&y>=z) cout<<y;
    else if(z>=x&&z>=y) cout<<z;

    }


Measured memory_bytes: 256
n,m = map(int,input().split())
l = [[int(x) for x in input().split()[1:]] for i in range(m)]
odd_even = [int(x) for x in input().split()]


num = 0
limit = 2**n
ans = 0
while(num < limit):
    
    isOK = True
    for i in range(m):
        cnt = 0
        for x in l[i]:
            if((num >> (x-1)) & 1):
                cnt += 1
        
        if(cnt%2!=odd_even[i]):
            isOK = False
            break        
        
    if(isOK):
        ans += 1    
    
    num += 1

print(ans)

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        long[][] dp = new long[n + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            dp[i][i] = 0;
        }

        for (int k = 1; k <= n; k++) {
            for (int i = 0; i + k <= n; i++) {
                int j = i + k;
                if ((n - k) % 2 == 0) {
                    dp[i][j] = Math.max(dp[i][j - 1] + a[j - 1], dp[i + 1][j] + a[i]);
                } else {
                    dp[i][j] = Math.min(dp[i][j - 1] - a[j - 1], dp[i + 1][j] - a[i]);
                }
            }
        }

        System.out.println(dp[0][n]);
    }
}


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

vector<int> a;
vector<vector<int>> graph;
vector<int> ans;
int inf = 1e9;

void dfs(int u, int p, vector<int>& dp) {
    int idx = -1;
    int value = -1;
    int targetIdx = lower_bound(dp.begin(), dp.end(), a[u]) - dp.begin();
    if (dp[targetIdx] > a[u]) {
        idx = targetIdx;
        value = dp[targetIdx];
        dp[targetIdx] = a[u];
    }
    ans[u] = lower_bound(dp.begin(), dp.end(), inf) - dp.begin() - 1;

    for (int v : graph[u]) {
        if (v == p) {
            continue;
        }
        dfs(v, u, dp);
    }
    if (idx != -1) {
        dp[idx] = value;
    }
}

int main() {
    int N;
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    graph.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    ans.resize(N);
    vector<int> dp(N + 1, inf);
    dp[0] = 0;
    dfs(0, -1, dp);
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 30692
#
# Setting Go Stones
#

while (n=gets.to_i)!=0

  stone=[]
  count=[]

  stone<<gets.chomp
  count<<1

  2.upto(n) do |i|
    s=gets.chomp
    if i.even?
      if stone[-1]!=s
        stone[-1]=s
        count[-1]+=1
        # マージ
        (stone.size-2).downto(0) do |j|
          if stone[j]!=s
            stone[j]=s
            count[j]+=count[j+1]
            stone.pop
            count.pop
          else
            break
          end
        end
        if stone[-2]==s
          count[-2]+=count[-1]
          stone.pop
          count.pop
        end
      else
        count[-1]+=1
      end
    else
      if stone[-1]==s
        count[-1]+=1
      else
        stone<<s
        count<<1
      end
    end
  end

  sum=0
  stone.each_with_index do |s, i|
    sum+=count[i] if s=='0'
  end
  puts sum

end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
  //入力
  long N,K;
  cin>>N>>K;
  vector<long>H(N);
  for(long i=0;i<N;i++){
    cin>>H[i];
  }
  long cnt=0;
  vector<long>A;
  if(N<=K){
    cout<<cnt<<endl;
  }else{
    sort(H.begin(),H.end());
    for(int i=0;i<N-K;i++){
      A.push_back(H[i]);
    }
    for(int i=0;i<A.size();i++){
      cnt+=A[i];
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

s = input()

isStartwithA = False
has1CinMiddle = False
otherArelower = True

if list(s)[0] == "A":
    isStartwithA = True


sample = list(s)[2:-1]
if sample.count("C") == 1:
    has1CinMiddle = True

sample2 = list(s)
sample2 = list(set(sample2))

try:
    sample2.remove("A")
    sample2.remove("C")
except:
    pass
    isStartwithA = False
    has1CinMiddle = False

#print(sample2)

for word in sample2:
    if (not word.islower()):
        otherArelower = False

if isStartwithA and has1CinMiddle and otherArelower:
    print("AC")
else:
    print("WA")


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b){
        rep(i,a) cout << b;
    }
    else if(a < b){
        rep(i,b) cout << a;
    }
    else rep(i,a) cout << a;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n,pp,tp,i,csum=0,psum=0,ans=0;
  cin>>n>>pp>>tp;
  int pc;
  cin>>pc;
  vector<int>v(n);
  for(i=0;i<n;i++){
    cin>>v[i];
  }
  csum=pc;
  psum=pp;
  sort(v.begin(),v.end());
  for(i=n-1;i>-1;i--){
    csum+=v[i];
    psum+=tp;
    ans=max(ans,csum/psum);
    //cout<<csum/psum<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3156
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second 

using namespace std;

int main() {
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    long double l;
    cin >> l;

    cout << fixed << setprecision(12) << l / 27.0 * l * l;

    return 0;
}

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

int main(void){
    int i,n,ans,m;
    ans = 1;
    cin >> n;

    int p[n+10];
    for(i=1; i<=n; i++){
        cin >> p[i];
    }

    m = p[1];

    for(i=2; i<=n; i++){
        m = min(m,p[i]);
        if( m == p[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

void solv()
{
	int n; scanf("%d", &n);
	int p[100];
	for (int i = 0; i < n; i++){
		 scanf("%d", p + i);
	}
	int cnt = 0;
	for (int i = 1; i < n - 1; i++){
		if (p[i - 1] < p[i] && p[i] < p[i + 1]){
			cnt++;
		}
		if (p[i + 1] < p[i] && p[i] < p[i - 1]){
			cnt++;
		}
	}

	printf("%d", cnt);

	
	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w;
    cin >> h >> w;
    int c[10][10];
    rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
    rep(k, 0, 10) {
        rep(i, 0, 10) {
            rep(j, 0, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, 0, h) {
        rep(j, 0, w) {
            int a;
            cin >> a;
            if (a != -1) {
                ans += c[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint M;
    cin >> M;
    cout << 24 + 24 - M << "\n";
}

Measured memory_bytes: 256
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

amod= a%10
bmod= b%10
cmod= c%10
dmod= d%10
emod= e%10

p(a,b,c,d,e)
p(amod,bmod,cmod,dmod,emod)

x=9

from math import ceil

if amod==bmod==cmod==dmod==emod==0:
  ans=a+b+c+d+e
else:
  if amod!=0: x=min(x,amod)
  if bmod!=0: x=min(x,bmod)
  if cmod!=0: x=min(x,cmod)
  if dmod!=0: x=min(x,dmod)
  if emod!=0: x=min(x,emod)
  ans= (ceil(a/10)*10)+(ceil(b/10)*10)+(ceil(c/10)*10)+(ceil(d/10)*10)+(ceil(e/10)*10)-10+x

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using M = map<int, int>;
ll INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll sum = accumulate(a.begin(), a.end(), 0);

  bitset<(ll)5e6> dp;
  dp[0] = 1;
  rep(i, n) {
    dp |= (dp << a[i]);
  }

  repI(i, (sum+1)/2, sum+1) {
    if (dp[i]) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 2048
/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            PrintWriter ot=new PrintWriter(System.out);
            int t=Integer.parseInt(br.readLine().trim());
            // int total=0;
            while(t-->0)
            {
                ot.print("ACL");
                
            }
            ot.close();
            br.close();
            
        } catch(Exception e){
            System.err.println("ERROR");
            return;
        }
    }
}
    

Measured memory_bytes: 32336
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 200050
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n;
ll a[N],h[N];

struct ST{
	ll t[2*N];
	ST(){ fill(t,0); }
	ll query(int l, int r){
		ll ans = 0;
		for(l += n, r += n; l < r; l >>= 1, r >>= 1){
			if(l&1) ans = max(ans,t[l++]);
			if(r&1) ans = max(ans,t[--r]);
		}
		return ans;
	}
	void update(int p, ll v){
		for(t[p+=n] = v; p >>= 1; ) t[p] = max(t[p<<1],t[p<<1|1]);
	}
};

ST st;

int main(){

	fastio;
	cin >> n;
	FER(i,0,n) cin >> h[i];
	FER(i,0,n) cin >> a[i];

	n++;
	ll ans = 0;
	for(int i = 0; i < n; ++i)
		st.update(h[i],st.query(0,h[i])+a[i]);
	cout << st.query(0,n) << endl;

	return 0;
}


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

using namespace std;

const int N = 5050;

int a[N];
long long f[N];

int main() {
	int n, A, B;
	scanf("%d %d %d", &n, &A, &B);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	a[0] = 0;
	a[n + 1] = n + 1;
	f[0] = 0;
	for (int i = 1; i <= n + 1; ++i) {
		f[i] = 1e18;
		int cnt = 0;
		for (int j = i - 1; j >= 0; --j) {
			if (a[i] > a[j]) {
				f[i] = min(f[i], f[j] + (long long) A * cnt + (long long) B * (i - j - 1 - cnt));
			} else {
				++cnt;
			}
		}
	}
	printf("%lld\n", f[n + 1]);	
}


Measured memory_bytes: 256
#include<stdio.h>

int count=0;
int stack[100];

void push(int);
int sumpop(void);

int main(){
  int x;
  char s[100];
  int a,b;
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      a=pop();
      b=pop();
      push(b-a);
    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[count]);
  return 0;
}

void push(int x){
  stack[++count]=x;
}

int pop(){
  count--;
  return stack[count+1];
}

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

int main(){
	int a;
	cin>>a;
	for(int i=1;i<=50000;i++){
		if((int)(1.08*i) == a){
			cout<<i<<endl;
			return(0);
		}
	}
	cout<<":("<<endl;

	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N;
int sevencounter=0,fivecounter=0,threecounter=0,ans=0;
void dfs(int s){
  if(s>N) return;
  string n=to_string(s);
  sevencounter=0,fivecounter=0,threecounter=0;
  for(int i=0;i<n.size();i++){
    if(n[i]=='7') sevencounter++;
    else if(n[i]=='5') fivecounter++;
    else if(n[i]=='3') threecounter++;
  }
  if(sevencounter>=1 && fivecounter>=1 && threecounter>=1) ans++;
  dfs(s*10+3);
  dfs(s*10+5);
  dfs(s*10+7);
}

signed main(){
  cin >> N;
  dfs(0);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#O(n)で実装
n,m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
rest = sorted(lst, key=lambda x:x[1], reverse=False)
ans = 1
et = rest[0][1] #end_time
for i in range(len(rest)):
    if rest[i][0]>=et:
        et=rest[i][1]
        ans+=1
print(ans)

Measured memory_bytes: 29848
#include <bits/stdc++.h>
using namespace std;
#define REP(n) for(int i=0;i<(int)(n);i++)
int main() {
  int n,k;long long S=0;cin>>n>>k;vector<int>h(n);
  REP(n)cin>>h[i];sort(h.begin(),h.end());REP(n-k)S+=h[i];
  cout<<S<<endl;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=1e2+10,mod=1e9+7,M=1e5+100;
/*E*/

ll dp[N][M];
ll w[N];
ll v[N];

int32_t main(){
    ll n,k;
    cin >> n >> k;
    for (int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }

    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            dp[i][j]=(ll)1e12;
        }
    }
    for (int i=0;i<N;i++){
        dp[i][0]=0;
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=M;j++){
            dp[i][j]=dp[i-1][j];
            if (v[i]<=j){
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
            }
        }
    }
    ll ans=0;
    for (int i=0;i<M;i++){
        if (dp[n][i]<=k){
            ans=i;
        }
    }
    cout << ans;
}


Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<vector<int> >G(210);
int color[210];
bool is_BG(int i,int p,int c){
    if(color[i]!=0){
        if(color[i]==c)return 1;
        else return 0;
    }
    color[i]=c;
    bool f=1;
    for(auto e:G[i]){
        if(e==p)continue;
        if(c==1){
            f&=is_BG(e,i,2);
        }else{
            f&=is_BG(e,i,1);
        }
    }
    return f;
}
int main(){
    int n;cin>>n;
    vector<vector<int> >g(n,vector<int>(n));
    rep(i,n){
        rep(j,n){
            char y;
            cin>>y;
            g[i][j]=y-'0';
        }
    }
    rep(i,n)rep(j,i){
        if(g[i][j]){
            G[i+1].pb(j+1);
            G[j+1].pb(i+1);
        }
    }
    if(!is_BG(1,0,1)){
        cout<<-1<<endl;
        return 0;
    }
    int ma=0;
    int dis[210]={0};
    REP(i,1,n+1){
        fill(dis,dis+n+1,-1);
        int ma1=1;
        queue<int>q;
        q.push(i);
        dis[i]=1;
        while(!q.empty()){
            int k=q.front();
            q.pop();
            for(auto e:G[k]){
                if(dis[e]!=-1)continue;
                q.push(e);
                dis[e]=dis[k]+1;
            }
            ma1=max(ma1,dis[k]);
        }
        ma=max(ma1,ma);
    }
    cout<<ma<<endl;
}

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

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

int main() {

  	// 入力
	int N,L;
	int i, taste[1000], min = 1000, sum = 0, minmin = 1000;

  	cin >> N >> L;

	REP(i, N){
		taste[i] = L + i ;
		sum += taste[i];
		if( min > abs(taste[i]) ){
			min = abs(taste[i]);
			minmin = taste[i];
		}
	}
	sum -= minmin;

  	cout << sum  << endl;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main() {
	string S; cin >> S;
	int m = 0;
	for(char c : S) {
		m = (m + (c - '0'));
		if(m >= 9) m -= 9;
	}
	cout << (m ? "No" : "Yes");
}


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

int main() {
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(),a.end());
  
  int64_t ans=0;
  rep(i,n-k) ans += a[i];
  
  cout << ans << endl;
    
}


Measured memory_bytes: 1792
from operator import mul
from functools import reduce
from collections import Counter
# from itertools import combinations as comb
# from itertools import permutations as perm
# from copy import copy
# 配列二分法アルゴリズム
# https://docs.python.jp/3/library/bisect.html
# import bisect
# 桁数指定
# print('{:.3f}'.format(X))
# from collections import defaultdict
# dic = defaultdict(lambda: ...)
# 値で辞書をソート
# sorted(dic.items(), key=lambda x:x[1])
# ヒープキュー
# https://docs.python.org/ja/3/library/heapq.html
# import heapq
# 正規表現(regular expression)のためのモジュール
# import re

import sys

sys.setrecursionlimit(2000)


def inpl():
    return list(map(int, input().split()))


# 重複組み合わせは nHr = (n + r - 1)Cn
def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N = int(input())
A = inpl()

cumA = [0]
for a in A:
    cumA.append(cumA[-1] + a)

# print(cumA)
print(sum(cmb(v, 2) for k, v in Counter(cumA).items()))


Measured memory_bytes: 41964
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    float N; cin >> N;
    
    float odd = 0;
    for(int i = 0; i <= N;i++){
        if(i % 2 == 1) odd+=1;
    }
    
    cout << odd / N << "\n";
}


Measured memory_bytes: 384
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
99992
'''

def sieve(x):
	prime = [1]*(2*x+1)
	for i in range(2,int(sqrt(2*x+1))+1):
		zz = 2
		while(i*zz <= 2*x):
			prime[i*zz] = 0
			zz += 1
	prime[0] = prime[1] = 0
	return prime

def solve(x):
	prime = sieve(x)
	for i in range(x,len(prime)):
		if(prime[i]):
			return i

N = int(stdin.readline())
ans = solve(N)
print(ans)



Measured memory_bytes: 85096
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
class UF{
public:
	vector<int> par,num;
 
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UF(int N):par(N),num(N,1){
		iota(par.begin(),par.end(),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),orga(n),orgb(n);
    map<int,int> mp,search,search2;
    for(int i=0;i<n;i++){
        cin>>a[i];
        orga[i]=a[i];
        mp[a[i]]=i;
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        orgb[i]=b[i];
    }
    sort(all(a));
    sort(all(b));
     for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            return cout<<"No"<<endl,0;
        }
        search[b[i]]=a[i];
        search2[a[i]]=b[i];
    }
    bool ok=false;
    for(int i=0;i<n-1;i++){
        if(a[i+1]<=b[i])ok=true;
    }
    if(ok)cout<<"Yes"<<endl;
else {
   UF u(n);
   for(int i=0;i<n;i++){
        if(search2[orga[i]]!=orgb[i]){
            u.unite(i,mp[search[orgb[i]]]);
            }
        }
   if(u.size(0)<n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 17280
### main

loop do
  n, m = gets.strip.split(' ').map{|s| s.to_i}
  break if (n | m) == 0

  masu = n.times.map{gets.strip.to_i}
  ds = m.times.map{gets.strip.to_i}
  #p masu
  #p ds

  goal = n - 1
  x = 0
  num = 0

  for d in ds
    num += 1
    x += d
    break if x >= goal
    x += masu[x]
    break if x >= goal
  end

  puts num
end

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1e3;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
struct edge
{
	int to,next;
}e[2*N];
int head[N],cnt=0,dis[N];
void add(int u,int v)
{
	e[++cnt].to=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}
void dfs1(int now,int father,int Dis)
{
	dis[now]=Dis;
	for (int i=head[now];i;i=e[i].next)
	if (e[i].to!=father)
	dfs1(e[i].to,now,Dis+1);
}
int dfs2(int now,int father,int Dis)
{
	if (dis[now]<Dis) return 0;
	int ret=dis[now]-1;
	if (dis[now]!=Dis)
	for (int i=head[now];i;i=e[i].next)
	if (e[i].to!=father)
	ret=max(ret,dfs2(e[i].to,now,Dis+1));
	return ret;
}

int main()
{
	int n=read(),u=read(),v=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add(x,y);
		add(y,x);
	}
	dfs1(v,0,0);
	print(dfs2(u,0,0));

	return 0;
}

Measured memory_bytes: 6400
package main

import "fmt"

func main() {
	var K, A, B int
	fmt.Scan(&K, &A, &B)
	if B-A < 2 {
		fmt.Println(K + 1)
		return
	}

	// A枚溜まったらABを繰り返すのが一番いい
	// Aまい貯まるまで A-1ターン
	AB := (K - (A - 1))
	if AB <= 0 {
		fmt.Println(K + 1)
		return
	}

	amari := AB % 2
	AB -= amari

	// Kは偶数

	fmt.Println(A + (B-A)*AB/2 + amari)
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   string s;
   cin >> s;
   s[3] = '8';
   cout << s << endl;

   return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define endl '\n'

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

	int n, a, b, c;	// a = 0	b = 1	c = 2
	cin >> n;
	int dp[n+1][3];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	for(int i=1; i<=n; i++)
	{
		cin >> a >> b >> c;
		dp[i][0] = a + max( dp[i-1][1] , dp[i-1][2] );
		dp[i][1] = b + max( dp[i-1][0] , dp[i-1][2] );
		dp[i][2] = c + max( dp[i-1][0] , dp[i-1][1] );
	}
	cout << max( dp[n][0] , max( dp[n][1] , dp[n][2] ) );
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    double a = 30.0*H+0.5*M;
    double b = 6.0*M;
    double x = abs(a-b)*M_PI/180;
    cerr << a << "\t" << b << endl;
    printf("%.12lf\n",sqrt(1.0*A*A+1.0*B*B-2.0*A*B*cos(x)));
    return 0;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  // 前処理
  //COMinit();

	ll N,K;
  cin>>N>>K;
  ll ans=0;
  if(N==K)ans=N*2;
  else ans=max(N,K)*2-1;

  cout<<ans<<endl;


  return 0;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
 int n;
 cin>>n;
 int ans=0,ans2=1;
 for(int i=1;i<=n;i++){
   int j=0,k=i;
   while(!(k%2)){
     j++;
     k/=2;
   }
  if(j>ans){
    ans=j;
    ans2=i;
  }
 }
 cout<<ans2<<endl;



}


        


Measured memory_bytes: 256