akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n,z,w;
    ll a[100010];
    cin>>n>>z>>w;
    rep(i,n) cin>>a[i];
    ll dp[2010][3];
    for(ll i=n-1;i>=0;i--){
        dp[i][0]=-LLINF;
        ll x=(i ? a[i-1] : w);
        chmax(dp[i][0],abs(a[n-1]-x));
        for(ll j=i+1;j<n;j++){
            chmax(dp[i][0],dp[j][1]);
        }

        dp[i][1]=LLINF;
        ll y=(i ? a[i-1] : z);
        chmin(dp[i][1],abs(a[n-1]-y));
        for(ll j=i+1;j<n;j++){
            chmin(dp[i][1],dp[j][0]);
        }
    }
    cout<<dp[0][0]<<endl;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     

    solve(); 


    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

map<ll, ll> mp;

int main()
{
    int n;
    cin>>n;
    REP(i,n) {
        int a, b;
        cin>>a>>b;
        mp[b] += a;
    }
    ll sum = 0ll;
    bool ans = true;
    for (auto itr : mp) {
        sum += itr.second;
        if (itr.first < sum) {
            ans = false;
            break;
        }
    }
    Yes(ans);

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
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 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 long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

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

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1)*a%MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1)*a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b,a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size()>n) return kaijo_memo[n];
  if(kaijo_memo.size()==0) kaijo_memo.push_back(1);
  while(kaijo_memo.size()<=n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1]*kaijo_memo.size()%MOD);
  return kaijo_memo[n];
}

signed main(){
	VI a(3); rep(i,3) cin>>a[i];
	if((a[1]*10+a[2])%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll M, D[300000], C[300000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> M;
    for (int i = 0; i < M; ++i) {
        cin >> D[i] >> C[i];
    }
    ll dig = 0;
    ll digsum = 0;
    for (int i = 0; i < M; ++i) {
        dig += C[i];
        digsum += D[i] * C[i];
    }
    cout << (dig-1 + (digsum-1)/9) << endl;
    return 0;
}


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

class Program {
    static void Main(string[] args) {
        var num = int.Parse(Console.ReadLine());
        var numList = new List<List<int>>();
        for (var i = 0; i < num; i++) {
            var nums = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList();
            numList.Add(nums);
        }

        var result = "No";
        for (var i = 0; i < numList.Count - 2; i++) {
            if (numList[i][0] == numList[i][1] && numList[i + 1][0] == numList[i + 1][1] && numList[i + 2][0] == numList[i + 2][1]) result = "Yes";
        }
        Console.Write(result);
    }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n, time; cin >> n;
    vec<int> c(n-1), s(n-1),f(n-1); rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    vec<int> ans;

    for(int i = 0; i < n-1; ++i) {
        time = s[i];
        time += c[i];
        for(int j = i+1; j < n-1; ++j) {
            // j駅を出る時刻
            if(time < s[j]) time = s[j];
            else time = s[j] + f[j]*((time-s[j]+f[j]-1)/f[j]);  // 切り上げ除算で計算
            time += c[j];
        }
        ans.emplace_back(time);
    }

    for(auto i : ans) cout << i << '\n';
    cout << 0 << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cstdio>
using namespace std;
#define NIN(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define NINJ(i,n) for((i)=1;(i)<=(int)(n);(i)++)
#define pb push_back
#define LL long long
#define ff first
#define ss second
#define pp pair<double,double>
#define pt pair<double,pair<int,int>>

int pr[200005];

int fnd(int r)
{
    return (pr[r]==r) ? r :  pr[r]=fnd(pr[r]);
}
int main()
{
    vector<string>v;
    int n,l;
    cin>>n>>l;

    for(int i=0; i<n; i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }

    sort(begin(v),end(v));
    string d="";

    for(int i=0; i<n; i++)
        d+=v[i];
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))

MAX = pow(10, 4) * N
costs = [MAX for _ in range(N)]
costs[0] = 0

for h_i in range(N - 1):
    next_step = h_i + 1
    back_max = min(next_step, K)
    for back_index in range(back_max):
        costs[next_step] = min(abs(h[next_step] - h[next_step - back_index -1]) + costs[next_step - back_index -1 ], costs[next_step])


print(costs[N - 1])


Measured memory_bytes: 56672
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
const int N=1e5+5;
const int p=1e9+7;
#define PI acos(-1)
ll qpow(ll a,ll n){ll res=1;while(n){if(n&1)res=res*a%p;a=a*a%p;n>>=1;}return res;}
void work()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int sum=0;
    for(int i=1;i<=m;i++){
        int x;
        scanf("%d",&x);
        sum+=x;
    }
    if(sum>n){
        printf("-1\n");
    }else{
        printf("%d\n",n-sum);
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T=1;
    //scanf("%d",&T);
    //cin>>T;
    while(T--){
        work();
    }
}

Measured memory_bytes: 3788
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q), r(Q);
  REP(i, Q) {
    cin >> l[i] >> r[i];
    // 0-based
    l[i]--;
    r[i]--;
  }

  vector<int> cs(N, 0);
  FOR(i, 1, N) {
    const auto T = S.substr(i - 1, 2);
    cs[i] = cs[i - 1] + ((T == "AC") ? 1 : 0);
  }
  REP(i, Q) { cout << cs[r[i]] - cs[l[i]] << endl; }

  return 0;
}


