akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	int h,w,k;
	cin>>h>>w>>k;
	int m=w-1;
	k--;
	vector<int> f;
	FOR(i,0,(1<<m)){
		if(i&(i<<1))continue;
		f.PB(i);
		//cerr<<bitset<32>(i)<<endl;
	}
	int sz=f.size();
	LL dp[111][10]={};
	dp[0][0]=1LL;
	FOR(i,1,h+1){
		FOR(func,0,sz){
			int tmp=f[func];
			int used[10]={};
			FOR(j,0,m){
				if(tmp&(1<<j)){
					dp[i][j]=add(dp[i-1][j+1],dp[i][j]);
					dp[i][j+1]=add(dp[i-1][j],dp[i][j+1]);
					used[j]=1;
					used[j+1]=1;
				}
			}
			FOR(j,0,w){
				if(!used[j]){
					dp[i][j]=add(dp[i-1][j],dp[i][j]);
				}
			}
		}
	}
	cout<<dp[h][k]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int kaisuu=0;
  int X=0,Y=0,W=0,H=0;
  int N=0;
  int x[50000],y[50000];
  int h,i;
  int number=0;

  scanf("%d",&kaisuu);
  for(h=0;h<kaisuu;++h){
    number=0;
  scanf("%d%d%d%d",&X,&Y,&W,&H);
  scanf("%d",&N);
  for(i=0;i<N;++i) {
    scanf("%d%d",&x[i],&y[i]);
    if(X<=x[i] && x[i]<=X+W && Y<=y[i] && y[i]<=Y+H) number+=1;
  }
    printf("%d\n",number);
  }
  return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, MIN, ANS = 0;
	cin >> N;
	MIN = N + 1;
	for (int i = 0; i < N; i++) {
		long long A;
		cin >> A;
		if (MIN > A) ANS++;
		MIN = min(MIN, A);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n,k;
    cin >> n >> k;
    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        if (ans*2<ans + k)
        {
            ans*=2;
        }
        else
        {
            ans += k;
        }
        
    }
    cout << ans << endl;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,x;
  cin >> n >> x;
  ll l[n];
  for(int i=0;i<n;i++)cin >> l[i];

  ll s=0;
  ll c=1;
  for(int i=0;i<n;i++){
    if(s+l[i]<=x){
      c++;
      s+=l[i];
    }
    else break;
  }
  cout << c << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;

void p(bool t){
    if(t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    iosetup;
    int a, b, c, ans = 0, cnt = 0;
    string S, T;
    int v[10];
    cin >> b >> a;
    cout << (int)ceil((double)b / a) << endl;

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N, 0);
  int a;
  for (int i = 0; i < N; i++) 
  {
    cin >> a;
    A.at(a)++;
  }
  
  long long ans = 1;
  bool ok = true;
  
  if (N % 2 == 1)
  {
    if (A.at(0) != 1) ok = false;
    for (int i = 1; i < N; i++) 
    {
      if (i % 2 == 0)
      {
        if (A.at(i) == 2) {ans *= 2; ans %= mod;}
        else {ok = false; break;}
      } else
      {
        if (A.at(i) == 0) {}
        else {ok = false; break;}
      }
    }
  } else
  {
    for (int i = 0; i < N; i++) 
    {
      if (i % 2 == 0)
      {
        if (A.at(i) == 0) {}
        else {ok = false; break;}
      } else
      {
        if (A.at(i) == 2) {ans *= 2; ans %= mod;}
        else {ok = false; break;}
      }
    }
  }
  
  if (!ok) ans = 0;
  
  cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())

a = [int(x) for x in input().split()]

flag = 0

for x in a:
  if x % 2 == 0:
    if x % 3 == 0 or x % 5 == 0:
      continue
    else:
      flag = 1
      break

