akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
typedef pair<int,int> P;
string alph="abcdefghijklmnopqrstuvwxyz";
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
    int n;cin>>n;
    int count=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        count+=b-a+1;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
#include<set>
using namespace std;
char in[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	while(n){
		if(n>=5&&in[n-5]=='d'&&in[n-4]=='r'&&in[n-3]=='e'&&in[n-2]=='a'&&in[n-1]=='m'){
			n-=5;
			continue;
		}
		if(n>=7&&in[n-7]=='d'&&in[n-6]=='r'&&in[n-5]=='e'&&in[n-4]=='a'&&in[n-3]=='m'&&in[n-2]=='e'&&in[n-1]=='r'){
			n-=7;
			continue;
		}
		
		if(n>=5&&in[n-5]=='e'&&in[n-4]=='r'&&in[n-3]=='a'&&in[n-2]=='s'&&in[n-1]=='e'){
			n-=5;
			continue;
		}
		if(n>=6&&in[n-6]=='e'&&in[n-5]=='r'&&in[n-4]=='a'&&in[n-3]=='s'&&in[n-2]=='e'&&in[n-1]=='r'){
			n-=6;
			continue;
		}
		break;
	}
	if(n)printf("NO\n");
	else printf("YES\n");
}

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<double> vt(n);
    double s=0, M=0;
    rep(i,n) {
        int p;
        cin >> p;
        vt.at(i) = p+1;
    }
    rep(i,k) s += vt.at(i);
    M = s;
    for(int i=0; i<n-k; ++i) {
        s = s - vt.at(i) + vt.at(i+k);
        M = max(M,s);
    }
    M /= 2;
    cout << fixed << setprecision(10) << M << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
x = [0]*(n)
y = [0]*(n)
for i in range(n):
  a = int(input())
  x[i] = [0]*a
  y[i] = [0]*a
  for j in range(a):
    x[i][j], y[i][j] = map(int, input().split())

A = 0
for i in range(2**n):
  flag = 0
  ans = 0
  num = list(format(i, '0{}b'.format(n)))
  for j, k in enumerate(num):
    if k == "1":
      ans += 1
      for l, m in zip(x[j], y[j]):
        if num[l-1] != "{}".format(m):
          flag = 1
          break
    if flag == 1:
      break
  if flag == 0:
  	A = max(A,ans)
print(A)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] dp = new int[h+1];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			for(int j=1;j<=h;j++) {
				if(0<=j-a)
					dp[j] = Math.min(dp[j], dp[j-a]+b);
				else
					dp[j] = Math.min(dp[j], b);
			}
		}
		
		System.out.println(dp[h]);
	}
}

Measured memory_bytes: 25664
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;

int const MAXN=110000;
int const MAXM=110000;
int N,M;
vector<int> events[MAXN];
bool disc[MAXM];
stack<int> st;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  cin>>N>>M;
  rep(i,1,M+1) {
    int a,b;
    cin>>a>>b;
    events[a].push_back(i);
    events[b].push_back(-i);
  }

  int res=0;
  rep(i,1,N+1) {
    sort(events[i].begin(),events[i].end());
    for (int e:events[i]) {
      if (e>0) {
        st.push(e);
        continue;
      }

      if (disc[-e]) {
        continue;
      }

      res++;
      while (!st.empty()) {
        disc[st.top()]=true;
        st.pop();
      }
    }
  }
  cout<<res<<"\n";
}


Measured memory_bytes: 6400
#include<iostream>

using namespace std;

int max(int a,int b)
{
	if(a>b)
		return a;
	else
		return b;
}


int main()
{
	int n,i,t1,t2,t3;
	cin >> n;
	int dp[n+1][3];

	int a[n+1],b[n+1],c[n+1],d[n+1] = {},cost[n+1];

	for(i=1;i<=n;i++)
		cin >> a[i] >> b[i] >> c[i];

	dp[1][0]=a[1];
	dp[1][1]=b[1];
	dp[1][2]=c[1];

	for(i=2;i<=n;i++)
	{
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
	}

	cout << max(max(dp[n][0],dp[n][1]),max(dp[n][1],dp[n][2])) << endl;

}

Measured memory_bytes: 2944
n,m,x,y=map(int,input().split())
xs=list(map(int,input().split()))
ys=list(map(int,input().split()))
xs.sort()
ys.sort()
res = 'War'
for z in range(x+1,y+1):
    if xs[n-1] < z and ys[0] >= z:
        res = 'No War'