Measured memory_bytes: 2256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int ans[51] = {0};
	int n,m,a;
	cin >> n >> m;
	m += m;
	for(int i=0;i<m;i++){
		cin >> a;
		ans[a]++;
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 256
n, k = map(int,input().split( ))
a = list(map(int, input().split( )))
lst=[0 for _ in range(2010)]#種類ごとの数
mod = 10**9+7
unit = 0
#print(n,k,*a)
"""
for i in range(n):
    lst[a[i]] += 1
    for j in range(i):
        if a[i] < a[j]:
            #print(a[i],a[j])
            unit += 1
#print(unit)
lst2 = [0 for _ in range(n)]#種類ごとに小さい種類の要素数
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            #lst2[i] += lst[a[j]] //lst2[i]=+1か?
"""

"""
新規
"""
unit = 0
multi = 0
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            unit += 1

for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            multi+=1

#print(lst[:15])
#print(lst2[:15])
ans = 0
"""
for i in range(n):
    ans += (lst[a[i]] * lst2[i] * (k-1) * k) //2
"""
ans += multi*(k-1)*k//2
    
ans += unit*k

print(ans%mod)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
  string w; cin >>w;
  int c[26]={};
  for(int i=0;i<w.size();i++){
  	c[w[i]-'a']++;
  }
  bool b=true;
  for(int i=0;i<26;i++){
  	if(c[i]%2!=0)b=false;
  }
  if(b)cout << "Yes" << endl;
  else cout << "No"<< endl;
} 

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

const int N = 10010;
const int Mod = 998244353;

void add(int &x, int y){
	x += y;
	if(x >= Mod) x -= Mod;
}

int mul(int x, int y){
	return (long long)x * y % Mod;
}

int Pow(int x, int e){
	int ret = 1;
	while(e){
		if(e & 1) ret = mul(ret, x);
		x = mul(x, x);
		e >>= 1;
	}
	return ret;
}

using namespace std;

int fac[N], rfac[N];

void init(int n){
	fac[0] = 1;
	For(i, 1, n) fac[i] = mul(fac[i - 1], i);
	rfac[n] = Pow(fac[n], Mod - 2);
	Forr(i, n, 1) rfac[i - 1] = mul(rfac[i], i);
}

char S[N], T[N];
int n, m;
int dp[N][N], f[N];

int main(){
	scanf("%s%s", S + 1, T + 1);
	int l = strlen(S + 1);
	For(i, 1, l) if(S[i] == T[i] && S[i] == '1') ++m; else if(S[i] == '1') ++n;
	
	dp[n][m] = 1;
	Forr(i, n, 0) Forr(j, m, 0){
		long long v = dp[i][j];
		if(!v) continue;
		if(i) add(dp[i - 1][j], v * i * i % Mod);
		if(j) add(dp[i][j - 1], v * i * j % Mod);
	}

	init(m + n);

	int ans = 0;
	For(i, 0, m) add(ans, mul(mul(dp[0][i], fac[i]), mul(fac[n + m], rfac[n + m - i])));
	printf("%d\n", ans % Mod);

	return 0;
}

Measured memory_bytes: 195072
string = input()
list1 = []
for i in string:
  list1.append(int(i))
  
prev = list1[0]
sum = 0
for i, char in enumerate(list1):
  if (i > 0):
    if (char == prev):
      prev = 1 if char == 0 else 0
      sum += 1
    else:
      prev = char
print(sum)

