akhauriyash/Code-Regression huggingface dataset:
/*	Success may not come to me immediately,
 *	but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li	int64_t
#define ld	double_t
#define ulli	uint64_t
//=====================================================================
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define repi(i,v)	for(i=v.begin();i!=v.end();i++)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
#define nl		cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>	 vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb	push_back
#define pob	pop_back
#define pf	push_front
#define pof	pop_front
#define all(v)	v.begin(),v.end()
#define itr	iterator
#define sz	size()
#define lb	lower_bound
#define ub	upper_bound
#define bs	binary_search
#define mp	make_pair
#define F	first
#define S	second
//=====================================================================
#define mod	1000000007
#define inf	1000000000000000005
#define MX1	100005
#define MX2	1000005
#define pi	acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li a[105],dp[105][10005],n;

li f(li idx,li sum){
	if(idx==n){
		if(sum%10==0) return -inf;
		return sum;
	}
	if(dp[idx][sum]!=-1) return dp[idx][sum];
	li ans=0;
	ans=max(ans,f(idx+1,sum+a[idx]));
	ans=max(ans,f(idx+1,sum));
	return dp[idx][sum]=ans;
}

void solve(){
	li i;cin>>n;
	rep(i,0,n) cin>>a[i];
	mset(dp,-1);
	li ans=f(0,0);
	cout<<ans;
}

int main(){
    opt
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    li t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b, T;	
  cin >> n >> a >> b;
 
  T = n * a;
  
  if (T < b) cout << T << endl;
  else if (T > b) cout << b << endl;
  else cout << T << endl;
  
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if (a<b) {
    cout << "a" << " " << "<" << " " << "b" << endl;
  }
  
  else if (a>b) {
    cout << "a" << " " << ">" << " " << "b" << endl;
  }
  
  else if (a==b) {
    cout << "a" << " " << "==" << " " << "b" << endl;
  }
  return 0;
}


Measured memory_bytes: 3056
from math import gcd
n=int(input())
l=list(map(int,input().split()))
mal=max(l)
e=[i for i in range(mal+1)]

x=2
while x*x <= mal:
    if x == e[x]:
        for m in range(x, len(e), x):
            if e[m] == m:
                e[m] = x
    x+=1
#print(e)    
s=set()
f=0
for i in l:
  st = set()
  while i > 1:
    st.add(e[i])
    i//=e[i]
  if not s.isdisjoint(st):
    f=1
    break
  s |= st

if f==0:
    print('pairwise coprime')
    exit()
p=l[0]
for i in range(1,n):
    p=gcd(p,l[i])
if p==1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 134580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		//long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;
		long[] array=new long[3];

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		//Arrays.sort(array);
		if(n<1200) {
			System.out.println("ABC");
		}else if(n<2800){
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main() {
    string s;
    int k, sl;
    cin >> s >> k;
    sl = s.length();

    unordered_set<string> st;

    for(int i=0; i<sl; i++) {
        for(int j=1; j<=k && i+j-1<sl; j++) {
            st.insert(s.substr(i, j));
        }
    }

    vector<string> vec(st.begin(), st.end());
    sort(vec.begin(), vec.end());

    cout << vec[k-1] << endl;

    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N; cin >> N;
    vector<string> S (N);
    
    map<char, int> occ;
    for (char c : "abcdefghijklmnopqrstuvwxyz") occ[c] = 100;

    F0R(i, N) {
        string t; cin >> t;
        map<char, int> temp;
        for (char c : t) ++temp[c];
        for (auto x : occ) occ[x.first] = min(temp[x.first], x.second);
    }

    string ans;
    for (auto x : occ) ans += string (x.second, x.first);
    cout << ans;
}

Measured memory_bytes: 256
n = int(input())
s = input()
mod = 10 ** 9 + 7
if n == 1:
    print(3)
    exit()
if s[0] == s[1]:
    i = 2
    rslt = 6
    flag = True
else:
    i = 1
    rslt = 3
    flag = False
while i < n:
    if i != n-1 and s[i] == s[i + 1]:
        if flag:
            rslt = rslt * 3 % mod
        else:
            rslt = rslt * 2 % mod
        i += 2
        flag = True
    else:
        if not flag:
            rslt = rslt * 2 % mod
        i += 1
        flag = False

print(rslt)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int gcd(int p, int q)
{
    int a, b;
    if (p > q)
    {
        a = p;
        b = q;
    }
    else
    {
        a = q;
        b = p;
    }
    while (a % b != 0)
    {
        int c = a % b;
        a = b;
        b = c;
    }

    return b;
}

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> x(N, 0);
    REP(i, N)
    {
        cin >> x[i];
    }
    
    sort(x.begin(), x.end());
    
    int startIndex = -1;
    REP(i, N)
    {
        if (X < x[i])
        {
            startIndex = i;
            break;
        }
    }
    if (startIndex == -1) startIndex = N;
    

    vector<int> diffX(N, 0);
    if (N == 1)
    {
        diffX[0] = abs(X - x[0]);
    }
    else
    {
        REP(i, N - 1)
        {
            diffX[i] = x[i + 1] - x[i];
        }
    }
    int ans = diffX[0];
    
    REP(i, N - 2)
    {
        ans = gcd(ans, diffX[i + 1]);
    }

    if (startIndex == 0)
    {
        ans = gcd(ans, x[0] - X);
    }
    else if (startIndex == N)
    {
        ans = gcd(ans, X - x[N - 1]);
    }
    else
    {
        ans = max(gcd(ans, x[startIndex] - X), gcd(ans, X - x[startIndex - 1]));
    }

    cout << ans << endl;
}


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

long long X;

int main(){
	cin >> X;
	for(long long i = 0; i < 10; i++) {
		if(X >= 400 + 200 * i && X <  600 + 200 * i) {
			cout  << 8 - i << endl;
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    int h[n+1];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    h[n] = 1000000000;
    int i=0;
    long long ans = 0;
    while(i <= n-1){
        while(h[i] == 0){
            i ++;
        }
        if(i == n){
            break;
        }
        int min = 1000000000;
        int left = i;
        int right = i;
        for(int j=i;j<n;j++){
            if(h[j] == 0){
                break;
            }
            if(min > h[j]){
                min = h[j];
            }
            right = j;
        }
        
        for(int j = left;j<=right;j++){
            h[j]-= min;
        }
        ans += min;
        
        while(h[i] == 0){
            i ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 3e5 + 10 , mod = 998244353;

char s[maxn];
int n;
int pos[maxn][3];
int cnt[3];
int sum[maxn][3];
int bel[maxn];

int main(){
	cin >> n >> s;
	memset(cnt , 0 , sizeof cnt);
	for(int i = 0 ; i < 3 * n ; ++ i){
		if(s[i] == 'R')
			pos[++ cnt[0]][0] = i;
		else if(s[i] == 'G')
			pos[++ cnt[1]][1] = i;
		else
			pos[++ cnt[2]][2] = i;
	}
//	for(int i = 1 ; i <= n ; ++ i)
//		cout << pos[i][0] << " " << pos[i][1] << " " << pos[i][2] << endl;
	for(int i = 1 ; i <= n ; ++ i){
		int t1 = min(min(pos[i][0] , pos[i][1]) , pos[i][2]) , t2 = max(max(pos[i][0] , pos[i][1]) , pos[i][2]);
		bel[t1] = 0;
		bel[t2] = 2;
		for(int k = 0 ; k < 3 ; ++ k)
			if(pos[i][k] != t1 && pos[i][k] != t2){
//				cout << i << " " << k << endl;
				bel[pos[i][k]] = 1;
			}
	}
//	for(int i = 0 ; i < 3 * n ; ++ i)
//		cout << bel[i] << " ";
//	cout << endl;
	memset(cnt , 0 , sizeof cnt);
	cnt[0] = n;
	int ans = 1;
	for(int i = 0 ; i < 3 * n ; ++ i){
		ans = 1ll * ans * cnt[bel[i]] % mod;
		cnt[bel[i]] --;
		if(bel[i] != 2) cnt[bel[i] + 1] ++;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    int n;
    cin >> n;
    unordered_map<int, int> o;
    unordered_map<int, int> e;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        if (i % 2 == 0) e[v]++;
        else o[v]++;
    }
    pair<int, int> omax1 = make_pair(0, 0);
    pair<int, int> emax1 = make_pair(0, 0);
    for (auto& p : o) {
        if (p.second > omax1.second)
            omax1 = p;
    }
    for (auto& p : e) {
        if (p.second > emax1.second)
            emax1 = p;
    }
    int ans;
    if (omax1.first != emax1.first) {
        ans = n / 2 - omax1.second + n / 2 - emax1.second;
    } else {
        o.erase(omax1.first);
        e.erase(emax1.first);
        pair<int, int> omax2 = make_pair(0, 0);
        pair<int, int> emax2 = make_pair(0, 0);
        for (auto& p : o) {
            if (p.second > omax2.second)
                omax2 = p;
        }
        for (auto& p : e) {
            if (p.second > emax2.second)
                emax2 = p;
        }
        ans = min(n / 2 - omax1.second + n / 2 - emax2.second, n / 2 - omax2.second + n / 2 - emax1.second);
    }
    cout << ans << endl;

    return 0;
}


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

bool isNotEasy(int i, char c);
int main(){
  string tap;
  cin >> tap;
  for(int i=1; i<=tap.size(); i++){
    if(isNotEasy(i, tap[i-1])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
bool isNotEasy(int i, char c){
  if(i%2==0) return c=='R';
  return c=='L';
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, x;
	cin >> n >> x;

	int a[n];
	rep(i, n) cin >> a[i];

	sort(a, a+n);

	int sm = 0;
	int ans = 0;
	rep(i, n){
		if(sm + a[i]> x) break;
		if(i == n-1){
			if(sm + a[i] == x) ans++;
		}else{
			sm += a[i];
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k,q;
	cin >> n >> k >> q;
	int a[n+1];
	for(int i=1;i<=n;i++)
		a[i]=k-q;
	while(q--){
		int x;
		cin >> x;
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		if(a[i]>0)
			cout <<  "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 1024
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0093
public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		boolean isFirst = true;
		while (true) {
			int a, b;
			a = sc.nextInt();
			b = sc.nextInt();
			if (a == 0 && b == 0) break;
			if (isFirst) 
				isFirst = false;
			else
				System.out.println();
			
			boolean find = false;
			for (int y = a; y <= b; y++) {
				boolean isLeap = false;
				if (y % 4 == 0) {
					if (y % 100 == 0) {
						if (y % 400 == 0)
							isLeap = true;
					} else {
						isLeap = true;
					}
				}
				
				if (isLeap) {
					find = true;
					System.out.println(y);
				}
			}
			
			if (!find)
				System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;
const int maxn = 200200;

void solve()
{
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (s.size() == n) cout << "YES\n";
    else cout << "NO\n";
}


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





Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<stack>
//#include<ctime>
using namespace std;

const int maxn = 1E5 + 10;
typedef long long LL;

int n,m,N,tp,cur;
LL stk[maxn],Ans[maxn],f[maxn];

inline LL getLL()
{
	char ch = getchar(); LL ret = 0;
	while (ch < '0' || '9' < ch) ch = getchar();
	while ('0' <= ch && ch <= '9')
		ret = ret * 10LL + 1LL * (ch - '0'),ch = getchar();
	return ret;
}

char ss[22];
inline void Print(LL x)
{
	if (!x) {putchar('0'); return;} int len = 0;
	while (x) ss[++len] = x % 10LL,x /= 10LL;
	for (int i = len; i; i--) putchar(ss[i] + '0');
}

void Print_Ans()
{
	for (int i = n - 1; i; i--) Ans[i] += Ans[i + 1];
	for (int i = 1; i <= n; i++)
		Print(Ans[i]),putchar(i == n ? '\n' : ' ');
}

int main()
{
	
	stk[tp = 1] = n = getLL(); m = getLL();
	if (!m)
	{
		for (int i = 1; i <= n; i++)
			printf("1 ");
		return 0;
	}
	for (int i = 1; i <= m; i++)
	{
		LL x = getLL();
		while (tp && stk[tp] >= x) --tp;
		stk[++tp] = x;
	}
	N = stk[1]; f[tp] = 1;
	if (tp == 1) {Ans[N] = 1,Print_Ans(); return 0;}
	for (int i = tp; i; i--)
	{
		if (!f[i]) continue;
		LL len = stk[i],ti = f[i];
		for (;;)
		{
			if (len <= N) {Ans[len] += ti; break;}
			int pos = lower_bound(stk + 1,stk + tp + 1,len) - stk;
			LL Mod = stk[pos - 1],t = len / Mod; f[pos - 1] += t * ti;
			len %= Mod; if (!len) break;
		}
	}
	Print_Ans();
	//cerr << (double)(clock()) / CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
using namespace std;
int main () {
  int N;
  cin >> N;
  int A = 0;
  int B = 0;
  int AB = 0;
  int ans = 0;
  for (int j = 0; j < N; j ++) {
    string S;
    cin >> S;
    if (S[0] == 'B') {
      if (S[S.size() - 1] == 'A') AB ++;
      else B ++;
    }
    else if (S[S.size() - 1] == 'A') A ++;
    for (int i = 0; i < S.size() - 1; i ++) {
      if (S[i] == 'A' && S[i + 1] == 'B') ans ++;
    }
  }
  int k = min(A, B) + AB;
  if (A + B == 0 && AB != 0) k --;
  ans += k;
  cout << ans << endl;
}



Measured memory_bytes: 256
s=input()
d=input()
v=sorted(list(map(str,s)))
w=sorted(list(map(str,d)),reverse=True)
a=""
b=""
for i in range(len(s)):
  a += v[i]
for c in range(len(d)):
  b += w[c]
if a==b:
  print("No")
else:
  print("Yes") if max([a,b])==b else print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5+7;

int p[MAXN];
int parent(int u) {
    if (u==p[u]) return u;
    return p[u] = parent(p[u]);
}

int a[MAXN], b[MAXN], c[MAXN];
int done[MAXN];

vector< int >edg[MAXN];
vector< int >child[MAXN];

LL bsum[MAXN];
void dfs(int u) {
    bsum[u] = b[u];
    for (int v : child[u]) {
        dfs(v);
        bsum[u] += bsum[v];
    }
//    cout << "bsum[" << u << "] = " << bsum[u] << endl;
}

int root;
LL solve(int u, LL upore) {
    if (child[u].empty()) return max(upore, bsum[root]+c[u]);

    LL ans = 1e18;
    for (int v : child[u]) {
        LL tmp = bsum[root]-bsum[v]+c[u];
        ans = min(ans, solve(v, max(upore, tmp)));
    }

//    cout << "ans[" << u << "] = " << ans << endl;
    return ans;
}

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

    vector< int >order(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];

        c[i] = max(a[i]-b[i], 0);
        order[i-1] = i;
        p[i] = i;
    }

    sort(order.begin(), order.end(), [&](int i, int j) {
        return c[i] < c[j];
    });

    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }

    for (int u : order) {
//        cout << "c[" << u << "] = " << c[u] << endl;
        for (int v : edg[u]) {
            if (done[v]) {
                int pv = parent(v);
                if (pv != u) {
                    child[u].push_back(pv);
                    p[pv] = u;
//                    cout << "parent[" << pv << "] = " << u << endl;
                }
            }
        }
        done[u] = 1;
//        cout << u << " done" << endl;
    }

    root = order.back();
    dfs(root);
    cout << solve(root, 0) << "\n";


    return 0;
}


Measured memory_bytes: 22156
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,r;
    cin>>N;
    string S="";
    while(N!=0){
        r=N%2;
        if(r<0) r+=2;
        N=(N-r)/(-2);
        S+=(char)('0'+r);
    }
    reverse(S.begin(),S.end());
    if(S=="") cout<<"0"<<endl;
    else cout<<S<<endl;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
l = [Counter(input()) for _ in range(n)]
c = Counter()

for s in [chr(97+i) for i in range(26)]:
    c[s] = 10**12
    for d in l:
        c[s] = min(c[s], d[s])

s = ""
for j in [chr(97+i) for i in range(26)]:
    s += j*c[j]
print(s)


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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main(){
ll K,N; cin>>K>>N;
vi A(N);
REP(i,N){
    cin>>A.at(i);
    }
ll ans=0;
REP(i,N-1){
    ll tmp=A.at(i+1)-A.at(i);
    if(tmp>ans){
        ans=tmp;
    }
}
if((K-A.at(N-1)+A.at(0))>ans) {
    ans=(K-A.at(N-1)+A.at(0));

  }
  cout<<K-ans<<endl;
}

Measured memory_bytes: 4020
N = int(input())
h = list(map(int, input().split()))

h += [0]
prev = 0
imos = [None] * (N + 1)
for i in range(N + 1):
    imos[i] = h[i] - prev
    prev = h[i]
    
# print("#", h)
# print("#", imos)
ans = sum([int(item > 0) * item for item in imos])
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


#define MOD 998244353

long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}


long long dp[3005][3005];


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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	dp[a][b] = 1;

	for (int x = a; x <= c; x++) {
		for (int my = b; my <= d; my++) {
			(dp[x + 1][my + 1] += dp[x][my] * x) %= MOD;
		}
		for (int my = b; my <= d; my++) {
			(dp[x + 1][my] += dp[x + 1][my - 1] * x) %= MOD;
		}
		for (int my = b; my <= d; my++) {
			(dp[x + 1][my] += dp[x][my] * my) %= MOD;
		}
	}
	long long ans = 0;
	rep(my, d + 1) {
		(ans += dp[c][my] * pow_mod(c, d - my)) %= MOD;
	}
	cout << ans % MOD << endl;


	return 0;
}


Measured memory_bytes: 74044
#include<bits/stdc++.h>
using namespace std;
int n,k,a,d[10],ans;

bool check(int x){
  bool res=true;
  while(x){
    if(d[x%10])res=false;
    x/=10;
  }
  return res;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<k;i++){
    cin>>a;
    d[a]=1;
  }
  ans=n;
  while(!check(ans++));
  cout<<--ans<<endl;
  return 0; 
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    boolean ok = true;
    for (int i = 0; i < n; i++) {
      int t = in.nextInt();
      if (t % 2 == 0 && !(t % 3 == 0 || t % 5 == 0)) {
        ok &= false;
      }
    }
    System.out.println(ok ? "APPROVED" : "DENIED");
  }
}


Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int X = scanner.nextInt();

        int count = 0;

        for (int i = 0; i <= A; i++) { // 500
            for (int j = 0; j <= B; j++) { // 100
                for (int k = 0; k <= C; k++) { // 50
                    int candidate = 500*i + 100*j + 50*k;
                    if (candidate == X) count++;
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,c,fans=0;
    int x,h[1000];
    cin >> n >> m >> c;
    for(int i = 0; i < m; i ++){
        cin >> h[i];
    }
    for(int i = 0; i < n; i ++){
        int ans = 0;
        for(int j =0; j < m; j ++){
            cin >> x;
            ans += h[j] * x;
        }
        //cout <<"ans"<< ans;
        if(ans + c > 0){
            fans++;
        }
    }
    cout << fans << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    ans = 0.0
    Rate = 380000.0
    for  i in range(N):
        otosidama, otype = input().split()
        otosidama = float(otosidama)
        if otype == "JPY":
            ans +=otosidama
        else:
            ans += otosidama*Rate
    
    print(ans)










if __name__== "__main__":
    main() 

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;


int main(void){
	int a,N;
	double sum=0;
	double ave;
	double min1=150;
	vector<int> A;

	cin>>N;
	for(int i=0; i<N; i++){
		cin>>a;
		sum+=a;
		A.push_back(a);
	}
	ave=sum/(double)N;	

	for(int i=0; i<N; i++)min1=min(min1,fabs(A[i]-ave));

	for(int i=0; i<N; i++){
		if(min1==fabs(A[i]-ave)){
			std::cout<<i<<std::endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

#define MAX 100000

int func(int);

 int main(){
     int N = 0;
     int ans = MAX;
     scanf("%d", &N);

     for (int A = 1; A <= N / 2; A++){
         int B = N - A;
         int tempA = func(A);
         int tempB = func(B);

         int temp = tempA + tempB;

         if (ans > temp){
             ans = temp;
         }
     }
     
     printf("%d", ans);

     return 0;

}

 int func(int X){

     int ans = 0;
     for (int loop = 0; loop < 5; loop++){
         ans += (int)(X - (X / 10 * 10.0));
         X = (int)(X / 10.0);
     }
     
     return ans;

 }


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n + 1,0);
    for(int i = 1; i < n + 1; i++){
        cin >> a.at(i);
    }
    
    int ball_num = 0;
    
    for(int i = n; i > 0; i--){
        int j = 2, count = 0;
        while(i * j <= n){
          count += b.at(i * j);
          j++;
        }
        count %= 2;
        if(a.at(i) == count){
            b.at(i) = 0;
        }else{
            b.at(i) = 1;
            ball_num++;
        }
    }
    
    cout << ball_num << endl;
    
    for(int i = 1; i < n + 1; i++){
        if(b.at(i) == 1){
            cout << i << " ";
        }
    }
    
}

Measured memory_bytes: 2432
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int n=Integer.parseInt(br.readLine());

	int matrix[][]=new int[n][n];

	for(int i=0;i<n;i++){
	    String str[]=br.readLine().split(" ");

	    int u=Integer.parseInt(str[0])-1;
	    int k=Integer.parseInt(str[1]);
	    for(int j=2;j<2+k;j++){
		int v=Integer.parseInt(str[j])-1;
		matrix[u][v]=1;
	    }
	}

	int dist[]=bfs(matrix,n,0);

	for(int i=0;i<n;i++){
	    System.out.println((i+1)+" "+dist[i]);
	}
	
    }
    static int[] bfs(int matrix[][],int n,int s){
	boolean used[]=new boolean[n];
	int dist[]=new int[n];

	Arrays.fill(dist,-1);

	Queue<Integer> q=new ArrayDeque<>();

	used[s]=true;
	dist[s]=0;
	q.add(s);

	while(!q.isEmpty()){
	    int now=q.poll();

	    for(int i=0;i<n;i++){
		if(matrix[now][i]==1&&!used[i]){
		    used[i]=true;
		    dist[i]=dist[now]+1;
		    q.add(i);
		}
	    }
	}
	return dist;
    }
}



Measured memory_bytes: 24440
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
string s;

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

    cin >> s;
    cout << s[0] << s[1] << s[2] << "\n";

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 10;

int A[maxn], B[maxn] = {0};

int main(){
    int n, k, anw = 0, num;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> num;
        A[i] = num;
        B[num] = i;
    }
    for(int i = 1; i <= n; i++){
        cout << B[i] << ' ';
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
/*
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) a=a*a%MOD;
		else res=res*a%MOD;
		b>>=1;
	}
	res=res*a%mod;
	return res;
}
*/
ll cnt[maxn];
char c[]={'M','A','R','C','H'};
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n){
		string s;
		cin>>s;
		REP(j,5) if(s[0]==c[j]) cnt[j]++;
	}
	ll ans=cnt[0]*cnt[1]*cnt[2]
		  +cnt[0]*cnt[1]*cnt[3]
		  +cnt[0]*cnt[1]*cnt[4]
		  +cnt[0]*cnt[2]*cnt[3]
		  +cnt[0]*cnt[2]*cnt[4]
		  +cnt[0]*cnt[4]*cnt[3]
		  +cnt[2]*cnt[1]*cnt[3]
		  +cnt[2]*cnt[1]*cnt[4]
		  +cnt[4]*cnt[1]*cnt[3]
		  +cnt[2]*cnt[4]*cnt[3];
	cout<<ans<<'\n';



	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

