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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);
    ll n;
    cin >> n;
    vector<ll> h(n + 10);
    h[n + 1] = INF;
    h[0]     = 0;
    rep1(i, n) { cin >> h[i]; }

    bool flg = false;
    for (int i = n; i >= 1; i--) {
        if (h[i - 1] - h[i] > 1) {
            flg = false;
            break;
        }
        if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
        flg = true;
    }

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

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
      ios_base::sync_with_stdio(false);
       cin.tie(NULL);
	char c;
	cin>>c;
	if(c>='A' && c<='Z')
	cout<<"A";
	else if(c>='a' && c<='z')
	cout<<"a";
	return 0;
}


Measured memory_bytes: 3612
use std::io;
use std::str::FromStr;

fn main() {
    let mut it = String::new();
    io::stdin().read_line(&mut it).expect("frl");
    let mut it = it.split_whitespace().map(|n| u32::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    let ans = if a==b && c==a || a!=b && b!=c && c!=a {
        "No"
    } else {
        "Yes"
    };
    println!("{}",ans)
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime[100005];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int R,S,P;
    cin>>R>>S>>P;
    string s;
    cin>>s;
    int ans=0;
    int i=0;
    while(i<n){
        if(i<k){
            if(s[i]=='r'){
                ans+=P;
                s[i]='p';
                i++;
            }
            else if(s[i]=='p'){
                ans+=S;
                s[i]='s';
                i++;
            }
            else if(s[i]=='s'){
                ans+=R;
                s[i]='r';
                i++;
            }
        }
        else{
            if(s[i]=='r'&&s[i-k]!='p'){
                ans+=P;
                s[i]='p';
                i++;
            }
            else if(s[i]=='p'&&s[i-k]!='s'){
                ans+=S;
                s[i]='s';
                i++;
            }
            else if(s[i]=='s'&&s[i-k]!='r'){
                ans+=R;
                s[i]='r';
                i++;
            }
            else{
                s[i]='#';
                i++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	ll n, k; cin >> n >> k;
	ll x[n];
	Rep(i, n){
		cin >> x[i];
	}
	ll ans = inf;
	Rep(j, n - k + 1){
		ans = min( ans, x[j+k-1] - x[j] + min( abs(x[j]), abs(x[j+k-1]) ) );
	}
	cout << ans << endl;
}

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

int main(void) {
    string A,B;

    cin >> A >> B;

    if(A.size()==B.size()) {
        int result = 0;
        for(int i=0;i<A.size();i++) {
            if(A[i] > B[i]) {
                result = 1;
                break;
            } else if(A[i] < B[i]) {
                result = -1;
                break;
            }
        }

        if(result == 1) {
        cout << "GREATER\n";
        } else if(result == -1) {
        cout << "LESS\n";
        } else {
        cout << "EQUAL\n";
        }
    } else if(A.size() > B.size()) {
        cout << "GREATER\n";
    } else {
        cout << "LESS\n";
    }
    return 0;
}


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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
    for(int j = 0; j < m; j++) cin >> a.at(i).at(j);
  }
  
  bool ok = false;
  int ans = pow(10, 9);
  for(int bit = 0; bit < (1<<n); bit++){
    vector<int> cnt(m);
    int cans = 0;
    bool cok = true;
    for(int i = 0; i < n; i++){
      if(1 & (bit>>i)){
        cans += c.at(i);
        for(int j = 0; j < m; j++){
          cnt.at(j) += a.at(i).at(j);
        }
      }
    }
    for(int i = 0; i < m; i++){
      if(cnt.at(i) < x) cok = false;
    }
    if(cok){
      ok = true;
      ans = min(ans, cans);
    }
  }
  
  if(ok) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int a, b;
    while(cin >> a >> b)
    {
        cout << (int)log10((double)(a + b)) + 1 << endl;
    }
}


Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull B=5575777;
int K;
  
int n,m;
char a[5000];
char b[5000];
ull po[5000];
 
int main(){
  po[0]=1;
  for(int i=1;i<500;i++)po[i]=po[i-1]*B;
    
  scanf("%s %s",a,b);
  n=strlen(a);
  m=strlen(b);
  
  int ans=0;
  for(int K=1;K<=min(n,m);K++){
 
    set< ull > st;
    ull key,d;
      
    key=0,d=1;
    for(int i=0;i<n;i++){
      key+= po[ (int)a[i] ];
      if(i-K>=0){
        key-= po[ (int)a[i-K] ];
      }else d*=B;
      if(i>=K-1)st.insert(key);
    }
      
    key=0,d=1;
    for(int i=0;i<m;i++){
      key+= po[ (int)b[i] ];
      if(i-K>=0){
        key-= po[ (int)b[i-K] ];
      }else d*=B;
       
      if(i>=K-1)
        if( st.count(key)>0 )
          ans=K;
    }
      
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3420
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<list>
#include<map>
using namespace std;
int id[20005];
double dp[405][70];
int a[200005],f[200005],n,c;
double ans;
int main(){
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) id[i]=i;
	sort(a+1,a+n+1);
	f[0]=1;
	for(int i=1;i<=n;i++) f[i]=f[i-1]*i;
	for(int i=1;i<=f[n-1];i++){
		memset(dp,0,sizeof(dp));
		dp[a[n]*n][0]=1;
		for(int t=0;t<=n*c;t++){
			for(int j=t;j<=n*c;j++){
				for(int S=0;S<(1<<n-1);S++){
					if(t%n&&!((S>>(t%n-1))&1)){
						dp[min(n*c,max(j,t+a[id[t%n]]*n))][S|(1<<(t%n-1))]+=dp[j][S];
					}
				}
			}
		}
//		cout<<dp[n*c][(1<<n-1)-1]<<endl;
		ans+=dp[n*c][(1<<n-1)-1];
		next_permutation(id+1,id+n);
//		for(int t=1;t<=n-1;t++) cout<<id[t]<<' ';
//		cout<<endl;
	}
	printf("%.15lf",ans/f[n-1]/pow(c,n-1));
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n), dp(k + 1);
	for(int i = 0; i < n; ++ i) cin >> a[i];
	for(int i = 0; i <= k; ++ i) {
		for(auto x : a) {
			if(x > i) continue;
			if(!dp[i - x]) dp[i] = 1;
		}
	}
	cout << (dp[k] ? "First\n":"Second\n");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s1[10], s2[10], s3[10];
	char c1 , c2 , c3;
	scanf("%s %s %s", s1,s2,s3);
	c1=s1[0];
	putchar (toupper(c1));
	c2=s2[0];
	putchar (toupper(c2));
	c3=s3[0];
	putchar (toupper(c3));
}

Measured memory_bytes: 256
a=[]
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
N=int(input())
c = [int(input()) for _ in range(N)]
b=[[0,0,0],[0,0,0],[0,0,0]]
for val in c:
    for i in range(3):
        for j in range(3):
            if val == a[i][j]:
                b[i][j]=1
if sum(b[1])==3 or sum(b[0])==3 or sum(b[2])==3 or b[0][0]+b[1][0]+b[2][0]==3 or b[0][1]+b[1][1]+b[2][1]==3 or b[0][2]+b[1][2]+b[2][2]==3 or b[0][2]+b[1][1]+b[2][0]==3 or b[0][0]+b[1][1]+b[2][2]==3:
    print('Yes')
else:
    print('No')


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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n), a(n + 1);
	for (int i = 0; i < n; i++) cin >> v[i];
	while (k--)
	{
		for (int i = 0; i < n; i++)
		{
			a[max(0, i - v[i])]++;
			a[min(n, i + v[i] + 1)]--;
		}
		for (int i = 1; i < n; i++)//还原差分数组
		{
			a[i] += a[i - 1];
		}
		for (int i = 0; i < n; i++) v[i] = a[i];
		for (int i = 0; i < n + 1; i++) a[i] = 0;
		int flag = 0;
		for (int i = 0; i < n; i++)
		{
			if (v[i] != n)
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0) break;//特判数组是否饱和
	}
	for (int i = 0; i < n; i++)
	{
		cout << v[i] << ' ';
	}

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

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

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

    ll N, K;
    cin >> N >> K;

    cout << N - K +1 << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, ll> m;
  for (auto& e : a) {
    cin >> e;
    m[e]++;
  }

  ll s = 0;
  for (auto e : m) s += e.second * (e.second - 1) / 2;

  for (auto e : a) {
    ll d = -(m[e] * (m[e] - 1) / 2) + ((m[e] - 1) * (m[e] - 2) / 2);
    cout << s + d << '\n';
  }
  cout << flush;
}


