akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ll,N);
  IN(ll,K);
  AIN(ll, H, N);
  ll count = 0;
  REP(i,N){
    if(H.at(i) >= K)
      count++;
  }
  OUT(count);
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  int total=0;
  int ans=0;
  for(int i=0; i<n; i++) {cin >> arr[i]; total+=arr[i];}
  for(int i=0; i<n; i++) {
    if(total%(4*m)==0&&arr[i]>=(total/(4*m))) ans++;
    else if(arr[i]>(total/(4*m))) ans++;
  }
  if(ans>=m) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=10;
int n,num[N+7],Max,Sum;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&num[i]),
		Sum+=num[i],
		Max=max(Max,num[i]);
	if(Max<Sum-Max) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin >> n;
  int ans = 0;
   int s= (int)(n.length());
  for(int i = 0;i < s; i++)
  {
    int a = n[i] - '0';;
    ans += a;

  }
  if(ans % 9 == 0)
  {
    cout << "Yes" << endl;
  }
  else if(ans % 9 != 0)
  {
    cout << "No" << endl;
  }

}


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

using namespace std;

typedef long long ll;

int gcd(int a, int b){
	if(b == 0) return a;
	return gcd(b, a % b);
}

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

	int n;
	cin >> n;
	
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int g = a[0];
	rep(i, n - 1) g = gcd(g, a[i + 1]);

	cout << g << endl;
}


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

#define SEG_LEN (1 << 18)

int seg[SEG_LEN*2];//完全2分木が作れるなら要素数は2^nで,2分木の一番下・一番左の要素は2^nの番号だから2^n+2^n=2*2^nとなる.

void add(int ind,int v){
	ind += SEG_LEN;
	seg[ind] += v;
	while(true){
		ind /= 2;
		if(ind == 0)break;
		seg[ind] = seg[ind * 2] + seg[ind * 2 + 1];
	}
}

int sum(int l,int r){
	l += SEG_LEN;
	r += SEG_LEN;
	int ans = 0;
	while(l < r){
		if(l % 2 == 1){
			ans += seg[l];
			l++;
		}
		l /= 2;
		if(r % 2 == 1){
			ans += seg[r-1];
			r--;
		}
		r /= 2;
	}
	return ans;
}

