akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int t,x;
    cin>>t>>x;
    cout<<(double)t/x<<endl;
    return 0;
}

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

using namespace std;
const int maxn=510;
int mp[maxn][maxn];
struct node
{
    int x,y;
};
typedef pair<node,node>pp;
vector<pp>st;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            scanf("%d",&mp[i][j]);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(mp[i][j]%2)
            {
                node pos1,pos2;
                pos1.y=i;
                pos1.x=j;
                pos2.y=i;
                pos2.x=j+1;
                mp[i][j]--;
                mp[i][j+1]++;
                pp pos3=make_pair(pos1,pos2);
                st.push_back(pos3);
            }
        }
    }

    for(int i=1;i<n;i++)
    {
        if(mp[i][m]%2)
        {
            node pos1,pos2;
            pos1.y=i;
            pos1.x=m;
            pos2.y=i+1;
            pos2.x=m;
            mp[i][m]--;
            mp[i+1][m]++;
            pp pos3=make_pair(pos1,pos2);
            st.push_back(pos3);
        }
    }
    printf("%d\n",st.size());

    for(int i=0;i<st.size();i++)
    {
        printf("%d %d %d %d\n",st[i].first.y,st[i].first.x,st[i].second.y,st[i].second.x);
    }

    return 0;
}





Measured memory_bytes: 5232
c = []
re = 0
oc = []
s = gets.chomp.split(" ")
hi = s[0].to_i
wi = s[1].to_i
10.times do |i|
  c[i] = gets.chomp.split(" ").collect{ |item| item.to_i}
end
10.times do |i|
  al = [0,1,2,3,4,5,6,7,8,9]
  olist = []
  unfinish = true
  while(unfinish)
    s = al.collect{ |j| c[i][j]}.min
    v = al.select{ |j| c[i][j] == s}[0]
    olist.push(v)
    al.delete(v)
    if (v == 1)
      oc[i] = s
      unfinish = false
    else
      10.times do |w|
        next if olist.include?(w)
        if(c[i][w] > (c[i][v] + c[v][w]))
          c[i][w] = c[i][v] + c[v][w]
        end
      end
    end
  end
end
hi.times do |h|
  s = gets.chomp.split(" ").collect{ |item| item.to_i}
  s.each { |w| re += oc[w] unless (w == -1 || w == 1)}
end
print re,"\n"


Measured memory_bytes: 3964
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int s; cin >> s;
	set<int>st;
	st.insert(s);
	auto f = [&](int n) {
		if (n % 2 == 0)return n / 2;
		else return 3 * n + 1;
	};
	int i = 2;
	for (;; i++) {
		s = f(s);
		if (st.count(s))break;
		st.insert(s);
	}
	cout << i  << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int sum[100010]={};
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        sum[a]++;
        sum[b+1]--;
    }
    sum[0]++;
    sum[100002]--;
    for(int i=0;i<100003;i++){
        sum[i+1]+=sum[i];
    }
    int ans=0;
    for(int i=0;i<=n+1;i++){
        if(i<=sum[i])ans=i-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3492
//**KEEP IT SHORT AND SIMPLE**

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef set <long long> sll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
double pi = 2 * acos(0.0);
int OO = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
ll n, k, arr[100010], dp[100010];
ll solve(ll i)
{
    if(i == n - 1)  return 0;
    if(~dp[i])      return dp[i];
    ll ans = OO;
    for(int j = i + 1;j <= min(i + k, n - 1);j++)
        ans = min(solve(j) + abs(arr[j] - arr[i]), ans);
    return dp[i] = ans;
}
int main()
{
    IO
    cin >> n >> k;
    REP(i, 0, n)
        cin >> arr[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main(){

    int n; cin >> n;
    list<int> L;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(i % 2 == 0) L.push_back(a);
        else L.push_front(a);
    }

    if(n % 2 == 1) reverse(L.begin(), L.end());

    for(auto x : L) cout << x << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 8448
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);

            Console.WriteLine(Math.Max(0, (C - (A - B))).ToString());
//            Console.Read();
        }
    }
}

Measured memory_bytes: 13140
<?php

define('MAX', 50001);
define('COUNT', 5133);
$table = new SplFixedArray(MAX);
$table[0] = $table[1] = false;
$primes = new SplFixedArray(COUNT);
$p_i = 0;
$i = 2;
while ($i < MAX) {
    $primes[$p_i++] = $i;
    $table[$i] = true;
    for ($j = $i * 2; $j < MAX; $j += $i) {
        $table[$j] = false;
    }
    while (++$i < MAX && $table[$i] === false);
}

