akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void) {

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a < c) {

		if (b < c) {

			cout << 0;

		}
		else if (b <= d) {

			cout << b - c;

		}
		else if (b > d) {

			cout << d - c;

		}

	}
	else {

		if (d < a) {

			cout << 0;

		}
		else if (d <= b) {

			cout << d - a;

		}
		else if (d > b) {

			cout << b - a;

		}

	}

	cout << endl;


	return 0;

}

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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define Ifor(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dfor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Ifoz(i, a) Ifor(i, 0, a)
#define Dfoz(i, a) Dfor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define all(x) begin(x), end(x)

using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	ll x, y;
	cin >> x >> y;
	int ans = 1;
	while (2 * x <= y) { ans++; x <<= 1; }
	cout << ans << '\n';
}



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

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        N: usize,
        A: [isize; N]
    }
    let buff = A.windows(2).map(|v| (v[1] - v[0]).abs()).sum::<isize>();
    for i in 0..N {
        let mut ans = if i == 0 {
            buff - (A[1] - A[0]).abs() + (A[1] - 0).abs() + (0 - A[N - 1]).abs()
        } else if i == N - 1 {
            buff - (A[N - 1] - A[N - 2]).abs() + (A[0] - 0).abs() + (0 - A[N - 2]).abs()
        } else {
            buff + (A[0] - 0).abs() + (0 - A[N - 1]).abs()
                - (A[i] - A[i - 1]).abs()
                - (A[i + 1] - A[i]).abs()
                + (A[i + 1] - A[i - 1]).abs()
        };
        println!("{}", ans);
    }
}

Measured memory_bytes: 5244
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i!=j)
            {
                c=c+a[i]*a[j];
            }
        }
    }
    cout<<c/2;
}


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

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  vector<P>data(0);
  char st = s[0];
  int cnt = 0;
  rep(i,0,n){
    if(st != s[i]){
      data.push_back(P(cnt,st-'0'));
      st = s[i];
      cnt = 1;
    }
    else cnt++;
  }
  if(cnt != 0) data.push_back(P(cnt,st-'0'));
  
  vector<P>sum(data.size());
  sum[0].first = data[0].first;
  sum[0].second = data[0].second;
  rep(i,1,data.size()){
    sum[i].first = sum[i-1].first+data[i].first;
    sum[i].second = data[i].second;
  }
  
  int ans = 0;
  rep(i,0,sum.size()){
    int tmp,b,f;
    if(sum[i].second == 0){
      if(i+2*k-1 < sum.size()) b = sum[i+2*k-1].first;
      else b = sum[sum.size()-1].first;
      if(i-2 >= 0) f = sum[i-2].first;
      else f = 0;
    }
    else{
      if(i+2*k < sum.size()) b = sum[i+2*k].first;
      else b = sum[sum.size()-1].first;
      if(i-1 >= 0) f = sum[i-1].first;
      else f = 0;
    }
    tmp = b-f;
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}

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

vector<vector<int>> al;
vector<int> p;
vector<int> color;
vector<int> score;

bool path(int i, int d) {
  color[i] = 1;
  if(i == d) {
    p.push_back(d);
    return true;
  }
  bool found = false;
  for(int n: al[i]) {
    if(color[n] != -1) continue;
    if(path(n, d)) {
      found = true;
      p.push_back(i);
    }
  }
  return found;
}

int s(int i) {
  color[i] = 1;
  int res = 1;
  for(int n: al[i]) {
    if(color[n] != -1) continue;
    res += s(n);
  }
  return res;
}

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

  al = vector<vector<int>>(n, vector<int>(0));
  rep(i,n-1) {
    int s,t;
    scanf("%d %d", &s, &t);
    al[s-1].push_back(t-1);
    al[t-1].push_back(s-1);
  }

  color = vector<int>(n, -1);
  path(0, n-1);


  fill(color.begin(), color.end(), -1);
  reverse(p.begin(), p.end());
  for(int i : p) color[i] = 1;
  int l = p.size();
  vector<int> score(l, 0);
  rep(i,l) score[i] = s(p[i]);

  int fs = 0, ss = 0;
  rep(i,(l+1)/2) {
    fs += score[i];
  }
  for(int i = l-1, m = (l+1)/2; i >= m; i--) {
    ss += score[i];
  }

  if(fs > ss) {
    printf("Fennec\n");
  } else {
    printf("Snuke\n");
  }

  return 0;
}


