akhauriyash/Code-Regression huggingface dataset:
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt
    
    // 0 0が入力された
    if(!width && !height){
      break;
    }
    
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
        
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];
    
        switch(c){
        case 'S':
          start = pos(x, y);
          break;
        case 'G':
          goal = pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1][elem[c - 1].length] = pos(x, y);
          break;
        }
      }
    }
    
    var INF = 1 << 30;
    var bestElement = -1;
    var distance = INF;
        
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = INF;
        }
      }
          
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;
      for (var j = elem[first].length; j--; ) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
          
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        for (var j = elem[now].length; j--; ) {
          for (var k = elem[next].length; k--; ) {
            dp[next][k] = fmin(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
          
      var last = (first + 3) % 5;
      for (var j = elem[last].length; j--; ) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
            
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
            
      }
          
    }
        
    if (distance == INF) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
    
    i++;
  }
      
    
}
    
function dist(from, to){
  // x座標とy座標の切り出し(11ビット右シフトでxを、2047(下位10ビット1)とのAND演算でyを取り出す)
  return fabs((from >> 11) - (to >> 11)) + fabs((from & 2047) - (to & 2047));
}
    
function fmin(a, b){
  // ビット演算で高速化
  var t = a - b;
 return b + (t & (t >> 31));
}
    
function pos(a, b){
  // 2^10 = 1024なので、下位10ビットでy座標を、上位ビットでx座標を表す
  return (a << 11) + b;
}
   
function fabs(a){
 // ビット演算で高速化
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
    
var
input = '';
    
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 51192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vll water(31, 0), sugar(3001, 0);
    REP(i, 31){
        REP(j, 31){
            if(a * i + b * j > 30) continue;
            water[a * i + b * j] = 1;
        }
    }
    REP(i, f + 1){
        REP(j, f + 1){
            if(c * i + d * j > 3000) continue;
            sugar[c * i + d * j] = 1;
        }
    }
    ll resw, ress;
    double conc = -1;
    FOR(i, 1, 30){
        FOR(j, 1, 3000){
            if(!water[i] || !sugar[j]) continue;
            ll w = 100 * i, s = j;
            if(w + s > f || s > e * i) continue;
            double tmp = s / (100.0 * i + s);
            if(tmp > conc){
                resw = w;
                ress = s;
                conc = tmp;
            }
        }
    }
    if(conc < 0){
        cout << a * 100 << " " << 0 << endl;
        return 0;
    }
    cout << resw + ress << " " << ress << endl;
    return 0;
}

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

int c[1000];
int top;

void push(int x){
    c[++top] = x;
}

int pop(){
    top--;
    return c[top+1];
}

int main(){
    int x;
    char s[100];
    int a;
    int b;
    
    while(scanf("%s",s)!=EOF){
        if( s[0] == '+' ){
            a=pop();
            b=pop();
            push(b+a);
        } else if ( s[0] == '-' ){
            a=pop();
            b=pop();
            push(b-a);;
        } else if ( s[0] == '*' ){
            a=pop();
            b=pop();
            push(b*a);
        }else if(s[0] == '/' ){
            a=pop();
            b=pop();
            push(b/a);
        } else {
      x  = atoi(s);
     push(x);
     
    }
     
  }
   printf("%d\n",pop());
  return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int K; cin >> K;
    rep(i, K) cout << "ACL";
    cout << endl;
}


Measured memory_bytes: 3608
mod = 10 ** 9 + 7
def max(a,b); a > b ? a : b end
def min(a,b); a < b ? a : b end
def swap(a,b); a, b = b, a  end
def yn(f); puts f ? "Yes" : "No" end
def yes; puts "Yes"; exit end
def no; puts "No"; exit end
# (n, k), a, f = $<.map{|l| l.to_s.split.map(&:to_i) }
#n = gets.to_s.to_i
h1, m1, h2, m2, k  = gets.to_s.split.map{|e|e.to_i}
#m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
#s = gets.to_s.chomp

