akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 6/16/2019, 9:01:39 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

int N;
int L[110];
int X;

int main()
{
  // init();
  cin >> N >> X;
  for (auto i = 0; i < N; i++)
  {
    cin >> L[i];
  }
  int d = 0;
  int ans = 1;
  for (auto i = 0; i < N; i++)
  {
    d += L[i];
    if (d <= X)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int a,b,ans=0;
    cin>>a>>b;

    if( a <= 5 )
    {
        ans = 0;
    }
    else if( a <= 12 )
    {
        ans = b/2;
    }
    else
        ans = b;
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, x;
	
    while (1) {
	scanf("%d %d", &n, &x);
    if (n == 0 && x == 0)
    break;
    int count = 0;
    int i, j, k;
    for (i = 1; i <= n; i++){
        for (j = i+1; j <= n; j++){
            for (k = j+1; k <= n; k++){
            if (i + j + k == x){
            count++;}
            }
        }
    }
    printf("%d\n", count);


    }



    return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    VI v(10050, 0);
    FOR(i, 1, 106)
    {
        FOR(j, 1, 106)
        {
            FOR(k, 1, 106)
            {
                ull num = i * i + j * j + k * k + i * j + i * k + j * k;
                if (num < 10050) v[num]++;
                else break;
            }
        }
    }
    FOR(i, 1, n + 1)
    {
        cout << v[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
  if(a.first != b.first) return a.first > b.first;
  else return a.second < b.second;
}
 
int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;

  if(k < n)
  cout << k*x+(n-k)*y << endl;
  else
  cout << n*x << endl;
  
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/arc103/tasks/arc103_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn solve(s: Vec<i32>) -> Option<Vec<(usize, usize)>> {
    let n = s.len();
    if s[n-1] == 1 {
        return None;
    }
    if s[0] == 0 {
        return None;
    }
    for i in 0..n-1 {
        if s[i] != s[n-2-i] {
            return None;
        }
    }

    let mut edges = vec![];


    let mut last_one = 0;
    for v in 1..n-1 {
        if s[v] == 1 {
            let cnt = v - last_one;
            for w in last_one..v {
                edges.push((w, v));
            }
            last_one = v;
        }
    }
    assert_eq!(last_one, n-2);
    edges.push((last_one, n-1));
    assert_eq!(edges.len(), n-1);

    Some(edges)
}

fn main() {
    input! {
        s: chars
    };
    let s = s.into_iter().map(|c| ifv!(c == '0', 0, 1)).collect::<Vec<_>>();
    let edges = solve(s);
    match edges {
        Some(e) => {
            for (u, v) in e {
                println!("{} {}", u+1, v+1);
            }
        },
        None => {
            println!("-1");
        }
    }
}


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

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

using namespace std;

const int64_t INF=INT64_C(100000000000000);

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n)break;
    int64_t dl[200][200];
    int64_t ds[200][200];
    REP(i,200)REP(j,200){
      dl[i][j] = INF;
      ds[i][j] = INF;
    }
    REP(i,200)
      dl[i][i]=ds[i][i]=0;
    REP(i,m){
      int64_t x,y,t;
      string s;
      cin>>x>>y>>t>>s;
      --x;--y;
      if(s=="L")
        dl[x][y]=dl[y][x]=min(dl[x][y],t);
      else
        ds[x][y]=ds[y][x]=min(ds[x][y],t);
    }
    REP(k,200)REP(i,200)REP(j,200){
      dl[i][j]=min(dl[i][j],dl[i][k]+dl[k][j]);
      ds[i][j]=min(ds[i][j],ds[i][k]+ds[k][j]);
    }
    int64_t r;
    cin>>r;
    vector<int64_t> twn(r);
    REP(i,r){
      int64_t z;
      cin>>z;
      --z;
      twn[i]=z;
    }
    int64_t dp[1001][200];
    REP(i,1001)REP(j,200)dp[i][j]=INF;
    dp[0][twn[0]] = 0;
    REP(i,r-1){
      REP(j,n)
        dp[i+1][j]=min(dp[i+1][j],dl[twn[i]][twn[i+1]]+dp[i][j]);
      REP(j,n)REP(k,n){
        dp[i+1][k]=min(dp[i+1][k],dl[twn[i]][j]+ds[j][k]+dl[k][twn[i+1]]+dp[i][j]);
      }
    }
    cout<<*min_element(begin(dp[r-1]),end(dp[r-1]))<<endl;
  }
  return 0;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  // KがAより小さい
  if(K <= A){
      cout << K;
  }
  // KがBの途中まで
  else if(K <= A + B){
      cout << A;
  }
  // KがCの途中まで
  else{
      cout << A - (K - A - B); 
  }

}