print(res)
        



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int a_find,z_find;
  int n=S.size();
  for(int i=0;i<n;i++){
    if(S.at(i)=='A'){
      a_find=i;
      break;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(S.at(i)=='Z'){
      z_find=i;
      break;
    }
  }
  cout << z_find-a_find+1 << endl;
}
      

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        ll tmp;
        cin >> tmp;
        if (tmp >= k) {
            ++cnt;
        }

    }
    cout << cnt;

    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int K,T; cin >>K >>T;
  priority_queue<int> pq;
  rep(i, T){ int a; cin >>a; pq.push(a);}
  int res = 0;
  int pqtop = pq.top(); pq.pop();
  while (true){
    if (!pq.empty()){
      int buf = pq.top(); pq.pop();
      if (pqtop>1) pq.push(pqtop-1);
      pqtop = buf;
    }else{
      res += pqtop-1;
      break;
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
import math
L=int(input())-1
  
if L==0:
  print(2,2)
  print(1,2,0)
  exit()
elif L==1:
  print(2,2)
  print(1,2,0)
  print(1,2,1)
  exit()

L2=int(math.log2(L))
LLL=2**(L2-1)
lll=LLL*2-1

branch_list=[]
for x in range(1,L2+1):
  branch_list.append([x,x+1,0])
  branch_list.append([x,x+1,LLL])
  LLL//=2


lll+=1
while True:
  ls=L-lll
  if ls<=0:
    branch_list.append([1,L2+1,lll])
    break
  else:
    ls2=int(math.log2(ls))
    branch_list.append([1,L2+1-ls2,lll])
    lll+=2**ls2

print (L2+1,len(branch_list))
for x,y,z in branch_list:
  print (x,y,z)


Measured memory_bytes: 3064
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_H = 100, MAX_W = 100;
int H, W, N;

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

    int ma = max(H, W);


    cout << (N + ma - 1) / ma << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){	

	int a, b, c, ctr = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(; a<=b; a++ ){
		if(a%c==0) {
			ctr++;
  		}
 	}
	printf("%d\n", ctr);
		return 0;
}

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

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += S.at(i) * S.at(j);
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int n,m,i;
    long long int sum=0;
    cin>>n>>m;
    int *amount=new int [n];
    for(i=0;i<n;i++) cin>>amount[i];
    sort(amount,amount+n,greater<int>());
    for(i=0;i<m;i++)
    {
        amount[0]/=2;
        if(n>=1000) sort(amount,amount+1000,greater<int>());
        else sort(amount,amount+n,greater<int>());
        if((i+1)%1000==0) sort(amount,amount+n,greater<int>());
    }
    for(i=0;i<n;i++) sum+=amount[i];
    cout<<sum;
    delete [] amount;
    return 0;
}


Measured memory_bytes: 640
import numpy as np # sin/cos、円周率のため

a,b,h,m = map(int, input().split())

ab_time = h + (m / 60)
rad_a = np.pi * ab_time / 6
rad_b = np.pi * ab_time * 2
rad_ab = rad_b - rad_a

ll = a**2 + b**2 - 2 * a * b * np.cos(rad_ab)
l = ll**0.5

print(str(l))

Measured memory_bytes: 27204
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<utility>
#include<queue>
using namespace std;

int N, M, dp[1 << 21], toy[100005], sum[22][100005] = {}, cnt[22] = {};

int main() {
	//input
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> toy[i];
		cnt[toy[i]]++;
		sum[toy[i]][i]++;
		for (int j = 1; j <= M; j++) sum[j][i] += sum[j][i - 1];
	}

	//bitdp
	for (int i = 0; i < (1 << M); i++) dp[i] = 999999;
	dp[0] = 0;
	for (int i = 0; i < (1 << M); i++) {
		int ntc = 0;//now toy count
		for (int j = 1; j <= M; j++)if (i&(1 << (j - 1)))ntc += cnt[j];
		for (int j = 1; j <= M; j++) {
			if (i&(1 << (j - 1))) continue;
			int diff = sum[j][ntc + cnt[j]] - sum[j][ntc];//toy j of true lange
			diff = cnt[j] - diff;
			dp[(i | (1 << (j - 1)))] = min(dp[(i | (1 << (j - 1)))], dp[i] + diff);
		}
	}
	cout << dp[(1 << M) - 1] << endl;
	return 0;
}