ans = 0
min_ = a[0]
for i in range(1, len(a)):
    if a[i] < min_:
        ans += min_-a[i]
    else:
        min_ = a[i]
print(ans)


Measured memory_bytes: 32140
#include <cstdio>
#include <algorithm>

const int kN = 1e5;
int red[kN], green[kN], colorless[kN];

int X, Y, A, B, C;

bool cmp(int a, int b) {
    return a > b;
}

int main() {
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
    for (int i = 1; i <= A; i++) {
        scanf("%d", red + i);
    }
    for (int i = 1; i <= B; i++) {
        scanf("%d", green + i);
    }
    for (int i = 1; i <= C; i++) {
        scanf("%d", colorless + i);
    }
    std::sort(red + 1, red + 1 + A, cmp);
    std::sort(green + 1, green + 1 + B, cmp);
    std::sort(colorless + 1, colorless + 1 + C);

    int tail = C;
    while((X || Y) && C) {
        if ((X == 0 || colorless[C] <= red[X]) && (Y == 0 || colorless[C] <= green[Y])) {
            break;
        }
        if (X && (red[X] <= green[Y] || Y == 0)) {
            X--;
            C--;
        } else if (Y && (red[X] > green[Y] || X == 0)) {
            Y--;
            C--;
        }
    }
    long long ans = 0;
    for (int i = C + 1; i <= tail; i++) {
        ans = ans + colorless[i];
    }
    for (int i = 1; i <= X; i++) {
        ans = ans + red[i];
    }
    for (int i = 1; i <= Y; i++) {
        ans = ans + green[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1280
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        s: chars,
    }
    let mut gl_ma = 0;
    for diff in 1..n {
        let mut ma = 0;
        let mut cur = 0;
        for i in 0..n - diff {
            if s[i] == s[i + diff] {
                cur += 1;
            } else {
                cur = 0;
            }
            ma = max(ma, cur);
        }
        gl_ma = max(gl_ma, min(ma, diff));
    }
    puts!("{}\n", gl_ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n, i;
	cin >> n >> i;

	cout << (1+n-i) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t;string inp;
int main()
{
	cin>>t;int ac=0,wa=0,tle=0,re=0;
	while(t--)
	{
		cin>>inp;
		if(inp=="AC")ac++;
		else if(inp=="WA")wa++;
		else if(inp=="TLE")tle++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  int ans=3;
  cin>>a>>b>>c;
  if(a==b)ans--;
  if(a==c)ans--;
  if(b==c)ans--;
  if(ans==0)ans++;
  o(ans);
}

Measured memory_bytes: 256
N = int(input())
m = [input() for _ in range(2)]

i = 0
count = 0
prestate = -1
while i < N:
    if i == 0:
        if m[0][0] != m[1][0]:
            count = 6
            prestate = 0
            i += 2
        else:
            count = 3
            prestate = 1
            i += 1
    else:
        if m[0][i] == m[1][i]: 
            if prestate == 1:
                count *= 2
                count %= int(1e9+7)
            i += 1
            prestate = 1
        else:
            if prestate == 0:
                count *= 3
            else:
                count *= 2
            count %= int(1e9+7)
            i += 2
            prestate = 0
            
print(count)

Measured memory_bytes: 38384
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
     cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    cout << n-k+1 <<endl;


}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
       printf("a < b\n");
       }
    if(a>b){
      printf("a > b\n");
      }
    if(a==b){
      printf("a == b\n");
      }
	return 0;
}

Measured memory_bytes: 1008
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DPredictionAndRestriction {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, K;
        in>>N>>K;
        vc<int> P(3);
        for(auto& p : P) in>>p;
        string T;
        in>>T;
        vvc<int> dp(N+1, vc<int>(3, 0));
        for(int i=N-1;0<=i;--i){
            if(i+K<N){
                REP(j, 3) REP(k, 3){
                    if(j!=k) chmax(dp[i][j], dp[i+K][k]);
                }
            }
            if(T[i]=='r') dp[i][2] += P[2];
            else if(T[i]=='s') dp[i][0] += P[0];
            else dp[i][1] += P[1];
        }
        int ans = 0;
        REP(i, K){
            int mx = 0;
            REP(j, 3) chmax(mx, dp[i][j]);
            ans += mx;
        }
        out<<ans<<'\n';
    }
};