while (true) {
    fscanf(STDIN, '%d', $n);
    if ($n === 0) {
        break;
    }
    $c = 0;
    for ($i = 0; $i < COUNT; $i++) {
        if ($primes[$i] > $n / 2) {
            break;
        }
        if ($table[$n - $primes[$i]]) {
            $c++;
        }
    }
    echo $c . PHP_EOL;
}

Measured memory_bytes: 9644
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

const int MOD = 10007;
int dp[1010][1<<3];
int map[256];

int main(){
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < 3; ++i) map["JOI"[i]] = 1<<i;
	dp[0][1] = 1;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < (1 << 3); ++j){
			for (int k = 0; k < (1 << 3); ++k){
				if ((j&k)&&(k&map[s[i]])){
					dp[i + 1][k] += dp[i][j];
					dp[i + 1][k] %= MOD;
				}
			}
		}
	}

	cout << accumulate(dp[n], dp[n + 1], 0) % MOD << endl;

	return 0;
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;

ll z[100005];int m=10;ll y;
map<int,int>p;
void dfs(ll x,ll n)
{
	if(m==100002)return;
	if(n==0)
	{
		if(p[x]==0)
		{p[x]=1;
		z[m]=x;
		m++;}
		return;
	}
	if(x%10==0)
	{	
		y=x*10+0;
		dfs(y,n-1);
		y=x*10+1;
		dfs(y,n-1);
	}
	else 
	if(x%10==1)
	{	
		y=x*10+0;
		dfs(y,n-1);
		y=x*10+1;
		dfs(y,n-1);
		y=x*10+2;
		dfs(y,n-1);
	}
		else 
	if(x%10==2)
	{	
		y=x*10+1;
		dfs(y,n-1);
		y=x*10+2;
		dfs(y,n-1);
		y=x*10+3;
		dfs(y,n-1);
	}
		else 
	if(x%10==3)
	{	
		y=x*10+2;
		dfs(y,n-1);
		y=x*10+3;
		dfs(y,n-1);
		y=x*10+4;
		dfs(y,n-1);
	}
		else 
	if(x%10==4)
	{	
		y=x*10+3;
		dfs(y,n-1);
		y=x*10+4;
		dfs(y,n-1);
		y=x*10+5;
		dfs(y,n-1);
	}
		else 
	if(x%10==5)
	{	
		y=x*10+4;
		dfs(y,n-1);
		y=x*10+5;
		dfs(y,n-1);
		y=x*10+6;
		dfs(y,n-1);
	}
		else 
	if(x%10==6)
	{	
		y=x*10+5;
		dfs(y,n-1);
		y=x*10+6;
		dfs(y,n-1);
		y=x*10+7;
		dfs(y,n-1);
	}
		else 
	if(x%10==7)
	{	
		y=x*10+6;
		dfs(y,n-1);
		y=x*10+7;
		dfs(y,n-1);
		y=x*10+8;
		dfs(y,n-1);
	}
		else 
	if(x%10==8)
	{	
		y=x*10+7;
		dfs(y,n-1);
		y=x*10+8;
		dfs(y,n-1);
		y=x*10+9;
		dfs(y,n-1);
	}
		else 
	if(x%10==9)
	{	
		y=x*10+8;
		dfs(y,n-1);
		y=x*10+9;
		dfs(y,n-1);
	}
}



int main()
{
	int a,b,c,d;
	scanf("%d",&a);
	for(int i=1;i<10;i++){
	z[i]=i;p[i]=1;}p[0]=1;
	for(ll i=1;i<=10;i++)
	{
		for(ll j=0;j<=9;j++)
		dfs(j,i);
	}
	printf("%lld\n",z[a]);
}




Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
//      std macros
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
//      dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
//      loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define PER(i,b,a) for(int i=b;i>=a;--i)
#define all(X) (X).begin(), (X).end()
//      I/O
#define sd(n) scanf("%d",&n)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define ss(s) scanf("%s",s)
//      debug
#define debug(x) cerr<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
//      set values
#define mset(n,k) memset(n,k,sizeof(n))
//modular expo
ll power(ll a,ll b, ll c){
    ll x=1,y=a;
    while(b>0){
        if(b&1)
            x=(x*y)%c;
        y=(y*y)%c;
        b/=2;
    }
    return x%c;
}
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};//clockwise from left
int dr[]={1,1,0,-1,-1,-1, 0, 1};
int dc[]={0,1,1, 1, 0,-1,-1,-1};//anticlockwise from down
char S[50];
int main() {

	int a,b;
	sd2(a,b);
	scanf("%s",S+1);

	bool fl = 1;
	REP(i,1,a+b+1) {
		if(i == (a+1)) {
			if(S[i]!='-')
				fl = 0;
		}
		else {
			if(!(S[i]>='0' && S[i]<='9'))
				fl = 0;
		}
	}
	if(fl)
		printf("Yes\n");
	else
		printf("No\n");

	
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n):
  c+=min(a[i],b[i])
  d=b[i]-a[i]
  if d>0:
    c+=min(d,a[i+1])
  a[i+1]=min(a[i+1],max(0,a[i+1]-d))
