akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<iostream>
int hideo[2000001] = { 0 };
int main(void)
{
	int noyori = 0, debu = 0, n, temp = 1, ruio[32] = { 0 }, x;
	while (scanf("%d %d", &n, &x)) {
		if (n == 0 && x == 0) {
			return 0;
		}
		for (int i = 1; i <= n; i++) {
			scanf("%d", &ruio[i]);
			hideo[ruio[i]] = 1;
		}
		while (temp != x) {
			if (hideo[temp] == 1) {
				for (int j = 1; j <= n; j++) {
					if (temp + ruio[j] > x)continue;
					if (hideo[temp + ruio[j]] == 0) {
						hideo[temp + ruio[j]] = 1;
					}
				}
			}
			temp++;
		}
		for (int i = x; i >1; i--) {
			if (hideo[i] == 1) {
				for (int j = 2; j < i - 1; j++) {
					if (i%j == 0) {
						debu = 1;
					}
				}
				if (debu == 0) {
					noyori = i;
					break;
				}
			}
			debu = 0;
		}
		if (noyori > 1) {
			printf("%d\n", noyori);
		}
		else {
			printf("NA\n");
		}
		temp = 1;
		noyori = 0;
		debu = 0;
		memset(ruio, 0, sizeof(ruio));
		memset(hideo, 0, sizeof(hideo));
	}
	return 0;
}

Measured memory_bytes: 10884
import java.io.InputStream

const val MOD = (1e9 + 7).toInt()

fun main(args: Array<String>) = input.run {
    val n = nextInt() + 1
    val a = nextInts(n)
    val first = IntArray(n) { -1 }
    var x = -1
    var y = -1
    a.forEachIndexed { i, value ->
        if (first[value] != -1) {
            x = first[value]
            y = i
        } else {
            first[value] = i
        }
    }

    val fact = IntArray(n + 1)
    fact[0] = 1
    (1..n).forEach {
        fact[it] = (fact[it - 1] * it.toLong() % MOD).toInt()
    }

    fun modInv(x: Int) = x.powMod(MOD - 2L, MOD)

    fun choose(n: Int, m: Int) =
            if (m <= n) fact[n] * modInv((fact[m] * fact[n - m].toLong() % MOD).toInt()).toLong() % MOD else 0

    (1..n).forEach { m ->
        var ans = 0L
        ans += choose(n - 2, m)
        if (m > 1) {
            ans += choose(n - 2, m - 2)
        }
        ans += choose(n - 2, m - 1)
        ans += choose(n - 2, m - 1)
        ans -= choose(n - (y - x + 1), m - 1)
        ans += MOD
        println(ans % MOD)
    }
}

val input = FastScanner()

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()

    fun nextInts(n: Int) = IntArray(n) { nextInt() }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}

fun Int.powMod(n: Long, mod: Int): Int {
    assert(n >= 0)
    assert(mod > 0)

    var ans = 1L % mod
    var y = toLong()
    var m = n
    while (m > 0) {
        if ((m and 1) != 0L) {
            ans *= y
            ans %= mod
        }
        y *= y
        y %= mod
        m = m shr 1
    }
    return ans.toInt()
}

Measured memory_bytes: 40256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n, k; string s; cin >> n >> k >> s;
    transform (s.begin()+(k-1), s.begin()+k, s.begin()+(k-1), ::tolower);
	cout << s << endl;
	return 0;
}

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

int main(){
int N;
string str;
int cnt[4]={0};
cin>>N;

for(int i=0;i<N;i++){
cin>>str;
if(str=="AC"){
    cnt[0]++;
}else if(str=="WA"){
    cnt[1]++;
}else if(str=="TLE"){
    cnt[2]++;
}else if(str=="RE"){
    cnt[3]++;
}
}


    cout<<"AC x "<<cnt[0]<<endl;
    cout<<"WA x "<<cnt[1]<<endl;
    cout<<"TLE x "<<cnt[2]<<endl;
    cout<<"RE x "<<cnt[3]<<endl;


}

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