int main(){
	int n,q;
	cin >> n >> q;
	for(int i = 0;i < q;i++){
		int com;
		cin >> com;
		if(com == 0){
			int ind,v;
			cin >> ind >> v;
			add(ind-1,v);
		}
		if(com == 1){
			int l,r;
			cin >> l >> r;
			cout << sum(l-1,r) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3880
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};
 
/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> l(n);
    rep(i,0,n){
        cin >> l[i];
    }
    sort(all(l));
    int ans = 0;
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
                if(l[i]+l[j]>l[k]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

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

const int Nmax=200010;

int main() {
	int A,B;
	string S;
	bool flag = true;
	cin >> A >> B >> S;
	for(int i=0;i < S.length();i++){
		if(i==A){
          if(S[i] != '-') flag = false;
        }else if(S[i] == '-') flag = false;
      	
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,bool> M;
bool OK;
int main()
{
  OK=true;
  int N;
  cin>>N;
  while(N--)
  {
    int X;
    cin>>X;
    if(M[X])
      OK=false;
    M[X]=true;
  }
  if(OK)
    puts("YES");
  else	puts("NO");
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  int N;
  cin >> N;
  int ans=0;
  REP(i,N){
    int a;
    cin >> a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s,t; cin>>s>>t;
  int cnt = 0;
  rep(i,3){
    if(s[i]==t[i]) cnt++;
  }
  cout<<cnt<<endl;




  return 0;
}


Measured memory_bytes: 256
import math
a,b,c=map(int,input().split())
rad=math.radians(c)
s=a*b*math.sin(rad)/2
print(s)
edge=math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(a+b+edge)
print(s*2/a)


Measured memory_bytes: 5708
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, W = gets_i_list
wv_list = []
N.times do
  wv_list.push gets_i_list
end
wv_list.sort!{|x,y| x[0]<=>y[0]}
INF = Float::INFINITY

# dpをhashで管理する。 {最大価値 => 容量}
# w <= 10**9, v <= 10**3 なので v をkeyにする
# w を key にすると LTE
dp = Hash.new(INF)
dp[0] = 0

wv_list.each do |w, v|
  # ループで更新した値を参照してしまうため、dupする
  dp.dup.each do |dpv, dpw|
    nw = dpw + w
    nv = dpv + v
    # 容量を超えた場合は next
    next if nw > W
    # 同じ価値で重さが軽ければ更新
    dp[nv] = nw if dp[nv] > nw
  end
end
puts dp.keys.max

# # dpをhashで管理する。 {容量 => 最大価値}
# w <= 10**9, v <= 10**3 なので w を key にすると LTE
# dp = Hash.new(0)
# dp[0] = 0
#
# wv_list.each do |w, v|
#   # ループで更新した値を参照してしまうため、dupする
#   # (計測したい処理)
#   dp.dup.each do |dpw, dpv|
#     nw = dpw + w
#     nv = dpv + v
#     # 容量を超えた場合は next
#     next if nw > W
#     # 同じ重さで価値が大きければ更新
#     dp[nw] = nv if dp[nw] < nv
#   end
# end
# puts dp.values.max


Measured memory_bytes: 80584
S = input()

tag = 'keyence'

ans = 0

if S[0:7]==tag:
    ans = 1
elif S[len(S)-7:len(S)]==tag:
    ans = 1
else:
    for j in range(1, 6):
        f_tag = tag[0:j]
        a_tag = tag[j+1:7]
        f = 1
        for k in range(len(f_tag)):
            if not S[k]==f_tag[k]:
                f = -1
        for k in range(len(a_tag)):
            if not S[len(S)-len(a_tag)+k]==a_tag[k]:
                f = -1
        if f>0:
            ans = 1

if ans>0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    vi  c(26);
    REP(i, 26) cin >> c[i];
    vvl s(d, vl(26));
    REP(i, d) REP(j, 26) cin >> s[i][j];

    vi last(26);
    ll ans = 0;
    REP(i, d) {
        ll ans2 = -LINF;
        ll ans_i = -1;
        REP(x, 26) {
            ll tmp = s[i][x];
            REP(j, 26) {
                if (x != j) tmp -= c[j] * ((i + 1) - last[j]);
            }
            if (chmax(ans2, tmp)) ans_i = x;
        }
        last[ans_i] = i + 1;
        ans += ans2;
        cout << ans_i + 1 << endl;
    }
}


Measured memory_bytes: 3708
#include<stdio.h>

int Parent(int);
int Right(int);
int Left(int);

int main(){
  int h,i,X[100001];

  scanf("%d",&h);

  for(i=0;i<h;i++){
    scanf("%d",&X[i+1]);
    
      }
  
  for(i=0;i<h;i++){
    printf("node %d: key = %d, ",i+1,X[i+1]);

    if(Parent(i+1)>=1)printf("parent key = %d, ",X[Parent(i+1)]);
    if(Left(i+1) <= h)printf("left key = %d, ",X[Left(i+1)]);
    if(Right(i+1) <= h)printf("right key = %d, ",X[Right(i+1)]);
    printf("\n");
  }
  return 0;
}

int Parent(int x){
  return x/2;
}

int Right(int y){
  return 2 * y + 1;
}

int Left(int z){
  return 2 * z ;
}
  
    



Measured memory_bytes: 2148
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i = 0;
  int count = 0;
  double x, y;
  double a[1000], b[1000], c[1000], d[1000], e[1000], f[1000];

  while((scanf("%lf%lf%lf%lf%lf%lf",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i])) != EOF){
    if((-1000 <= (a[i], b[i], c[i], d[i], e[i], f[i])) && ((a[i], b[i], c[i], d[i], e[i], f[i]) <= 1000)){
    i++;
    count++;
    }
  }

  for(i = 0; i < count; i++){
    int n;
    double ansx,ansy,unit;
    if(a[i] == b[i] == c[i] == d[i] == e[i] == f[i]){
      x = 2;
      y = -1;
    }else{
    x = ((c[i]*e[i])-(b[i]*f[i]))/((a[i]*e[i])-(b[i]*d[i]));
    y = ((a[i]*f[i])-(c[i]*d[i]))/((a[i]*e[i])-(b[i]*d[i]));
    }

    if(x == 0)
      x = copysign(0.0,1.0);

    if(y == 0)
      y = copysign(0.0,1.0);

    n = 4;
    unit = pow(10, n-1);
    ansx = (round(x*unit))/unit;
    ansy = (round(y*unit))/unit;
    printf("%.3f %.3f\n", ansx, ansy);
    x = y = ansx = ansy = 0;
  }
  

  return 0;
}

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

int main(){
  char A,B;
  cin >> A >> B;
  if(A<B) cout << '<' << endl;
  else if(A>B) cout << '>' << endl;
  else cout << '=' << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s1,s2,s3;
int main(){
    int num1=0,num2=0;
    cin>>s1;cin>>s2;
    for(int i=0;i<s1.size()+s2.size();i++){
        if(i%2) cout<<s2[num1++];
        else cout<<s1[num2++];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
// Lets go to the next level
// AIM EXP at CF *__* asap
// Hit A,B,C faster and reach Expert
// Remember you were also a novice when you started,
// hence never be rude to anyone who wants to learn something!Be calm and help everyone.
// Never open the rank list until and unless you are done with solving problems!
/*HACK ME IF YOU CAN!
░░███▒▒░░░░░░░░░░░░░░░░████
░░████▒░░░░░░░░░░░░░░░███▒█
░░██████░░░░░░░░░░░░░███▒▒▒█
░░██▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒█████▒██
░▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▓▓▓▓▓▓▒▒▒░██
▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒█
▒▒▓▓███████▓░▓▓███████▓▒▒▒▒▒▒
▒▒▓▓▓█▓▄▓█▓░░░▓▓█▓▄▓█▓▓▒▒▒▒▒▒
▒▒▓▓▓▓███▓░░░░░▓▓███▓▓▓▒▒▒▒▒▒
▒▒▒▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒
▒▒▒▒▓▓▓▓▓▒██▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
░▒▒▒▒▒▒▒▒█████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
░░▒▒▒▒▒▒█▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒
░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/

//Author: kaiyu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};

bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 2e5+ 10;

#define int long long
int32_t main() {
//#ifndef ONLINE_JUDGE
    //freopen("inp1.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
//#endif
    fio
    int n,k;
    cin >> n >> k;
    int p[n];
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    sort(p,p+n);
    int sum = 0;
    for (int j = 0; j <k ; ++j) {
        sum+=p[j];
    }
    cout << sum << endl;


    cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






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

int price[4] = { 6000, 4000, 3000, 2000 };

int main() {
    int t, n;
    for (int i=0; i<4; ++i) {
        cin >> t >> n;
        cout << price[t-1] * n << endl;
    }
    return 0;
}

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



int main(){
    ll n,d,a;cin>>n>>d>>a;
    queue<pair<ll,ll> > q;
    ll cn=0;
    vector<pair<ll,ll> > e(n);
    rep(i,0,n)cin>>e[i].first>>e[i].second;
    sort(e.begin(),e.end());
    ll dm=0;
    rep(i,0,n){
        while(q.size()&&q.front().first<e[i].first){
            dm-=q.front().second;
            q.pop();
        }
        ll nowh=e[i].second-dm;
        if(nowh>0){
            dm+=(nowh+a-1)/a*a;
            q.push(make_pair(e[i].first+2*d,(nowh+a-1)/a*a));
            cn+=(nowh+a-1)/a;
        }
        
    }
    cout<<cn<<endl;
}
    









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

bool appeared[1000010];

int main() {
  int s;
  cin >> s;
  for (int i = 0; i < 1000010; i++) appeared[i] = false;
  appeared[s] = true;
  int n = s;
  int res = 1;
  while (true) {
    int next;
    if (n % 2 == 0) {
      next = n / 2;
    } else {
      next = 3 * n + 1;
    }
    if (appeared[next]) break;
    appeared[next] = true;
    n = next;
    res += 1;
  }
  cout << res + 1 << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}







int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  ll x = min(n,b-1);

cout << (x*a)/b-a*(x/b) << endl;

}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
LL A[SIZE] ,B[SIZE];
int main(){
	int N;
	int ans=0;
	cin >> N;
	FOR(i,1,N+1){
		cin >> A[i];
	}
	FOR(i,1,N+1){
		if(A[i]==i){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   long long a, b, x; cin >> a >> b >> x;
   long long ans =  b/x;
   int k = 1;
   while(k*x <a)
   {
      ans--;
      k++;
   }
   if(!a)
      ans++;
   cout << ans << nl;



	return 0;
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') s[i] = '9';
		else s[i] = '1';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			final int infinity = 1000000000;
			int height = in.nextInt();
			int width = in.nextInt();
			int k = in.nextInt();
			char[][] s = new char[height][];
			int sr = -1;
			int sc = -1;
			for (int r = 0; r < height; r++) {
				s[r] = in.next().toCharArray();
				for (int c = 0; c < width; c++) {
					if (s[r][c] == 'S') {
						sr = r;
						sc = c;
					}
				}
			}
			int[] q = new int[2 * height * width];
			int[][] dist = new int[height][width];
			for (int[] arr : dist) {
				Arrays.fill(arr, infinity);
			}
			dist[sr][sc] = 0;
			int qt = 0;
			int qh = 0;
			q[qh++] = sr;
			q[qh++] = sc;
			int[] dr = {-1, 0, 1, 0};
			int[] dc = {0, -1, 0, 1};
			while (qt < qh) {
				int r = q[qt++];
				int c = q[qt++];
				for (int dir = 0; dir < 4; dir++) {
					int nr = r + dr[dir];
					int nc = c + dc[dir];
					if (nr < 0 || nr >= height || nc < 0 || nc >= width) {
						continue;
					}
					if (s[nr][nc] == '#') {
						continue;
					}
					if (dist[nr][nc] > 1 + dist[r][c]) {
						dist[nr][nc] = 1 + dist[r][c];
						q[qh++] = nr;
						q[qh++] = nc;
					}
				}
			}
			int ans = infinity;
			for (int r = 0; r < height; r++) {
				for (int c = 0; c < width; c++) {
					if (dist[r][c] > k) {
						continue;
					}
					int d = infinity;
					d = Math.min(d, r);
					d = Math.min(d, height - r - 1);
					d = Math.min(d, c);
					d = Math.min(d, width - c - 1);
					ans = Math.min(ans, 1 + (d + k - 1) / k);
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 37908
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

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

vector<ll>v;
vector<ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n;
        cin>>n;
        ll ans=0;
        for(ll x=1; x<=n/2; x++){
            if(x!=n-x){
                ans++;
            }
        }
        cout<<ans<<"\n";
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder {

    class Program {

        static void Main(string[] args) {

            var temp = Console.ReadLine().Split(' ');
            var A = int.Parse(temp[0]);
            var B = int.Parse(temp[1]);
            var T = int.Parse(temp[2]);

            var result = Math.Floor((T + 0.5) / A);

            Console.WriteLine(B * result);
        }
    }
}


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


int main(int argc, char const *argv[])
{
	string s; cin >> s;
	ll k; cin >> k;

	ll cnt = 0;
	for (const auto u : s) {
		if (u != '1') break;
		cnt++;
	}
	if (cnt >= k) printf("1\n");
	else printf("%c\n", s[cnt + 0]);
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(void){
    int n,i,j,k,l;
    int iNums[4][3][10];
    int b, f, r, v;
    for (i=0;i<4;i++){
        for(j=0;j<3;j++){
            for (k=0;k<10;k++){
                iNums[i][j][k]=0;
            }
        }
    }
    cin >> n;
    for (l=0;l<n;l++){
        cin >> b >> f>> r>> v;
        iNums[b-1][f-1][r-1]+=v;
    }
    for (i=0;i<4;i++){
    if (i!=0){
        cout << "####################" << endl ;
    }
        for (j=0;j<3;j++){
            for(k=0;k<10;k++){
                cout << ' ' << iNums[i][j][k];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string num;
  cin >> num;
  if(num[0] == num[1] && num[1]== num[2] || num[1]==num[2] && num[2]==num[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;

ll L[51];	// L[i]: i 層までの長さ
ll P[51]; 	// P[i]: i 層までのパッティの数

void dfsL(int depth, ll length){
	L[depth] = length;
	if (depth == 50){
		return;
	} // end if

	dfsL(depth + 1, 2LL * length + 3LL);
}

void dfsP(int depth, ll num){
	P[depth] = num;
	if (depth == 50){
		return;
	} // end if

	dfsP(depth + 1, 2LL * num + 1LL);
}

int main()
{
	memset(L, 0LL, sizeof(L));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	dfsL(0,1LL);
	dfsP(0,1LL);
	
	ll N, X; cin >> N >> X;

/*
	rep (i, N + 1){
		cerr << "i: " << setw(2) << i << " length: " << setw(16) << L[i]  << " #patti: " << setw(16) << P[i] << endl;
	} // end rep
	cerr << endl;
*/

	ll res = 0LL;
	int m = N;

	while(X > 0LL && m > 0){
		if (X == 1LL){
			break;
		}else
		if (X > 1LL && X <= L[m-1] + 1LL){
			--X;
		}else
		if (X == L[m-1] + 2LL){
			res += P[m-1] + 1LL;
			break;
		}else
		if (X > L[m-1] + 2LL && X <= 2LL * L[m-1] + 2LL){
			res += P[m-1] + 1LL;
			X -= L[m-1] + 2LL;
		}else
		if (X == 2LL * L[m-1] + 3LL){
			res += 2LL * P[m-1] + 1LL;
			break;
		} // end if
		--m;
	} // end while

	res += (int)(m == 0 && X == 1LL);

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    vector<int> C{};
    
    cin >> N;
    int C_temp;
    cin >> C_temp;
    C.push_back(C_temp);
    for (int i=1;i<N;i++) {
        cin >> C_temp;
        if (C_temp!=C[C.size()-1]) C.push_back(C_temp); // 連続数字は除去する
    }
    N = C.size();
    
//    cout << endl;
//    for (int i=0;i<N;i++) {
//        cout << C[i] << endl;
//    }
    
    int D[N] = {};
    
    int list[200001] = {};
    for (int i=0;i<=200001;i++) list[i] = -1;
    for (int i=0;i<N;i++) {
        if (list[C[N-1-i]]==-1) {
            D[N-1-i] = -1;
            list[C[N-1-i]] = N-1-i;
        }
        else {
            D[N-1-i] = list[C[N-1-i]];
            list[C[N-1-i]] = N-1-i;
        }
    }
    
//    cout << endl;
//    for (int i=0;i<N;i++) cout << D[N-1-i] << endl;
    
    long long result[N];
    result[N-1] = 1;
    result[N-2] = 1;
    
    for (int i=2;i<N;i++) { // result[N-1-i]を更新
        if (D[N-1-i]==-1) {
            result[N-1-i] = result[N-1-i+1];
        }
        else {
            result[N-1-i] = result[N-1-i+1] + result[D[N-1-i]];
            result[N-1-i] = result[N-1-i]%1000000007;
        }
    }
    
//    cout << endl;
//    for (int i=0;i<N;i++) cout << result[N-1-i] << endl;
    
    cout << result[0] << endl;
    
    
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int n;
vector<int> a, idx;
/**********************************************/

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

    cin >> n;
    a.resize(n+5);
    idx.resize(n+5);
    REP(i, n){
        cin >> a[i];
        idx[a[i]] = i;
    }
    
    LL ans = 0;
    set<int> st;
    st.insert(-1); st.insert(n);
    for(int i = 1; i <= n; i++){
        auto r = st.upper_bound(idx[i]);
        auto l = r;
        l--;
        ans += 1LL * i * (*r - idx[i]) * (idx[i] - *l);
        st.insert(idx[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 11264
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    
    while(1){
    int m = 0;
    int nMin = 0;
    int nMax = 0;
    
    scanf("%d %d %d",&m,&nMin, &nMax);
    if(m==0 && nMin == 0 && nMax == 0)break;
    
    int p[2100] = { 0 };
    
    for(int i=0;i<m;i++){
        scanf("%d",&p[i]);
    }
    
    int gap = 0;
    int gap_i = 0;
    
    for(int i=0;i<m;i++){
        for(int j=nMin-1;j<nMax;j++){
            if(p[j]-p[j+1]>=gap){
                gap = p[j]-p[j+1];
                gap_i = j+1;
            }
            }
        }
    
    cout << gap_i << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int t = 0;int min = 10;
 for(int i = 0;i<5;i++){
     int a;cin >> a;
     if(a % 10 != 0 and a% 10 < min){
         min = a % 10;
     }
     if(a % 10 != 0){
        a += 10 - (a % 10);
     }
     t += a;
 }
 t -= 10 - min;
 
 cout << t << endl;
}

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

using namespace std;
using ll = long long;

template<class T>
class SegTree{

private:

	int n;
	int m;
	int depth;
	T def;
	vector<T> data;
	function<T(T,T)> calculate;
	function<T(T,T)> update;

	T rec(int l, int r, int node, int node_l, int node_r) {
		if (node_r <= l || node_l >= r) return def;
		if (node_l >= l && node_r <= r) return data[node];
		int mid = (node_l + node_r) / 2;
		return calculate(
			rec(l, r, node * 2, node_l, mid),
			rec(l, r, node * 2 + 1, mid, node_r));
	}



public:


	SegTree(vector<T> a, T _def, function<T(T,T)> _calculate, function<T(T,T)> _update):
	def(_def), calculate(_calculate), update(_update) {
		m = a.size();
		for (n = 1; n < (int) a.size(); n *= 2, depth++);
		data.resize(n * 2, def);
		for (int i = 0; i < (int) a.size(); i++) data[i + n] = a[i];
		for (int i = n - 1; i >= 1; i--)
			data[i] = calculate(data[i * 2], data[i * 2 + 1]);
	}


	//区間取得
	T get(int l,int r){
		if(l == r)return def;
		return rec(l,r,1,0,n);
	}

	//一点更新
	void assign(int index, T val){
		index += n;
		data[index] = update(data[index], val);
		for(;index /= 2;)
			data[index] = calculate(data[index * 2],data[index * 2 + 1]);
	}


	void print() {
		cerr << "[";
		for(int i = 0; i < m; i++) {
			cerr << data[i + n] << (i != m - 1 ? "," : "]\n");
		}
	}

	T operator[] (int i){
		return data[i + n];
	}

};

/*
Constructor: O(N) 初期配列, 単位元, 演算, 更新
	演算: (v1, v2) -> calc(v1, v2)
	更新: (index, value) -> SegTree[index] := value
get(left, right): O(logN) [left, right)での区間和
assign(index, value): O(logN) 一点更新
opertor[index]: O(1)
*/


int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	SegTree<int> tree(a, 0, [](int a, int b){return __gcd(a, b);}, [](int a, int b){return b;});
	int nax = 0;
	for(int i = 0; i < n; i++) {
		tree.assign(i, 0);
		nax = max(nax, tree.get(0, n));
		tree.assign(i, a[i]);
	}
	cout << nax << endl;
}


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

int main() {
  int a[190];
  int d[33000];
  for(int i=0; i<33000; i++) d[i]=0;
  for(int i=0; i<182; i++) {
    a[i]=i*i;
    d[a[i]]=1;
  }
  int n;
  while(cin >> n && n) {
    int cnt=0;
    for(int i=0; i<182; i++) {
      if(a[i]>n) break;
      for(int j=i; j<182; j++) {
	if(a[i]+a[j]>n) break;
	for(int k=j; k<182; k++) {
	  if(a[i]+a[j]+a[k]>n) break;
	  if(n-a[i]-a[j]-a[k]<a[k]) continue;
	  if(d[n-a[i]-a[j]-a[k]]==1) cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 1288
six=[6**i for i in range(1,7)][::-1]
nine=[9**i for i in range(1,6)][::-1]
N=int(input())

ans=[]
def find(n,a):
    if n<6: ans.append(n+a)
    for s in six:
        if s<=n:
            find(n-s,a+1)
            break
    for s in nine:
        if s<=n:
            find(n-s,a+1)
            break
find(N,0)
print(min(ans))

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

int main() {
    int N;
    cin >> N;
    int n = N;
    int S = 0;
    int ans = 0;
    while(n>0){
      S += (n%10);
      n/=10;
    }
    cout << (N%S==0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N, K, S = map(int,input().split())
A = [S] * K
if N > K:
    if S < 10 ** 9:
        A.extend([S + 1] * (N - K))
    else:
        A.extend([S - 1] * (N - K))

print(A[0], end = "")
for i in range(1,N):
    print(" ", end = "")
    print(A[i], end = "")

Measured memory_bytes: 5360
# minimum power to give i damage to the enemy
import math

h,n=map(int,input().split())
ablist=[]
amax=0
for i in range(n):
    a,b=map(int,input().split())
    ablist.append([a,b])
    amax=max(a,amax)

powlist=[]
for i in range(h+amax):
    powlist.append(math.ceil((i+1)/ablist[0][0])*ablist[0][1])

for i in range(1,n):
    for j in range(h+amax):
        if j+1 <= ablist[i][0]:
            powlist[j]=min(powlist[j],ablist[i][1])
        else:
            powlist[j]=min(powlist[j],powlist[j-ablist[i][0]]+ablist[i][1])
            

print(min(powlist[h-1:]))





Measured memory_bytes: 52828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)(x.size()))

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

int m, n;
double dp[17][1 << 16];
double p[17][17];

double rec(int i, int S) {
    auto &DP = dp[i][S];
    if (DP != -1) return DP;

    double ret = 0;
    REP(k, m) {
        if (S >> k & 1) continue;
        int nextS = S | (1 << k);
        double tmp = 0, prd = 1;
        for (int l = 0; i + l < n; ++l) {
            tmp += prd * (1 - p[k][i + l]) * rec(i + l, nextS);  // i+l に負ける
            prd *= p[k][i + l];
        }
        tmp += prd;  // 全勝
        chmax(ret, tmp);
    }
    return DP = ret;
}

signed main() {
    REP(i, 17) REP(j, 1 << 16) dp[i][j] = -1;

    cin >> m >> n;
    REP(i, m) {
        REP(j, n) {
            cin >> p[i][j];
        }
    }
    cout << setprecision(20) << fixed << rec(0, 0) << endl;
}



Measured memory_bytes: 11988
def reverse_array(array):
    array = array[::-1]
    
    for i in range(len(array)):
        if i == len(array) - 1:
            print(str(array[i]), end = "")  
        else:
            print(str(array[i]) + " ", end = "") 

    print("\n", end="")       

if __name__ == "__main__":

    number = int(input())
    seq = input().split(" ")
    array = [int(a) for a in seq ]
    reverse_array(array)



Measured memory_bytes: 5624
/*
Write a program which solve a simultaneous equation:

        ax + by = c
        dx + ey = f
The program should print x and y for given a, b, c, d, e and f(-1000 &#8804; a, b, c, d, e, f &#8804; 1000). You can suppose that given equation has a unique solution.
 */

#include <iostream>
#include <cstdio>

using namespace std;

void solve(int a, int b, int c, int d, int e, int f) {
	double x = (f - (double)e*c/b) / (d - (double)e*a/b);
	double y = (c - a*x) / b;
	if (x == 0) x = 0.000;
	if (y == 0) y = 0.000;
	printf("%4.3f %4.3f\n", x, y);
}

int main() {
	int a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		solve(a,b,c,d,e,f);
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(), c.end())

int main()
{
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) == '1')
			count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

void RE(){cout<<1/0;}
void TLE(){sleep(100);}
void WA(){cout<<char(0);exit(0);}

const int N = 1e5;
int n, k, c;
string s;
char p = '?';
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k >> s;
  FOR(i, 0, n){
    if(p != s[i]) c++;
    p = s[i];
  }
  cout << n-max(1, c-k*2) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
long long dp[100010][5];
int main(){
    string s;
    cin >> s;
    for(int i = s.length(); i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == s.length()){
                dp[i][j] = (j == 3 ? 1 : 0);
            }
            else{
                dp[i][j] = dp[i+1][j] * (s[i] == '?' ? (long long)3 : (long long)1);
                if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 4352
a,b,x=map(int,input().split())
import math
if a*a*b==x:
  c=math.pi/2
elif a*a*b/2>=x:
  c=math.atan((2*x)/(a*b*b))
else:
  c=math.atan(a**3/(2*a*a*b-2*x))
d=math.degrees(c)
print(90-d)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int max(int a,int b)
{
	if(a>b)
		return a;
	else
		return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	else
		return b;
}
int main()
{
	int w,h,n,s,i,x[105],y[105],a[105];
	cin>>w>>h>>n;
	int x1=0,x2=w,y1=0,y2=h;
	for(i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>a[i];
		if(a[i]==1)
			x1=max(x1,x[i]);
		if(a[i]==2)
			x2=min(x2,x[i]);
		if(a[i]==3)
			y1=max(y1,y[i]);
		if(a[i]==4)
			y2=min(y2,y[i]);
	}
	s=(x2-x1)*(y2-y1);
	if(x2-x1<=0||y2-y1<=0)
		s=0;
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <set>

using namespace std;

bool judge(int x, int y, int z, int yen)
{
	if (10000*x+5000*y+1000*z == yen)
	{
		cout << x << " " << y << " " << z << "\n";
		return true;
	}

	return false;
}

int main(int argc, char const *argv[])
{
	int n;

	int yen;

	cin >> n >> yen;

	for (int i = 0; i <= 2000; ++i)
	{
		for (int j = 0; j <= 2000; ++j)
		{
			int k = n-i-j;
			if(k < 0) continue;
			if(judge(i,j,k,yen)) return 0;
		}
	}

	cout << -1 << " " << -1 << " " << -1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MOD = 1e9+7;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using mint = ModInt<MOD>;

struct combination {
    using mint  = ModInt<MOD>;
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inverse();
        for (int i = n; i > 0; i--) ifact[i-1] = ifact[i] * i;
    }
    mint operator() (int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    combination comb(400400);
    
    mint ans = 0;
    for (int a = A; a < H; a++) {
        mint res = comb(H-1-a+B-1, B-1);
        res *= comb(a+W-B-1, a);
        ans += res;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
    long long int K, N, tmp, min1;
    min1 = 1000000;
    cin >> K >> N;

    long long int A[N];
    memset(A, 0, N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for(int i = 0; i < N; i++) {
        if(i == N - 1) {
            tmp = 0;
            if(min1 > K - (K - (A[i] - A[tmp]))) {
                min1 = K - (K - (A[i] - A[tmp]));
            }
        } else {
            tmp = i + 1;
            if(min1 > K - (A[tmp] - A[i])) {
                min1 = K - (A[tmp] - A[i]);
            }
        }
    }

    cout << min1 << endl;
    return 0;
}


Measured memory_bytes: 1792