print(c)  

Measured memory_bytes: 18624
require "prime"

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

a, b = gets.split(" ").map(&:to_i)


ary = divisors(a) & divisors(b)
cnt = 1

ary.each do |x|
  if x.prime?
    cnt += 1
  end
end

puts cnt


Measured memory_bytes: 2936
def main():
    s = input()
    t = input()
    dp = [["" for _ in range(3010)] for _ in range(3010)]
    for i in range(len(s)):
        for j in range(len(t)):
            dp[i + 1][j + 1] = dp[i][j + 1] if len(dp[i][j + 1]) >= len(dp[i + 1][j]) else dp[i + 1][j]
            if s[i] == t[j] and len(dp[i][j]) + 1 > len(dp[i + 1][j + 1]):
                dp[i + 1][j + 1] = dp[i][j] + s[i]
    print(dp[len(s)][len(t)])


if __name__ == '__main__':
    main()


Measured memory_bytes: 920084
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N; 
  string S;

  int i; 
  int ctr = 1;

  
  cin >> N;
  cin >> S;
  
  for(i=1;i<N;i++){
    if(S[i]!=S[i-1]){
      ctr++; 
    }
  }
    
  cout << ctr; 
  
  return 0;
}


Measured memory_bytes: 512
num_limit = int(input())
num_list = [0] * num_limit
j_limit = int(num_limit ** 0.5)
for j in range(1,j_limit+1):
    for k in range(1,j + 1):
        if num_limit < j**2 + k**2 + j*k:
            break
        for l in range(1,k+1):
            if num_limit < j**2 + k**2 + l**2 + j*k + k*l + l*j:
                break
            elif num_limit >= j**2 + k**2 + l**2 + j*k + k*l + l*j:
                if j > k:
                    if k > l:
                        num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 6
                    else:
                        num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 3
                elif k > l:
                    num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 3
                else:
                    num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 1
for i in num_list:
    print(i)

Measured memory_bytes: 9580
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

inline int tonum(string s){ stringstream ss(s); int n; ss >> n; return n; }

int main(){
    string s;
    cin >> s;
    s = "0" + s;
    int ans = 0;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == '0') continue;
        int sub = tonum(s.substr(0, i));
        int add = tonum(s.substr(i));
        int x = (add + sub) / 2;
        int y = add - x;
        if((add + sub) % 2 == 0 && x >= 0 && y >= 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)

inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int h[100001];
int main(){
  int n=read(),a=read(),b=read();a-=b;
  rep(i,n)h[i]=read();
  int left=0,right=1000000000;
  ll temp,cnt=0,mid;
  while (right>left+1) {
    mid=(right+left)>>1;
    cnt=0;
    rep(i,n){
      temp=h[i]-b*mid;
      if(temp>0)cnt+=ceil(1.0*temp/a);
    }
    if(cnt<=mid)right=mid;
    else left=mid;
  }
  printf("%d\n",right);
  return 0;
}

Measured memory_bytes: 512
n=int(input())
li=list(map(int,input().split()))
li.sort()
while True:
  if len(li)==1:
    print(li[0]);exit()
  divisor=li[0]
  temp=[li[0]]
  for i in li[1:]:
    if i%divisor:
      temp+=[i%divisor]
  li=sorted(temp)

Measured memory_bytes: 15020
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(CardGameforThreeABCEdit());
    }

    private static long CardGameforThreeABCEdit()
    {
        long N = 0;
        long[] A = null;

        readData(ref N, ref A);        

        return playerPower(N, A);
    }

    private static long playerPower(long N, long[] a)
    {
        long sum = 0;

        Array.Sort(a);
        Array.Reverse(a);

        for (int i = 0; i < N; i++)
        {
            sum += a[2*i+1];
        }

        return sum;
    }

    /// <summary>
    /// データを読み込む
    /// </summary>
    private static void readData(ref long N, ref long[] A)
    {
        N = long.Parse(Console.ReadLine());

        A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
    }
}




Measured memory_bytes: 39884
n=int(input())
A=[int(i) for i in input().split()]

