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

int main()
{
    int n;
    cin>>n;
    int a[n];//i番目の料理
    int b[n];//i番目の料理で得る満足度
    int c[n-1];//iを食べた直後にi+1を食べると追加で上がる満足度
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]--;
    }
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    
    int ans=b[a[0]];
    i=1;
    while(1)
    {
        ans += b[a[i]];
        if(a[i]==a[i-1]+1)
        {
            ans += c[a[i-1]];
        }
        i++; 
      if(i>=n)break;
    }
    
   /*int ans =0;
    for(i=0;i<n;i++)
    {
        ans+=b[a[i]];
        if(i>0 && a[i]==a[i-1]+1)
        {
            ans+=c[a[i-1]];
        }
    }*/
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back

typedef struct{
  int pat;
  int te,pos0;
}node;

void swap(int&ta,int p,int t){
  stringstream in,out;
  in<<ta;
  string str=in.str();
  if(str.size()<8)str='0'+str;
  swap(str[p],str[t]);
  out<<str;
  out>>ta;
}

main(){
  queue<node> Q;
  Q.push((node){1234567,0,0});
  map<int,int> memo;
  memo[1234567]=0;
  while(!Q.empty()){
    int tvi=Q.front().pat;
    int te=Q.front().te,pos0=Q.front().pos0;
    Q.pop();
    int n=tvi;

    if(pos0%4){
      swap(n,pos0,pos0-1);
      if(memo.count(n)==0){
        memo[n]=te+1;
        Q.push((node){n,te+1,pos0-1});
      }
    }

    n=tvi;
    if(pos0%4!=3){
      swap(n,pos0,pos0+1);
      if(memo.count(n)==0){
        memo[n]=te+1;
        Q.push((node){n,te+1,pos0+1});
      }
    }

    n=tvi;
    swap(n,(pos0+4)%8,pos0);
    if(memo.count(n)==0){
      memo[n]=te+1;
      Q.push((node){n,te+1,(pos0+4)%8});
    }
  }

  int goal=1234567;
  
  int s;
  while(cin>>s){
    int pos0=7;
    int start=s;
    rep(i,7){
      if(!s)pos0=i;
      cin>>s;
      start=start*10+s;
    }
    cout<<memo[start]<<endl;
  }
}

Measured memory_bytes: 1516
#include<stdio.h>
int main()
{
    int n,r,temp;
    scanf("%d",&n);
    temp=n;
    r=temp%10;
    if(r==3)
    printf("bon");
    else if(r==0||r==1||r==6||r==8)
    printf("pon");
    else printf("hon");
    return 0;
    
    
}

Measured memory_bytes: 2144
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, 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")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize
    }
    let mut x = 0;
    for i in 1..n + 1 {
        let sum = count(i);
        if a <= sum && sum <= b {
            x += i;
        }
    }
    println!("{}", x)
}

