akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <map>
#include <vector>

using namespace std;

constexpr int64_t kMod = 1e9+7;
constexpr int64_t kMax = 1000001;

int divs[1000001];

void Divs(int mx) {
  for (int i = 0; i <= mx; ++i) divs[i] = i;
  for (int i = 2; i <= sqrt(mx); ++i) {
    if (divs[i] < i) continue;
    for (int j = i+i; j <= mx; j+=i) {
      divs[j] = i;
    }
  }
}

int64_t ModInv(int64_t a, int64_t m) {
  int64_t b = m, u = 1, v = 0;
  while (b) {
    int64_t t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

  vector<int64_t> nums(N);
  int64_t mx = 0;
  for (int n = 0; n < N; ++n) {
    cin >> nums[n];
	mx = max(mx, nums[n]);
  }
  Divs(mx);
  map<int, int> lcm;
  for (int n = 0; n < N; ++n) {
    int64_t num = nums[n];
    while (num > 1) {
      int cnt = 0;
      int d = divs[num];
      while (num % d == 0) {
        ++cnt;
        num /= d;
      }
      lcm[d] = max(lcm[d], cnt);
    }
  }

  int64_t mod_lcm = 1;
  for (const auto& p : lcm) {
    for (int i = 0; i < p.second; ++i) {
      mod_lcm *= p.first;
      mod_lcm %= kMod;
    }
  }

  int64_t res = 0;
  for (const int64_t num : nums) {
    res += mod_lcm * ModInv(num, kMod);
    res %= kMod;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 7840
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

/*
ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}*/

int h, w, c[10][10], cntnmb[10], mem, ans, gp[10];

int main(){
	cin >> h >> w;
	lp(10) {
		LP(10, j) {
			cin >> c[j][i];
		}
	}
	lp(10)
		cntnmb[i] = 0;
	lp(h) {
		LP(w, j) {
			cin >> mem;
			if (mem != -1)
				cntnmb[mem]++;
		}
	}
	lp(10)
		gp[i] = 1000000;
	gp[1] = 0;
	lp(10) {
		LP(10, j) {
			LP(10, k) {
				gp[j] = min(gp[j], gp[k] + c[k][j]);
			}
		}
	}
	ans = 0;
	lp(10)
		ans += cntnmb[i] * gp[i];
	cout << ans << endl;
	return 0;
}

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

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

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);

  for(int i=0;i<N;i++) {
    cin >> A.at(i);
  }

  for(int i=0;i<N;i++) {
    cin >> B.at(i);
  }

  for(int i=0;i<N-1;i++) {
    cin >> C.at(i);
  }

  int ans=0;

  for(int i=0;i<N;i++) {
    ans += B.at(A.at(i)-1);
    if(1<=i && i<=N-1) {
      if(A.at(i)==A.at(i-1)+1) {
        ans += C.at(A.at(i-1)-1);
      }
    }
  }

  cout << ans << endl;

  return (0);
}


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

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = H.iota.map!(_ => readln.chomp.map!(a => (a - 'a').to!int).array).array;

    auto can_pair = new bool[][](H, H);

    foreach (i; 0..H) {
        foreach (j; 0..H) {
            auto cnt1 = new int[](26);
            auto cnt2 = new int[](26);
            foreach (k; 0..W) {
                cnt1[A[i][k]] += 1;
                cnt2[A[j][k]] += 1;
            }
            if (26.iota.map!(a => cnt1[a] == cnt2[a]).all) {
                can_pair[i][j] = true;
                can_pair[j][i] = true;
            }
        }
    }

    auto used = new bool[](H);
    int[] stack;
    int center = -1;

    bool dfs(int n) {
        if (n >= H) {
            auto B = new int[][](H, W);
            foreach (i; 0..H/2) {
                B[i] = A[stack[i*2]].dup;
                B[H-i-1] = A[stack[i*2+1]].dup;
            }
            if (center != -1) {
                B[H/2] = A[center].dup;
            }

            auto col_used = new bool[](W);
            bool center = false;
            
            foreach (j; 0..W) {
                if (col_used[j]) continue;
                foreach (k; j+1..W) {
                    if (H.iota.map!(i => B[i][j] == B[H-i-1][k]).all) {
                        col_used[j] = true;
                        col_used[k] = true;
                        break;
                    }
                }

                if (!col_used[j]) {
                    if (W % 2 == 0 || center) return false;
                    if ((H/2).iota.map!(i => B[i][j] == B[H-i-1][j]).all) {
                        center = true;
                        col_used[j] = true;
                    }
                }
            }

            return true;
        }
        if (used[n]) return dfs(n+1);

        used[n] = true;
        stack ~= n;

        foreach (i; 0..H) {
            if (used[i] || !can_pair[n][i]) continue;
            used[i] = true;
            stack ~= i;
            if (dfs(n+1)) return true;
            used[i] = false;
            stack.popBack;
        }

        stack.popBack;

        if (center == -1 && H % 2 == 1) {
            center = n;
            if (dfs(n+1)) return true;
            center = -1;
        }
        
        used[n] = false;

        return false;
    }

    writeln(dfs(0) ? "YES" : "NO");
}