d = ( h2 * 60 + m2) - (h1 * 60 + m1)
puts d - k

Measured memory_bytes: 14396
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

"""
dp
time / books_no?
10 0 0
20 0 0
30 0 0
40 0 0
50 0 0
60 1 0
70 1 0
80 0 1




"""



N, M, K = LI()
A = LI()
B = LI()

"""
片方に注目して探索すればよい　

単純にfor,forだと計算量がまずいが，前回の値の部分から探索すればいいのでそこまで
計算量は増えない

"""

a = [0]
b = [0]

for i in range(N):
    a.append(a[-1] + A[i])

for i in range(M):
    b.append(b[-1] + B[i])

# print(a)
ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
    

Measured memory_bytes: 50880
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  int A,B, C, D ,E ,F;
  string S,Sa,Sb,Sc;
  cin >> A >> S >> B;
  if(S[0] == '+')cout << A + B << endl;
  else cout << A - B << endl;
        return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int count(int ini, int thr){
  int retval = 0;
  int num = ini;
  while(num < thr){
    retval++;
    num *= 2;
  }
  return retval;
}
int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0.;
  for(int i = 1; i <= n; i++){
    int c = count(i, k);
    ans += pow(0.5, c);
  }
  ans /= static_cast<double>(n);
  cout << setprecision(18) << ans;
  return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

