akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define M 1000000007
#define vc vector
#define vci vector<ll>
#define si set<ll>
#define pb push_back
#define pop pop_back
#define fs first
#define sc second
#define endl "\n"
#define mii map<ll,ll>
#define pii pair<ll,ll>
#define msi map<string,ll>
#define PI 3.14159265
#define r0 return 0
using namespace std;

ll n,co,ans;
ll dp[100003][3];
ll a[100003][3];

void ah_shit_here_we_go_again()
{
    co=0;
    ans=0;
    cin>>n;
    
    rep(i,0,n)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    rep(i,0,n+1)
    {
        rep(j,0,3)
        {
            dp[i][j]=0;
        }
    }
    rep(i,0,3)
    {
        dp[0][i]=a[0][i];
    }
    ll x=0,y;
    rep(i,1,n)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    x=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<x;
}   


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    ll t;
    t=1;
    //cin>>t;
    rep(i1,0,t)
    {
        ah_shit_here_we_go_again();
    }
    return 0;

}

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

using namespace std;

int main(void){
  int tgt = 100000;
  vector<int> prime;
  prime.reserve(tgt);
  prime.push_back(2);
  for(int n = 3; n <= tgt; n += 2){
    int i;
    for(i = 0; prime[i] * prime[i] <= n; i++){
      if(n % prime[i] == 0){
        break;
      }
    }
    if(prime[i] * prime[i] > n){
      prime.push_back(n);
    }
  }
  vector<bool> isprime(tgt + 1, false);
  for(int p : prime) isprime[p] = true;
  vector<int> cumsum(tgt + 1, 0);
  cumsum[1] = 0;
  for(int i = 3; i <= tgt; i += 2){
    cumsum[i] = cumsum[i - 2];
    if(isprime[i] && isprime[(i + 1) / 2]) cumsum[i]++;
  }
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    if(l <= 1) l = 3;
    cout << cumsum[r] - cumsum[l - 2] << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n;
  cin >> n;
  int ans = n * n * n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pii pair<int,int>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(10)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod = 1000000007;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int a,b,q;
vector<int> s,t,dist_s,dist_t;

int binary_search_s(int key){
    int low = 0,high = b;
    while(high - low > 1){
        int mid = (high + low) / 2;
        if(t[mid] >= key) high = mid;
        else low = mid;
    }
    return high;
}

int binary_search_t(int key){
    int low = 0,high = a;
    while(high - low > 1){
        int mid = (high + low) / 2;
        if(s[mid] >= key) high = mid;
        else low = mid;
    }
    return high;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> q;
    s.resize(a);
    t.resize(b);
    dist_s.resize(a);
    dist_t.resize(b+1,LINF);
    s.emplace_back(LINF);
    t.emplace_back(LINF);
    dist_s.emplace_back(LINF);
    rep(i,a){
        cin >> s[i];
    }
    rep(i,b){
        cin >> t[i];
    }
    rep(i,a){
        int pos = binary_search_s(s[i]);
        if(abs(s[i] - t[pos]) > abs(s[i] - t[pos-1])){
            dist_s[i] = abs(s[i] - t[pos-1]);
            chmin(dist_t[pos-1],abs(s[i] - t[pos-1]));
        }
        else{
            dist_s[i] = abs(s[i] - t[pos]);
            chmin(dist_t[pos],abs(s[i] - t[pos]));
        }
    }
    rep(i,b){
        int pos = binary_search_t(t[i]);
        if(abs(t[i] - s[pos]) > abs(t[i] - s[pos-1])){
            chmin(dist_t[i],abs(t[i] - s[pos-1]));
            chmin(dist_s[pos-1],abs(t[i] - s[pos-1]));
        }
        else{
            chmin(dist_t[i],abs(t[i] - s[pos]));
            chmin(dist_s[pos],abs(t[i] - s[pos]));
        }
    }
    rep(i,q){
        int x;
        cin >> x;
        int pos = binary_search_t(x);
        int minv = min(dist_s[pos]+abs(x-s[pos]),dist_s[pos-1]+abs(x-s[pos-1]));
        pos = binary_search_s(x);
        cout << min({minv,dist_t[pos]+abs(x-t[pos]),dist_t[pos-1]+abs(x-t[pos-1])}) << '\n';
    }
    return 0;
}

Measured memory_bytes: 4432
import itertools
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

s = int(input())
if s == 1 or s == 2:
  print(0)
elif s >= 3 and s <= 5:
  print(1)
else:
  ans = 1
  for i in range(2,1000):
    x = s - 3*i
    if x < 0:
      break
    ans += combinations_count(x + i - 1, x)
  print(ans % (10**9 + 7))

Measured memory_bytes: 9512
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long[] nk = ILongs();
            char[] s = IChars();

            long change = 0;

            for(int i=0;i<nk[0]-1;i++){
                if(s[i]!=s[i+1])change ++;
            }
            long cantchange = Max(change - 2 * nk[1],0);

            WriteLine(nk[0]-1-cantchange);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13216
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

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

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

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

  ll h[N];
  rep(i, N) cin >> h[i];

  ll dp[N];
  rep(i, N) dp[i] = INF;
  dp[0] = 0;

  repd(i, 0, N)
  {
    chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[N - 1];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL memo[405][405];
LL sum[405][405];
LL A[405];

LL stoneGame(LL n) {

      for (LL i = 0; i < n; i++) 
      	memo[i][i] = 0;

      LL left = 0;
      LL right = n - 1;

      for (LL i = 0; i < n; i++) sum[i][i] = A[i];
      for (LL i = 0; i < n; i++) {
          for (LL j = i + 1; j < n; j++) {
              sum[i][j] = sum[i][j-1] + A[j];
          }
      }
      for (LL length = 1; length <= right - left; length++) {
          for (LL start = 0; start < n; start++) {
              LL end = start + length;
              if (end >= n) continue;
              memo[start][end] = INF64;
              for (LL k = start; k < end; k++) {
                  memo[start][end] = min(
                      memo[start][end], 
                      memo[start][k] + memo[k + 1][end] + sum[start][end]);
              }
          }
      }

      return memo[0][n - 1];
  }

int main() {
	LL n;
	scanf("%lld", &n);
	for (LL i = 0; i < n; i++)
		scanf("%lld", A + i);
	printf("%lld\n", stoneGame(n));
	return 0;
}
		

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


auto solve() {
    string S;
    cin>>S;
    map<char, bool> nwse;
    for(auto&& s: S) {
        nwse[s] = true;
    }
    if((nwse['N'] && !nwse['S']) || (!nwse['N'] && nwse['S']))
        return false;
    if((nwse['E'] && !nwse['W']) || (!nwse['E'] && nwse['W']))
        return false;

    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

mod = 10 ** 9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
fac, inv = factorial(n, mod)

ans = 0
for i in range(0, n-k+1):
    m = n - i - 1
    ans = (ans + (a[-i-1] - a[i]) % mod * fac[m] % mod * inv[m-k+1] % mod * inv[k-1]) % mod
print(ans)



Measured memory_bytes: 87312
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}


#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  int in(N);

  priority_queue<pii> q;
  rep(i, N) {
    int in(a);
    q.emplace(a, i);
  }

  vv<ll> dp(N+1, vector<ll>(N+1, 0));
  rep(i, N) {
    auto [a, idx] = q.top(); q.pop();
    rep(j, i+1) {
      chmax(dp[i+1][j], dp[i][j] + 1ll * a * abs(N-(i-j)-1-idx));
      chmax(dp[i+1][j+1], dp[i][j] + 1ll * abs(idx - j) * a);
    }
  }
  cout << *all(max_element, dp[N]) << endl;

  return 0;
}


Measured memory_bytes: 34684
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var d = new Dictionary<int, KeyValuePair<string, int>>();
    for (int i = 0; i < n; i++) {
      var a = Console.ReadLine().Split();
      d[i + 1] = new KeyValuePair<string, int>(a[0], int.Parse(a[1]));
    }
    foreach (var i in d.OrderBy(x => x.Value.Key).ThenByDescending(x => x.Value.Value)) {
      Console.WriteLine(i.Key);
    }
  }
}

