akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
vector<pair<int,int> > V;

int main(){
    int N , k , i , j;
    scanf( "%d%d" , &N , &k );

    if( k > ( ( N - 1 ) * ( N - 2 ) ) / 2  ){
        puts( "-1" );
        return 0;
    }

    int Cur = ( ( N - 1 ) * ( N - 2 ) ) / 2;
    i = 2 , j = 3;

    while( Cur > k ){
        V.emplace_back( make_pair( i , j  ) );
        ++j;
        --Cur;

        if( j == N + 1 ){
            ++i;
            j = i + 1;
        }
    }

    int M = N - 1 + int(V.size());
    printf( "%d\n" , M );

    for( i = 2 ; i <= N ; ++i )
        printf( "1 %d\n" , i );
    
    for( i = 0 ; i < V.size() ; ++i )
        printf( "%d %d\n" , V[i].first , V[i].second );
    return 0;
}

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

using namespace std;

const int N = 1e5 + 9;
int n, abc[N][3], dp[N][3];

int sol(int i, int ch){
    if(i==n-1) return abc[i][ch];

    int &ret = dp[i][ch];
    if(~ret) return ret;

    return ret = max(abc[i][ch]+sol(i+1, (ch+1)%3),
                     abc[i][ch]+sol(i+1, (ch+2)%3));
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

    memset(dp, -1, sizeof dp);
    cout << max({sol(0, 0), sol(0, 1), sol(0, 2)});
}


Measured memory_bytes: 8832
fun main(args: Array<String>) {
    val (a, b, n) = readLine()!!.split(' ').map { it.toLong() }

    fun calc(a: Long, b:Long, x:Long):Long {
        val ad = a.toDouble()
        val bd = b.toDouble()
        val xd = x.toDouble()
        val ret = (Math.floor(ad * xd / bd) - ad * Math.floor(xd / bd)).toLong()
        return ret
    }

    println(calc(a, b, Math.min(n, b-1)))
}


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

const int N = 1e5 + 100;