Measured memory_bytes: 3568
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

double dp[301][301][301];


double fun(int& n, int x, int y, int z)
{
    //Base case
    if(x==0 && y==0 && z==0)
    return 0;
    if(x<0 || y<0 || z<0)
    return 0;

    //Lookup
    if(dp[x][y][z] > -0.9)
    return dp[x][y][z];

    //Rec case
    double ans = n + (x*fun(n,x-1,y,z)) + (y*fun(n,x+1,y-1,z)) + (z*fun(n,x,y+1,z-1));
    return dp[x][y][z] = ans/(x+y+z);
}

int main()
{
    memset(dp,-1,sizeof(dp));
    int n,j;
    cin>>n;

    int o=0,tw=0,th=0;

    for(int i=0;i<n;i++)
    {
        cin>>j;
        if(j == 1)
        o++;
        else if(j == 2)
        tw++;
        else
        th++;
    }
    cout<<sp(10)<<fun(n,o,tw,th)<<endl;

    return 0;
}

Measured memory_bytes: 213376
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int inf = (1e18)+7;
const int neginf = -1*((int)1e18 ) + 7 ;
const int mod = (int)1e9 + 7;
const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/

int32_t main() 
{
fastio
  
  int n;
  cin>>n;
    
    int arr[n];
    fo(i,n)
        cin>>arr[i];
    sort(arr,arr+n);
    int ct = 0;
    int sum = 0;
    //int ct = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            sum = arr[i]+arr[j];
            int x = lower_bound(arr,arr+n,sum)-arr;
            x--;
            ct+= x-j;
            
        }
    }
    cout<<ct;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> s;
  rep(i,0,s.sz)d[i] = s[i] - '0';
  rep(i,0,2){
    rep(j,0,2){
      rep(k,0,2){
        l = d[0];
        s = d[0] + '0';
        //
        if(i % 2){
          s += "+";
          l += d[1];
          s += d[1] + '0';
        }else{
          s += "-";
          l -= d[1];
          s += d[1] + '0';
        }
        //
        if(j % 2){
          s += "+";
          l += d[2];
          s += d[2] + '0';
        }else{
          s += "-";
          l -= d[2];
          s += d[2] + '0';
        }
        //
        if(k % 2){
          s += "+";
          l += d[3];
          s += d[3] + '0';
        }else{
          s += "-";
          l -= d[3];
          s += d[3] + '0';
        }
        if(l == 7){
          s += "=7";
          print(s);
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

void dfs(vvdef& tree, vdef& ans, int papaID, int stop = -1)
{
	for (int i : tree[papaID])
	{
		if (i == stop) continue;
		ans[i] += ans[papaID];
		dfs(tree, ans, i, papaID);
	}
}

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

	vvdef tree(n);
	for (int i = 0; i < n - 1; ++i)
	{
		int papa, child;
		cin >> papa >> child;
		--papa;
		--child;
		tree[papa].emplace_back(child);
		tree[child].emplace_back(papa);
	}

	vdef ans(n, 0);
	for (int i = 0; i < q; ++i)
	{
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}

	dfs(tree, ans, 0);

	for (int i : ans)
	{
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 29696
A=int(input())
B=int(input())
C=int(input())
X=int(input())

l=0
for a in range(A+1):
    ax = X - a*500
    for b in range(B+1):
        bx =ax - b*100
        for c in range(C+1):
            if bx - c*50 == 0:
                l+=1
print(l)


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	if A == B {
		fmt.Println(A + B)
	} else if A > B {
		fmt.Println(A + A - 1)
	} else {
		fmt.Println(B + B - 1)
	}
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=0;i--)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<endl
#define DO(x, y) cout<<x<<" "<<y<<endl
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<<endl
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)



int main(void)
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int i, j;
    string s;
    SI(s);
    string temp = "";
    string prev = "";
    int ans = 0;
    F(i, 0, s.length())
    {
        temp += s[i];
        if(temp != prev)
        {
            ++ans;
            prev = temp;
            temp = "";
        }
    }
    SO(ans);
    
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func isPrime(x int) bool {
	if x == 2 {
		return true
	}
	if x < 2 || x%2 == 0 {
		return false
	}

	var i = 3.0
	for i <= math.Sqrt(float64(x)) {
		if x%int(i) == 0 {
			return false
		}
		i += 2
	}
	return true
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n, count int
	if sc.Scan() {
		n, _ = strconv.Atoi(strings.TrimSpace(sc.Text()))
	}
	for i := 0; i < n; i++ {
		sc.Scan()
		stdIn, _ := strconv.Atoi(strings.TrimSpace(sc.Text()))
		if isPrime(stdIn) {
			count++
		}
	}

	fmt.Println(count)
}



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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 55, mod = 1e9 + 7;

int n, m;
int w[N];
LL f[N][N][N * N];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> w[i];

    f[0][0][0] = 1LL;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= i; j++)
            for(int k = 0; k <= 2500; k++)
            {
                f[i][j][k] += f[i - 1][j][k];
                if(j > 0 && k >= w[i]) f[i][j][k] += f[i - 1][j - 1][k - w[i]];
            }

    LL res = 0;
    for(int i = 1; i <= n; i++) res += f[n][i][m * i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 65792
/* ex 9_2
   unomi */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;  // 要素を代入
    new->next = *first;  // 新しいノードの指す先にfirstの値を代入
    *first = new;  // firstを新しいノードに設定
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) return 2;  
    elem = tmp->elem;  //要素を取り出し
    *first = tmp->next;  // firstを手前に
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    char input[10*10*10*10*10], trash;
    int i=1, cnt=0;

    //最初のノードの指す先を設定
    node *first = NULL;

    // 入力の取得
    scanf("%s",input);

    // 最初の箱をスタックにpush
    push(&first, input[0]);

    // inputを先頭から確認
    while(input[i] != '\0'){
        // input[i]がfirstの色と違うならpop
        if(first != NULL && first->elem != input[i]){
            trash = pop(&first);
            cnt+=2; // 消せる箱の数をカウント
        }
        // スタックに何も入っていないか、input[i]がfirstの色と同じならpush
        else push(&first, input[i]);
        i++;
    }

    // 結果を表示    
    printf("%d\n",cnt);

    return 0;
}



Measured memory_bytes: 4880
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool ends_with(const string& str, const string& suffix) {
  return str.size() >= suffix.size() &&
         str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
}

bool helper(string s) {
  for (;;) {
    if (s.empty())
      return true;

    if (ends_with(s, "dreamer")) {
      s = s.substr(0, s.size() - 7);
    } else if (ends_with(s, "dream")) {
      s = s.substr(0, s.size() - 5);
    } else if (ends_with(s, "eraser")) {
      s = s.substr(0, s.size() - 6);
    } else if (ends_with(s, "erase")) {
      s = s.substr(0, s.size() - 5);
    } else {
      break;
    }
  }

  return false;
}

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

  cout << (helper(s) ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

vector<int> prime;
bool is_prime[300010 + 1];

int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++) {
		if (i % 7 == 1 || i % 7 == 6)is_prime[i] = 1;
	}
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = 0;
		}
	}
	return p;
}

