akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define N 1000000
const int mod = 998244353;

int n;
int A[N+1];
int B[N+1];
int M[N+1];
int S[N+1];
int inv[N+1];

/*
\sum_{i<j} lcm(Ai,Aj)
\sum_{i<j} Ai Aj / gcd(Ai,Aj)
\sum_{d} 1/d \sum_{i<j: gcd(Ai, Aj) = d} Ai Aj

f(d) = \sum_{i,j: gcd(Ai, Aj) = d} Ai Aj
F(d) = \sum_{i,j: d | gcd(Ai, Aj)} Ai Aj
F(d) = \sum_{i,j: d | Ai, d | Aj)} Ai Aj
F(d) = (\sum_{i: d | Ai} Ai)^2
\sum_{d} 1/d \sum_{n: d|n} m(n/d) F(n)
\sum_{n} F(n) \sum_{d: d|n} 1/d m(n/d)
*/

int modpow(int x, int n){
  int r=1;
  for(;n;n>>=1){
    if(n&1) r = (long long) r * x % mod;
    x = (long long) x * x % mod;
  }
  return r;
}

int main(){
  int i, j, r;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    A[x]++;
  }
  inv[1] = 1;
  for(i=2;i<=N;i++) inv[i] = (long long) (mod - mod/i) * inv[mod%i] % mod;

  M[1] = 1;
  for(i=2;i<=N;i++){
    if(!S[i]){
      M[i] = -1;
      for(j=2*i;j<=N;j+=i){
        S[j] = 1;
        if(M[j]) M[j] = -M[j];
        else M[j] = -1;
      }
    }
  }
  for(i=2;i*i<=N;i++){
    if(S[i]) continue;
    int ii = i*i;
    for(j=ii;j<=N;j+=ii) M[j] = 0;
  }

  for(i=1;i<=N;i++){
    for(j=i;j<=N;j+=i){
      B[i] = (B[i] + (long long) j * A[j]) % mod;
    }
  }

  for(i=1;i<=N;i++){
    B[i] = ((long long) B[i] * B[i]) % mod;
    for(j=i;j<=N;j+=i){
      B[i] = B[i] - (long long) j * j * A[j] % mod;
      if(B[i] < 0) B[i] += mod;
    }
    B[i] = B[i]&1?(B[i]+mod)/2:B[i]/2;
  }


  r = 0;
  for(i=1;i<=N;i++){
    int z = 0;
    for(j=1;j*i<=N;j++){
      if(M[j] > 0) z += B[i * j];
      else if(M[j] < 0) z += mod - B[i * j];
      if(z >= mod) z -= mod;
    }
    r = (r + (long long) inv[i] * z) % mod;
  }
  printf("%d\n", r);

  return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    int ans = 0;
    REP(i,N){
        while(a[i]%2 == 0){
            ans++;
            a[i] >>= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteByte(' ')
		}
		fmt.Fprint(io.writer, v)
	}
	io.writer.WriteByte('\n')
}

func (io *Io) PrintfLn(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format + "\n", a...)
}

func (io *Io) PrintIntLn(a ...int) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteByte(' ')
		}
		fmt.Fprint(io.writer, v)
	}
	io.writer.WriteByte('\n')
}

func (io *Io) PrintStringLn(a ...string) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteByte(' ')
		}
		fmt.Fprint(io.writer, v)
	}
	io.writer.WriteByte('\n')
}

type Tuple2 struct {
	first, second int
}

func main() {
	io := NewIo()
	defer io.Flush()
	s := []string{}
	for i := 0; i < 3; i++ {
		s = append(s, io.Next())
	}
	io.PrintfLn("A%cC", s[1][0])
}


Measured memory_bytes: 640
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

