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

using namespace std;

typedef long long ll;

ll A[20202], B[222][20202];
ll n, k, ans, sz = 1 << 13;

ll getmax(ll *T, ll l, ll r)
{
	ll ret = 0;
	
	for(l+=sz, r+=sz; l<=r; ){
		if(l & 1) ret = max(ret, T[l]);
		if(~r & 1) ret = max(ret, T[r]);
		l = l + 1 >> 1;
		r = r - 1 >> 1;
	}
	
	return ret;
}

ll cost(ll l, ll r)
{
	ll i, s;
	
	s = A[l] - A[r];
	
	for(i=1; i<=k; i++){
		s += getmax(B[i], l, r);
	}
	
	return s;
}

void dnc(ll s, ll e, ll l, ll r)
{
	if(s > e) return;
	
	ll m, i, v, x, t;
	
	m = s + e >> 1;
	v = -1e18; x = l;
	
	for(i=l; i<=r && i<=m; i++){
		t = cost(i, m);
		if(t > v) v = t, x = i;
	}
	
	ans = max(ans, v);
	
	dnc(s, m - 1, l, x);
	dnc(m + 1, e, x, r);
}

int main()
{
	ll i, j;
	
	scanf("%lld%lld", &n, &k);
	
	for(i=2; i<=n; i++){
		scanf("%lld", A + i);
		A[i] += A[i - 1];
	}
	
	for(i=1; i<=n; i++){
		for(j=1; j<=k; j++){
			scanf("%lld", B[j] + sz + i);
		}
	}
	
	for(i=1; i<=k; i++){	
		for(j=sz-1; j>=1; j--){
			B[i][j] = max(B[i][j << 1], B[i][j << 1 | 1]);
		}
	}
	
	dnc(1, n, 1, n);
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main(){
  int a;
  string s;
  cin >> a;
  cin >> s;
  if(a >= 3200)cout<<s<<endl;
  else cout<< "red" << endl;
  return 0;
}

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

int main(){
  int n,a,jud;
  cin >> n >> a;
  jud = n % 500;
  if(jud <= a){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;

#define ll long long
#define ull unsigned long long

int main()
{
	long n, m;
	cin >> n >> m;
	unordered_map<long, long> s;
	ll	sum = 0;
	for (long i = 0; i < n; i++)
	{
		long in;
		cin >> in;
		sum += in;
		if (s.find(sum % m) != s.end())
			s.at(sum % m)++;
		else
			s[sum % m] = 1;
	}

	ll	result = 0;

	for (auto itr = s.begin(); itr != s.end(); itr++)
		result += itr->second * (itr->second - 1) / 2;
	if (s.find(0) != s.end())
		result += s[0];

	printf("%lld", result);
	return 0;
}


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

int main(){
  int E,Y;
  cin>>E>>Y;
  if(E==0){
    if(1868<=Y && Y<=1911){
      cout<<"M"<< Y-1867 <<endl;
    }else if(1912<=Y && Y<=1925){
      cout<<"T"<<Y-1911<<endl;
    }else if(1926<=Y && Y<=1988){
      cout<< "S" <<  Y-1925 <<endl;
    }else{
      cout<<"H"<<Y-1988<<endl;
    }
  }else if(E==1){
    cout<<1867+Y<<endl;
  }else if(E==2){
    cout<<1911+Y<<endl;
  }else if(E==3){
    cout<<1925+Y<<endl;
  }else if(E==4){
    cout<<1988+Y<<endl;
  }
  return 0;
}
  



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long c;
    cin >> c;
    long long x[n], v[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> v[i];
    pair<int, long long> cw[n], cwd[n], acw[n], acwd[n];
    for (int i = 0; i < n; i++) {
        cw[i].first = cwd[i].first = acw[i].first = acwd[i].first = i;
    }
    cw[0].second = v[0] - x[0];
    cwd[0].second = v[0] - 2 * x[0];
    acw[n - 1].second = v[n - 1] - (c - x[n - 1]);
    acwd[n - 1].second = v[n - 1] - 2 * (c - x[n - 1]);
    for (int i = 1; i < n; i++) {
        cw[i].second = cw[i - 1].second + v[i] - (x[i] - x[i - 1]);
        cwd[i].second = cwd[i - 1].second + v[i] - 2 * (x[i] - x[i - 1]);
    }
    for (int i = n - 2; i >= 0; i--) {
        acw[i].second = acw[i + 1].second + v[i] - (x[i + 1] - x[i]);
        acwd[i].second = acwd[i + 1].second + v[i] - 2 * (x[i + 1] - x[i]);
    }
    // sort(cw, cw + n, [](pair<int, long long> x, pair<int, long long> y){return (x.second > y.second);});
    // sort(cwd, cwd + n, [](pair<int, long long> x, pair<int, long long> y){return (x.second > y.second);});
    // sort(acw, acw + n, [](pair<int, long long> x, pair<int, long long> y){return (x.second > y.second);});
    // sort(acwd, acwd + n, [](pair<int, long long> x, pair<int, long long> y){return (x.second > y.second);});
    long long res = 0;// = max(cw[0].second, acw[0].second);
    for (int i = 0; i < n; i++) {
        res = max(res, cw[i].second);
        res = max(res, acw[i].second);
    }
    // res = max(res, (long long) 0);
    for (int i = 1; i < n; i++) {
        cw[i].second = max(cw[i].second, cw[i - 1].second);
    }
    for (int i = n - 2; i >= 0; i--) {
        acw[i].second = max(acw[i].second, acw[i + 1].second);
    }
    // cout << res << "\n";
    // for (int i = 0; i < n; i++) {
    //     cout << acw[i].second << "\n";
    // }
    for (int i = 0; i < n - 1; i++) {
        res = max(res, cwd[i].second + acw[i + 1].second);
        // cout << i << " " << cwd[i].second << acw[i + 1].second << "\n";
    }
    for (int i = n - 1; i > 0; i--) {
        res = max(res, acwd[i].second + cw[i - 1].second);
    }
    cout << res << "\n";
    return 0;
}

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

using namespace std;

int main()
{
    int N;

    int A[N+1];

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

    sort( A, A+N);
    
    int d = 0;
    int i = N-1;
    while ( 1 ) {
        d += A[i];
        i --;
        if ( i < 0 ) break;
        d -= A[i];
        i --;
        if ( i < 0 ) break;
    }

    cout << d << endl;


    return 0;
}

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

int main(void){
    ll N;
    cin>>N;
    vector<ll> A(N+2);
    A[0]=0;
    A[N+1]=0;
    for(int i=1;i<=N;i++) cin>>A[i];
    
    vector<ll> B(N+1);
    ll sum=0;
    for(int i=1;i<=N+1;i++){
        B[i-1]=abs(A[i]-A[i-1]);
        sum+=B[i-1];
    }
    
    int ans;
    for(int i=1;i<N+1;i++){
        ans=sum;
        ans-=(B[i-1]+B[i]);
        ans+=abs(A[i+1]-A[i-1]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2816
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 200;
int a[N];

int sqr(int x) {
  return x * x;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  int ret = INF;
  for (int i = a[0]; i <= a[n - 1]; ++i) {
    int sum = 0;
    for (int k = 0; k < n; ++k) {
      sum += sqr(i - a[k]);
    }
    ret = min(ret, sum);
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ld x1, y1, x2, y2, x3, y3, x4, y4;
	rep(i, n) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 == x2 || x3 == x4) { if (x1 == x2 && x3 == x4) { cout << "YES" << endl; } else { cout << "NO" << endl; } continue; }
		ld katamuki[2];
		katamuki[0] = (y2 - y1) / (ld)(x2 - x1);
		katamuki[1] = (y4 - y3) / (ld)(x4 - x3);
		if (katamuki[0] == katamuki[1]) { cout << "YES" << endl; }
		else { cout << "NO" << endl; }
	}
	return 0;
}


Measured memory_bytes: 3192
s = input()
st = list(s)
D = []
n = int(input())
for i in range(n) : 
  B = input().split()
  a = int(B[1])
  b = int(B[2])
  if B[0] == 'print' :
   
    st[a : b+1] = ''.join(st[a:b+1])
    if st[a : b+1] not in D :     
      D.append(''.join(st[a : b+1]))
    
    
  elif B[0] == 'reverse' :
    C = st[a : b + 1]
    C.reverse()
    del st[a : b + 1]
    st[a : a] = C

  elif B[0] == 'replace' :
    del st[a : b + 1]
    st[a : a] = B[3]
    
   
    
st  = ''.join(st) 


for i in D :
  print(i)




Measured memory_bytes: 5628
#include <iostream>

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

	int n = std::max( a + b, c + d );

	int cnt = 0;
	for( int i = 0; i <= n; i++ ) {
		if( ( a < i and i <= b )  and ( c < i and i <= d ) ) {
			cnt += 1;
		}
	}

	std::cout << std::endl;
	std::cout << cnt << std::endl;
	return 0;
}



Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long>H(N);
    rep(i, N)cin >> H[i];
    sort(H.begin(), H.end(), greater<int>());
    long long ans = 0;
    for (int i = K; i < N; i++)ans += H[i];
    cout << ans;

    return 0;
}

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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


int cnt(CumulativeSum &s, int a, int b) {
    return s.getSectionSum(a, b) % 3;
}

int main() {
    string s, t;
    cin >> s >> t;

    CumulativeSum ssum(s.size()), tsum(t.size());
    rep(i, s.size()) {
        if (s[i] == 'A') ssum.set(i, 1);
        else if (s[i] == 'B') ssum.set(i, 2);
    }
    rep(i, t.size()) {
        if (t[i] == 'A') tsum.set(i, 1);
        else if (t[i] == 'B') tsum.set(i, 2);
    }
    ssum.calculate();
    tsum.calculate();

    int q;
    cin >> q;

    rep(i, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        a--;
        b--;
        c--;
        d--;

        if (cnt(ssum, a, b) == cnt(tsum, c, d)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }

    }

}


Measured memory_bytes: 4096
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

ll a; string b;
cin>>a>>b;
string c;
for(int i=0;i<b.length();i++){
if (b[i]!='.')
c.pb(b[i]);
}

ll s=stol(c);

cout<<(a*s)/100;

return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       while((s=br.readLine())!=null){
           String[] str = s.split(" ");
           int n = Integer.parseInt(str[0]);
           int x = Integer.parseInt(str[1]);
           if(n==0 && x==0) break;
           int count=0;
           for(int i=1; i<n; ++i){
               for(int j=i; j<n; ++j){
                   if(i==j) continue;
                   int num = x - (i+j);
                   if(num<1) break;
                   if(num<j) break;
                   if(i != num && j != num && num <= n) count++;
                   num = 0;
               }
           }     
       System.out.println(count);
       }
    }
}

Measured memory_bytes: 17912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string s;
	cin >> s;

	Int x, y;
	cin >> x >> y;

	Int len = s.size();
	
	//最初の→のFF
	Int cnt = 0;
	while (cnt<len && s[cnt] != 'T') {
		cnt++;
	}

	cnt++;

	vector<Int> tate;
	vector<Int> yoko;
	Int temp;
	Int flag = 1;//0: 横　1: 縦
	for (Int i = cnt; i < len; i++) {
		temp = 0;
		if (flag) {
			while (i<len && s[i] != 'T') {
				temp++;
				i++;
			}
			tate.push_back(temp);
			flag = 0;
		}
		else {
			while (i<len && s[i] != 'T') {
				temp++;
				i++;
			}
			yoko.push_back(temp);
			flag = 1;
		}
	}

	Int len_tate = tate.size();
	Int len_yoko = yoko.size();

	vector<vector<bool>> dp_tate(len_tate+1, vector<bool>(16001, false));
	vector<vector<bool>> dp_yoko(len_yoko+1, vector<bool>(16001, false));
	dp_yoko[0][8000 + cnt - 1] = true;
	dp_tate[0][8000] = true;

	//横方向dp
	for (Int i = 0; i < len_yoko; i++) {
		for (Int j = 0; j < 16001; j++) {
			if (dp_yoko[i][j] == false)continue;
			dp_yoko[i + 1][j + yoko[i]] = true;
			dp_yoko[i + 1][j - yoko[i]] = true;
		}
	}

	//縦方向dp
	for (Int i = 0; i < len_tate; i++) {
		for (Int j = 0; j < 16001; j++) {
			if (dp_tate[i][j] == false)continue;
			dp_tate[i + 1][j + tate[i]] = true;
			dp_tate[i + 1][j - tate[i]] = true;
		}
	}

	if (dp_tate[len_tate][8000 + y] && dp_yoko[len_yoko][8000 + x]) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
int n,a[N];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1,greater<int>());
	for(int i=1;i<=n;i++){
		if(i+1>a[i+1]){
			int now=i+1;
			while(a[now]==i) now++;
			if((a[i]-i)%2||(now-i-1)%2) puts("First");
			else puts("Second");
			break;
		}
	}
    return 0;
}

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