Measured memory_bytes: 380
#include<stdio.h>
int main()
{
	int a1, a2, a3, a4;
	int b1, b2, b3, b4;
	while (scanf("%d%d%d%d", &a1, &a2, &a3, &a4)>0 && scanf("%d%d%d%d", &b1, &b2, &b3, &b4)>0) {
		int a[10] = {0};
		int hit=0, blow=0;
		a[a1]=a[a2]=a[a3]=a[a4]=1;
		if (a1==b1) hit++;
		if (a2==b2) hit++;
		if (a3==b3) hit++;
		if (a4==b4) hit++;
		blow = a[b1]+a[b2]+a[b3]+a[b4]-hit;
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    rep(i,n)cin>>d[i];
    sort(d.begin(),d.end());
    if(n%2==0){
        cout<<d[n/2]-d[n/2-1];
    }
    else{
        cout<<d[n/2+1]-d[n/2-1];
    }
return 0;
}

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

struct Prime{

  vector<int> prime; // 2,3,5,7,11...
  vector<bool> is_prime; // 素数=1,合成数=0
  void eratos(int n){
    is_prime.resize(n+1,true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
      if(is_prime[i]){
        prime.push_back(i);
        for(int j = i*2; j <= n; j+=i){
          is_prime[j] = false;
        }
      }
    }
  }

  //因数分解
  map<int,int> prime_factor(int n){
    map<int,int> mp; //{約数,個数}
    for(int i = 2; i*i <= n; i++){
      while(n%i == 0){
        mp[i]++;
        n /= i;
      }
    }
    if(n != 1) mp[n] = 1; //n=素数
    return mp;
  }

  //mpから作れる、約数をちょうどn個もつ数の個数
  int factor_cnt(map<int,int> mp,int n){
    vector<int> dp(n+2); //約数がちょうどi個の数の個数
    dp[1] = 1;
    for(auto p : mp) {
      for(int i = n; i > 0; i--) {
        for(int j = p.second; j > 0; j--) {
          dp[ min(n+1,i*(j+1)) ] += dp[i];
        }
      }
    }
    return dp[n];
  }

}prime;

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

  prime.eratos(100000);
  vector<int> v(100000);
  for(int i = 1; i < 100000; i++){
    if(prime.is_prime[i] && prime.is_prime[(i+1)/2]){
      v[i]++;
    }
    v[i] += v[i-1];
  }

  int Q; cin >> Q;
  for(int i = 0; i < Q; i++){
    int l,r; cin >> l >> r;
    //cout << v[l] << " " << v[r] << endl;
    cout << v[r] - v[l-1] << endl;
  }

  return 0;
}


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

int main(){
    int N,Q;cin>>N>>Q;
    vector<int> check(N+1);
    string S;cin>>S;

    check[0] = 0;
    for(int j = 1; j < N; j++){
        if(S[j-1] == 'A' && S[j] == 'C'){
            check[j] += 1;
            check[j+1] = check[j];
        }else{
            check[j+1] = check[j];
        }
    }
    /* 
    for(int i = 0; i <= N ; i++){
        cout << check[i] << endl;
    }
    */
    for(int i = 0 ; i < Q ; i++){
        int l,r;cin>>l>>r;
        l--;r--;
        int ans = check[r] - check[l];
        cout << ans << endl;
    }


       

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",&s);
  unsigned long long int f,r,g,b; r=0;g=0;b=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }
  f=r*g*b;
  for(int i=0;i<n;i++)
  {
    for(int j=i;j<n;j++)
    {
      int k=2*j-i;
      if(k<=j) continue;
      else{
        if(n>k
          &&
          k>0
          &&
          s[i]!=s[j]
          &&
          s[j]!=s[k]
          &&
          s[i]!=s[k]
          )f--;
      }
    }
  }
  printf("%u",f);
  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int x,y; cin >>x >>y;
  cout <<(x % y == 0 ? -1 : x) <<endl;
}