Measured memory_bytes: 10752
#include<stdio.h>
int main(void)
{
	int a,s;
	while(scanf("%d",&a)!=EOF){
		s=a%39;
		if(s==0){
			printf("3C39\n");
		}
		else{
			printf("3C%02d\n",s);
		}
	}
	return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n)  for(int i=0;i<n;i++)

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll a;
   cin>>a;
   
   cout<<a+(a*a)+(a*a*a)<<"\n";
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define vi vector<int>

using namespace std;

ll dp[20][2][12][2][2];
int k;
vi dig;



vi get_digit(ll x) {
    vi digits;
    do {
        digits.pb(x % 10);
        x /= 10;
    } while(x);

    return digits;
}

ll solve(int idx, int restrict, int last, int good, int zeros) {
    if(idx == -1) return good;

    ll& ans = dp[idx][restrict][last][good][zeros];

    if(~ans) return ans;

    int limit = (restrict ? dig[idx] : 9);

    ans = 0;

    for(int d = 0; d <= limit; ++d) {
        if(zeros) {
            ans += solve(idx - 1, (d < dig[idx] ? 0 : restrict), d, good, zeros && (d == 0) );
        }
        //if(idx == dig.size() - 1) {
        //    ans += solve(idx - 1, (d < dig[idx] ? 0 : restrict), d, good);
        //}
        else {
            ans += solve(idx - 1, (d < dig[idx] ? 0 : restrict), d, (abs(last - d) <= 1) && good, zeros);
        }

    }
    return ans;
}