namespace AGC032
{
    class Program
    {
        static void Main(string[] args)
        {
            // input, N ,List<int> b 
            //for N -> 1 
            //各処理時点において、1 <= j <= i を満たす要素が存在するのか確認する
            //添字と要素の数が一致しているかどうか

            int N = int.Parse(Console.ReadLine());
            List<int> b = Console.ReadLine().Split().Select(int.Parse).ToList();

            if (b[0] != 1) { Console.WriteLine(-1); return; }

            int[] Res = new int[N];
            int index = 0;
            for (int i = N; i >= 1; i--)
            {
                bool isOK = false;
                for (int j = 0; j < b.Count; j++)
                {
                    //条件を満たすものが複数ある場合は、一番大きいものを選ぶ

                    if (b[j] == j + 1)
                    {
                        isOK = true;
                        index = Math.Max(index, j);
                    }
                }
                if (!isOK) { Console.WriteLine(-1); return; }

                Res[i - 1] = index + 1;
                b.RemoveAt(index);
                index = 0;
            }

            foreach (var i in Res)
            {
                Console.WriteLine(i);
            }
        }
    }
}


Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int num = Integer.parseInt(br.readLine());
            if (num < 1 || num > 100) {
                System.out.println("Err!");
                return;
            }
            int answer = num * num * num;
            System.out.println(answer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

vector<bool> revealed;

struct UnionFind {
  vector<int> parent;
  vector<int> height;

  // n要素で初期化
  UnionFind(int n) {
    for (int i = 0; i < n; i++) {
      parent.push_back(i);
      height.push_back(0);
    }
  }

  // 木の根を求める
  int find(int x) {
    if (parent.at(x) == x) {
      return x;
    } else {
      parent.at(x) = find(parent.at(x));
      return parent.at(x);
    }
  }

  // xとyの属する集合を併合
  void unite (int x, int y) {
    int p = find(x);
    int q = find(y);
    if (p == q) return;

    if (height.at(p) < height.at(q)) {
      parent.at(p) = q;
    } else {
      parent.at(q) = p;
      if (height.at(p) == height.at(q)) height.at(p)++;
    }
  }

  // xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  revealed.resize(N, false);

  UnionFind u(N);

  rep(i, M) {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X--; Y--;
    u.unite(X, Y);
  }

  int ans = 0;
  rep(i, N) {
    int p = u.find(i);
    if (revealed.at(p)) continue;
    revealed.at(p) = true;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1276
//061
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n, m;
    int a, b;
    cin >> n >> m;
    vector<int>L(n, 0);
    rep(i, m){
        cin >> a >> b;
        L[a-1] +=1;
        L[b-1] +=1;
    }
    rep(i, n) cout << L[i] << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
MOD=10**9+7
if abs(N-M)>=2:
    print(0)
    quit()
if abs(N-M)==1:
    a=1
else:
    a=2
def factorials(M):#M!までのリストｘと其の逆元のリストyを返すmod INF
    INF=int(1e9+7)
    fac=[0]*(M+1)
    finv=[0]*(M+1)
    inv=[0]*(M+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,M+1):
        fac[i]=(fac[i-1]*i)%INF
        inv[i]=INF-(inv[INF%i]*(INF//i))%INF
        finv[i]=finv[i-1]*inv[i]%INF
    return fac,finv
fac,finv=factorials(max(N,M))
print((a*fac[N]*fac[M])%MOD)


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

int main() {
  string S;
  int K;
  int64_t Q=998244353;
  cin>>S>>K;
  vector<int> p;
  int a=0,P=0,V=S.size();
  for(int i=0;i<V;i++){
    if(S.at(i)=='1'){
      a++;
      P++;
    }
    else{
      p.push_back(a);
      a=0;
    }
  }
  int N=p.size();
  K=min(K,P);
  vector<vector<vector<int64_t>>> dp(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> yr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> tr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  dp.at(0).at(0).at(0)=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      yr.at(j).at(j).at(i)=dp.at(j).at(j).at(i);
      tr.at(K-j).at(0).at(i)=dp.at(K-j).at(0).at(i);
      for(int k=j;k<K;k++){
        yr.at(k+1).at(j).at(i)=(yr.at(k).at(j).at(i)+dp.at(k+1).at(j).at(i))%Q;
        tr.at(K-j).at(k+1-j).at(i)=(tr.at(K-j).at(k-j).at(i)+dp.at(K-j).at(k+1-j).at(i))%Q;
      }
    }
    int b=p.at(i);
    for(int j=0;j<=K;j++){
      for(int k=0;k<=j;k++){
        int64_t X=0,Y=0;
        if(k-b-1>=0){
          X=tr.at(j).at(k-b-1).at(i);
        }
        if(j-P+b-1>=0){
          Y=yr.at(j-P+b-1).at(k).at(i);
        }
        dp.at(j).at(k).at(i+1)=(tr.at(j).at(k).at(i)+yr.at(j).at(k).at(i)-dp.at(j).at(k).at(i)-X-Y+3*Q)%Q;
      }
    }
  }
  int64_t Z=0;
  for(int j=0;j<=K;j++){
    for(int i=j;i<=min(K,j+a);i++){
      Z+=dp.at(i).at(j).at(N);
      Z%=Q;
    }
  }
  cout<<Z<<endl;
}



Measured memory_bytes: 85296
#include <bits/stdc++.h>
using namespace std;
#define ll	        long long
#define all(v)      (v).begin() , (v).end()
#define vi          vector <ll>
#define vii         vector <pair<ll,ll>>
#define ii          pair<int,int>
#define lp(i,a,b)	for(int i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
const ll mod=1e9+7,MAX=2e5+7;
void fast();
int main()
{
    fast();
    string s;
    cin>>s;
    lp(i,0,s.size())
        if(s[i]=='7')
            return cout<<"Yes",0;
    cout<<"No";
}

void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int A;
        int B;
        int C;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextInt();
            B = sc.nextInt();
            C = sc.nextInt();

        }
        if (A != 5 && A != 7) {
            System.out.println("NO");
            return;
        }
        if (B != 5 && B != 7) {
            System.out.println("NO");
            return;
        }
        if (C != 5 && C != 7) {
            System.out.println("NO");
            return;
        }
        if (A + B + C != 17) {
            System.out.println("NO");
            return;
        }

        System.out.println("YES");

    }

}


Measured memory_bytes: 19540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a%2 && b%2)
    cout << "Odd" << endl;
  else
    cout << "Even" << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()

    var minDividableBy2AndN = 0
    if (N.mod(2) == 0) {
        minDividableBy2AndN = N
    } else {
        minDividableBy2AndN = 2 * N
    }

    println(minDividableBy2AndN)
}