Measured memory_bytes: 13536
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NMX = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var left = NMX[1] - A.Count(x => x <= NMX[2]);
            var right = NMX[1] - left;
            Console.WriteLine(Math.Min(left, right));
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;

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

	int maxL=1;
	int minR=n;

	for (int i = 0; i < m; i++) {
		int L, R;
		cin >> L >> R;
		if (L > maxL) {
			maxL = L;
		}

		if (R < minR) {
			minR = R;
		}
	}

	int ans = minR - maxL + 1;

	if (ans < 0) {
		ans = 0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
const int mod = 1000000007;


long long mpow(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}



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

    ll dp[k+1];
    dp[k] = 1;
    for(int i = k-1; i >= 1; i--) {
        dp[i] = mpow(k/i, n);
        for(int j = 2*i; j <= k; j += i) {
            dp[i] = dp[i] - dp[j];
            if(dp[i] < 0)
                dp[i] += mod;
        }
    }

    ll ans = 0;
    for(ll d = 1; d <= k; d++) {
        ans = (ans + (1LL * d * dp[d])%mod) %mod;
    }
    cout << ans << endl;


}


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

const int N = 2222;
const int mod = 924844033;

#define int long long

int dp[N][2] , n , m , k , tmp[N][2];

void Add(int &x , int y) {
	(x += y) %= mod;
}