ll f(ll x) {
    dig = get_digit(x);


    memset(dp, -1, sizeof dp);

    return solve(dig.size() - 1, 1, 0, 1, 1) - 1;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin >> k;
    
    ll lo = 1, hi = 1e10, mid;

    //cout << f(23) << endl;

    while(lo < hi) {
        mid = (lo + hi) / 2;
        if(f(mid) >= k) {
            hi = mid;
        }
        else {
            lo = mid + 1;
        }
    }
    cout << lo << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <map>
using namespace std;

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

int main() {
	int a, b, c; cin >> a >> b >> c;
	int ans = 3;
	if (a == b)ans--;
	if (b == c)ans--;
	if (a == c)ans--;
	ans += ans == 0;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

void StreamLine()
{
  int n;
  int m;
  cin >> n >> m;
  vector<int> x(m);
  for (int i = 0; i < m; i++) cin >> x[i];
  sort(x.begin(), x.end());
  
  int ans=0;
  if (n < m)
  {
    vector<int> sub(m - 1);
    for (int i = 0; i < m - 1; i++)
    {
      sub[i] = x[i + 1] - x[i];
      ans = ans + sub[i];
    }
    sort(sub.begin(), sub.end(), greater<int>());

    for (int i = 0; i < n-1; i++) ans = ans - sub[i];
  }

  cout << ans << endl;
  return;
}

int main()
{
  StreamLine();
}


Measured memory_bytes: 1024
#include <complex>
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;
#define X real()
#define Y imag()
#define EPS 1e-10
typedef complex<double> P;
typedef pair<P, P> L;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > EPS) return 1;
  if(cross(b-a,c-a) < -EPS) return -1;
  if(dot(b-a,c-a) < EPS) return 2;
  if(abs(c-a) - EPS < abs(b-a)) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

double p_to_s_dist(P a, L s){
  if(dot(s.second-s.first,a-s.first) >= 0 && dot(s.first-s.second,a-s.second) >= 0){
    return abs(cross(s.first-s.second,a-s.second))/abs(s.first-s.second);
  }
  return min(abs(a-s.first), abs(a-s.second));
}

double s_to_s_dist(L a, L b){
  if(is_cross(a,b)) return 0;
  return min(min(p_to_s_dist(a.first,b),p_to_s_dist(a.second,b)),
	     min(p_to_s_dist(b.first,a),p_to_s_dist(b.second,a)));
}

int main(){
  int q;
  cin >> q;
  P points[4];
  double x, y;
  for(int i = 0; i < q; ++i){
    for(int j = 0; j < 4; ++j){
      cin >> x >> y;
      points[j] = P(x, y);
    }
    L s1 = L(points[0],points[1]), s2 = L(points[2],points[3]);
    printf("%.10lf\n", s_to_s_dist(s1,s2));
  }
  return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    if(n % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll div = 5;
    while(true){
        ans += (n / div) / 2;
        div *= 5;
        if(div >= n) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
vector<int> g[114514];
bool used[114514];
int main() {
	IOS;
	ll n, x;
	cin >> n >> x;
	ll ans = 0;
	vector<vector<ll>> v(n, vector<ll>(n));
	REP(i, n) {
		cin >> v[0][i];
		ans += v[0][i];
	}
	FOR(i, 1, n) {
		ll tmp = 0;
		REP(j, n) {
			v[i][j] = min(v[i - 1][j], v[0][(j + n - i) % n]);
			tmp += v[i][j];
		}
		ans = min(ans, tmp + x * i);
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 36352
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
     int N,K;
      string S;
      cin>>N>>S>>K;
      
      for(int i=0;i<S.size();i++){
        if(S.at(i)!=S.at(K-1)){S.at(i)='*';}}
      
      cout<<S<<endl;
      return 0;
    }

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

int main() {
	int a, b;
	for (;;) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (a > b) {
			cout << b << " " << a << endl;
		} else {
			cout << a << " " << b << endl;
		}
	}
}



Measured memory_bytes: 3080
# -*-coding:utf-8

#import fileinput
import math

def main():
    while True:
        a, b, c = input().split()

        if (b == '?'):
            break
        else:
            if (b == '+'):
                print('%d' % (int(a)+int(c)))
            elif (b == '-'):
                print('%d' % (int(a)-int(c)))
            elif (b == '*'):
                print('%d' % (int(a)*int(c)))
            elif (b == '/'):
                print('%d' % (int(a)/int(c)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7864
import math
a,b,C=map(float,input().split())
s=a*b*math.sin(math.radians(C))/2
print(s)
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
l=a+b+c
print(l)
h=s*2/a
print(h)


Measured memory_bytes: 5696
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair < int , pair < int , int > > mp;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 153456;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;
long long a[N];

const long long LIM = 6e5 + 5;
long long seg[LIM];
long long lazy[LIM];
bool push[LIM];

long long combine(long long &a, long long &b) {
    return max(a, b);
}
void propagate(long long t, long long i, long long j) {
    if (push[t]) {
        seg[t] = seg[t] + lazy[t];
        if (i != j) {
            push[t*2] = true;
            push[t*2 + 1] = true;
            lazy[t*2] = lazy[t*2] + lazy[t];
            lazy[t*2 + 1] = lazy[t*2 + 1] + lazy[t];
        }
        push[t] = false;
        lazy[t] = 0;
    }
}
void build(long long t, long long i, long long j) {
    push[t] = false;
    lazy[t] = 0;
    if (i == j) {
        seg[t] = a[i];
        return ;
    }
    long long mid = (i + j) / 2;
    build(t*2, i, mid);
    build(t*2 + 1, mid + 1, j);
    seg[t] = combine(seg[2*t], seg[2*t+1]);
}
void update(long long t, long long i, long long j, long long l, long long r, long long x) {
    propagate(t, i, j);
    if (i > r || j < l) {
        return ;
    }
    if (l <= i && j <= r) {
        lazy[t] += x;
        push[t] = true;
        propagate(t, i, j);
        return ;
    }
    long long mid = (i + j) / 2;
    update(t*2, i, mid, l, r, x);
    update(t*2 + 1, mid + 1, j, l, r, x);
    seg[t] = combine(seg[2*t], seg[2*t+1]);
}
long long query(long long t, long long i, long long j, long long l, long long r) {
    propagate(t, i, j);
    if (i > r || j < l) {
        return 0;
    }
    if (l <= i && j <= r) {
        return seg[t];
    }
    long long mid = (i + j) / 2;
    if (l <= mid) {
        if (r <= mid) {
            return query(t*2, i, mid, l, r);
        }
        else {
            long long a = query(t*2, i, mid, l, r);
            long long b = query(t*2 + 1,  mid + 1, j, l, r);
            return combine(a, b);
        }
    }
    else {
        return query(t*2 + 1,  mid + 1, j, l, r);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    int n , k , q;
    cin >> n >> k >> q;

    rep(i , 1 , n) a[i] = k;

    build(1 , 1 , n);
    while(q--) {
        int x;
        cin >> x;
        update(1 , 1 , n , 1 , x - 1 , -1);
        update(1 , 1 , n , x + 1 , n , -1);
    }

    rep(i , 1 , n) {
        int x = query(1 , 1 , n , i , i);
        string s = "";
        if(x <= 0) {
            s = "No";
        }
        else {
            s = "Yes";
        }
        cout << s << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  double v[N], ans;
  for(int i=0; i<N; i++) cin >> v[i];
  sort(v, v+N);
  for(int i=0; i<N; i++){
    if(i==0) ans = v[i];
    else ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * 0.5 ** i)) + 1) * 0.5 ** i
        - max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5 ** i
        for i in range(1, len(bin(K)) - 2 + 1))) / N)
    return


main()


Measured memory_bytes: 3060
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..220]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 200 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			for j:=mp downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
			mp:=min(mp+x,200);
		end else if x<0 then begin
			for j:=mm downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
			mm:=min(mm-x,200);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 200 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
 
int n, q;
int a[99];
string b[99] = {"kogakubu10gokan"};
 
string solve(int i, int p){
 
  if(a[i] == p) i++;
  if(p == q) return b[i];
 
  return solve(i, p+1);
 
}
 
int main(){
 
  cin >> n >> q;
 
  for(int i=0;i<n;i++) cin >> a[i] >> b[i+1];
 
  cout << solve(0, 0) << endl;
 
}

Measured memory_bytes: 1208
//abc134_b.cpp
//Sat Jul 20 20:59:16 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int cover = 2*d+1;


	cout << (n+cover-1)/cover<< endl;
//	printf("%.4f\n",ans);
}

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


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(8);
    srand(time(NULL));

	ll a;
	ld b;
	cin>>a>>b;
	ll ans = a*b;
	cout<<ans;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 3748
from collections import deque

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

neighbor_list = [[] for _ in range(N+1)]
for ab in AB:
    neighbor_list[ab[0]].append(ab[1])
    neighbor_list[ab[1]].append(ab[0])


parent_array = [-1]*(N+1)
parent_array[1] = 0
d = deque([1])
while len(d)!=0:
    v = d.popleft()
    for ch in neighbor_list[v]:
        if parent_array[ch] == -1:
            parent_array[ch] = v
            d.append(ch)

print('Yes')
for i in parent_array[2:]:
    print(i)

Measured memory_bytes: 58544
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string str[8];

bool F(int x,int y){
	return (0<=x&&x<8&&0<=y&&y<8&&str[y][x]=='1')?true:false;
}

int main() {
	while(cin>>str[0]>>str[1]>>str[2]>>str[3]>>str[4]>>str[5]>>str[6]>>str[7]){
		int x,y;
		for(y=0;y<8;y++){
			for(x=0;x<8;x++){
				if(F(x,y)){
					if(F(x+1,y)){
						if(F(x+2,y)){
							puts("C");
						}else{
							if(F(x,y+1)){
								if(F(x+1,y+1)){
									puts("A");
								}else{
									puts("G");
								}
							}else{
								puts("E");
							}
						}
					}else{
						if(F(x,y+2)){
							puts("B");
						}else if(F(x-1,y+2)){
							puts("D");
						}else{
							puts("F");
						}
					}
					goto next;
				}
			}
		}
		next:;
	}
	return 0;
}

Measured memory_bytes: 0
/*
g++ -ggdb -fsanitize=address -std=c++14 A.cpp && ./a.out <<< "3 3"
*/

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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n, m; cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}

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

int main() {
  string s; cin >> s;
  int ans = 1000;
  for (int i = 0; i < s.size() - 2; i++) {
    int n = stoi(s.substr(i, 3));
    ans = min(ans, abs(753 - n));
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    
    vector<int> hoge(m);
    for(int i=0;i<m;i++) cin>>hoge.at(i);
    sort(hoge.begin(),hoge.end());
    priority_queue<int> length;
    
    for(int i=0;i<m-1;i++){
        length.push(hoge.at(i+1)-hoge.at(i));
    }
    
    long long ans=0;
    for(int i=0;i<n-1;i++) length.pop();
    
    while(!length.empty()){
        ans+=length.top();
        length.pop();
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

template<typename T, int B>
struct segment_tree_sum {
    T arr[1 << (B+1)]; int N;

    segment_tree_sum(int n) {
        N = 1;
        while (N < n) N *= 2;

        for (int i = 0; i < 2*N-1; ++i) {
            arr[i] = (T)0;
        }
    }

    void add(int i, T v) {
        int j = i + N-1;
        arr[j] += v;
        while (j > 0) {
            j = (j-1) / 2;
            arr[j] += v;
        }
    }

    T query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return arr[k];

        int m = (l+r)/2;
        return query(a, b, 2*k+1, l, m) + query(a, b, 2*k+2, m, r);
    }
};

int N, Q;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> Q;
    segment_tree_sum<int, 17> segt(N+1);
    for (int j = 0; j < Q; ++j) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            segt.add(x, y);
        } else {
            cout << segt.query(x, y+1) << endl;
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
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...);
}

bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(ll x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(ll i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll lcm(ll a, ll b)
{
    return (a / __gcd(a, b) * b);
}
ll nPr(ll n,ll r)
{
    if(r==0)return 1;
    ll ans = 1;
    while(r--)ans*=n,n--;
    return ans;
}
ll nCr1(ll n,ll r)
{
    if(r==0)return 1;
    ll ans=r;
    ll rr=r;
    while(--rr)ans*=rr;
    return nPr(n,r)/ans;
}
ll power(ll x, ll y)
{
      ll ans=1;
      while(y--)ans*=x;
      return ans;
}
ll nCr(ll n,ll r)
{
     if(n==r ||r==0) return 1;
     if(r>n)return 0;
     if(r==1) return n;
     return nCr(n-1,r) + nCr(n-1,r-1);
}
///priority_queue<int,vector<int>,greater<int> >pq;
//###################################################\\


int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    ///freopen("ss.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int ans=0,c=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='R')c++;
            else c=0;
            ans=max(ans,c);
        }
        cout<<ans;
    }
    return 0;
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, Q; cin>>N>>Q;

    vec_int tate(N);
    vec_int yoko(N);
    int smallest_tate=N;
    int smallest_yoko=N;

    int tot=0;
    rep(h,Q){
        int a, b; cin>>a>>b;
        if(a==1){
            if(b<smallest_tate){
                int prev = smallest_tate;
                smallest_tate = b;
                tot += smallest_yoko-2;
                for(int i=smallest_tate+1; i<prev;i++){
                    tate.at(i) = smallest_yoko;
                }
            }else{
                tot += tate.at(b) -2;
            }
        }else{
            if(b<smallest_yoko){
                int prev = smallest_yoko;
                smallest_yoko = b;
                tot += smallest_tate-2;
                for(int i=smallest_yoko+1; i<prev;i++){
                    yoko.at(i) = smallest_tate;
                }
            }else{
                tot += yoko.at(b) -2;
            }
        }
    }
    cout<<(N-2)*(N-2)-tot<<endl;





    return 0;
}

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