mode=0
cnt=0

ans=[]

def do(a,b):
    global cnt
    cnt+=1
    A[b]+=A[a]
    ans.append((a+1,b+1))

def doMAX(b):
    if b==-1:
        b+=n
    do(A.index(max(A)),b)

def doMIN(b):
    if b==-1:
        b+=n
    do(A.index(min(A)),b)

if abs(max(A))>=abs(min(A)):
    doMAX(-1)
    mode=0
elif abs(max(A))<abs(min(A)):
    doMIN(0)
    mode=1
else:
    doMAX(-1)
    mode=0

if mode==0:
    old=-10**30
    for i in range(n-1):
        if A[i]>=old:
            old=A[i]
            continue
        while A[i]+A[-1]<old:
            doMAX(-1)
        doMAX(i)
        old=A[i]
    while A[-1]<old:
        doMAX(-1)
    #print(A,cnt)
elif mode==1:
    old=10**30
    for i in range(n-1,0,-1):
        if A[i]<=old:
            old=A[i]
            continue
        while A[i]+A[0]>old:
            doMIN(0)
        doMIN(i)
        old=A[i]
    while A[0]>old:
        doMIN(0)
    #print(A,cnt)
else:
    pass
#print(A,cnt)
print(cnt)
for ele in ans:
    print(ele[0],ele[1])
    

Measured memory_bytes: 64248
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
#define inf 2147483647
#define B 400
using namespace std;


int find(int x, int y, vector<int> &a, vector<int> &b){
    int ans = inf;
    int i = x;
    y++;
    while(i < y){
        if(i % B == 0 && i + B <= y){
            ans = min(ans, b[i / B]);
            i += B;
        }else{
            ans = min(ans, a[i]);
            i++;
        }
    }
    return ans;
}

void update(int n, int x, int y, vector<int> &a, vector<int> &b){
    a[x] = y;
    b[x / B] = inf;
    for(int i = x - x % B; i < min(x - x % B + B, n); i++){
        b[x / B] = min(b[x / B], a[i]);
    }
}

int main(){
    int n, q;
    while(cin >> n >> q){
        vector<int> a(n,inf), b(B,inf);
        rep(i,q){
            int com, x, y;
            cin >> com >> x >> y;
            if(com) cout << find(x,y,a,b) << endl;
            else update(n,x,y,a,b);
        }
    }
}

Measured memory_bytes: 1532
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] f = new int[n];
		int[] a = new int[n];
		int[] t = new int[n];
		int[] x = new int[n];
		int[] y = new int[n];
		
		double AM = -1;
		double BM = -1;
		double A = Integer.MAX_VALUE;
		double B = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++) {
			f[i] = sc.nextInt();
			a[i] = sc.nextInt();
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		
		for(int i = 1; i < n; i++) {
			if(t[i-1] != t[i]) continue;
			if(a[i-1] == a[i]) continue;
			double d = Math.sqrt(Math.pow(x[i] - x[i-1], 2.0) + Math.pow(y[i] - y[i-1], 2.0));
			double time = f[i] - f[i-1];
			if(t[i] == 0) {
				if(d > AM || (d == AM && time < A)) {
					AM = d;
					A = time;
				}
			}
			else {
				if(d > BM || (d == BM && time < B)) {
					BM = d;
					B = time;
				}
			}
		}
		if(AM == -1) System.out.println(-1 + " " + -1);
		else System.out.printf("%.20f %.20f\n",AM,A/60.0);
		if(BM == -1) System.out.println(-1 + " " + -1);
		else System.out.printf("%.20f %.20f\n",BM,B/60.0);
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}

}