fn count(mut n: usize) -> usize {
    let mut sum = 0;
    while n > 0 {
        sum += n % 10;
        n /= 10;
    }
    sum
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            if (a >= 10 || b >= 10)
                Console.WriteLine("-1");
            else
                Console.WriteLine(a * b);

            Console.ReadKey(); 

        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,a[N];
map<int,int> cnt,now;

void No() {
	puts("No");exit(0);
}

bool check(int x,int y) {
	now=cnt;
	a[1]=x,a[2]=y;
	if(x==y&&now[x]==1) return 0;
	--now[x],--now[y];
	for(int i=3;i<=n;i++) {
		int cur=a[i-1]^a[i-2];
		if(!now[cur]) return 0;
		--now[cur];a[i]=cur;
	}
	if((a[n]^a[n-1]^a[1])!=0) return 0;
	if((a[n]^a[1]^a[2])!=0) return 0;
	return 1;
}

int main() {
	cin>>n;for(int i=1;i<=n;i++) a[i]=gi(),++cnt[a[i]];
	if(cnt.size()>=4) No();
	for(auto x:cnt)
		for(auto y:cnt) if(check(x.first,y.first)) return puts("Yes"),0;
	No();
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[200010],sum[200010],ans=INF;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum[i+1]=a[i]+sum[i];
    }
    rep2(i,2,n-1){
        ll p,q,r,s,p0,p1,q0,q1,r0,r1,s0,s1;
        p0=*lower_bound(sum,sum+n,sum[i]/2);
        q0=sum[i]-p0;
        p1=*(lower_bound(sum,sum+n,sum[i]/2)-1);
        q1=sum[i]-p1;
        if(abs(p0-q0)>=abs(p1-q1)){
            p=p1,q=q1;
        } else{
            p=p0,q=q0;
        }
        r0=*(lower_bound(sum,sum+n,sum[i]+(sum[n]-sum[i])/2));
        s0=sum[n]-r0;
        r0-=sum[i];
        r1=*(lower_bound(sum,sum+n,sum[i]+(sum[n]-sum[i])/2)-1);
        s1=sum[n]-r1;
        r1-=sum[i];
        if(abs(r0-s0)>=abs(r1-s1)){
            r=r1,s=s1;
        } else{
            r=r0,s=s0;
        }
        ll div=max(max(p,q),max(r,s))-min(min(p,q),min(r,s));
        ans=min(ans,div);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
  	ci(n>>k);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  ll ans=INF;
  FOR(i,0,n-k+1){
  chmin(ans,abs(A[i])+abs(A[i+k-1]-A[i]));
  chmin(ans,abs(A[i+k-1])+abs(A[i]-A[i+k-1]));
  }  
  co(ans)
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, A, B;

//xにyをk桁目に挟みいれる(yは0か1)
inline int ibit(int k, int x, int y) {
	int lo = x % (1 << k);
	int hi = (x - lo) * 2;
	return hi + (y << k) + lo;
}
//xからk桁目を外す
inline int obit(int k, int x) {
	int lo = x % (1 << k);
	int hi = ((((x - lo) >> k) / 2) << k);
	return hi + lo;
}

vector<int> f(int x, int b) {
	vector<int>vec;
	if (b == 1) {
		vec.push_back(0);
		vec.push_back(1);
		return vec;
	}
	int k;
	for (k = 0; true; k++) {
		if ((x & (1 << k))) {
			break;
		}
	}
	int z = 1;
	int y = obit(k, x);
	vector<int>fi = f(z, b - 1);
	vector<int>se = f(z ^ y, b - 1);
	for (auto elm : fi) {
		vec.push_back(ibit(k, elm, 0));
	}
	for (auto elm : se) {
		vec.push_back(ibit(k, elm ^ z, 1));
	}
	assert(vec.back() == x);
	return vec;
}

inline int bitnum(int S) {
	int res = 0;
	for (int i = 0; i < 30; ++i) {
		res += ((S & (1 << i)) ? 1 : 0);
	}
	return res;
}

int main(void)
{
	cin >> N >> A >> B;
	int X = A ^ B;
	if (bitnum(X) % 2 == 0) {
		//cout << "NO" << endl;
		printf("NO\n");
		return 0;
	}
	//cout << "YES" << endl;
	printf("YES\n");
	auto ans = f(X, N);
	for (int elm : ans) {
		//cout << (elm ^ A) << endl;
		printf("%d\n", elm ^ A);
	}
	fflush(stdout);
	return 0;
}


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

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    
    vector<int> cnt(26);
    for (int i = 0; i < N; i += 2) {
        cnt[S[i] - 'a'] += 1;
    }
    
    vector<int> p(10);
    for (int i = 0; i < 26; i++) {
        p[cnt[i]] += 1;
    }

    int res = 2 * p[1];
    for (int i = 2; i <= 9; i++) {
        if (p[i] == 1) {
            res += 4;
        } else if (p[i] >= 2) {
            res += 5 + 2 * p[i] - 1;
        }
    }
    cout << res - 1 << endl;    
    return 0;
}

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

int h, w;
std::vector<std::vector<char>> vec;
int main() {
    std::cin >> h >> w;
    vec.assign(h, std::vector<char>(w, 'a'));
    for (int i = 0; i < h; i++) {
        for (int p = 0; p < w; p++) {
            std::cin >> vec[i][p];
        }
    }
    std::vector<std::vector<int>> ways(h, std::vector<int>(w, 0));
    ways[0][0] = 1;
    for (int t = 0; t < h; t++) {
        for (int s = 0; s < w; s++) {
            if (t == 0 && s == 0) {
                continue;
            }
            if (vec[t][s] == '#') {
                continue;
            }
            if (t-1 >= 0 && vec[t-1][s] != '#') {
                ways[t][s] += ways[t-1][s];
            }
            if (s-1 >= 0 && vec[t][s-1] != '#') {
                ways[t][s] += ways[t][s-1];
            }
            ways[t][s] %= 1000000007;
        }
    }
    
    std::cout << ways[h-1][w-1] << std::endl;

}


Measured memory_bytes: 5248
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key))sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2052
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	float v;
	while (scanf("%f", &v) != EOF) {
		double n = (v * v / 19.6 + 5) / 5.0;
		if ((int)n != n) ++n;
		printf ("%d\n", (int)n);
	}
	return 0;
}