signed main()
{

    int n, k;
    string s;
    cin >> n >> k >> s;

    int same = 0;
    rep(i, n - 1)
    {
        if (s[i] == s[i + 1])
        {
            same++;
        }
    }

    cout << min(same + k * 2, n - 1) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.math.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static BigInteger a, b;
	public static void main(String[] args) {
		while(read()){
			
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			a = sc.nextBigInteger(); b = sc.nextBigInteger();
			solve();
		}
		return true;
	}
	static void solve(){
		if(a.toString().length() > 80 || b.toString().length() > 80 || a.add(b).toString().length() > 80){
			System.out.println("overflow");
		}else{
			System.out.println(a.add(b));
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){

   int n;
   cin >> n;
   vector<int> a;
   for(int i=0; i < n; i++){
      int aaa;
      cin >> aaa;
      a.push_back(aaa);
   }
   sort(a.begin(), a.end());
   cout << abs(a.back() - a[0]) << endl;
   return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (char c : s) {
        if (c == '1')
            cout << '9';
        else if (c == '9') {
            cout << '1';
        }
        else
            cout << c;
    }

    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

struct vertex {
    vector<int> to;
    int branch;
};

int n;
set<int> p;
vector<int> pa;
int visited[100000];
vertex v[100000];

int dfs(int u) {
    visited[u] = true;
    rep(i, v[u].to.size()) {
        if (visited[v[u].to[i]]) continue;
        int tmp = dfs(v[u].to[i]);
        if (!p.count(v[u].to[i])) v[u].branch += tmp;
    }
    return v[u].branch;
}

bool path(int u, int from) {
    if (u == n - 1) {
        p.insert(u);
        pa.pb(u);
        return true;
    }
    bool on = false;
    rep(i, v[u].to.size()) {
        if (v[u].to[i] == from) continue;
        on |= path(v[u].to[i], u);
    }
    if (on) p.insert(u), pa.pb(u);
    return on;
}

int main(){
    cin.sync_with_stdio(false);
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].to.pb(b);
        v[b].to.pb(a);
        visited[i] = false;
        v[i].branch = 1;
    }
    v[n - 1].branch = 1; visited[n - 1] = false;
    path(0, -1);
    dfs(0);
    reverse(pa.begin(), pa.end());
    int fennec = 0, snuke = 0, m = pa.size() / 2 + pa.size() % 2;
    rep(i, m) fennec += v[pa[i]].branch;
    repl(i, m, pa.size()) snuke += v[pa[i]].branch;
    if (fennec > snuke) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 18296
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s, t;

    cin >> s >> t;

    if(s == t.substr(0, s.size()) && s.size()+1 == t.size()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    map<i64, i64> mp;
    REP(i, N) {
        i64 a; cin >> a;
        mp[a] = i;
    }

    i64 smin = 0;
    set<i64> se;
    for (auto &kv : mp) {
        i64 ai = kv.first;
        i64 idx = kv.second;
        auto near_r = se.upper_bound(idx);
        i64 r, l;
        if (near_r == se.end()) r = N;
        else r = *near_r;
        if (near_r == se.begin()) l = -1;
        else l = *prev(near_r, 1);
        smin += ai * (idx - l) * (r - idx);
        se.insert(idx);
    }
    cout << smin << endl;

    return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    vector<int> prime(0);
    prime.push_back(2);
    prime.push_back(3);
    prime.push_back(5);
    prime.push_back(7);
    prime.push_back(11);
    prime.push_back(13);
    prime.push_back(17);
    prime.push_back(19);
    prime.push_back(23);
    prime.push_back(29);
    prime.push_back(31);
    prime.push_back(37);
    prime.push_back(41);
    prime.push_back(43);
    prime.push_back(47);
    prime.push_back(53);
    prime.push_back(59);
    prime.push_back(61);
    prime.push_back(67);
    prime.push_back(71);
    prime.push_back(73);
    prime.push_back(79);
    prime.push_back(83);
    prime.push_back(89);
    prime.push_back(97);
    
    int N;
    cin >> N;
    vector<int> prime_count(25,0);
    for (int i = 2; i <= N; i++){
        int i_copy = i;
        int j = 0;
        while(true){
            if (i_copy == 1){
                break;
            }
            else if (i_copy % prime[j] == 0){
                i_copy /= prime[j];
                prime_count[j]++;
            }
            else{
                j++;
            }
        }
    }
    int over_2 = 0;
    int over_4 = 0;
    int over_14 = 0;
    int over_24 = 0;
    int over_74 = 0;
    for (int i = 0; i < 25; i++){
        if (prime_count[i] >= 74) over_74++;
        else if (prime_count[i] >= 24) over_24++;
        else if (prime_count[i] >= 14) over_14++;
        else if (prime_count[i] >= 4) over_4++;
        else if (prime_count[i] >= 2) over_2++;
    }
    int ans = 0;
    ans += over_2 * (over_4 + over_14 + over_24 + over_74) * (over_4 + over_14 + over_24 + over_74 - 1) / 2;
    ans += (over_4 + over_14 + over_24 + over_74) * (over_4 + over_14 + over_24 + over_74 - 1) * (over_4 + over_14 + over_24 + over_74 - 2) / 2;
    ans += (over_2 + over_4 + over_14) * (over_24 + over_74);
    ans += (over_24 + over_74) * (over_24 + over_74 - 1);
    ans += over_4 * (over_14 + over_24 + over_74);
    ans += (over_14 + over_24 + over_74) * (over_14 + over_24 + over_74 - 1);
    ans += over_74;
    cout << ans << endl;
}

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  vector<pair<int, int>> vec;

  while (true)
  {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0)
    {
      break;
    }

    vec.push_back(make_pair(h, w));
  }

  for (auto &&p : vec)
  {
    int h = p.first;
    int w = p.second;

    rep(i, h)
    {
      rep(j, w)
      {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
        {
          printf("#");
        }
        else
        {
          printf(".");
        }
      }
      printf("\n");
    }

    printf("\n");
  }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,k,n,m;
     ll t;
     ll a,b,c,d;
     set<string> m1;
     cin>>n;
     string s;
     for(i=0;i<n;i++)
     {
         cin>>s;
         m1.insert(s);
     }
     cout<<(ll)m1.size();
}  


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

int n, a[100005];

int val (int I, int M) {
	if(I <= M/2) return M/2-I;
	return I-(M+1)/2;
}