int main() {
	DPredictionAndRestriction solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5840
using System;

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine().Split();

        int A = int.Parse(line[0]);
        int B = int.Parse(line[1]);

        string str = "No";
        if(A % 2 != 0 && B % 2 != 0)
        {
            str = "Yes";
        }
        Console.WriteLine(str);
    }
}


Measured memory_bytes: 13140
main :: IO ()
main = do
  s1 <- readLn :: IO Int
  let s  = mod s1 60
  let m  = mod (s1 `div` 60) 60
  let h = s1 `div` 3600
  putStrLn $ (show h) ++ ":" ++ (show m) ++ ":" ++ (show s)



Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			String str = sc.next();
			if(str.equals("-")) {
				break;
			}
			
			int m = sc.nextInt();
			for(int i = 0; i < m; i++) {
				int n = sc.nextInt();
				str = str.substring(n, str.length()) + str.substring(0, n);
			}
			
			System.out.println(str);
		}
	}
}


Measured memory_bytes: 26208
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
int main(){
	int n;
	while(scanf("%d",&n),n){
		int k[12800]={0};
		int mi = 10000000;
		rep(i,n){
			scanf("%d",&k[i]);
		}
		int cnt = 0;
		int plus = 0;
		rep(i,n){
			if(k[i] > 0){
				k[i]--;
				cnt++;
			}
		}
		bool flg = false;
		rep(i,n){
			if(k[i] > 0){
				flg = true;
				break;
			}
		}

		if(!flg){
			puts("NA");
		}
		else printf("%d\n",cnt+1);
	}
	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

constexpr int MAXN = 5 + 1000;
int a[MAXN];

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  ll n,k; cin >> n >> k;
  ll ans = n;
  for (int i = 0; i < 100; ++i) {
    if (n >= k) {
      n %= k;
    } else {
      n = abs(n-k);
    }
    ans = min(ans, n);
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{
	int a;
	int count = 0;
	cin >> a;

	if (a >= 100) {
		count++;
		a -= 100;
	}
	if (a >= 10) {
		count++;
		a -= 10;
	}
	if (a >= 1) {
		count++;
	}

	cout << count;
}



Measured memory_bytes: 256
# 約数を全部列挙する関数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:  # 9の約数の場合、3*3で割る方も割られる方も同じ数のため、こういう組み合わせを除外。12の約数を求める場合3がもとまったら、4も約数。 int型で返すため, //で計算。
                divisors.append(n // i)
    return sorted(divisors)


N = int(input())

# NがKで一度も割れない場合, 最終的に1になるには、NmodK=1のため, N=aK+1と表される。そのため、K=N-1/aのため、Kは1を除く、N-1の全ての約数
count = len(divisors(N - 1)) - 1

for K in divisors(N)[1:]:
    N_ = N
    while N_ % K == 0:
        N_ = N_ // K
    N_ = N_ % K
    if N_ == 1:
        count += 1

print(count)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

LLI A[200007] = {};

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);
    for( i=1; i<=N; i++)
    {
        scanf("%lld", &A[i]);
    }

    map< LLI, int> mp;

    for( i=1; i<=N; i++)
    {
        mp[ (i-1)-A[i] ]++;
    }

    LLI goal = -1;
    LLI ans = 0;
    for( i=1; i<=N; i++)
    {
        mp[ (i-1)-A[i] ]--;
        goal += ( A[i] - A[i-1]) + 1;

        ans += mp[ goal ];
    }

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

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 28008
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int b,k;
int main(){
	string a;
	cin>>b>>k;
	cin>>a;
	if(a[k-1]==	'A')
		a[k-1]='a';
	if(a[k-1]==	'B')
		a[k-1]='b';
	if(a[k-1]==	'C')
		a[k-1]='c';
		
	cout<<a;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;
int main(void){
    int a,b;
    string s,t,u;
    cin >>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)a--;
    if(t==u)b--;
    cout << a<<" "<<b;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <cstdint>
#include <bits/stdc++.h>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;

int qp(int a, ll b)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
  } while (b >>= 1);
  return ans;
}
int qp(int a, ll b, int mo)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);