double dist[1005];
struct circle
{
	double x,y,r;
};
const double INF = 1e12;

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

	double sx,sy,ex,ey;
	circle c;
	vector <circle> v;
	int n;

	cin >> sx >> sy >> ex >> ey;
	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> c.x >> c.y >> c.r;
		v.push_back(c);
	}

	c.x = sx;
	c.y = sy;
	c.r = 0;
	v.push_back(c);
	c.x = ex;
	c.y = ey;
	c.r = 0;
	v.push_back(c);

	fill(dist,dist+1005,INF);
	dist[n] = 0;
	priority_queue <pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> pque;
	pque.push(make_pair(dist[n],n));

	while(!pque.empty())
	{
		int now = pque.top().second;
		if(pque.top().first > dist[now])
		{
			pque.pop();
			continue;
		}
		pque.pop();

		for(int i=0;i<v.size();i++)
		{
			double d = ((v[i].x - v[now].x)*(v[i].x - v[now].x) + (v[i].y - v[now].y)*(v[i].y - v[now].y));
			double rr = v[i].r + v[now].r;
			d = sqrt(d);
			d-=rr;
			if(d<0)
			{
				d = 0;
			}
			if(dist[i] > dist[now] + d)
			{
				dist[i] = dist[now] + d;
				pque.push(make_pair(dist[i],i));
			}
		}
	}

	cout << fixed;
	cout.precision(16);

	cout << dist[n+1] << '\n';

	return 0;
}

Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll comb(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
 


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

    int N,K; cin >> N >> K;

    init_combination();
    
    for(ll k = 1; k <= K; k++) {
        ll nowr = N - K - k + 1;
        if(nowr < 0) {
            cout << 0 << endl;
            continue;
        }
        cout << comb(N - K + 1, k) * comb(K - 1, k - 1) % mod << endl;
    }
    return 0;
}



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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  ll W, H;
  cin >> W >> H;
  vector<ll> p(W), q(H);
  REP(i,W) cin >> p[i];
  REP(i,H) cin >> q[i];

  ll res = 0;
  vector<pair<ll,ll>> r;
  REP(i,W) r.push_back(make_pair(p[i], 0));
  REP(i,H) r.push_back(make_pair(q[i], 1));
  sort(r.begin(), r.end());

  int used_p = 0, used_q = 0;
  REP(i,H + W) {
    if(r[i].second == 0) {
      res += (H + 1 - used_q) * r[i].first;
      used_p++;
    }else{
      res += (W + 1 - used_p) * r[i].first;
      used_q++;
    }
  }
  cout << res << endl;
  return 0;
}



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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