Measured memory_bytes: 3956
sum_a = 0
max_a = 0
for i in range(5):
  num = int(input())
  sum_a += num if num % 10 == 0 else ((num // 10) + 1) * 10
  if (10 - (num % 10) > max_a) and (num % 10 != 0):
    max_a = 10 - (num % 10)
print(sum_a - max_a)

Measured memory_bytes: 3060
//	C++ (Clang3.8.0)
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	
	cin >> n;
	
	cout << num[n-1];
	
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define int ll
int N,S,x,p;

deque <pi> dq;

int32_t main(){
	fast;
	
	cin>>N>>S;
	
	FOR(i,0,N-1){
		cin>>x>>p;
		dq.pb(pi(x,p));
	}
	
	deque <int> ans;
	
	while (dq.size() > 1){
		if (dq[0].f > S || dq.back().f < S) break;
		if (dq[0].s >= dq.back().s){
			dq[0].s += dq.back().s;
			ans.push_front(dq.back().f);
			dq.pop_back();
		}else{
			dq[dq.size() - 1].s += dq[0].s;
			ans.push_front(dq[0].f);
			dq.pop_front();
		}
	}
	
	if (S < dq[0].f) sort(all(dq),greater <pi> ());
		
	aFOR(i,dq) ans.push_front(i.f);
	
	int lans = 0;
	
	
	lans += abs(S - ans[0]);
	
	FOR(i,0,ans.size() - 2){
		lans += abs(ans[i+1] - ans[i]);
	}
	
	cout<<lans;
	
}



Measured memory_bytes: 2688
#![allow(non_snake_case)]

use proconio::input;

fn main() {
    input! {
        X: i32,
        N: usize,
        P: [i32; N],
    }

    for i in 0..=100 {
        // -i が含まれているか
        for s in &[-1, 1] {
            let mut ans = X + s * i;
            for &p in P.iter() {
                if ans == p {
                    ans = -1;
                    break;
                }
            }
            if ans >= 0 {
                println!("{}", ans);
                return;
            }
        }
    }
}


Measured memory_bytes: 2128
def f(i):
    global m
    if i == n:
        for j in range(n):
            for k in range(n):
                if G[j][k] == 1:
                    if s[j] == 1 and s[k] == 0:
                        return
                elif G[j][k] == 0:
                    if s[j] == 1 and s[k] == 1:
                        return
        if m < sum(s):
            m = sum(s)
        return
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 0

n = int(input())
G = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        G[i][x - 1] = y
s = [0] * n
m = 0
f(0)
print(m)

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

int main(){

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

    string s;
    cin >> s;

    rep(i,s.size()){
        if(s[a]!='-'){
            cout << "No" << endl;
            return 0;
        }
        if(s[i]-'0'>=0&&s[i]-'0'<=9) ;
        else if(i==a) ;
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数のインデックス
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)

Measured memory_bytes: 3064
S = int(input())

def even(n):
    n = n // 2
    return n

def odd(n):
    n = (3 * n) + 1
    return n

results = [S]
while True :
    if S % 2 == 0:
        S = even(S)
    else :
        S = odd(S)
    if S in results:
        results.append(S)
        break
    else :
        results.append(S)

print(len(results))
    

Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
	int n, k;
	scanf("%d%d ", &n, &k);

	for (int i = 0; i < n; i++) {
		int c = getchar();
		if (i+1 == k) c += 32;
		putchar(c);
	}
	printf("\n");
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int maX = max(a, max(b, c));
    //cout << maX << endl;
    if(maX == (sum - maX))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  unsigned long long h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  unsigned long long x = (w + 1) / 2;
  unsigned long long y = (h + 1) / 2;
  unsigned long long ans = x * y;
  x = w / 2;
  y = h / 2;
  ans += x * y;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){
  int N; cin >> N;
  vector<vector<int>> to(N);vector<vector<int>> cost(N);
  
  for(int i = 1; i < N; i++){
    int a,b,w; cin >> a >> b >> w; a--; b--;
    to[a].push_back(b); cost[a].push_back(w);
    to[b].push_back(a); cost[b].push_back(w);}
  
  vector<int> ans(N,-1); queue<int> q;
  
  ans[0] = 0;
  q.push(0); 
  
  while(!q.empty()){
    int v = q.front();
    q.pop();
    
    for(int i = 0; i < to[v].size(); i++){
      int u = to[v][i]; int x = cost[v][i];
      if( ans[u] != -1){continue;}
      ans[u] = ( ans[v] + x ) % 2;
      
      q.push(u);}}
  
  for(int i = 0; i < N; i++){
    cout << ans[i] << endl;}
  
  return 0;}
      
  


Measured memory_bytes: 11904
using System;


class MainClass
{
    public static void Main(string[] args)
    {

        int n = int.Parse(Console.ReadLine());
        int[][] m = new int[n][];
        int u, k, v;
        string[][] st = new string[n][];

        for (int i = 0; i < n; i++)
        {
            m[i] = new int[n];
            st[i] = new string[n];
        }


        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            u = int.Parse(s[0]) - 1;
            k = int.Parse(s[1]);
            int ite = 2;

            for (int j = 0; j < k; j++)
            {
                v = int.Parse(s[ite++]) - 1;
                m[u][v] = 1;
            }

        }

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                st[i][j] = m[i][j].ToString();
            }
        }
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(string.Join(" ", st[i]));
        }


    }
}

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