Measured memory_bytes: 11768
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n; 

int main(){
	double r;
	cin>>r;
	r = acos(-1)*2.0*r;
	printf("%.10lf\n",r);
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A = 0;
    int long long X, B = 100;
    cin >> X;
    double C = 101*0.01;
    while(true){
        B = B*C;
        A = A + 1;
        if(B >= X){
            goto ABC;
        }
    }
    ABC:
    cout << A << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int N;
	int W[105];
	int i;
	int SumL=0;
	int SumR=0;
	int mindiff=20000;
	int diff;
	scanf("%d",&N);
	for(i=0;i<N;i++) 
	{
		scanf("%d",&W[i]);
		SumL+=W[i];
	}
	for(i=0;i<N;i++)
	{
		SumL-=W[i];
		SumR+=W[i];
		diff=abs(SumL-SumR);
		if(diff<mindiff) mindiff=diff;
	}
	printf("%d\n",mindiff);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {
    
    int n,m;
    cin>>n>>m;
    vi sum(n);
    vb isac(n);
    int ac=0,wa=0;
    rep(i,m){
        int p;
        string s;
        cin>>p>>s;
        p--;
        if(isac[p])continue;
        if(s=="AC"){
            isac[p]=1;
            ac++;
        } else {
            sum[p]++;
        }
    }
    rep(i,n){
        if(isac[i])wa+=sum[i];
    }
    cout<<ac<<' '<<wa<<endl;

}


Measured memory_bytes: 640
// ABC166B - 

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

int main() {
	int N, K;
	cin >> N >> K;

	set<int> A;
	for (int i = 0; i < K; i++) {
		int t;
		cin >> t;
		for (int j = 0; j < t; j++) {
			int s;
			cin >> s;
			A.insert(s);
		}
	}

	cout << N - A.size() << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;
typedef unsigned long ul;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vc;
    while(n--) {
        int x;
        cin >> x;
        vc.push_back(x);
    }
    n = vc.size();
//    int n = 200000;
//    int k = 200000;
//    vector<int> vc;
//    for (int i = 0; i < n; i ++) {
//        vc.push_back(1000);
//    }

    vector<ul> cums;
    ul cum = 0;
    cums.push_back(0);
    for (int i = 0; i < n; i++) {
        cum += vc[i];
        cums.push_back(cum);
    }
    ul max = 0;
    for (int i = 0; i < n - k + 1; i++) {
        int a = cums[i + k] - cums[i];
        if (max < a) {
            max = a;
        }
    }
//    int max = *max_element(buf.begin(), buf.end());

    cout << setprecision(20) << (max + k) / 2.0 << '\n';


    return 0;
}


Measured memory_bytes: 3188
// ------------------------------------
// Date:2018/ 2/25
// Problem:ABC 050 ContestWithDrinkEasy b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

using ll = long long;

#define MOD 1000000007

int main()
{
  int N,M,P,X;
  ll ans;
  cin >> N;
  int T[111];
  REP(i,N) {
    cin >> T[i];
  }
  cin >> M;
  REP(mi,M) {
    ans = 0ll;
    cin >> P >> X;
    REP(ni,N) {
      if (ni == P-1) ans += X;
      else ans += T[ni];
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));


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

    string S,T;
    int Q;
    cin>>S>>T>>Q;
    int sz=S.size(),tz=T.size();
    vector<int> s(sz),t(tz);
    for(int i=0;i<sz;i++){
        int x;
        if(S[i]=='A') x=1;
        else x=2;
        if(i==0) s[i]=x;
        else s[i]=s[i-1]+x;
    }
    for(int i=0;i<tz;i++){
        int x;
        if(T[i]=='A') x=1;
        else x=2;
        if(i==0) t[i]=x;
        else t[i]=t[i-1]+x;
    }

    while(Q--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--; b--; c--; d--;
        int ss,tt;
        if(a==0) ss=s[b];
        else ss=s[b]-s[a-1];
        if(c==0) tt=t[d];
        else tt=t[d]-t[c-1];
        if(ss%3==tt%3) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1744
#include<stdio.h>
int main()
{
	int a,b,c,d,p,x,y;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);

	// x????????????
	x=a*p;

	// y?????§?????¬??????????¶??????????????????????
	if(p<=c){
		y=b;
	}else{
		y=b+(p-c)*d;
	}
	
	// x?????¨y????????????
	if(x<=y){
		printf("%d\n",x);
	}else{
		printf("%d\n",y);
	}

	return 0;
}

Measured memory_bytes: 596
import collections

def solve(n, s):
    records = []
    D = {}
    for i in range(n):
        counter = collections.Counter(s[i])
        k = ",".join(["%s:%d" % (k,v) for k, v in sorted(counter.items())])
        if not k in D:
            D[k] = 0
        D[k] += 1
    res = 0
    for k, v in D.items():
        res += v * (v-1) // 2
    return res

n = int(input())
s = [input() for i in range(n)]
print(solve(n, s))

Measured memory_bytes: 27100
#include<iostream>
using namespace std;
bool Test()
{
		int w,h,x,y,r;
		cin>>w>>h>>x>>y>>r;
		if((x+r)>w)return false;
		if((x-r)<0)return false;
		if((y+r)>h)return false;
		if((y-r)<0)return false;
		return true;
}
int main()
{
	if(Test())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3112
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .takeWhile(_ != "-")
      .foreach { cards =>
        val m = io.StdIn.readInt()
        val shuffle = (for (_ <- 0 until m) yield io.StdIn.readInt()).sum
        val result = shuffle % cards.length match {
          case 0 => cards
          case i => cards.substring(i) + cards.substring(0, i)
        }
        println(result)
      }
  }
}

Measured memory_bytes: 43960
from math import factorial

mod = 10**9 + 7


def combi(n, k):
    return factorial(n) // factorial(k) // factorial(n - k)


n = int(input())

ans = 0
for n_part in range(1, n // 3 + 1):
    rest = n - n_part * 3
    ans += combi(n_part - 1 + rest, rest)
    ans %= mod

print(ans)


Measured memory_bytes: 8960
#include <cstdio>
#include <algorithm>
using namespace std;

const int Maxn = 1e5;

struct Node {
	int val, id;
	bool operator < (const Node &rhs) const {return val < rhs.val;}
};

int N;
Node A[Maxn + 5];

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%d", &A[i].val), A[i].id = i;
	sort(A + 1, A + N + 1);
	for(int i = 1; i <= N; i++)
		printf("%d ", A[i].id);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
bool f(long long a) {
  if(a % 2 == 0) return false;
  for(long long i = 3; i *i <= a; i += 2)
    if(a % i == 0) return false;
  return true;
}
  
int main() {
  int n;
  cin >> n;
  int res=0;
  for(int i=0; i<n; i++) {
    long long a;
    cin>> a;
    if(f(a*2+1)) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 998244353;

template <int mod>
struct modint {
    lint v;
    modint() : v(0) {}
    modint(signed v) : v(v) {}
    modint(lint t) {
        v = t % mod;
        if (v < 0)
            v += mod;
    }

    modint pow(lint k) {
        modint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static modint add_identity() { return modint(0); }
    static modint mul_identity() { return modint(1); }
    modint inv() { return pow(mod - 2); }

    modint &operator+=(modint a) {
        v += a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    modint &operator-=(modint a) {
        v += mod - a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    modint &operator*=(modint a) {
        v = v * a.v % mod;
        return *this;
    }
    modint &operator/=(modint a) { return (*this) *= a.inv(); }

    modint operator+(modint a) const { return modint(v) += a; };
    modint operator-(modint a) const { return modint(v) -= a; };
    modint operator*(modint a) const { return modint(v) *= a; };
    modint operator/(modint a) const { return modint(v) /= a; };

    modint operator-() const { return v ? modint(mod - v) : modint(v); }

    bool operator==(const modint a) const { return v == a.v; }
    bool operator!=(const modint a) const { return v != a.v; }
    bool operator<(const modint a) const { return v < a.v; }
};
using mint = modint<mod>;
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<mint>> dp(c + 1, vector<mint>(d + 1, 0));
    dp[a][b] = 1; // all white
    for (int i = a + 1; i <= c; ++i) {
        dp[i][b] = dp[i - 1][b] * b;
    }
    for (int i = b + 1; i <= d; ++i) {
        dp[a][i] = dp[a][i - 1] * a;
    }
    for (int i = a + 1; i <= c; ++i) {
        for (int j = b + 1; j <= d; ++j) {
            // dp[i][j] += dp[i - 1][j - 1] * (((i - 1) * j + (j - 1) * i - (i - 1) - (j - 1)) / 2 + (i - 1) + (j - 1));
            // dp[i][j] += (dp[i - 1][j] * (j - 1) + dp[i][j - 1] * (i - 1)) / 2 + dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] += dp[i - 1][j] * j + dp[i][j - 1] * i;
            dp[i][j] -= dp[i - 1][j - 1] * ((i - 1) * j + (j - 1) * i - (i - 1) - (j - 1)) / 2;
        }
    }
    cout << dp[c][d] << "\n";
    return 0;
}

Measured memory_bytes: 73680
S = int(input())
first = S // 100
end = S % 100

if (0 < first and first < 13) and (0 < end and end < 13):
    print('AMBIGUOUS')
elif (0 < first and first < 13) and (0 == end or end > 12):
    print('MMYY')
elif (0 == first or first > 12) and (0 < end and end < 13):
    print('YYMM')
else:
    print('NA')    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef pair<int,int> ii;
typedef pair<ii,int> iii;

const int MAX=1e5+5;

int n,f[MAX];
ii a[MAX];
vector<iii> V;

int32_t main() {
	//freopen("input","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	V.push_back({a[1],1});
	for(int i=2;i<=n;i++)
		if(a[i].first>a[i-1].first)
			V.push_back({a[i],1});
		else
			V.back().second++;
	int minId=1e9,cnt=0;
	for(int i=V.size()-1;i>=0;i--) {
		minId=min(minId,V[i].first.second);
		cnt+=V[i].second;
		f[minId]+=(V[i].first.first-(i==0?0:V[i-1].first.first))*cnt;
	}
	for(int i=1;i<=n;i++)
		cout<<f[i]<<'\n';
}


Measured memory_bytes: 8000
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int sum=0;
  for(int i = 0; i < n; i++){
    if(i<=k-1) sum+=x;
    else sum+=y;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    string S; cin >> S;
    long long len = S.size();
    long long B = 0; long long ans = 0;
    for(long long i=1;i<=len;i++){
        if(S[len-i] == 'B'){
            B++;
            //cout << len-B << len-i << endl;
            ans += len-B-(len-i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

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

int main(){
    ll H,ans=0,dep=1;
    cin>>H;
    while(H>0){
        ans+=dep;
        dep*=2;
        H/=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int dp[N];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	vector<pii> v;
	for(int i = 0; i < n; i++) {
		int x, l;
		cin >> x >> l;
		v.pb({x - l, x + l});
	}
	sort(all(v));
	for(int i = 0; i < v.size(); i++) {
		if(i == 0) {
			dp[i] = 1;
		}
		else {
			dp[i] = max(dp[i], dp[i - 1]);
		}
		int pos = lower_bound(all(v), make_pair(v[i].se, 0LL)) - v.begin();
		dp[pos] = max(dp[pos], dp[i] + 1);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans;

	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int v1[100000] = {0},v2[100000] = {0};
    if(n%2){
        int num;
        cin >> num;
        v2[num-1]++;
    }
    for(int i=0; i<n/2; i++){
        int a,b;
        cin >> a >> b;
        v1[a-1]++;
        v2[b-1]++;
    }
    int p,q,r,s;
    p = 0;
    q = 1;
    for(int i=1; i<100000; i++){
        if(v1[p] < v1[i]) {
            q = p;
            p = i;
        }
        else if(v1[q] < v1[i]){
            q = i;
        }
    }

    r = 0;
    s = 1;
    for(int i=1; i<100000; i++){
        if(v2[r] < v2[i]){
            s = r;
            r = i;
        }
        else if(v2[s] < v2[i]){
            s = i;
        }
    }
    if(p != r){
        cout << n - v1[p] - v2[r] << endl;
    }
    else{
        cout << min(n-v1[p]-v2[s],n-v1[q]-v2[r]) << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll MOD = 1000000007ll;
ll dp[100100];
bool broken[100100];
int N,M;
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int a;
		cin >> a;
		broken[a]=true;
	}
	dp[0]=1ll;
	for(int i=1;i<=N;i++){
		if(broken[i])continue;
		if(i-1>=0)dp[i]=(dp[i]+dp[i-1])%MOD;
		if(i-2>=0)dp[i]=(dp[i]+dp[i-2])%MOD;
	}
	cout << dp[N] << endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

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

int main(){
    int64_t N, M, A, i, ans = 0;
    cin >> N >> M;
    priority_queue<int64_t> que;
    for(i = 0; i < N; i++){
        cin >> A;
        que.push(A);
    }
    for(i = 0; i < M; i++){
        A = que.top();
        que.pop();
        A /= 2;
        que.push(A);
    }
    for(i = 0; i < N; i++){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

int main() {
    double X, Y;
    cin >> X;

    vector<int> ans;
    ans.push_back(1);
    for(int i = 2; i < X; i++){
        int j = i;
        while((j *= i) <= X){
            ans.push_back(j);
        }
    }
    sort(ans.begin(), ans.end(), [](const int& a, const int& b){return a < b;});
    cout << ans.back() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	//int t;
	//cin >> t;
	//while(t--)
	//{
		string s1,s2;
		cin >>s1>>s2;
		cout <<s2+s1<<endl;
	//}
	return 0;
}

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

long gcd(long m, long n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}

long lcm(long m, long n) {
  return m / gcd(m, n) * n;
}

int main() {
  int n;
  cin >> n;
  long ans = 1;
  for (int i = 0; i < n; i++) {
    long t;
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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


const long long INF = 1LL << 60;

//bucket1
// bool ch[10] = {0};
// bool check(int n){
//     while(n!=0){
//         if(ch[n%10]) return false;
//         n /= 10;
//     }
//     return true;
// }



// --------write my code!!!!!----------//


int main(){
    int a,b,h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>

int main(void)
{
  int n;
  std::cin >> n;
  int h[n];
  for ( int i = 0; i < n; i++ ) {
    std::cin >> h[i];
  }

  // DP table
  int dp[n+1];
  std::memset(dp, 0, sizeof(dp));
  dp[2] = std::abs(h[1] - h[0]);
  for ( int i = 2; i < n; i++) {
    dp[i+1] = std::min(dp[i] + std::abs(h[i] - h[i-1]), dp[i-1] + std::abs(h[i] - h[i-2]));
  }

  std::cout << dp[n] << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <map>
#include <climits>

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))

using namespace std;

int main() {
  int t, k;cin >> t >> k;
  int arr[t], brr[t];
  if (t == 1) {
    cout << 0 << endl;
    return 0;
  }
  cin >> arr[0];
  cin >> arr[1];
  brr[0] = 0;
  brr[1] = fabs(arr[1] - arr[0]);
  for (int i = 2; i < t; i++) {
    cin >> arr[i];
    brr[i] = INT_MAX;
    for (int j = i; j >= i - k && j >= 0; j--) {
      brr[i] = min(brr[i], brr[j] + fabs(arr[j] - arr[i]));
    }
  }
  cout << brr[t - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;

  cout << n / 3 << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, X, T = map(int, readline().split())

    ans = (N + X - 1) // X * T
    print(ans)

    return


if __name__ == '__main__':
    main()


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

int dp[1001][1001];

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string x, y;
    cin >> x >> y;
    int xlen = x.length(), ylen = y.length();
    for (int j = 0; j <= ylen; j++) dp[0][j] = 0;
    for (int i = 1; i <= xlen; i++) {
      dp[i][0] = 0;
      for (int j = 1; j <= ylen; j++) {
        dp[i][j] = x[i - 1] == y[j - 1] ? dp[i - 1][j - 1] + 1
                                        : max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
    cout << dp[xlen][ylen] << endl;
  }
}



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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int a;
	cin>>a;

	cout<<(int)(a + pow(a,2) + pow(a,3));
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 4108
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int l = sc.nextInt();
		int t = sc.nextInt();
		Node[] n = new Node[l];
		for(int i=0;i<l;i++)n[i]=new Node(i+1);
		int out =0;
		for(int i=0;i<t;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			n[x-1].addc(n[y-1]);
		}
		for(int i=0;i<l;i++) {
			out=Math.max(out, getLayer(n[i]));
		}
		pw.println(out);
		pw.close();
	}
	public static int getLayer(Node n) {
		if(n.layer>-1)return n.layer;
		else if(n.c.isEmpty())return 0;
		else {
			int temp =0;
			for(Node x : n.c) {	
				temp=Math.max(temp, getLayer(x)+1);
			}
			n.layer=temp;
			return temp;
		}
	}
	static class Node{
		int layer;
		int val;
		ArrayList<Node> c;
		public Node(int v) {
			val=v;
			layer=-1;
			c=new ArrayList<Node>();
		}
		public void addc(Node n) {
			c.add(n);
		}
	}
}
@SuppressWarnings("all")
class FastScanner {
    BufferedReader br;
    StringTokenizer st;
 
    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
 
    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    int nextInt() {
        return Integer.parseInt(nextToken());
    }
 
    long nextLong() {
        return Long.parseLong(nextToken());
    }
 
    double nextDouble() {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 58304
abcList = [[4, 6, 9, 11], [2]]
x, y = map(int, input().split())
a = (abcList[0].count(x) == abcList[0].count(y))
b = (abcList[1].count(x) == abcList[1].count(y))
print("Yes" if (a and b) else "No")


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

int main() {
  int n, i, j = 1, count = 0, m = 0;
  cin >> n;
  
  vector<int> a(n), b(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  for(i = n - 1; i >= 0; i--){
    j = 1;
    count = 0;
    while(j * (i + 1) <= n){
      if(b.at(j * (i + 1) - 1) == 1){
        count++;
      }
      j++;
    }
    if(count % 2 != a.at(i)){
      b.at(i) = 1;
      m++;
    }
  }
  
  cout << m << endl;
  for(i = 0; i < n; i++){
    if(b.at(i) == 1) cout << i + 1 << " ";
  }
}

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

int main()
{
	long i,N,temp,sum=0;
	vector<long> A;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		A.push_back(temp);
		sum=sum+pow(-1,i)*temp;
	}
	cout<<sum<<" ";
	for(i=0;i<N-1;i++){
		sum=2*A.at(i)-sum;
		cout<<sum<<" ";
	}
}


Measured memory_bytes: 2164
N, K = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)

IP = [nil]*N
N.times{|i|
	IP[P[i]] = i
}

UP = [1]*N
(N-2).downto(0){|i|
	UP[i] = P[i] < P[i+1] ? UP[i+1]+1 : 1
}

def NextIndex(_N, _IP)
	ri = (1..N).to_a + [N, N]
	li = (-1..(N-2)).to_a + [-1, -1]
	lr, rr = [nil]*N, [nil]*N
	_IP.each{|i|
		l, r = li[i], ri[i]
		li[r], ri[l] = l, r
		lr[i], rr[i] = l, r
	}
	return lr, rr
end

LU,_ = NextIndex(N, IP)
_,RL = NextIndex(N, IP.reverse)

pm, n = K <= UP[0] ? [1, 0] : [0, 1]
(N-K).times{|i|
	if K <= UP[i+1]
		pm += 1
	elsif RL[i] < i+K or i < LU[i+K]
		n += 1
	end
}

p n+[pm,1].min


Measured memory_bytes: 42816
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<int> checkone(n, 0);
    std::vector<int> checkn(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a == 0) {
            checkone[b]++;
        } else if (a == n - 1) {
            checkn[b]++;
        }
        if (b == 0) {
            checkone[a]++;
        } else if (b == n - 1) {
            checkn[a]++;
        }
    }
    int flag = 0;
    for (int i = 0; i < n; i++) {
        if (checkone[i] * checkn[i] == 1) {
            flag = 1;
            break;
        }
    }
    if (flag) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<180*(n-2)<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    char s[20];
    scanf("%d%d%s",&a,&b,s);
    if(a<1||a>5||b<1||b>5)
    {
        printf("No");
        return 0;
    }
    int i,l,k,m;
    k=0;l=0;m=0;
    for(i=0;i<(a+b+1);i++)
    {
        k++;
        if(s[i]=='-')
        {
            l=l+10;
            m++;
        }
        if(l<10)
        {
            l++;
        }
    }
    l=l-10;
    if(l==a&&(k-l-1)==b&&m==1)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
def smaller(x, y):
	if x < y: return x
	else: return y

A = int(raw_input())
B = int(raw_input())
C = int(raw_input())
D = int(raw_input())
P = int(raw_input())

X = P*A
Y = B
if C < P:
	Y += (P-C)*D
print smaller(X, Y)


Measured memory_bytes: 4640
// map=~190ms >> unordered_map
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    unordered_map<int, int> ump;
    rep(i, n) {
        int d; cin >> d;
        ump[d]++;
    }
    int m; cin >> m;
    vector<int> t(m);
    rep(i, m) cin >> t[i];

    int cnt = 0;
    rep(i, m) {
        if(ump[t[i]]) cnt++;
        ump[t[i]]--;
    }
    cout << (cnt >= m ? "YES" : "NO") << '\n';
    return 0;
}

Measured memory_bytes: 9288
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

struct node{int val,id,op;}a[N<<1];
bool cmp(node p,node q) {return p.val<q.val;}
int n,cnt[2],vis[N];

int main()
{
    n=read();
    rep(i,1,n)
    {
        int x=read(),y=read();
        a[i*2-1]=(node){x,i,0};
        a[i*2]=(node){y,i,1};
    }
    sort(a+1,a+1+n*2,cmp);
    ll sum=0;int ok=0;
    rep(i,1,n)
    {
        cnt[a[i].op]++;sum+=a[i].val;vis[a[i].id]++;
        if (vis[a[i].id]==2) ok=1;
    }
    if ((ok) || (cnt[0]==n) || (cnt[1]==n)) {printf("%lld",sum);return 0;}
    //cout << sum << endl;
    cnt[a[n].op]--;vis[a[n].id]--;
    cnt[a[n+1].op]++;vis[a[n+1].id]++;
    if (vis[a[n+1].id]==2) ok=1;
    sum+=a[n+1].val-a[n].val;
    if ((ok) || (cnt[0]==n) || (cnt[1]==n)) printf("%lld",sum);
    else printf("%lld\n",sum+min(a[n+2].val-a[n+1].val,a[n].val-a[n-1].val));
    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{-1};
    lol n, m; cin >> n >> m;
    vector<int> a(m, 0), b(m, 0);
    REP(i, m)
    {
        cin >> a[i] >> b[i];
    }
    if(m == 0)
    {
        if(n == 1)
            result = 0;
        if(n == 2)
            result = 10;
        if(n == 3)
            result = 100;
    }
    else if(n == 1)
    {
        FOR(i, 0, 9)
        {
            string s = to_string(i);
            REP(j, m)
            {
                if(((int)s[a[j]-1]-(int)'0') != b[j])
                    break;
                if(j == m-1)
                    result = i;
            }
            if(result != -1)
                break;
        }
    }
    else if(n == 2)
    {
        FOR(i, 10, 99)
        {
            string s = to_string(i);
            REP(j, m)
            {
                if(((int)s[a[j]-1]-(int)'0') != b[j])
                    break;
                if(j == m-1)
                    result = i;
            }
            if(result != -1)
                break;
        }
    }
    else if(n == 3)
    {
        FOR(i, 100, 999)
        {
            string s = to_string(i);
            REP(j, m)
            {
                if(((int)s[a[j]-1]-(int)'0') != b[j])
                    break;
                if(j == m-1)
                {
                    result = i;
                }
            }
            if(result != -1)
                break;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3692
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		long m = long.Parse(input[1]);
    long[][] vertexes = new long[n][];
    for(long i = 0; i < n; i++)
    {
      vertexes[i] = new long[2];
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i][0] = nums[0];
      vertexes[i][1] = nums[1];
    }
    Array.Sort(vertexes, (a, b) => a[0].CompareTo(b[0]));
		long answer = 0;
    int checkingDrink = 0;

    while(true)
    {
      if(vertexes[checkingDrink][1] < m)
      {
        m -= vertexes[checkingDrink][1];
        answer += vertexes[checkingDrink][1]*vertexes[checkingDrink][0];
        checkingDrink++;
        //Console.WriteLine(answer);
      }else
      {
        answer += vertexes[checkingDrink][0]*m;
        break;
      }
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 20552
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  vector<int> X(11);
  for(int i=0;i<4;i++){
    int K;
    cin>>K;
    X.at(K)++;
  }
  if(X.at(1)==1&&X.at(9)==1&&X.at(7)==1&&X.at(4)==1) cout<<"YES";
  else cout<<"NO";
  
return 0;}


Measured memory_bytes: 3596