struct Dice {
  int face[6];
  bool operator == (const Dice& other) {
    for (int i = 0; i < 6; i++) if (face[i] != other.face[i]) return false;
    return true;
  }
  bool operator != (const Dice& other) {
    return !(*this == other);
  }
  void roll(int a, int b, int c, int d) {
    int tmp = face[a];
    face[a] = face[b];
    face[b] = face[c];
    face[c] = face[d];
    face[d] = tmp;
  }
  void roll(char c) {
    switch (c) {
      case 'N' : roll(0, 1, 5, 4); break;
      case 'S' : roll(0, 4, 5, 1); break;
      case 'E' : roll(0, 3, 5, 2); break;
      case 'W' : roll(0, 2, 5, 3); break;
      case 'R' : roll(1, 2, 4, 3); break;
      case 'L' : roll(1, 3, 4, 2); break;
    }
  }
  bool identical(Dice other) {
    for (int i = 0; i < 6; i++) {
      other.roll(i & 1 ? 'E' : 'N');
      for (int j = 0; j < 4; j++) other.roll('R');
      if (*this == other) return true;
    }
    return false;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  Dice D;
  for (int i = 0; i < 6; i++) {
    cin >> D.face[i];
  }
  string s;
  cin >> s;
  for (auto c : s) {
    D.roll(c);
  }
  cout << D.face[0] << endl;

  return 0;
}


Measured memory_bytes: 3228
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
 ll MOD = 998244353LL;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 1e7+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    boost
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(b-1, n);
    cout << (a*x)/b - a*(x/b) << endl;
}


Measured memory_bytes: 3608
import bisect

MAX = 60000

#エラトステネスの篩
is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
  if is_prime[i]:
    for j in range(i ** 2, MAX, i):
      is_prime[j] = False

primes = [i for i in range(MAX) if is_prime[i]]

while True:
  try:
    n = int(input())
    ind = bisect.bisect_left(primes, n)
    if primes[ind] == n:
      print(primes[ind - 1], primes[ind + 1])
    else:
      print(primes[ind - 1], primes[ind])

  except EOFError:
    break


Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <pair <ll, ll>> v(m);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    v.at(i) = make_pair(a, b);
  }
  if (n==1) {
    for (ll i = 0; i <= 10; i++) {
      if (i == 10) {
        cout << -1 << endl;
      } else {
        
      string str = to_string(i);
      ll tmp = 0;
      rep(j, m) {
        if (ctoi(str.at(v.at(j).first-1))!=v.at(j).second) {
          tmp++;
          break;
        }
      }
      if (tmp == 0) {
        cout << i << endl;
        break;
      }
    }
    }
  } else if (n==2) {
    for (ll i = 10; i <= 100; i++) {
      if (i == 100) {
        cout << -1 << endl;
      } else {
      string str = to_string(i);
      ll tmp = 0;
      rep(j, m) {
        if (ctoi(str.at(v.at(j).first-1))!=v.at(j).second) {
          tmp++;
          break;
        }
      }
      if (tmp==0) {
        cout << i << endl;
        break;
      }
    }
    }
  } else {
    for (ll i = 100; i <= 1000; i++) {
      if (i == 1000) {
        cout << -1 << endl;
      } else {
      string str = to_string(i);
      ll tmp = 0;
      rep(j, m) {
        if (ctoi(str.at(v.at(j).first-1))!=v.at(j).second) {
          tmp++;
          break;
        }
      }
      if (tmp==0) {
        cout << i << endl;
        break;
      }
    }
  }
  }
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