long long n, a[N], ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i && a[i] && a[i - 1]) {
			a[i - 1]--;
			a[i]--;
			ans++;
		}
		ans += a[i] >> 1;
		a[i] &= 1;
	}
	cout << ans;	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
	ninja
	int t; 
	ll n,m;
	cin>>n>>m;
	vector<ll> v(n);
	ll s=0;
	for(ll i=0;i<n;i++){
		cin>>v[i];s+=v[i];
	}
	ll p=4*m;
	float tre = ((float)s/(float)p);
	sort(all(v),greater<ll>());
	ll c=0;
	bool f=1;
	for(ll i=0;i<n;i++){
		if((float)v[i]>=(float)tre){
			c++;
			if(c==m){
				break;
			}
		}
		else{
			f=0; break;
		}
	}
	if(f)
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve1(){
 int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0){
        n=n/k;
        cnt++;
    }
   cout<<cnt<<endl;
}
/*
void solve2(){
 int x,y;
 cin>>x>>y;
 int temp=1,ans=0;
 while(temp<=x){
    temp=temp*y;
    ++ans;
 }
 cout<<ans<<endl;
}
*/
int main()
{
    
    solve1();
   // solve2();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int k=0,a=0,b=0,boo=0;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    for(int i=a;i<=b;i++){
	if(i%k==0){
	    boo=1;
	    break;
	}
    }

    if(boo==1)
	printf("OK\n");
    else 
	printf("NG\n");

    return 0;
}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m ; cin >> n >> m;
  ll isok[m];
  REP(i,m){
      isok[i] = 0;
  }
  REP(i,n){
      ll k; cin >> k;
      REP(j,k){
          ll a; cin >> a;a--;
          isok[a]++;
      }
  }
  ll ans = 0;
  REP(i,m){
      if(isok[i] == n){
          ans++;
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
def insertionSort(A, N):
    for i in range(0, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join(map(str, A)))


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    insertionSort(A, N)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> v[4];
  ll M;
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    if(!i) M=x;
    v[x-M].pb(y);
  }
  rep(i,4) sort(all(v[i]),greater<ll>());
  ll ans=0,d1=0;
  rep(i,v[0].size()+1) {
    ll d2=0;
    rep(j,v[1].size()+1) {
      ll d3=0;
      rep(k,v[2].size()+1) {
        ll d4=0;
        rep(l,v[3].size()+1) {
          if(M*i+(M+1)*j+(M+2)*k+(M+3)*l>m) break;
          ans=max(ans,d1+d2+d3+d4);
          if(l==v[3].size()) break;
          d4+=v[3][l];
        }
        if(k==v[2].size()) break;
        d3+=v[2][k];
      }
      if(j==v[1].size()) break;
      d2+=v[1][j];
    }
    if(i==v[0].size()) break;
    d1+=v[0][i];
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

const int N=1e5+5;

vector<int> adj[N];
int n,m;
int dp[N][2];
bool used[N];

void bfs()
{
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int node=q.front();
        q.pop();
        for(int i=0;i<adj[node].size();i++)
        {
            int next=adj[node][i];
            if(!used[next])
            {
                used[next]=1;
                dp[next][0]=dp[node][0]+1;
                dp[next][1]=node;
                q.push(next);
            }
        }
    }
}
bool check()
{
    for(int i=1;i<=n;i++)
    {
        if(!dp[i][1])return 0;
    }
    return 1;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    bfs();
    if(!check())cout<<"No";
    else
    {
        cout<<"Yes"<<'\n';
        for(int i=2;i<=n;i++)
        {
            cout<<dp[i][1]<<'\n';
        }
    }
}


Measured memory_bytes: 10828
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int A,B; cin>>A>>B;
	for (int x=1; x<=10000; x++) {
		int u=8*x/100, v=10*x/100;
		if(u==A&&v==B) {
			cout<<x<<"\n";
			return 0;
		}
	}
	cout<<-1<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

int main() {
    std::vector<int> vec(1000, 0);
    int accm = 0;
    for (int i = 1; i <= 999; i++) {
        accm += i;
        vec[i] = accm;
    }
    int a, b;
    std::cin >> a >> b;
    int diff = b - a;
    std::cout << vec[diff] - b << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k - 1] << endl;
    return 0;
}

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

int main()
{
    int n,T,c,t;
    cin >> n >> T;

    int ans = 1001;
    rep(i,n) {
        cin >> c;
        cin >> t;
        if(t <= T) {
            ans = min(ans,c);
        }
    }

    if (ans == 1001) {
        cout << "TLE" << endl;
        return 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())
    A = [[int(i) for i in input().split()] for j in range(M)]
    S = [0]*(N+2)
    for le, ri in A:
        S[le] += 1
        S[ri+1] += -1
    ans = 0
    for i in range(N):
        S[i+1] += S[i]
        if S[i+1] == M:
            ans += 1
    # print(S)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60984
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int X,Y;
  cin>>X>>Y;
  cout<<X+Y/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, A, B;
  cin >> n >> A >> B;
  string x;
  cin >> x;
  int suma=0, sumb=0, sumab=0;
  for(int i=0; i<n; i++){
      if(x.at(i)=='c') {
          cout << "No" << endl;
      }
      if(x.at(i)=='a'){
          
          if(sumab<A+B){
          suma++;
          cout << "Yes" << endl;
          sumab++;
             }
          else cout << "No" << endl;
      }
      if (x.at(i)=='b'){
          
          if(sumab<A+B && sumb<B){
          sumb++;
          cout << "Yes" << endl;
          sumab++;
          }
          else cout << "No" << endl;
      }
  }
 // cout << suma << sumb << sumab << endl;
  return 0;
}


Measured memory_bytes: 896
import sys
readline = sys.stdin.readline

# そこまでの最小値を記録する
# 最小値との差が最大になった時点で、その値を記録し、1を計上
# 最小値との差がこれまでの最大値と同じ場合は+1を計上
# 最小値との差の最大値が更新された場合はまた1から計上
# Tは関係ない