vector<ll> dp(100001, false);

bool f(ll x)
{
  if (x == 0)
    return true;
  else if (x < 0)
    return false;
  else if (dp[x] == true)
  {
    return true;
  }
  else
  {
    bool flag = false;

    for (ll i = 0; i <= 5; i++)
    {
      flag |= f(x - 100 - i);
      if (flag)
      {
        return dp[x] = true;
      }
    }

    return false;
  }
}

int main(void)
{

  ll x;
  cin >> x;

  //cout << (ll)f(x) << endl;
  dp[0] = 1;

  for (ll j = 0; j < 6; j++)
  {
    for (ll i = 0; i <= 100000; i++)
    {
      if (i + 100 + j >= 0 && i + 100 + j <= 100000 && dp[i] == 1)
        dp[i + 100 + j] = 1;
    }
  }

  cout << dp[x] << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return t * t % mod;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = t * t % mod;
    return k * x % mod;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % mod;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

Measured memory_bytes: 1024
S = gets.chomp
if S == 'SUN'
  puts 7
elsif S == 'MON'
  puts 6
elsif S == 'TUE'
  puts 5
elsif S == 'WED'
  puts 4
elsif S == 'THU'
  puts 3
elsif S == 'FRI'
  puts 2
else
  puts 1
end


Measured memory_bytes: 1788
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:usize = read();
    let mut cnt = 0;
    for _ in 0..n {
        let a:usize = read();
        let b:usize = read();
        cnt += b-a+1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352