void solve(){
	int n;
	cin >> n;
	vector<pair<int, int>>a(n);
	bool ans = false;
	for (auto &b: a) cin >> b.f >> b.s;
	for (int i = 0; i <= n -3; ++i){
		bool ok = true;
		for (int j = i; j < i + 3; ++j){
			if (a[j].f != a[j].s) ok = false;
		}
		if (ok) {
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 3660
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int>a(4);
    for(int i=0;i<4;++i)
    {
        cin>>a[i];
    }
    sort(all(a));
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


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

int n,ans=0ll,pos=10ll;

signed main()
{
	cin>>n;
	if (n==1||n==2||n%2==1)  return cout<<0<<endl,0;
		
	while (pos<=1e18)
	{
		ans+=(n/pos);
		pos*=5;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
// Created by arjun_singh12 (Arjun Singh) on [12-05-2020 10:55:50]
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define M 1000000007
#define INF LLONG_MAX
#define vll vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>>
#define pb push_back
#define pll pair<ll,ll>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define repr(i,n,a) for(ll i=n;i>=a;i--)
#define endl "\n"
#define db(x); cout<<"Debug: "<<#x<<" = "<<x<<endl;
#define dbv(v); cout<<"Debug: Vector "<<#v<<" = "; for(ll i=0;i<sz(v);i++) cout<<v[i]<<" "; cout<<endl;
using namespace std;
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll test=1;
	// cin>>test;
	while(test--)
	{
	    ll n,m; cin>>n>>m;
	    vector<vector<char>> c(n,vector<char>(m));
	    rep(i,0,n)
	    {
	    	rep(j,0,m)
	    	{
	    		cin>>c[i][j];
	    	}
	    }
	    ll dp[n+1][m+1];
	    memset(dp,0,sizeof(dp));
	    dp[0][0]=1;
	    rep(i,0,n)
	    {
	    	rep(j,0,m)
	    	{
	    		if(i==0 && j==0) continue;
	    		else if(i==0)
	    		{
	    			if(c[i][j]=='#') dp[i][j]=0;
	    			else dp[i][j]=dp[i][j-1];
	    		}
	    		else if(j==0)
	    		{
	    			if(c[i][j]=='#') dp[i][j]=0;
	    			else dp[i][j]=dp[i-1][j];
	    		}
	    		else
	    		{
	    			if(c[i][j]=='#') dp[i][j]=0;
	    			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
	    		}
	    	}
	    }
	    cout<<dp[n-1][m-1];
	}
}


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var s = ReadLine();
		var t = ReadLine();

		var sa = MakeCharA(s);
		var ta = MakeCharA(t);
		Array.Reverse(ta);
		WriteLine(Judge(sa, ta) ? "Yes" : "No");
	}

	static char[] MakeCharA(string s) {
		var sa = new char[s.Length];
		for (var i = 0; i < s.Length; i++) {
			sa[i] = s[i];
		}
		Array.Sort(sa);
		return sa;
	}

	static bool Judge(char[] s, char[] t) {
		for (var i = 0; i < Math.Max(s.Length, t.Length); i++) {
			if (i >= s.Length) {
				return true;
			}
			if (i >= t.Length) {
				return false;
			}
			if (s[i] < t[i]) {
				return true;
			}
			if (t[i] < s[i]) {
				return false;
			}
		}
		return false;
	}
}

Measured memory_bytes: 11604
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	int w;
	string s;
	cin >> s >> w;
	for(int i=0;i<s.size();i+=w) cout << s[i];
	cout << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}


int main () {
  cin.tie(0);
  cout << setprecision(10);
  
  string s, t; cin >> s >> t;

  bool ans = true;
  string tmpt = t;
  for(int i=0;i<SZ(s);i+=2) {
    while(!t.empty() && !s.empty() && t[0] != s[i]) {
      t = t.substr(1, SZ(t)-1);
    }
    if(t.empty() || s.empty()) {
      ans = false;
      break;
    }
    t = t.substr(1, SZ(t)-1);
  }

  if(ans) {
    cout << "Yes" << endl;
    return 0;
  }

  ans = true;

  t = tmpt;
  for(int i=1;i<SZ(s);i+=2) {
    while(!t.empty() && !s.empty() && t[0] != s[i]) {
      t = t.substr(1, SZ(t)-1);
    }
    if(t.empty() || s.empty()) {
      ans = false;
      break;
    }
    t = t.substr(1, SZ(t)-1);
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

///////////////////////////



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

	string w[200];

	repn(i, N) cin >> w[i];

	ll ans = 1;

	repn(i, N - 1) {
		if (w[i][w[i].size() - 1] != w[i + 1][0]) { ans = 0; }

		for (ll j = i + 1; j <= N; j++) {
			if (w[i] == w[j]) { ans = 0; }
		}
	}

	if (ans == 1) { cout << "Yes"; }
	else { cout << "No"; }

	

	system("PAUSE");
}

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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

int main() 
{
    FIO;
    int t,n,k,i,j;
    cin >> n;
    
    int a[n],b[n];
    
    for(i=0;i<n;i++){
        cin >> a[i];
        b[i]=a[i];
    }
    
    sort(b,b+n);
    
    k=0;
    for(i=0;i<n;i++)
        if(a[i]!=b[i])
            k++;
    if(k<=2)
        cout << "YES";
    else    
        cout << "NO";
    
	return 0;
}


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

a = list(zip(a, range(len(a))))
a = sorted(a, reverse = True) + [(0, 0)]

ans = [0] * n
min_ind = 10**9

for i in range(n):
    tmp = a[i][0] - a[i+1][0]
    min_ind = min(min_ind, a[i][1])
    ans[min_ind] += (i+1) * tmp

for i in ans:
    print(i)

Measured memory_bytes: 70756
#ABC160-D Line++
"""
ある２点xとyがつながっているので、
二重ループを回して、
・単純にiとjの距離
・i-x,j-yをつなげた時の距離
・i-y,j-xをつなげた時の距離
の最小値がi-jの距離になる。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,x,y = map(int,readline().split())
ans = [0]*n
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[
            min(
                j-i,
                abs(i-x)+abs(j-y)+1,
                abs(i-y)+abs(j-x)+1
            )
            ] += 1
for i in ans[1:]:
    print(i)


Measured memory_bytes: 47452
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    string s;
    cin >> s;
    ll n = s.size();
    if (n == 1)
    {
        putout(ctoi(s[0]));
        return 0;
    }
    ll ans = 0;
    loop(bit, 1 << n - 1)
    {
        string math;
        loop(i, n)
        {
            math += s[i];
            if (i < n - 1)
            {
                if (flagon(bit, i))
                    math += '+';
            }
        }
        ll sum = 0;
        ll now = 0;
        ll L = math.size();
        loop(i, L)
        {
            if (math[i] == '+')
            {
                sum += now;
                now = 0;
            }
            else
            {
                now *= 10;
                now += ctoi(math[i]);
            }
        }
        sum += now;
        ans += sum;
    }
    putout(ans);
    return 0;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const int mod=998244353;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int dp[2][307][307];
vector<int> v;

inline int singlemod(int x)
{
    return x>=mod ? x-mod : x;
}

int32_t main()
{
    IOS
    string s;
    int n,K;
    cin>>s>>K;
    n=s.length();
    K=min(n,K);

    int summ=0;
    v.pb(0);
    for (int i=0;i<n;i++)
        if (s[i]=='0') v.pb(summ);
        else summ++;
    int _0=sz(v)-1;
    K=min(K,n-_0);

    dp[0][0][0]=1;

    for (int i=1;i<=_0;i++)
    {
        //clear
        memset(dp[i&1],0,sizeof(dp[i&1]));

        for (int j=0;j<=(n-_0)-v[i];j++)
            for (int k=0;k<=n-_0;k++)
        {
            for (int l=0;l<=j;l++) dp[i&1][j][k]=singlemod(dp[i&1][j][k]+dp[i&1^1][l][k]);
            for (int l=j+1;l<=min({j+(v[i]-v[i-1]),n-_0,k+j});l++)
                dp[i&1][j][k]=singlemod(dp[i&1][j][k]+dp[i&1^1][l][k-(l-j)]);
        }
    }
    //

    int ans=0;
    for (int i=0;i<=(n-_0);i++)
        for (int j=0;j<=K;j++)
            if (i+j<=K) ans=(ans+dp[_0&1][i][j])%mod;
    cout<<ans<<endl;
}




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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 998244353;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION

ll a, b, c, d;

void solve() {
    cin >> a >> b >> c >>d;
    vvll dp(c + 1, vll(d + 1, 1));
    dp[a][b] = 1;
    for (int i = a; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            if (i == a && j == b) {
                dp[i][j] = 1;
                continue;
            }
            else if (i == a) {
                dp[i][j] = dp[i][j - 1] * i;
            }
            else if (j == b) {
                dp[i][j] = dp[i - 1][j] * j;
            }
            else {
                dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i;
                ll haaa = (i-1)*(j-1);
                haaa = haaa % mod;
                haaa *= dp[i - 1][j - 1];
                haaa = haaa % mod;
                dp[i][j] -= haaa;
                dp[i][j] = dp[i][j] % mod;
                while (dp[i][j] < 0)
                    dp[i][j] += mod;
            }
            dp[i][j] = dp[i][j] % mod;
        }
    }



    cout << dp[c][d] << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 73652
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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


int a[4],b[4];

int main(){
	
	
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		int hit=0,blo=0;
		rep(i,4){
			if(a[i]==b[i]){
				a[i] = -1;
				b[i] = -2;
				hit++;
			}
		}
		rep(i,4){
			rep(j,4){
				if(a[i] == b[j]){
					a[i]=-1;
					b[j]=-2;
					blo++;
				}
			}
		}
		cout<<hit<<" "<<blo<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()
 
ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}
ll modComb(ll n,ll a){
  ll x=1,y=1;
  rep(i,a){
    x*=n-i;
    x%=MOD;
    y*=i+1;
    y%=MOD;
  }
  y=modPow(y,MOD-2);
  return (x*y)%MOD;
}

int main(){
  ll S,ans=0;
  cin >> S;
  rep(i,S/3){
    ans+=modComb(S-3*(i+1)+i,i);
    ans%=MOD;
  }
  cout << ans << endl;
}

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

int main() {
	int n, k; cin >> n >> k;
	double p[n];
	for(int i = 0; i < n; i++) {
		double q; cin >> q;
		p[i] = (q + 1) / 2;
	}

	double s[n];
	s[0] = p[0];
	for (int i = 1; i < n; i++)
	{
		s[i] = s[i-1] + p[i];
	}

	double res = s[k-1];
	for (int i = k; i < n; i++)
	{
		res = max(res, s[i] - s[i-k]);
	}
	cout << fixed << setprecision(12) << res << endl;
	return 0;
}



Measured memory_bytes: 6844
#include <bits/stdc++.h>
using namespace std;
int n, m, matrice[12][12], nr;
float ans;
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            cin >> matrice[i][j];
   for(int i = 1; i <= n; ++i)
   {
       for(int k = i + 1; k <= n; ++k)
       {
        ans = 0;
        for(int j = 1; j <= m; ++j)
        {
            ans += (matrice[i][j] - matrice[k][j])*(matrice[i][j] - matrice[k][j]);
        }
            float rez = sqrt(ans);
            if(int(rez) == (float)rez)
                nr++;
       }
    }
    cout << nr;
    return 0;
}


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

class Solution
{
    static void Main()
    {
    lb:
        ReadLine();
        var xList = ReadLine().Split().Select(Parse).ToList();
        xList.Sort();
        var result = MaxValue;
        for (int i = xList[0]; i <= xList[xList.Count - 1]; ++i)
        {
            int tmp = 0;
            foreach (var x in xList) tmp += (x - i) * (x - i);
            result = Min(result, tmp);
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		if(num >= 10) {
			num = 10;
		}
		int disp = scanner.nextInt();
		int inner = disp + ((10 - num) * 100);
		System.out.println(inner);
	}

}


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

X = list(map(int, input().split()))

L = min(X)
R = max(X)

answer_list = []
for i in range(L, R+1):
  total = 0
  
  for x in X:
    total += (x-i)**2
  answer_list.append(total)
print(min(answer_list))

Measured memory_bytes: 9176
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n = int(input())
m = {}
np = [deque([]) for _ in range(n)]
for _ in range(n-1):
    a, b, c = [int(x) for x in input().strip().split()]
    m[(a, b)] = c
    m[(b, a)] = c
    np[a-1].append(b)
    np[b-1].append(a)

q, k = [int(x) for x in input().strip().split()]
master = [-1 for _ in range(n)]
master[k-1] = 0

def dfs(cur, pre, master):
    #print('cur = {}, pre = {}'.format(cur, pre))
    for p in np[cur-1]:
        if p == pre:
            continue
        master[p-1] = master[cur-1] + m[(cur, p)]
        dfs(p, cur, master)

dfs(k, -1, master)

for _ in range(q):
    x, y = [int(x) for x in input().strip().split()]
    print(master[x-1] + master[y-1])

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


int main(){
    string s,t;
    cin>>s>>t;
    long long int n=0;
    for(long long int i=0;i*i<s.size();i++){
        if(s[i]!=t[i]){
            n=1;
        }
    }
    if(n==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int A,B;
	cin >> A >> B ;
	cout << (B % A == 0 ? (A + B) : (B - A)) << endl;
	
    return 0;
}


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

int main(){
	int x1, x2, x3, x4;
	int y1, y2, y3, y4;
	int dx, dy;
	cin >> x1 >> y1 >> x2 >> y2;
	dx = x2 - x1;
	dy = y2 - y1;
	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x1 - dy;
	y4 = y1 + dx;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

const ll INF = 1LL << 50;

using namespace std;

ll calcRectArea(ll leftTopX, ll leftTopY, ll rightBottomX, ll rightBottomY){
	ll area;
	area = (rightBottomX - leftTopX) * (rightBottomY - leftTopY);
	return area;
}

int main(){
    ll H, W;
    ll ans = INF;
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0)
    {
    	ans = 0;
    }
    else
    {
    	ll lineH, lineW;
    	// 面積を記録しておく変数
    	ll s1, s2, s3;
    	ll area1, area2, area3;
    	ll diff;
    	// ひとつの長方形に関しては全探索
    	// あとの二つは真ん中に境界線を引く
    	// 縦方向に全探索
		for (lineH = 1; lineH <= H - 1; ++lineH)
		{	
			s1 = calcRectArea(0, 0, W, lineH);
    		// 残りを縦に分割
    		ll line = (H - lineH) / 2;
    		s2 = calcRectArea(0, lineH, W, lineH + line);
    		s3 = calcRectArea(0, lineH + line, W, H);
    		diff = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
			ans = min(ans, diff);

			// 残りを横に分割
			line = W / 2;
			s2 = calcRectArea(0, lineH, line, H);
			s3 = calcRectArea(line, lineH, W, H);
    		diff = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
			ans = min(ans, diff);
    	}

    	// 横方向に全探索
		for (lineW = 1; lineW <= W - 1; ++lineW)
		{
    		s1 = calcRectArea(0, 0, lineW, H);
    		// 残りを縦に分割
    		ll line = H / 2;
    		s2 = calcRectArea(lineW, 0, W, line);
    		s3 = calcRectArea(lineW, line, W, H);
    		diff = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
			ans = min(ans, diff);

			// 残りを横に分割
			line = (W - lineW) / 2;
			s2 = calcRectArea(lineW, 0, lineW + line, H);
			s3 = calcRectArea(lineW + line, 0, W, H);
			diff = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
			ans = min(ans, diff);
    	}
    }

    cout << ans << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k;

int main(){
	cin>>n>>k;
	int t=0;
	for(int i=k-n+1;i<n+k;i++){
		if(t) cout<<' ';
		cout<<i;
		t++;
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

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

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

const int MAX_N = 1e5;
int dp[MAX_N + 1] = {};
int n, k;
int func(int a){
  if(a >= k) return 0;
  if(dp[a] > 0) return dp[a];
  dp[a] = func(a * 2) + 1;
  return dp[a];
}

int main(){
  cin >> n >> k;
  double p = 0;
  REP(i, n){
    p += 1.0 / pow(2, func(i + 1));
  }
  p /= n;
  printf("%.10f\n", p);
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    long long a, b, c;
    while(cin >> a >> b >> c){
        auto check = [&](){
            auto d = c-a-b;
            if(d <= 0) return false;
            return 4*a*b < d*d;
        };
        cout << (check() ? "Yes" : "No") << endl;
    }
}

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

typedef pair <int, int> pii;

const int MAXN = 5e2 + 5;

int N;
bool vis[MAXN][MAXN];
bool bio[MAXN][MAXN];
int dist[MAXN][MAXN];
int perm[MAXN * MAXN];
vector <pii> todo;

void load() {
	scanf("%d", &N);
	for (int i = 0; i < N * N; i++) {
		scanf("%d", perm + i);
		perm[i]--;
	}
}

void dfs(int x, int y) {
	todo.push_back({x, y});
	vis[x][y] = true;
	for (auto delta : vector <pii>{{0, -1}, {0, 1}, {-1, 0}, {1, 0}}) {
		int nx = x + delta.first;
		int ny = y + delta.second;
		if (nx >= 0 && ny >= 0 && nx < N && ny < N && !vis[nx][ny] && dist[nx][ny] == dist[x][y] + !bio[x][y])
			dfs(nx, ny);
	}
}

int solve() {
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			dist[i][j] = min(min(i, N - i - 1), min(j, N - j - 1));
	
	int sol = 0;
	for (int i = 0; i < N * N; i++) {
		int cx = perm[i] / N;
		int cy = perm[i] % N;
		sol += dist[cx][cy];
		todo.clear();
		dfs(cx, cy);
		for (auto it : todo) {
			vis[it.first][it.second] = false;
			if (it.first != cx || it.second != cy) 
				dist[it.first][it.second]--;
		}
		bio[cx][cy] = true;
	}
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 53984
import numpy as np
from scipy.sparse import lil_matrix, csr_matrix
from scipy.sparse.csgraph import shortest_path
M=49*50+1
n,m,s=map(int,input().split())
s=min(s,M-1)
G=lil_matrix((n*M,n*M))
for _ in range(m):
    a,b,silver,time=map(int,input().split())
    a-=1
    b-=1
    for i in range(silver,M):
        G[a*M+i,b*M+i-silver]=time
        G[b*M+i,a*M+i-silver]=time
for i in range(n):
    silver,time=map(int,input().split())
    for j in range(M-silver):
        G[i*M+j,i*M+j+silver]=time
G=G.tocsr()
G=shortest_path(G,method='D',indices=s) # D=VlogE ndarray

for i in range(1,n):
    ans=np.min(G[i*M:i*M+M])
    print(int(ans))

Measured memory_bytes: 113140
d = int(input())
m=[]
for _ in range(d):
    x=list(map(int,input().split()))
    m.append(x)

dp=[[-1]*3 for i in range(d)]
dp[0][0]=0
dp[0][1]=0
dp[0][2]=0
n=d
for i in range(1,n):
    for j in range(3):
        dp[i][j] = max(dp[i-1][j-1]+m[i-1][j-1],dp[i-1][j-2]+m[i-1][j-2])

ans = max(dp[n-1][0]+m[n-1][0],dp[n-1][1]+m[n-1][1],dp[n-1][2]+m[n-1][2])

# print(md)
print(ans)

Measured memory_bytes: 50128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
  int n;
  cin >> n;
  string t;
  queue<string> que;
  while(cin >> t) que.push(t);
  int out=0,run=0,point=0;
  while(!que.empty()) {
    if(n==0) break;
    string s=que.front();
    que.pop();
    if(s=="HIT") {
      run++;
      if(run==4) {
	point++;
	run=3;
      }
    } else if(s=="HOMERUN") {
      run++;
      point+=run;
      run=0;
    } else {
      out++;
      if(out==3) {
	n--;
	run=0;
	out=0;
	cout << point << endl;
	point=0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(string, O, E);
	vector<char> ans(O.size() + E.size());
	loop(i, O.size()) ans[i*2] = O[i];
	loop(i, E.size()) ans[i*2+1] = E[i];
	cout << string(ans.begin(), ans.end()) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, H;
string S;
vector<pii> va;

void input() {
  cin >> H >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i].first >> va[i].second; };
  ;
}

const int maxdam = 20000;
vector<int> maryoku(11111);
map<int, int> mp;
int damage[maxdam + 1];
int dp[111111111];
int dam[maxdam];
void solve() {
  // rep(i, 0, maxdam) dam[i] = INF;
  // for (auto x : va) {
  //   maryoku[x.second] = max(maryoku[x.second], x.first);
  //   mp[x.second] = max(mp[x.second], x.first);
  //   dam[x.first] = min(dam[x.first], x.second);
  // }
  // dam[0] = 0;
  // rrep(i, maxdam - 1, 0) {
  //   if (dam[i] == INF) {
  //     dam[i] = dam[i + 1];
  //   }
  // }

  rep(i, 0, maxdam) { damage[i] = INF; }
  damage[0] = 0;
  rep(i, 0, maxdam) {  // damage i をあたえるのにさいしょうのまりょく
    // damage[i] = ?
    for (auto x : va) {
      if (i - x.first >= 0) {
        chmin(damage[i], damage[i - x.first] + x.second);
      }
    }
  }
  int ans = INF;
  rep(i, H, maxdam) { chmin(ans, damage[i]); }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 2432
def build_max_heap(n,a):
	for i in range(int(n/2),0,-1):
		max_heap(n,a,i)

def max_heap(n,a,i):
	l = i * 2
	r = i * 2 + 1
	larg = i
	if l <= n and a[i-1] < a[l-1]:
		larg = l
	if r <= n and a[larg-1] < a[r-1]:
		larg = r
	if larg != i:
		tmp = a[larg-1]
		a[larg-1] = a[i-1]
		a[i-1] = tmp
		max_heap(n,a,larg)		

n = int(input())
a = list(map(int,input().split()))
build_max_heap(n,a)
for i in range(n):
	print(' ' + str(a[i]), end='')
print()


Measured memory_bytes: 63704
#include <iostream>

using namespace std;

//const int MAXN = 10000500;
//const int MAXN = 50;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	int k = 0;
	cin >> k;

	long long int res = 0;

	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			int r0 = gcd(i, j);
			for (int h = 1; h <= k; ++h) {
				res += gcd(r0, h);
			}
		}

	}
	
	cout << res << endl;

	//system("pause");
	return 0;
}
	
	


Measured memory_bytes: 3164
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            if (A % 2 != B % 2)
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            else
            {
                Console.WriteLine((A + B) / 2);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

struct abdata {
    int a, b;
};

int main() {
    int n; cin >> n;
    vector<abdata> ans;
    if(n%2 == 0) {
        // 偶数
        int tar = n+1;
        for(int i = 1; i < n; ++i) {
            for(int j = i+1; j <= n; ++j) {
                if(i+j != tar) {
                    abdata indata;
                    indata.a = i; indata.b = j;
                    ans.emplace_back(indata);
                }
            }
        }
    }else {
        // 奇数
        int tar = n;
        for(int i = 1; i < n; ++i) {
            for(int j = i+1; j < n; ++j) {
                if(i+j != tar) {
                    abdata indata;
                    indata.a = i; indata.b = j;
                    ans.emplace_back(indata);
                }
            }
            abdata last;
            last.a = i; last.b = n;
            ans.emplace_back(last);
        }
    }

    int anslen = ans.size();
    cout << anslen << endl;
    for(int i = 0; i < anslen; ++i) {
        cout << ans[i].a << " " << ans[i].b << endl;
    }
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<int> alpha(26);
    if(n < 26)
    {
        for(int i = 0; i < n; i++)
        {
            alpha[s[i]-'a']++;
        }
        for(int i = 0; i < 26; i++)
        {
            if(alpha[i] == 0)
            {
                cout << s << char(i+'a') << endl;
                return 0;
            }
        }
    }
    else
    {
        for(int i = 1; i < 26; i++)
        {
            int x = s[n-1-i] - s[n-i];
            if(x >= 1)
            {
                alpha[s[n-i]-'a']++;
            }
            else
            {
                alpha[s[n-i]-'a']++;
                int pos = s[n-1-i] - 'a';
                for(int j = pos+1; j < 26; j++)
                {
                    if(alpha[j] == 1)
                    {
                        cout << s.substr(0, n-1-i) << char(j+'a') << endl;
                        return 0;
                    }
                }
            }
        }
        cout << -1 << endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n,k,ans=0;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;++i){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	int ret = K;
	for(int i=1; i<N; i++)
	{
		ret *= K - 1;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(n, k);
  int at = n - k;
  if (at <= 0) {
    out(1);
  } else {
    out(1 + (at + k - 2) / (k - 1));
  }
}


Measured memory_bytes: 256
import heapq as heapy
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort(reverse=True)
friendliness = 0
circle = [arr[0]]
best = [[-arr[0], (arr[0], arr[0])]]
heapy.heapify(best)
i = 1
while i != n:
    p = heapy.heappop(best)
    left = p[1][0]
    right = p[1][1]
    p1 = [-min(left, arr[i]), (left, arr[i])]
    p2 = [-min(right, arr[i]), (arr[i], right)]
    heapy.heappush(best, p1)
    heapy.heappush(best, p2)
    friendliness += -p[0]
    i += 1
print(friendliness)

Measured memory_bytes: 147080
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vint fact(1e5+1);

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n); in(k);
    vint arr(n), dp(n);
    f(n) cin>>arr[i];
    dp[0]=0;
    for(int i=1; i<n; i++){
    	int mini = INT_MAX;
    	for(int j=i-1; j>=max((int)0, i-k); j--){
    		int a = dp[j]+abs(arr[i]-arr[j]);
   			mini = min(mini, a);
    	}
    	dp[i] = mini;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 4484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            String a = sn.next();
            if (a.length() >= "YAKI".length()) {
                if (a.substring(0, 4).equals("YAKI")) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 21972