N,T = map(int,readline().split())
A = list(map(int,readline().split()))

minval = 10 ** 9 + 1 # そこまでの最小値
maxdiff = 0 # そこまでの差の最大値
ans = 0
for a in A:
  if a < minval:
    minval = a
    continue
  diff = a - minval
  if diff > maxdiff:
    maxdiff = diff
    ans = 1
  elif diff == maxdiff:
    ans += 1

print(ans)

Measured memory_bytes: 14628
/*
二分木は、子が一つしかなくても、それが右の子か左の子かラベル付けされていなければならないようだ。
以下のは、ラベル付けがされている答えと、されてない私の実行結果の違いである。（inorderが違くなる）

 ALDS1_7_C: Tree Walk test cace 6より

7
0 -1 -1
1 -1 4
4 5 -1
2 3 1
3 -1 0
6 -1 -1
5 6 -1

 correct answer
Preorder
 2 3 0 1 4 5 6
Inorder
 3 0 2 1 6 5 4
Postorder
 0 3 6 5 4 1 2

 my answer 
Preorder
 2 3 0 1 4 5 6
Inorder
 0 3 2 6 5 4 1
Postorder
 0 3 6 5 4 1 2
*/


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


using namespace std;

class Rooted_Tree
{

public:
	int id;  //idはなくす。　全部添え字で管理　そうしないと配列内でidに対してfindしないといけなくなり、実行時間増えるので
	int parent;
	//int degree;
	int l_sub; //left subtree.
	int r_sub; //right subtree.

	Rooted_Tree()
    {
        id = parent = -1;
    }

};


void Preorder(vector<Rooted_Tree> &rt, int id){

	cout << " " << id;
	if(rt[id].l_sub!=-1) Preorder(rt, rt[id].l_sub);
	if(rt[id].r_sub!=-1) Preorder(rt, rt[id].r_sub);
}

void Inorder(vector<Rooted_Tree> &rt, int id){

	if(rt[id].l_sub!=-1) Inorder(rt, rt[id].l_sub);
	cout << " " << id;
	if(rt[id].r_sub!=-1) Inorder(rt, rt[id].r_sub);
}

void Postorder(vector<Rooted_Tree> &rt, int id){

	if(rt[id].l_sub!=-1) Postorder(rt, rt[id].l_sub);
	if(rt[id].r_sub!=-1) Postorder(rt, rt[id].r_sub);
	cout << " " << id;
}


bool asc(const Rooted_Tree &right, const Rooted_Tree &left){ return right.id < left.id;}

int main() {
	int i,j,i_buf;
	int n;
	vector<Rooted_Tree> rt;
	vector<int> out_buf;

	//input
	// 標準入出力をファイルに変更////////////////////////////////////////////////////////
    //FILE* fp_in = freopen("\\\\k1300\\k1300\\s1350010\\.windows\\Desktop\\input_data.txt", "r", stdin);
	/////////////////////////////////////////////////////////////////////////////////////
	cin >> n;
	for(i=0; i<n; i++){
		Rooted_Tree buf;
		cin >> buf.id;
		cin >> buf.l_sub;
		cin >> buf.r_sub;
		rt.push_back(buf);
	}
	// ファイルを閉じる//////////////////////////////////////////////////////////////////
    //fclose(fp_in);
	/////////////////////////////////////////////////////////////////////////////////////
	

	//id==添え字　にする
	sort(rt.begin(), rt.end(), asc);
	
	// fill parent
	//ID==iのnodeが持っている子のnodeを埋めていく。
	for(i=0; i<n; i++){
		if(rt[i].l_sub !=-1) rt[ rt[i].l_sub ].parent=rt[i].id;
		if(rt[i].r_sub !=-1) rt[ rt[i].r_sub ].parent=rt[i].id;
	}

	//出力はout_bufにためて、output_node()で成形して出す。
	for(i=0; i<n; i++){
		//rootをさがす。わざわざループ使わなくてもfindとかでもいいが、構造体のvectorなので検索専用の関数作るのめんどくさいからやめた
		if(rt[i].parent==-1){
			printf("Preorder\n");
			Preorder(rt, i);
			cout << endl;

			printf("Inorder\n");
			Inorder(rt, i);
			cout << endl;

			printf("Postorder\n");
			Postorder(rt, i);
			cout << endl;

			break;
		}
	}
	

	
	return 0;
}