Measured memory_bytes: 31760
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    print("ABC" + str(N))
    
if __name__ == "__main__":
	main()


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

int main() {
  
  int N; cin >> N;
  
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  
  vector<long long> B(N);
  for (long long i = 0; i < N; i++) B[i] = A[i] - i;
  
  sort(B.begin(), B.end());
  
  long long b = B[N / 2];
  
  long long ans = 0;
  
  for (int i = 0; i < N; i++) {
    if (i < N / 2) ans += b - B[i];
    else ans += B[i] - b;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++ i)
#define per(i,a,b) for(int i = (a); i >= (b); -- i)
#define pb push_back
#define VI vector<int>
#define VVI vector<VI>
#define Pii pair<int,int>
#define Pll pair<ll,ll>
#define Pli pair<ll,int>
#define fi first
#define se second
#define Ppi pair<Pii,int>
#define VII vector<Pii>

using namespace std;

typedef long long ll;
typedef int (*funI_I) (int);
typedef int (*funI_II) (int, int);

constexpr int N = 4000100;

int n, a[N], R, A;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> R;
    if(n < 10) {
        A = R + 100 * (10 - n);
    } else {
        A = R;
    }
    cout << A << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int H;
int W;
int N;
int A[100000];
int B[100000];
long long res[10];
int main(){
  int i;
  int j;
  set< pair<int,int> > black;
  set< pair<int,int> > used;
  rd(H);
  rd(W);
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
    }
  }
  res[0] = (long long) (H-2) * (W-2);
  for(i=(0);i<(N);i++){
    black.insert( make_pair(A[i], B[i]) );
  }
  for(i=(0);i<(N);i++){
    int x;
    for(x=(A[i]-1);x<(A[i]+2);x++){
      int y;
      for(y=(B[i]-1);y<(B[i]+2);y++){
        int xx;
        if(x-1 < 0 || x+1 >= H || y-1 < 0 || y+1 >= W){
          continue;
        }
        if(used.count( make_pair(x,y) )){
          continue;
        }
        used.insert( make_pair(x,y) );
        j = 0;
        for(xx=(x-1);xx<(x+2);xx++){
          int yy;
          for(yy=(y-1);yy<(y+2);yy++){
            j += black.count( make_pair(xx,yy) );
          }
        }
        res[0]--;
        res[j]++;
      }
    }
  }
  for(i=(0);i<(10);i++){
    wt_L(res[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int H, W, N, A[1d5], B[1d5];
// ll res[10];
// {
//   int j;
//   set< pair<int,int> > black, used;
//   rd(H,W,N,(A--,B--)(N));
//   res[0] = (ll) (H-2) * (W-2);
//   rep(i,N) black.insert( make_pair(A[i], B[i]) );
//   rep(i,N) rep(x,A[i]-1,A[i]+2) rep(y,B[i]-1,B[i]+2){
//     if(x-1 < 0 || x+1 >= H || y-1 < 0 || y+1 >= W) continue;
//     if(used.count( make_pair(x,y) )) continue;
//     used.insert( make_pair(x,y) );
//     j = 0;
//     rep(xx, x-1, x+2) rep(yy, y-1, y+2) j += black.count( make_pair(xx,yy) );
//     res[0]--;
//     res[j]++;
//   }
//   rep(i,10) wt(res[i]);
// }


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

int main() {
  int latas_seged=1;
  int n;
  bool logikai_valtozo=true;
  vector <int> sanyiszamok;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> latas_seged;
    sanyiszamok.push_back(latas_seged);
  }
  latas_seged=1;
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      if(sanyiszamok[j]>sanyiszamok[i]){
        logikai_valtozo=false;        
      }
    }
    if(logikai_valtozo){
     latas_seged+=1; 
    }
    logikai_valtozo=true;
  }
  cout << latas_seged;
	return 0;
}