Measured memory_bytes: 28532
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t q,a,b,x,y,z,l,r,m,i,ans;
  cin>>q;
  for(i=0;i<q;i++){
    cin>>a>>b;
    x=min(a,b);
    y=max(a,b);
    z=a*b-1;
    l=x-1;
    r=y;
    while(r-l>1){
      m=(l+r)/2;
      if(m*m<=z) l=m;
      else r=m;
    }
    ans=l;
    if(x<=l) ans--;
    ans+=z/(l+1);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
#define TRESUREMAXNUM 1000
#define TRESUREMAXWEIGHT 1000

int dp[TRESUREMAXNUM+1][TRESUREMAXWEIGHT+1];
struct Tresure{
	int price;
	int weight;
};
Tresure tresureBox[TRESUREMAXNUM+1];
int
main(){
	int W,N;
	for(int i=1;cin>>W&&W;i++){
		memset(dp,-1,sizeof(dp));

		cin>>N;
		cout<<"Case "<<i<<":"<<endl;
		for(int j=1;j<=N;j++){
			char c;
			int w,p;
			cin>>p>>c>>w;
			tresureBox[j].price=p;tresureBox[j].weight=w;
		}
/*		cout<<"---list----"<<endl;
		for(int j=1;j<=N;j++)cout<<tresureBox[j].price<<","<<tresureBox[j].weight<<endl;
		cout<<"-----------"<<endl;*/
		dp[0][0]=0;
		for(int j=0;j<N;j++){
			for(int k=0;k<=W;k++){
				if(dp[j][k]==-1)continue;
				dp[j+1][k]=max(dp[j+1][k],dp[j][k]);

				if(k+tresureBox[j+1].weight<=W)dp[j+1][k+tresureBox[j+1].weight]=max(dp[j+1][k+tresureBox[j+1].weight]
				                                              ,dp[j][k]+tresureBox[j+1].price);
			}
		}
		int maxPrice=-1;
		int maxWeight=-1;
		for(int j=0;j<=W;j++){
			if(dp[N][j]==-1)continue;
			if(maxPrice<dp[N][j]){
				maxPrice=dp[N][j];
				maxWeight=j;
			}
		}
//		cout<<"##ans##"<<endl;
		cout<<maxPrice<<endl<<maxWeight<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

INF = sys.maxsize

v, e = map(int, input().split())
g = [[INF for _ in range(v)] for _ in range(1 << v)]

for i in range(e):
    s, t, d = map(int, input().split())
    g[s][t] = d

dp = [[INF for _ in range(v)] for _ in range(1 << v)]
dp[1][0] = 0

for bit in range(1, (1 << v) ):
    for i in range(v):
        if not bit>>i&1:
            continue

        for j in range(v):
            if bit >> j&1:
                continue
            dp[bit | (1 << j)][j] = min(dp[bit | (1 << j)][j], dp[bit][i] + g[i][j])

mn = INF

for end in range(v):
    mn = min(mn, dp[(1 << v) - 1][end] + g[end][0])
if mn == INF:
    print(-1)
else:
    print(mn)



Measured memory_bytes: 23728
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N, D; cin>>N>>D;
    vector<vector<ll>> A(N, vector<ll>(D));
    REP(i, N){
        REP(j, D) cin>>A[i][j];
    }
    set<ll> x;
    REP(i, 10000) x.insert(i*i);
    ll res=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            ll d=0;
            for(int k=0; k<D; k++){
                d += (A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
            }
            if(x.count(d)) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 768
N, X = map(int, input().split())


def func(n, x):
    if n == 0:
        return 1

    a = pow(2, n + 1) - 3
    b = pow(2, n) - 1

    if x == 1:
        return 0
    elif x <= 1 + a:
        return func(n - 1, x - 1)
    elif x == 2 + a:
        return 1 + b
    elif x <= 2 * a + 2:
        return b + 1 + func(n - 1, x - 2 - a)
    else:
        return 2 * b + 1


print(func(N, X))


Measured memory_bytes: 9036
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

ll op(ll a, ll b) { return max(a, b); }
ll e() { return -1ll; }
ll target;
bool f(ll a) { return a < target; }

void solve() {
    ll n, q;
    cin >> n >> q;
    vll a(n);
    rep(i, n) cin >> a[i];
    segtree<ll, op, e> seg(a);
    while(q--) {
        ll t, x, y;
        cin >> t >> x >> y;
        if(t == 1) seg.set(x-1, y);
        else if(t == 2) cout << seg.prod(x-1, y) << endl;
        else if(t == 3) {
            target = y;
            cout << seg.max_right<f>(x-1) + 1 << endl;
        }
    }
    return;
}

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

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

using namespace std;

int a[100010];
int dp[100010];

int32_t main()
{
    int n;
    cin >> n;

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

    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);

    for(int i=2;i<n;i++)
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));

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

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

int main() {
  string s;
  cin >> s;
  int left = 0, right = s.length() - 1;
  int ans = 0;
  for (int left = 0; left * 2 < s.length(); left++){
    if (s[left] != s[right - left]){
      ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
struct edge {
    int to;
    int cap;
    int rev;
};

vector <edge> edges[202];
int level[202];
int iter[202];

void add_edge(int from, int to, int cap){
    edges[from].push_back((edge){to, cap, (int) edges[to].size()});
    edges[to].push_back((edge) {from, 0, (int) edges[from].size() - 1});
}

void bfs(int s){
    memset(level, -1, sizeof(level));
    queue <int> q;
    level[s] = 0;
    q.push(s);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i = 0; i < edges[v].size(); i++){
            edge &e = edges[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                q.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f){
    if(v == t){
        return f;
    }

    for(int &i = iter[v]; i < edges[v].size(); i++){
        edge &e = edges[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                edges[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int dinic(int s, int t){
    int flow = 0;
    while(true){
        bfs(s);
        if(level[t] < 0){
            return flow;
        }
        memset(iter, 0, sizeof(iter));
        while(true){
            int f = dfs(s, t, INT_MAX);
            if(f <= 0){
                break;
            }
            flow += f;
        }
    }
    return 0;
}
int main(void){
    int X;
    int Y;
    int E;
    cin >> X >> Y >> E;

    for(int i = 0; i < X; i++){
        add_edge(0, i + 1, 1);
    }
    for(int i = 0; i < Y; i++){
        add_edge(X + i + 1, X + Y + 1, 1);
    }

    for(int i = 0; i < E; i++){
        int x;
        int y;
        cin >> x >> y;
        add_edge(x + 1, y + X + 1, 1);
    }
    cout << dinic(0, X + Y + 1) << endl;
    return 0;
}


Measured memory_bytes: 3356
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import Data.Bits
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

col = 40

solve :: Int -> Int -> [Int] -> Int
solve bN bK as = snd calc
  where
  vecX = foldl (\v a -> VU.zipWith (+) v (vecExp a)) (VU.replicate col 0) as
  calc = VU.ifoldl f (0,0) vecX
    where
    f (dec, und) i numOne
      | testBit bK i = (dec', max (2^i * numZero + und) (2^i * numOne + dec))
      | otherwise    = (dec', 2^i * numOne + und)
      where numZero = bN - numOne
            dec' = 2^i * (max numZero numOne) + dec

vecExp x = VU.generate col (\i -> if testBit x i then 1 else 0)

-------------------------------------------------------------------------------

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN,bs_bK]:remLines1 = remLines0
      bN = readBInt bs_bN
      bK = readBInt bs_bK
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN bK as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "3 7\n1 6 3\n"
inp2 = "4 9\n7 4 0 3\n"
inp3 = "1 0\n1000000000000\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 14
test2 = tv2 == 46
test3 = tv3 == 1000000000000
alltest = test1 && test2 && test3



Measured memory_bytes: 2428
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

vector<int> V(200010);

int main()
{

    int N;
    cin >> N;
    int min = N + 1;
    int b = 0;

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

    int next = 1;

    for (int i = 0; i < N; ++i)
    {
        if (V[i] == next)
        {
            b++;
            next++;
        }
    }

    if (!b)
        cout << -1;
    else
        cout << N - b;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())

ans = N
for i in range(N + 1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 9
        t //= 9
    t = N - i
    while t > 0:
        cnt += t % 6
        t //= 6
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 40940
using System;
class c
{
    static void Main()
    {
        var s = Console.ReadLine();
        int n = s.Length;
        var ans = new int[n];
        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'R') cnt++;
            else
            {
                ans[i - 1] = cnt;
                cnt = 0;
            }
        }
        for (int i = n - 1; i >= 0; i--)
        {
            if (s[i] == 'L') cnt++;
            else if (ans[i + 1] == 0)
            {
                ans[i + 1] = cnt;
                cnt = 0;
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (ans[i] != 0)
            {
                int sum = ans[i] + ans[i + 1];
                if (sum % 2 == 0)
                {
                    ans[i] = sum / 2;
                    ans[i + 1] = sum / 2;
                }
                else
                {
                    ans[i] = sum / 2 + ans[i] % 2;
                    ans[i + 1] = sum / 2 + ans[i + 1] % 2;
                }
                i++;
            }
        }
        foreach (var x in ans) Console.Write("{0} ", x);
    }
}


Measured memory_bytes: 18016
#include <cstdio>
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main() {
  string l;
  while (getline(cin, l)) {
    if (l == "0") {
      break;
    }

    int s = 0;
    for (size_t i = 0; i < l.size(); ++i) {
      const char c = l[i];
      s += atoi(&c);
    }
    printf("%d\n", s);
  }
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#define SEC_NUM 10
#define STR_MAX 201

void c2s(char str[]){
	int i;
	for(i = 0; str[i] != 0; i++){
		if(str[i] == ','){
			str[i] = ' ';
		}
	}
}

int main(void){
	int i;
	int section[SEC_NUM];
	int length;
	int v1, v2;
	int plength[SEC_NUM];
	int position;
	char str[STR_MAX];
	while(1){
		length = 0;
		if(scanf("%s",str) == EOF){break;}
		c2s(str);
		sscanf(
			str, "%d%d%d%d%d%d%d%d%d%d%d%d",
			section  , section+1, section+2, section+3,
			section+4, section+5, section+6, section+7,
			section+8, section+9, &v1, &v2
		);
		for(i = 0; i < SEC_NUM; i++){
			length += section[i];
			plength[i] = length;
		}
		position = v1 * length * 10 / (v1+v2);
		if(position % 10 >= 5){
			position /= 10;
			position++;
		}else{
			position /= 10;
		}
		for(i = 0; i < SEC_NUM; i++){
			if(position <= plength[i]){
				printf("%d\n",i+1);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			if(a<b){
					int s = a;
					a = b;
					b = s;
			}
			if(a<c){
					int s = a;
					a = c;
					c = s;
			}

			if((a*a)==((b*b)+(c*c))){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 32996
def d_AtCoDeer_and_RockPaper(S):
    # 解説どおり
    n = len(S)  # ターン数
    p = 0  # 相手がパーを出した回数
    for c in S:
        if c == 'p':
            p += 1
    return n // 2 - p

S = input().strip()
print(d_AtCoDeer_and_RockPaper(S))

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

using namespace std;

int main()
{
    int n;
    
    scanf("%d", &n);
    
    long long l = 0, r = 0;
    for (int i = 0; i < n; i++){
        int a;
        char s[2];
        scanf("%*lld %s %d", s, &a);
        
        if (s[0] == '(') l += a;
        else r += a;
        
        printf("%s\n", l == r ? "Yes" : "No");
    }
    
    return (0);
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

ll ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}

signed main() {
  char a, b;
  cin >> a >> b;
  ll ca = ctoi(a);
  ll cb = ctoi(b);

  string A, B;
  rep(i, cb) {
    A += a;
  }
  rep(i, ca) {
    B += b;
  }

  if (A < B) {
    COUT(A);
  } else {
    COUT(B);
  }
  return 0;
}

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


public class Test
{	
    public static void Main()
	{
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
	
	    int ans = 0;
	    for(int i = 0 ; i < n ; i++)
	    {
	        if(i < k) ans += x;
	        else ans += y;
	    }
	    Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for(int i=0; i<M; ++i){
    int A, B;
    cin >> A >> B;
    --A;
    --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  vector<int> dist(N, -1);
  queue<int> que;
  int count = 0;
  int ans = 0;
  for(int v=0; v<N; ++v){
    if(dist[v]!=-1) continue;
    dist[v]=0;
    que.push(v);
    ++count;
    while(!que.empty()){
      int v=que.front();
      que.pop();
      for(auto nv : G[v]){
        if(dist[nv] == -1){
          dist[nv] = dist[v]+1;
          que.push(nv);
          ++count;
        }
      }
    }
    ans = max(ans, count);
    count = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 15576
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;

long long int minimum(long long int x,long long int y)
{
    if(x>=y)
    {
        return y;
    }
    else
    {
        return x;
    }
}

int main()
{
    long long int n;
    cin>>n;
    vector<long long int> v(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    long long int arr[n];
    arr[0] = 0;
    arr[1] = abs(v[1]-v[0]);
    for(long long int j=2;j<n;j++)
    {
        long long int x,y;
        x = abs(v[j]-v[j-1]) + arr[j-1];
        y = abs(v[j]-v[j-2]) + arr[j-2];
        arr[j] = minimum(x,y);
    }
    cout<<arr[n-1]<<endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  long double a, b, x;
  cin >> a >> b >> x;

  long double vol = a * a * b;

  long double ng = M_PI_2;
  long double ok = 0;

  long double mid = (ok + ng) / 2;
  REP(i, 100000) {
    mid = (ok + ng) / 2;
    if (b >= a * tan(mid)) {
      if (vol - a * a * a * tan(mid) / 2 >= x) {
        ok = mid;
      } else {
        ng = mid;
      }
    } else {
      if (b * b * a / (2 * tan(mid)) >= x) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
  }

  cout << fixed << setprecision(10) << mid / M_PI * 180 << endl;
  return 0;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {

	ll N, K;
	cin >> N >> K;
	vll num(N + 1, 0);
	rep(i, N) {
		ll tmp; cin >> tmp;
		++num[tmp];
	}
	sort(all(num));
	num.erase(remove(all(num), 0), num.end());
	ll ans = 0;
	rep(i, (ll)num.size() - K) {
		ans += num[i];
	}
	cout << ans << endl;
}

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

int main(){
	int N;
  	long long p=1,b=1;
  	cin>>N;
  	for(int i=0;i<9;++i)b*=10;
  	for(int i=1;i<=N;++i) p=p*i%(b+7);
	cout<<p<<endl;
  	return 0;
}

Measured memory_bytes: 256
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

let a = Int(split[0])! 
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
let b = Int(split[1])!
print(a*b)

Measured memory_bytes: 14164
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct point{
    ll x,y,p;
};
int main() {
    

    bool lis[1001][1001] = {};
    ll h,w;
    cin >> h >> w;
    queue <point> v;
    for (ll i=0;i<h;i++){
        string s;
        cin >> s;
        for (ll j=0;j<w;j++){
            if(s[j] == '#'){
                lis[i+1][j+1] = true;
                point tmp;
                tmp.x = i+1;
                tmp.y = j+1;
                tmp.p = 0;
                v.push(tmp);
            }
        }
    }
    ll ans = 0;
    while(!v.empty()){
        point tmp;
        tmp = v.front();
        ans = max(ans, tmp.p);
//        cout << tmp.x << " " << tmp.y << " " << tmp.p << " " << ans << endl;
        v.pop();
        point tmp2;
        if(tmp.x - 1 >= 1 and lis[tmp.x-1][tmp.y] == false){
            lis[tmp.x-1][tmp.y] = true;
            tmp2.x = tmp.x-1;
            tmp2.y = tmp.y;
            tmp2.p = tmp.p+1;
            v.push(tmp2);
        }
        if(tmp.x + 1 <= h and lis[tmp.x+1][tmp.y] == false){
            lis[tmp.x+1][tmp.y] = true;
            tmp2.x = tmp.x+1;
            tmp2.y = tmp.y;
            tmp2.p = tmp.p+1;
            v.push(tmp2);
        }
        if(tmp.y - 1 >= 1 and lis[tmp.x][tmp.y-1] == false){
            lis[tmp.x][tmp.y-1] = true;
            tmp2.x = tmp.x;
            tmp2.y = tmp.y-1;
            tmp2.p = tmp.p+1;
            v.push(tmp2);
        }
        if(tmp.y + 1 <= w and lis[tmp.x][tmp.y+1] == false){
            lis[tmp.x][tmp.y+1] = true;
            tmp2.x = tmp.x;
            tmp2.y = tmp.y+1;
            tmp2.p = tmp.p+1;
            v.push(tmp2);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 25524
//18
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

vector<int> v[5],u;
const char *e;
int x;

vector<int> exp();

vector<int> ss(){
  if(e[x]=='('){
    x++;
    vector<int> r=exp();
    x++;
    return r;
  }else if(e[x]!='c'){
    return v[e[x++]-'A'];
  }else{
    x++;
    vector<int> l=ss(),a(u.size());
    vector<int>::iterator it;
    it=set_difference(u.begin(),u.end(),l.begin(),l.end(),a.begin());
    a.resize(it-a.begin());
    return a;
  }
}

vector<int> exp(){
  vector<int> l=ss();
  string op="uids";
  for(char o=e[x];op.find(o)!=string::npos;o=e[x]){
    x++;
    vector<int> r=ss(),a(u.size());
    vector<int>::iterator it;
    if(o=='u'){
      it=set_union(l.begin(),l.end(),r.begin(),r.end(),a.begin());
    }else if(o=='i'){
      it=set_intersection(l.begin(),l.end(),r.begin(),r.end(),a.begin());
    }else if(o=='d'){
      it=set_difference(l.begin(),l.end(),r.begin(),r.end(),a.begin());
    }else{
      it=set_symmetric_difference(l.begin(),l.end(),r.begin(),r.end(),a.begin());
    }
    a.resize(it-a.begin());
    l=a;
  }
  return l;
}

int main(){
  for(;;){
    u.clear();
    for(int i=0;i<5;i++){
      v[i].clear();
    }
    char c;
    int n;
    while(cin>>c>>n,cin&&c!='R'){
      int x=c-'A';
      v[x].resize(n);
      while(n--){
	cin>>v[x][n];
	u.push_back(v[x][n]);
      }
      sort(v[x].begin(),v[x].end());
    }
    if(!cin)return 0;
    sort(u.begin(),u.end());
    u.resize(unique(u.begin(),u.end())-u.begin());
    string s;
    cin>>s;
    e=s.c_str();
    x=0;
    vector<int> r=exp();
    if(r.empty()){
      cout<<"NULL"<<endl;
    }else{
      for(int i=0;i<r.size();i++){
	cout<<r[i]<<((i==r.size()-1)?'\n':' ');
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1244