int n;

int main() {
	sieve(300010);
	while (cin >> n&&n != 1) {
		cout << n << ":";
		rep(i, prime.size()) {
			if (n%prime[i] == 0)cout << " " << prime[i] ;
		}
		cout << endl;
	}
}



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

int main(void) {
	using namespace std;
	long long Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	if(N % 2 == 0) {
		cout << min(min(4 * Q * N, 2 * H * N), min(S * N, D * N / 2)) << '\n';
	} else {
		long long one = min(min(4 * Q, 2 * H), S);
		cout << min(min(4 * Q * N, 2 * H * N), min(S * N, D * (N - 1) / 2 + one)) << '\n';
	}
	return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    auto tax = [](auto money, auto rate) { return money * rate / 100; };

    // A, B <= 100
    // x * 8% = 100
    // <=> x = 1250 is max
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 1250; i++) {
        int eight = tax(i, 8);
        int ten = tax(i, 10);
        if (a == eight && b == ten) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
typedef long long ll;
using namespace std;
typedef vector<int> vi;
int a,b,d;
typedef pair<int,int> pii;
typedef vector<vector<int> > Matrix;
const int inf=1e9;
ll ansx=inf;
ll ansy=inf;
ll xplusy=inf;
ll xtimesy=1e13;
void solve(int a,int b, int d)
{
  for(int i=0;i<=100000;i++)
    {
      ll x,y;
      x=i;
      if((a*i-d)%b==0)
	{
	  y=(a*i-d)/b;
	  if(y>=0 && abs(x)+abs(y)<xplusy)
	    {
	      xplusy=abs(x)+abs(y);
	      ansx=abs(x);
	      ansy=abs(y);
	    }
	  if(y>=0 && abs(x)+abs(y)==xplusy && ll(abs(a*x)+abs(b*y))<xtimesy)
	    {
	      xtimesy=abs(a*x)+abs(b*y);
	      ansx=abs(x);
	      ansy=abs(y);
	    }
	}
      if((d-a*i)%b==0)
	{
	  y=(d-a*i)/b;
	  if(abs(x)+abs(y)<xplusy)
	    {
	      xplusy=abs(x)+abs(y);
	      ansx=abs(x);
	      ansy=abs(y);
	    }
	  if(abs(x)+abs(y)==xplusy && ll(abs(a*x)+abs(b*y))<xtimesy)
	    {
	      xtimesy=abs(a*x)+abs(b*y);
	      ansx=abs(x);
	      ansy=abs(y);
	    }
	}
      if((d+a*i)%b==0)
	{
	  y=(d+a*i)/b;
	  if(abs(x)+abs(y)<xplusy)
	    {
	      xplusy=abs(x)+abs(y);
	      ansx=abs(x);
	      ansy=abs(y);
	    }
	  if(abs(x)+abs(y)==xplusy && ll(abs(a*x)+abs(b*y))<xtimesy)
	    {
	      xtimesy=abs(a*x)+abs(b*y);
	      ansx=abs(x);
	      ansy=abs(y);
	    }
	}
    }
}

int main()
{
  while(cin >> a >> b >> d && a)
    {
      ansx=inf;
      ansy=inf;
      xplusy=inf;
      xtimesy=1e13;
      solve(a,b,d);
      cout << ansx << ' ' << ansy << endl;
    }
  return 0;
}



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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

                                                                                                                
int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> D(N);
  rep(i, N) {
    ll t1, t2;
    cin >> t1 >> t2;
    D[i].push_back(t1);
    D[i].push_back(t2);
  }

  ll cnt = 0;
  rep(i, N) {
    if(D[i][0] == D[i][1]) {
      cnt++;
    }
    else {
      cnt = 0;
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
ll nmax = 200001;
vector<mint> kai(nmax,mint(1));

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    cin >> n >> m >> k;
    kai[0] = 1LL;
    for(mint i=mint(1);i.x<=n;i.x+=1){
        kai[i.x] = kai[i.x-1]*i;
    }
    mint ans = mint(0);
    for(ll i = 0;i<=k;++i){
        mint t = mint(1);
        t *= kai[n-1];
        t /= kai[i];
        t /= kai[n-1-i];
        t *= mint(m);
        t *= mint(m-1).pow(n-1-i);
        ans += t;
    }
    cout << ans.x << endl; 
    return 0;
}

Measured memory_bytes: 4656
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int h,w,k;cin>>h>>w>>k;

  vvi g(h, vi(w));
  rep(i, h){
    string s;cin>>s;
    rep(j, w){
      g[i][j] = (s[j]=='#'?1:0);
    }
  }
  dump_2d(g, h, w);

  vvi ans(h, vi(w, -1));
  int cur = 0;
  rep(i, h){
    int exist = 0;
    rep(j, w){
      if (g[i][j]==1) exist++;
    }

    if (exist==0){
    }
    else{
      cur++;
      int e2 = 0;
      rep(j, w){
        if (g[i][j]==1){
          e2++;
          if (e2>=2) cur++;
        }
        ans[i][j]=cur;
      }
    }
  }
  dump_2d(ans, h, w);

  rep(i, 1, h){
    rep(j, w){
      if (ans[i][j]==-1) ans[i][j] = ans[i-1][j];
    }
  }
  rrep(i, 0, h-1){
    rep(j, w){
      if (ans[i][j]==-1) ans[i][j] = ans[i+1][j];
    }
  }

  dump_2d(ans, h, w);

  if (cur<k) assert(false);

  rep(i, h){
    vi r = ans[i];
    rep(i, sz(r)) cout << r[i] << (i!=sz(r)-1 ? " " : "\n");
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 2176
/*
[abc166] F - Three Variables Game
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;

int N, A, B, C;
int s[MAX_N];
int ans[MAX_N];

int to_i(string &si) {
    if (si == "AB") return 0;
    if (si == "BC") return 1;
    return 2;
}

bool solve() {
    int n[3] = {A, B, C};
    for (int i = 0; i < N; i++) {
        int p = s[i], q = (p + 1) % 3;
        if (n[p] + n[q] == 0) {
            return false;
        }
        if (n[p] == 0 || n[q] == 0) {
            if (n[p] == 0) swap(p, q);
        } else if (i + 1 < N && s[i + 1] != s[i]) {
            if (q == (s[i + 1] + 2) % 3) swap(p, q);
        }
        n[p]--, n[q]++;
        ans[i] = q;
    }
    return true;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        s[i] = to_i(str);
    }

    if (solve()) {
        cout << "Yes" << endl;
        for (int i = 0; i < N; i++) {
            cout << char('A' + ans[i]) << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

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

	return 0;
}

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

using namespace std;

const int MOD = 1000000007;

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

long long calcInv(long long a){
    return modPow(a, MOD-2);
}

int main(){
	vector<long long> inv(200002);
	vector<long long> fact(200002);
	vector<long long> factInv(200002);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<=inv.size()-1;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    
    int N, A, B, C;
    while(cin >> N >> A >> B >> C){
        auto probA = A * inv[100 - C] % MOD;
        auto probB = B * inv[100 - C] % MOD;
        auto mul = 100 * inv[100 - C] % MOD;
        long long res = 0;
        for(int i=0;i<N;i++){
            auto pattern = comb(N-1+i, N-1);
            auto pa = modPow(probA, N-1) * modPow(probB, i) % MOD * probA % MOD;
            auto pb = modPow(probB, N-1) * modPow(probA, i) % MOD * probB % MOD;
            res += mul * (N+i) % MOD * pattern % MOD * (pa + pb) % MOD;
            res %= MOD;
        }
        cout << res << endl;
    }
}

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

int main(){
    ll a;
    cin >>a;
    double b;
    cin >>b;
    ll ib = b*100+0.5;
    a*=ib;
    a/=100;
    cout<<a << endl;
    return 0;
}

Measured memory_bytes: 3728
a, b, c = list(map(int, input().split()))

# from math import sqrt
import decimal

a2 = decimal.Decimal(a)
b2 = decimal.Decimal(b)
c2 = decimal.Decimal(c)

a2 = a2.sqrt()
b2 = b2.sqrt()
c2 = c2.sqrt()


# if sqrt(a) + sqrt(b) < sqrt(c):
#     print('Yes')
# else:
#     print('No')

if a2 + b2 < c2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5076
using System;

class AtCoDeer
{
	static void Main(string[] args)
	{
		int N;
		N = int.Parse(Console.ReadLine());
		int[] T;
		int[] A;
		T = new int[N];
		A = new int[N];
		for(int i=0; i<N; i++)
		{
			string[] v = Console.ReadLine().Split(' ');
			T[i] = int.Parse(v[0]);
			A[i] = int.Parse(v[1]);
		}

		long voteT, voteA, x, xt, xa;
		voteT = T[0];
		voteA = A[0];
		for(int i=1; i<N; i++)
		{
			xt = voteT / T[i];
			if(voteT % T[i] > 0)
				xt++;
			xa = voteA / A[i];
			if(voteA % A[i] > 0)
				xa++;
			x = Math.Max(xt, xa);
			voteT = T[i] * x;
			voteA = A[i] * x;
		}
		Console.WriteLine(voteT + voteA);

	}
}


Measured memory_bytes: 2904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, p[10], q[10];
vector<int> vec;
int a, b;
int cnt;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	for (int i = 0; i < n; i++)cin >> q[i];
	for (int i = 1; i <= n; i++)vec.push_back(i);
	do {
		cnt++;
		bool bl = true;
		for (int i = 0; i < n; i++)if (vec[i] != p[i])bl = false;
		if (bl)a = cnt;
		bl = true;
		for (int i = 0; i < n; i++)if (vec[i] != q[i])bl = false;
		if (bl)b = cnt;
	} while (next_permutation(all(vec)));
	cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#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>;

int main() {
    int d,n;
    cin >> d >> n;
    if(d == 0){
        if(n != 100)cout << n << endl;
        else cout << n+1 << endl;
    }else if (d == 1)
    {
        if(n != 100)cout << n * 100 << endl;
        else cout << n*100 + n << endl;
    }else{
        if(n != 100)cout << n * 10000 << endl;
        else cout << n * 100 * 100 + n*100 << endl;
    }
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    char s[4];
    cin >> s;
    if(s[0] > '1' || (s[0] == '1' && s[1] > '2') || (s[0] == '0' && s[1] == '0')){    //MMYYじゃない
        if(s[2] > '1' || (s[2] == '1' && s[3] > '2') || (s[2] == '0' && s[3] == '0')){  //YYMMじゃない
            cout << "NA" << endl;
        }
        else{
            cout << "YYMM" << endl;
        }
    }
    else{   //MMYYになる
        if(s[2] > '1' || (s[2] == '1' && s[3] > '2') || (s[2] == '0' && s[3] == '0')){  //YYMMじゃない
            cout << "MMYY" << endl;
        }
        else{
            cout << "AMBIGUOUS" << endl;
        }
    }
    return (0);
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

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

class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> X(N), Y(N), W(N);
        rep(i, N) cin >> X[i] >> Y[i] >> W[i];
        
        map<int, map<int, int>> G;
        rep(i, N) G[Y[i]][X[i]] = W[i];
        
        ll max_a = 0;

        rep(i, N) {
            int x = X[i], y = Y[i];
            for(int x_sign: {1, -1}) {
                for(int y_sign: {1, -1}) {
                    ll sum = 0;
                    rep(j, 4) {                        
                        int xx = x + dx[j] * x_sign;
                        int yy = y + dy[j] * y_sign;
                        sum += G[yy][xx];
                    }
                    set_max(max_a, sum);
                }
            }
        }

        cout << max_a << " / " << 1 << endl;
        
        return 0;
    }
};

int main() {
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 74316
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String a = s.next();
    String b = s.next();
    Boolean flag = true;
    if (a.equals("H")) {
      if (b.equals("H")) {
        flag = true;
      } else {
        flag = false;
      }
    } else {
      if (b.equals("H")) {
        flag = false;
      } else {
        flag = true;
      }
    }
    if (flag) {
      System.out.println("H");
    } else {
      System.out.println("D");
    }
  }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans,tmpans,h[100001];
inline int read(){
	char ch=getchar();
	int o=0;
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		o=(o<<3)+(o<<1)+(ch^48);
		ch=getchar();
	}
	return o;
}
int main(){
	n=read();
	for(register int i=1;i<=n;i++)h[i]=read();
	for(register int i=1;i<n;i++){
		if(h[i]>=h[i+1]){
			tmpans++; 
			ans=max(tmpans,ans);
		}
		else tmpans=0;
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <cctype>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, double> pid;
typedef pair<LL, int> pLi;
typedef pair<int, LL> piL;
typedef stringstream strstm;
#define PI acos(-1.0)
#define CLR(a) MST(a,0);
#define E 2.718281829459
#define pb(x) push_back(x)
#define CLR(a) MST(a,0);
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)


bool istrue(double a){
	if(a - (int)a == 0) return true;
	return false;
}

int w(int a){
	int ans = 0;
	while( a > 0){
		ans ++;
		a/=10;
	}
	if(ans == 1) return 10;
	if(ans == 2) return 100;
	if(ans == 3) return 1000;
	if(ans == 4) return 10000;
}

int main(int argc, char const *argv[])
{
	
	int a, b; cin >> a >> b;
	int num = b + a*w(b);
	//cout << "num == " << num << endl;
	if(istrue(sqrt(num))) puts("Yes");
	else puts("No");
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int t[5];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  forn(i,5) cin >> t[i];

  sort(t,t+5);

  int res = INT_MAX;
  do {
    int v = 0;
    for (int i = 0; i < 5; i++) {
      v += t[i];
      if (i < 4 && v % 10 != 0) {
        v = (v/10+1)*10;
      }
    }
    chmin(res,v);
  } while (next_permutation(t,t+5));

  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(2e5) +5;

bool ar[105][ms]={0};
ll pp[105]={0};

int main()
{
    idfc;
    ll n;
    cin>>n;
    int i;
    int a,b;int e;
    for(i=1;i<=n;i++)
    {
        b=i%10;
        if(!b)continue;
        e=i;
        while(e>0)
        {
            a=e%10;
            e/=10;
        }
        a=(a*10)+b;
                ar[a][i]=true;
    }
    int j;
    for(i=11;i<=99;i++)
    {
        e=0;
        for(j=1;j<=n;j++)
        {
            if(ar[i][j])e++;
        }
        pp[i]=e;
    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        b=i%10;
        if(!b)continue;
        e=i;
        while(e>0)
        {
            a=e%10;
            e/=10;
        }
        a=a+(b*10);
        ans+=pp[a];
    }
    cout<<ans;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
 
int64_t ryuka(int64_t n,int64_t a, int64_t b)
{
  if(n == 0) return 2;
  if(n == 1) return 1;
  if(n == 2) return a + b;
  else return ryuka(n - 1,a + b,a);
}
 
int main() {
  int64_t S = 0;
  int64_t N;
  
  cin >> N;
  
  S = ryuka(N,1,2);
  
  printf("%ld\n",S);
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  vector<int> p(N);
  rep(i, N) { cin >> p[i]; }

  int tmpMin = 1e9;

  rep(i, N) {
    if (tmpMin > p[i]) {
      tmpMin = p[i];
    }

    if (tmpMin == p[i]) {
      sum += 1;
    }
  }

  cout << sum << endl;
  return 0;

}

Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().rstrip()

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 same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n,m=map(int, input().split())
    uf=UnionFind(n)
    for _ in range(m):
        x,y,z=map(int, input().split())
        uf.union(x-1,y-1)
    print(uf.group_count())




 
if __name__=='__main__':
    main()

Measured memory_bytes: 13616