Measured memory_bytes: 15364
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class Pair{
		long x;
		int y;
		Pair(long x, int y){
			this.x=x;
			this.y=y;
		}
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Pair> pl = new ArrayList<>();
		for(long i=2; i*i<=n; i++) {
			int cnt=0;
			while(n%i==0) {
				n /= i;
				cnt++;
			}
			pl.add(new Pair(i, cnt));
		}
		if(n != 1) {
			pl.add(new Pair(n, 1));
		}

		int ans = 0;
		for(Pair p : pl) {
			int cnt = p.y;
			int i = 1;
			while(i<=cnt) {
				cnt -= i;
				i++;
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}


}

Measured memory_bytes: 77788
from collections import deque

n = int(input())
g = []
d = [10**10] * n
d[0] = 0

for i in range(n):
    temp = list(map(int, input().split()))
    k = temp[1]
    temp = temp[2:]
    adj = []
    for j in range(k):
        v, c = temp[j*2], temp[j*2+1]
        adj.append([v, c])
    g.append(adj)

# for i in range(n):
#     print(g[i])

q = deque()
# Add tupple of prev and adj into Queue
q.append((0, g[0]))
done = set()

while q:
    node = q.popleft()
    prev = node[0]
    adj = node[1]
    # print('\nadj:', adj)

    for next in adj:
        v = next[0]
        w = next[1]
        # print('v:', v)
        # print('prev:', prev)

        # d[v] = min(d[v], d[prev] + w)
        if d[prev] + w < d[v]:
            d[v] = d[prev] + w
            # Need to add to Queue regardless of it's in done or not,
            # because the shortest path was updated.
            q.append((v, g[v]))
        if v not in done:
            done.add(v)
            q.append((v, g[v]))

# print('d:', d)

for i in range(len(d)):
    print(i, d[i])


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

int main() {
	// your code goes here
	int n;
	cin >> n;
    vector<int> A(n,0);
    vector<int> B(n,0);
    vector<int> C(n-1,0);
    for(int i=0 ; i<n ; i++)
    {
        int temp;
        cin >> temp;
        A[i]=(temp);
    }
     for(int i=0 ; i<n ; i++)
    {
        int temp;
        cin >> temp;
        B[i]=temp;
    }
     for(int i=0 ; i<n-1 ; i++)
    {
        int temp;
        cin >> temp;
        C[i]=(temp);
    }
    int sum=0;
    for(int i=0 ; i<n ; i++)
    {
        sum+=B[A[i]-1];
        if(i<(n-1) && A[i+1]==(A[i]+1))
        {
            sum+=C[A[i]-1];
        }
    }
    cout << sum ;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <chrono>
#include <ctime>
#include <climits>
#include <stack>
#include <array>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace
#define y0 withindarkness
#define y1 apinklotusbloomed
#define yn carryingapurplesoul
#define j1 togetherformingtheTeam

void useiostream() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(8);
}

void drop(char const* bu) {
	printf("%s", bu);
	exit(0);
}

ull gcd(ull a, ull b) {
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ld const pi = acos(-1.0L);
ld const eps = 0.0001L;

template<typename T, typename TT> bool mi(T& a, TT b) { return a > b ? (a = b, true) : false; }
template<typename T, typename TT> bool ma(T& a, TT b) { return a < b ? (a = b, true) : false; }

mt19937 ran(996);

int const mod = 1000000007;

ull bm(ull a, ull p, ull mod) {
	return (a * p - (ll)((ld)a * p / mod) * mod + mod) % mod;
}

ull bp(ull a, ull p, ull mod) {
	ull re = 1;
	while (p) {
		if (p & 1)re = bm(re, a, mod);
		p >>= 1;
		a = bm(a, a, mod);
	}
	return re;
}



int main() {
	useiostream();
#ifdef _DEBUG
	(void)freopen("input.txt", "r", stdin);
	(void)freopen("output.txt", "w", stdout);
#else
	//(void)freopen("bisector.in", "r", stdin);
	//(void)freopen("bisector.out", "w", stdout);
#endif

	int n;
	string a, b;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cout << a[i] << b[i];
	}


	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;
  std::vector<std::map<int64_t, int64_t>> no(n);
  std::set<std::pair<int64_t, int64_t>> ans;

  for (int64_t i = 0; i < m; i++) {
    int64_t a, b, c;
    std::cin >> a >> b >> c;
    a--;
    b--;
    no[b].insert({a, c});
    no[a].insert({b, c});
    ans.insert({a, b});
  }

  for (int64_t i = 0; i < n; i++) {
    std::vector<int64_t> f(n, -1);
    f[i] = 0;
    std::multimap<int64_t, std::pair<int64_t, int64_t>> q;
    for (const auto j : no[i]) {
      q.insert({j.second, {i, j.first}});
    }
    while (!q.empty()) {
      const auto &tmp = *q.cbegin();
      const auto cost = tmp.first;
      const auto before = tmp.second.first;
      const auto now = tmp.second.second;
      q.erase(q.begin());
      if (f[now] == -1 || cost <= f[now]) {
        f[now] = cost;
        ans.erase({now, before});
        ans.erase({before, now});
        for (const auto k : no[now]) {
          const auto next = k.first;
          const auto next_cost = cost + k.second;
          if (f[next] == -1 || next_cost <= f[next]) {
            f[next] = next_cost;
            q.insert({next_cost, {now, next}});
          }
        }
      }
    }
  }
  std::cout << ans.size() << std::endl;
  return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var H = long.Parse(Console.ReadLine());
            long numEnemy = 1;
            long attackCount = 0;
            while (H != 1)
            {
                attackCount += numEnemy;
                numEnemy *= 2;
                H /= 2;
            }
            Console.WriteLine(numEnemy + attackCount);
        }
    }
}