string s;

bool ismonth(string x) {
  if (x[0]=='0') {
    return x[1] != '0';
  } else if (x[0]=='1') {
    return x[1]=='0' || x[1]=='1' || x[1]=='2';
  }
  return false;
}

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

  cin>>s;
  vector<string> ans;

  if (ismonth(s.substr(0,2))) {
    ans.push_back("MMYY");
  }

  if (ismonth(s.substr(2,2))) {
    ans.push_back("YYMM");
  }

  if (ans.size() == 0) out("NA");

  if (ans.size() == 1) out(ans.front());

  out("AMBIGUOUS");  

  return 0;
}


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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long n,k;
  cin>>n>>k;
  long long a[n];
  long tmp[n+1],flg[n+1];
  long long i,j,m;
  long l;
  
  flg[0]=0;
  for(i=0;i<n;i++){
    cin>>a[i];
    flg[i+1]=-1;
  }
  tmp[0]=1;
  flg[tmp[0]]=0;
  for(i=1;i<=n;i++){
    tmp[i]=a[tmp[i-1]-1];
    //cout<<i<<" "<<tmp[i]<<endl;
    
    if(i==k){
      cout<<tmp[i]<<endl;
      return 0;
    }
    if(flg[tmp[i]]==-1){
      flg[tmp[i]]=i;
      //cout<<i<<" "<<tmp[i]<<endl;
    }
    else{
      l=i-flg[tmp[i]];
      m=flg[tmp[i]];
      //cout<<i<<" "<<tmp[i]<<endl;
      break;
    }
  }
  //cout<<i<<" "<<l<<" "<<m<<endl;
  cout<<tmp[m+(k-m)%l]<<endl;
  return 0;
}    