Measured memory_bytes: 3612
#include"bits/stdc++.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 << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <climits>
#include <iostream>

using namespace std;

int main(void) {
  int N, a[100], cost, mincost = INT_MAX, max = 0, min = INT_MAX;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (max < a[i])
      max = a[i];
    if (min > a[i])
      min = a[i];
  }
  for (int i = min; i <= max; i++) {
    cost = 0;
    for (int j = 0; j < N; j++) {
      cost += pow(a[j] - i, 2.0);
    }
    if (cost < mincost)
      mincost = cost;
  }
  cout << mincost << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
G = {i: [] for i in range(1, n+1)}
for _ in range(n):
    tmp = list(map(int, input().split()))
    G[tmp[0]] += tmp[2:] if tmp[1]>0 else []

adj = [[0]*(1+n) for _ in range(1+n)]
for i in range(1, n+1):
    for j in G[i]:
        adj[i][j] = 1
for i in range(1, n+1):
    print(*adj[i][1:])



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

int getnum() {
    char C; int s = 0, t = 1;
    while (!isdigit(C = getchar())) if(C=='-') t=-1;
    do {s = s * 10 + C - '0'; } while( isdigit(C = getchar()));
    return s * t;
}   

int main() {
  int N = getnum();
  int K = getnum();
  vector<int> A(200000, 0);
  int maxint = 0, minint = 2000000;
  for (int i = 0; i < N; i++) {
    int a = getnum();
    A[a]++;
    maxint = max(maxint, a);
    minint = min(minint, a);
  }
  if (maxint-minint+1<= K) printf("%d\n", 0);
  else {
//    for (int i = 0; i<=maxint;i++) printf("%d", A[i]);
//    printf("\n");
    sort(A.begin()+minint, A.begin()+maxint+1);
//    for (int i = 0; i<=maxint;i++) printf("%d", A[i]);
//    printf("\n");
    int cnt = 0, i = 1;
    while(maxint-i+1>K) {
    cnt += A[i];
    i++;
    }
    printf("%d\n", cnt);
  }
}