int fac[N];

main(void) {
	cin >> n >> k;
	dp[0][0] = 1;
	fac[0] = 1;
	for(int i = 1;i <= n;++ i) fac[i] = fac[i - 1] * i % mod;
	if(k > n) {
		cout << fac[n] << endl;
		return 0;
	}
	if(!k) {
		cout << fac[n] - 1 << endl;
		return 0;
	}
	for(int i = 1;i <= k;++ i) {
		int len = 0;
		for(int j = i;j <= n;j += k)
		++ len;
		-- len;
		for(int j = 0;j <= n;++ j) {
			Add(dp[j][0] , dp[j][1]);
			dp[j][1] = 0;
		}
		for(int j = 1;j <= len;++ j) {
			for(int a = 0;a <= n;++ a) 
			tmp[a][0] = dp[a][0] , tmp[a][1] = dp[a][1] , dp[a][0] = dp[a][1] = 0;
			for(int a = 0;a <= n;++ a) {
				Add(dp[a][0] , tmp[a][0]);
				Add(dp[a][0] , tmp[a][1]);
				Add(dp[a + 1][1] , tmp[a][0]);
			}
		}
		for(int j = 0;j <= n;++ j) {
			Add(dp[j][0] , dp[j][1]);
			dp[j][1] = 0;
		}
		for(int j = 1;j <= len;++ j) {
			for(int a = 0;a <= n;++ a) 
			tmp[a][0] = dp[a][0] , tmp[a][1] = dp[a][1] , dp[a][0] = dp[a][1] = 0;
			for(int a = 0;a <= n;++ a) {
				Add(dp[a][0] , tmp[a][0]);
				Add(dp[a][0] , tmp[a][1]);
				Add(dp[a + 1][1] , tmp[a][0]);
			}
		}
	}
	int ans = 0;
	for(int i = 0 , j = 1;i <= n;++ i) {
		Add(ans , fac[n - i] * j % mod * (dp[i][0] + dp[i][1]) % mod);
		j = mod - j;
	}
	cout << ans << endl;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main(void) {
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])yn
	return 0;
}

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

static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,m[MAX][MAX];

int prim(){
  int u,min,d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    min=INFTY;
    u=-1;
    for(int i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
        u=i;
        min=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int j=0;j<n;j++){
      if(color[j]!=BLACK && m[u][j]!=INFTY){
        if(d[j]>m[u][j]){
          d[j]=m[u][j];
          p[j]=u;
          color[j]=GRAY;
        }
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1) sum+=m[i][p[i]];
  }
  return sum;
}

int main(){
  cin >>n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin >> e;
      m[i][j]=(e==-1) ? INFTY : e;
    }
  }
  cout << prim() << endl;

  return 0;
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];
	
	for(int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	color[0] = GRAY;
	
	while( 1 ) {
		minv = INFTY;
		u = -1;
		for(int i = 0; i < n; i++) {
			if(minv > d[i] && color[i] != BLACK) {
				minv = d[i];
				u = i;
			}
		}
		if(u == -1) break;
		color[u] = BLACK;
		for(int v = 0; v < n; v++) {
			if(color[v] != BLACK && M[u][v] != INFTY) {
				if(d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
				}
			}
		} 
		
	}
	
	int sum = 0;
	for(int i = 0; i < n; i++) {
		if(p[i] != -1) sum += M[i][p[i]];
	}
	
	return sum;
}