int main() {
	scanf("%d",&n);
	int M = 0, V = 0;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		M = max(M, a[i]);
	}
	if(a[1] == M) V = a[n];
	else V = a[1];
	for(int i=1;i<=n;i++) {
		if(val(V,M)>val(a[i],M)) V = a[i];
	}
	printf("%d %d\n",M,V);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
//#define INF ((1LL<<62)-(1LL<<31))
#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int n,k,ans=INF;
    cin>>n>>k;
    int a[n];
    rep(i,0,n)cin>>a[i];
    rep(i,0,n-k+1){
        ans=min(ans,min(abs(a[i])+abs(a[i]-a[i+k-1]),abs(a[i]-a[i+k-1])+abs(a[i+k-1])));
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N,cnt=0;
	cin >> N;
	FOR(i,1,N+1){
		ll k;
		cin >> k;
		if(k!=i)cnt++;
	}
	cout << (cnt<=2?"YES":"NO") << endl;
}


Measured memory_bytes: 256
n = int(input())
#アルファベットのリスト
l = ['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']
#文字格納
j = []

while n > 0:
    j.insert(0 , l[n % 26])
    if n % 26 == 0:
        n = n // 26 - 1
    else:
        n = n // 26

print(''.join(j))

Measured memory_bytes: 9192
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;
const ll INF = 1LL<<50;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main(){

int N;
cin>>N;
int h[N+2],count=0;
h[0]=0;h[N+1]=0;
rep3(i,N+1){
    if(i!=N+1){
    cin>>h[i];
    }
    if(h[i]<h[i-1])count+=h[i-1]-h[i];
}


cout<<count<<endl;

return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>

int main()
{
    std::string s;
    std::cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
hs = [int(val) for val in input().split(' ')]
# num = len(hs)
# start_idx = None
# end_idx = None
# op_num = 0
# last_op_idx = None
# while sum(hs) > 0:
#     for i in range(num):
#         if hs[i] > 0:
#             hs[i] -= 1
#             last_op_idx = i
#             if i == num - 1:
#                 op_num += 1
#         else:
#             if i >= 1 and last_op_idx == i-1:
#                 op_num += 1
#print(op_num)




def recursion(hs, op_num):
    if not hs:
        return op_num-1
    if min(hs) >= 1:
        return recursion([val - 1 for val in hs], op_num+1)

    results = []
    curr_results = []
    for i in range(len(hs)):
        if hs[i] >= 1:
            curr_results.append(hs[i]-1)
        else:
            results.append(curr_results)
            curr_results = []
    results.append(curr_results)
    for result in results:
        op_num += recursion(result, 1)
    return op_num

print(recursion(hs, 0))


Measured memory_bytes: 3064
#include <iostream>

std::string binary_tree(std::string, std::string, char);

int main(int argc, char const *argv[]){

	char operation;
	std::string tree_A;
	std::string tree_B;

	while(std::cin >> operation >> tree_A >> tree_B){
		std::string answer = binary_tree(tree_A,tree_B,operation);
		std::cout << answer << std::endl;
	} 

	return 0;
}

std::string binary_tree(std::string tree_A, std::string tree_B, char operation){

	if(tree_A==tree_B){

		return tree_A;

	}else if(tree_A==""){

		if(operation=='i'){
			return tree_A;
		}else if(operation=='u'){
			return tree_B;
		}else{
			//exception
		} 

	}else if(tree_B==""){

		if(operation=='i'){
			return tree_B;
		}else if(operation=='u'){
			return tree_A;
		}else{
			//exception
		}

	}else{

		std::string node_A[2] = "";
		std::string node_B[2] = "";
		int period;

		period = 0;
		for (int i = 1; i < tree_A.length()-1; ++i){

			int bracket_count = 0;

			if(tree_A[i]=='('){
				do{
					node_A[period] += tree_A[i];
					if(tree_A[i]=='('){
						bracket_count += 1;
					}else if(tree_A[i]==')'){
						bracket_count -= 1;
					}else{
						//exception
					}
					i += 1;
				}while(bracket_count>0);
			}
			period++;
		}

		period = 0;
		for (int i = 1; i < tree_B.length()-1; ++i){

			int bracket_count = 0;

			if(tree_B[i]=='('){
				do{
					node_B[period] += tree_B[i];
					if(tree_B[i]=='('){
						bracket_count += 1;
					}else if(tree_B[i]==')'){
						bracket_count -= 1;
					}else{
						//exception
					}
					i += 1;
				}while(bracket_count>0);
			}
			period++;
		}


		std::string node[2];
		node[0] = binary_tree(node_A[0],node_B[0],operation);
		node[1] = binary_tree(node_A[1],node_B[1],operation);

		return "(" + node[0] + "," + node[1] + ")";
	}
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int C[26] = {0};
    for (int i = 0; i < 4; i++)
    {
        C[S[i] - 'A']++;
    }
    int cnt = 0;
    for (int i = 0; i < 26; i++)
    {
        if(C[i] == 2){
            cnt++;
        }
    }
    if(cnt == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var RGBN = Sarray();
            var R = RGBN[0];
            var G = RGBN[1];
            var B = RGBN[2];
            var N = RGBN[3];
            var ans = 0;
            for(var i=0;i<=N;i++)
            {
                for(var j=0;j<=N;j++)
                {
                    var tmp = N - R * i - G * j;
                    if (tmp >= 0 && tmp % B == 0) ans++;
                }
            }
            WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    lli val1 = h1 * 60 + m1;
    lli val2 = h2 * 60 + m2;
    lli p = abs(val2 - val1);
    lli ans = p - k;
    if (ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    string A,B,C;
    cin >> A >> B >> C;
    if (A.back() == B.front() && B.back() == C.front()){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

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

template<size_t mx>
class SnukeNumber{
private:
    constexpr long long int digitsum(long long int a){
        long long int ret = 0;
        while(a){
            ret += a % 10;
            a /= 10;
        }
        return ret;
    }

    constexpr long double f(long long int a){
        long long int ret = digitsum(a);
        return a / static_cast<long double>(ret);
    }

public:
    long long int ans[mx];

    constexpr SnukeNumber() : ans(){
        size_t cnt = 0;
        long double a = f(1), b = f(2);
        long long int s = 1, t = 1;
        
        for(long long int i = 1; cnt < mx; i += s){
            b = f(i + s);
            
            if(a < b){
                s = t;
                b = f(i + s);
            }
            if(a > b){
                if(s == t)t *= 10;
            }else{
                ans[cnt] = i;
                ++cnt;
            }
            
            long double tmp = a;
            a = b;
            b = tmp;
        }
    }
};

constexpr SnukeNumber<792> S = SnukeNumber<792>();

long long int K;

int main(){
    scanf("%lld", &K);
    for(int i = 0; i < K; ++i)printf("%lld\n", S.ans[i]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	string s;
	cin >> s;
	int f = 0;
	rep(i, 0, s.length() - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			f = 1;
		}
	}
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

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

    int count = 0;

    for (int i = 0; i < n-2; i++) {
        char a, b, c;
        a = s.at(i);
        b = s.at(i+1);
        c = s.at(i+2);
        if (a == 'A' && b == 'B' && c == 'C') {
            count += 1;
        }
    }
    

    cout << count << endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

ll a[10000001];

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i) {
            a[j]++;
        }
        ans += i * a[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81676
//In the Name of God
//Let Our Voices Echo
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define X real()
#define Y imag()
typedef long long ll;
typedef double ld; 
typedef complex<ld> point;
const ld eps=1e-9;
const int MAX=1e5+9,MOD=1e9+7;
ll a,b,c,t;
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>c;
	while (a%2==0 && b%2==0 && c%2==0)
	{
		int aa=b/2+c/2,bb=a/2+c/2,cc=b/2+a/2;
		a=aa;
		b=bb;
		c=cc;
		t++;
		if (t>1e6) break;
	}
	if (t>1e6) cout<<-1;
	else cout<<t;
	return 0;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

const int MAX_N = 200010;
ll arr[MAX_N];
int n;
ll k;

bool poss(ll length) {
    if(length == 0) return 0;
    ll cnt = 0;
    M00(i, n) {
        if(arr[i] <= length) continue;
        cnt += (arr[i]-1)/length;
    }
    return cnt <= k;
}

int main() { FAST
    cin >> n >> k;
    M00(i, n) cin >> arr[i];
    ll lo = 0;
    ll hi = ((ll)1e9)+5;
    while(lo+1 != hi) {
        ll mid = (lo+hi)/2;
        if(poss(mid)) hi = mid;
        else lo = mid;
    }
    finish(hi);
}



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	cin >> n;
	vector<int> w(n + 1);
	FOR(i, 1, n) {
		cin >> w[i];
	}
	int mindiff = INF;
	FOR(i, 2, n) {
		int diff = abs( accumulate(RANGE(w, 1, i),0) - accumulate(RANGE(w, i, n+1), 0) );
		if (mindiff > diff) {
			mindiff = diff;
		}
	}
	pv(mindiff);
	return(0);
}

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

int main() {
	int n;
	cin >> n;
	map<int, int> m;
	
	for(int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		if(m.find(temp) != m.end()) {
			cout << "NO";
			return 0;
		} 
		m[temp] = 1;
	}
	
	cout << "YES";
	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<20;

int p[MAX];

int main()
{
  ll sum = 0;
  int n;

  scanf("%d", &n); n *= 3;
  REP(i, n) scanf("%d", &p[i]);

  sort(p, p + n, greater<int>());
  REP(i, n/3)
    sum += p[2*i+1];

  printf("%lld\n", sum);

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
ll h[maxn], a[maxn], id[maxn], seg[maxn * 4];
void upd(int pos, ll val, int id = 1, int l = 0, int r = n - 1)
{
    if(l == r)
    {
        seg[id] = val;
        return;
    }
    int mid = (l + r) / 2;
    if(pos <= mid) upd(pos, val, id * 2, l, mid);
    else upd(pos, val, id * 2 + 1, mid + 1, r);
    seg[id] = max(seg[id * 2], seg[id * 2 + 1]);
}
ll query(int x, int y, int id = 1, int l = 0, int r = n - 1)
{
    if(r < x || l > y) return 0;
    if(l >= x && r <= y) return seg[id];
    int mid = (l + r) / 2;
    return max(query(x, y, id * 2, l, mid), query(x, y, id * 2 + 1, mid + 1, r));
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) id[i] = i;
    sort(id + 1, id + n + 1, [&](int a, int b)
    {
        return h[a] < h[b];
    });
    for(int i = 1; i <= n; i++)
    {
        ll mx = query(0, id[i] - 1);
        upd(id[i] - 1, mx + a[id[i]]);
    }
    cout << query(0, n - 1) << "\n";
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main() {
	int A,B,C;
	C=0;
	char D[6];
	cin >> A >> B;
	for (int i = A; i <= B; i++){
		snprintf(D,6,"%d",i);
		if (D[0]==D[4]&&D[1]==D[3]){
			C++;
		}
	}
	cout << C << endl;
}

Measured memory_bytes: 256
#include<cassert>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<valarray>

using namespace std;

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

int can[20010];
int ispow[20010];

bool ok(int m, int n, int p, int q) {
  int mul = m * m + n * n;
  if ((m * p + n * q) % mul) return false; 
  if ((m * q - n * p) % mul) return false; 
  return true;
}

void solve() {
  int p, q;
  cin >> p >> q;
  int m = p * p + q * q;
  rep (i, m) if (can[i] && m % i == 0 && can[m / i]) {
    cout << "C" << endl;
    return;
  }
  cout << "P" << endl;
  return;
}

int main() {
  rep (i, 20010) can[i] = false;
  rep (i, 20010) rep (j, 20010) {
    if (i * i + j * j >= 20010) break;
    if (i * i + j * j <= 1) continue; 
    can[i * i + j * j] = true;
  }
  rep (i, 20010) ispow[i] = false;
  rep (i, 20010) if (i * i < 20010) ispow[i] = true;
  int t;
  cin >> t;
  rep (i, t) solve();
  return 0;
}

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

//#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define N_MIN 1
#define N_MAX 100000

#define X_MIN 0
#define X_MAX 100000

#define T_MIN 1
#define T_MAX 100000
int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}

int main(int argc, char **argv) {
	char s[4];
	fscanf(stdin,"%s",s);
	if (strcmp(s,"SUN") == 0) {
		fprintf(stdout,"7\n");
		return 0;
	}
	if (strcmp(s,"MON") == 0) {
		fprintf(stdout,"6\n");
		return 0;
	}
	if (strcmp(s,"TUE") == 0) {
		fprintf(stdout,"5\n");
		return 0;
	}
	if (strcmp(s,"WED") == 0) {
		fprintf(stdout,"4\n");
		return 0;
	}
	if (strcmp(s,"THU") == 0) {
		fprintf(stdout,"3\n");
		return 0;
	}
	if (strcmp(s,"FRI") == 0) {
		fprintf(stdout,"2\n");
		return 0;
	}
	if (strcmp(s,"SAT") == 0) {
		fprintf(stdout,"1\n");
		return 0;
	}
	assert(0);
	return 0;
}



Measured memory_bytes: 128
str     = input()

input   = int(str)

if input < 100:
    if input ==0:
        out = 'NA'
    elif input < 13:
        out = 'YYMM'
    else:
        out = 'NA'
elif input < 1300:
    if input % 100 == 0:
        out = 'MMYY'
    elif input%100 < 13:
        out = 'AMBIGUOUS'
    else:
        out = 'MMYY'
elif input%100==0:
    out = 'NA'
elif input%100<13:
    out = 'YYMM'
else:
    out = 'NA'
print(out)

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



int main() {
int N;
cin >> N;
int D, X;
cin >> D >> X;
int choco[110];
for(int i = 0; i < N; i++){
cin >> choco[i];
}

for(int i = 0; i < N; i++){
    int niti = 1;
while(D >= niti){
niti += choco[i];
X++;
}


}
cout << X << endl;

}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

signed main()
{
	int N;
	int a[1000];
	cin >> N;
	rep(i, N) cin >> a[i];
	sort(a, a+N);
	int res = 0;
	rep(i, N-1) {
		res += a[i+1] - a[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
p = [k - q for _ in range(n)]

for i in a:
	p[i-1] += 1

for i  in p:
	if i >= 1:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 11796
S = input().strip()[::-1]
mod = 10**9+7
n = len(S)
d = [[0]*13 for _ in range(n+1)]
d[0][0] = 1
b = 1
for i in range(n):
    for k in range(13):
        for j in range(10) if S[i] == "?" else [int(S[i])]:
            d[i+1][(k+(j*b))%13] += d[i][k]
            d[i+1][(k+(j*b))%13] %= mod
    b = b*10%13
print(d[n][5])

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

int main() {
	int ans = 0;
	string str1;
	while(cin >> str1){
		string str2(str1);
		reverse(str2.begin(),str2.end());
		if(str1 == str2) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
const int N = 1e6 + 10, Mod = 1e9 + 7;
int n, m, q, r, t, a, b, c, d, A[N];
int main()
{
    string s;
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; i++)
        for (int j = i; j <= n; j++)
        {
            string t = s.substr(0, i);
            string p = s.substr(j, n - j);
            if (t + p == "keyence")
                return !printf("YES");
        }
    printf("NO");
    return (0);
}

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

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	int arr[n], xo = 0;
	for(int i = 0; i < n; ++i){
		cin>>arr[i];
		xo^=arr[i];
	}
	for(int i = 0; i < n; ++i){
		cout<<(xo^arr[i])<<" ";
	}
}




Measured memory_bytes: 4332
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(){
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    vector<int> xa, ya;
    int n = (int) s.size();
    int flag = 0;
    int flag2 = 0;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'T') {
            if(flag2 == 0) flag2 = 2;
            if(flag == 0 && cnt > 0) {
                xa.push_back(cnt);
            }
            else if(flag == 1 && cnt > 0)ya.push_back(cnt);
            cnt = 0;
            flag = (flag + 1) % 2;
        }
        else {
            if(flag2 == 0) flag2 = 1;
            cnt++;
        }
    }
    if(cnt > 0 && flag == 0) xa.push_back(cnt);
    else if(cnt > 0 && flag == 1) ya.push_back(cnt);
    set<int> xt, yt;
    xt.insert(0);
    yt.insert(0);
    for(int i = 0; i < (int)xa.size(); i++){
        set<int> t;
        for(auto v: xt){
            t.insert(v + xa[i]);
            if(flag2 == 1 && i == 0) continue;
            t.insert(v - xa[i]);
        }
        xt.swap(t);
    }
    for(int i = 0; i < (int)ya.size(); i++){
        set<int> t;
        for(auto v: yt){
            t.insert(v + ya[i]);
            t.insert(v - ya[i]);
        }
        yt.swap(t);
    }
    int ans = 0;
    for(auto v: xt){
        if(v == x) ans++;
    }
    for(auto v: yt){
        if(v == y) ans++;
    }
    if(ans == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4128
n = int(input())
lp = list(map(int, input().split()))

count = 0

for i in range(1, n-1):
	if lp[i+1] > lp[i] and lp[i] >= lp[i-1]:
		count += 1
	elif lp[i-1] > lp[i] and lp[i] >= lp[i+1]:
		count += 1


print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int clorlim[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200};

int main() {
  int N;
  cin>>N;
  vector<int> v;
  REP(i,0,N){
    int tmp;
    cin>>tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());

  vector<int> tv;
  //set<int> tv;
  set<int> s;
  REP(i,0,N){
    bool flag = false;
    REP(j,0,8){
      if(v[i] < clorlim[j]){
        s.insert(j);
        flag = true;
        break;
      }
    }
    if(!flag){
      tv.push_back(v[i]);
      //tv.insert(v[i]);
    }
  }

  cout<<max(1, (int)s.size())<<" "<<s.size() + tv.size()<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200005],n,k;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int main (){
	int i,x,ans=0;
	n=read();k=read();
	for (i=1;i<=n;i++)
	{x=read();a[x]++;}
	sort(a+1,a+200001);
	for (i=200000;i>=200001-k;i--)
	{ans-=a[i];}
	ans+=n;
	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import itertools, math

S = input().split()
N = int(S[0])
D = int(S[1])

X = []

for i in range(N):
    X.append([int(x) for x in input().split()])

count = 0

for p in itertools.combinations(X, 2):
    sum = 0
    for i in range(0, D):
        sum += pow(abs(p[0][i] - p[1][i]), 2)
    if math.modf(math.sqrt(sum))[0] == 0.0:
        count += 1

print(count)

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n), a(10, 3);
  for(int i = 0; i < n; i++) {
    cin >> b.at(i);
    if(b.at(i) > i+1) {
      cout << -1;
      exit(0);
    }
  }
  for(int i = 0; i < n; i++) {
   a.insert(a.begin() + b.at(i), b.at(i));  
  }
  for(int i = 1; i < n+1; i++) {
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 256