akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long int findMaxProfit(vector < int > &weights, vector < int > &values, int W, int n, vector < vector < long long int > > &dp) {
  if (n == 0 || W == 0) {
    return 0;
  }

  if (dp[n][W] != -1) {
    return dp[n][W];
  }

  long long int inclusive = 0;
  long long int exclusive = 0;
  if (weights[n - 1] <= W) {
    inclusive = values[n - 1] + findMaxProfit(weights, values, W - weights[n - 1], n - 1, dp);
  }

  exclusive = findMaxProfit(weights, values, W, n - 1, dp);

  return dp[n][W] = max(inclusive, exclusive);

}

long long int maxProfit(vector < int > &weights, vector < int > &values, int W) {
  int n = weights.size();
  vector < vector < long long int > > dp(n + 1, vector < long long int >(W + 1, -1));
  return findMaxProfit(weights, values, W, n, dp);
}

int main() {
  // int test;
  // cin>>test;
  // while (test--) {
    int n;
    cin>>n;
    int W;
    cin>>W;
    vector < int > weights(n, 0);
    vector < int > values(n, 0);
    for (int i = 0; i < n; i++) {
      cin>>weights[i];
      cin>>values[i];
    }

    cout<<maxProfit(weights, values, W)<<endl;

  // }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
// エラトステネスの篩 [1,n]
bool is_prime[INF];
void sieve(ll n){
  for(ll i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;

  for(ll i=2;i<=n;i++){
    if(is_prime[i]){
      for(ll j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
}
int main(){
  cin.sync_with_stdio(false);
  sieve(1000000);
  Vector prs(100000+1,0);
  repl(i,1,100000)if(i % 2 == 1 && is_prime[i] && is_prime[(i+1) / 2])prs[i]++;
  repl(i,2,100000)prs[i] += prs[i-1];
  ll q;
  cin >> q;
  Vector ans(q);
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    cout << prs[r] - prs[l-1] << endl;
  }
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>

int main()
{
	char s1[10000], s2[10000];
	scanf("%s%s", s1, s2);
	int i = strlen(s1);
	int j;
	for(j = 0; j<i; j++)
    {
        s1[i+j] = s1[j];
    }
	strstr(s1, s2) != NULL ? printf("Yes\n") : printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 200005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
int32_t main()
{ 
  IOS

  int x,y;
  cin>>x>>y;
  int a = (4*x - y)/2;
  int b = (y- 2*x)/2;
  if(a>=0 and b>=0 and a+b == x and 2*a + 4*b == y){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  




}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var N = _[0]; var M = _[1];
        var H = LnInts();
        var towers = new Tower[N];
        for(int i = 0; i < N; i++)
        {
            towers[i] = new Tower();
            towers[i].h = H[i];
        }
        for(int i = 0; i < M; i++)
        {
            var con = LnInts();
            towers[con[0] - 1].connect.Add(con[1] - 1);
            towers[con[1] - 1].connect.Add(con[0] - 1);
        }
        int goods = 0;
        for(int i = 0; i < N; i++)
        {
            bool good = true;
            foreach(var n in towers[i].connect)
            {
                if (towers[i].h <= towers[n].h) { good = false; }
            }
           if(good) goods++;
        }
        print(goods);
    }

    public class Tower
    {
        public long h;
        public HashSet<int> connect=new HashSet<int>();
    }

    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable{var a = new List<T>(array).ToArray();var res = new List<T[]>();res.Add(new List<T>(a).ToArray());var n = a.Length;var next = true;while (next){next = false;int i;for (i = n - 2; i >= 0; i--){if (a[i].CompareTo(a[i + 1]) < 0) break;}if (i < 0) break;var j = n;do{j--;} while (a[i].CompareTo(a[j]) > 0);if (a[i].CompareTo(a[j]) < 0){var tmp = a[i];a[i] = a[j];a[j] = tmp;Array.Reverse(a, i + 1, n - i - 1);res.Add(new List<T>(a).ToArray());next = true;}}return res;}}




Measured memory_bytes: 75784
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d){
    cout << "Left";
  }else if(a+b<c+d){
    cout << "Right";
  }else if(a+b==c+d){
    cout << "Balanced";
  }
  return 0;
}
      

Measured memory_bytes: 888
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
                panic(e)
        }
        return i
}

func main() {
        sc.Split(bufio.ScanWords)
        a := nextInt()
        b := nextInt()
        c := nextInt()

        if a < b && b < c {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}


Measured memory_bytes: 1092
#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>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int t = x - z;
  int d = y + z;
  int ans = t / d;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;
class Main {
	int n,i;
	int[] a = new int[100];
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for(i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}
		for(i = (n - 1);i > 0;i--){
			System.out.print(a[i]);
			System.out.print(" ");
		}
		System.out.println(a[0]);
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

Measured memory_bytes: 19660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int N;
	double odd;
	cin >> N;
	if (N % 2 == 0) odd = N / 2;
	else odd = N / 2 + 1;
	double p = odd / N;
	cout << fixed << setprecision(6) << p << endl;
	return 0;
}

Measured memory_bytes: 3776
n = int(input())
arr = [int(x) for x in input().split(' ')]

pos = True

for i in range(n-2, -1, -1):
    if(arr[i] > arr[i+1]):
        if(arr[i] - arr[i+1] > 1):
            pos = False
            break
        else:
            arr[i] = arr[i+1]

if pos:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        char[] n = N.toCharArray();
        boolean[] ans = new boolean[4];
        for (int i = 0; i < N.length(); i++) {
            if (n[i] == 'N') {
                ans[0] = true;
            } else if (n[i] == 'W') {
                ans[1] = true;
            } else if (n[i] == 'S') {
                ans[2] = true;
            } else if (n[i] == 'E') {
                ans[3] = true;
            }
        }
        if((ans[0]==ans[2])&&(ans[1]==ans[3])){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25172
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [s] <- readString
  putStrLn $ solve s

f s | s == reverse s = True
    | otherwise      = False

solve s
  | f s && f (take ((length s - 1) `div` 2) s) && f
    (take ((length s - 1) `div` 2) $ reverse s)
  = "Yes"
  | otherwise
  = "No"


Measured memory_bytes: 380
#include <algorithm>
#include <array>
#include <functional>
#include <iostream>
#include <math.h>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n, 0);
    REP1(i, n + 1) {
        FOR(j, i + 1, n + 1) {
            ans[min(abs(i - j), min(abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))) - 1]++;
            // cout << min(abs(i - j), min(abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))) << " ";
        }
    }
    REP(i, n - 1) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())

ans = 0
dame = []

for i in range(m):
    if h[a[i] - 1] < h[b[i] - 1] and (not a[i] in dame):
        dame.append(a[i])
    elif h[a[i] - 1] > h[b[i] - 1] and (not b[i] in dame):
        dame.append(b[i])
    elif h[a[i] - 1] == h[b[i] - 1] and (not a[i] in dame):
        dame.append(a[i])
    if h[a[i] - 1] == h[b[i] - 1] and (not b[i] in dame):
        dame.append(b[i])


print(n - len(dame))


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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO;
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<nl;
	return 0;
}