Measured memory_bytes: 256
import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

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

main = do
  [n, m] <- getIntList
  rs <- replicateM m getIntList

  ds <- VM.new n
  VM.set ds (-1::Int)

  forM_ rs $ \[s, c] -> do
    d <- VM.read ds (s-1)
    let c' = if (d >= 0 && d /= c) || (n > 1 && s == 1 && c == 0) then 10 else c
    VM.write ds (s-1) c'

  d1 <- VM.read ds 0
  when (n > 1 && d1 < 0) $ VM.write ds 0 1

  ds' <- V.freeze ds

  let xs = V.map (\i -> i <= 9) ds'

  if V.and xs
    then do forM_ [0..(n-1)] $ \i -> putStr . show $ max 0 (ds' V.! i)
            putStrLn ""
    else print (-1)

Measured memory_bytes: 508
n = int(input())
H = list(map(int, input().split()))

memo = [0 for _ in range(n)]
memo[1] = abs(H[1] - H[0])
for i in range(2, n):
  memo[i] = min(memo[i-1] + abs(H[i] - H[i-1]), memo[i-2] + abs(H[i] - H[i-2]))
print(memo[-1])

Measured memory_bytes: 20464
a,b,c,d=list(map(int,input().split())),[],0,0
for i in range(a[0]):
    b.append(list(map(int,input().split())))
b.sort()
for i in range(a[1]):
    c+=b[d][0]
    b[d][1]-=1
    if b[d][1]==0:
        d+=1
print(c)

Measured memory_bytes: 27760
#include <iostream>
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=0;i<ty-sy;i++)cout<<"U";
    for(int i=0;i<tx-sx;i++)cout<<"R";
    for(int i=0;i<ty-sy;i++)cout<<"D";
    for(int i=0;i<tx-sx+1;i++)cout<<"L";
    for(int i=0;i<ty-sy+1;i++)cout<<"U";
    for(int i=0;i<tx-sx+1;i++)cout<<"R";
    cout<<"DR";
    for(int i=0;i<ty-sy+1;i++)cout<<"D";
    for(int i=0;i<tx-sx+1;i++)cout<<"L";
    cout<<"U\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
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;}


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

    V h(n);
    rep(i, n) cin >> h[i];

    V dp(n+1, inf);
    dp[0] = 0;
    rep(i, n-1) {
        FOR(j, 1, k+1) {
            dp[i+j] = min(dp[i+j], abs(h[i]-h[i+j]) + dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#19 B - RGB Boxes
R,G,B,N = map(int,input().split())
lis = sorted([R,G,B])
MA, MID, MI = lis[0],lis[1],lis[2]

cnt = 0
for ma in range(N//MA+1):
    for mid in range(N//MID+1):
        mi = (N - (MA*ma+MID*mid))//MI
        mi_judge = (N - (MA*ma+MID*mid))%MI
        if mi>= 0 and (mi_judge == 0):
            cnt += 1
print(cnt)

Measured memory_bytes: 67796
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
X, Y = X[::-1], Y[::-1]

MOD = 10**9 + 7
x_sum, y_sum = 0, 0

for i in range(N):
  x_sum = x_sum + (N-i-1)*X[i]
X = X[::-1]
for i in range(N):
  x_sum = x_sum - (N-i-1)*X[i]
x_sum %= MOD

for i in range(M):
  y_sum = y_sum + (M-i-1)*Y[i]
Y = Y[::-1]
for i in range(M):
  y_sum = y_sum - (M-i-1)*Y[i]
y_sum %= MOD

print((x_sum*y_sum)%MOD)

Measured memory_bytes: 18556
$r = "Yes";
$cnt = 1;
for $i (split(//, <>)){
	if(($cnt % 2 == 0) and ($i eq "R")){
		$r = "No";
		last;
	}
	if(($cnt % 2 != 0) and ($i eq "L")){
		$r = "No";
		last;
	}
	$cnt++;
}

print "$r\n";


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

LL func(LL a)
{
  return a * a * a * a * a;
}

void solve(long long X)
{

  LL maxim = 0;
  for (LL i = 1;; i++)
  {
    if (func(i) - func(i - 1) > X)
      break;

    maxim = i;
  }

  bool ended = false;
  for (LL i = -maxim; i <= maxim; i++)
  {
    for (int j = -maxim; j < maxim; j++)
    {
      if (func(i) - func(j) == X)
      {
        std::cout << i << " " << j << endl;
        ended = true;
      }
      if (ended)
        break;
    }
    if (ended)
      break;
  }
}

int main()
{
  cout << setprecision(10);
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int a = abc[0];
                int b = abc[1];
                int c = abc[2];
                if (a == -1 && b == -1 && c == -1)
                    break;
                {
                    if (a == -1 || b == -1 || a + b < 30)
                    {
                        Console.WriteLine("F");
                    }
                    {
                        if (a + b > 79  && a >-1 && b>-1)
                        {
                            Console.WriteLine("A");
                        }
                        {
                            if (a + b > 64 && a + b < 80 && a >-1 && b > -1)
                            {
                                Console.WriteLine("B");
                            }
                            {
                                if (49 < a + b && a + b < 65 && a>-1 && b > -1)
                                {
                                    Console.WriteLine("C");
                                }
                                {
                                    if (29 < a + b && a + b < 50 && c > 49 && a>-1 && b>-1)
                                    {
                                        Console.WriteLine("C");
                                    }
                                    {
                                        if (29 < a + b && a + b < 50 && 50 >c && a>-1 && b>-1)
                                        {
                                            Console.WriteLine("D");

                                        }

                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9380
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
using ll = long long;


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int a = 0, b = 0;
	for(int i=0;i<n;i++) if(s[i] == 'R') ++a;
	int ans = max(a,b);
	for(int i=0;i<n;i++){
		if(s[i] == 'R') --a;
		else ++b;
		int now = max(a,b);
		ans = min(ans,now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0);
    cout.tie(0);
    map <string, int> mp ;
    string str ;
    int n ;
    cin >> n ;
    while(n--)
    {
        cin >> str ;
        mp[str]++ ;
    }
    int mx = 0 ;
    for(auto i:mp)
    {
        if(i.second > mx) mx = i.second;
    }
    for(auto i:mp)
    {
        if(i.second == mx) cout << i.first << endl ;
    }

}


Measured memory_bytes: 19264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/lazysegtree>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint998244353;

struct S{
    mint a,b;
};

struct F{
    mint a,b;
};

S op(S x,S y){
    x.a += y.a;
    x.b += y.b;
    return x;
}

S e(){ return S{0,0};}

S mapping(F l,S r){
    return S{r.a*l.a+r.b*l.b,r.b};
}

F composition(F l,F r){
    l.b = l.a*r.b + l.b;
    l.a *= r.a;
    return l;
}

F id(){ return F{1,0};}

int main(){
    int n,q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i,n){
        int x;
        cin >> x;
        a[i].a = x;
        a[i].b = 1;
    }

    lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);

    while(q--){
        int t;
        cin >> t;
        if(t==0){
            int l,r,c,d;
            cin >> l >> r >> c >> d;
            seg.apply(l,r,F{c,d});
        }else{
            int l,r;
            cin >> l >> r;
            cout << seg.prod(l,r).a.val() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19376
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<algorithm>
#include<climits>
using namespace std;

int minJumpsCost(vector<int>& input, int K)
{
	vector<int> dp(input.size(), INT_MAX);
	dp[0] = 0;
	dp[1] = abs(input[0] - input[1]);
	for (int i = 2; i < int(dp.size()); ++i)
	{  
		int k = K-1;
		for (int j = i - 1; j >= 0 && k >= 0; --j, --k)
		{
			dp[i] = min(dp[i], abs(input[i] - input[j]) + dp[j]);
		}
	}
	return dp[input.size() - 1];
}

int main()
{
	int N, K;
	cin >> N;
	cin >> K;
	vector<int> input;
	while (int(input.size()) < N)
	{
		int num;
		cin >> num;
		input.push_back(num);

	}
	if (N == 1 || K ==0)
	{
		cout << 0;
	}
	else {
		cout << minJumpsCost(input, K);
	}
	return 0;
}



Measured memory_bytes: 3960
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int a; CI a;
	if (a == 1) {
		CO "Hello World" EN; return 0;
	}
	else {
		int b, c; CI b >> c;
		CO b + c EN;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main(){
	
	double a,b;
	
	while(cin>>a>>b){
		if(a<35.5&&b<71)
			cout<<"AAA"<<endl;
		else if(a<37.5&&b<77)
			cout<<"AA"<<endl;
		else if(a<40&&b<83)
			cout<<"A"<<endl;
		else if(a<43&&b<89)
			cout<<"B"<<endl;
		else if(a<50&&b<105)
			cout<<"C"<<endl;
		else if(a<55&&b<116)
			cout<<"D"<<endl;
		else if(a<70&&b<148)
			cout<<"E"<<endl;
		else
			cout<<"NA"<<endl;
	}
	
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
#define rep(i, j) for (long long i = j; i > 0; i--)
using namespace std;


int main() {
	long long ans = 2018;
	long long l, r;
	cin >> l >> r;
	int flag = 0;
	if (r - l > 2018) {
		cout << 0 << endl;
		return 0;
	}
	for (long long i = l; i < r; i++) {
		for (long long j = i + 1; j <= r; j++) {
			ans = min(ans, (i * j) % 2019);
			
		}
	}

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

Measured memory_bytes: 256
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
mod = 1000000007
dp = [0] * (n+1)
dp[0] = 1#0段目へ行く移動方法は1通りしかない
if 1 not in a:#もし階段がぶっ壊れてるリストに1段目が入っていないならば1段目へ行く移動方法は1通り、そうでないなら0通り
    dp[1] = 1
else:
    dp[1] = 0
for i in range(2,n+1):#2段目から調べていく
    if i in a:#現在のi段目がぶっ壊れリストに含まれてるなら何もせず飛ばす
        continue
    dp[i] = dp[i-1] + dp[i-2]#フィボナッチで処理
    dp[i] %= mod#modで割っていく
print(dp[n])#n+1番目を出力する

Measured memory_bytes: 13216
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    using vs_type = std::vector<std::string>;
    int h, w;
    std::cin >> h >> w;
    h += 2;
    w += 2;
    vs_type vs{vs_type(h, std::string(w, '#'))};
    for (auto i = 1; i < h - 1; ++i)
    {
        std::string s;
        std::cin >> s;
        std::copy(s.begin(), s.end(), vs[i].begin() + 1);
    }
    for (auto v : vs)
    {
        std::cout << v << "\n";
    }
    return 0;
}


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

typedef long long ll;

int main() {
	ll n;
	cin >> n;
	vector<ll> A(n);
	for (ll i = 0; i < n; i++)cin >> A[i];
	for (ll i = 0; i < n-1; i++) {
		cout << A[i] << ' ';
	}
	cout << A[n - 1] << endl;
	for (ll i = 1; i < n; i++) {
		ll v = A[i];
		ll j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		for (ll p = 0; p < n-1; p++) {
			cout << A[p] << ' ';
		}
		cout << A[n - 1] << endl;
	}
}


Measured memory_bytes: 3100
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		char a = inchar(), b = inchar();
		out.println(a==b ? "=" : a<b ? "<" : ">");

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}
	
	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21844
// 2011/07/16 Tazoe

#include <iostream>
#include <queue>
#include <map>
using namespace std;

struct state{
	int tx;
	int ty;
	int kx;
	int ky;
	int tim;
};

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		int d[52][52];
		for(int y=0; y<=Y+1; y++)
			for(int x=0; x<=X+1; x++)
				d[y][x] = 1;

		struct state now;
		cin >> now.tx >> now.ty;
		cin >> now.kx >> now.ky;
		now.tim = 0;

		queue<struct state> que;
		que.push(now);

		map<int, bool> memo;


		for(int y=1; y<=Y; y++)
			for(int x=1; x<=X; x++)
				cin >> d[y][x];

		while(true){
			if(que.empty()){
				cout << "NA" << endl;
				break;
			}

			now = que.front();
			que.pop();

			if(memo.find(((now.tx*100+now.ty)*100+now.kx)*100+now.ky)!=memo.end())
				continue;
			else
				memo[((now.tx*100+now.ty)*100+now.kx)*100+now.ky] = true;

			if(now.tim>=100){
				cout << "NA" << endl;
				break;
			}

			if(now.tx==now.kx&&now.ty==now.ky){
				cout << now.tim << endl;
				break;
			}

			struct state nxt = now;
			if(d[nxt.ty-1][nxt.tx]==0)
				nxt.ty--;
			if(d[nxt.ky+1][nxt.kx]==0)
				nxt.ky++;
			nxt.tim++;
			que.push(nxt);

			nxt = now;
			if(d[nxt.ty+1][nxt.tx]==0)
				nxt.ty++;
			if(d[nxt.ky-1][nxt.kx]==0)
				nxt.ky--;
			nxt.tim++;
			que.push(nxt);

			nxt = now;
			if(d[nxt.ty][nxt.tx-1]==0)
				nxt.tx--;
			if(d[nxt.ky][nxt.kx+1]==0)
				nxt.kx++;
			nxt.tim++;
			que.push(nxt);

			nxt = now;
			if(d[nxt.ty][nxt.tx+1]==0)
				nxt.tx++;
			if(d[nxt.ky][nxt.kx-1]==0)
				nxt.kx--;
			nxt.tim++;
			que.push(nxt);
		}
	}

	return 0;
}

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int n;
	cin >> n;
	int a[n];
	FOR(i,n) cin >>a[i];
	
	for(int i=n-1;i>=0;i-=2) cout << a[i] <<" ";
	if(n%2==1)
	for(int i=1; i < n;i+=2) cout << a[i] <<" ";
	if(n%2==0)
	for(int i=0;i<n;i+=2) cout << a[i] <<" ";


	return 0;
}

Measured memory_bytes: 2944
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
long long K,N;
int main()
{
    long long sum=0;
    //freopen("in.txt","r",stdin);
    scanf("%lld%lld",&N,&K);
    if(K==0)
    {
        cout<<N*N<<endl;
        return 0;
    }
    for(int i=K+1;i<=N;++i)
    {
        for(int j=i;j<=N;j+=i)
        {
            sum+=i-K;
        }
        if(N%i>=K)
        {
            sum+=N%i-K+1;
        }
    }
    printf("%lld\n",sum);
}


Measured memory_bytes: 256
G = [set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2])]
def check(x, y):
  for g in G:
    if x in g and y in g:
      return True
  return False
x, y = map(int, input().split())
print("Yes" if check(x, y) else "No")


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

int main(){
    int H, W;
    cin >> H >> W;

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

    for (int k = 0; k <= W+1; k++)
    {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < H; i++){
        cout << "#" << a[i]<< "#" << endl;
    }
    for (int k = 0; k <= W+1; k++)
    {
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int A[]=new int[N];
		int One=0;
		for(int i=0;i<N;i++){
			A[i] = sc.nextInt();
			if(A[i]==1){
				One=i;
			}
		}
		System.out.println((N+K-3)/(K-1));



	}

}


Measured memory_bytes: 49968
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n;
        double sum=0,sum2=0;;
        double ave=0;
        double[] data = new double[1001];
        double[] data2 = new double[1001];
        
        
        while(true) {
            n = sc.nextInt();
            if(n==0)break;
            for(int i = 0;i<n;i++) {
            	data[i]=sc.nextInt();
            	sum +=data[i];
            }
            ave = sum/n;
        	
            for(int i = 0;i<n;i++) {
            	data2[i]=Math.pow(data[i]-ave, 2);
            	sum2 +=data2[i];
            	}
            double ans = sum2/n;
            System.out.printf("%f\n", Math.sqrt(ans));
            
            
            
            sum =0 ;
            sum2=0;
        }
        
        
        
        
        sc.close();
	}


}



Measured memory_bytes: 31912
S = input()


if S[0] != "A":
    print("WA")

elif "C" in S:
    a = S.index("C")

    if 2 <= a <= len(S)-2:
        S = S.replace("A", "", 1).replace("C", "", 1)
        
        if S.islower():
            print("AC")
        
        else:
            print("WA")

    else:
        print("WA")

else:
    print("WA")


Measured memory_bytes: 3060
N, K = map(int, input().split())
if K == 0:
    print(N * N)
    exit()
cnt = 0
for b in range(K + 1, N + 1):
    p = N // b
    r = N % b
    cnt += p * (b - K)
    if r >= K:
        cnt += r - K + 1
print(cnt)

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

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

    vector<int> a(100);
    int dif = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        vector<int>::iterator maxIt = max_element(a.begin(), a.end());
        if (i % 2)
        {
            dif += *maxIt;
            a.erase(maxIt);
        }
        else
        {
            dif -= *maxIt;
            a.erase(maxIt);
        }
    }
    cout << dif << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAP_NUM 21
#define NEUTRAL 10
#define COMMAND_NUM 30

void trace(int A[], int n){
	int i;
	for ( i = 1; i <= n; i++ ){
		if ( i > 1 ) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

int main(){
    int jewel_num, command_num;
    int map[MAP_NUM][MAP_NUM], command[COMMAND_NUM];
    char direction[COMMAND_NUM], d_char;
    int k, m, i, j, flg;
    int x, y;

    while(1){
        /* ?????°???????????? */
        for(i = 0; i < MAP_NUM; i++){
            for(j = 0; j < MAP_NUM; j++){
                map[i][j] = 0;
            }
        }
        for(i = 0; i < COMMAND_NUM; i++){
            direction[i] = ' ';
            command[i] = 0;
        }
        x = NEUTRAL;
        y = NEUTRAL;

        /* ???????????°?????? */
        scanf("%d", &jewel_num);
        if(jewel_num == 0){
            /* 0????????????????????? */
            break;
        }

        /* ????????????????????? */
        for(i = 0; i < jewel_num; i++){
            scanf("%d", &k);
            scanf("%d", &m);
            map[k][m] = 1;
        }

        /* ?????????????§??????????????????°?????? */
        scanf("%d", &command_num);
        
        /* ?????????????§?????????????????????? */
        for(i = 0; i < command_num; i++){
            scanf("%c", &d_char);
            scanf("%c", &d_char);
            scanf("%d", &m);
            direction[i] = d_char;
            command[i] = m;
        }

        /* ???????????¢??? */
        for(i = 0; i < command_num; i++){
            for(j = 1; j <= command[i]; j++){
                /* ????§?????¢?????????? */
                if(direction[i] == 'N'){
                    y++;
                }
                if(direction[i] == 'E'){
                    x++;
                }
                if(direction[i] == 'W'){
                    x--;
                }
                if(direction[i] == 'S'){
                    y--;
                }

                /* ??????????????? */
                map[x][y] = 0;
            }
        }

        /* ??????????????°????????????????????????????????? */
        map[NEUTRAL][NEUTRAL] = 0;

        /* ???????????°????????§???????????? */
        flg = 0;
        for(i = 0; i < MAP_NUM; i++){
            for(j = 0; j < MAP_NUM; j++){
                if(map[i][j] != 0){
                    flg = 1;
                }
            }
        }
        if(flg != 0){
            /* ?????????????????§????????£???????????°No??????????????? */
            printf("No\n");
        }
        else{
            /* ???????????????????????£?????????????????°Yes??????????????? */
            printf("Yes\n");
        }
    }

	return 0;
}

Measured memory_bytes: 1748
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <map>
#include <math.h>

using namespace std;

typedef signed long long ll;

int main(void)
{
    long long count = 0;
    int N = 0;
    cin >> N;

    vector<long> A(N, 0);
    vector<long> B(N, 0);
    vector<long> C(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    sort(B.begin(), B.end());
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    long long ab = 0;
    long long bc = 0;
    for (int j = 0; j < N; j++, ab = 0, bc = 0)
    {
        auto it_A = lower_bound(A.begin(), A.end(), B[j]);
        ab = distance(A.begin(), it_A);
        auto it_C = upper_bound(C.begin(), C.end(), B[j]);
        bc = N - distance(C.begin(), it_C);

        count = count + (ab * bc);
    }

    cout << count << endl;

    return 0;
}


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

vector<int> divisor(int n) {
  vector<int> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  int n, m, d = 1;
  cin >> n >> m;
  vector<int> y = divisor(m);
  for(int i = 0; i < y.size(); i++) {
    if(y.at(i) >= n) {
      d = m / y.at(i);
      break;
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
using namespace std;

const int maxn = 200000 + 10;
set<int> island[maxn];
bool read[maxn];
int n, m;
bool possible = false;

void dfs(const int num,const int t) {
	if (num == n&&t <= 2) { possible = true; return; }
	if (t >= 2) return;
	if (island[num].empty()) return;
	if (read[num]) return;
	read[num] = true;
	for (set<int>::const_iterator it = island[num].begin(); it != island[num].end(); it++) {
		dfs(*it, t + 1);
	}
}

int main(void) {
	cin >> n >> m;
	int ai, bi;
	for (int i = 1; i <= m; i++) {
		cin >> ai >> bi;
		island[ai].insert(bi);
	}
	memset(read, false, sizeof(read));
	dfs(1, 0);
	cout << (possible ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 19200
#include<iostream>
 
using namespace std;
 
int main(){
 
    int A[5][4][11], n;
 
    for ( int i = 1; i <= 4; i++ )
 
        for ( int j = 1; j <= 3; j++ )
 
            for ( int k = 1; k <= 10; k++ ) A[i][j][k] = 0;
 
 
    cin >> n;
 
    for ( int i = 0; i < n; i++ ){
 
        int b, f, r, v;
 
        cin >> b >> f >> r >> v;
 
        A[b][f][r] += v;
 
    }
 
    for ( int f = 1; f <= 4; f++ ){
 
        if ( f > 1 ) cout << "####################\n";
 
        for ( int b = 1; b <= 3; b++ ){
 
            for ( int r = 1; r <= 10; r++ ){
 
                cout << " " << A[f][b][r];
 
            }
 
        cout << endl;
 
        }
 
    }
 
    return 0;
 
}

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


int main(){
    string s;
    cin >> s;
    int n = s.size();
    cout << s[0] + to_string(n-2) + s[n-1] << endl;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var w, h, x, y float64

	fmt.Scanf("%g %g %g %g", &w, &h, &x, &y)

	area := w * h / 2

	var ans float64
	ans = 0
	if x == w/2 && y == h/2 {
		ans = 1
	}
	fmt.Printf("%g %g", area, ans)
}


Measured memory_bytes: 512
def min_coin(i):
    if coin_dp[i]!=50001:
        return(coin_dp[i])
n,m=map(int,input().split())
coin_dp=[float("inf")]*(n+1)
coin_dp[0]=0
coin=list(map(int,input().split()))
for i in range(n):
    for j in coin:
        if i+j>n:
            continue
        else:
            coin_dp[i+j]=min(coin_dp[i+j],coin_dp[i]+1)
print(coin_dp[-1])


Measured memory_bytes: 7264
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

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

    int ans = 0;
    while (n >= k) {
        ans += 1;
        n /= k;
    }

    print(1 + ans);

    return 0;
}


Measured memory_bytes: 256
S=input()
if S=="abc" :
  print("Yes")
elif S=="bca" :
  print("Yes")
elif S=="cba" :
  print("Yes")
elif S=="acb" :
  print("Yes")
elif S=="bac" :
  print("Yes")
elif S=="cab" :
  print("Yes")
else :
  print("No")

Measured memory_bytes: 2940
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
		System.out.println((C-(A-B)) > 0 ? C-(A-B) : 0);

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n, k; cin >> n >> k;
    int ans = k;
    for(int i = 1; i < n; i++) ans *= (k - 1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main() {
  vector<int> v(6,0);
  for (int i = 0; i < 6; i++) {
    cin >> v.at(i);
  }

  int yay = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i+1; j < 5; j++) {
      if (abs(v.at(i) - v.at(j)) > v.at(5)) {
        yay = yay + 1;
      }
    }
  }

  if (yay != 0) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}


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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var a1 = Read();
            if (a1.Contains("a") && a1.Contains("b") && a1.Contains("c"))
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import sys
def main():
    for line in sys.stdin:
        A = list(map(int,line.split()))
        C = A[0]+A[1]
        count = 0
        while True:
            C/=10
            if C < 1:
                break
            count += 1
        print(count+1)

if __name__ == '__main__':
    main()

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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 998244353


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

bool check(int x,int y)
{
	return x>=0 && y>=0 && x<=2000 && y<=2000;
}
int fun()
{
	static int num = 16;
	return num--;
}
ll exp(ll a,ll p,ll m)
{
	if(p==0)
		return 1LL;
	if(p==1)
		return a;
	ll h=exp(a,p/2,m);
	h=(h*h)%m;
	if(p&1)
		h=(h*a)%m;
	return h;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,m,k;
	cin>>n>>m>>k;

	vector<ll>fact(200001,0);
	fact[0]=1;
	for(ll i=1;i<=200000;i++)
		fact[i]=(i*fact[i-1])%M;
	ll ans=0;
	for(ll i=0;i<=k;i++)
	{
		ll n_1ci=(fact[n-1]*((exp(fact[i],M-2,M)*exp(fact[n-i-1],M-2,M))%M))%M;

		ll p=(m*(exp(m-1,n-1-i,M)))%M;
		// cout<<n_1ci<<" "<<p<<endl;
		ans=(ans+(n_1ci*p)%M+M)%M;
	}
	cout<<ans<<endl;

}



Measured memory_bytes: 4784
from collections import Counter

s = input()
snotx = "".join([ch for ch in s if ch != 'x'])

if s == s[::-1]:
    print(0)
    exit()

if snotx != snotx[::-1]:
    print(-1)
    exit()

# 両端から見てくる (解説解法)
index_l = 0
index_r = len(s) - 1
count = 0
while index_l < index_r:
    if s[index_l] == s[index_r]:
        index_l += 1
        index_r -= 1
    elif s[index_l] == 'x':
        count += 1
        index_l += 1
    elif s[index_r] == 'x':
        count += 1
        index_r -= 1
    else:
        print(-1)
        exit()
print(count)

Measured memory_bytes: 47088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    string s; cin >> s;
    int ans = 0;
    rep(i,s.size()) {
        if(s[i] == '+') ans++;
        else ans --;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596