akhauriyash/Code-Regression huggingface dataset:
<?php
$n = trim(fgets(STDIN));
$trampCheckList = createTrampCheckList();

for ($i = 0; $i < $n; $i++) {
    list($mark, $num) = getSpacesByExplodeTrimInput();
    $trampCheckList[$mark][$num] = 'check';
}

foreach ($trampCheckList as $key => $nullTramp) {
    for ($i = 1; $i <= 13; $i++) {
        if (! isset($trampCheckList[$key][$i])) {
            echo "$key".' '.$i, PHP_EOL;
        }
    }
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

function createTrampCheckList()
{
    return array(
        "S" => array_fill(1, 13, null),
        "H" => array_fill(1, 13, null),
        "C" => array_fill(1, 13, null),
        "D" => array_fill(1, 13, null)
    );
}

Measured memory_bytes: 15500
MOD = 10 ** 9 + 7

n = $stdin.readline.to_i
a = $stdin.readline.chomp.split.map(&:to_i).sort!
k = a[-1].bit_length
dp = Array.new(k) { Array.new(2, 0) }

res = 0
k.times do |b|
  n.times do |i|
    dp[b][(a[i] >> b) & 1] += 1
  end
  res = (res + dp[b].inject(:*) * 2.pow(b, MOD) % MOD) % MOD
end
puts res

Measured memory_bytes: 45088
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=(ll)(vec[i]-1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import math
T = [int(input()) for i in range(5)]
Rest=[0]*5
for i in range(5):
    if T[i]%10 == 0:
        Rest[i] = 10
    else: Rest[i] = T[i]%10
maxrest = 10-min(Rest)
ans = 0
for i in range(5):
    ans += 10*math.ceil(T[i]/10)
print(ans-maxrest)

Measured memory_bytes: 3064
S = input()
MOD = 10**9+7

dp = [0]*13
flag = 0
for s in S:
    if flag == 0:
        if s == "?":
            dp = [1 for _ in range(10)]+[0]*3
        else:
            s = int(s)
            dp[s%13] = 1
        flag = 1
    else:
        prev = dp
        dp = [0]*13
        if s == "?":
            for i in range(13):
                for j in range(10):
                    dp[(10*i+j)%13] += prev[i]
        else:
            s = int(s)
            for i in range(13):
                dp[(10*i+s)%13] += prev[i]
        dp = [x % MOD for x in dp]
print(dp[5])

Measured memory_bytes: 43244
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
unsigned long long int r = 1, k1 = 0;
unordered_map<int, int> mp;
unordered_map<int, int>::iterator it;


void fact(int x)
{
  for(int i = 2; i*i <=x; i++)
  {
    while(x%i == 0)
    {

      it = mp.find(i);
      if(it== mp.end())
      mp.insert({i,1});
      else
      mp[i] = (mp[i]+1)%mod;


      x = x/i;
    }
  }
  if(x > 1)
  {
//    t.push_back(x);
  it = mp.find(x);
  if(it == mp.end())
  mp.insert({x, 1});
  else
  mp[x] = (mp[x]+1)%mod;
  }

}

int main()
{

  // int t;
  // cin>>t;
  // while(t--)
  // {
  int n;
  cin>>n;


//  cout<<"stuck inside the main while loop\n";
  for(int i = 2; i<=n;i++)
  {
    fact(i);
  }
  // for(auto l : mp)
  // {
  //   // k1 = l.second + 1;
  //   // r = (r*k1)%mod;
  //
  //   cout<<l.first<<" "<<l.second<<endl;
  // }

  for(auto l : mp)
  {
    r *= (l.second +1);
    r = r%mod;
  }
  cout<<r<<endl;

  // }

}


Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int v[300300], w[300300];
ll dp[513][100010];
int need;
void dfs(int now)
{
    if(now > need) return;
    int i,j;
    int prev = now / 2;
    for(i=100000;i>0;i--) {
        dp[now][i] = max(dp[now][i], dp[prev][i]);
        if(i - w[now] < 0) continue;
        dp[now][i] = max(dp[now][i], dp[prev][i - w[now]] + v[now]);
    }
    dfs(now*2);
    dfs(now*2+1);
}
int main()
{
    int n,i,j,k,x,y,ans,curr,m;
    int tc;
    scanf("%d",&n);
    need = min(n, 512);
    for(i=1;i<=n;i++) {
        scanf("%d %d",&v[i],&w[i]);
    }
    dp[0][0] = 0;
    dfs(1);
    int q;
    scanf("%d",&q);
    while(q--) {
        scanf("%d %d",&x,&y);
        if(x <= need) {
            printf("%lld\n", dp[x][y]);
        }
        else {
            vector<int> vi;
            while(x > need) {
                vi.push_back(x);
                x /= 2;
            }
            int sz = vi.size();
            ll chaeng = 0;
            for(i = 0; i < (1<<sz); i++) {
                ll cost = 0, gain = 0;
                for(j = 0; j < sz; j++) {
                    if(i & (1 << j)) {
                        gain += v[vi[j]];
                        cost += w[vi[j]];
                    }
                }
                if(cost <= y) {
                    chaeng = max(chaeng, dp[x][y - cost] + gain);
                }
            }
            printf("%lld\n", chaeng);
        }
    }
    return 0;
}


Measured memory_bytes: 405840
#include <cstdio>
#include <map>
#include <algorithm>

using namespace std;

int main() {
	while (true) {
		int n, m, a;

		scanf("%d %d %d", &n, &m, &a);

		if (n == 0) break;

		pair<int, pair<int, int> > bar[1000];

		for (int i = 0; i < m; i++) {
			int h, p, q;

			scanf("%d %d %d", &h, &p, &q);

			bar[i] = make_pair(-h, make_pair(p, q));
		}

		sort(bar, bar + m);

		for (int i = 0; i < m; i++) {
			pair<int, int> b = bar[i].second;

			if (b.first == a) a = b.second;
			else if (b.second == a) a = b.first;
		}

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

	return 0;
}

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

using namespace std;
const int maxn = 100005;
typedef long long ll;

int a[maxn];

int main()
{
    int a,b,c,x,y;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);

    if(a+b > c*2)
    {
        int cnt = min(x,y);

        int ans = 2*cnt * c;

        if(x>y)
        {
            int cnt2 = x-y;
            ans += min(cnt2*a, cnt2*2*c);
        }
        else
        {
            int cnt2 = y-x;
            ans += min(cnt2*b,cnt2*2*c);
        }
        cout<<ans<<endl;
    }
    else
    {
        cout<<x*a+b*y<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int l, r, d;
  cin >> l >> r >> d;

  int ans = r / d - l / d;

  if (d == 1) {
    ans++;
  } else if (l == d) {
    ans++;
  } else if (l == r) {
    if (l % d == 0) {
      ans = 1;
    }
  }
  cout << ans;
  return 0;
}


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

int main(){
    int N, p[51];
    cin >> N;
    int count = 0;

    for(int i = 0; i< N; i++){
        cin >> p[i];
        if(p[i] != i+1){
            count++;
        }
    }

    if(count == 2 | count == 0){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
	unordered_map<int, int> map;
  	int n, a, c;
  	cin >> n;
  	for (int i = 0; i < n; i++) {
    	cin >> a;
      	if (map.find(a) == map.end()) {
          	c = 1;
        } else {
          c = map[a] + 1;
        }
        map[a] = c;
    }
  	int key, val;
  	int ans = 0;
  	for (pair<int, int> element: map) {
    	key = element.first;
      	val = element.second;
      	if (val > key) {
        	ans += val - key;
        } else if(val == key) {
         	ans += 0; 
        }else {
          	ans += val;
        }
    }
  	cout << ans;
}

Measured memory_bytes: 6660
#include <cstdio>
#include <complex>
using namespace std;
typedef complex<double> P;

/* ?¨±?????????????????  */
#define EPS (1e-10)
/* 2?????????????????????????????????????????? */
#define EQ(a,b) (abs((a)-(b)) < EPS)

/* ?????? (cross product) : a??b = |a||b|sin */
double cross(const P& a, const P& b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

/* ?????? (dot product) : a???b = |a||b|cos??  */
double dot(const P& a, const P& b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

/* 2??´????????´????????? : a??\b <=> dot(a, b) = 0 */
int isOrthogonal(const P& a1, const P& a2, const P& b1, const P& b2) {
  return EQ( dot(a1-a2, b1-b2), 0.0 );
}

/* 2??´?????????????????? : a//b <=> cross(a, b) = 0 */
int isParallel(const P& a1, const P& a2, const P& b1, const P& b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

int main() {
  int n;
  int ax, ay, bx, by, cx, cy, dx, dy;
  scanf("%d", &n);

  while(n--) {
    scanf("%d %d %d %d %d %d %d %d", &ax, &ay, &bx, &by, &cx, &cy, &dx, &dy);
    P a(ax, ay), b(bx, by), c(cx, cy), d(dx, dy);
    if(isParallel(a, b, c, d)) puts("2");
    else if(isOrthogonal(a, b, c, d)) puts("1");
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 2672
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cfloat>
using namespace std;
int mod = 1e9+7;
long long int inf = 1e18;

int main() {

  int n; cin >> n;
  vector< pair<int, int> > r(n);
  vector< pair<int, int> > b(n);
  for(int i=0; i<n; i++) cin >> r[i].first >> r[i].second;
  for(int i=0; i<n; i++) cin >> b[i].first >> b[i].second;

  sort(r.begin(), r.end());
  sort(b.begin(), b.end());
  int cnt = 0;
  vector<bool> x(n, false);
  for(int i=0; i<n; i++){
    int tmp = -1;
    int p = -1;
    for(int j=0; j<n; j++){
      if( x[j] ) continue;
      if( b[i].first > r[j].first && b[i].second > r[j].second ){
        if( tmp < r[j].second ){
          tmp = r[j].second;
          p = j;
        }
      }
    }
    if( p != -1 ){
      x[p] = true;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

//


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

struct UF {
  vector<int> par; // parent
  vector<int> sizes;
  UF(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; ++i) {
      par[i] = i;
    }
  }
  int root(int x) {
    if (x == par[x]) {
      return x;
    }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (sizes[x] < sizes[y]) {
      swap(x, y);
    }
    par[y] = x;
    sizes[x] += sizes[y];
    sizes[y] = 0;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};

vvi g;

int main() {
  int n;
  scanf("%d", &n);
  vector<pii> x(n), y(n);
  rep (i, n) {
    scanf("%d %d", &x[i].first, &y[i].first);
    x[i].second = y[i].second = i;
  }

  sort(all(x));
  sort(all(y));
  rep (i, n-1) {
    vi xedge = {x[i+1].first - x[i].first, x[i].second, x[i+1].second};
    g.push_back(xedge);
    vi yedge = {y[i+1].first - y[i].first, y[i].second, y[i+1].second};
    g.push_back(yedge);
  }

  sort(all(g));
  UF uf(n);
  ll cost = 0;
  rep (i, 2*n-2) {
    if (uf.same(g[i][1], g[i][2])) {
      continue;
    }
    cost += g[i][0];
    uf.unite(g[i][1], g[i][2]);
  }
  printf("%lld\n", cost);

  return 0;
}


Measured memory_bytes: 15020
/*Practice hard*/
#include <bits/stdc++.h>
using namespace std;
//_______MACROS_______//
#define   fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   long long int
#define   pb    push_back
#define   f     first
#define   s     second
 
 
 
signed main()
{
    //code
    fast ;
    int t = 1 ;
	//cin>>t;
 
	while(t--)
    {
 
		string s , t ;
		cin >> s >> t ;
		if (s.size() == t.size() - 1)
        {
            if (s == t.substr(0,s.size()))
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, maxint


def main():
    num = int(stdin.readline())

    L = []
    for _ in xrange(num):
        it = iter(int(s) for s in stdin.readline().split()[1:])
        L.append([(next(it), next(it)) for _ in xrange(next(it))])

    weight = [maxint] * num
    weight[0] = 0
    V = set(xrange(1, num))
    index = 0

    while V:
        for v, cost in L[index]:
            if v not in V:
                continue
            weight[v] = min(weight[v], cost + weight[index])

        index = min(V, key=lambda i: weight[i])
        V.remove(index)

    for i, d in enumerate(weight):
        print(i, d)


main()

Measured memory_bytes: 4672
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a=[]
3.times{a<<gsmi}
n=gi
b=n.times.map{gi}


hits=ar2(3,3,0)
b.each do |i|
  a.each.with_index do |j,ji|
    j.each.with_index do |k,kk|
      if i==k
        hits[ji][kk]=1
      end
    end
  end
end

# たて
hits.each.with_index do |j,ji|
  if j.count(1)==3
    putsend 'Yes'
  end
end
#よこ
hits.transpose.each.with_index do |j,ji|
  if j.count(1)==3
    putsend 'Yes'
  end
end
#ななめ
if hits[0][0]==1&&hits[1][1]==1&&hits[2][2]==1 ||hits[0][2]==1&&hits[1][1]==1&&hits[2][0]==1
  putsend 'Yes'
end
puts 'No'

Measured memory_bytes: 2044
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int A, B, C, X, Y;

// i) 
//

void input() {
  cin >> A >> B >> C >> X >> Y;
}

Int dfs(Int x, Int y) {
  if (x <= 0 && y <= 0) return 0;
  if (x > 0 && y > 0) {
    Int num = min(x, y);
    Int cost = 0;
    if (C*2 > A+B) cost += A*num + B*num;
    else cost += C*2*num;
    cost += dfs(x-num, y-num);
    return cost;
  }

  if (x > 0) {
    if (C*2 > A) return A*x;
    else return C*2*x;
  }

  // y > 0;
  if (C*2 > B) return B*y;
  else return C*2*y;
}

void solve() {
  cout << dfs(X, Y) << endl;
}

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


Measured memory_bytes: 256
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int h[1000000];
int dp[1000000];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;  
  cin >> n;

  REP(i, n) {
    int tmp;
    cin >> tmp;
    h[i] = tmp;
  }
  REP(i, n) dp[i] = 0;
  
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);

  REP(i, n) dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]), dp[i+1]+abs(h[i+2]-h[i+1]));

  //REP(i, n) cout << dp[i] << endl;
  
  cout << dp[n-1] << endl;
  
  return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
#define MAXN 102
#define MAXK 100005
#define INF 1000000009
#define pb push_back

int a, b;

int main()
{
    cin >> a >> b;
    if(a > 8 || b > 8){
        printf(":(\n");
    }
    else printf("Yay!\n");

    return 0;
}


Measured memory_bytes: 256
import  scipy
import  numpy as np
import  itertools

n = int(input())
arr = []
def dist(a,b):
  return  np.sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]))

for i in range(n):
  x,y = map(int,input().split())
  arr.append([x,y])

hoge = 0
ind = 0
for z in itertools.permutations(range(n)):
  ind += 1
  for i in range(n-1):
    # print(arr[i],arr[i+1])
    hoge += dist(arr[z[i]],arr[z[i+1]])

print(hoge/ind)


Measured memory_bytes: 21588
#include<iostream>

using namespace std;


int main(){
  int height[10] = {};
  int i,j,temp;

  for(i=0;i<10;i++){
    cin >> height[i];
  }

  for(i=9;i>0;i--){
    for(j=0;j<i;j++){
      if(height[j]<height[j+1]){
	temp = height[j];
	height[j] = height[j+1];
	height[j+1] = temp;
      }
    }
  }


  for(i=0;i<3;i++){
    cout << height[i] << endl;
  }

}

Measured memory_bytes: 1160
N = int(input())
tmp = [int(x) for x in input().split()]
lst = [tmp[0]]
for x in tmp[1:]:
    lst.append(lst[-1] + x)

total = lst[-1]
ret = 10 ** 100
for i in range(N - 1):
    n = lst[i]
    ret = min(ret, abs(n - (total - n)))
print(ret)

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

int main(void) {
	int a,b;
	int v, l;
	cin >> a >> b;

	v = a * b;
	l = 2 * a + 2 * b;
	cout << v << " " << l << endl;
	
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)
 
int main() {
  int n, a, b, ans = 0;
  long long x;
  string s;
  cin >> n >> a >> s;
  for(int i = 0; i < 10; i++) {
  }
  s.at(a - 1) += 32;
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;
int main()
{
  int H, N;
  cin >> H >> N;

  vector<int> vec(N);
  REP(i, N){
    int back;
    cin >> back;

    vec.at(i) = back;
  }

  bool ans = false;

  REP(i, N){
    H -= vec.at(i);
    if(0 >= H){
      ans = true;
    }
  }

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

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

int main(){

  int cnt[26]={};
  string w;
  bool j=true;

  cin>>w;
  for(int i=0;i<w.length();i++) cnt[w[i]-'a']++;
  for(int i=0;i<26;i++) if(cnt[i]%2) j=false;

  if(j) cout<<"Yes"<<endl;
  else cout<<"No"<<endl; 
  
  return 0;
}


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

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

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

const ll MAX = 1e9;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int N, A, B;

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

    cout << min(A * N, B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  if (n ==1 && m ==1) {
    cout << 1 << '\n';
  } else if (n == 1) {
    cout << m - 2 << '\n';
  } else if (m == 1) {
    cout << n - 2 << '\n';
  } else {
    cout << (n - 2) * (m - 2) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, tab[N], res[N], i;

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
res[0] = 0;
res[1] = abs(tab[1] - tab[0]);
for (i=2;i<n;i++) res[i] = min(res[i - 2] + abs(tab[i] - tab[i - 2]), res[i - 1] + abs(tab[i] - tab[i - 1]));
printf("%d\n", res[n - 1]);
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
class mint{
    public:
        long long x;
 
    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};
ll pow_mod(ll n,ll k,ll m){
  ll res=1;
  for(;k>0;k>>=1){
    if(k&1){
      res=(res*n)%m;
    }
    n=(n*n)%m;  
  }
  return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        int num=a[i];
        for(int j=2;j*j<=a[i];j++){
            int cnt=0;
            while(num%j==0){
                num/=j;
                cnt++;
            }
            chmax(mp[j],cnt);
        }
        if(num!=1){
            chmax(mp[num],1);
        }
    }
    mint ans=0,lcm=1;
    for(auto x:mp){
        mint c=x.first;
        lcm*=c.pow(x.second);
    }
    for(int i=0;i<n;i++){
        mint c=a[i];
        ans+=lcm/c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int max = 300;
	if (max > p + q)max = p + q;
	if (max > r + q)max = r + q;
	if (max > p + r)max = p + r;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
heapq.heapify(A)
for _ in range(M):
  a = -heapq.heappop(A)
  heapq.heappush(A, -(a//2))
print(-sum(A))

Measured memory_bytes: 20380
import java.io.IOException;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		if(s.equals("AAA") || s.equals("BBB")) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}

	}

}


Measured memory_bytes: 23764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b==c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    long long k,n;
    cin>>k;
    n=k/50,k%=50;
    cout<<50<<endl;
    for(int i=1;i<=50;i++) {
	if(i<=k) cout<<100+n-k<<' ';
	else cout<<49+n-k<<' ';
    }
    return 0;
}

Measured memory_bytes: 256
#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>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Combination {

public:
    vector<ll> fact;

    Combination(int max_n) {
        //1 ~ n!までの階乗modを求める
        int n = max_n;
        vector<ll> fact(n + 1);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
        this->fact = fact;
    }

    template<typename T>
    //templateをつかってみｔか
    ll pow(T x, int y) {
        if (y == 0) return 1;
        if (y == 1) return x;
        if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
        if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
        return pow(pow(x, y / 2), 2) % MOD;
    }

    ll nCk(int n, int k) {
//        return (fact[n] * pow(fact[n-k],MOD-2) * pow(fact[k],MOD-2)) % MOD;
        return (((fact[n] * pow(fact[n - k], MOD - 2)) % MOD) * pow(fact[k], MOD - 2)) % MOD;
    }

    ll extgcd(ll a, ll b, ll &x, ll &y) {
        ll d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }

    /**
     * x ^ -1を求める
     */
    template<typename T>
    ll inv(T x) {
//        ll x, y;
//        extgcd(a, MOD, x, y);
//        return (m + x % m) % m;

        return pow(x, MOD - 2);
    }
};

Combination cmb(2100001);

class Solve {
public:
    void solve() {
        Int X, Y;
        cin >> X >> Y;
        if ((X + Y) % 3 != 0) {
            cout << 0 << endl;
            return;
        }


        Int N = (X + Y) / 3;
        Int x = X - N;
        Int y = Y - N;
        if (x < 0 || y < 0) {
            cout << 0 << endl;
            return;
        }

        Int ans = cmb.nCk(x + y, x);
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 33656
n = int(input())
a = list(map(int, input().split()))
ans = 0

M = max(a)
m = min(a)
while M > n - 1:
	Mi = a.index(M)
	div = M // n
	for i in range(n):
		if i == Mi:
			a[i] -= n * div
		else:
			a[i] += div
	ans += div
	M = max(a)
	m = min(a)

print(ans)

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

using ll=long long;

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

const ll INF = 1LL << 60;

int N,K;
ll h[100010];
ll dp[100010];

int main(){
  cin >> N >> K;
  for (int i=0;i<N;i++)
    cin >> h[i];
  for (int i=0;i<100010;i++)
    dp[i]=INF;
  dp[0]=0;
  for (int i=0;i<N;i++){
    for (int j=1;j<=K;j++)
      chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
  }
  cout << dp[N-1] << endl;
  
}

Measured memory_bytes: 1792
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(ll i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(ll i = b; i < e; i++)
#define erep(i, b, e) for(ll i = b; i <= e; i++)
#define rrep(i, b, e) for(ll i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// debug
#define debug(x) cout << (#x) << ": " << x << endl;
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vll& v, ll n){v.pb(2); for(auto i = 3; i <= n; i += 2){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    
    int ans = 0;
    for(int i = 0; i < k; i++){
        char c = 'N';
        for(int j = 0; k * j + i < n; j++){
            if(t[k * j + i] == 'r'){
                if(c == 'P'){
                    c = 'N';
                }else{
                    ans += p;
                    c = 'P';
                }
            }else if(t[k * j + i] == 's'){
                if(c == 'R'){
                    c = 'N';
                }else{
                    ans += r;
                    c = 'R';
                }
            }else if(t[k * j + i] == 'p'){
                if(c == 'S'){
                    c = 'N';
                }else{
                    ans += s;
                    c = 'S';
                }
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	int ans = 1;
	for(int i = 0; i < n-1; i++)
		ans *= k-1;
	cout << k * ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
  public:
  vector<int> rank, prt;
  disjoint_set (int size) {
    rank.resize(size, 0);
    prt.resize(size, 0);
    for (int i = 0; i < size; i++) {
      prt[i] = i;
      rank[i] = 0;
    }
  }
  int find (int x) {
    return (x == prt[x] ? x : prt[x] = find(prt[x]));
  }
  bool is_equiv (int x, int y) {
    return find(x) == find(y);
  }
  bool unite (int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }
    if (rank[x] > rank[y]) {
      swap(x, y);
    }
    prt[x] = y;
    if (rank[x] == rank[y]) {
      rank[y]++;
    }
    return true;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> grh(m);
  for (int i = 0; i < m; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    grh[i] = {w, {s, t}};
  }
  sort(grh.begin(), grh.end());
  int ans = 0;
  disjoint_set djs(n);
  for (int i = 0; i < m; i++) {
    auto e = grh[i];
    int w = e.first;
    int s = e.second.first;
    int t = e.second.second;
    bool ret = djs.unite(s, t);
    if (ret) {
      ans += w;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace std;

string str;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> str;
	bool val = true;
	for(int i = 0; i < (int)str.length(); i++)
		if(str[i] != str[(int)str.length() - 1 - i]) val = false;
	for(int i = 0; i < (int)str.length() / 2; i++)
		if(str[i] != str[(int)str.length() / 2 - 1 - i]) val = false;
	for(int i = 0; i < (int)str.length() / 2; i++)
		if(str[(int)str.length() / 2 + 1 + i] != str[(int)str.length() - i - 1]) val = false;
	cout << (val ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
s=input()
if 0<int(s[:2])<=12 and 0<int(s[2:])<=12:
    ans='AMBIGUOUS'
elif 0<=int(s[:2])<=99 and 0<int(s[2:])<=12:
    ans='YYMM'
elif 0<int(s[:2])<=12 and 0<=int(s[2:])<=99:
    ans='MMYY'
else:
    ans='NA'
print(ans)

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

constexpr std::int32_t MAX_N = 100005;

void Main() {
    int n;
    cin >> n;
    vint v(n);
    rep(i, n)cin >> v[i];


    vint a(MAX_N, 0), b(MAX_N, 0);
    rep(i, n) {
        if (i % 2 == 0) {
            ++a[v[i]];
        }
        else {
            ++b[v[i]];
        }
    }

    auto a_max = max_element(ALL(a));
    auto b_max = max_element(ALL(b));

    int val = *a_max + *b_max;

    int a_index = a_max - a.begin();
    int b_index = b_max - b.begin();
    if (a_index == b_index) {
        vint ac = a;
        vint bc = b;
        ac.erase(ac.begin() + a_index);
        bc.erase(bc.begin() + b_index);
        auto ac_max = max_element(ALL(ac));
        auto bc_max = max_element(ALL(bc));

        if (*a_max + *bc_max > *b_max + *ac_max) {
            val = *a_max + *bc_max;
        }
        else {
            val = *b_max + *ac_max;
        }
    }

    cout << n - val << endl;
}

int main() {
    std::cin.tie(nullptr);
        std::ios_base::sync_with_stdio(false);
        std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2176
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

X = ni()
S = 100
year = 0
while True:
    if S >= X:
        print(year)
        exit(0)
    S = (S * 101) // 100
    year = year +1


Measured memory_bytes: 9156
def merge(A,left,mid,right):
    global cnt
    inf=float("inf")
    L=A[left:mid]+[inf]
    R=A[mid:right]+[inf]

    i,j=0,0
    for k in range(left,right):
        cnt +=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i +=1
        else:
            A[k]=R[j]
            j +=1


def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)


n=int(input())
A=list(map(int,input().split()))
cnt=0
mergeSort(A,0,n)

print(*A)
print(cnt)


Measured memory_bytes: 61644
// Maximum Sum

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;
    sort(a.begin(), a.end());

    for (int i = 0; i < k; i++) {
        a[2] *= 2;
    }

    cout << a[0] + a[1] + a[2] << endl;

    return 0;
}


Measured memory_bytes: 256
H, W, A, B  = map(int, input().split())
graph = [[0]*W for _ in range(H)]
for i in range(B):
    for j in range(A, W):
        graph[i][j] = 1
for i in range(B, H):
    for j in range(A):
        graph[i][j] = 1
for line in graph:
    print("".join(map(str, line)))


Measured memory_bytes: 51292
N = int(input())
HB = input().split(' ')
HB = [int(HB[i]) for i in range(N)]
Hs = [0]
for i in range(N):
  H = HB[i]
  if Hs[i] > H:
    print('No')
    break
  else:
   if Hs[i] == H:
     Hs.append(H)
   else:
     H = H - 1
     Hs.append(H)
else:
  print('Yes')

Measured memory_bytes: 20568
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, m, maxn = 0;
	vector<int>list;
	int k;
	string s;

	cin >> s;

	string s1 = { s[0] , s[1] };
	string s2 = { s[2] , s[3] };
	int m1 = stoi(s1);
	int m2 = stoi(s2);
	//int n0 = s[0] - 48;
	//int n1 = s[1] - 48;
	//int n2 = s[2] - 48;
	//int n3 = s[3] - 48;

	if (m1 >= 1 && m1 <= 12 && m2 >= 1 && m2 <= 12) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (m1 >= 1 && m1 <= 12) {
		cout << "MMYY" << endl;
	}
	else if (m2 >= 1 && m2 <= 12) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans;
}

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

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
const int INF=100000000;
//--------------------------------------//
int main(){
	cint(x);
	while(true){
		int a=2,p;
		bool b=false;
		while(x>=a*a){
			if(x%a==0){
				p=a;
				int n=x/a;
				while(true){
					if(n==1) {
						b=true;
						break;
					}
					if(n%p==0){
						n/=p;
					}
					else break;
				}
				if(b) break;
			}
			a++;
		}
		if(b||x==1){
			cout<<x<<endl;
			break;
		}
		x--;
	}
	return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=count(x->x=='R',chomp(readline()))
    if s>n-s
        println("Yes")
    else
        println("No")
    end
end
main()

Measured memory_bytes: 111568
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	char a[15],b[15],c[15];
	scanf("%s %s %s",&a,&b,&c);
	int lena=strlen(a),lenb=strlen(b);
	if(a[lena-1]==b[0]&&b[lenb-1]==c[0]){
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
} 

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int inputSecond = sc.nextInt();
        int hour = inputSecond / 3600;
        int minute = (inputSecond % 3600) / 60;
        int second = (inputSecond % 3600) % 60;
        System.out.println(hour + ":" + minute + ":" + second);
    }
}


Measured memory_bytes: 26212
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        p[a-1] = i+1;
    }
    for (int i = 0; i < N; i++) {
        if (i) cout << ' ';
        cout << p[i];
    }
    cout << '\n';
}


Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	string S, T;
	cin >> S >> T;

	Int len_S = S.size();
	Int len_T = T.size();

	Int flag = 0;
	Int temp;
	for (Int i = 0; i < len_S; i++) {
		if (S[i] == T[0] || S[i] == '?') {
			for (Int j = 0; j < len_T; j++) {
				if (i + j >= len_S)break;
				if (S[i + j] != T[j] && S[i + j] != '?') {
					break;
				}
				if (j == len_T - 1) {
					flag = 1;
					temp = i;
				}
			}

		}
	}

	if (flag) {
		for (Int i = 0; i < len_T; i++) {
			S[i + temp] = T[i];
		}
	}

	for (Int i = 0; i < len_S; i++) {
		if (S[i] == '?')S[i] = 'a';
	}

	cout << (flag ? S : "UNRESTORABLE") << "\n";

}

Measured memory_bytes: 256