Measured memory_bytes: 3752
#include<stdio.h>
#include<vector>
#define pb push_back
using namespace std;
typedef long long LL;
LL MX = 1e9+7;
int a[30];

int main()
{
    int n,i,j,s,e,m,mem;
    char ch;
    LL res=1;
    scanf("%d", &n);
    for(i=1;i<=n;i++){
        scanf(" %c", &ch);
        a[ch-'a']++;
    }
    for(i=0;i<26;i++){
        res*=(a[i]+1);
        res%=MX;
    }
    res = (res+MX-1)%MX;
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t N, K;
    cin >> N >> K;
    int64_t ans = 0;
    for (int64_t i = K; i <= N+1; i++){
        int64_t start = (i - 1) * i / 2;
        int64_t goal = (N * (N + 1) / 2) - ((N - i) * (N - i + 1) / 2);
        //cout << start << " " << goal << endl;
        ans += (goal - start + 1);
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,X,ans=0;
    bool chokuzen=true;
    cin >> A >> B >> C >> X;
    for (int i=0;i<A+1;i++){
        for (int j=0;j<B+1;j++){
            for (int k=0;k<C+1;k++){
                if (500*i + 100*j + 50*k == X) {
                    ans++;
                    }
            }
        }
    }
    printf ("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; ++i) cin >> a[i];
  ll ans = 0;
  ll b = 0,crt = 0;
  while(b < n-1){
    if(a[b] >= a[b+1]){
      ++crt;
      ans = max(ans,crt);
    }
    else crt = 0;
    ++b;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long H; cin >> H; 
	long long ans = 1; 
	while(114514){
		if(ans >= H){
			cout << ans << endl; return 0; 
		}
		else{
			ans *= 2; ans ++; 
		}
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int a,b; cin >> a >> b;
    VB A(3, true);
    A[a-1] = A[b-1] = false;
    REP(i, 3) if(A[i]) cout << 1 + i << "\n";
    return 0;
}


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

int main(){
    int n; cin >> n;
    char c; vector<int> w, r;
    rep(i,n) {
        cin >> c;
        (c == 'W')? w.push_back(i) : r.push_back(i);
    }
    int ans = 0;
    if(!r.empty() && !w.empty()) { 
        while(r.back() > w.front()) {
            int k = r.back(); r.pop_back();
            int l = w.front(); w.erase(w.begin());
            w.push_back(k);
            r.insert(r.begin(),l);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  sort(vec.begin(),vec.end());
  cout << vec[n/2] - vec[n/2-1] << endl;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}



template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;

    rep(i, b){
        if(a*(i+1)%b == c){
            YES();
            return 0;
        }
    }
    NO();
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long long buy, n, i, sum = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i){
    scanf("%lld", &buy);
    sum += buy;
  }

  printf("%lld\n", sum /n);
  return 0;
}

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

using namespace std;

int main() {

    string s, t;

    cin >> s >> t;

    int ans = t.size();

    for (int i = 0; i < s.size() - t.size() + 1; i++) {

        int count = 0;

        for (int j = 0; j < t.size(); j++) {

            if (s.at(i + j) != t.at(j)) {

                count++;

            }

        }

        ans = min(count, ans);

    }

    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#include<queue>
#include<map>
#include<cassert>
#pragma warning(disable:4996)
using namespace std;

#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4]={0, -1, 0, 1};
static const int dy[4]={1, 0, -1, 0};
static const char dir[4]={'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {int f[N2], space, MD;};
Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
	int sum=0;
	for(int i=0; i<N2; i++){
		if( pz.f[i]==N2 ) continue;
		sum += MDT[i][pz.f[i]-1];
	}
	return sum;
}

bool isSolved(){
	for(int i=0; i<N2; i++) if( state.f[i]!= i+1 ) return false;
	return true;
}

bool dfs(int depth, int prev){
	if( state.MD==0 ) return true;
	// ?????¨?????±???????????\??????????????£??????????¶?????????¶???????¶??????????????????????
	if( depth + state.MD > limit ) return false;

	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;

	for(int r=0; r<4; r++){
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if( tx<0 || ty<0 || tx>=N || ty>=N ) continue;
		if( max(prev,r)-min(prev,r)==2 ) continue;
		tmp = state;

		// ???????????????????????¢?????????????¨????????????????????????????????????????
		state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
		state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
		swap(state.f[tx*N+ty],state.f[sx*N+sy]);
		state.space = tx*N+ty;
		if( dfs(depth+1,r) ) {
			path[depth] = r; 
			return true;
		}
		state = tmp;
	}
	return false;
}

// ????????±???
string iteratuve_deepening(Puzzle in){
	in.MD = getAllMD(in); // ????????¶?????????????????????????????¢

	for(limit=in.MD; limit<=LIMIT; limit++){
		state = in;
		if( dfs(0,-100) ){
			string ans = "";
			for(int i=0; i<limit; i++) ans += dir[path[i]];
			return ans;
		}
	}
	return "unsolvable";
}

int main(){
	for(int i=0; i<N2; i++)
		for(int j=0; j<N2; j++)
			MDT[i][j] = abs(i/N-j/N) + abs(i%N-j%N);
	Puzzle in;

	for(int i=0; i<N2; i++){
		cin >> in.f[i];
		if( in.f[i]==0 ){
			in.f[i] = N2;
			in.space = i;
		}
	}
	string ans = iteratuve_deepening(in);
	cout << ans.size() << "\n";
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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


vector<ll> factorization(ll n)
{
    ll _n = n;
    ll s = (ll)sqrt(n);
    ll r;
    vector<ll> p;

    for(ll i=2; i<=s; ++i){
        if(_n % i == 0){
            do{
                _n /= i;
            }while(_n % i == 0);
            p.pb(i);
        }
    }
    if(_n > s) p.pb(_n);

    return p;
}

int main()
{
    ll A, B;
    cin >> A >> B;
    
    ll G = gcd(A,B);
    auto p = factorization(G);
    _PS(p.size()+1);

    return 0;
}

/*



*/

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

int main(){
    long long n, m;
    cin >> n >> m;
    if(n < m) swap(n, m);
    long long ans = n * (m - 2) - (m - 2) * 2;
    cout << abs(ans) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt(), K = sc.nextInt();
			char[] S = sc.next().toCharArray();
			int score = 0;
			for (int i = 0; i < N - 1; i++) score += S[i] == S[i + 1] ? 1 : 0;
			System.out.println(Math.min(N - 1, score + 2 * K));
		}
	}
}

Measured memory_bytes: 26056
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!

    println(if (s.isPostalCode(a, b)) "Yes" else "No")
}

fun String.isPostalCode(pre: Int, post: Int): Boolean =
        this[pre] == '-' &&
                this.subSequence(0, pre).all { it in '0'..'9' } &&
                this.subSequence(pre + 1, this.length).all { it in '0'..'9' }


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

int main(){
  int N,K;
  long long ans=1;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if(i==0){
      ans*=K;
    }
    else{
      ans*=K-1;
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var sum float64
	for i := 0; i < n; i++ {
		var currency string
		var amount float64
		fmt.Scan(&amount, &currency)
		if currency == "BTC" {
			sum += 380000.0 * amount
		} else {
			sum += amount
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1768
function main(input) {
    var split = input.split(" ");
    var sheep = parseInt(split[0]);
    var elf = parseInt(split[1]);
    if (sheep > elf) {
     console.log("safe");
    } else if (sheep <= elf){
     console.log("unsafe");
    }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29616
#include <iostream>
#include <string>

using namespace std;

int main()
{
    long A;
    string B;

    cin >> A >> B;

    B.erase(B.begin() + 1);

    long B_num = 0;
    int i;
    int digit = 100;
    for (i = 0; i < B.length(); i++) {
        B_num += (char(B[i]) - 48) * digit;
        digit /= 10;
    }

    cout << A * B_num / 100;


    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    while(N>=10){
        N=N%10;
    }
    if(N==2||N==4||N==5||N==7||N==9){
        cout<<"hon"<<endl;
    }
    else if(N==0||N==1||N==6||N==8){
        cout<<"pon"<<endl;
    }
    else if(N==3){
        cout<<"bon"<<endl;
    }
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{

}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int l,r,d;
cin>>l>>r>>d;
int ans=0;
rep(i,l,r)if(i%d==0)ans++;
ol(ans);
return 0;
}



Measured memory_bytes: 3608
#include <iomanip>
#include <iostream>

int main() {
  int n, k;
  std::cin >> n >> k;

  double p = 0;
  for (int i = 1; i <= n; ++i) {
    auto pi = 1.0 / n;
    for (int j = i; j < k; j *= 2) pi /= 2.0;
    p += pi;
  }
  std::cout << std::setprecision(10) << p << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#define NUM 1000000007
long long sum(long long begin,long long end){
        return (begin + end)* (end -begin+1)/2;
}
int main(){
    long long N,K;
    scanf("%lld %lld",&N,&K);
    long long ans = 0;
    for(long long i=K;i<=N+1;i++){
        ans += sum(N-(i-1),N) - sum(0,i-1) + 1;
        ans %= NUM;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  if (a<=5)
  {
    cout << 0 << endl;
    return 0;
  }
  else if (a <=12)
  {
    cout << b/2 << endl;
    return 0;
  }
  else
    cout << b << endl;
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	if(c+b>a)
	d=c+b-a;
	if(b+c<a)
	d=0;
	printf("%d\n",d);
	
	// your code goes here
	return 0;
}

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

int N, x;
int a[2010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }  
  int b[2010];
  ll ans = 1LL << 60;
  fill_n((int*)b, 2010, 1 << 30);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      b[j] = min(b[j], a[(j - i + N) % N]);
    }
    ll sum = (ll)i * x;
    for (int j = 0; j < N; j++) {
      sum += b[j];
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//import java.math.BigDecimal
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()

    val counts = (1..n).map { reqFace(it, k) }
    val maxCount = counts.max()!!
    val sum = counts.map { Math.pow(2.0, (maxCount - it).toDouble()) }.sum()
    print(sum / (n * (Math.pow(2.0, maxCount.toDouble()))))
//    val sum = counts.map { BigDecimal(2).pow(maxCount - it) }.sumBy { it.toInt() }
//    val ans = BigDecimal(sum).divide(BigDecimal(n).multiply(BigDecimal(2).pow(maxCount)))
//    print(ans.toPlainString())
}

fun reqFace(base: Int, req: Int): Int {
    if (base >= req) return 0

    var count = 1
    var score = base
    while (score * 2 < req) {
        score *= 2
        count++
    }
    return count
}

Measured memory_bytes: 42416
while line = STDIN.gets
  y, m, d = line.chomp.split(" ")
  ymd = y.rjust(4, '0') + m.rjust(2, '0') + d.rjust(2, '0')
  if ymd.to_i < 18680908 then
    puts "pre-meiji"
  elsif 18680908 <= ymd.to_i and ymd.to_i <= 19120729 then
    puts "meiji " + (y.to_i-1867).to_s + " #{m} #{d}"
  elsif 19120730 <= ymd.to_i and ymd.to_i <= 19261224 then
    puts "taisho "  + (y.to_i-1911).to_s + " #{m} #{d}"
  elsif 19261225 <= ymd.to_i and ymd.to_i <= 19890107 then
    puts "showa " + (y.to_i-1925).to_s + " #{m} #{d}"
  elsif 19890108 <= ymd.to_i then
    puts "heisei " + (y.to_i-1988).to_s + " #{m} #{d}"
  end
end

Measured memory_bytes: 8580
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var maxv = ary.Max();
        var ce = maxv / 2;

        var max = 0;
        var maxi = 0;
        var maxj = 0;

        for (int i=0; i<n; i++) {
            var v = (ary[i] > ce) ? maxv - ary[i] : ary[i] - 0;
            if (v >= max) {
                max = v;
                maxi = maxv;
                maxj = ary[i];
            }
        }

        return maxi + " " + maxj;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//cin>>str;
//cout<<str<<endl;
  string S;
  int K;
  int hairetu;
  cin>>K;
  cin>>S;
  hairetu = S.size();
  if(hairetu<=K){
    cout<<S<<endl;
  }else{
    for(int i=0;i<K;i++){
      cout<<S[i];
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const inf = int(2e12)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func fcLR(a []int, x int) (int, int) {
	l, r := 0, len(a)-1
	for r-l > 1 {
		if m := l + (r-l)/2; a[m] >= x {
			r = m
		} else {
			l = m
		}
	}
	return a[l], a[r]
}

func fc(a []int, x int) int {
	l, r := fcLR(a, x)
	if abs(r-x) < abs(l-x) {
		return r
	} else {
		return l
	}
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, q := ri(), ri(), ri()
	s := make([]int, a, a+2)
	for i := 0; i < a; i++ {
		s[i] = ri()
	}
	t := make([]int, b)
	for i := 0; i < b; i++ {
		t[i] = ri()
	}
	sort.Ints(s)
	sort.Ints(t)
	s = append([]int{-inf}, s...)
	s = append(s, inf)
	t = append([]int{-inf}, t...)
	t = append(t, inf)

	for i := 0; i < q; i++ {
		x := ri()

		var s2t int
		{
			fL, fR := fcLR(s, x)
			s1, s2 := fc(t, fL), fc(t, fR)
			s2t = smaller(abs(fL-x)+abs(s1-fL), abs(fR-x)+abs(s2-fR))
		}

		var t2s int
		{
			fL, fR := fcLR(t, x)
			s1, s2 := fc(s, fL), fc(s, fR)
			t2s = smaller(abs(fL-x)+abs(s1-fL), abs(fR-x)+abs(s2-fR))
		}

		fmt.Println(smaller(s2t, t2s))
	}
}


Measured memory_bytes: 5760
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int S;
		Scanner scanner=new Scanner(System.in);
		S=scanner.nextInt();
		
		
	    int s,m,h;
	    if(0<=S&S<86400){
	    s=S%60;
	    m=(S-s)%3600;
	    h=(S-m-s)/3600;
	    
	    
	    System.out.println(h+":"+m/60+":"+s);

	}

}
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    map<string,int>mp;
    mp["SAT"]=1;
    mp["SUN"]=7;
    mp["MON"]=6;
    mp["TUE"]=5;
    mp["WED"]=4;
    mp["THU"]=3;
    mp["FRI"]=2;
    string a;
    cin>>a;
    cout<<mp[a];
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define mp makr_pair
#define pii pair<ll,ll>

#define ll long long

int h,n;
pii arr[1001];
ll dp[10005][1005];

ll f(int h,int i){
	if(i==n){
		if(h<=0) return 0;
		return 1e9+7;
	}
	if(h<=0) return 0;
	if(dp[h][i]!=-1) return dp[h][i];
	ll ans = 1e9+7;
	ans = min(ans,min(arr[i].second+f(h-arr[i].first,i),f(h,i+1)));
	//ans = min(ans,);
	return dp[h][i] = ans;
}


int main(int argc, char const *argv[])
{
	cin>>h>>n;
	for (int i = 0; i <n ; ++i)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	memset(dp,-1,sizeof(dp));
	cout<<f(h,0);
	return 0;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n, k;
    cin>>n>>k;
    vector<int> hs(n);
    rep(i, n) cin>>hs[i];
    sort(hs.begin(), hs.end());

    int m = 1001001001;
    for (int i = 0; i < n - k + 1; ++i) {
        m = min(m, hs[i + k - 1] - hs[i]);
    }
    cout<<m<<endl;
}

Measured memory_bytes: 640
from itertools import combinations
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, k = map(int, input().split())
x = [0]* n
y = [0]* n
for i in range(n):
    x[i], y[i] = map(int, input().split())

xc = list(combinations(x,2))
yc = list(combinations(y,2))
ans = 4*10**18

for yy in yc:
    u = max(yy)
    d = min(yy)
    for xx in xc:
        r = max(xx)
        l = min(xx)
        count = 0
        for i in range(n):
            if l <= x[i] <=r and d <= y[i] <=u: count += 1
        if count >= k:
            ans = min(ans, (u-d)*(r-l))

print(ans)

Measured memory_bytes: 47452
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[0 for _ in range(l)] for _ in range(n)]
for i in range(n):
    for j in range(l):
        total = 0
        for k in range(m):
            total += a[i][k]*b[k][j]
        c[i][j] = total
for i in range(n):
    print(' '.join(map(str, c[i])))


Measured memory_bytes: 6884
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define N_MAX 1000

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll dp[3][305][605];

int N, d[305];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    cin >> N;
    for(int i = 0; i < N; i++) cin >> d[i];
    dp[0][0][0] = 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= i; j++){
            for(int k = 0; k <= 2*N; k++){
                dp[(i+1)%2][j][k] = 0;
            }
        }
        for(int j = 0; j <= i; j++){
            for(int k = 0; k+d[i] <= 2*N; k++){
                // cycleに使う
                if(d[i] >= 2){
                    dp[(i+1)%2][j+1][k+d[i]] += (dp[i%2][j][k]*finv[d[i]-2])%MOD;
                    dp[(i+1)%2][j+1][k+d[i]] %= MOD;
                }
                // cycleに使わない
                dp[(i+1)%2][j][k] += (dp[i%2][j][k]*finv[d[i]-1])%MOD;
                dp[(i+1)%2][j][k] %= MOD;
            }
        }
    }
    ll ans = dp[N%2][N][2*N];
    ans *= fac[N-1];
    ans %= MOD;
    ans *= inv[2];
    ans %= MOD;
    for(int j = 3; j <= N-1; j++){
        for(int k = 2*j+1; k <= 2*N; k++){
            ll tmp = dp[N%2][j][k];
            tmp *= fac[j-1];
            tmp %= MOD;
            tmp *= inv[2];
            tmp %= MOD;
            tmp *= fac[N-j-1];
            tmp %= MOD;
            tmp *= finv[k-2*j-1];
            tmp %= MOD;
            // そととのつなぎ方
            tmp *= fac[k-2*j];
            tmp %= MOD;
            ans += tmp;
            ans %= MOD;
            // cout << fac[j-1] << ' ' << fac[N-2*j-2] << ' ' << finv[k-2*j-1] << endl;
            // cout << "dp[" << N << "][" << j << "][" << k << "] = " << dp[N][j][k] << ' ' << tmp << endl;
        }
    }
    cout << ans << endl;
}

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

ll A[200100], N, ans, M;

int main(){
  cin>>N;
  for (int i=1;i<=N;++i)cin>>A[i];
  for (int i=1;i<=N;++i)A[i] -= i;
  sort(A+1, A+N+1);
  M = A[(N+1)/2];
  for (int i=1;i<=N;++i)ans += abs(A[i] - M);
  cout<<ans;
}

Measured memory_bytes: 1792
from sys import stdin
n, k = list(map(int, input().split()))

d_a = stdin.readlines()

a_s = [0] * n

for i in range(1, k * 2 + 1, 2):
    l_s = [int(x) for x in d_a[i].rstrip().split()]
    for n in range(len(l_s)):
        a_s[l_s[n]-1] = 1

res = 0
for su in range(len(a_s)):
    if a_s[su] == 0:
        res = res + 1

print(res)


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

int main()
{
  int A, B, T;
  int a[110000];
  int res=0;
  cin >> A >> B >> T;

  int i=1;
  while(i*A<=T){
    res+= B;
    i++;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    cout<<((a>=b)?10:0)<<endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

A,B,C,K = map(int,sys.stdin.readline().split())

#ALL = [1]*A+[0]*B+[-1]*C
#print(sum(ALL[:K]))
print(1*min(A,K)+0*min(B,max(K-A,0))-1*min(C,max(K-A-B,0)))


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

typedef long long ll;

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

int main() {
  int N;
  cin >> N;
  vector<ll> a(N),b(N);
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];
  ll timea = 0,timeb = 0;
  rep(i,N) timea += b[i]-a[i];
  timeb = timea;
  rep(i,N) {
    if (b[i]-a[i] <= 0) timeb -= a[i]-b[i];
    else timea -= (b[i]-a[i]+1)/2;
  }
  if ((timea >= 0) && (timeb >= 0)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3792
while True:
    d = input()
    if d == '-':
        break
    else:
        D = list(d)
        m = int(input())
        for i in range(m):
            h = int(input())
            for i in range(h):
                D.append(D[0])
                D.pop(0)
        D = ''.join(D)
        print(D)


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

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

const double PI = 3.14159265358979323846;
int main()
{
        int64_t n;
	cin >> n;
	auto a = vector<int64_t>(n + 1, 0);
	auto b = vector<int64_t>(n + 1, 0);
	for (int i = 2; i <= n; i++)
	{
		cin >> a[i];
		b[a[i]]++;
	}
	for (int i  = 1; i <= n; i++)
	{
		cout << b[i] << "\n";
	}
	return 0;
	
}

Measured memory_bytes: 6424
import math

def main():
    N = int(input())
    lowercase = 'abcdefghijklmnopqrstuvwxyz'
    ans = ''
    for i in range(len(str(N))):
        if N == 0:
            break
        j = N % 26
        N -= 1
        N = N // 26
        ans = lowercase[j-1] + ans
        # print(N, j-1, ans)
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

char s[10];

int main(){
	scanf("%s", s);
	
	int l = strlen(s);
	
	for(int i = 0; i < l - 1; i++){
		if(s[i] == 'A' && s[i + 1] == 'C')
		return 0 * printf("Yes\n");
	}
	
	printf("No\n");
}


Measured memory_bytes: 256
import java.util.Scanner;
import static java.lang.System.out;

class Range {
    public void run() {
        Scanner scan = new Scanner( System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        out.println( ( a < b) ? ( ( b < c) ? "Yes" : "No") : "No");

    }
}

public class Main {
    public static void main( String... args) {
        Range test = new Range();
        test.run();
    }
}

Measured memory_bytes: 26288
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	k,n = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	m = k
	for i in 1:n-1
		m = min(m,k-(a[i+1]-a[i]))
	end
	m = min(m,a[n]-a[1])
	println(m)
end

main()

Measured memory_bytes: 180212
#include<stdio.h>
int main(void) {
	int num,sum=0;
	scanf("%d", &num);
	int a[100];
	for (int i = 0; i < num; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < num; i++) {
		for (int j = i + 1; j < num; j++) {
			if (i == j) {
				continue;
			}
			sum += a[i] * a[j];
		}
	}
	printf("%d	", sum);
	return 0;
}

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

int main() {
  int n, k, c = 0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  cout << (n - 3 + k) / (k - 1) << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    unsigned long long int a[100005] = {0},b[100005],c[100005];
    unsigned long long int aa[100005];
    unsigned long long int buf;
    unsigned long long int n,q;
    unsigned long long int sum = 0;
    
    scanf("%llu",&n);
    for(int i= 0;i < n;i++){
        scanf("%llu",&buf);
        a[buf] ++;
        aa[i] = buf;
    }
    
    scanf("%llu",&q);
    for(int i = 0;i<q;i ++)scanf("%llu %llu",&b[i],&c[i]);
    for(int i = 0;i<n;i++)sum += aa[i];

    for(int j = 0;j<q;j++){
        sum = sum + a[b[j]] * (c[j] - b[j]);

        a[c[j]] += a[b[j]];
        a[b[j]] = 0;

        printf("%llu\n",sum);
    }
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define int long long
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}
const int N=110;
int n,m,num,a[N];

signed main() {
  n=read(),m=read();
  rep(i,1,n)a[i]=read(),num+=a[i];
  sort(a+1,a+n+1);
  if(a[n-m+1]<double(num)/(4*m))puts("No");
  else puts("Yes");
  return 0;
}

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

int main(){
    string str1, str2, str3;
    
    cin >> str1 >> str2 >> str3;

    cout << char (str1[0] - 32) << char (str2[0] - 32) << char (str3[0] - 32) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void maxh(int* ,int);

int i,num,a[500001];
int main()
{
  scanf("%d",&num);
  for(i=1;i<=num;i++)
    scanf("%d",&a[i]);
  for(i=num/2;i>=1;i--)
    {
      maxh(a,i);
    }
  for(i=1;i<=num;i++)
    printf(" %d",a[i]);
  printf("\n");

  return 0;
}
void maxh(int a[], int i){
  int l,r,e,largest;        


  l = 2*i;
  r = 2*i+1;
  if (l <= num && a[l] > a[i])
    largest = l;
  else 
    largest = i;
  if (r <= num && a[r] > a[largest])
    largest = r;
  if (largest != i){
    e=a[i]; 
    a[i]=a[largest];         
    a[largest]=e;    
maxh(a, largest);
  }

} 

Measured memory_bytes: 2552