int main() {
	int e; 
	cin >> n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
		    cin >> e;
		    M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	
	cout << prim() << endl;
	return 0; 
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	string S;
	cin >> S;
	if(S[0]==S[2]) cout << "Yes" <<endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
m = input()
t = int(m.split()[0])
a = int(m.split()[1])
c = None
d = 9999
k = input().split()
for i in range(n):
    w = t - int(k[i]) * 0.006
    if abs(a - w) < d:
        c = i+1
        d = abs(a - w)
print(c)

Measured memory_bytes: 3060
#include<stdio.h>

int main (void){
	long long int a[110][110]={},b[110][110]={},c[110][110]={},n,m,l,i,j,k=1;
	scanf("%lld %lld %lld",&n,&m,&l);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(i=1;i<=m;i++){
		for(k=1;k<=l;k++){
			scanf("%lld",&b[i][k]);
		}
	}
	for(i=1;i<=n;i++){
		for(k=1;k<=l;k++){
			for(j=1;j<=m;j++){
				c[i][k]+=a[i][j]*b[j][k];
			}
		}
	}
	for(i=1;i<=n;i++){
		for(k=1;k<=l-1;k++){
			printf("%lld ",c[i][k]);
		}
		printf("%lld\n",c[i][l]);
	}
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int x; cin >> x;
  vector<int> v(n);
  for(auto&e:v)cin >> e;
  sort(v.begin(),v.end());
  int cnt = n;
  for(auto e:v) x -= e;
  while(x - v.front() >= 0){
    x -= v.front();
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632
import math
n = int(input())
s = input()
r_cnt = 0
g_cnt = 0
b_cnt = 0
for i in s:
    if i == 'R':
        r_cnt += 1
    elif i == 'G':
        g_cnt += 1
    elif i == 'B':
        b_cnt += 1
        
total = r_cnt*g_cnt*b_cnt

if n < 4:
    print(0)

else:
    for i in range(1,math.floor((len(s)-2)/2)+10):
        for j in range(n-2*i):
            tmp = s[j]+s[j+i]+s[j+2*i]
            if (tmp == 'RGB') or (tmp == 'RBG') or (tmp == 'GBR') or (tmp == 'GRB') or (tmp == 'BRG') or (tmp == 'BGR'):
                total -= 1

    print(total)


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

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        string s;
        cin>>n>>s;
        ll res=0;
        for(int i=0;i<n;i++){
            map<char,ll> F;//前半
            map<char,ll> S;//後半
            ll x=0;
            for(int j=0;j<i+1;j++){
                F[s[j]]++;
            }
            for(int j=i+1;j<n;j++){
                S[s[j]]++;
            }
            for(auto p:F){
                if(S[p.first]>0) x++;
            }
            res=max(res,x);
        }
        cout<<res<<endl;
    }


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

using namespace std;

const int INF = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, K;
  cin >> h >> w >> K;
  vector<vector<int>> s(h, vector<int> (w, 0));
  for(int i = 0; i < h; i++)
  {
    string str;
    cin >> str;
    for(int j = 0; j < w; j++)
    {
      if(str[j] == '1') s[i][j] = 1;
    }
  }
  int ans = INF;
  for(int i = 0; i < (1 << (h - 1)); i++)
  {
    int cuts = __builtin_popcount(i) + 1;
    vector<vector<int>> ns(cuts, vector<int> (w, 0));
    vector<int> pos;
    for(int j = 0; j < h - 1; j++)
    {
      if((i >> j) & 1)
      {
        pos.push_back(j + 1);
      }
    }
    pos.push_back(h);
    for(int j = 0; j < w; j++)
    {
      for(int k = 0, cur = 0; k < cuts; k++)
      {
        for(; cur < pos[k]; cur++)
        {
          ns[k][j] += s[cur][j];
        }
      }
    }
    vector<vector<int>> kdis(cuts, vector<int> (w, 0));
    vector<int> dp(w, 0);
    int br = 0;
    for(int j = 0; j < cuts; j++)
    {
      for(int k = w - 1, l = w - 1, diff = 0; k >= 0; k--)
      {
        diff += ns[j][k];
        for(; l > k && diff > K; l--) diff -= ns[j][l];
        if(diff <= K)
          kdis[j][k] = l + 1;
        else
        {
          br = 1;
        }
      }
    }
    if(br == 1) continue;
    for(int j = w - 1; j >= 0; j--)
    {
      int mm = w;
      for(int k = 0; k < cuts; k++)
      {
        mm = min(mm, kdis[k][j]);
      }
      if(mm == w) dp[j] = 0;
      else
      {
        dp[j] = 1 + dp[mm];
      }
    }
    ans = min(ans, dp[0] + cuts - 1);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int a[3][3];
	bool b[3][3];
	for(int i=0; i<3; i++)
	{
		for(int j=0; j<3; j++)
		{
			cin>>a[i][j];
			b[i][j]=0;
		}
	}
	int n;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		int s;
		cin>>s;
		for(int i=0; i<3; i++)
		{
			for(int j=0; j<3; j++)
			{
				if(a[i][j]==s)
				{
					b[i][j]=1;
				}
			}
		}
	}
	bool benar=0;
	for(int i=0; i<3; i++)
	{
		if(b[i][0]==1 && b[i][1]==1 && b[i][2]==1)
		{
			benar=1; break;
		}
	}
	for(int i=0; i<3; i++)
	{
		if(b[0][i]==1 && b[1][i]==1 && b[2][i]==1)
		{
			benar=1; break;
		}
	}
	if(b[0][0]==1 && b[1][1]==1 && b[2][2]==1)
	{
		benar=1;
	}
	if(b[2][0]==1 && b[1][1]==1 && b[0][2]==1)
	{
		benar=1;
	}
	if(benar)
	{
		cout<<"Yes\n";
	}else cout<<"No\n";

}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long ans;
        if(a == 0){
        	ans = b / x + 1;
        }else{
        	ans = b / x - (a - 1) / x;
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 35888
def cal(A,B,C,D,E,F):
    div = [0 for _ in range(4)]
    div[0] = F // (100 * A)
    div[1] = F // (100 * B)
    if B % A == 0:
        div[1] = 0
    div[2] = (F * E) // ((100 + E) * C)
    div[3] = (F * E) // ((100 + E) * D)
    if D % C == 0:
        div[3] = 0

    concent,concent_max = -1.0,[0,0]
    for i2 in range(div[1]+1):
        for i1 in range(div[0]+1):
            for j2 in range(div[3]+1):
                for j1 in range(div[2]+1):
                    if 100 * (A * i1 + B * i2) + (C * j1 + D * j2) <= F \
                    and (C * j1 + D * j2) <= E * (A * i1 + B * i2) \
                    and ((i1 != 0) or (i2 != 0)):
                        if concent < (C * j1 + D * j2) / (A * i1 + B * i2):
                            concent = (C * j1 + D * j2) / (A * i1 + B * i2)
                            concent_max = [C * j1 + D * j2 , (A * i1 + B * i2) * 100]
                    else:
                        break

    return concent_max

def main():
    A,B,C,D,E,F = map(int,input().split())

    concent_max = cal(A,B,C,D,E,F)
    print(concent_max[0] + concent_max[1],concent_max[0])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	int pop_count(int bs) {
		int cnt = 0;
		for (int i = 0; i < 16; ++i) {
			cnt += (bs >> i) & 1;
		}
		return cnt;
	}

	void run() {
		for (;;) {
			int n = ni();
			int c = ni();
			if ((n | c) == 0) {
				break;
			}
			int[] a = new int[n + 1];
			for (int i = 0; i < n; ++i) {
				a[i] = 0;
				for (int j = 0; j < 16; ++j) {
					int v = ni();
					a[i] |= v << j;
				}
			}
			a[n] = 0;
			int[] b = new int[c];
			for (int i = 0; i < c; ++i) {
				b[i] = 0;
				for (int j = 0; j < 16; ++j) {
					int v = ni();
					b[i] |= v << j;
				}
			}

			int[][] dp = new int[2][1 << 16];
			for (int i = 0; i < 2; ++i) {
				Arrays.fill(dp[i], -1);
			}
			dp[0][a[0]] = 0;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < 1 << 16; ++j) {
					if (dp[(i&1)][j] == -1) {
						continue;
					}
					for (int k = 0; k < c; ++k) {
						int cnt = pop_count(b[k] & j);
						int nbs = ((b[k] ^ j) & j) | a[i + 1];

						dp[(i&1)^1][nbs] = Math.max(dp[(i&1)^1][nbs], dp[(i&1)][j]
								+ cnt);
					}
				}
				Arrays.fill(dp[i&1], -1);
			}

			int ans = 0;
			for (int i = 0; i < 1 << 16; ++i) {
				ans = Math.max(ans, dp[n&1][i]);
			}
			System.out.println(ans);
		}
	}

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

	void test() {
		for (int i = 0; i < 1; ++i) {
			System.out.println("30 30");
			for (int j = 0; j < 30; ++j) {
				for (int k = 0; k < 16; ++k) {
					if (k > 0) {
						System.out.print(" ");
					}
					System.out.print(Math.random() > 0.5 ? "1" : "0");
				}
				System.out.println();
			}
			for (int j = 0; j < 30; ++j) {
				for (int k = 0; k < 16; ++k) {
					if (k > 0) {
						System.out.print(" ");
					}
					System.out.print(Math.random() > 0.5 ? "1" : "0");
				}
				System.out.println();
			}
		}
		System.out.println("0 0");
	}

	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}

	int ni() {
		return Integer.parseInt(sc.next());
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 51076
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    cout<<a-(s==u)<<' '<<b-(t==u)<<endl;
}