Measured memory_bytes: 13140
s = input()
l = ["KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA", "AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"]
if s in l:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 2940
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
a, b = int(s[:2]), int(s[2:])
if 0 < a < 13:
  if 0 < b < 13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0 < b < 13:
    print('YYMM')
  else:
    print('NA')






Measured memory_bytes: 27048
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    print(sum([1 for a in aa[0::2] if a%2 == 1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
/**
 * @author torith
 * @date 2018-10-30
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

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

    for (int i = 0; i < N; ++i) {
        int B[27] = {};
        string s; cin >> s;
        for (int j = 0; j < s.length(); ++j) {
            B[s[j] - 'a'] += 1;
        }

        for (int j = 0; j < 27; ++j) {
            A[j] = min(A[j], B[j]);
        }
    }

    string ans = "";
    for (int i = 0; i < 27; ++i) {
        if(A[i] > 0) {
            for (int j = 0; j < A[i]; ++j) {
                ans += (char) ('a' + i);
            }
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, q;
    cin >> n >> q;
    vl s(n), t(n), x(n);
    deque<tuple<ll, ll, ll>> events;
    for (int i = 0; i < n; ++i) {
        cin >> s[i] >> t[i] >> x[i];
        events.emplace_back(s[i] - x[i], 1, x[i]);
        events.emplace_back(t[i] - x[i], -1, x[i]);
    }
    sort(events.begin(), events.end());
    vl d(q);
    for (int i = 0; i < q; ++i) {
        cin >> d[i];
    }
    ll time = 0;
    set<ll> stop;
    for (int i = 0; i < q; ++i) {
        while (true) {
            if (events.empty())
                break;
            auto e = events.front();
            if (get<0>(e) <= d[i]) {
                ll flag = get<1>(e);
                if (flag == 1) {
                    stop.insert(get<2>(e));
                } else {
                    stop.erase(get<2>(e));
                }
                events.pop_front();
            } else {
                break;
            }
        }
        if (stop.empty())
            cout << -1 << "\n";
        else
            cout << *stop.begin() << "\n";
    }

    return 0;
}

Measured memory_bytes: 21904
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m, i, j, k,o,l,z;
ll a[100005], inf = 1000000000000;
map<ll, ll> b;
string s;
ll t[100005], xx[100005];
ll p[10], q[10], r[10] = {}, aa[10] = {};
char ss,st;
int main() {
	cin >> ss ;
	st = char(int(ss) + 1);
	cout << st;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,h,i,max,cnt=1;
	scanf("%d %d",&n,&h);
	max=h;
	for(i=1;i<n;i++){
		scanf("%d",&h);
		if(max<=h){
			cnt++;
			max=h;
		}
	}
	printf("%d",cnt);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int a=0,b=0;
  for(int i=0; i<s.length(); i++) {
    if(s[i]=='0') {
      a++;
    }
    else {
      b++;
    }
  }
  cout << min(a,b)*2 << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 50388
#include <iostream>
#include <cmath>
#include <string>
#include <queue>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <string.h>
#include <stack>
#include <cstdio>

using namespace std;
typedef long long ll;
const int mod=1000000007;
const int maxn=100007;

typedef struct node{
    int x,y;
};
int vis[100100];
typedef struct bian{
    int l,r,we;
};
//bian ss[100100];
 int fan(int x)
 {
     if(x==1)
        return 0;
     else
        return 1;
 }
 queue<bian> qu[100100];
 void dfs(int x)
 {
     while(!qu[x].empty())
     {
         bian a=qu[x].front();
         qu[x].pop();
         if(a.we%2==1)
         {
             vis[a.r]=fan(vis[x]);
         }
         else
            vis[a.r]=vis[x];
        dfs(a.r);
     }
 }

int main()
{
    int n;
    scanf("%d",&n);
    vis[1]=0;
    //int l,r,we;
    for(int i=0;i<n-1;i++)
    {
        bian x;
        scanf("%d%d%d",&x.l,&x.r,&x.we);
        qu[x.l].push(x);
        swap(x.l,x.r);
        qu[x.l].push(x);
    }
    dfs(1);
    for(int i=1;i<=n;i++)
        printf("%d\n",vis[i]);
    return 0;
}


Measured memory_bytes: 73344
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

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


}

Measured memory_bytes: 3652
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.StreamTokenizer

class B

fun main( args: Array<String> ) {
    val st = StreamTokenizer( BufferedReader( InputStreamReader( System.`in` ) ) )
    val n = st.nextInt()
    val k = st.nextInt()
    val a = LongArray( n, { st.nextInt().toLong() } )
    var s = LongArray( n * ( n + 1 ) / 2 )
    var curLen = 0
    for ( i in a.indices ) {
        var sum = 0L
        for ( j in i .. a.lastIndex ) {
            sum += a[j]
            s[curLen ++] = sum
        }
    }
    var r = 0L
    for ( p in 40 downTo 0 ) {
        val newS = LongArray( curLen )
        var cur = 0
        for ( sum in s ) {
            if ( ( sum and ( 1L shl p ) ) > 0 ) {
                newS[cur ++] = sum
            }
        }
        if ( cur >= k ) {
            s = newS
            curLen = cur
            r += 1L shl p
        }
    }
    println( r )
}

private fun StreamTokenizer.nextInt(): Int {
    nextToken()
    return nval.toInt()
}


Measured memory_bytes: 46404
use std::io;
use std::io::BufRead;

fn main() {
  let stdin = io::stdin();
  let input = stdin.lock().lines().skip(1).next().unwrap().unwrap();
  let xs = input.trim()
    .split_whitespace()
    .map(|x| x.parse::<i64>().unwrap())
    .collect::<Vec<_>>();

  let min = xs.iter().min().unwrap();
  let max = xs.iter().max().unwrap();
  let sum = xs.iter().sum::<i64>();

  println!("{} {} {}", min, max, sum);
}


Measured memory_bytes: 5044
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	ans := n*(n-1)/2 + m*(m-1)/2
	fmt.Println(ans)
}


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

int main(){
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2==1){
        cout << 1;
    }else{
        cout << 0;
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

	ll N=in<ll>();
	auto E=enum_div(N);
	map<ll,ll> M;
	for(auto& x:E){
		ll v=x;
		ll n=0;
		while(v){
			n++;
			v/=10;
		}
		M[x]=n;
	}
	
	ll minV=1LL<<60;
	for(auto& x:E){
		ll y = N/x;
		minV = min(minV,max(M[x],M[y]));
	}
	out(minV);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n - 1);
  vector<int> ans(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a.at(i);
    ans.at(a.at(i) - 1)++;
  }
  
  for (int i = 0; i < n; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 4844
class Main
  def self.main lines
    hh,ww = lines[0].split.map(&:to_i)
    h,w = lines[1].split.map(&:to_i)
    (hh*ww-h*ww-hh*w+h*w).to_s
  end
end

if $0 == __FILE__
  $stdout = open('/dev/null', 'w')
  r = Main.main STDIN.readlines
  $stdout = STDOUT
  puts r
end

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, q;
    string s;
    cin >> n >> s >> q;
    for (Int i = 0; i < q; i++) {
        Int len;
        cin >> len;
        Int res = 0;
        Int cur = 0;
        Int d, m, c, dm, mc, dmc;
        d = m = c = dm = mc = dmc = 0;
        while (cur < len) {
            if (s[cur] == 'D') {
                d++;
            } 
            if (s[cur] == 'M') {
                m++;
                dm += d;
            } 
            if (s[cur] == 'C') {
                c++;
                mc += m;
                dmc += dm;
            }
            cur++;
        }
        res += dmc;
        while (cur < n) {
            if (s[cur - len] == 'D') {
                d--;
                dm -= m;
                dmc -= mc;
            }
            if (s[cur - len] == 'M') {
                m--;
                mc -= c;
            }
            if (s[cur - len] == 'C') {
                c--;
            }
            if (s[cur] == 'D') {
                d++;
            }
            if (s[cur] == 'M') {
                m++;
                dm += d;
            }
            if (s[cur] == 'C') {
                c++;
                mc += m;
                dmc += dm;
                res += dm;
            }
            cur++;
        }
        dump(res);
    }
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;


int main() {
  string S; cin>>S;
  if(S.at(S.size()-1)=='s') S+="es";
  else  S+="s";
  cout<<S;
}


Measured memory_bytes: 3624
Menu = [int(input()) for _ in range(5)]

# 最下位桁の値が0以外で最も小さい料理を最後に届けさせる
lsd = 10  # 最下位桁の値
lsd_min_index = -1
for k, time in enumerate(Menu):
    if time % 10 < lsd and not time % 10 == 0:
        lsd = time % 10
        lsd_min_index = k
ans = 0
for k, time in enumerate(Menu):
    if k == lsd_min_index or time % 10 == 0:
        ans += time
    else:
        ans += time // 10 * 10 + 10  # 1の位を切り上げ
print(ans)

Measured memory_bytes: 3064
let [| a; b; c; d|] = stdin.ReadLine().Split()|>Array.map int64

// 最大公約数
let rec gcd x y = 
    let (x,y) = if y > x then (y,x) else (x,y)
    match x,y with
    | _ when x % y = 0L -> y
    | _ -> gcd y (x % y)

// 最小公倍数
let lcm x y = x / gcd x y * y

// B以下の割り切れない個数
let ans downX =
    downX - (downX / c + downX / d - downX / lcm c d)

ans b - ans (a-1L) |> stdout.WriteLine

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

long long int n;
string s;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>s;
	if (s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes";else cout<<"No";
}


Measured memory_bytes: 3628
#include<stdio.h>
#define MAX 500000
#define SENTINEL 1000000001

int S[MAX+1],n,cnt;
int L[(MAX/2)+1],R[(MAX/2)+1];

void merge( int left, int mid, int right ){
	int i,j,k;
	int n1=mid-left;
	int n2=right-mid;

	for( i = 0; i < n1; i++ ) {
    	L[i]=S[left+i];
    }
	for( i = 0; i < n2; i++ ) {
    	R[i]=S[mid+i];
    }
    
	L[n1]=R[n2]=SENTINEL;
	i=j=0;
	for( k = left; k < right; k++ ) {
		cnt++;
		if( L[i] <= R[j]) 
			S[k]=L[i++];
		else 
			S[k]=R[j++];
    }
	return;
}

void mergeSort(int left, int right){	
	int mid;
	if( left+1 < right) {
		mid=(left+right)/2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
	return;
}


int main() {
    scanf("%d", &n );
    
	int i;
	for( i=0; i<n; i++ ) {
		scanf("%d", &S[i] );
	}
	cnt=0;
	mergeSort( 0, n );

	for( i = 0; i < n; i++ ) {
		printf("%d", S[i] );
		if( i < n-1 ) 
		    printf( " " ); 
	}
	printf("\n%d\n", cnt);
	
    return 0;
}



Measured memory_bytes: 5604
//Solution by NurlashKO
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <list>
#include <map>

using namespace std;

typedef long long ll;
const int sz = 1e6;
#define pb push_back

long long n, x, a[sz], d[sz];
vector <ll> b[sz];
ll ans;

ll get(ll k) {
    int c = 0;
    ll res = 0;
    for (int i = 0; i < k; i++) b[i].clear();
    for (int i = n; i >= 1; i--) {
        if (!b[c].empty()) {
            res += (b[c].back() - a[i]) * (b[c].size() + 1) * (b[c].size() + 1);
        } else {
            res += a[i];
        }
        b[c].pb(a[i]);
        c = (c + 1) % k;
    }
    for (int i = 0; i < k; i++) res += b[i].back() * (b[i].size() + 1) * (b[i].size() + 1);
    return res + x * n + x * k;
}



int main() {
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll l = 1, r = n;
    while (r - l > 4) {
        int m1 = l + (r - l ) / 3;
        int m2 = r - (r - l) / 3;
        if (get(m1) > get(m2))
            l = m1;
        else
            r = m2;
    }

    ans = 1e18;
    for (; l <= r; l++) {
        ans = min(ans, get(l));
    }

    cout << ans;
}


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

int main() {
	long long X;
	cin >> X;
	for (int i = 0; i <= 2000; i++) {
		for (int j = -2000; j <= 2000; j++) {
			long long tmp = pow(i, 5) - pow(j, 5);
			if (tmp == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

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

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  int ans = 0;
  for (int i = 1; i < N; i++)
  {
    if (S.at(i - 1) != S.at(i)) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        Integer[] p = new Integer[n];
        for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		for(int a = 0; a < 1000; a++) {
			if(!(Arrays.asList(p).contains(x - a))){
			System.out.println(x - a);
			return;
			}
			else if(!(Arrays.asList(p).contains(x + a))){
			System.out.println(x + a);
			return;
			}
		}
	}
}

Measured memory_bytes: 35964
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <iomanip>

using namespace std;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

vector<pair<ll, ll>> pF;


void prime_fact(ll n){
// 素因数分解
for(ll i = 2; i * i <= n; i ++){
ll cnt = 0;
while(n % i == 0){
cnt ++;
n /= i;
}
pair<ll, ll> f = {i, cnt};
pF.push_back(f);
}
if(n != 1){
pF.push_back({n, 1});
}
}


int main(){
    int N, M;
    cin  >> N >> M;
    vector<int> cs(M, -1);
    vector<vector<pair<int, int>>> ps(N);
    vector<pair<int, int>> os(M);
    rep(i, M){
        int p, y;
        cin >> p >> y;
        p --;
        ps[p].push_back({y, i});
    }
    rep(i, N){
        sort(ps[i].begin(), ps[i].end());
    }

    rep(i, N){
        rep(j, ps[i].size()){
            int city = ps[i][j].second;
            os[city] = {i, j};
        }
    }

    rep(i, os.size()){
        cout << setfill('0') << setw(6)  << os[i].first + 1;
        cout << setfill('0') << setw(6)  << os[i].second + 1 << endl;
    }

    return 0;
}


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

int main()
{
     int a, b, c;
  cin >> a >> b >> c ;
if (a == 5 && b == 5 && c == 7) {cout<<"YES";}
 else  if (a == 5 && b == 7 && c == 5) {cout<< "YES";}
  else if (a == 7 && b == 5 && c == 5) {cout<<"YES" ;}
  else {cout<<"NO" ;}
	return 0 ;

	}


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

int main() {
  int n, a[3];
  scanf("%d", &n);
  while (n--) {
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) puts("YES");
    else puts("NO");
  }
}


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

void solve() {
    int n;
    string s;
    cin >> n >> s;
    for (int i=0; i<s.length(); i++){
        char j = s[i];
        cout << (char) (((((int) j - 65) + n) % 26) + 65);
    }
    return;
}

int main() {
	solve();
	return 0;
}


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

int main(){
long long a,b,h,m;
cin >> a >> b >> h >>m;

double ans;

ans =pow((pow(b*cos(2*M_PI*m/60)-a*cos(2*M_PI*h/12 +2*M_PI*m/(12*60)),2) +pow(b*sin(2*M_PI*m/60)-a*sin(2*M_PI*h/12 +2*M_PI*m/(12*60)),2)),0.5);


 cout << setprecision(20) << ans << endl;

}


Measured memory_bytes: 4356
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	for (int i = 0; i < 5; i++) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		/*int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == c){
			System.out.println(b);
		}else if(b == c){
			System.out.println(a);
		}else if(b == a){
			System.out.println(c);
		}else{
			System.out.println("error!");
		}
	}*/
		int Height = sc.nextInt();
		int Weight = sc.nextInt();
		if(Height < 1 || Weight > 50){
			System.out.println("error!");
		}

		String[] S = new String[Height];
		for(int i = 0 ; i < Height ; i ++){
			S[i] = sc.next();
		}
		int BombCounter;
		for(int i = 0; i < Height ; i++){
			for(int j = 0; j < Weight ; j++){
				BombCounter = 0;
				if(i != 0 && j >= 1){
					if(S[i-1].charAt(j-1)== '#'){
						BombCounter ++;
					}
				}
				if(i != 0){
					if(S[i-1].charAt(j)== '#'){
						BombCounter ++;
					}
				}
				if(i != 0 && j <= Weight - 2){
					if(S[i-1].charAt(j+1)== '#'){
						BombCounter ++;
					}
				}
				if(j >= 1){
					if(S[i].charAt(j-1)== '#'){
						BombCounter ++;
					}
				}
				if(S[i].charAt(j)== '#'){
					BombCounter ++;
				}
				if(j <= Weight -2){
					if(S[i].charAt(j+1)== '#'){
						BombCounter ++;
					}
				}
				if(i <= Height -2 && j >= 1){
					if(S[i+1].charAt(j-1)== '#'){
						BombCounter ++;
					}
				}
				if(i <= Height-2){
					if(S[i+1].charAt(j)== '#'){
						BombCounter ++;
					}
				}
				if(i <= Height-2 && j <= Weight -2){
					if(S[i+1].charAt(j+1)== '#'){
						BombCounter ++;
					}
				}
				if(S[i].charAt(j)=='.'){
					System.out.print(BombCounter);
				}else{
					System.out.print("#");
				}
			}
			System.out.print("\n");
		}
}
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s;
    cin >> s;
    vi num(3, 0);
    for (int i = 0; i < s.size(); ++i) {
        num[s[i] - 'a']++;
    }
    int maxi = max({num[0], num[1], num[2]});
    int mini = min({num[0], num[1], num[2]});
    if (maxi > mini + 1) {
        cout << "NO"
             << "\n";
    } else {
        cout << "YES"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(int(2e9))

def distance(P, p1, p2):
    return min(abs(P[p1][1]-P[p2][1]), abs(P[p1][2]-P[p2][2]))
def root(CI, p):
    if CI[p] == p:
        return p
    else:
        CI[p] = root(CI, CI[p])
        return CI[p] 

N = int(input())
P = [[j]+[int(i) for i in input().split(' ')] for j in range(N)]
sortX = sorted(P,key=lambda x:x[1])
sortY = sorted(P,key=lambda x:x[2])
EX = [[sortX[i][0], sortX[i+1][0], distance(P,sortX[i][0],sortX[i+1][0])] for i in range(N-1)]
EY = [[sortY[i][0], sortY[i+1][0], distance(P,sortY[i][0],sortY[i+1][0])] for i in range(N-1)]
E = EX + EY
E = sorted(E, key=lambda x:x[2])
CI = [i for i in range(N)]
disSum = 0
for e in E:
    s,l = min(e[0],e[1]),max(e[0],e[1])
#     if CI[s] != CI[l]:
#         CI = list(map(lambda x:CI[s] if x == CI[l] else x, CI))
#         disSum += e[2]
    if root(CI, s) != root(CI, l):
        CI[root(CI, l)] = root(CI, s)
        disSum += e[2]
print(disSum)
    

Measured memory_bytes: 94808
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	vector<int> p(4);
	cinf(4,p);
	bool a=false;
    bool b=false;
    bool c=false;
  	bool d=false;
	for(int i=0;i<4;i++){
		if(p[i]==1)a=true;
		if(p[i]==9)b=true;
		if(p[i]==7)c=true;
		if(p[i]==4)d=true;
	}
	cout << (a&&b&&c&&d?"YES":"NO") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> M >> K;
	if (M == 0 && K == 0) {
		cout << 0 << " " << 0 << endl;
	} else if (M == 1 && K == 0) {
		cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
	} else if (M >= 2 && K < pow2(M)) {
		for (int i = 0; i < pow2(M); i++)
			if (i != K) {
				cout << i << " ";
			}
		cout << K << " ";
		for (int i = pow2(M) - 1; i >= 0; i--)
			if (i != K) {
				cout << i << " ";
			}
		cout << K << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1792