akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
#define ARRAY_MAX 1005

int dp[ARRAY_MAX][ARRAY_MAX];
char alpha[29]= "abcdefghijklmnopqrstuvwxyz";


int main(){

    int n;
    cin >> n;
    string t;

    vector<string> s(n);
    
    vector<int> b(26,100000);
    for(int i = 0;i < n;i++){
        vector<int> a(26,0);
        cin >> t;
        for(int j = 0;j < t.length();j++){
            a[t[j]-'a']++;
        }
        
        for(int j = 0;j < 26 ;j++){
            b[j] = min(b[j],a[j]);
        }
        /*for(int j = 0;j < 26 ;j++){
            cout << b[j];
        }
        cout << endl;*/
    }

    for(int i = 0;i < 26;i++){
        for(int j = 0;j < b[i];j++){
            cout << alpha[i];
        }
    }
    cout << endl;

    

    


    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, x int
	fmt.Scanf("%d %d", &n, &x)

	var l int
	d := 0
	ans := 1
	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		d = d + l
		if d <= x {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

vector<ll> len(60, 1), p(60, 1);

ll solve(int n, ll x){
    if(n == 0) return 1;

    if(x == 1) return 0;
    else if(x <= 1 + len[n-1]) return solve(n - 1, x - 1);
    else if(x == 2 + len[n-1]) return p[n-1] + 1;
    else if(x <= 2 * (1 + len[n-1])) return p[n-1] + 1 + solve(n - 1, x - 2 - len[n-1]);
    else return p[n];
}

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

    int n; cin>>n;
    ll x; cin>>x;
    for(int i=0; i<n; i++){
        len[i+1] = len[i] * 2 + 3;
        p[i+1] = p[i] * 2 + 1;
    }

    cout << solve(n, x) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		sc.close();
		long cnt=0;
		if(b>=a&&n>1) {
			cnt=(b-a)*(n-2)+1;
		} else if(b==a&&n==1) {
			cnt=1;
		} 
		out.println(cnt);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5],t;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  for(int i=0;i<5;i++){
    if(a[i]==0){
      t=i+1;
    }
  }
  cout<<t;
}


Measured memory_bytes: 3676
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
    int x,y,s;
    char c;
    int a[14][14]={0};
    while(cin>>x>>c>>y>>c>>s){
      if(s==1){
         a[x+2][y+2]++;
         a[x+1][y+2]++;
         a[x+2][y+1]++;
         a[x+3][y+2]++;
         a[x+2][y+3]++;
      }
      if(s==2){
         a[x+1][y+1]++;
         a[x+1][y+2]++;
         a[x+1][y+3]++;
         a[x+2][y+1]++;
         a[x+2][y+2]++;
         a[x+2][y+3]++;
         a[x+3][y+1]++;
         a[x+3][y+2]++;
         a[x+3][y+3]++;
      }
      if(s==3){
         a[x+1][y+1]++;
         a[x+1][y+2]++;
         a[x+1][y+3]++;
         a[x+2][y+1]++;
         a[x+2][y+2]++;
         a[x+2][y+3]++;
         a[x+3][y+1]++;
         a[x+3][y+2]++;
         a[x+3][y+3]++;
         a[x][y+2]++;
         a[x+2][y]++;
         a[x+2][y+4]++;
         a[x+4][y+2]++;
      }
    }
    int max=0,sum=0;
    loop(i,2,12)loop(j,2,12){
      if(a[i][j]==0) sum++;
      if(a[i][j]>max) max=a[i][j];
    }
    cout << sum << endl;
    cout << max << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
    //freopen("input.txt","r",stdin);
    lli n;
    cin >> n;
    vector <lli> v(n);
    for(int i =0;i<n;i++)cin >> v[i];
    vector < vector <lli> > dp(n,vector <lli> (n));
    for(int l = n-1;l>=0;l--){
        for(int r=l;r<n;r++){
            if(l==r){
                dp[l][r] = v[l];
            }else{
                dp[l][r] = max(v[l]-dp[l+1][r],v[r]-dp[l][r-1]);
            }
        }
    }
    cout << dp[0][n-1]<<endl;
}


Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {
	static int n;
	static int[][] bridge;
	
	static int dfs(int now) {//1から葉の親までのcostの最大のものをみつける
		int sum=0;
		for(int i=1; i<=n; i++) {
			if(bridge[now][i]<=0) continue;
			bridge[i][now]=0;
			sum=Math.max(sum, dfs(i)+bridge[now][i]);
		}
		return sum;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				n=sc.nextInt();
				if(n==0) break;
				bridge=new int[n+1][n+1];
				int sum=0;
				for(int i=1; i<n; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					int t=sc.nextInt();
					bridge[a][b]=bridge[b][a]=t;
					sum+=t*2;//全部の往復を足す
				}
				for(int i=2; i<=n; i++) {
					int count=0, now=0;
					for(int j=1; j<=n; j++) {
						if(bridge[i][j]>0 || bridge[i][j]==-1) {
							count++;
							now=j;
						}
					}
					if(count!=1) continue;
					sum-=2*bridge[i][now];//葉の島へかかる分は引く(i:葉の島 now:その親のときcount=1)
					bridge[i][now]=bridge[now][i]=-1;
				}
				System.out.println(sum-dfs(1));//sumから最大のcostのものひけばいい
			}

		}
	}
}


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