Measured memory_bytes: 256
/*
	Templates start.
	Powered by c++11.
	Author : Alex_Wei.
*/

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

// IO templates.

char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#ifdef __WIN64
	#define gc getchar()
#else
	#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#define pc(x) (*O++=x)
#define flush() fwrite(obuf,O-obuf,1,stdout)

inline int read(){
	int x=0,sign=0; char s=getchar();
	while(!isdigit(s))sign|=s=='-',s=getchar();
	while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
	return sign?-x:x;
}
void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

/*
	Templates end.
	Please give me more points.
*/

string s;

int main(){
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])puts("Yes");
	else puts("No");
	
	return 0; 
}

Measured memory_bytes: 256
n1,n2,n3 = map(int,input().split(" "))

list1 = [list(map(int,input().split(" "))) for _ in range(n1)]
list2 = [list(map(int,input().split(" "))) for _ in range(n2)]

mat = [[0 for _ in range(n3)] for _ in range(n1)]
for i in range(n1):
	for j in range(n2):
		for k in range(n3):
			mat[i][k] += list1[i][j] * list2[j][k]

for m in mat:
	print(*m)



Measured memory_bytes: 7060
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s = list(Counter(s).items())
m = int(input())
t = [input() for _ in range(m)]
t = Counter(t)