int A, B, C, D, E, F;

bool check(int t, int a, int b)
{
	for(int x=0;x*a<=t;++x){
		for(int y=0;x*a+y*b<=t;++y){
			if(x*a+y*b==t) return true;
		}
	}
	return false;
}

bool ok(int s, int w)
{
	if(s+w > F) return false;
	if(s*100 > E*w) return false;
	if(w % 100) return false;
	w /= 100;
	if(!check(w,A,B)) return false;
	if(!check(s,C,D)) return false;
	return true;
}

void solve()
{
    int x = 0, y = 100*A;
	for(int w = 0; w <= F; w+=100){
		for(int s = 0; s <= F; ++s){
			if(ok(s, w)){
				if(s*(x+y) > x*(s+w)){
					x = s;
					y = w;
				}
			}
		}
	}	
	cout << x+y << ' ' << x << '\n';
}

int main()
{
	cin >> A >> B >> C >> D >> E >> F;
	solve();
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
struct edge { int to; double cost; };
vector<edge> G[30];
double d[30][9];
double horse[8];
int n, m, p, a, b;
double t[8];
void init() {
	rep(i, 30) {
		G[i].clear();
	}
}
void cop() {
	rep(i, n) {
		horse[i] = t[i];
	}
}
double bfs(){
	rep(i, 30) {
		rep(j, 9) {
			d[i][j] = 1000000;
		}
	}
	d[a][0] = 0;
	rep(j, n) {
		rep(i, m) {
			int len = G[i].size();
			rep(k, len) {
				d[G[i][k].to][j + 1] = min(d[G[i][k].to][j + 1], d[i][j] + G[i][k].cost / horse[j]);
			}
		}
	}
	double res = 1000000;
	rep(j, n + 1) {
		res = min(res, d[b][j]);
	}
	return res;
}
int main() {
	while(cin >> n >> m >> p >> a >> b, n) {
		init();
		a--; b--;
		rep(i, n) {
			cin >> t[i];
		}
		sort(t, t + n);
		rep(i, p) {
			int x, y; double z; cin >> x >> y >> z; x--; y--;
			G[x].push_back({ y,z });
			G[y].push_back({ x,z });
		}
		cop();
		double mi = bfs();
		while (next_permutation(t, t + n)) {
			cop(); mi = min(mi, bfs());
		}
		if (mi == 1000000) {
			cout << "Impossible" << endl;
		}
		else {
			cout << fixed << setprecision(3) << mi << endl;
		}
	}
	return 0;
}


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

int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll>> path1;
    vector<pair<ll, ll>> path2;
    for(ll i=1; i<=M; i++){
        ll a, b;
        cin >> a >> b;
        if(a==1) path1.push_back(make_pair(b, a));
        if(b==N) path2.push_back(make_pair(a, b));
    }

    sort(path1.begin(), path1.end());
    sort(path2.begin(), path2.end());

    if(M==1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    for(ll i=0; i<path1.size(); i++){
        ll l = 0;
        ll r = path2.size()-1;
        while(r-l>=0){
            ll mid = (l+r)/2;
            if(path1.at(i).first == path2.at(mid).first){
                cout << "POSSIBLE" << endl;
                return 0;
            }
            if(path1.at(i).first < path2.at(mid).first){
                r = mid - 1;
            }
            if(path1.at(i).first > path2.at(mid).first){
                l = mid + 1;
            }
        } 
    }

    cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 3512
d={}
def s(x):
  if 100<=x<=105 or x>=2000:
    return True
  if x<100:
    return False
  if x not in d:
    d[x]=any(s(x-i) for i in range(100,106))
  return d[x]

x=int(input())
print(int(s(x)))


Measured memory_bytes: 3060
row = STDIN.gets
row = row.to_i

def check (x)
cond = false
 if(x == "m" || x == "c" || x == "x" || x == "i")
  cond = true
 end
  return (cond)
end


def to_int(x)
 num = nil
 case x
 when 'm'
  num = 1000
 when 'c'
  num = 100
 when 'x'
  num = 10
 when 'i'
  num = 1
 end
 return (num)
end

def transfer(x)
 sum = 0
 i = 0

 while(true)
  sub_num = 1 # '○'m
  if(check(x[i]))
   sum = sum + sub_num * to_int(x[i])
  else#数字２〜９が入っていたとき
   sub_num = x[i].to_i
   i = i + 1
   sum = sum + sub_num * to_int(x[i])
  end
  i = i + 1
  if(x[i] == nil)
   break
  end
 end
 return (sum)
end


def transfer_inv(x)
 str = ""
 while(true)
  if(x >= 1000)
   str = str + (x / 1000).to_s + "m"
   x = x - (x/1000) * 1000
  else
   if (x >= 100)
    str = str + (x / 100).to_s + "c"
    x = x - (x/100) * 100
   else
    if (x >= 10)
     str = str + (x / 10).to_s + "x"
     x = x - (x/10) * 10
    else
     str = str + x.to_s + "i"
     x = 0
    end
   end
  end
  if(x == 0)
   break
  end
 end
 return (str.delete("1"))
end






for i in 0...row # !> assigned but unused variable - i
 str = STDIN.gets
 str_array = str.split(" ")
 puts transfer_inv(transfer(str_array[0]) + transfer(str_array[1]))
end

Measured memory_bytes: 6116
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
#include <set>


using namespace std;
typedef long long ll;

ll ans, mx, mn, flag, sum, cnt;
int main(){
	ll n;
	cin>>n;
	set<string> st;
	while(n--){
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size();
}


Measured memory_bytes: 19104
#include <algorithm>
#include <iostream>
#include <string>

int main(int, char *[]) {
  std::string s, t;
  std::cin >> s;
  std::cin >> t;

  if (s.size() + 1 != t.size()) {
    std::cout << "No" << std::endl;
    return 0;
  }

  auto sub = t.substr(0, s.size());

  if (sub == s) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int t[5 * maxn], lazy[5 * maxn], clazy[5 * maxn];

int doit(int a, int b) {
    return a + b;
}

void propagate(int start, int end, int index) {
    t[index] = (end - start + 1) * lazy[index];
    if (start != end) {
        lazy[index << 1] = lazy[index];
        clazy[index << 1] = 1;
        clazy[index << 1 | 1] = 1;
        lazy[index << 1 | 1] = lazy[index];
    }
    lazy[index] = 0;
    clazy[index] = 0;
}

int query(int start, int end, int l, int r, int index = 1) {
    if (clazy[index] == 1)
        propagate(start, end, index);
    //Invalid range
    if (r < start or l > end)
        return 0;

    //In range
    if (l <= start and end <= r) {
        return t[index];
    }

    int mid = start + end >> 1;
    return doit(query(start, mid, l, r, index << 1), query(mid + 1, end, l, r, index << 1 | 1));
}

void rangeUpdate(int start, int end, int l, int r, int val, int index) {
    if (clazy[index] == 1)
        propagate(start, end, index);
    if (l > end or r < start)
        return;

    if (l <= start and end <= r) {
        clazy[index] = 1;
        lazy[index] = val;
        propagate(start, end, index);
        return;
    }

    int mid = start + end >> 1;
    rangeUpdate(start, mid, l, r, val, index << 1);
    rangeUpdate(mid + 1, end, l, r, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void solve() {
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;

        if (a == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            rangeUpdate(0, n - 1, s, t, x, 1);
        } else {
            int s, t;
            cin >> s >> t;

            cout << query(0, n - 1, s, t, 1) << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 9256
#include<iostream>
using namespace std;
typedef long long ll;
 
int main(){
 
 ll A,Ans;
 cin>>A;
string bstr;
cin>>bstr;
ll B=(bstr[0]-'0')*100+(bstr[2]-'0')*10+(bstr[3]-'0')*1;
Ans=A*B;
  Ans/=100;
 
 cout<<Ans;
}

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

int main()
{
    int N, a, i, flag;
    cin >> N;
    flag = 0;
    for (i = 0; i < N; i++)
    {
        cin >> a;
        if (a % 2 == 0)
        {
            if (!(a % 6 == 0 || a % 10 == 0))
            {
                flag = 1;
                break;
            }
        }
    }
    if (flag == 1)
    {
        cout << "DENIED" << endl;
    }
    else
    {
        cout << "APPROVED" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
int main(){
	std::vector<int>a;
	for (int i = 0; i < 3; ++i){
		int t;
		std::cin >> t;
		a.push_back(t);
	}
	std::sort(a.begin(), a.end());
	std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int h,a,c=0;
	cin>>h>>a;
  	while(h>0){
      h-=a;
      c++;
    }
  cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	ll n; cin >> n;
	ll x = 1;
	int ans = 0;
	while (x < n) {
		ans++; x *= 3;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, Y; cin >> N >> Y;
  int Y2 = Y / 1000;

  bool flag = false;
  int x, y, z;
  for (int i = 0; i < 20000; ++i){
    if ((Y2 - N - 9 * i) % 4 == 0 && Y2 - N - 9 * x>= 0) {
      x = i;
      y = (Y2 - N - 9 * x) / 4;
      z = N - x - y;
      if (x >=0 && y >= 0 && z >= 0){
        flag = true;
        break;
      }
    }
  }
  if(flag) cout << x << " " << y << " " << z << endl;
  else cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
  int rz,wz,c,r;
  while(cin >> rz >> wz >> c >> r,rz|wz|c|r){
    for(int i=0;;i++){
      if(rz+r*i >= c*wz){
	cout << i << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

class Main{
    static void hikaku(int a, int b){
	if(a > b)
	    System.out.println("a > b");
	else if(a < b)
	    System.out.println("a < b");
	else
	    System.out.println("a == b");
    }

    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int x = stdIn.nextInt();
	int y = stdIn.nextInt();
	hikaku(x,y);
	
    }
}

Measured memory_bytes: 17216
#include<bits/stdc++.h>
using namespace std;
 
const int N = 3e3 + 20;
long double a[N], dp[N][N];
 
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int ted = 0; ted <= i; ted++)
		{
			if (ted == 0)
			{
				dp[i][ted] = (1 - a[i]) * dp[i - 1][ted];
				continue;
			}
			dp[i][ted] = dp[i - 1][ted] * (1 - a[i]) + dp[i - 1][ted - 1] * a[i];
		}
	}
	long double maj = 0;
	for (int ted = (n + 1) / 2; ted <= n; ted++)
	{
		maj += dp[n][ted];
	}
	cout << fixed << setprecision(20) << maj;
}


Measured memory_bytes: 85608
#include <bits/stdc++.h>
using namespace std;
int solve()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ans = 0, count = 0;
  string s;
  cin >> n;
  vector<int> v(n, 0);
  vector<int> c(n, 0);

  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++)
  {
    if (v[i] > c[i])
    {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}
signed main()
{
  solve();
}

Measured memory_bytes: 256
n = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for i in range(n):
    name = input()
    if name[0] == 'M':
        m += 1
    elif name[0] == 'A':
        a += 1
    elif name[0] == 'R':
        r += 1
    elif name[0] == 'C':
        c += 1
    elif name[0] == 'H':
        h += 1

s = [m, a, r, c, h]
x = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2]
y = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3]
z = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4]

cnt = 0
for i in range(10):
    cnt += (s[x[i]] * s[y[i]] * s[z[i]])
print(cnt)

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

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int sum = 0;
    sum = accumulate(a.begin(), a.end(), 0);
    if (sum < h)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,from,to) for(int i=from;i<(int)to;++i)
#define REP(i,from,to) for(int i=from;i<=(int)to;++i)
#define ll long long
using namespace std;
static const int MAX = 10000000;
int S[MAX];
int n, q, T;
bool binary_search(int A) {
	int left, right, mid;
	left = 0;
	right = n;
	while (left < right) {
		mid = (left + right) / 2;
		if (S[mid] == A)
			return true;
		if (T > S[mid])
			left = mid + 1;
		else if (T < S[mid])
			right = mid;
	}
	return false;
}

void solve() {
	int ans;
	ans = 0;
	cin >> n;
	rep(i,0,n)
	{
		cin >> S[i];
	}
	cin >> q;
	rep(i,0,q)
	{
		cin >> T;
		if (binary_search(T))
			ans++;
	}
	cout << ans << endl;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll a;
  cin>>a;
ll ans;
  ans=a+a*a+a*a*a;
  
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[101];
	int x,y,len;
	scanf("%s",s);
	len=strlen(s);
	x=len-2;
	printf("%c%d%c\n",s[0],x,s[len-1]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int num[]=new int[w+1];
		for(int i=1;i<=w;i++){
			num[i]=i;
		}

		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String[] str=sc.next().split(",");
			int a=Integer.parseInt(str[0]);
			int b=Integer.parseInt(str[1]);
			int c=num[a];
			num[a]=num[b];
			num[b]=c;
		}

		for(int i=1;i<=w;i++){
			System.out.println(num[i]);
		}
		sc.close();
	}

}

Measured memory_bytes: 25988
#include<bits/stdc++.h>
using namespace std;
long long cnt[1003][1003];
char arr[1003][1003];
long long M=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long i,j,k,n,x,y,z,m;
    cin>>n>>m;
    for (i=0;i<n;i++)
    {
    	for (j=0;j<m;j++)
    	{
    		cin>>arr[i][j];
		}
	}
	for (i=0;i<n;i++)
	{
		if (arr[i][0]=='.')
		{
			cnt[i][0]=1;
		}
		else
		{
			break;
		}
	}
	for (i=0;i<m;i++)
	{
		if (arr[0][i]=='.')
		{
			cnt[0][i]=1;
		}
		else
		{
			break;
		}
	}	
	for (i=1;i<n;i++)
	{
		for (j=0;j<m;j++)
		{
			if (arr[i][j]=='.')
			{
				cnt[i][j]=(cnt[i-1][j]+cnt[i][j-1])%M;
			}
			else
			{
				cnt[i][j]=0;
			}
		}
	}
	cout<<cnt[n-1][m-1]<<endl;
}

Measured memory_bytes: 9088
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

a,b,h,m = map(float , input().split())
hd= h*30+m/2
md = m*6
d = abs(hd-md)
d= min(d, 360-d)
ans = (a*a+b*b-2*(a*b*(math.cos(d*math.pi/180))))
print('%.20lf'%math.sqrt(ans))


Measured memory_bytes: 62604
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll X[30], Y[30], P[30], dist[30];
long double eps = 1e-9;
ll ans[35];
ll distx[40000][30], disty[40000][30];

void init_dist() {
  rep(i, 0, N) {
    ll d = INF;
    chmin(d, abs(X[i]));
    chmin(d, abs(Y[i]));
    dist[i] = d;
  }
}

void dfs(int cur, int cnt) {
  if (cur >= N) {
    ll score = 0;
    rep(i, 0, N) { score += dist[i] * P[i]; }
    chmin(ans[cnt], score);
    return;
  }

  dfs(cur + 1, cnt);

  ll cdist[30];
  rep(i, 0, N) {
    cdist[i] = dist[i];
    chmin(dist[i], abs(Y[i] - Y[cur]));
  }
  dfs(cur + 1, cnt + 1);

  rep(i, 0, N) { dist[i] = min(cdist[i], abs(X[i] - X[cur])); }
  dfs(cur + 1, cnt + 1);

  rep(i, 0, N) {
    dist[i] = min(cdist[i], abs(X[i] - X[cur]));
    chmin(dist[i], abs(Y[i] - Y[cur]));
  }
  dfs(cur + 1, cnt + 2);

  rep(i, 0, N) { dist[i] = cdist[i]; }
}

int main() {
  //
  cin >> N;
  rep(i, 0, N) { cin >> X[i] >> Y[i] >> P[i]; }

  init_dist();
  repe(i, 0, N) { ans[i] = INF; }

  for (ll bit = 0; bit < (1 << N); ++bit) {
    rep(i, 0, N) {
      distx[bit][i] = min(abs(X[i]), abs(Y[i]));
      disty[bit][i] = min(abs(X[i]), abs(Y[i]));
    }

    rep(i, 0, N) {
      if (bit & (1 << i)) {
        rep(j, 0, N) {
          chmin(distx[bit][j], abs(X[j] - X[i]));
          chmin(disty[bit][j], abs(Y[j] - Y[i]));
        }
      }
    }
  }

  for (ll bit = 0; bit < pow(3, N) + eps; ++bit) {
    ll b = bit;
    ll xx = 0;
    ll yy = 0;
    ll digit = 1;
    ll cnt = 0;
    rep(i, 0, N) {
      if (b % 3 == 1) {
        xx += digit;
        ++cnt;
      } else if (b % 3 == 2) {
        yy += digit;
        ++cnt;
      }
      digit *= 2;
      b /= 3;
    }

    ll score = 0;
    rep(i, 0, N) { score += min(distx[xx][i], disty[yy][i]) * P[i]; }
    chmin(ans[cnt], score);
  }

  cout << ans[0] << "\n";
  repe(i, 1, N) {
    chmin(ans[i], ans[i - 1]);
    cout << ans[i] << "\n";
  }
}


Measured memory_bytes: 19408
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    auto cache = 0;
    auto s = max(x, y), t = min(x, y);
    if (a + b > c * 2) {
        cache += t * c * 2;
    } else {
        cache += (a + b) * t;
    }
    if (x > y) {
        if (a > c * 2) {
            cache += (s - t) * c * 2;
        } else {
            cache += (s - t) * a;
        }
    } else {
        if (b > c * 2) {
            cache += (s - t) * c * 2;
        } else {
            cache += (s - t) * b;
        }
    }
    cout << cache << endl;
}



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

int main() {
   int a, b, c;
   cin >> a >> b >> c;

   if (a * c <= b) {
       cout << c << endl;
   } else {
       cout << b / a << endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d){
        cout<<"Left"<<endl;
    }
    else if(a+b<c+d){
        cout<<"Right"<<endl;
    }
    else{
        cout<<"Balanced"<<endl;
    }
    return 0;
}

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

int main()
{
	int h,w,i,j,k;
	
	while(1){
	cin>>h>>w;
		if(h==0&&w==0)
			break;
		for(i=0;i<h;i++){
		k=0;
			if(0==i%2)
				for(j=0;j<w;j++,k++){
					if(0==k%2)
						cout<<"#";
					if(1==k%2)
						cout<<".";
					if(j==w-1)
						cout<<endl;
						}
			if(1==i%2)
				for(j=0;j<w;j++,k++){
					if(0==k%2)
						cout<<".";
					if(1==k%2)
						cout<<"#";
					if(j==w-1)
						cout<<endl;
						}
			if(i==h-1)
				cout<<endl;	
			}
	}
	return 0;
}

Measured memory_bytes: 1156
import numpy as np

N ,L = (int(i) for i in input().split())
hoge=[]
for i in range(N):
	hoge.append(L + i )

#print(hog)

ab = np.abs(np.array(hoge))
#print(ab)

amin = ab.argmin()
del hoge[amin]
print(sum(hoge))

Measured memory_bytes: 20512
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;

typedef unsigned long long ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

int add(int x, int y) { return ((x % MOD)  + (y % MOD)) % MOD;             }
int mul(int x, int y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;   }
int sub(int x, int y) { return add(x, -y + MOD);                           }


ll n, k, h[MAXN], dp[MAXN];

ll solve(ll x) {
   if (dp[x] != -1) return dp[x];
   if (x > n) return INF;
   if (x == n) {
      return 0;
   }

   ll cost = INF;

   for (int i = 1; i <= k && x + i <= n; ++i) {
      ll val = abs(h[x + i] - h[x]) + solve(x + i);
      cost = min(cost, val);
   }

   if(dp[x] != -1) return dp[x] = min(dp[x], cost);
   else return dp[x] = cost;
}

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

   cin >> n >> k;

   memset(dp, -1, sizeof dp);

   for (int i = 1; i <= n ;  ++i) {
      cin >> h[i];
   }

   cout << solve(1) << endl;

   return 0;
}

Measured memory_bytes: 6528
n=int(input(""))
k=1
li=list(map(int,input("").split(" ")))
if 0 in li:
    print("0")
else:
    for i in li:
        k*=int(i)
        if k>1000000000000000000:
            print("-1")
            break
    else:
        print(k)


Measured memory_bytes: 21688
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n;
 cin>>n;
 ll a[n];
 f(n)
 {
  cin>>a[i];
 }
 for(ll i=n-2;i>=0;i--)
 {
  if(a[i]>a[i+1])
  {
   a[i]--;
   if(a[i]>a[i+1])
   {
    cout<<"No"<<endl;
    return 0;
   }
  }
 }
 cout<<"Yes"<<endl;

 return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, b * d, a * d, b * c}) << endl;
}


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

using namespace std;

int A[110];

int main(void) {
	int N, M, X;
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		int x;
		cin >> x;
		A[x]++;
	}
	int cost = 0;
	int cost2 = 0;
	for (int i = X - 1; i > 0; i--) {
		if (A[i] > 0) {
			cost++;
		}
	}
	for (int i = X + 1; i <= N; i++) {
		if (A[i] > 0) {
			cost2++;
		}
	}
	cout << min(cost, cost2) << endl;
	//system("pause");
}

Measured memory_bytes: 256