Measured memory_bytes: 0
void main()
{
    long n, m;
    rdVals(n, m);
    long[] a = rdRow;

    a.sort!"a > b";
    long total = a.sum;
    foreach (i; 0 .. m)
    {
        if (4 * m * a[i] < total)
        {
            "No".writeln;
            return;
        }
    }

    "Yes".writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};

int f(int x,int d){
	auto s=to_string(x);
	while(s.size()<d) s+='0';
	sort(s.begin(),s.end());
	auto t=s;
	reverse(t.begin(),t.end());
	return atoi(t.c_str())-atoi(s.c_str());
}

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vp a(n);
		int res=0;
		for(int i=0;i<n;i++){
			cin>>a[i].second>>a[i].first;
			res+=a[i].first*a[i].second;
		}
		sort(a.rbegin(),a.rend());
		for(int i=0;i<n&&m;i++){
			int t=min(m,a[i].second);
			res-=t*a[i].first;
			m-=t;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3124
s=int(input())
a=[]
a.append(0)
a.append(s)#初項a[1]
i=1
k=0
while k==0:
    if a[i]%2==0:
        a.append(a[i]/2)
    else:
        a.append(3*a[i]+1)
    i+=1
    for j in range(1,i):
        if a[j]==a[i]:
            print(i)
            k=1
            break

Measured memory_bytes: 3064
import heapq


def main():
    x, y, z, k = map(int, input().split())
    *a, = map(int, input().split())
    *b, = map(int, input().split())
    *c, = map(int, input().split())

    a = list(reversed(sorted(a)))
    b = list(reversed(sorted(b)))
    c = list(reversed(sorted(c)))

    h = []
    heapq.heappush(h, (-(a[0] + b[0] + c[0]), 0, 0, 0))
    queued = set([(0, 0, 0)])
    tastes = []
    for _ in range(k):
        t, i, j, l = heapq.heappop(h)
        tastes.append(-t)
        if i + 1 < x and (i + 1, j, l) not in queued:
            heapq.heappush(h, (-(a[i + 1] + b[j] + c[l]), i + 1, j, l))
            queued.add((i + 1, j, l))
        if j + 1 < y and (i, j + 1, l) not in queued:
            heapq.heappush(h, (-(a[i] + b[j + 1] + c[l]), i, j + 1, l))
            queued.add((i, j + 1, l))
        if l + 1 < z and (i, j, l + 1) not in queued:
            heapq.heappush(h, (-(a[i] + b[j] + c[l + 1]), i, j, l + 1))
            queued.add((i, j, l + 1))

    for t in tastes:
        print(t)


main()


Measured memory_bytes: 5076
import Control.Monad
 
main = do
  [h, w] <- map read . words <$> getLine
  ass <- replicateM h getLine
  putStrLn . take (w + 2) $ repeat '#'
  mapM_ putWithFrame ass
  putStrLn . take (w + 2) $ repeat '#'
 
putWithFrame xs = putStrLn $ "#" ++ xs ++ "#"

Measured memory_bytes: 1404
#include<stdio.h>

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x % 2 ==0) return 0;
  for(i = 3; i*i <= x; i+=2 ){
    if(x % i ==0) return 0;
  }
  return 1;
}


int main(){
  int n, x, i;
  int cnt =0;
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &x);
    if ( isPrime(x)) cnt++;
  }
  printf("%d\n",cnt);

  return 0;
}




