akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
     
    public class Main{
      public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble();
        double c = (2 * x) / Math.pow(a, 2) - b;
        if(c >= 0){
          double lengthalpha = b - c;
          double lengthbeta = Math.sqrt(Math.pow(a, 2) + Math.pow(lengthalpha, 2));
          double siny = a / lengthbeta;
          double y = Math.asin(siny);
          double degree = Math.toDegrees(y);
          System.out.println(180 - 90 - degree);
        }
        if(c < 0){
          double lengthganma = 2 * x / (a * b);
          double lengthdelta = Math.sqrt(Math.pow(b,  2) + Math.pow(lengthganma, 2));
          double sinz = lengthganma / lengthdelta;
    	  double z = Math.asin(sinz);
    	  double degree2 = Math.toDegrees(z);
    	  System.out.println(180 - 90 - degree2);
    	}
      }
    }
          

Measured memory_bytes: 25172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
int dp[1001][1<<12];
int main()
{
	int n,m;
	ll ans=0;
	cin>>n>>m;
	fill(dp[0],dp[1001],1e9-1);
	dp[0][0]=0;
	for(int i=1;i<m+1;i++)
	{
		int a,b,key;
		key=0;
		cin>>a>>b;
		for(int j=0;j<b;j++)
		{
			int t;
			cin>>t;
			t--;
			key|=(1<<t);
		}
		for(int j=0;j<(1<<n);j++)
		{
			if(dp[i-1][j]!=1e9-1)
			{
				//買わない
				dp[i][j]=min(dp[i-1][j],dp[i][j]);
				//買う
				dp[i][j|key]=min(dp[i][j|key],dp[i-1][j]+a);
			}
		}
	}
	if(dp[m][(1<<n)-1]==1e9-1)
		cout<<-1<<endl;
	else
		cout<<dp[m][(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll func(ll n, vector<ll>&arr){
    vector<ll>dp(n, 0);
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i = 2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    return dp[n-1];
}
int main(){
    ll n;
    cin>>n;
    vector<ll>arr(n);
    for(ll i = 0 ; i < n ; i++){
        cin>>arr[i];
    }
    cout<<func(n, arr);
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string[] AB = Console.ReadLine().Split(' ');
            int A = int.Parse(AB[0]);
            int B = int.Parse(AB[1]);

            for (int i = A; i <= B; i++)
            {
                if(i % K == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }

            Console.WriteLine("NG");            
        }
    }
}


Measured memory_bytes: 27384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mmax = 1e5 + 5;
char str1[mmax], str2[mmax];
int gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int main()
{
	ll n, m, N, M;
	scanf("%lld%lld", &n, &m);
	scanf("%s%s", str1, str2);
	ll gcdd = gcd(n, m);
	N = n / gcdd;
	M = m / gcdd;
	ll lcm = n*m / gcdd;
	int flag = 1;
	for (int i = 0, j = 0;str1[i] && str2[j];i += N, j += M)
		if (str1[i] != str2[j]) { flag = 0;break; }
	if (flag)printf("%lld\n", lcm);
	else printf("-1\n");
	//system("pause");
}

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

Measured memory_bytes: 22228
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let a: Vec<i64> = read_vec();
    let mut heap_forward = BinaryHeap::new();
    let mut heap_forward_sum = vec![0i64; n * 3];
    for i in 0..n * 3 {
        heap_forward.push(-a[i]);
        heap_forward_sum[i] = a[i];
        if i > 0 {
            heap_forward_sum[i] += heap_forward_sum[i - 1];
        }
        if heap_forward.len() > n {
            heap_forward_sum[i] += heap_forward.pop().unwrap();
        }
    }

    let mut heap_backward = BinaryHeap::new();
    let mut heap_backward_sum = vec![0i64; n * 3];
    for i in 0..n * 3 {
        let i = 3 * n - i - 1;
        heap_backward.push(a[i]);
        heap_backward_sum[i] = a[i];
        if i < 3 * n - 1 {
            heap_backward_sum[i] += heap_backward_sum[i + 1];
        }
        if heap_backward.len() > n {
            heap_backward_sum[i] -= heap_backward.pop().unwrap();
        }
    }
    println!(
        "{}",
        (n - 1..2 * n)
            .map(|x| heap_forward_sum[x] - heap_backward_sum[x + 1])
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 18292
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int stack[110];
int top = 0;

void push(int v){ stack[top++] = v; }
int  pop(){ return stack[--top]; }
int getInt(char *s)
{
  int i,ret=0;
  int size = strlen(s);
  for(i=0;i<size;i++)
    {
      ret += (s[i]-'0')*pow(10,size-i-1);
    }
  return ret;
}

int main()
{
  char s[1000];
  while(scanf("%s",s)!=EOF)
    {
      if('0' <= s[0] && s[0] <= '9')
	{
	  int v = getInt(s);
	  push(v);
	  continue;
	}
	  int a,b;
	  b = pop();
	  a = pop();
	  if(s[0] == '+')
	      push(a+b);
	  else if(s[0] == '-')
	    push(a-b);
	  else if(s[0] == '*')
	    push(a*b);
	  else 
	    assert(0);
    }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;
int a[100010];
int main(){
	int i,n,k,s;
	cin >> n >> k >> s;
	for(i=0;i<k;i++){
		a[i] = s;
	}
	if(s>n - k){
		for(i=k;i<n;i++){
			a[i] = 1;
		}
	}else{
		for(i=k;i<n;i++){
			a[i] = s + 1;
		}
	}
	for(i=0;i<n;i++){
		cout << a[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1664
a, b, c = map(int, input().split())
a1 = max(a,b,c)
c1 = min(a,b,c)
b1 = a+b+c-a1-c1

if b1%2 ==c1%2:
    print(int((2*a1-c1-b1)/2))
else:
    print(int((2*(a1+1)-c1-b1)/2)+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int N; cin >> N;
    ll a[110000][3];
    REP(i, N) REP(j, 3) cin >> a[i][j];

    ll dp[110000][3];
    REP(i, N) {
        REP(j, 3) {
            REP(k, 3) {
                if (j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll ans = 0;
    REP(i, 3) chmax(ans, dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 5120
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, l := nextInt(), nextInt()
	sum := 0
	for i := 0; i < n; i++ {
		sum += l + i
	}

	if l >= 0 {
		sum -= l
	} else if -1 * l >= n {
		sum -= l + n - 1
	}

	fmt.Println(sum)
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll to_id(ll a, ll b) {
    if (a > b) swap(a, b);
    return 5005 * a + b;
}

void Main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    Graph graph(N);
    rep(i, N - 1) {
        graph[i].push_back(i + 1);
        graph[i + 1].push_back(i);
    }
    X--;
    Y--;
    graph[X].push_back(Y);
    graph[Y].push_back(X);
    map<ll, ll> ans;
    set<ll> used;
    rep2(i, 1, N) {
        vector<ll> dist(N, -1);
        dist[i] = 0;
        queue<P> que;
        que.push({i, 0});
        while (!que.empty()) {
            P p = que.front();
            que.pop();
            for (ll v: graph[p.first]) {
                if (dist[v] == -1) {
                    dist[v] = p.second + 1;
                    que.push({v, dist[v]});
                }
            }
        }
        // print(dist);
        rep(x, N) {
            if (i == x) continue;
            ll id = to_id(i, x);
            if (used.count(id)) {
                continue;
            }
            ll d = dist[x];
            ans[d]++;
            used.insert(id);
        }
        //print(ans);
    }
    rep(i, N - 1) {
        cout << ans[i + 1] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 94208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
vector<string> Data;
bool ispos(ll k,ll n,ll m,ll row,ll col){
    ll cnt = 0;
    ll i, j;
    for (i = 0; i < n;i++){
        for (j = 0; j < m;j++){
            if(getbit(row,i)==0&&getbit(col,j)==0&&Data[i][j]=='#')
                cnt++;
        }
    }
    return cnt == k;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n >> m >> k;
    for (i = 1; i <= n;i++){
        string s;
        cin >> s;
        Data.pb(s);
    }
    ll ans = 0;
    for (i = 0; i < (1LL << n);i++){
        for (j = 0; j < (1LL << m);j++){
            if(ispos(k,n,m,i,j))
                ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  int ac,bc,cc;
  ac=0;
  bc=0;cc=0;
  string vec;
  cin >> vec;
  for(int i=0;i<3;i++){
    if(vec.at(i)=='a'){
      ac++;
    }
    if(vec.at(i)=='b'){
      bc++;
    }
    if(vec.at(i)=='c'){
     cc++;
    }
  }
  if(ac==1&&bc==1){
    if(cc==1){
      cout << "Yes" << endl;
    }
    else{
      cout <<"No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<intmax_t> p(n);
  for (auto& pi: p) scanf("%jd", &pi);
  std::vector<intmax_t> j(n-1);
  for (auto& ji: j) scanf("%jd", &ji);

  intmax_t lsum = std::accumulate(p.begin(), p.end(), 0LL);
  intmax_t res = lsum;
  lsum += std::accumulate(j.begin(), j.end(), 0LL);
  std::sort(j.rbegin(), j.rend());
  for (intmax_t i = 1; i <= n; ++i) {
    // fprintf(stderr, "%jd * %jd\n", i, lsum);
    res = std::max(res, i * lsum);
    if (!j.empty()) {
      lsum -= j.back();
      j.pop_back();
    }
  }
  printf("%jd\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);
int cost(int a, int b) {
  return (a-b)*(a-b);
}
int main() { BUFF
  int best_cost = INF;
  int n; cin >> n;
  vi a(n);
  for(auto &it : a) cin >> it;
  for(int i=-100; i<=100; i++) {
    int cur_cost = 0;
    for(auto it : a)   
      cur_cost += cost(i, it);
    best_cost = min(best_cost, cur_cost);
  }
  cout << best_cost << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define inf 20021225
using namespace std;

char ch[200100];
int main()
{
	scanf("%s",ch+1);
	int n=strlen(ch+1);ll ans=0,tmp=0;
	for(int i=n;i;i--)
	{
		if(ch[i]=='W')	tmp++;
		else	ans+=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int n,m;
vector<vector<int>> g;
vector<bool> vis;
int cnt;
void dfs(int s){
    vis[s]=1;
    ++cnt;
    for(auto e:g[s]){
        if(!vis[e])dfs(e);
    }
}

void solve()
{
    cin>>n>>m;
    vis.resize(n+1);
    g=vector<vector<int>>(n+1);

    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            cnt=0;
            dfs(i);
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<"\n";
}

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

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

using namespace std;

typedef long long ll;

int dp[3];
int ndp[3];
int n;

void solve() {
  cin >> n;
  while(n--) {
    memset(ndp, 0, sizeof(ndp));
    for(int i = 0; i < 3; i++) {
      int inc;
      cin >> inc;
      for(int j = 0; j < 3; j++) {
        if(j != i) {
          ndp[i] = max(ndp[i], dp[j] + inc);
        }
      }
    }
    memcpy(dp, ndp, sizeof(dp));
  }
  sort(dp, dp+3);
  cout << dp[2] << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1E5+7;
struct stu{
    int w,v;
    bool friend operator <(const stu &x ,const stu &y) {
        return x.w<y.w;
    }
}arr[N];
int dp[N];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>arr[i].w>>arr[i].v;
    sort(arr+1,arr+1+n);
    for(int i=1;i<=n;i++) {
        for(int j=m+arr[i].w-1;j>=arr[i].w;j--){
            dp[j]=max(dp[j],dp[j-arr[i].w]+arr[i].v);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(dp[m+arr[i].w-1],ans);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int count = 0;
        for(int i = 0; i < n - 2; i++)
        {
            if ((p[i] <= p[i + 1] && p[i + 1] < p[i + 2])
                || (p[i] > p[i + 1] && p[i + 1] >= p[i + 2]))
            {
                count++;
            }
        }
        Console.WriteLine(count);
     }
}


Measured memory_bytes: 13396
import math

A, B, H, M = map(int, input().split())

Minute_angle = (M / 60) * 2 * math.pi
Time_angle = (H + (M / 60)) * math.pi / 6
theta = Minute_angle - Time_angle
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
print(ans)

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
  int a,b,x;
 
  cin >> a >> b >> x;
 
  int cost = 0;
 
  while(x > 0){
    if(x <= 500){
      cost += min(a,b);
      break;
    }
 
    cost += min(a,b*2);
    x -= 1000;
  }
 
  cout << cost << endl;
 
  return 0;
}


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

int     main() {
        int N, M, X, Y;
        cin >>N >>M >>X >>Y;
        string S="No War";
        string W="War";
        int x=X, xx;
        int y=Y, yy;
        for (int i=0; i<N; i++) {
                cin >>xx;
                x=max(x, xx);
        }
        for (int i=0; i<M; i++) {
                cin >>yy;
                y=min(y, yy);
        }
        if (x>=y) S=W;
        cout <<S << endl;
        return 0;
}

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

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> ans(2*(N+W), 0);
  ans[0] = W;
  for(int i = 1; i <= W/2; ++i){
    ++ans[i+1];
  }
  for(int i = W/2+1; i < W; ++i){
    for(int j = 3; j*i <= N; ++j){
      ++ans[j*i-W+1];
      --ans[j*i-W+1+W-i];
    }
  }
  for(int i = 1; i <= N-W+2; ++i){
    ans[i] += ans[i-1];
  }
  cout << ans[1];
  for(int i = 2; i <= N-W+1; ++i) cout << " " << ans[i];
  cout << endl;
  return 0;
}



Measured memory_bytes: 4368
package main

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

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	var ch, cw int
	fmt.Scan(&ch, &cw)
	ch--
	cw--
	var dh, dw int
	fmt.Scan(&dh, &dw)
	dh--
	dw--

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ss := make([][]byte, h)
	for i := range ss {
		sc.Scan()
		ss[i] = []byte(sc.Text())
	}

	cs := make([][]int, h)
	for i := range cs {
		cs[i] = make([]int, w)
	}

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

	nqs := make([][]int, 0)
	iqs := make([][]int, 0)
	iqs = append(nqs, []int{ch, cw, 0})
	for len(iqs) > 0 {
		qs := make([][]int, 0)
		qs = append(qs, iqs...)
		nqs := make([][]int, 0)
		for len(qs) > 0 {
			q := qs[0]
			qs = qs[1:]
			y, x := q[0], q[1]
			//fmt.Println("y,x: ", y, x)
			for i := range dx {
				ny, nx := y+dy[i], x+dx[i]
				if ny < 0 || ny >= h || nx < 0 || nx >= w {
					continue
				}
				if cs[ny][nx] == 1 {
					continue
				}
				if ss[ny][nx] == '#' {
					continue
				}
				if ny == dh && nx == dw {
					fmt.Println(q[2])
					return
				}
				cs[ny][nx] = 1
				qs = append(qs, []int{ny, nx, q[2]})
				nqs = append(nqs, []int{ny, nx, q[2]})
			}
		}
		nqs = append(nqs, iqs...)
		iqs = make([][]int, 0)
		for len(nqs) > 0 {
			q := nqs[0]
			nqs = nqs[1:]
			y, x := q[0], q[1]
			for dy := -2; dy <= 2; dy++ {
				for dx := -2; dx <= 2; dx++ {
					if dy == 0 && abs(dx) <= 1 {
						continue
					}
					if dx == 0 && abs(dy) <= 1 {
						continue
					}
					ny, nx := y+dy, x+dx
					if ny < 0 || ny >= h || nx < 0 || nx >= w {
						continue
					}
					if cs[ny][nx] == 1 {
						continue
					}
					if ss[ny][nx] == '#' {
						continue
					}
					if ny == dh && nx == dw {
						fmt.Println(q[2] + 1)
						return
					}
					cs[ny][nx] = 1
					iqs = append(iqs, []int{ny, nx, q[2] + 1})
				}
			}
		}
	}

	fmt.Println(-1)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 24196
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,d,x;
    cin >> n>> d >> x;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        x+=(d-1)/(a)+1;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<bitset>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100][2];

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

	if (n >= 2 * k - 1)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void dfs(vt<string> &s, vvt<int> &dist, int &h, int &w, int x, int y, int d = 0) {
  if(y < 0 || y >= h || x < 0 || x >= w) return;
  if(s[y][x] == '#' || dist[y][x] <= d) return;

  dist[y][x] = d;
  rep(i, 0, 4) dfs(s, dist, h, w, x + dx[i], y + dy[i], d + 1);
}

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

  int h, w;
  cin >> h >> w;
  vt<string> s(h);
  rep(i, 0, h) cin >> s[i];

  int ans = 0;
  rep(i, 0, h) {
    rep(j, 0, w) {
      vvt<int> dist(h, vt<int>(w, INF));
      dfs(s, dist, h, w, j, i);
      rep(a, 0, h) rep(b, 0, w) if(dist[a][b] != INF) ans = max(ans, dist[a][b]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[string]bool)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		m[s] = true
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 20468
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi())
    MOD = 1000000007

    count=[0]*(N+1)
    zero = 0
    ans = 1
    for i in range(N):
        a = A[i]
        if a == 0:
            ans *= (3-zero) % MOD
            zero += 1
        else:
            b = a-1
            ans *= count[b] % MOD
            # print(count[b])
            count[b] -= 1
        
        count[a] += 1
        ans %= MOD

    ans %= MOD
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 84364
let f x y =
    if x < 35.5 &&  y < 71. then "AAA"
    else if x < 37.5 &&  y < 77. then "AA"
    else if x < 40. &&  y < 83. then "A"
    else if x < 43. &&  y < 89. then "B"
    else if x < 50. &&  y < 105. then "C"
    else if x < 55. &&  y < 116. then "D"
    else if x < 70. &&  y < 148. then "E"
    else "NA"
;;

let () =
  let rec read () =
    try let line = read_line ()
            |> Str.split (Str.regexp " ")
            |> List.map float_of_string
            |> Array.of_list
        in
        let (x,y) = (line.(0), line.(1)) in
        Printf.printf "%s\n" (f x y);
        read ()
     with End_of_file -> ()
  in
  read ()
;;

Measured memory_bytes: 2376
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>


using namespace std;


typedef long long ll;


int main() {

	char s[100010];
	int K;

	scanf("%s", s);
	scanf("%d", &K);

	int length = strlen(s);

	// 左から、aに戻せる限り戻していく
	for (int i = 0; i < length-1; i++) {

		if (s[i] == 'a') {
			continue;
		}

		int left_to_a = ('z' + 1) - s[i];

		if (left_to_a <= K) {

			// aに戻す
			s[i] = 'a';
			K -= left_to_a;
		}
		else {
			continue;
		}
	}

	K %= 26;

	// 最後の文字で埋め合わせ
	while (K > 0) {

		s[length - 1] += 1;
		if (s[length - 1] == ('z' + 1)) {
			s[length - 1] = 'a';
		}
		K--;
	}


	printf("%s\n", s);

	return 0;
}

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

using namespace std;

typedef long long ll;

#define debug(x) cout << #x << " : " << x << '\n';


// code //
const int N = 100100;
int n, k;
int h[N], dp[N];

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

	dp[0] = 0;
	for(int i = 1; i < n; ++i) {
		int j = i;
		dp[i] = INT_MAX;
		while(j >= 0 && j >= i - k)
			dp[i] = min(dp[i], dp[j] + abs(h[j--] - h[i]));
	}

	cout << dp[n-1];
}	


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

	#define ONLINE_JUDGE
	#define ll long long
	#define PI 3.14159265359
	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
	#define pb(a) push_back(a)

	//////////// Solution /////////////////////////////////

void solve() {
	int a,p;
	cin >> a >> p;
	cout << (3*a+p)/2 << '\n';
}

		/////////// End Solution ///////////////////////////////////////

		//////// Initialization ////////////////////////////////////

int main() {

			#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
			#endif

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

	solve();

			#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
			#endif

	return 0;
}

		//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        A: usize,
        B: usize,
        C: usize,
    }
    
    if (A == B && A != C)||(A != B && A == C)||(C == B && A != C)  {
        println!("Yes");
    } else {
        println!("No");
    }
    }
    


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

using namespace std;

int main() {
    long long a;
    cin >> a;
    if(a == 0){
        cout << 1;
    }else if(a == 1){
        cout << 2;
    }else{
        for (long long i = a; i <= a * a; i++) {
            long long flag = 1;
            for (long long j = 2; j <= i / 2; ++j){
                if (i % j == 0) {
                    flag = 0;
                    break;
                }
            }
            if(flag && i >= a){
                cout << i;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=3005;
int n,T,a[N],b[N],f[N][N][2],mx;
int main(){
	scanf("%d%d",&n,&T),--T;
	fp(i,1,n)scanf("%d%d",&a[i],&b[i]);
	memset(f,0xef,sizeof(f));
	int inf=f[0][0][0];
	f[0][0][0]=0;
	fp(i,0,n-1){
		fp(j,0,T){
			if(f[i][j][0]!=inf){
				cmax(f[i+1][j][0],f[i][j][0]);
				cmax(f[i+1][j][1],f[i][j][0]+b[i+1]);
				if(j+a[i+1]<=T)cmax(f[i+1][j+a[i+1]][0],f[i][j][0]+b[i+1]);
			}
			if(f[i][j][1]!=inf){
				cmax(f[i+1][j][1],f[i][j][1]);
				if(j+a[i+1]<=T)cmax(f[i+1][j+a[i+1]][1],f[i][j][1]+b[i+1]);
			}
		}
	}
	R int res=0;
	fp(i,0,T)cmax(res,f[n][i][1]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;
	if(A==B && A==C) cout << "No" << endl;
	else if((A==B && A!=C) || (C==B && A!=C) || (A==C && A!=B)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};
use std::cmp::max;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let cs: Vec<_> = lines.next().unwrap().unwrap().chars().collect();
  let n = cs.len();
  let mut c = cs[0];
  let mut i = 0;
  let mut j = 0;
  let mut buf: Vec<usize> = vec![0; n+1];
  while j < n {
    if c == '<' && (j == n - 1 || cs[j+1] == '>') {
      for k in 0..(j-i+1) {
        buf[i+k+1] = max(k+1, buf[i+k+1]);
      }
      if j < n - 1 {
        c = cs[j+1];
        i = j + 1;
      }
    } else if c == '>' && (j == n - 1 || cs[j+1] == '<') {
      for k in 0..(j-i+1) {
        buf[j-k] = max(k+1, buf[j-k]);
      }
      if j < n - 1 {
        c = cs[j+1];
        i = j + 1;
      }
    }
    j += 1;
  }
  println!("{}", buf.iter().sum::<usize>());
}

Measured memory_bytes: 10492
#include <iostream>

using namespace std;

int selectionSort(int a[], int n){
	int count = 0;
	for(int i = 0; i < n; i++){
		int minj = i;
		for(int j = i; j < n; j++){
			if(a[j] < a[minj]) minj = j;
		}
		if(i != minj){
			swap(a[i], a[minj]);
			count++;
		}
	}
	return count;
}

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

	int count = selectionSort(a, n);

	for(int i = 0; i < n; i++){
		if(i) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << count << endl;
}

Measured memory_bytes: 1160
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = list(list(map(int,input().split())) for i in range(m))
#ここに保持しておく
c = 0
q = list([0] for i in range(n))
for j,k in a:
  q[k-1].append(h[j-1])
  q[j-1].append(h[k-1])
for i in range(n):
  a = h[i]
  if a>max(q[i]):
    c += 1
print(c)

Measured memory_bytes: 44292
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int res = h / a;
        if(h % a > 0) res++;
        System.out.println(res);

    }

}


Measured memory_bytes: 23764
#!/usr/bin/env python
def main():
    A, B = list(map(int, input().split()))
    tmp = B
    if A > B:
        B = A
        A = tmp
    
    tmp = (B - A) / 2 + A
    if round(tmp) == tmp:
        return int(tmp)
    else:
        return 'IMPOSSIBLE'

if __name__ == '__main__':
    print(main())
    


Measured memory_bytes: 2940
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int a, b, c, m;
    scanf("%d %d %d", &a, &b, &c);
    m = max(a,max(b, c));
    if(m==a)
    {
        printf("%d",(a*10)+b+c);
    }
    else if(m==b)
    {
        printf("%d", (b*10)+a+c);
    }
    else if(m==c)
    {
        printf("%d", (c*10)+a+b);
    }
}


Measured memory_bytes: 3792
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = defaultdict(int)
for i in range(N):
  d[A[i]] += 1
  
cnt = max(len(d.keys()) - K, 0)
d = sorted(d.items(), key=lambda x:x[1])
ans = 0
for i in range(cnt):
  ans += d[i][1]
print(ans)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct FordFulkerson {
  struct edge {
    int to, cap, rev;
    edge(){}
    edge(int to, int cap, int rev):to(to), cap(cap), rev(rev){}
  };
  vector< vector<edge> > graph;
  vector<bool> used;
  FordFulkerson(){}
  FordFulkerson(int V):graph(V), used(V){}
  pair<int, int> add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
    return make_pair(graph[from].size()-1, graph[to].size()-1);
  }
  int dfs(int v, int t, int f, int k = inf) {
    if(v == t) return f;
    if(k == 0) return 0;
    used[v] = true;
    for(edge& e : graph[v]) {
      if(!used[e.to] && e.cap > 0) {
	int d = dfs(e.to, t, min(f, e.cap), k-1);
	if(d > 0) {
	  e.cap -= d;
	  graph[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int s, int t, int ff = inf, int k = inf) {
    if(s == t) return 0;
    int flow = 0;
    while(ff) {
      fill(all(used), false);
      int f = dfs(s, t, inf, k);
      if(f == 0) return flow;
      flow += f;
      ff -= f;
    }
    return flow;
  }
};

#define MAX_N 6000

int N, K;
int x[MAX_N], y[MAX_N];

int sq(int x) {
  return x*x;
}

int dist(int i, int j) {
  return sq(x[i]-x[j]) + sq(y[i]-y[j]);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;
  rep(i, N) cin >> x[i] >> y[i];

  int s = N, t = s + 1, V = t + 1;
  FordFulkerson graph(V);
  vector<int> eid(N);
  rep(i, N) {
    if(y[i]%2 == 0) eid[i] = graph.add_edge(s, i, 1).first;
    else eid[i] = graph.add_edge(i, t, 1).first;
    reps(j, i+1, N) {
      if(y[i]%2 != y[j]%2 && dist(i, j) < 4) {
	if(y[i]%2 == 0) graph.add_edge(i, j, inf);
	else graph.add_edge(j, i, inf);
      }
    }
  }

  int mx_st = N - graph.max_flow(s, t);
  if(mx_st < K) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> ans;
  rep(i, N) {
    if(ans.size() == K) break;
    auto& e = y[i]%2 ? graph.graph[i][eid[i]] : graph.graph[s][eid[i]];
    int cap = e.cap;
    int rcap = graph.graph[e.to][e.rev].cap;
    e.cap = inf;
    int f = graph.max_flow(s, t);
    if(mx_st - f >= K) {
      ans.push_back(i);
      mx_st -= f;
    } else {
      e.cap = cap;
      graph.graph[e.to][e.rev].cap = rcap;
      if(y[i]%2 == 0) graph.max_flow(t, i, f, 2);
      else graph.max_flow(i, s, f, 2);
      //graph.max_flow(s, t);
    }
  }

  //assert(ans.size() == K);

  rep(i, K) cout << ans[i]+1 << endl;

  return 0;
}

Measured memory_bytes: 4452
#include <stdio.h>

int main(void)
{
   int a,b,c;

   scanf("%d %d %d\n", &a,&b,&c);

  if (a<=b && b<=c)
     printf("%d %d %d\n",a,b,c);
  else if (a<=c && c<=b)
     printf("%d %d %d\n",a,c,b);
  else if(b<=a && a<=c)
     printf("%d %d %d\n",b,a,c);
  else if(b<=c && c<=a)
     printf("%d %d %d\n",b,c,a);
  else if(c<=a && a<=b)
     printf("%d %d %d\n",c,a,b);
  else
     printf("%d %d %d\n",c,b,a);

    return 0;
}


Measured memory_bytes: 2148
/*
RAone00
Rohit sharma
*/

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

typedef long long ll;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef vector < vector < ll > > matrix;
typedef vector < ll > vll;

#define pb push_back
#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int main() {
    fast_io();
    int a, s;
    cin >> a >> s;
    int d = min(a, s);
    int f = max(a, s);
    for (int i = 0; i < f; ++i) {
      cout << d;
    }
    cout << endl;
    return 0;
}


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

int main()
{
	//std::numeric_limits<int>::max();
	int b,c,n,m,k,i,j;
	string s;
	
	int a[3][3];
	int ar[3][3];
	memset(ar,0,sizeof(ar));
	set<int> v;
	
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
			cin>>a[i][j];
	}
	cin>>n;
	int cnt=0,rs=0,cs=0,flag=0;
	for(k=0;k<n;k++)
	{
		cin>>b;
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				if(a[i][j]==b && a[i][j]!=-1)
				{
					a[i][j]=-1;
					cnt++;
					ar[i][j]=1;
				}
					
				
			}
		}
	}
	if(cnt==5)
	cout<<"Yes"<<endl;
	else
	{
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				rs+=ar[i][j];
				cs+=ar[j][i];
			}
			if(rs==3 || cs==3)
				{
					cout<<"Yes"<<endl;
					flag=1;
					break;
				}
			rs=0;
			cs=0;
		}
		k=0;
		if(flag==0 && (ar[2][0]+ar[1][1]+ar[0][2]==3 || ar[0][0]+ar[1][1]+ar[2][2]==3))
		{
			cout<<"Yes"<<endl;
			k=1;
		}
		if(flag==0 && k==0)
		cout<<"No"<<endl;
		
		
	}
	
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

def zerosplit(l): # split by zero
  #print("zsp")
  mother = []
  child = []
  for e in l:
    if e != 0:
      child.append(e)
    elif e == 0 and len(child) != 0:
      mother.append(child)
      child = []
  if len(child) !=0:
    mother.append(child)
  return mother

def mizuyari(l): # decrease all elements by min(l)
  d = [0]*len(l)
  cnt1 = min(l)
  for i in range(len(l)):
    d[i] = l[i] - min(l)
  #print("mizuyari " + str(cnt1)+ " times")
  return [d,cnt1]
localcount = []
def mini(h): # mizuyari for splitted list
  l = zerosplit(h)
  #print(l)
  for e in l:
    #print(":in min: for"+ str(e))
    d,c = mizuyari(e)
    localcount.append(c)
    #print("localcnt " + str(localcount))    
    if len(d) != 0:
      mini(d)
  return sum(localcount)

print(mini(h))

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

using namespace std;

int main(void) {

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

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    vector<long long> dp(n);

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

        if (i == 0) {
            dp[i] = 0;
        } else for (int j = 1; j <= k && j <= i; ++j) {
            long long val = dp[i-j] + abs(h[i] - h[i-j]); 
            if (j == 1 || val < dp[i]) dp[i] = val;
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


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

int n,m,temp,ans=0;
int a[100005];

inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	
	while (ch<'0'||ch>'9')
	{
		if (ch=='-')  w=-w;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9')
	{
		s=(s<<1)+(s<<3)+(ch-'0');
		ch=getchar();
	}
	return s*w;
}

signed main()
{
	std::priority_queue<int> q;
	
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		temp=read();
		q.push(temp);
	}
	for (int i=1;i<=m;i++)
	{
		int tmp=q.top();
		q.pop();
		q.push(tmp/2);
	}
	while (!q.empty())
	{
		ans+=q.top();
		q.pop();
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

long long n, m;
int tem;

int read()
{
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * w;
}

inline void write(int x)
{
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[-- top] + 48);
}

int main()
{
	n = read();
	m = read();
	while(m --) {
		cin>>tem;
		n -= tem;
		if(n < 0) {
			n = -1;
			break;
		}
	}
	cout<<n;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=400010;
int n,m,h[N],f[N],mx[N],s[N];
int main()
{
	n=gi();m=gi();
	for(int i=1;i<=n;i++)h[i]=gi();
	while(m--)
	{
		int u=gi(),v=gi();
		mx[u]=max(mx[u],h[v]);
		mx[v]=max(mx[v],h[u]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(mx[i]<h[i])ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4544
#include<bits/stdc++.h> 
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using tiii = tuple<int, int, int>;
int used[100];

int main()
{
    int d, g;
    cin >> d >> g;
    // vector<
    vector<int> p(d);
    vector<int> c(d);

    rep(i, d)
        cin >> p[i] >> c[i];

    int cnt = 0;
    int ans = -1;
    rep(i, 1 << d)
    {
        int num = 0;
        int value = 0;
        int used[d];

        rep(j, d)
            if (i & (1 << j))
            {
                num += p[j];
                used[j] = 1;
                value += (j + 1) * 100 * p[j] + c[j];
            }
            else 
                used[j] = 0;
        // cout << value << ' ' <<  num << endl;
        
        for (int j = d - 1; j >= 0; j--)
        {
            if (used[j] > 0) continue;
            for(int k = 0; k < (p[j] - 1) and value < g; k++)
            {
                num++;
                value += (j + 1) * 100;
                // cout << value << ' ' << p[j] << ' ' << k << ' ' << (j + 1) * 100 << ' ' << d << ' ' << i << ' ' << used[j] << endl;
            }
            // cout << (p[j] - 1) << ' ' << value << ' ' << j << ' ' << used[j] << endl;
        }
        // cout << value << ' ' << num << endl;
        // cout << "**********" << endl;
        if ((ans == -1 or ans > num) and value >= g)
            ans = num;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP1(i,n) for(ll i=1;i<=(ll)(n);i++)

int main() {
	ll n;
    cin >> n;
    if( n%10 == 7 ){
        cout << "Yes" << endl;
    } else if( (n/10)%10 == 7 ){
        cout << "Yes" << endl;
    } else if( n/100 == 7 ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, max;
  
  cin >> N;
  
  vector<int> values(N);
  vector<int> costs(N);
  
  for (int i = 0; i < N; i++) {
    cin >> values.at(i);
  }
  
  for(int i = 0; i < N; i++) {
  	cin >> costs.at(i);
  }
  
  for(int i = 0; i < N; i++){
    if(values.at(i) - costs.at(i) > 0){
      max = max + values.at(i) - costs.at(i);
    }
  } 
  
  cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
int mp[50][50],n,a,b,c;
bool flag[10];
#define INF 10000000
int main()
{
    int Min;
    cin >> n;
    while(n)
    { 
        int V = 10;
        Min = INF;
        memset(flag,0,sizeof(flag));
    for(int i=0;i<50;i++)
        for(int j = 0;j<50;j++)
        {
          if(i==j)
              mp[i][j] = 0;
         else
          mp[i][j] = INF;

        }
     
    for(int i=1;i<=n;i++)
    {
         cin >> a >> b >> c;
         mp[a][b] = mp[b][a] = c;
         flag[a] = flag[b] = true;
    }
    for(int k=0;k<V;k++)
        for(int i=0;i<V;i++)
            for(int j=0;j<V;j++)
                mp[i][j]= min(mp[i][j],mp[i][k]+mp[k][j]);
   
   int MinN[11];
   memset(MinN,0,sizeof(MinN));
   for(int i=0;i<V;i++){
   	for(int j=0;j<V;j++)
   	   if(flag[j]==true)
   	  MinN[i] += mp[i][j];
   }
   
    cout << min_element(MinN,MinN+V) - MinN <<" "<<*min_element(MinN,MinN+V) <<endl;
    
    cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3032
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc132/tasks/abc132_b

n = int(input())
p = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        cnt += 1
print(cnt)


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

using namespace std;

constexpr int INF = 1e8;
constexpr int MAX_N = 1e5;

int T, X;

void input()
{
  scanf("%d", &T);
  scanf("%d", &X);
}

void solve()
{
  cout << float(T) / X << endl;
}

int main()
{
  input();
  solve();

  return 0;
}

Measured memory_bytes: 256
import itertools
n=int(input())
data=list(map(int,input().split()))
count=0
if len(data) < 3:
    print(0)
else:
    for d in itertools.combinations(data,3):
        
        triple=list(d)
        if (triple[0]+triple[1] > triple[2]) and (triple[1]+triple[2] > triple[0]) and (triple[2]+triple[0] > triple[1]):
            if triple[0] != triple[1] and triple[1] != triple[2] and triple[2] != triple[0]:
                count += 1
        
        else:
            pass
    print(count)

Measured memory_bytes: 68248