// auto mod int
const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint (ll x = 0) : x ((x % mod + mod) % mod) {}
    mint operator-() const { return mint (-x); }
    mint &operator+= (const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-= (const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*= (const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+ (const mint a) const { return mint (*this) += a; }
    mint operator- (const mint a) const { return mint (*this) -= a; }
    mint operator* (const mint a) const { return mint (*this) *= a; }
    mint pow (ll t) const {
        if (!t) return 1;
        mint a = pow (t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow (mod - 2); }
    mint &operator/= (const mint a) { return *this *= a.inv(); }
    mint operator/ (const mint a) const { return mint (*this) /= a; }
};
istream &operator>> (istream &is, const mint &a) { return is >> a.x; }
ostream &operator<< (ostream &os, const mint &a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination (int n) : fact (n + 1), ifact (n + 1) {
        assert (n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator() (int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} c (200005);

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    mint ans = 0;
    mint col = m;
    for (int i = n - 1; i >= 0; i--) {
        mint now = col;
        now *= c (n - 1, i);
        if (i <= k) ans += now;
        col *= m - 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6220
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int):
    if A + B > C + D:
        ret = 'Left'
    elif A + B < C + D:
        ret = 'Right'
    else:
        ret = 'Balanced'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  ll k;
  cin>>n>>k;

  vector<ll> p(n);
  vector<ll> q(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];

  sort(all(p));
  sort(all(q));
  reverse(all(q));

//————————————————二分探索——————————————————————————

  ll ng = -1;
  ll ok = 1e13;
  while (abs(ok - ng) > 1) {
    ll mid = (ng + ok) / 2;

    ll cnt=0;
    rep(i,n){
      ll x = mid/q[i];
      if(x<p[i]) cnt+=p[i]-x;
    }
    (cnt<=k? ok : ng) = mid;
  }

  cout << ok << endl;

}

Measured memory_bytes: 6356
import java.util.Scanner;
     
class Main {
   public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    String S = stdIn.next();
     switch (S) {
       case "Sunny": System.out.println("Cloudy");
       break;
       case "Cloudy": System.out.println("Rainy");
       break;
       case "Rainy": System.out.println("Sunny");
       break;
  }
 }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<lld,int> Pd;
typedef pair<lld,lld> P;
#define INF ((lld)1<<50)

lld n,m,C;
vector<P> node[200010];
lld min_cost[100010];
vector<P> X;
lld sum = 0;

int main(){
  cin >> n >> m >> C;
  for(int i=0;i<m;i++){
    lld a,b,c; cin >> a >> b >> c;
    a--; b--; sum += c;
    node[a].push_back(P(b,c));
    node[b].push_back(P(a,c));
  }
  fill_n(min_cost,100010,INF);
  priority_queue<P,vector<P>,greater<P> > que;
  min_cost[0] = 0;
  que.push(P(0,0));
  while(!que.empty()){
    P p = que.top(); que.pop();
    lld cnt = p.first;
    lld pos = p.second;
    if(min_cost[pos] < cnt) continue;
    for(int i=0;i<node[pos].size();i++){
      P pi = node[pos][i];
      lld next = pi.first, cost = pi.second;
      if(min_cost[next] > cost + cnt){
        min_cost[next] = cost + cnt;
        que.push(P(cost+cnt,next));
      }
    }
  }
  for(int i=0;i<n;i++){
    X.push_back(P(min_cost[i],i));
  }
  sort(X.begin(),X.end());
  X.push_back(P(INF,0));
  lld ret = INF;
  bool used[100010];
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++){
    int pos = X[i].second;
    used[pos] = true;
    for(int j=0;j<node[pos].size();j++){
      if(used[node[pos][j].first]) sum -= node[pos][j].second;
    }
    if(i != n-1 && X[i].first == X[i+1].first) continue;
    ret = min(ret,sum+C*X[i].first);
  }
  cout << ret << endl;
}

Measured memory_bytes: 19764
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String s[]  =sc.next().split(":");
			double hour, minute;
			hour = 360.0 * Double.valueOf(s[0]) / 12 + 30.0 * Double.valueOf(s[1]) / 60;
			minute = 360.0 * Double.valueOf(s[1]) / 60;
			
			double diff = Math.abs(minute - hour);
			if (180.0 < diff) {
				diff = 360.0 - diff;
			}
			if (0.0 <= diff && diff < 30.0) {
				System.out.println("alert");
			} else if (90.0 <= diff && diff <= 180.0) {
				System.out.println("safe");
			} else {
				System.out.println("warning");
			}
		}
	}
}

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

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];

  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  sort(r.begin(), r.end());
  p.resize(x);  
  q.resize(y);

  vector<ll> eat;
  while(1) {
    if(r.size() == 0 || (p.size() == 0 && q.size() == 0)) break;
    if(p.size() == 0) {
      if (q.back() < r.back()) {
        q.pop_back();
        eat.push_back(r.back());
        r.pop_back();
      } else {
        break;
      }
    } else if (q.size() == 0) {
      if(p.back() < r.back()) {
        p.pop_back();
        eat.push_back(r.back());
        r.pop_back();
      } else {
        break;
      }
    } else if (p.back() <= q.back()) {
      if(p.back() < r.back()) {
        p.pop_back();
        eat.push_back(r.back());
        r.pop_back();
      } else {
        break;
      }
    } else {
      if(q.back() < r.back()) {
        q.pop_back();
        eat.push_back(r.back());
        r.pop_back();
      } else {
        break;
      }
    }
  }

  ll ans = 0;
  rep(i,p.size()) ans += p[i];
  rep(i,q.size()) ans += q[i];
  rep(i,eat.size()) ans += eat[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3704
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int A, B;
	cin >> A >> B;
	A = (A + 11) % 13;
	B = (B + 11) % 13;
	if (A > B) {
		cout << "Alice" << endl;
	}
	else if (A < B) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
}