Measured memory_bytes: 1204
import sys
from itertools import combinations
from collections import Counter
n, x, y = [int(i) for i in sys.stdin.readline().split()]
x -= 1
y -= 1
ls = [[0 for i in range(n)] for j in range(n)]
for i, j in combinations(range(n), 2):
    ls[i][j] = min(abs(i - j), abs(y - j) + abs(x - i) + 1)
ct = Counter()
for i in range(n):
    ct.update(ls[i])
for i in range(1, n):
    print(ct[i])

Measured memory_bytes: 83548
#!/usr/bin/env python

def main():
    n = int(input())
    s = input()

    lst = [[] for _ in range(10)]
    numset = set()

    for i in range(n):
        num = int(s[i])
        lst[num].append(i)

    cnt = 0
    for i in range(10):
        if lst[i] == []:
            continue
        for k in range(10):
            if lst[k] == []:
                continue
            p_min = lst[i][0]
            p_max = lst[k][-1]
            if p_max - p_min <= 1:
                continue
            for j in range(10):
                for p in lst[j]:
                    if p_min < p < p_max:
                        cnt += 1
                        break
                    elif p >= p_max:
                        break

    print(cnt)


if __name__ == '__main__':
    main()


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

using namespace std;

struct Card {
    char suit;
    int value;

    bool operator==(const Card &c) const {
        return suit == c.suit && value == c.value;
    }
};

void BubbleSort(Card A[], int N) {
    for (int i = 0; i < N; ++i) {
        for (int j = N - 1; j >= i + 1; --j) {
            if (A[j].value < A[j - 1].value) {
                swap(A[j], A[j - 1]);
            }
        }
    }
}