Measured memory_bytes: 7944
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(20);
    vvc<int> c(3,vi(3));
    rep(i,3) rep(j,3) cin >> c[i][j];
    rng(i,1,3){
        int x = c[i][0]-c[0][0];
        rng(j,1,3){
            if(x+c[0][j] != c[i][j]){
                no();
                return 0;
            }
        }
    }
    yes();
    return 0;
}


Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

const std::string YES = "Yes";
const std::string NO = "No";
void solve(int N, const std::vector<int> &A, std::vector<int> &B) {
  // TODO: edit here
  map<int, int> mp;
  REP(i, N) {
    mp[A[i]]++;
    mp[B[i]]++;
  }

  for (const auto [key, val] : mp) {
    if (val > N) {
      cout << NO << endl;
      return;
    }
  }

  cout << YES << endl;
  reverse(ALL(B));

  int target = -1;
  int idx = -1;
  REP(i, N) {
    if (A[i] == B[i]) {
      target = B[i];
      idx = i;
      break;
    }
  }

  if (target != -1) {
    int l = 0, r = N - 1;
    int cnt = 0;
    REP(i, N) {
      if (B[i] == target)
        cnt++;
    }
    REP(i, cnt) {
      if (i < cnt / 2) {
        swap(B[l], B[idx + i]);
        l++;
      } else {
        swap(B[r], B[idx + i]);
        r--;
      }
    }
  }

  cout << B << endl;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    std::cin >> B[i];
  }
  solve(N, A, B);
  // failed to analyze output format
  // TODO: edit here
  return 0;
}