Measured memory_bytes: 1024
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())
#n = ip()                                     #入力整数1つ
h,w= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
x,y= (int(i) for i in input().split())
print((h-x)*(w-y))

Measured memory_bytes: 15420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	vector<int> dp(3,0);
	for(int i=0; i<n; i++)
	{	
		vector<int> v(3),new_dp(3,0);
		cin>>v[0]>>v[1]>>v[2];
		for(int i=0; i<3; i++)
			for(int j=0; j<3; j++)
				if(i!=j)
					new_dp[j] = max(new_dp[j],dp[i]+v[j]);
			
		dp = new_dp;
		//trace3(dp[0],dp[1],dp[2]);
	}
	cout<<max(dp[0],max(dp[1],dp[2]));
	return 0;
}


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

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

int main() {
  int a, b, c, x, y;
  std::cin >> a >> b >> c >> x >> y;

  if (2 * c > a + b) {
    std::cout << a * x + b * y << std::endl;
  } else {
    int total = 0;
    if (x < y) {
      total += 2 * c * x;
      if (b < 2 * c)
        total += b * (y - x);
      else
        total += 2 * c * (y - x);
    } else {
      total += 2 * c * y;
      if (a < 2 * c)
        total += a * (x - y);
      else
        total += 2 * c * (x - y);
    }
    std::cout << total << std::endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

vector<int> v;

pair<ull, ull> total(int s) {
    if(s == v.size()) return {1, 0};

    pair<ull, ull> t = {0, 0};
    ull n = 0;

    for(int i = s + 1; i <= v.size(); i++) {
        n *= 10;
        n += v[i - 1];

        pair<ull, ull> m = total(i);

        t.first += m.first;
        t.second += m.second + m.first * n;
    }

    return t;
}

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

    for_each(s.begin(), s.end(), [&](char& c){
        v.push_back(c - '0');
    });

    cout << total(0).second << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    int count;
    int i, j, k, l;
    
    while(scanf("%d", &n) != EOF){
    	count = 0;
        for (i = 0; i < 10; i++){
            for (j = 0; j < 10; j++){
                for (k = 0; k < 10; k++){
                    for (l = 0; l < 10; l++){
                        if ((i + j + k + l) == n) count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

long int dp[51][51][2501];
int main(){
    long int n, a;
    cin >> n >> a;
    long int x[n];
    rep(i, n) cin >> x[i];
    
    rep(i, n + 1)rep(k, n + 1)rep(j, 2501) dp[i][k][j] = 0;
    
    rep(i, n + 1) dp[i][0][0] = 1; 
    
    rep(i, n){
        for (int k = 0; k <= i; k++){
            for (int j = 0; j <= 2500; j++){
                if(j >= x[i]){
                    dp[i+1][k+1][j] = dp[i][k+1][j] + dp[i][k][j-x[i]];
                }else{
                    dp[i+1][k+1][j] = dp[i][k+1][j];
                }
            }   
        }
    }

    // rep(i, n + 1){
    //     rep(j, 40){
    //         cout << dp[n][i][j] << " ";
    //     }cout << endl;
    // }

    long int ans = 0;
    rep(i, n){
        ans += dp[n][i+1][(i+1)*a];
    }
    cout << ans << endl;
}


Measured memory_bytes: 51072
import math
from decimal import Decimal
A, B, H, M = map(int, input().split())
theta = abs(11/2*M - 30*H)
rad = math.radians(theta)
cos = Decimal(math.cos(rad))
ans = math.sqrt(A**2 + B**2 - 2 * A * B * cos)
print("{:.020f}".format(ans))

Measured memory_bytes: 10256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 X;
  cin >> X;
  if(X >= 30) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

#define YES printf("Yes\n")
#define NO printf("No\n")

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[105][105];
    ll h,w;
    scanf("%lld%lld",&h,&w);
    ll cnt[26]={};
    rep(i,0,h){
        scanf("%s",s[i]);
        rep(j,0,w){
            cnt[(ll)s[i][j]-97]++;
        }
    }
    
    if(h%2==0&&w%2==0){
        rep(i,0,26){
            if(cnt[i]%4!=0){
                NO;
                return 0;
            }
        }
        YES;
        return 0;
    }


    if(h*w%2==1){
        ll a=0,b=0,c=0;
        rep(i,0,26){
            if(cnt[i]%4==1){a++;}
            if(cnt[i]%4==2){b++;}
            if(cnt[i]%4==3){c++;}
        }
        
        if(a==1){
            if(c!=0){
                NO;
            }else{
                if( b <= h/2+w/2 ){
                    YES;
                }else{
                    NO;
                }
            }
        }else{
            if(c!=1){
                NO;
            }else{
                if( b-1 > h/2+w/2 ){
                    YES;
                }else{
                    NO;
                }
            }
        }
    }


    if( h*w%2==0  && (h+w)%2==1 ){
        ll a=0,b=0,c=0;
        rep(i,0,26){
            if(cnt[i]%4==1){a++;}
            if(cnt[i]%4==2){b++;}
            if(cnt[i]%4==3){c++;}
        }
        // printf("b%lld\n",b);
        if(a!=0 || c!=0){
            NO;
        }else{
            if(b > ( (h%2) ? (w/2) : (h/2) ) ){
                NO;
            }else{
                YES;
            }
            // if( b%2 == ( (h%2) ? (w/2%2) : (h/2%2) ) ){
            //     YES;
            // }else{
            //     NO;
            // }
        }
    }
    // rep(i,0,26){
    //     printf("%c%lld ",(char)i+97,cnt[i]);
    // }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int M;
  cin >> M;

  int keta = 0;
  int sum = 0;
  REP(i, M){
    int d, c;
    cin >> d >> c;
    keta += c;
    sum += d*c;
  }

  cout << keta-1+(sum-1)/9 << "\n";

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B) = listOfInt()
    val M = (A + B) / 2
    val a = Math.abs(A - M)
    val b = Math.abs(B - M)
    println(if (a == b) M else "IMPOSSIBLE")
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toLong)

Measured memory_bytes: 37824
#include<iostream>
using namespace std;
int main(){
	int a,b;
	bool first=true;

	while(cin>>a>>b,a||b){
		bool flag=true;
		if(!first)
			cout<<endl;
		else
			first=false;

		for(int i=a;i<=b;i++){
			if(i%4==0 && ((i%100!=0) ||( i%400==0)) ){
				cout<<i<<endl;
				flag=false;
			}
		}
		if(flag){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll T;
ll n;
ll a[205];
string s;
vector<ll> ve;

int main()
{
    scanf("%lld", &T);
    while(T--)
    {
        bool v = false;
        ve.clear();
        scanf("%lld", &n);
        for(ll i = 0; i < n; i++)
        {
            scanf("%lld", &a[i]);
        }
        cin>>s;
        for(ll i = n - 1; i >= 0; i--)
        {
            for(ll j = 0; j < ve.size(); j++)
            {
                a[i] = min(a[i], a[i] ^ ve[j]);
            }
            if(s[i] == '0')
            {
                if(a[i] > 0) ve.push_back(a[i]);
            }
            else if(a[i] > 0)
            {
                printf("1\n");
                v = true;
                break;
            }
        }
        if(!v) printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 3660