Measured memory_bytes: 2072
# AtCoder Beginner Contest 126
# https://atcoder.jp/contests/abc126
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    a = int(S[:2])
    b = int(S[2:])
    ma = 1 <= a and a <= 12
    mb = 1 <= b and b <= 12
    if ma and mb:
        print('AMBIGUOUS')
    elif ma:
        print('MMYY')
    elif mb:
        print('YYMM')
    else:
        print('NA')

main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

double L;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>L;
	L/=3;
	_P("%.12lf\n",L*L*L);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
class UnionFind
  attr_reader :tree
  def initialize
    @tree = Hash.new { |hash, key| hash[key] = key }
  end

  def root(x)
    if @tree[x] == x
      x
    else
      @tree[x] = root(@tree[x])
    end
  end

  def same?(x, y)
    root(x) == root(y)
  end

  def unite(x, y)
    x = root(x)
    y = root(y)
    return if x == y
    @tree[x] = y
  end
end

n, k, l = gets.split.map(&:to_i)
road = UnionFind.new()
rail = UnionFind.new()
k.times do
  p, q = gets.split.map(&:to_i)
  road.unite(p, q)
end
l.times do
  r, s = gets.split.map(&:to_i)
  rail.unite(r, s)
end
roots = Array.new(n)
ans = Hash.new { |hash, key| hash[key] = 0 }
for i in 1..n do
  roots[i - 1] = [road.root(i), rail.root(i)]
  ans[roots[i - 1]] += 1
end
roots.each_with_index do |x, i|
  print " " unless i == 0
  print ans[x]
end
puts

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

using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  if(y%2==1){
    cout << "No" << endl;
  }
  else{
    
  if(4*x-y>=0&&y-2*x>=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  }
}
  

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>



#define MAX_P 10
int main(){

int N;//????????°
int M;//??????
int d,p;
int i;
int ans;
int p_p;

int dist[MAX_P+1];



while(scanf("%d %d",&N,&M) == 2 && N){


	//0??§dist????????????????????????
	memset(dist,0,sizeof(dist));

	//?????????????????¨????????????????????????
	
	//for(i=0;i<MAX_P; i++){
	//	dist[i] = 0;
	//}
	

	ans = 0;
	for(i=0; i<N; i++){

		scanf("%d %d",&d,&p);
		//?????±??????????????????p?????????0~10????????§10????????????????????£?????????????´???????????????????????±???????
		dist[p] += d; 
	}

	p_p = MAX_P;

	while(M > 0 && p_p != 0){
		
		if(dist[p_p] == 0){
			p_p--;
			continue;
		}

		dist[p_p]--;
		M--;
	}

	for(i=0; i<=MAX_P; i++){

		ans += dist[i]*i;
	}

	printf("%d\n",ans);
}

return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int a[10];

//B:=B?????????????????° C*=C?????????????????° cnt:=??????????????°??????
bool dfs(int B, int C, int cnt){
	if(cnt == 10){
		return true;
	}
	if(B < a[cnt]){
		return dfs(a[cnt], C, cnt + 1);
	}
	if(C < a[cnt]){
		return dfs(B, a[cnt], cnt + 1);
	}
	if(B > a[cnt] && C > a[cnt]){
		return false;
	}
}
int main(void){
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		rep(j, 10) cin >> a[j];
		if(dfs(0, 0, 0)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1112
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct Dscc {
public:

	//fst:belongs , scd:newedges
	pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) {
		nums.resize(edges.size());
		fill(nums.begin(), nums.end(), -1);
		vector<vector<int>>revedges(edges.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				revedges[j].push_back(i);
			}
		}
		int num = 0;
		for (int i = 0; i < edges.size(); ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(nums.size());
		for (int i = 0; i < nums.size(); ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());
		unis.resize(edges.size());
		fill(unis.begin(), unis.end(), -1);
		num = 0;
		for (int i = 0; i < big.size(); ++i) {

			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < unis.size(); ++i) {
			nums.push_back(unis[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());


		map<int, int>mp;
		for (int i = 0; i < nums.size(); ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < unis.size(); ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(nums.size());
		for (int i = 0; i < unis.size(); ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<int>>newedges(nums.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				if (unis[i] != unis[j]) {
					newedges[unis[i]].push_back(unis[j]);
				}
			}
		}
		return make_pair(belongs, newedges);
	}
private:
	vector<int>nums;
	vector<int>unis;


	void dfs(const int id, int &num, const vector<vector<int>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<int>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id])
				dfs2(i, num, edges);
		}
		unis[id] = num;
		return;
	}

}dscc;




int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<vector<int>>edges(N);
		vector<ld>sleeps;
		for (int i = 0; i < N; ++i) {
			ld p;int  m; cin >> p >> m;
			sleeps.push_back(p);
			for (int j = 0; j < m; ++j) {
				int a; cin >> a; a--;
				edges[a].push_back(i);
			}
		}
		auto p = dscc.get(edges);
		auto nextedges(p.second);
		auto nextbelongs(p.first);
		vector<ld>nextsleeps(nextbelongs.size());
		for (int i = 0; i < nextsleeps.size(); ++i) {
			ld per = 1;
			for (int j = 0; j < nextbelongs[i].size(); ++j) {
				per *= sleeps[nextbelongs[i][j]];
			}
			nextsleeps[i] = 1-per;
		}
		ld ans = 1;
		for (int i = 0; i < nextedges.size(); ++i) {
			if (nextedges[i].size() == 0)ans *= nextsleeps[i];
		}
		cout <<fixed<<setprecision(10)<< ans << endl;
	}
	return 0;
}

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