int main() {
  int a, b;
  cin>>a>>b;
  if (a == 1 && b == 1) {
    cout<<"1 2"<<endl;
    cout<<"#."<<endl;
    return 0;
  }
  if (a == 1 || b == 1) {
    cout<<"50 100"<<endl;
  } else {
    cout<<"100 100"<<endl;
  }
  if (a > 1) {
    --b;
    for (int i=0; i<50; i++) {
      for (int j=0; j<100; j++) {
        if (i % 2 == 0 && j % 2 == 0) {
          if (a > 1 || (a == 1 && b == 0)) {
            cout<<'.';
            --a;
          } else {
            cout<<'#';
          }
        } else {
          cout<<'#';
        }
      }
      cout<<endl;
    }
  }
  if (b > 0) {
    for (int i=0; i<50; i++) {
      for (int j=0; j<100; j++) {
        if (i % 2 == 1 && j % 2 == 0) {
          if (b > 0) {
            cout<<'#';
            --b;
          } else {
            cout<<'.';
          }
        } else {
          cout<<'.';
        }
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc110_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            var t = Console.ReadLine().ToCharArray();

            var dic = new Dictionary<char,char>();
            for(int i=0; i<s.Length; i++){
                if(dic.ContainsKey(s[i])){
                    if(dic[s[i]] != t[i]){
                        WriteLine("No");
                        return;
                    }
                }else {
                    dic[s[i]] = t[i];
                }
            }

            var dic2 = new Dictionary<char,char>();
            for(int i=0; i<t.Length; i++){
                if(dic2.ContainsKey(t[i])){
                    if(dic2[t[i]] != s[i]){
                        WriteLine("No");
                        return;
                    }
                }else {
                    dic2[t[i]] = s[i];
                }
            }
            WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 15456
/*
  Contest 089
  A - Grouping 2
  Rakesh Kumar --> 18/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    std::cout << n / 3 << std::endl;

    return 0;
}


Measured memory_bytes: 3624
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int solve(int N) {
    int res = 0;

    const int B = 60;
    for(int i=0; i<B; i++) {
        int T = (1LL << (i+1));
        int div = N / T, mod = N % T;

        int pari = div * (1LL << i) % 2;
        if(mod >= T / 2) {
            pari += mod - (T / 2) + 1;
        }

        pari %= 2;
        res |= (pari << i);

        // fprintf(stderr, "N = %lld, i = %lld, T = %lld, div = %lld, mod = %lld, pari = %lld\n", N, i, T, div, mod, pari);
    }
    // fprintf(stderr, "res = %lld\n", res);
    return res;
}

signed main() {
    int A, B; cin >> A >> B;
    cout << (solve(B) ^ solve(A-1)) << endl;
    return 0;
}


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

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    if (N >= B)
        cout << A * (B - 1) / B << endl;
    else
        cout << A * N / B << endl;
    return 0;
}

Measured memory_bytes: 3620
n, p = map(int, input().split())

res = []
for i in range(2, int(pow(p, 0.5)) + 1):
    if p % i == 0:
        ex = 0
        while p % i == 0:
            ex += 1
            p //= i
        res.append([i, ex])
if p != 1:
    res.append([p, 1])

ans = 1
for p in res:
    k = p[1]
    while k:
        if k < n:
            k = 0
        else:
            ans *= p[0]
            k -= n
print(ans)

Measured memory_bytes: 3444
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    string previous = "";
    string now = "";

    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        now += s[i];
        if(now != previous){ 
            ans++;
            previous = now;
            now = "";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n; cin>>n;
    if (n==0) {cout<<0<<endl; return 0;}
    vll a(0); vll b(0);
    while (n!=0){
        if ((inf + n)%4==1){
            a.push_back(1);
            b.push_back(0);
            n -= 1;
        }
        else if((inf + n)%4==3){
            a.push_back(1);
            b.push_back(1);
            n += 1;
        }
        else if((inf + n)%4==2){
            a.push_back(0);
            b.push_back(1);
            n += 2;
        }
        else{
            a.push_back(0);
            b.push_back(0);
            n += 0;
        } 
        n /= 4;
    }

    reverse(ALL(a));
    reverse(ALL(b));
    if(b[0] != 0){
        REP(i,a.size()) cout<<b[i]<<a[i];
    }
    else{
        cout<<a[0];
        REP(i,a.size()-1) cout<<b[i+1]<<a[i+1];
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)
point = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    point[p-1] += x
done = [-1]*N
def dfs(cur, fr, p):
    done[cur] = p
    for nex in G[cur]:
        if nex == fr: continue
        dfs(nex, cur, p+point[nex])
dfs(0, -1, point[0])
ans = []
for i in range(N):
    ans.append(done[i])
print(*ans)


Measured memory_bytes: 239020
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1) ret = (ret * x)%MOD;
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

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

    vector<ll> sum(n+1,0);

    ll factorial = 1;

    for(ll k = 1; k < n+1; k++){
        factorial = (factorial * k)%MOD;
        sum[k] = (sum[k-1] + mypow(k,MOD-2))%MOD;
    }

    ll ans = 0;

    for(ll k = 0; k < n; k++){
        ll p = (sum[k+1] + sum[n-k])%MOD;
        p = (p + (MOD - 1))%MOD;
        p = (p * factorial)%MOD;
        ans = (ans + (p * a[k])%MOD )%MOD;
    }

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

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn = 1e2 + 5;
int a[maxn], n;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i++){
	   int t = 0; 
	   while(a[i] > a[t] && t < i)t++;
	   	int target = a[i];
	   	for(int k = i - 1; k >= t; k--){
	   		a[k + 1] = a[k];
	   	}
	   	a[t] = target;
	   	int first = 1;
		for(int j = 0; j < n; j++){
			if(first) first = 0;
			else printf(" ");
			printf("%d", a[j]);
		}	
		printf("\n");
	}
	
	return 0;
}


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

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

	int ans = 0;
	for (int i = 1; i < n; i++) {
		int cnt = 0; 
		for (char target = 'a'; target <= 'z'; target++) {
			bool left = false, right = false;
			for (int j = 0; j < i; j++)if (s[j] == target)left = true;
			for (int j = i; j < n; j++)if (s[j] == target)right = true;
			if (left && right)cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;

int main() {
  int n;
  int x;
  vector<int> v;
  cin >> n;
  
  rep(i, n) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());

  int ans = 0;
  int ans_m = 1000000000;
  for (int j=1; j<= *max_element(v.begin(), v.end()); j++) {
    ans = 0;
    
    rep(k, n) {
      ans += pow((v[k] - j), 2);
    }
    if (ans < ans_m) {
      ans_m = ans;
    }
  }
  cout << ans_m << endl;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
ls_ka = [[int(_) for _ in input().split()] for _ in range(n)]

ls_k = [0] * n
ls_a = [0] * n
st_ans = {_ for _ in range(1, m+1)} 

for i in range(n):
    ls_k[i] = ls_ka[i][0]
    ls_a[i] = ls_ka[i][1:]
    st_ans &= set(ls_a[i])

print(len(st_ans))

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

const int N = 100005;
long long ans;

int a[N], b[N], c[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", b+i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", c+i);
  }
  sort(a, a+n);
  sort(b, b+n);
  sort(c, c+n);
  for (int i = 0; i < n; ++i) {
    auto x = lower_bound(a, a+n, b[i])-a;
    auto y = c+n-upper_bound(c, c+n, b[i]);
    ans += x*y;
  }
  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 1408
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

let solve ans w v =
  let rec g ans j xs =
    if j = w then (ans, xs)
    else
      match xs with
      | [] -> g ans (j + 1) [(v.(j), j)]
      | (ch, _) :: _ ->
        if ch = v.(j) then g ans (j + 1) xs
        else if ch < v.(j) then g ans (j + 1) ((v.(j), j) :: xs)
        else
          let rec f ans k = function
            | [] -> g ans (j + 1) [(v.(j), k)]
            | (ch, cj) :: tl as ys ->
              if ch >= v.(j) then f (if ch * (j - cj) > ans then ch * (j - cj) else ans) cj tl
              else g ans (j + 1) ((v.(j), k) :: ys) in
          f ans j xs in
  let (ans, xs) = g ans 0 [] in
  List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs

let () =
  match read_ns () with
  | [h; w] ->
    let s = Array.make w 0 in
    let t = Array.make w 0 in
    let rec doit i ans =
      if i = h then ans
      else begin
        read_ns () |> List.iteri (fun j e -> t.(j) <- if e = 1 then 0 else s.(j) + 1);
        Array.iteri (fun i e -> s.(i) <- e) t;
        solve ans w t |> doit (i + 1)
      end in
    doit 0 0 |> Printf.printf "%d\n"
  | _ -> assert false

Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,k,r,s,p;
    string t;
    cin >> n >> k >> r>> s >> p >> t;
    int ans = 0;
    rep(i,n) {
        if(i-k >= 0) if(t[i] == t[i-k]){
            t[i] = '0';
        }
        if(t[i] == 'r')  {
            ans += p;
        }
        if(t[i] == 's') {
            ans += r;
        }
        if(t[i] == 'p') {
            ans += s;
        }
    }
    cout << ans << endl;
}


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

int p[1010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	int q;
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		int id, a, b;
		scanf("%d%d%d", &id, &a, &b);
		if(id == 0) {
			printf("%d\n", *min_element(p+a, p+b));
		}else if(id == 1) {
			printf("%d\n", *max_element(p+a, p+b));
		}
	}
}



Measured memory_bytes: 3208
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;


void Main()
{
	index_t N, K;
	std::cin >> N >> K;
	std::vector<int> data(N);
	for (auto& v : data)
	{
		std::cin >> v;
	}
	std::vector<std::pair<mod_t, mod_t>> count(N);
	for (auto i : boost::irange<index_t>(0, N))
	{
		for (auto j : boost::irange<index_t>(0, i))
		{
			if (data[j] < data[i])
			{
				count[i].first += 1;
			}
		}
		for (auto j : boost::irange<index_t>(i + 1, N))
		{
			if (data[j] < data[i])
			{
				count[i].first += 1;
				count[i].second += 1;
			}
		}
	}
	mod_t x = mod_t(K) * mod_t(K - 1) / 2;
	mod_t sum = 0;
	for (auto i : boost::irange<index_t>(0, N))
	{
		sum += x * count[i].first + K * count[i].second;
	}
	std::cout << sum << std::endl;
}

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

Measured memory_bytes: 256
S = list(input())
N = [int(i) for i in S]
A = N[0]*10+N[1] in range(1,13)
B = N[2]*10+N[3] in range(1,13)
if(A):
  print("AMBIGUOUS") if(B) else print("MMYY")
elif(B):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
N,C=gets.split.map(&:to_i)
a=[]
N.times{
    a << gets.split.map(&:to_i)
}
a.sort!
r=[]
until a.empty?
    s=a.shift
    r.size.times{|i|
        if r[i][1]<s[0]
            r[i]=s
            s=nil
            break
        end
        if r[i][1]==s[0] && r[i][2]==s[2]
            r[i][1]=s[1]
            s=nil
            break
        end
    }
    if s
        r << s
    end
end
puts r.size


Measured memory_bytes: 22068
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        ArrayList<String[]> array = new ArrayList<String[]>();
        for (int i = 0; i < n; i++){
            String[] s = br.readLine().split(" ");
            array.add(s);
        }
        double ans = 0;
        for (int i = 0; i < n - 1; i++){
            double xi = Double.parseDouble(array.get(i)[0]);
            double yi = Double.parseDouble(array.get(i)[1]);
            double xi1 = Double.parseDouble(array.get(i+1)[0]);
            double yi1 = Double.parseDouble(array.get(i+1)[1]);            
            ans += (xi * yi1 - xi1 * yi) / 2;
        }
        // i == n -1
        double xn = Double.parseDouble(array.get(n-1)[0]);
        double yn = Double.parseDouble(array.get(n-1)[1]);
        double xn1 = Double.parseDouble(array.get(0)[0]);
        double yn1 = Double.parseDouble(array.get(0)[1]);
        ans += (xn * yn1 - xn1 * yn) / 2;
        System.out.printf("%.1f\n", ans);
    }
}

Measured memory_bytes: 17012
#include<bits/stdc++.h>
#define pir pair<int,int>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define rsort(x,y) sort(x,y),reverse(x,y)
#define fr first
#define se second
using namespace std;
typedef long long ll;
const int Maxn=4100000;
const int inf=0x3f3f3f3f;

int n,x[Maxn],y[Maxn],dir[Maxn],bj[Maxn];
vector<pir> v[Maxn];

int getadir() {
    char ch=getchar();
    while(!isalpha(ch)) ch=getchar();
    switch(ch) {
        case 'U' : return 0;
        case 'R' : return 1;
        case 'D' : return 2;
        case 'L' : return 3;
    }
}

signed main() {
    // freopen("test.in","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d%d",&x[i],&y[i]);
        dir[i]=getadir();
    }
    int ans=inf;
    for(int i=1;i<=n;i++) if((dir[i]&1)==0) v[x[i]].push_back(make_pair(y[i],i)),bj[x[i]]=1;
    for(int i=1;i<Maxn;i++) if(bj[i]) {
        sort(v[i].begin(),v[i].end());
        int temp=0;
        for(pir j:v[i]) {
            if(dir[j.se]==2) {
                if(temp) qmin(ans,j.fr-y[temp]);
            }
            else temp=j.se;
        }
    }
    for(int i=1;i<Maxn;i++) if(bj[i]) v[i].clear(),bj[i]=0;
    for(int i=1;i<=n;i++) if(dir[i]&1) v[y[i]].push_back(make_pair(x[i],i)),bj[y[i]]=1;
    for(int i=1;i<Maxn;i++) if(bj[i]) {
        sort(v[i].begin(),v[i].end());
        int temp=0;
        for(pir j:v[i]) {
            if(dir[j.se]==3) {
                if(temp) qmin(ans,j.fr-x[temp]);
            }
            else temp=j.se;
        }
    }
    for(int i=1;i<Maxn;i++) if(bj[i]) v[i].clear(),bj[i]=0;
    for(int i=1;i<=n;i++) v[x[i]+y[i]].push_back(make_pair(x[i],i)),bj[x[i]+y[i]]=1;
    for(int i=1;i<Maxn;i++) if(bj[i]) {
        sort(v[i].begin(),v[i].end());
        int tempx=0,tempy=0;
        for(pir j:v[i]) {
            if(dir[j.se]==0) {
                if(tempy) qmin(ans,(j.fr-x[tempy])*2);
            }
            else if(dir[j.se]==1) tempy=j.se;
            else if(dir[j.se]==2) tempx=j.se;
            else if(tempx) qmin(ans,(j.fr-x[tempx])*2);
        }
    }
    for(int i=1;i<Maxn;i++) if(bj[i]) v[i].clear(),bj[i]=0;
    for(int i=1;i<=n;i++) v[x[i]-y[i]+2000000].push_back(make_pair(x[i],i)),bj[x[i]-y[i]+2000000]=1;
    for(int i=1;i<Maxn;i++) if(bj[i]) {
        sort(v[i].begin(),v[i].end());
        int tempx=0,tempy=0;
        for(pir j:v[i]) {
            if(dir[j.se]==3) {
                if(tempy) qmin(ans,(j.fr-x[tempy])*2);
            }
            else if(dir[j.se]==0) tempy=j.se;
            else if(dir[j.se]==1) tempx=j.se;
            else if(tempx) qmin(ans,(j.fr-x[tempx])*2);
        }
    }
    for(int i=1;i<Maxn;i++) if(bj[i]) v[i].clear(),bj[i]=0;
    if(ans==inf) return 0*puts("SAFE");
    ans*=5;
    printf("%d\n",ans);
    return 0;
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    const auto a = Read(n);
    ll m;
    cin >> m;
    const auto b = Read(m);

    auto ans = vi();
    set_difference(ALL(a), ALL(b), inserter(ans, ans.end()));

    DumpRow(ans);

    return 0;
}



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

int main(){
    int N, H;  cin >> N >> H;
    vector<pair<int,int>> d;
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        d.push_back(make_pair(a,0));
        d.push_back(make_pair(b,1));
    }
    sort(d.begin(), d.end(), [](const pair<int,int>& a, const pair<int,int>&b){
        return a.first > b.first;
    });

    int ans = 0;
    int nowK = 0;
    while(H>0){
        if(d[nowK].second==0){
            ans += (H-1)/d[nowK].first + 1;
            break;
        }else{
            ans++;
            H -= d[nowK].first;
            nowK++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <stdio.h>
 
int main(){
	int i, j, tmp, N, K, sum = 0;
	int l[51];
	
	scanf("%d %d", &N, &K);

	for(i = 1; i <= N; i++) {
		scanf("%d", &l[i]);
	}

	for(i = 1; i <= N; ++i) {
		for (j = i + 1; j <= N; ++j) {
			if(l[i] < l[j]) {
				tmp = l[i];
				l[i] = l[j];
				l[j] = tmp;
			}
		}
	}

	
	for(i = 1; i <= K; i++) {
		sum += l[i];
	}

	printf("%d", sum);

}

Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		BigInteger bi = sc.nextBigInteger(10);
		BigInteger bi2 = sc.nextBigInteger(10);
		int a = bi.compareTo(bi2);
		System.out.println(a == 0 ? "EQUAL" : a > 0 ?"GREATER" : "LESS");
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
const ll INF = 1001001001001001001;
int n, a, b;
ll v[55];
map<double, int> mp, mp2;
map<double, ll> ans;
ll comb[60][60];

// 二分探索判定条件
bool C(int c, double x){
    vector<double> tmp(n);
    for(int i = 0; i < n; ++i){
        tmp[i] = (double)v[i] - x;
    }
    sort(tmp.begin(), tmp.end(), greater<double>());
    
    double sum = 0;
    for(int i = 0; i < c; ++i){
        sum += tmp[i];
    }
    if(sum >= 0){
        mp2.clear();
        for(int i = 0; i < c; ++i){
            ++mp2[tmp[i] + x];
        }
        
        return true;
    }
    
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> a >> b;
    for(int i = 0; i < n; ++i){
        cin >> v[i];
        ++mp[v[i]];
    }
    
    comb[0][0] = 1;
    for(int i = 1; i <= n; ++i){
        comb[i][0] = comb[i][i] = 1;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= i; ++j){
            comb[i + 1][j] = comb[i][j] + comb[i][j - 1];
        }
    }
    
    double max_e = 0;
    for(int i = a; i <= b; ++i){
        double lb = 0, ub = INF;
        for(int j = 0; j < 100; ++j){
            double mid = (lb + ub) / 2;
            if(C(i, mid))   lb = mid;
            else            ub = mid;
        }
        
        ll temp = 1;
        // mp,mp2:(first, second) = (要素数, 個数)
        for(auto it = mp2.begin(); it != mp2.end(); ++it){
            temp *= comb[mp[it->first]][it->second];
        }
        
        ans[lb] += temp;
        if(lb > max_e)  max_e = lb;
    }
    
    cout << fixed << setprecision(6);
    cout << max_e << "\n";
    cout << ans[max_e] << "\n";
}

Measured memory_bytes: 256
s = input()
t = input()
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1, len(s)+1):
  for j in range(1, len(t)+1):
    dp[i][j] = max(dp[i][j], dp[i][j-1], dp[i-1][j])
    if s[i-1] == t[j-1]:
      dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1)

ans = ""
i, j = len(s), len(t)
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans = s[i-1] + ans
    i -= 1
    j -= 1
print(ans)

Measured memory_bytes: 144132
#include <stdio.h>
#include <set>
using namespace std;
int main(){
    int n,temp;
    set<int> s;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        s.insert(temp);
    }
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        if(s.find(temp)==s.end()){
            printf("0\n");
            return 0;
        }
    }
    
    printf("1\n");
}


Measured memory_bytes: 12060
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		System.out.printf("%f %f\n", r*r*Math.PI, 2*Math.PI*r);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 28316
/*
 program to find the number of ways to get x+y+z=s and x,y,z<=k in O(k^2)
 */
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{cin.tie(0);
	ios::sync_with_stdio(false);
    int k,s;
    cin >> k >> s;
    int ans = 0;
   for(int x=0;x<k+1;x++){
       for(int y=0;y<k+1;y++){
           int z = s - x - y;
           if(z < 0 || z > k) continue;
           else if(x + y + z == s) ans++;}}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int a, b, c, k; cin >> a >> b >> c >> k;
    int cnt = 0;
    while(a >= b) {
        b *= 2;
        ++ cnt;
    }
    while(b >= c) {
        c *= 2;
        ++ cnt;
    }
    if(cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll w,h,c;
	cin>>w>>h>>c;
	cout<<(w/gcd(w,h))*(h/gcd(w,h))*c<<endl;
}


Measured memory_bytes: 3192
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A, B, C = read_int()
A, B = B, A
A, C = C, A
def solve():
    print("{a} {b} {c}".format(a=A, b=B, c=C))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long X;
    cin >> X;
    long long happy;
    happy = 0;
    int sen = 0;
    int amari = 0;
    sen = X/500;
    amari = X%500;
    int go = 0;
    go = amari/5;
    cout << (sen*1000+go*5) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
        int X,A,B;
        scanf("%d %d %d",&X,&A,&B);
        if (B-A <= 0) printf("delicious\n");
        if (1 <= B-A && B-A <= X) printf("safe\n");
        if (X+1 <= B-A) printf("dangerous\n");
        return 0;
    }

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n;
	int a[1000];
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	for (i = n - 1; i >= 0; i--){
		printf("%d", a[i]);
		if (i != 0){
			printf(" ");
		}
	}
	printf("\n");

	return (0);
}



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

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

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s;
    int a,b,x; cin >> a >> b >> x;

    if(a<=x && a+b>=x) cout << "YES" << '\n';
    else cout << "NO" << '\n';
}

Measured memory_bytes: 256
<?php
	fscanf(STDIN, "%s", $S);
	fscanf(STDIN, "%s", $T);

	$buf = $S;

	for ($i = 0; $i < strlen($buf); $i++){
		$buf = $buf[strlen($buf) - 1].substr($buf, 0, strlen($buf) - 1);
// 		var_dump($buf);
		if($T === $buf){
			echo "Yes";
			return;
		}
	}

	echo "No";

?>

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

int main(void)
{
        int n;
        cin >> n;
        int cnt = 1;
        int temp = n % 10;
        n /= 10;
        for(int i = 0; i < 4; i++){
                if(temp == n%10) cnt++;
                else cnt = 1;
                temp = n%10;
                n /= 10;
                if(cnt == 3){
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;

        return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000)

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

func scanInt() int {
	out, e := strconv.Atoi(inputLine())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(inputLine(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

func f(numbers string, sum int, ans string){
	num_s := string(numbers[0])
	num, _ := strconv.Atoi(num_s)
	if len(numbers) != 1 {
		if ans == "" {
			f(numbers[1:], sum+num, string(num_s))
		} else {
			ans_p := ans + "+" + num_s
			ans_n := ans + "-" + num_s
			f(numbers[1:], sum+num, ans_p)
			f(numbers[1:], sum-num, ans_n)
		}
	} else {
		if sum+num == 7 {
			ans := ans + "+" + num_s + "=7"
			fmt.Println(ans)
			os.Exit(0)
		} else if sum-num == 7 {
			ans := ans + "-" + num_s + "=7"
			fmt.Println(ans)
			os.Exit(0)
		}
	}
}

func main() {
	sc.Buffer(buf, 10000)
	abcd := inputLine()
	f(abcd, 0, "")

}

Measured memory_bytes: 640
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int[] vx = [-1, 0, 1, 0];
    int[] vy = [0, -1, 0, 1];
    while(true) {
        int N = readln.chomp.to!int;
        if (N == 0) break;
        int[2][int] aa;
        aa[0] = [0, 0];
        int[] maxPos = [0, 0];
        int[] minPos = [0, 0];
        foreach(int i; 1..N) {
            int[] input = readln.split.to!(int[]);
            int n = input[0];
            int d = input[1];
            aa[i] = [aa[n][0]+vx[d], aa[n][1]+vy[d]];
            maxPos[0] = max(maxPos[0], aa[i][0]);
            maxPos[1] = max(maxPos[1], aa[i][1]);
            minPos[0] = min(minPos[0], aa[i][0]);
            minPos[1] = min(minPos[1], aa[i][1]);
        }
        writeln(maxPos[0]-minPos[0]+1, " ", maxPos[1]-minPos[1]+1);
    }
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n;
int dp[100010];
vector< vector<int> > e;

int memo_recursive(int v) {
	//cout << "memo_recursive: " << v << endl;
	if(dp[v] != -1) {
		//cout << v << " is already memoed " << dp[v] << endl;
		return dp[v];
	}
	
	int res = 0;
	for(auto nv : e[v]) {
		//cout << "call:" << nv << endl;
		chmax(res, memo_recursive(nv)+1);
	}
	//cout << "v: " << v << " res: " << res << endl;
	return dp[v] = res;
}

int main() {
	int m;
	cin >> n >> m;
	e.assign(n, vector<int>());
	//vector<int> deg(n, 0);
	int x,y;
	rep(i,m) {
		cin >> x >> y;
		e[x-1].pb(y-1);
		//deg[y-1]++;
	}
	rep(i,n) dp[i] = -1;
	/*rep(i,n) {
		cout << i << ":";
		for(auto j : e[i]) {
			cout << j << " "; 
		}
		cout << endl;
	}*/

	int res = 0;
	rep(i,n) chmax(res, memo_recursive(i));
	cout << res << endl;
	
  return 0;
}


Measured memory_bytes: 8192