result = 0
for i in range(len(s)):
    result = max(s[i][1]-t[s[i][0]], result)
print(result)

Measured memory_bytes: 3316
import copy
import sys

def isshoujun(ls):
    for i in range(N-1):
        if ls[i] > ls[i+1]:
            return False
    return True

N = int(input())
A = list(map(int,input().split()))
for i in range(N-1):
    for j in range(i, N):
        temp = copy.deepcopy(A)
        x = temp[i]
        temp[i] = temp[j]
        temp[j] = x
        if isshoujun(temp):
            print("YES")
            sys.exit()
print("NO")

Measured memory_bytes: 45788
N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge)-1 for hoge in input().split()]#0-indexed似直した
Went = [False]* N
curpos = 0
Went[0] = True
asiato = [0]
while 1:
    curpos = A[curpos]
    if Went[curpos]:break
    asiato.append(curpos)
    Went[curpos] = True
Loopstart = asiato.index(curpos)
LenLoop = len(asiato) - Loopstart
#[0 6 2 5 3]2 5 3...
if K < len(asiato):
    print(asiato[K] + 1)
else:
    X = (K - Loopstart) % LenLoop + Loopstart
    print(asiato[X] + 1)



Measured memory_bytes: 102892
#include<bits/stdc++.h>
using namespace std;
#define N 100 + 5
#define Mod 1000000007
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define dep(i, l, r) for(int i = r; i >= l; --i)
int n, ans, a[N], dp[N][N][N];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){ return (a += b) >= Mod ? a - Mod : a;}
int main(){
    n = read();
    rep(i, 1, 2 * n - 1) a[i] = read();
    sort(a + 1, a + 2 * n);
    dp[n][0][0] = 1;
    dep(i, 1, n - 1){
        int l = (a[i] != a[i + 1]), r = (a[n * 2 - i] != a[n * 2 - i - 1]);
        rep(j, 0, 2 * n - 1) rep(k, 0, 2 * n - 1){
            dp[i][j + l][k + r] = Inc(dp[i][j + l][k + r], dp[i + 1][j][k]);
            rep(p, 0, j + l - 1) dp[i][p][k + r + 1] = Inc(dp[i][p][k + r + 1], dp[i + 1][j][k]);
            rep(p, 0, k + r - 1) dp[i][j + l + 1][p] = Inc(dp[i][j + l + 1][p], dp[i + 1][j][k]);
        }
    }
    rep(i, 0, 2 * n - 1) rep(j, 0, 2 * n - 1) ans = Inc(ans, dp[1][i][j]);
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(){
  int a,b;
  int pm;
  scanf("%d%d",&a,&b);
  if (b>0) pm=a+b;
  else pm=a-b;
  if (pm>a*b) printf("%d\n",pm);
  else printf("%d\n",a*b);
  return 0;
}

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

int main(){
  vector<int > p(2);
  rep(i,2){cin >> p[i];}
  
  cout << p[1] + (p[1]-p[0]) << endl;
                  
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

vl solve_small(int n,vl qs)
{
	vi a(n); iota(all(a),1);
	for(ll q:qs){
		vi b(q);
		rep(i,q) b[i]=a[i%a.size()];
		a=b;
	}
	vl res(n);
	for(int x:a) res[x-1]++;
	return res;
}

vl solve(int n,vl qs)
{
	{
		vl t(1,n);
		for(ll q:qs){
			while(t.size() && t.back()>=q)
				t.pop_back();
			t.push_back(q);
		}
		qs=t;
	}
	vl cs(qs.size()); cs.back()=1;

	vl res(n+1);
	per(i,qs.size()){
		for(;;){
			auto it=upper_bound(begin(qs),begin(qs)+i,qs[i]);
			if(it==begin(qs)) break;
			int j=it-qs.begin()-1;
			cs[j]+=qs[i]/qs[j]*cs[i];
			qs[i]%=qs[j];
		}
		res[0]+=cs[i];
		res[qs[i]]-=cs[i];
	}
	rep(i,n) res[i+1]+=res[i];
	res.pop_back();
	return res;
}

int main()
{
	for(int n,q;cin>>n>>q && n|q;){
		vl qs(q);
		rep(i,q) cin>>qs[i];
		vl res=solve(n,qs);
		for(ll x:res) cout<<x<<endl;
	}
}


Measured memory_bytes: 4036
#include <cstdint>
#include <iostream>

using namespace std;

#define N 50

int32_t main()
{
  long long K;
  cin >> K;

  cout << N << endl;

  for (uint32_t i = 0; i <= N; i++) {
    if (i == (N - (K % N))) continue;
    if (i != 0) cout << " ";
    cout << i + (K / N);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>

#define WIN 3;
#define DRAW 1;

struct Order{
	char move[8];
	int start,end;
	char change[1000];
};

void print(char *str_Org, int st,int ed){
	int i;
	for(i=st; i<=ed; i++){
		printf("%c",str_Org[i]);
	}
	printf("\n");
	return ;
}

void reverse(char *str_Org, int st, int ed){
	int i,j;
	char str_Cpy[1001]={0};
	
	j = st;
	strcpy(str_Cpy,str_Org);
	
	for(i=ed; i>=st; i--){
		str_Org[j++] = str_Cpy[i];
	}
	memset(str_Cpy,'\0',strlen(str_Cpy));
	
	return ;
}

void replace(char *str_Org, int st, int ed, char *swc){
	int i,j;
	char str_Cpy[1001]={0};
	
	j = 0;
	strcpy(str_Cpy,str_Org);
	
	for(i=st; i<=ed; i++){
		str_Org[i] = swc[j++];
	}
	memset(str_Cpy,'\0',strlen(str_Cpy));
	
	return ;
}

int main(){
	
	int i,j,k,l;
	int num;
	char str_Org[1001]={0};
	struct Order ord[100]={0};
	
	scanf("%s",str_Org);
	scanf("%d",&num);
	for(i=0; i<num; i++){
		scanf("%s %d %d", ord[i].move, &ord[i].start, &ord[i].end);
		if( !strcmp(ord[i].move, "replace")){
			scanf("%s", ord[i].change);
		}
	}
	
	/*printf*/
	for(i=0; i<num; i++){
		if( !strcmp(ord[i].move,"print") ){
			print(str_Org, ord[i].start, ord[i].end);
		}else if(!strcmp(ord[i].move,"reverse") ){
			reverse(str_Org, ord[i].start, ord[i].end);
		}else if(!strcmp(ord[i].move,"replace") ){
			replace(str_Org, ord[i].start, ord[i].end, ord[i].change);
		}
	}
	
	return 0;
}


/*
	for(i=0; i<num; i++){
		scanf("%s %d %d", ord[i].move, &ord[i].start, &ord[i].end, ord[i].switch);
	}
	
		printf("%s\n",str_Org);
	printf("%d\n",num);
	for(i=0; i<num; i++){
		printf("order(%d):%s %d %d %s\n", i+1,ord[i].move, &ord[i].start, &ord[i].end, ord[i].switch);
	}


*/


Measured memory_bytes: 2144
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      x.begin(),x.end()
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

#define EPS 0.0000000001

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(double,w,h,x,y);
  int judge=0;
  if((abs(x - w/2) < EPS) && (abs(y - h/2) < EPS)){
    dout(EPS);
    dout(x);
    dout(w/2);
    dout(x-w/2);
    dout(y);
    dout(h/2);
    dout(y-h/2);
    judge=1;
  }

  cout<< (w*h)/2.0 << " " << judge << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

template<class T>
void prime_factors(T n, map<T, int>&out) {
    if(n == 1) { // n=1 の素因数分解はなし
        return;
    }
    for(T i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++out[i]; // 素数i^{out[i]}
            n /= i;
        }
    }
    if(n != 1) out[n] = 1;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    ll a,b;
    cin>>a>>b;
    map<ll,int> p,q;
    map<ll,int> r;
    prime_factors(a, p);
    prime_factors(b, q);
    for(const auto&x:q){
        auto it=p.find(x.F);
        if(it==p.end())continue;
        r[x.F]=min(it->S, x.S);
    }
    int c=0;
    for(const auto&x:r){
        if(x.S>0)++c;
    }
    cout<<c+1<<endl;

}


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

int main(void) {
	double x;
	long long q;
	
	while(cin >> q) {
		if(q == -1) break;
		
		x = (double)q / 2;
		
		while(abs(x*x*x - q) > (double)q / 100000) {
			x = x - (x*x*x - q) / (3*x*x);
		}
		
		printf("%.6lf\n", x);
	}
	
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    string s;
    int q;
    cin >> s >> q;
    deque<char> u;
    for (char c : s) u.push_back(c);
    bool rev = false;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;
            f--;
            if (rev) f = (f + 1) % 2;
            if (f) u.push_back(c);
            else u.push_front(c);
        }
    }
    if (rev) {
        reverse(begin(u), end(u));
    }
    for (char c : u) {
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bitset>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;

  int a[n][m], c[n];
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int p[n];
  rep(i, n) p[i] = 0;

  vector<int> ok;

  for (int i = 0; i < (1 << n); ++i) {
    bitset<12> choise(i);
    int sum = 0;
    int score[m];
    rep(j, m) score[j] = 0;

    for (int j = 0; j < n; ++j) {
      if (choise.test(j)) {
        sum += c[j];
        rep(l, m) { score[l] += a[j][l]; }
      }
    }

    bool isOk = true;
    rep(j, m) {
      if (score[j] < x) isOk = false;
    }
    if (isOk) ok.push_back(sum);
  }

  if (ok.size() == 0) {
    cout << "-1" << '\n';
    return 0;
  }

  int ans = ok[0];
  rep(i, ok.size()) { ans = min(ans, ok[i]); }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,N,D,A;
  D=0;
  cin >> H >> N;
  for (int i = 0;i<N;i++) {
    cin >> A;
    D+=A;
  };
  if (D>=H) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000



int main(){
	
	double A,B,H,M;
	cin>>A>>B>>H>>M;
	
	double PI = acos(-1.0);
	
	double D1 = PI/2.0 - PI/360.0 * (60.0*H+M);
	double D2 = PI/2.0 - PI/30.0 * M;
	
	double X1 = cos(D1)*A,Y1 = sin(D1)*A;
	double X2 = cos(D2)*B,Y2 = sin(D2)*B;
	
	
	
	cout<<fixed<<setprecision(15)<<sqrt(pow(X1-X2,2.0)+pow(Y1-Y2,2.0))<<endl;
	
	
	
	return 0;
}



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

using namespace std;
typedef long long ll;

int main(){
	string s; cin>>s;
  int t=0;
  ll ans=0;
  vector<int> SWI(s.size(),0);
  
  for(int i=0;i<pow(2,s.size()-1);i++){
	int rem=i;
        for(int j=s.size()-2;j>=0;j--){//2^jの位をSWI[j]
            SWI[j]=rem/(int)pow(2,j);
            rem=rem%(int)pow(2,j);
        }//1つのスイッチの状態完成
    	for(int k=s.size()-1;k>=0;k--){
          char x;
          x=s[k];
          int tmp=stoi(&x);
         	ans+=tmp*(ll)pow(10,t);
          
        	if(SWI[s.size()-k-1]==0) t++;
          	else t=0;
        }
    	t=0;
	}
  
  printf("%lld",ans);
}

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

using namespace std;

long long inf=1000000007;

int main(){
	int n,x;
	cin>>n>>x;
	vector<int> box(n);
	for(int i=0;i<n;i++) cin>>box.at(i);

	long long cnt=0;

	for(int i=0;i<n-1;i++){
		if(box.at(i)+box.at(i+1)>x){
			cnt+=box.at(i)+box.at(i+1)-x;
			box.at(i+1)-=box.at(i)+box.at(i+1)-x;

			if(box.at(i+1)<0){
				box.at(i)+=box.at(i+1);
				box.at(i+1)=0;
			}
		}
	}

	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N); cin >> A;

  for (int i = 0; i < K; ++i) {
    vector<int> tmp(N + 1, 0);
    for (int j = 0; j < N; ++j) {
      int start = max(0, j - A[j]);
      int end = min(N-1, j + A[j]);
      ++tmp[start];
      --tmp[end + 1];
    }
    int sum = 0;
    bool all_max = true;
    for (int j = 0; j < N; ++j) {
      sum += tmp[j];
      A[j] = sum;
      if (A[j] < N) all_max = false;
    }
    if (all_max) break;
  }
  cout << A << endl;
}


Measured memory_bytes: 4824