int main(){
  int x,a,b;
  cin >> x >> a >> b;
  int s,t;

  s = abs(a-x);
  t = abs(b-x);

  if(s > t){
    cout << "B" << endl;
      }
  else{
    cout << "A" << endl;
  }

  }

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

int main() {
   int N;
   cin>>N;
   int temp=N;
   vector<int> moti(N);
   for(int i=0;i<N;i++){
       cin>>moti.at(i);
   }sort(moti.begin(),moti.end());
   for(int j=0;j<=N-2;j++){
       if(moti.at(j)==moti.at(j+1)){
          temp--;
       }
   }cout<<temp<<endl;
}


Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

ll a, b, c, n, k, x;
string s;

int main()
{
  ll k, s;
  cin >> k >> s;
  ll count = 0;

  for (ll x = 0; x <= k; x++)
  {
    for (ll y = 0; y <= k; y++)
    {
      ll num = s - x - y;
      if (num >= 0 && num <= k)
      {
        count++;
      }
    }
  }
  cout << count << endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    int x, a , b;
    cin >>  x >> a >> b;

    int am = min(abs(x-a), abs(x-b));
    if(abs(x-a) == am)
        cout << "A";
    else
        cout << "B";
    cout << "\n";


    return 0;
}



Measured memory_bytes: 256
S=input()
Q=int(input())

guuki=0
ANS=S
ANS_back=""
ANS_front=""
for i in range(Q):
    A=list(input().split())
    if A[0]=="1":
        guuki+=1
    elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):
        ANS_back+=A[2]
    else:
        ANS_front+=A[2]
if guuki%2==1:
    ANS=ANS[::-1]
    ANS_back,ANS_front=ANS_front,ANS_back
print(ANS_front[::-1]+ANS+ANS_back)

Measured memory_bytes: 4412
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	//long long n, A[1000000000];
	//string s;
	cin >> a;
	if (a%2==0)
	{
		cout << a << endl;

	}
	else
	{
	cout << a*2 << endl;

	}



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int k;
    cin >> k;
    if(k % 2){
        pr((k/2)*(k/2+1));
    }else{
        pr((k/2)*(k/2));
    }
}

Measured memory_bytes: 256
x, y  = map(int, input().split())

if y % 2 == 1:
  print('No')
else:
  k = y // 2
  if k < x:
    print('No')
  else:
    b = k - x
    a = x - b
    if a < 0:
      print('No')
    else:
      print('Yes')

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

int N, K;
string s[15];

set<string>st;

int dfs(string w, int bit, int k)
{
  if(k == K) {
    if(st.find(w) == st.end()) {
      st.insert(w);
      return 1;
    }else {
      return 0;
    }
  }
  int ret = 0;
  Rep(i,N) {
    if(!((bit >> i) & 1)) {
      ret += dfs(w + s[i], bit | (1 << i), k + 1);
    }
  }
  return ret;
}
  