Measured memory_bytes: 256
M, D = map(int, input().split())
count = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d % 10
        d2 = (d//10) % 10
        if d1 >= 2 and d2 >= 2 and d1*d2 == m:
            count += 1
print(count)


Measured memory_bytes: 2940
n = int(input())
a = list(map(int,input().split()))

b = [0]*n
c = 0
for i in range(n):
	if a[i] < 0:
		c += 1
		b[i] = -a[i]
	else:
		b[i] = a[i]

b.sort()
if c%2 == 1:
	b[0] = -b[0]
print(sum(b))


Measured memory_bytes: 20052
#coding: utf-8                                                                  

def one_game():
    n = int(input())
    if n == 0:
        return False
    
    s = [list(map(int, input().split(' '))) for i in range(n)]

    win = {True: 0, False: 0}
    for a, b in s:
        if a == b:
            win[True] += a
            win[False] += a
            continue
        win[a>b] += (a + b)

    print(win[True], win[False])
    return True


while one_game() is True:
    a = 0

Measured memory_bytes: 9436
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans,P;
int a[1000001],g[100001],ni=0,gg[100001],nt;
signed main(){
	cin>>n>>a[1]>>P;
	int np=a[1],lp=np;
	while(!g[np]){
		ans+=np;gg[np]=ans;
		g[np]=++ni;if(ni>=n)break;lp=np;np=np*np%P;
	}
	if(ni>=n){
		printf("%lld\n",ans);
		return 0;
	}
	
	ni++;nt=ans-gg[np]+np;
	int nn=(n-g[lp])%(ni-g[np]);ans+=(n-g[lp])/(ni-g[np])*nt;
	for(int i=np,ni=1;ni<=nn;ni++,i=i*i%P)ans+=i;
	printf("%lld\n",ans);
	return 0;
}
/*
100 4 17
10 4 7
*/

Measured memory_bytes: 5208
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<double> p(N);
  rep(i, N) cin >> p[i];

  vector<vector<double>> dp(N + 10, vector<double>(N + 10, 0));
  dp[0][0] = 1.0;
  for (int i = 0; i < N; ++i){
    for (int j = 0; j < N; ++j){
      if (i + j >= N) continue;
      dp[i + 1][j] += dp[i][j] * p[i + j];
      dp[i][j + 1] += dp[i][j] * (1 - p[i + j]);
    }
  }
  double ans = 0;
  for (int i = N / 2 + 1; i <= N; ++i) {
    int j = N - i;
    ans += dp[i][j];
  }
  printf("%.10f\n", ans);
}


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

using namespace std;
int main(void) {
  int N, total = 0;
  int num[110];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> num[i];
  if (N % 2 == 1) num[N] = 0;
  sort(num, num + N, greater<int>());
  for (int i = 0; i < N; i += 2) {
    total += (num[i] - num[i + 1]);
  }
  cout << total;
  return 0;
}