void SelectionSort(Card C[], int N) {
    for (int i = 0; i < N; ++i) {
        int minj = i;
        for (int j = i; j < N; ++j) {
            if (C[j].value < C[minj].value) {
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
}

bool IsStable(Card in[], Card out[], int N) {
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int a = 0; a < N; ++a) {
                for (int b = a + 1; b < N; ++b) {
                    if (in[i].value == in[j].value && in[i] == out[b] && in[j] == out[a]) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

void Print(Card A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

int main() {
    Card inCards[100], bubbleSortedCards[100], selectionSortedCards[100];
    int N;

    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> inCards[i].suit >> inCards[i].value;
    }

    for (int i = 0; i < N; ++i) {
        bubbleSortedCards[i] = inCards[i];
        selectionSortedCards[i] = inCards[i];
    }

    BubbleSort(bubbleSortedCards, N);
    SelectionSort(selectionSortedCards, N);

    Print(bubbleSortedCards, N);
    if (IsStable(inCards, bubbleSortedCards, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    Print(selectionSortedCards, N);
    if (IsStable(inCards, selectionSortedCards, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
N, K, Q = [int(value) for value in input().split(' ')]
A = [int(input()) for _ in range(Q)]

points = [K - Q] * N

for value in A:
    points[value - 1] += 1

for point in points:
    if point <= 0:
        print('No')
    else:
        print('Yes')


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

int main(){
  string s;
  cin >> s;
  bool f = true;
  sort(s.begin(), s.end());
  for(int i = 0; i < s.size() - 1; i++){
    if(s[i] == s[i + 1]){
      cout << "no" << endl;
      f = false;
      break; 
    }
  }
  if(f){ cout << "yes" << endl;}
}

Measured memory_bytes: 256
s = input()
a = int(s[:2])
b = int(s[2:])
f_yymm = False
f_mmyy = False

if 1 <= a <= 12:
  f_mmyy = True
if 1 <= b <= 12:
  f_yymm = True
    
if f_yymm and f_mmyy:
  print("AMBIGUOUS")
elif f_yymm and (not f_mmyy):
  print("YYMM")
elif (not f_yymm) and f_mmyy:
  print("MMYY")
else:
  print("NA")
  


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    vector<int> abc(26);

    REP(i, s.size())
        abc[(s[i] - 'a')]++;
    
    REP(i, abc.size())
        if (abc[i] == 0) {
            cout << char(i + 'a') << endl;
            exit(0);
        }
        
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int ans = 0;
  rep(i, N) {
    int a; in(a);
    int count = 0;
    while (a % 2 == 0) {
      ++count;
      a /= 2;
    }
    ans += count;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
N = int(input())

bit = []

for i in range(16):
    if N > 0:
        if N % 26 == 0:
            bit.append(26)
            N //= 26
            N -= 1
        else:
            bit.append(N % 26)
            N //= 26

appear = False
res = ""
for b in bit[::-1]:
    if (not appear) and b != 0:
        appear = True
    if appear:
        res = res + chr(96+b)

print(res)

Measured memory_bytes: 9196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main byakko = new Main();
		String string, encode, source = "";
		
		while((string = reader.readLine()) != null){
			encode = "";
			if(string.length() % 2 != 0) string += "0";
			for(int i = 0; i < string.length() - 1; i += 2){
				source = byakko.pocketPager(string.substring(i, i + 2));
				if(source.equals("NA")) break;
				else encode += source;
			}
			if(source.equals("NA")) System.out.println("NA");
			else System.out.println(encode);
		}
		reader.close();
	}
	
	public String pocketPager(String source){
		if(source.equals("11")) return "a";
		if(source.equals("12")) return "b";
		if(source.equals("13")) return "c";
		if(source.equals("14")) return "d";
		if(source.equals("15")) return "e";
		if(source.equals("21")) return "f";
		if(source.equals("22")) return "g";
		if(source.equals("23")) return "h";
		if(source.equals("24")) return "i";
		if(source.equals("25")) return "j";
		if(source.equals("31")) return "k";
		if(source.equals("32")) return "l";
		if(source.equals("33")) return "m";
		if(source.equals("34")) return "n";
		if(source.equals("35")) return "o";
		if(source.equals("41")) return "p";
		if(source.equals("42")) return "q";
		if(source.equals("43")) return "r";
		if(source.equals("44")) return "s";
		if(source.equals("45")) return "t";
		if(source.equals("51")) return "u";
		if(source.equals("52")) return "v";
		if(source.equals("53")) return "w";
		if(source.equals("54")) return "x";
		if(source.equals("55")) return "y";
		if(source.equals("61")) return "z";
		if(source.equals("62")) return ".";
		if(source.equals("63")) return "?";
		if(source.equals("64")) return "!";
		if(source.equals("65")) return " ";
		return "NA";
	}
}

Measured memory_bytes: 24176
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(N);
    ll d;
    int w;
    for(int h=1;h<=3500;h++){
        for(int n=1;n<=3500;n++){
            d=4*h*n-N*n-N*h;
            if(d>0&&(N*h*n)%d==0){
                w=(N*h*n)/d;
                out(h,n,w);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3832
# by the authority of GOD    author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n,x,t = map(int,input().split())
    print((n//x + (n%x!=0))*t)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 62580
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

bool a[100][100];
ll dp[100][100];

void solve()
{
    IN(h, w);
    rep(i, h)
    {
        string s; cin >> s;
        rep(j, w)
        {
            a[j][i] = s[j] == '.';
        }
    }
    rep(y, h)
    {
        rep(x, w)
        {
            dp[x][y] = INF;
        }
    }
    dp[0][0] = !a[0][0];
    rep(y, h)
    {
        rep(x, w)
        {
            if (x > 0) chmin(dp[x][y], dp[x-1][y] + (a[x-1][y] != a[x][y]));
            if (y > 0) chmin(dp[x][y], dp[x][y-1] + (a[x][y-1] != a[x][y]));
        }
    }
    cout << (dp[w-1][h-1] + !a[w-1][h-1]) / 2 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define Maxn 100007
#define modp 998244353
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,cnt=0;
int pre[350007],inv[350007];
char a[Maxn],b[Maxn],c[Maxn],d[Maxn];
bool x[Maxn],y[Maxn],z[Maxn],w[Maxn];
long long power(long long a,long long b)
{
	long long res=1,now=a,left=b;
	while (left>0)
	{
		if (left%2==1) res=(1LL*res*now)%modp;
		now=(1LL*now*now)%modp;
		left/=2;
	}
	return res%modp;
}
int calc(int x,int y)
{
	if (x<y) return 0;
	int res=(1LL*pre[x]*inv[y])%modp;
	res=(1LL*res*inv[x-y])%modp;
	return res;
}
int get(int a,int b,int c)
{
	if (a==0&&b==0&&c==0) return 1;
	else if (b==0) return 0;
	else return calc(a+b+c-1,b-1);
}
int solve()
{
	int cnt1=0,cnt2=0;
	for (int i=1;i<=n;i++)
	{
		if (x[i]) ++cnt1;
		if (y[i]) ++cnt2;
	}
	int tot1=0,tot2=0;
	for (int i=1;i<=m;i++)
	{
		if (z[i]) ++tot1;
		if (w[i]) ++tot2;
	}
	int res=0,del=0;
	int p=0,q=0;
	for (int i=1;i<=m;i++)
	{
		if (z[i]==false&&w[i]==false) continue;
		del=(del+get(p,cnt1,q))%modp;
		if (z[i]&&w[i]) del=(2LL*del)%modp;
		if (z[i]) ++q,--tot1;
		if (w[i]) ++p,--tot2;
		res=(res+1LL*del*get(tot1,cnt2,tot2)%modp)%modp;
	}
	return res%modp;
}
int main()
{
	n=read(),m=read();
	pre[0]=1;
	for (int i=1;i<=350000;i++)
		pre[i]=(1LL*pre[i-1]*i)%modp;
	inv[350000]=power(pre[350000],modp-2)%modp;
	for (int i=350000;i;i--)
		inv[i-1]=(1LL*inv[i]*i)%modp;
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	scanf("%s",d);
	memset(x,false,sizeof(x));
	memset(y,false,sizeof(y));
	memset(z,false,sizeof(z));
	memset(w,false,sizeof(w));
	for (int i=0;i<n;i++)
	{
		if (a[i]=='0') x[i+1]=false; else x[i+1]=true;
		if (b[i]=='0') y[i+1]=false; else y[i+1]=true;
		if (x[i+1]) ++cnt;
		if (y[i+1]) ++cnt;
	}
	for (int i=0;i<m;i++)
	{
		if (c[i]=='0') z[i+1]=false; else z[i+1]=true;
		if (d[i]=='0') w[i+1]=false; else w[i+1]=true;
		if (z[i+1]) ++cnt;
		if (w[i+1]) ++cnt;
	}
	if (cnt==0)
	{
		printf("%d\n",1);
		return 0;
	}
	int ans=solve()%modp;
	swap(x,z);
	swap(y,w);
	swap(n,m);
	ans=(ans+solve())%modp;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <deque>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  int q, count = 0;
  cin >> q;
  deque<char> front;
  deque<char> back;
  
  rep(i, q) {
    int t;
    cin >> t;
    if(t == 1) {
      count++;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if((f == 1 && count % 2 == 0) || (f == 2 && count % 2 == 1)) {
        front.push_front(c);
      } else {
        back.push_back(c);
      }
    }
  }
  if(count % 2 == 0) {
    for(int i = 0; i < front.size(); i++) {
      cout << front[i];
    }
    cout << s;
    for(int i = 0; i < back.size(); i++) {
      cout << back[i];
    }
  } else {
    reverse(s.begin(), s.end());
    for(int i = back.size() - 1; i >= 0; i--) {
      cout << back[i];
    }
    cout << s;
    for(int i = front.size() - 1; i >= 0; i--) {
      cout << front[i];
    }
  }
}

Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    while(true){
        int n,x;
        cin >> n >> x;
        if(n+x==0) break;
        int ans=0;
        for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) for(int k=j+1;k<=n;k++){
            if(i+j+k==x) ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3092
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
D = [abs(A[i] - A[i-1]) for i in range(1, N+2)]
s = sum(D)
for i in range(N):
	ans = s - D[i] - D[i+1]
	ans += abs(A[i+2] - A[i])
	print(ans)

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    print(max(a - b * 2, 0LL));

    return 0;
}


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

int main() {
  int k;
  cin >> k;
  int x = 7%k;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x*10+7)%k;
    ++i;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 50512
H, W = map(int, input().split())
S = [input() for _ in range(H)]

for i in range(H):
    l = ''
    for j in range(W):
        if S[i][j] == '#':
            l += '#'
        else:
            l += str(sum([s[max(0, j-1):min(W, j+2)].count('#') for s in S[max(0, i-1):min(H, i+2)]]))
    print(l)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

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

// a^n mod を計算する
long int modpow(long int a, long int n, long int mod) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

long int modcomb(long int a, long int b, long int mod){
    long int res = 1;
    for(long int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
    }
    res %= mod;
    for(long int i = 1; i <= b; i++){
        long int i_inv = modpow(i, mod - 2, mod);
        res *= i_inv % mod;
        res %= mod;
    }
    res %= mod;
    // cout << res << endl;
    return res;
}

int main(){
    long int mod = 1000000007;
    long int n, k;
    cin >> n >> k;
    rep(i, k){
        if (k - 1 < i || n - k + 1 < i) {
            cout << 0 << endl;
            continue;
        }
        
        long int ans;
        ans = modcomb(k - 1, i, mod) * modcomb(n - k + 1, i + 1, mod);
        ans %= mod;
        cout << ans << endl;
    }
    

}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int min=0;
  int i, j;
  int N;
  int tmp;
  scanf("%d", &N);
  int A[N];
  for(i=0; i<N; ++i){
	scanf("%d", &A[i]);
  }
  int index;
  int count=0;
  for(i=0; i<(N-1); ++i){
	tmp=A[i];
	min=A[i];
	for(j=i+1; j<N; ++j){
	  if(min>A[j]){
		min=A[j];
		index=j;
	  }
	}
	if(tmp!=min){
	  A[i]=min;
	  A[index]=tmp;
	  ++count;
	}
  }
  for(i=0; i<N; ++i){
	printf("%d", A[i]);
	if(i<(N-1))
	  printf(" ");
}
  printf("\n");
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2100
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	string s;
	cin >> s;
	int ans=0;
	rep(i,4){
		if(s[i]=='+') ans++;
		else ans --;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N;
    cin >> N;
    vector<int> A, _A;
    int in;
    rep(_, N) {
        cin >> in;
        A.push_back(in);
        _A.push_back(in);
    }

    sort(all(_A));

    int diff = 0;
    rep(i, sz(A)) {
        if (A[i] != _A[i]) ++diff;
    }

    if (diff <= 2) prints("YES");
    else prints("NO");

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{

    int x;
    cin>>x;
    if(x>=400 && x<=599)
    {
        cout<<8;
    }
    if(x>=600 && x<=799)
    {
        cout<<7;
    }
    if(x>=800 && x<=999)
    {
        cout<<6;
    }
    if(x>=1000 && x<=1199)
    {
        cout<<5;
    }
    if(x>=1200 && x<=1399)
    {
        cout<<4;
    }
    if(x>=1400 && x<=1599)
    {
        cout<<3;
    }
    if(x>=1600 && x<=1799)
    {
        cout<<2;
    }
    if(x>=1800 && x<=1999)
    {
        cout<<1;
    }


}






Measured memory_bytes: 3628
n = int(input())
s = list(map(int, input().split())) + [-1]
q = int(input())
t = map(int, input().split())
c = 0

for i in t:
    L = -1
    U = n
    while U - L > 1:
        x = (L+U) // 2
        if s[x] >= i: U = x
        else: L = x
    if s[U] == i: c += 1

print(c)


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

int main(){
  
  int num;
  double w,h;
  double bmi;

  while(scanf("%d,%lf,%lf",&num,&w,&h) != EOF){
    bmi = w/(h*h);
    if(bmi>=25) printf("%d\n",num);
  }

  return 0;

}

Measured memory_bytes: 1212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long middle = b - 1 - a;
    if (middle % 2 == 1) {
      System.out.println((middle / 2L) + 1L);
    } else {
      long front = a + middle / 2L;
      long back = n - b + 1L + middle / 2L;
      System.out.println(Math.min(front, back));
    }
  }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=100005;
int n,a[N],cnt[20],ans,st;
int f[1<<16],xs[1<<16];

int main(){
	n=read();
	for(int i=1;i<n;i++) {
		int u=read(),v=read(),w=read();
		a[u]^=w;a[v]^=w;
	}
	for(int i=0;i<n;i++) cnt[a[i]]++;
	for(int i=1;i<=15;i++){
		ans+=cnt[i]/2;st|=(cnt[i]&1)*(1<<(i-1));
	}
	int Lim=(1<<16)-1;
	for(int i=1;i<=Lim;i++) f[i]=f[i>>1]+(i&1); 
	for(int i=1;i<=Lim;i++) f[i]--; 
	for(int i=1;i<=Lim;i++) 
		for(int j=1;j<=15;j++)
			if(i&(1<<(j-1))){
				xs[i]=xs[i^(1<<(j-1))]^j;break;
			}
	for(int i=1;i<=st;i++){
		if(xs[i]) continue;
		for(int j=i&(i-1);j;j=(j-1)&i){
			if(xs[j]) continue;
			f[i]=min(f[i],f[j]+f[i^j]);
		}		
	}
	write(ans+f[st]);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;



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

    int n; cin >> n;
    std::vector<ll> a(n), b(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];

    ll life = 0;

    REP(i,n){
        if(a[i] < b[i]){
            life += (b[i]-a[i])/2;
        } else {
            life -= (a[i]-b[i]);
        }
    }

    life >= 0 ? cout << "Yes" << endl : cout << "No" << endl;


    return 0;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

int main()
{
	_upgrade
	int a, b; string s;
	cin >> a >> b >> s;
	bool ok = 1;
	if(sz(s) != a + b + 1)
		ok = 0;
	if(s[a] != '-')
		ok = 0;
	s[a] = '0';
	for(auto c: s)
		if(!('0' <= c && c <= '9'))
			ok = 0;
	cout << (ok ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

	int pdata[8];
	int cdata[8][8] = {
		{ 4, 1, 4, 1, 2, 1, 2, 1 },
		{ 4, 1, 2, 1, 2, 1, 4, 1 },
		{ 2, 1, 4, 1, 4, 1, 2, 1 },
		{ 2, 1, 2, 1, 4, 1, 4, 1 },
		{ 1, 4, 1, 4, 1, 2, 1, 2 },
		{ 1, 4, 1, 2, 1, 2, 1, 4 },
		{ 1, 2, 1, 4, 1, 4, 1, 2 },
		{ 1, 2, 1, 2, 1, 4, 1, 4 },
	};
	int ians, sans, sum;

	while (cin >> pdata[0]){

		for (int i = 1; i < 8; i++){
			cin >> pdata[i];
		}

		for (int i = 7; i >= 0; i--){
			sum = 0;
			for (int j = 0; j < 8; j++){
				if (pdata[j] > cdata[i][j]) sum += pdata[j] - cdata[i][j];
			}
			if (i == 7){
				ians = 7;
				sans = sum;
			}
			else if (sum < sans){
				ians = i;
				sans = sum;
			}
		}

		for (int i = 0; i < 7; i++){
			cout << cdata[ians][i] << " ";
		}
		cout << cdata[ians][7] << endl;

	}

	return 0;
}

Measured memory_bytes: 1156