int main()
{
  while(cin >> N >> K,N || K) {
    Rep(i,N) cin >> s[i];
    cout << dfs("",0,0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	cout << max(ll(0),a-2*b);
	// your code goes here
	return 0;
}

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

char a[10];
int main(){
	cin >> a;

	for(int i = 0;i < 4;i++) {
        a[i] -= '0';    //aを文字コードから数字に変換する処理を書く
	}

	for(int i = 0;i < (1 << 3)/* +か-かを3回選ぶ時何回繰り返すのか？ */;i++) {

		int sum = a[0];    //計算結果を入れる変数を用意して、適切な値で初期化しよう。

		for(int j = 0;j < 3 /*計算する回数はいくらかな? */;j++) {
			if(i & (1 << j)/*演算子が+だったら*/) {
				sum += a[j+1];    //14行目で宣言した変数に値を加算代入
			}else {
				sum -= a[j+1];    //14行目で宣言した変数に値を減算代入
			}
		}

		if(sum == 7/*計算結果が7だったら*/) {
			cout << (int)a[0];   //第一項を出力
			for(int j = 0;j < 3/*演算子を出力する回数はいくつか？*/;j++) {
				if(i & (1 << j)/*演算子が+だったら*/) {
					cout << "+" ;   // +を出力
				}else {
				    cout << "-" ;	// -を出力
				}
				cout << (int)a[j+1] ;    //演算子の右の数字を出力
			}
			cout << "=7\n" ;    //=7改行 を出力
			break;  //見つかったので終了する。
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.time.chrono.MinguoChronology;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int min = in.nextInt();
      int second = in.nextInt();
      int max = in.nextInt();
      int swap = 0;
      
      if (min > second) {
        swap = min;
        min = second;
        second = swap;
      }
      if (min > max) {
        swap = min;
        min = max;
        max = swap;
      }
      if (second > max) {
        swap = max;
        max = second;
        second = swap;
      }
      out.println(min+" "+second+" "+max);
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> a(3 * n);
	FOR(i,0,3 * n)cin >> a[i];
	sort(ALL(a));
	ll ans = 0;
	FOR(i,0,n)ans += a[3 * n - 2 - 2 * i];
	ANS(ans);
	return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b, t;
    scanf("%d%d%d", &a, &b, &t);
    t /= a;
    printf("%d\n", t * b);
	return 0;
}


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


int main(){
	ll n;
	cin>>n;
	ll a[n+5];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll len=0;
	ll max_len=0;
	for(ll i=1;i<n;i++){
		if(a[i-1]>=a[i]){
			//cout<<i<<" "<<len<<endl;
			len++;
			if(len>max_len){
				max_len=len;
			}
		}
		else{
				len=0;
			}
	}
	if(len>max_len){
		max_len=len;
	}
	cout<<max_len<<endl;
	return 0;
}
				





Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int S = sc.nextInt();
		int W = sc.nextInt();
      	
		if(S<=W){
        	System.out.println("unsafe");
        }
        else{
        	System.out.println("safe");
        }
	}
}

Measured memory_bytes: 27088
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int n;

    while(cin >> n && n) {
        map<char,char> ch;
        rep(i,n) {
            char a,b;
            cin >> a >> b;

            ch[a] = b;
        }

        int m;
        cin >> m;

        rep(i,m) {
            char c;
            cin >> c;

            if(ch.find(c) == ch.end()) cout << c;
            else cout << ch[c];
        }
        cout << endl;
    }

    return 0;
}

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


int main(){
    int n;cin>>n;
    vector <ll> d(n);
    rep(i,n)cin>>d.at(i);
    int m;cin>>m;
    vector<ll> t(m);
    rep(i,m)cin>>t.at(i);
    multiset<int> ans;


    rep(i,n){
        ans.insert(d[i]);
    }
    rep(i,m){
        if(ans.count(t[i])){
            ans.erase(ans.find(t[i]));
        }
        else {
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
}


Measured memory_bytes: 12800
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N,M; cin >> N >> M;
	cout << N*(N-1)/2 + M*(M-1)/2 << ln;
}


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

using ll = long long;
using ld = long double;

const int nax = 1e5+20;
const  int mod =  1e9+7;


//Modular Addition
inline void add_self(int& a, int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}

//Modular Subtraction
inline void sub_self(int& a , int b){
    a -= b;
    if(a < 0)
        a+= mod;
}





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

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

    vector<int>dp(k+1);

    dp[0] = 1;

    for(int child = 0; child < n; child++) {
        int upto;
        cin >> upto;
        vector<int>fake(k+1);
        for (int used = k; used >= 0; --used) {
            int L = used+1;
            int R = used + min(upto, k - used);
            int tmp = dp[used];
            if (L <= R) {
                add_self(fake[L], tmp);
                if (R + 1 <= k) {
                    sub_self(fake[R + 1], tmp);
                }
            }

        }
        int prefix_sum = 0;

        for(int i = 0; i <= k; ++i){
            add_self(prefix_sum,fake[i]);
            add_self(dp[i],prefix_sum);
        }
    }

    cout<<dp[k];







}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

#define rep(i, s, e) for(ll i=(s); i<(e); i++)
const ll LL_MAX (1LL << 60);

using namespace std;

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

    vector<ll> r(n);

    rep(i, 0, n) cin >> r[i];

    ll min(LL_MAX); 
    ll profit (-LL_MAX);
    rep(i,0,n-1)
    {
        if (min > r[i])
            min = r[i];

        ll p = r[i+1]-min;

        if (p > profit)
        profit = p;
    }

    cout << profit << endl;    

    return 0;
}