Measured memory_bytes: 3540
#include<stdio.h>
int main (){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(0<=a,b,c<=100){
		if(a<b && b<c){
		printf("Yes\n");
		}else{
		printf("No\n");
		}
	}else{
	printf("NOT\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
struct UnionFind{
    int n;
    set<int> dame;
    vi p;
    vi use;
    UnionFind(int N):n(N){
        p.resize(n);
        use.resize(n);
    	iota(all(p),0);
    	rep(i,n){
    	    int tmp;
    	    cin>>tmp;
    	    unite(i,tmp+i);
    	}
    }
    void unite(int a, int b){int c=root(a),d=root(b); if(c!=d) p[c]=d; else if(a!=b) dame.insert(root(a));}
    int root(int a){return p[a]=(p[a]==a?a:root(p[a]));}
    bool same(int a, int b){return root(a)==root(b);}
    void useable(){
        set<int> tmp;
        //for(auto i :dame)tmp.insert(root(i));
        //dame=tmp;
        rep(i,n){
            use[i]=dame.find(root(i))==dame.end();
        }
    }
};
int main(){
	int n;
	cin>>n;
	UnionFind uf(n);
	uf.useable();
    vi turn(n,-1);
    turn[0]=0;
    queue<int> que;
    que.push(0);
    while(turn[n-1]==-1){
        int c=que.front();que.pop();
        range(d,1,7){
            if(c+d<n && uf.use[c+d] && turn[uf.p[c+d]]==-1){
                que.push(uf.p[c+d]);
                turn[uf.p[c+d]]=turn[c]+1;
            }
        }
    }
    cout<<turn[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4572
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(1000000)

n = int(input())
link = [[] for _ in range(n)]
for i in range(n-1):
    ut, vt, wi = list(map(int, input().split()))
    ui = ut - 1
    vi = vt - 1
    link[ui].append((vi, wi))
    link[vi].append((ui, wi))
color = [-1] * n

def dfs(index, c):
    color[index] = c
    for nxt, w in link[index]:
        if color[nxt] == -1:
            dfs(nxt, ((w % 2) + c) % 2)

def main():
    dfs(0, 0)
    for c in color:
        print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83528
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [minmax_assign] *!*/
/*+* 最大値、最小値の代入 *+*/
template<class T>bool max_assign(T&x,const T y){if(x < y) { x = y; return true;} else return false;}
template<class T>bool min_assign(T&x,const T y){if(x > y) { x = y; return true;} else return false;}

bool append_basis(vector<i64> &basis, i64 x) {
    i64 y = x;
    for(i64 b : basis) {
        min_assign(y, b ^ y);
    }
    if(y == 0) return false;
    basis.push_back(y);
    return true;
}

bool is_element_of(const vector<i64> &basis, i64 x) {
    for (i64 b : basis) {
        min_assign(x, b ^ x);
    }
    return x == 0;
}

int main() {
    int T;
    cin >> T;
    for(int t = 0; t < T; t++) {
        int N;
        cin >> N;
        vector<i64> A(N);
        for(i64 &x : A) cin >> x;
        string S;
        cin >> S;
        vector<i64> basis;
        for(int i = N - 1; i >= 0; i--) {
            if(S[i] == '0') {
                append_basis(basis, A[i]);
            } else if(S[i] == '1') {
                if(!is_element_of(basis, A[i])) {
                    basis.clear();
                    break;
                }
            }
        }
        cout << (basis.empty() ? 1 : 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
import sys


def input():
    return sys.stdin.readline()[:-1]

#N = int(input())
#A = [int(x) for x in input().split()]
#a, b, c = map(int, input().split())
#name1 = str(input())
#alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b, c = map(int, input().split())
if b >= c:
    print("delicious")
elif c-b <= a:
    print("safe")
else:
    print("dangerous")


Measured memory_bytes: 2940
#include<stdio.h>
 
int main(void){
int n;
int i = 0;
float x1,y1,x2,y2,x3,y3,x4,y4;
double a,b;
scanf("%d",&n);
while(scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4) != EOF){
if( i >= n )break;
a = (y2 - y1) / (x2 - x1);
b = (y4 - y3) / (x4 - x3);
if( a == b ){
printf("YES\n");
}else{
printf("NO\n");
}
i++;
}
return 0;
}

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

int main() {
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int dp[n];
	dp[0]=0;dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

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

using namespace std;

int N, h[100000], dp[100000];

int main(){
	// 入力
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> h[i];
	
	// 順に解く
	for(int i = 0; i < N; ++i){
		if(i == 0) dp[i] = 0;
		else if(i == 1) dp[i] = abs(h[0] - h[1]);
		else dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]));
	}
	
	// 解を出力
	cout << dp[N-1] << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
    --p[i];
  }

  int ans = 0;
  rep(i, n) if (p[i] == i) {
    ++ans;
    ++i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3768
#C - たくさんの数式

S = input()

total = 0

for i in range(2**(len(S)-1)):
  bin_i = format(i,'0'+str(len(S)-1)+'b')
  p = 0
  total += (10**p)*int(S[-1])
  for j in range(len(S)-1):
    if bin_i[-(j+1)] == '0':
      p += 1 
    else:
      p = 0
    total += (10**p)*int(S[-(j+2)])
    
print(total)

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


int main () {
    int n, k, r, s, p; 
    cin >> n >> k;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    int ret = 0;
    vector<int> loose(n, 0);
    for (int i = 0; i < n; ++i) {
        if ((i >= k) && (t[i] == t[i-k]) && !loose[i-k]) {
            loose[i] = 1;
            continue;
        }
        if (t[i] == 'r') ret += p;
        else if (t[i] == 's') ret += r;
        else ret += s;

    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 896
using System;

class Program
    {
        static void Main()
        {
            while (true)
            {
                string[] line = Console.ReadLine().Split(' ');

                int height = int.Parse(line[0]);
                int width = int.Parse(line[1]);

                if (height == 0 && width == 0)
                    break;

                for (int i = 0; i < height; i++)
                {
                    for (int j = 0; j < width; j++)
                    {
                        Console.Write("#");
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
        }
    }

Measured memory_bytes: 5276
#include <iostream>  
using namespace std;  
int n,m;  
void f(){  
    for(int i=0;i<=2000;i++){  
        for(int j=0;j+i<=2000&&i+j<=n;j++){  
            if(i*10000+j*5000+(n-i-j)*1000==m)  
            {  
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;  
                return;  
            }  
        }  
    }  
     cout<<-1<<" "<<-1<<" "<<-1<<endl;  
}  
int main() {  
    scanf("%d%d",&n,&m);  
    f();  
    //std::cout << "Hello, World!\n";  
      
    return 0;  
}  

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

const int mod = 1e9 + 7;
const int INF = 1e18;

typedef pair<int,int> P;

int n, m, s, t, d[2][100005], cnt[2][100005];
vector<P> G[100005];

void dijkstra(int S, int idx){
  
  for(int i=0;i<n;i++) d[idx][i] = INF;
    
  priority_queue<P,vector<P>,greater<P> > q;
  
  d[idx][S] = 0;
  cnt[idx][S] = 1;
  
  q.push(P( 0, S ));
  
  while( !q.empty() ){
    
    P tmp = q.top(); q.pop();
    
    int node = tmp.second;
    int cost = tmp.first;
    
    if( d[idx][node] < cost ) continue;
    
    for(P p : G[node] ){
      
      int nnode = p.first;
      int ncost = cost + p.second;
      
      if( d[idx][nnode] > ncost ){
	
	d[idx][nnode] = ncost;
	
	cnt[idx][nnode] = cnt[idx][node];
	cnt[idx][nnode] %= mod;
	
	q.push(P( ncost, nnode ));
	
      }
      else if( d[idx][nnode] == ncost ){
	
	cnt[idx][nnode] += cnt[idx][node];
	cnt[idx][nnode] %= mod;
	
      }
      
    }    
    
  }
    
}

int used[100005];

set<P> usede;
set<int> usedn;

void dfs(int x){
  
  if( used[x] ) return;
  used[x] = 1;
  
  usedn.insert( x );
  
  for(P p : G[x] ){
    
    int nx = p.first;
    int cost = p.second;
    
    if( d[0][x] - cost == d[0][nx] ){
      
      usede.insert(P( nx, x ));
      
      dfs( nx );
      
    }
    
  }
  
}

void solve(){
  
  dfs(t);
  
  int ans = 0, all = cnt[0][t] * cnt[0][t], mincost = d[0][t];

  assert( cnt[0][t] == cnt[1][s] );
  
  ans = all % mod;

  for(int i=0;i<n;i++){
    
    if( !usedn.count(i) ) continue;
    
    if( mincost % 2 == 0 && mincost / 2 == d[0][i] ){
      
      int x = cnt[0][i] * cnt[1][i] % mod;
      
      ans = ( ans - x * x % mod + mod );
      
      ans %= mod;
      
    }
    
  }
  
  for(int i=0;i<n;i++){
    
    double mid = mincost / 2.0;
    
    for(P p : G[i] ){
      
      int ni = p.first;
      
      if( !usede.count( P( i, ni ) ) ) continue;
      
      if( d[0][i] < mid && mid < d[0][ni] ){
	
	int x = cnt[0][i] * cnt[1][ni] % mod;
	
	ans = ( ans - x * x % mod + mod );
	
	ans %= mod;

      }
      
    }
    
  }
  
  cout<<ans<<endl;
  
}

signed main(){
  
  cin>>n>>m;

  cin>>s>>t;
  
  s--, t--;
  
  for(int i=0;i<m;i++){
    int u, v, c;
    cin>>u>>v>>c;
    G[u-1].push_back(P(v-1, c));
    G[v-1].push_back(P(u-1, c));
  }
  
  dijkstra( s, 0 );
  
  dijkstra( t, 1 );
  
  solve();
  
  return 0;
}


Measured memory_bytes: 34980
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

lcm = 1
for a in A:
    lcm = lcm // gcd(lcm,a) * a

ans = 0
for a in A:
    ans += lcm // a
ans %= MOD
print(ans)

Measured memory_bytes: 6112
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryH = readInts()
    //_______________________ここまで入力
    
    var left = 0
    var right = 1
    var ans = 0
    
    while right < n {
        if aryH[right - 1] < aryH[right] {
            ans = max(right - left - 1, ans)
            left = right
        }
        right += 1
    }
    print(max(ans, right - left - 1))
}

main()


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

long long m, n;

int main()
{
    cin>>n>>m;
    if(n==1&&m>=3)
    {
        cout<<m-2;
        return 0;
    }
    if(m==1&&n>=3)
    {
        cout<<n-2;
        return 0;
    }
    if(n==2||m==2)
    {
        cout<<0;
        return 0;
    }
    if(n==1&&m==1)
    {
        cout<<1;
        return 0;
    }
    cout<<n*m-n-n-m-m+4;
}

Measured memory_bytes: 256
/*
dpで書いたやつの解説

”i円までの最適を考える”
という感じで考える

i円集めるには高々i回
操作すればいいので
各要素をiで初期化

要素の個数は
9^7=4782969なので
5000000くらいあれば
十分

あとは配るdpで各要素を
最小化する

dp[n]を出力

補足として
要素数に十分ゆとりがあるから
i番目をi円集める最小
にするとわかりやすいかなと思って
出力がdp[n]でよい

では本文をどうぞ
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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;
}

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n; ci(n);
  vll dp(5000000);
  FOR(i,1,5000000){
    dp[i]=i;
  }
  FOR(i,0,n){
    FOR(j,0,8){
      ll a=pow(6,j);
      ll b=pow(9,j);
      chmin(dp[i+a],dp[i]+1);
      chmin(dp[i+b],dp[i]+1);
    }
  }
  co(dp[n])
}


Measured memory_bytes: 39552
#include <iostream>
#include <algorithm>
#include <string>

int main() {
    std::string str;
    int a[3];
    
    for(int& i : a)
        std::cin >> i;
    //std::cin >> str;
    
    std::sort(a, a + 3);
    
    if (a[0] == 5 && a[1] == 5 && a[2] == 7)
        std::cout << "YES"  << std::endl;
    else std::cout << "NO" << std::endl;
}

Measured memory_bytes: 764
import           Control.Exception     (assert)
import           Control.Monad
import qualified Control.Monad.ST      as ST
import qualified Data.Array.ST         as ST
import qualified Data.Array.Unboxed    as A
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe

warshallFloyd :: A.UArray (Int, Int) Int -> A.UArray (Int, Int) Int
warshallFloyd iarr = oarr
  where
    l  = (fst . fst . A.bounds) iarr
    l' = (snd . fst . A.bounds) iarr
    r  = (fst . snd . A.bounds) iarr
    r' = (snd . snd . A.bounds) iarr
    oarr = assert (l==l' && r==r') $ ST.runSTUArray $ do
      d <- ST.thaw iarr
      forM_ [l..r] $ \k ->
        forM_ [l..r] $ \i ->
          forM_ [l..r] $ \j -> do
            dik <- ST.readArray d (i,k)
            dkj <- ST.readArray d (k,j)
            dij <- ST.readArray d (i,j)
            when (dik + dkj < dij) $
              ST.writeArray d (i,j) (dik + dkj)
      return d

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  let infty = 10^6 :: Int

  [h, w] <- getIntList
  g <- replicateM h getLine

  let pos y x | (x < 0 || x >= w || y < 0 || y >= h) = False
              | otherwise = let c = (g !! y) !! x
                            in c == '.'

      arr = ST.runSTUArray $ do
        marr <- ST.newArray ((0,0),(h*w-1,h*w-1)) infty
        forM_ [0..(h-1)] $ \y -> do
          forM_ [0..(w-1)] $ \x -> do
            when (pos y x) $ do
              let p0 = y*w+x
              ST.writeArray marr (p0,p0) 0
              when (pos y (x-1)) $ ST.writeArray marr (p0,y*w+x-1) 1
              when (pos y (x+1)) $ ST.writeArray marr (p0,y*w+x+1) 1
              when (pos (y+1) x) $ ST.writeArray marr (p0,(y+1)*w+x) 1
              when (pos (y-1) x) $ ST.writeArray marr (p0,(y-1)*w+x) 1
        return marr

      arr' = warshallFloyd arr

      ans = maximum $
        map (\((_,_),d) -> if d < infty then d else 0) $ A.assocs arr'

  print ans

Measured memory_bytes: 5116
# AtCoder
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 1000000007
dp = [1]*(N+1)
for i in a:
    dp[i] = False

for i in range(2, N+1):
    if dp[i] != False:
        dp[i] = (dp[i-1]+dp[i-2]) % MOD
print(dp[N])


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - (h * W + w * (H - h)) << endl;
}


Measured memory_bytes: 384
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m, c = na()
b = na()
ans = 0
for i in range(n):
    a = na()
    s = c
    for j in range(m):
        s += a[j]*b[j]
    if s > 0:
        ans += 1
print(ans)


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

ll ans = 0, black = 0, white = 0;
int starti = 0, startj = 0;
char c[410][410]={'x'};

void dfs(int i,int j,char k){
    if(c[i][j]!=k||c[i][j]=='x')
        return;

    char l = '#';
    if(k=='#'){
        l = '.';
        black++;
    }
    else
        white++;

    c[i][j] = 'x';

    dfs(i - 1, j, l);
    dfs(i + 1, j, l);
    dfs(i, j + 1, l);
    dfs(i, j - 1, l);

    if(starti==i&&startj==j){
        ans += white * black;
        white = 0;
        black = 0;
    }
}



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

    int h, w;
    cin >> h >> w;

    
    rep(i, h) rep(j, w) cin >> c[i+1][j+1];

    forx(i,1,h+1)forx(j,1,w+1){
        starti = i;
        startj = j;
        dfs(i, j,c[i][j]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5376
for i in range(20000):
    S = input().split()
    if S[1] == "?":
        exit()
    elif S[1] == "+":
        print(int(S[0]) + int(S[2]))
    elif S[1] == "-":
        print(int(S[0]) - int(S[2]))
    elif S[1] == "*":
        print(int(S[0])*int(S[2]))
    elif S[1] == "/":
        print(int(S[0])//int(S[2]))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string a,b;
	cin>>a>>b;
	l=0;
	for(i=0;i<3;i++)
	{
	    if(a[i]==b[i])
	    {
	        l++;
	    }
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
A = list(input())
n = len(A)

for i in range((n-1)//2):
  if A[i] != A[n-1-i]:
    print('No')
    break
else:
  for i in range((n-1)//2):
    if A[i] != A[(n-3)//2 - i]:
      print('No')
      break
  else:
    print('Yes')

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

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

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

const ll INF=1e18;
const ll MOD=1e9+7;

ll cost[4];
ll dv[3] = { 2, 3, 5 };
map<ll, ll> memo;

ll getCost(ll n)
{
    if (n == 0) return 0;
    if (n == 1) return cost[3];
    if (memo.count(n)) return memo[n];

    ll res = INF;
    if (n < res/cost[3]) res = n*cost[3];
    rep(i,3) {
        if (n % dv[i] == 0) {
            res = min(res, getCost(n/dv[i]) + cost[i]);
        } else {
            ll lo = n / dv[i] * dv[i];
            ll hi = lo + dv[i];

            res = min(res, getCost(lo/dv[i]) + cost[i] + (n-lo)*cost[3]);
            res = min(res, getCost(hi/dv[i]) + cost[i] + (hi-n)*cost[3]);
        }
    }
    memo[n] = res;
    return res;
}

int main(int, char**)
{
    int t;
    cin >> t;

    ll n;
    vector<ll> ans;
    rep(i,t) {
        cin >> n;
        rep(j,4) cin >> cost[j];
        ans.push_back(getCost(n));
        memo.clear();
    }
    for (ll a : ans) cout << a << endl;

    return 0;
}

Measured memory_bytes: 4472
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;


    return 0;
}

Measured memory_bytes: 256