if flag == 1:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll           long long int
#define pb           push_back
#define F            first
#define S            second
using namespace std;
ll MOD=998244353;
ll n_max=200005;
ll power(long long int n,long long int p)
{
	if(p==0)
		return 1;
	long long int z=power(n,p>>1);
	z=(z*z)%MOD;
	return (p&1)?((z*n)%MOD):z;
}
ll f[200005],fi[200005];
void prefac()
{
	f[0]=1;fi[0]=1;
	for(ll i=1;i<n_max;++i)
	{
		f[i]=(f[i-1]*i)%MOD;
		fi[i]=power(f[i],MOD-2);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,m,k;
    prefac();
    cin>>n>>m>>k;
    ll ans=0,j;
    --n;
    --m;
    for(ll i=0;i<=k;++i)
    {
        j=(power(m,n-i)*fi[n-i])%MOD;
        j=(j*fi[i])%MOD;
        ans+=j;
    }
    ans%=MOD;
    ans=(ans*(f[n]))%MOD;
    ans=(ans*(m+1))%MOD;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 6780
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 人数
        int n;
        // お菓子の種類
        int k;
        
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        k = sc.nextInt();
        
        boolean[] has = new boolean[n + 1];
        
        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            
            for (int j = 0; j < d; j++) {
                has[sc.nextInt()] = true;
            }
        }
        
        int ans = 0;
        for (int i = 1; i < has.length; i++) {
            if (!has[i]) {
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 37608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M, D;
        public void Run()
        {
            var line = Input.ReadIntArray();
            N = line[0];
            M = line[1];
            D = line[2];

            int count2 = D == 0 ? 0 : Math.Max((N - D) - (D + 1) + 1, 0);
            int count1 = N - count2;
            double avg = (count1 + 2 * count2) * 1.0 / (N * 1.0) / (N * 1.0);
            double ret = (M - 1) * avg;
            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>
using namespace std;

const long long mod = 1000 * 1000 * 1000 + 7;



long long binpow(long long a, long long n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        long long b = binpow(a, n / 2);
        return (b * b) % mod;
    }
}

long long modInverse(long long n)
{
    return binpow(n, mod - 2);
}

long long fact(long long n)
{
    long long p = 1;
    for (long long i = 2; i <= n; ++i)
        p = (p * i) % mod;
    return p;
}

long long comb(long long n, long long k)
{
    long long res = 1;
    for (long long i = n - k + 1; i <= n; ++i)
        res = (res * i) % mod;
    res = (res * modInverse(fact(k))) % mod;
    return res;
}

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = (binpow(2LL, n) + mod - 1LL) % mod;
    if (a <= n)
        ans = (ans + mod - comb(n, a)) % mod;
    if (b <= n)
        ans = (ans + mod - comb(n, b)) % mod;
    while (ans < 0)
        ans += mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h1, h2, m1, m2, k, cnt, hr;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cnt  = 60 - m1;
	hr   = h2 - (h1+1);
	cnt += hr * 60 + m2;
	cout << cnt - k << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    double a,b,h,m,pi;
    cin >> a >> b >> h >> m;
  	pi=2*asin(1.0);
    h+=m/60;
    h*=30;
    m*=6;
    double ans=sqrt(a*a+b*b-2*a*b*cos((h-m)/180*pi));
    cout << fixed;
    cout << setprecision(10) << ans;
}

/*
*/



Measured memory_bytes: 4112
#include<stdio.h>
int main(void)
{
	int r,g,b,n;
	scanf("%d %d %d",&r,&g,&b);
	r=r*100;
	g=g*10;
	n=r+g+b;
	if(n%4==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
//????§???¢?????´?§?????§???¢???????????????????????°??????
#include <iostream>
using namespace std;
int main ()
{
int a,b,c,i,p;
cin >> p;
for (i = 0; i < p; i++){
cin >> a >> b >> c;
if (c*c == a*a + b*b || a*a == b*b + c*c || b*b == a*a + c*c){
cout << "YES" << endl;}
else
{cout << "NO" << endl;}
}
return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>

 int main ()
 {
     int n;
     int a,b;
     int j;
     while (scanf ("%d %d", &a, &b)!=EOF  )
     {
         j=0;
         n=a+b;
         while(n>0)
            {
                 n /=10;
                 j++;
            }
         printf("%d\n",j);
      }
    return 0;
 }

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

namespace AtCoder.Abc
{
    class A_167_Registration
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            string r = Console.ReadLine();


             // && s.Length == r.Length - 1
            if (Regex.IsMatch(r, s + "."))
            {
                string result = "Yes";
                Console.WriteLine(result);
            }
            else
            {
                string result = "No";
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


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

using namespace std;
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define freopen(x) freopen(x".in", "r", stdin);freopen(x".out", "w", stdout)
#define var register int

const int LEN = 200001;
const long long MOD = 1e9 + 7;

char s[LEN];

long long pow(int x, int y);

int main() {
	// freopen("e");
	scanf("%s", s + 1);
	int len = strlen(s + 1), num = 0;
	long long res = 0;
	for (var i = 1; i <= len; ++i) {
		if (s[i] == '1')
			(res += (pow(2, num) * pow(3, len - i)) % MOD) %= MOD, num++;
	}
	cout << (res + pow(2, num)) % MOD << endl;
  return 0;
}

long long pow(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (1LL * res * x) % MOD;
		x = (1LL * x * x) % MOD;
		y >>= 1;
	}
	return res;
}


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

int cnt;
char ans[100'001];

void apply2(int *a, int *b, string s, int index)
{
	(*a)++;
	(*b)--;
	ans[cnt++] = s[index];
}

bool solve2(int *X, int *Y, string s)
{
	if (!(*X) && !(*Y))
		return (false);
	if ((*X) > (*Y)) apply2(Y, X, s, 1);
	else apply2(X, Y, s, 0);
	return (true);
}

int	main(void)
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n + 1);
	int A, B, C;
	A = a;
	B = b;
	C = c;
	for (int i = 0; i < n; i++) cin >> s[i];
	s[n] = "ZZ";
	bool flag;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == "AB" && s[i + 1] == "BC") flag = solve2(&B, &A, "BA");
		else if (s[i] == "AB") flag = solve2(&A, &B, "AB");
		else if (s[i] == "BC" && s[i + 1] == "AC") flag = solve2(&C, &B, "CB");
		else if (s[i] == "BC") flag = solve2(&B, &C, "BC");
		else if (s[i] == "AC" && s[i + 1] == "AB") flag = solve2(&A, &C, "AC");
		else flag = solve2(&C, &A, "CA");
		if (flag == false)
		{
			cout << "No" << endl;
			return (0);
		}
	}
	cout << "Yes" << endl;
	for (int i = 0; i < n; i++) cout << ans[i] << endl;
	return (0);
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;

int main(void){
	int A,B,ans;
	cin >> A;
	cin >> B;
	
	if (A > B) {
		ans = A + A - 1;
		cout << ans;
	}
	else if(A<B){
		ans = B + B - 1;
		cout << ans;
	}
	else {
		ans = A + B;
		cout << ans;
	}
	return 0;
}

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

int n;
ll x;

ll total[55];
ll patty[55];

ll solve(int n, ll x){
  ll res=0;
  if (n == 0) return (x >= 0) ? 1 : 0;
  ll center = total[n] / 2;
  if(x==center){
    res += patty[n-1] + 1;
  }else if (x < center) {
    res += solve(n - 1, x - 1);
  } else {
    res += 1 + patty[n-1] + solve(n - 1, x - center - 1);
  }
  return res;
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  cin>>n;
  cin>>x;
  x--;
  total[0]=1;
  patty[0]=1;
  for(int i=1;i<=n;i++){
    total[i] = total[i - 1] * 2 + 3;
    patty[i] = patty[i-1]*2 + 1;
  }
  ll res=solve(n, x);
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rt return
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll a,b,c;
int main()
{
    cin>>a>>b>>c;
    cout<<a*b/2;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w;
char s[500][500];
ll x[800005],y[800005],z[900005];
ll xd[600006],yd[600006];
ll xm[500005],ym[500005];
ll dp[500][500];

int main(){	
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	for(i=0;i<m;i++){
		cin>>y[i];
	}
	for(i=0;i<n-1;i++){
		xd[i] = x[i+1] - x[i];
		xd[i] %= mod;
	}
	for(i=0;i<m-1;i++){
		yd[i] = y[i+1] - y[i];
		yd[i] %= mod;
	}
	for(i=0;i<n-1;i++){
		xm[i] = (((xd[i] * (i+1))%mod) * (n-i-1))%mod;
	}
	for(i=0;i<m-1;i++){
		ym[i] = yd[i] * (i+1);
		ym[i] %= mod;
		ym[i] *= (m-i-1);
		ym[i] %= mod;
	}
	ll sumx=0,sumy=0;
	for(i=0;i<n-1;i++){
		sumx += xm[i];
		sumx %= mod;
	}
	for(i=0;i<m-1;i++){
		sumy += ym[i];
		sumy %= mod;
	}
	p(sumx * sumy %mod);
	return 0;
}

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

string segment[] = {
    "0111111",
    "0000110",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111"
};

int main()
{
    int c, n;
    while(cin >> c && c > 0) {
        string s = "0000000";
        for(int i = 0; i < c; i++) {
            cin >> n;
            string op = "0000000";
            for(int k = 0; k < 7; k++) {
                if(s[k] == segment[n][k]) {
                    op[k] = '0';
                } else {
                    op[k] = '1';
                }
            }
            s = segment[n];
            cout << op << endl;
        }
    }
}

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

int main() {
	int num_people, days, rest_chocolate;
	cin >> num_people >> days >> rest_chocolate;
	vector<int> meal_interval;
	for (int i = 0; i < num_people; i++) {
		int tmp_meal_interval;
		cin >> tmp_meal_interval;
		meal_interval.push_back(tmp_meal_interval);
	}
	int sum_chocolate = 0;
	for (int i = 0; i < num_people; i++) {
		sum_chocolate++;
	//	cout << i << "人目:" << (days - 1) / meal_interval[i] << endl;
		sum_chocolate += (days - 1) / meal_interval[i];
	}
	cout << sum_chocolate + rest_chocolate;
	return 0;
}

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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)

const int inf=1000000000;

main()
{
	ios::sync_with_stdio(false);
	
	int N,K,S; cin>>N>>K>>S;
	for(int i=1;i<=K;i++)
	{
		cout<<S<<" ";
	}
	for(int i=K+1;i<=N;i++)
	{
		if(S!=inf) cout<<inf<<" ";
		else cout<<"1 ";
	}
	
	return 0;
}






















Measured memory_bytes: 1280
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		int h = N / 100;
		int a = N % 100;
		if(N < 100){
			myout(0);
			return;
		}
		if(a != 0){
			int req = (a + 4) / 5;
			if(h >= req){
				myout(1);
			}else{
				myout(0);
			}
		}else{
			myout(1);
		}
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver(int N, ll C, ll K, vector<ll> &A, ll &ans){
    
    sort(A.begin(), A.end());

    ll sum{}, st_time = A.at(0);
    for( int i = 0; i < N; ++i ){
        if( A.at(i) > K+st_time ){
            ++ans;
            sum -= C;
            if( sum < 0 ){
                sum = 0;
            }
            st_time = A.at(i);
        }
        else if( sum >= C ){
            ++ans;
            sum -= C;
            st_time = A.at(i);
        }
        ++sum;
    }

    if( sum != 0){
        if( sum%C == 0 ){
            ans += sum/C;
        }
        else{
            ans += sum/C+1;
        }
    }
    return;
}

int main(){

    int N;
    ll C, K;
    cin >> N >> C >> K;
    vector<ll> A(N);
    for( int i = 0; i < N; ++i){
        cin >> A.at(i);
    }

    ll ans{};
    solver(N, C, K, A, ans);

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


Measured memory_bytes: 4052
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
print((n-1)*n//2)

Measured memory_bytes: 38644
#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <regex>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) obj.begin(), obj.end()
#define UNIQUE(v) v.erase(unique(All(v)), v.end());
typedef long long ll;

typedef pair<int, int> P;
vector<P> vecp;
int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};

#define N 1000
// input

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  if (a >= 13){
    cout << b;
  }else if (a >= 6){
    cout << b / 2;
  }else {
    cout << 0;
  }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1<<30;
enum mod = 10L^^9 + 7;

void main() {
    int h, w, a, b;
    scan(h, w, a, b);

    auto fact = new long[](h + w + 1);
    auto rfact = new long[](h + w + 1);
    fact[0] = 1;
    foreach (i ; 1 .. h + w + 1) {
        fact[i] = (i * fact[i-1]) % mod;
    }
    rfact[h + w] = powmod(fact[h + w], mod - 2);
    foreach_reverse (i ; 0 .. h + w) {
        rfact[i] = (rfact[i+1] * (i + 1)) % mod;
    }

    long comb(int n, int r) {
        return fact[n] * rfact[n-r] % mod * rfact[r] % mod;
    }

    long ans;

    foreach (i ; 0 .. w - b) {
        ans += comb(h - a - 1 + b + i, h - a - 1) * comb(a - 1 + w - b - 1 - i, a - 1) % mod;
        if (ans > mod) ans-= mod;
    }

    writeln(ans);
}



long powmod(long x, long y) {
    return y > 0 ? powmod(x, y>>1)^^2 % mod * x^^(y & 1) % mod : 1;
}












































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4220
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

import math
X = input_int()
# print(math.ceil(math.log2(X / 100) / math.log2(1.01)))
budget = 100
count = 0
while budget < X:
    budget *= 1.01
    budget = int(budget)
    count += 1
print(count)

Measured memory_bytes: 9236
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Maybe (fromJust)
import Debug.Trace

solve :: Int -> Int -> Int
solve x time
    | (x - time) <= 0 = time
    | otherwise = solve (x - time) (time + 1)

main :: IO ()
main = do
    x <- (fst . fromJust . BS.readInt) <$> BS.getLine
    print $ solve x 1

Measured memory_bytes: 380
def main():
    N = int(input())
    P = [int(input()) for _ in [0] * N]

    num = []
    apnd = num.append
    for i, j in enumerate(P):
        apnd([j, i])
    num.sort()

    cnt = 1
    maxcnt = 1
    for i in range(N - 1):
        if num[i][1] < num[i+1][1]:
            cnt += 1
            maxcnt = max(maxcnt, cnt)
        else:
            cnt = 1
    print(N - maxcnt)

main()


Measured memory_bytes: 40924
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
bool solve(string str){
  map<char, int> t;
  t['['] = 1; t[']'] = 1;
  t['('] = 2; t[')'] = 2;
  stack<char> stk;
  REP(i,str.size()){
    if(str[i]=='['||str[i]=='('){
      stk.push(t[str[i]]);
    }else if(str[i]==']'||str[i]==')'){
      if(stk.empty()||stk.top()!=t[str[i]]) return false;
      else stk.pop();
    }
  }
  return stk.empty();
}
int main(){
  string str;
  while(getline(cin,str)){
    if(str==".") break;
    if(solve(str)) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 908
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[K - 1]) {
            S.replace(i, 1, "*");
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define pb push_back 
#define vi vector<int>
#define loop(x,a,b) for(ll x=a; x<b; x++)
#define rloop(x,a,b) for(ll x=a; x>=b; x--)
#define ll long long 
int main()
{
    ll n,sum;
    cin>>n;
    ll ar[n];
    sum = 0;
    loop(i,0,n) cin>>ar[i];
    loop(i,0,n-1){
        if (ar[i]>ar[i+1])
        {
            sum+= ar[i]-ar[i+1];
            ar[i+1] = ar[i];
        }
    }cout<<sum<<endl;
    return 0;
}

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

ll n,m,a[100009][3];
ll maxn = 0;

int main(){
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++) cin >> a[i][j];
	}
	for(int i=0;i<8;i++){
		vector<ll> vec;
		for(int j=1;j<=n;j++){
			ll S=0;
			for(int k=0;k<3;k++){
				if((i/(1<<k))%2==0) S+=a[j][k];
				else S-=a[j][k];
			}
			vec.push_back(S);
		}
		sort(vec.begin(),vec.end()); reverse(vec.begin(),vec.end());
		ll ans=0;
		for(int j=0;j<m;j++) ans+=vec[j];
		maxn = max(maxn,ans);
	}
	cout << maxn << endl;
}


Measured memory_bytes: 256
def main():
    a = input()
    b = input()
    c = input()

    i, j, k = 0, 0, 0

    temp = a[i]

    while True:

        if temp == 'a':
            if i == len(a):
                winner = 'A'
                break
            temp = a[i]
            i += 1
        elif temp == 'b':
            if j == len(b):
                winner = 'B'
                break
            temp = b[j]
            j += 1
        elif temp == 'c':
            if k == len(c):
                winner = 'C'
                break
            temp = c[k]
            k += 1

    print(winner)


if __name__ == '__main__':
    main()


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

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    a = abs(x-a);
    b = abs(x-b);
    if(a < b) cout << 'A' << endl;
    else cout << 'B' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int x,k,d;
    cin>>x>>k>>d;

    x=abs(x);
    int a=x/d;
    if(a>=k){
        cout<<x-k*d<<endl;
        return 0;
    }
    x-=a*d;
    if(x>abs(x-d)){
        a++;
        x=abs(x-d);
    }
    if((k-a)%2){
        cout<<abs(x-d)<<endl;
    }
    else cout<<x<<endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[100];
    int n,i,j=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    for(i=1;i<(n-1);i++)
    {

        if((a[i-1] > a[i] && a[i] > a[i+1])  ||  (a[i-1] < a[i] && a[i] < a[i+1])) j++;

    }

    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

even = []
odd = []

for i in range(0, n, 2):
    even.append(A[i])
for i in range(1, n, 2):
    odd.append(A[i])

if (n-1) % 2 == 0:
    even.reverse()
    ans = even + odd
else:
    odd.reverse()
    ans = odd + even

print(*ans)


Measured memory_bytes: 30856
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> v = {1};

  int nine = 1;
  while(nine <= N){
    nine *= 9;
    v.emplace_back(nine);
  }

  int six = 1;
  while(six <= N){
    six *= 6;
    v.emplace_back(six);
  }

  sort(ALL(v));
  

  int M = v.size();

  // i番目まで使ってjを作る時の最小
  vector<vector<int>> dp(M+1, vector<int>(N+1, INF));
  dp[0][0] = 0;
  REP(i, M) REP(j, N+1){
    chmin(dp[i+1][j], dp[i][j]);
    if(j+v[i] <= N) chmin(dp[i+1][j+v[i]], dp[i+1][j]+1);
  }

  cout << dp[M][N] << "\n";

  return 0;
}

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

int main(){
  vector<string>ans={"Sunny","Cloudy","Rainy"};
  string s;
  int i;
  cin>>s;
  for(i=0;i<3;i++){
    if(s==ans[i])
      break;
  }
  cout<<ans[(i+1)%3]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
using namespace std;
int dp[20005];
int p[10005];
int box[505][2];
const int MAX=100000007;
int main(){
	int m,n;
	int i,j,k;
	int s=0;
	for(i=0;i<20005;i++){dp[i]=MAX;}
	cin>>m>>n;
	for(i=0;i<m;i++){
		cin>>p[i];
	}
	sort(p,p+m,greater<int>());
	for(i=0;i<n;i++){
		cin>>box[i][0]>>box[i][1];
	}
	dp[0]=0;
	for(i=0;i<n;i++){
		for(j=m-1;j>=0;j--){
			dp[j+box[i][0]]=min(dp[j+box[i][0]],dp[j]+box[i][1]);
		}
	}
	for(i=20000;i>=0;i--){
		dp[i]=min(dp[i],dp[i+1]);
	}
	for(i=0,j=0;i<m;i++){
		j+=p[i];
		s=max(s,j-dp[i+1]);
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1LL<<60;
ll dp[100010][3];
ll queri[100010][3];
template<class T>bool chmin(T&a,const T b){if(a>b){a=b;return true;}else return false;}
template<class T>bool chmax(T&a,const T b){if(a<b){a=b;return true;}else return false;}
int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++)for(int j=0;j<3;j++)cin>>queri[i][j];
  for(int i=0;i<N;i++)for(int j=0;j<3;j++)dp[i][j]=-INF;
  for(int j=0;j<3;j++)dp[0][j]=0;
  int flag=-1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(k!=j)
        chmax(dp[i][k],dp[i-1][j]+queri[i-1][k]);
      }
    }
    //cout<<dp[i]<<endl;
  }
  ll res=0;
  for(int i=0;i<3;i++){
    chmax(res,dp[N][i]);
  }
  cout<<res<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005;
int a[N];
int f[N][N];
int n,x;
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		f[i][0]=a[i];
		for(int j=1;j<n;j++)
		{
			int cost=i-j;
			if(cost<=0) cost+=n;
			f[i][j]=min(f[i][j-1],a[cost]);
		}
	}
	long long minx=0x3f3f3f3f3f3f3f3f;
	for(int j=0;j<n;j++)
	{
		long long sum=0;
		for(int i=1;i<=n;i++)
			sum+=f[i][j];
		sum+=(long long)j*x;
		minx=min(sum,minx);
	}
	printf("%lld\n",minx);
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int h, w, num;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int x[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
	int y[9] = { -1, -1,-1, 0, 0, 0, 1, 1, 1 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#')continue;
				num = 0;
			for (int k = 0; k < 9; k++) {
				const int a = i + y[k];
				const int b = j + x[k];
				if (a < 0 || h <= a)continue;
				if (b < 0 || w <= b)continue;
				if (s[a][b] == '#')num++;
			}
			s[i][j] = char(num + '0');
		}
	}

	for (int i = 0; i < h; i++) {
		cout << s[i] << endl;
	}
		

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int p[5];
    int k;
    bool ans = true;
    for(int i = 0; i < 5; i++)
    {
        cin >> p[i];
    }
    cin >> k;
    for(int i = 0; i < 5; i++)
    {
        for(int j = i; j < 5; j++)
        {
            if (p[j] - p[i] > k) {
                ans = false;
                break;
            }
        }
        
    }
    if (ans) {
        cout << "Yay!";
    } else {
        cout << ":(";
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
c = []
for i in range(n):
  s.append(list(map(int, input().split())))
for i in range(m):
  c.append(list(map(int, input().split())))

ans = []
for i in range(n):
  d = {}
  for j in range(m):  
    d[j + 1] = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
  d = sorted(d.items(), key=lambda x:x[1])
  ans.append(d[0][0])
for e in ans:
  print(e)

Measured memory_bytes: 3064
fn main() {
    let v = read_vec::<usize>();
    let a = v[0];
    let b = v[1];

    if a < b {
        for _ in 0..b {
            print!("{}", a);
        }
    } else {
        for _ in 0..a {
            print!("{}", b);
        }
    }
    println!("");
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
"use strict"
function main(arg) {
    let data = arg.trim().split("\n")[0].split("")
    let max = 0
    let counter = 0
    for (let i = 0; i < data.length; i++) {
        if (data[i] === 'R') {
            counter++
            max = Math.max(max, counter)
        } else {
            counter = 0
        }
    }
    console.log(max)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29680
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
	string s;
	cin>>s;
	int f = 0,flag = 0;
	for(int i = 0;i < s.length();i++){
		if(s[0] == 'A'){
			if(s[1] == 'C'){
				f++; 
			}
			if(s[s.length()-1] == 'C'){
				f++;
			}
		}
		if(s[0] != 'A') f++;
		if('A'<=s[i]&&s[i]<='Z'){
			flag++;
		}
	}
	if(flag == 2&&f == 0)
		cout<<"AC"<<endl;
	else
		cout<<"WA"<<endl;
			
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[100005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	cin >> b;
	for (int i = 0; i < a; i++)
	{
		cin >> memo[i];
		if (memo[i]>b)
		{
			ans += memo[i] - b;
			memo[i] = b;
		}
	}
	for (int i = 0; i < a-1; i++)
	{
		if (memo[i]+memo[i+1]>b)
		{
			ans += memo[i] + memo[i + 1] - b;
			memo[i + 1] -= memo[i] + memo[i + 1] - b;
		}
	}
	cout <<ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 1024