Measured memory_bytes: 4340
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		int result = Integer.MAX_VALUE;
		boolean isZero = false;
		ArrayList<Integer> list = new ArrayList<Integer>();
		int cnt = 0;
		int sum = 0;
		for(int i = 0; i < s.length(); i++){
		    if(i == 0){
		        if(s.charAt(i) == '0') isZero = true;
		    }
		    if((s.charAt(i) == '0' && isZero)||(s.charAt(i) == '1' && !isZero)){
		        cnt++;
		    }else{
		        list.add(cnt);
		        sum += cnt;
		        cnt = 1;
		        isZero = !isZero;
		    }
		}
		list.add(cnt);
		sum += cnt;
		if(list.size() == 1){
		    result = list.get(0);
		}else{
		    int temp = 0;
		    for(int i = 0; i < list.size(); i++){
		        temp += list.get(i);
		        result = min(result, max(sum - temp, temp));
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 26260
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>
#include <functional>

using namespace std;
typedef long long int ll;
//考察が詰めきれず難しかった.
//クソコードにより添字地獄が発生して無限バグらせ死亡
int main(){

    ll N, A, B;
    cin >> N >> A >> B;
    if(N == 2){
        cout << "Borys" << endl;
    }else if(A == B - 1){
        cout << "Borys" << endl;
    }else if((B - A - 1) % 2 == 0 ){
        cout << "Borys" << endl;
    }else{
        cout << "Alice" << endl;
    }
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define lld_max 5000000000000000000
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>n; vec v;
        for(i=0;i<n;i++)
        {
            cin>>p>>q;
            if(p==q) v.pb(i);
        }
        if(v.size()<3)
            cout<<"No"<<endl;
        else
        {
            x = v.size();
            for(i=0;i<=x-3;i++)
            {
                if(v[i]+1 == v[i+1] && v[i+1]+1 == v[i+2])
                    flag=true;
            }
            if(flag) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3656
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val n = s.length
    val conv = mutableMapOf<Char, Char>()
    val convR = mutableMapOf<Char, Char>()

    var ans = true
    repeat(n) {
        if (conv[s[it]] == null) {
            conv[s[it]] = t[it]
        } else {
            if (conv[s[it]] != t[it]) ans = false
        }
        if (convR[t[it]] == null) {
            convR[t[it]] = s[it]
        } else {
            if (convR[t[it]] != s[it]) ans = false
        }
    }

    if (ans) println("Yes")
    else println("No")
}


Measured memory_bytes: 36708
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= H && A[r] > A[largest] ) largest = r;

  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if ( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n' ) break;
    if ( com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
  }

  return 0;
}


Measured memory_bytes: 6480
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=3000;

signed main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<(b-a==c-b?"YES":"NO")<<endl;
}

Measured memory_bytes: 256