Measured memory_bytes: 13904
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi

Union-Find木の実装は下記サイトを参考にした。
https://note.nkmk.me/python-union-find/
"""

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


def main():
    N, M = map(int, input().split())
    Edge_lsit = []
    for i in range(M):
        A, B = map(int, input().split())
        Edge_lsit.append((min(A, B), max(A, B)))
    Edge_lsit.sort()

    uf = UnionFind(N)
    for Edge in Edge_lsit:
        uf.union(Edge[0]-1, Edge[1]-1)
    
    max_size = 0
    for i in range(N):
        max_size = max(max_size, uf.size(i))
    print(max_size)

if __name__ == "__main__":
    main()



Measured memory_bytes: 39300
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int w,h,n;
    cin>>w>>h>>n;
    int x,y,d;
    int posx=w,posy=h,posxx=0,posyy=0;
    while (n--){
        cin>>x>>y>>d;
        if (d==4){
            if (posy>y)
                posy=y;
        }
        else if (d==3){
            if (posyy<y)
                posyy=y;
        }
        else if (d==2){
             if (posx>x)
                posx=x;
        }
        else{
            if (posxx<x)
                posxx=x;
        }
    }
    if (posx>posxx&&posy>posyy)
        cout<<(posx-posxx)*(posy-posyy);
    else
        cout<<0<<endl;
    return 0;
}


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

int main() {
    int x; cin >> x;
    if (400<= x && x <=599){
        cout << 8 << endl;
    }
    else if(600<= x && x <=799){
        cout << 7 << endl;
    }
    else if(800<= x && x <=999){
        cout << 6 << endl;
    }
    else if(1000<= x && x <=1199){
        cout << 5 << endl;
    }
    else if(1200<= x && x <=1399){
        cout << 4 << endl;
    }
    else if(1400<= x && x <=1599){
        cout << 3 << endl;
    }
    else if(1600<= x && x <=1799){
        cout << 2 << endl;
    }
    else if(1800<= x && x <=1999){
        cout << 1 << endl;
    }
    
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, k, ans = 0, x;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		ans += min(x, k - x) * 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256