akhauriyash/Code-Regression huggingface dataset:
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
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>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

VecVec tree;
Vec dp;

void dfs(ll node){
	if(dp[node]) return;
	ll max = -1;
	for(ll i : tree[node]){
		dfs(i);
		chmax(max, dp[i]);
	}
	dp[node] = max+1;
}

int main(void){
	ll n, m;
	cin >> n >> m;
	tree.resize(n);
	dp.resize(n);
	rep(i, m){
		ll x, y;
		cin >> x >> y;
		tree[--x].pb(--y);
	}

	rep(i, n) dfs(i);
	ll ans = 0;
	rep(i, n) chmax(ans, dp[i]);
	co(ans);

	return 0;
}


Measured memory_bytes: 8576
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	ll march[5] = { 0 };
	string check = "MARCH";
		
	vector<string> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		
		for (int j = 0; j < 5; j++)
		{
			if (s[i][0] == check[j])
			{
				march[j]++;
				break;
			}
		}
	}

	ll res = 0;

	res += march[0] * march[1] * march[2];
	res += march[0] * march[1] * march[3];
	res += march[0] * march[1] * march[4];
	res += march[0] * march[2] * march[3];
	res += march[0] * march[2] * march[4];
	res += march[0] * march[3] * march[4];
	res += march[1] * march[2] * march[3];
	res += march[1] * march[2] * march[4];
	res += march[1] * march[3] * march[4];
	res += march[2] * march[3] * march[4];
	cout << res << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int x, n; cin >> x >> n;
   vector<int> p(n);
   vector<bool> v(102,true);
   rep(i,n){
      int p; cin >> p;
      v[p] = false;
   }
   int dist = 101;
   int ans;
   rep(i,102){
      if(v[i] && dist > abs(x-i)){
         ans = i;
         dist = abs(x-i);
      }
   }
   cout << ans << endl;
}

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

typedef long in; 

in dp[3005][3005];

int main() 
{
    string a,b,s="";
    cin>>a>>b;
    
    in i,j,n=a.size(),m=b.size();
    
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=m;++j)
        {
            if(a[i-1]==b[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    // for(i=0;i<=n;++i)
    // {
    //     for(j=0;j<=m;++j)
    //     cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    
    i=n,j=m;
    
    while(i>0&&j>0)
    {
        if(dp[i][j]==(dp[i-1][j-1]+1)&&a[i-1]==b[j-1])
        {            s+=a[i-1];
            --i;
            --j;
        }
        else if(dp[i][j]==dp[i][j-1])
        {
            --j;
        }
        else if(dp[i][j]==dp[i-1][j])
        {
            --i;
        }
    }
    
    while(i>0&&j>0)
    {
        if(dp[i][j]==(dp[i-1][j-1]+1)&&a[i-1]==b[j-1])
        {            
            s+=a[i-1];
            --i;
            --j;
        }
        else if(dp[i][j]==dp[i][j-1])
        {
            --j;
        }
        else if(dp[i][j]==dp[i-1][j])
        {
            --i;
        }
    }
    
    for(i=s.size()-1;i>=0;--i)
    cout<<s[i];
		
	return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<cstdio>
using namespace std;
const int NIL = -1;
const int MAX = 10000;

typedef struct binaryTree{
	int parent, left, right;
}bTree;
bTree T[MAX];
int n;

void preParse(int u){
	if(u == NIL) return;
	printf(" %d", u);
	preParse(T[u].left);
	preParse(T[u].right);
}

void inParse(int u){
	if(u == NIL) return;
	inParse(T[u].left);
	printf(" %d",u);
	inParse(T[u].right);
}

void postParse(int u){
	if(u == NIL) return;
	postParse(T[u].left);
	postParse(T[u].right);
	printf(" %d",u);
}

int main(){
	int v, l, r, root;
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		T[i].parent = NIL;
	}
	for(int i = 0; i < n; i++){
		scanf("%d%d%d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	for(int i = 0; i < n; i++){
		if(T[i].parent == NIL) root = i;
	}
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 3192
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = n * n - a;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21204
from collections import Counter
from fractions import gcd
a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
g = gcd(a, b)
l = [1]
while g % 2 == 0:
    l.append(2)
    g /= 2
f = 3
while f * f <= g:
    if g % f == 0:
        l.append(f)
        g /= f
    else:
        f += 2
if g != 1:
    l.append(int(g))
cnt = Counter(l)
print(len(cnt))

Measured memory_bytes: 5288
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n;
    cin>>n;
    ll a[n];
    for (ll i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll height = 0;
    for (ll i = 1; i < n; ++i)
    {
        if(a[i]<a[i-1]){
            height += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }
    cout<<height;
}

Measured memory_bytes: 5004
#include<bits/stdc++.h>
using namespace std;
int n,nn;
int main(){
	scanf("%d",&n);
	for(int i=0;i<=n;i+=7){
		nn = n - i;
		if(nn % 4 == 0){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
using namespace std;


int main()
{
	
	int zorome[] ={111,222,333,444,555,666,777,888,999};
	int N;
	cin>>N;
	int entryNum = zorome[0];
	for(int i = 0 ;i < 8; i++){
		if( N > zorome[i]){
			entryNum = zorome[i+1];
		}
	}
	cout<<entryNum<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;
double pi = 3.141592653589793;

int main() {
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  long double Ax,Ay,Bx,By;
  Ax=A*cos((double)H*pi/6+(double)M*pi/360);
  Ay=A*sin((double)H*pi/6+(double)M*pi/360);
  Bx=B*cos((double)M*pi/30);
  By=B*sin((double)M*pi/30);
  cout << fixed << setprecision(15);
  cout << pow((Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By),0.5) << endl;
}

Measured memory_bytes: 4132
#include <cstdio>
#include <vector>
using namespace std;

int n;
int a[100000];
vector<int> v;
int ans;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	int c = 1;
	for(int i=1; i<n; i++){
		if(a[i] == a[i-1]){
			v.push_back(c);
			c = 1;
		}else{
			c++;
		}
	}
	v.push_back(c);

	if(v.size() == 1) ans = v[0];
	else if(v.size() == 2) ans = v[0] + v[1];
	else for(int i=0; i+2<v.size(); i++)
			ans = max(ans, v[i] + v[i+1] + v[i+2]);
/*
	for(int i=0; i<v.size(); i++){
		printf("%d\n", v[i]);
	}
*/
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    vector<vector<int>> v_s(200009, vector<int>()), v_t(200009, vector<int>());
    vector<int> used_s(26), used_t(26);

    string s, t;  cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (used_s[s[i] - 'a'] == 0) {
            used_s[s[i] - 'a'] = cnt;
            v_s[cnt].push_back(i);
            ++cnt;
        }
        else {
            v_s[used_s[s[i] - 'a']].push_back(i);
        }
    }
    cnt = 0;
    for (int i = 0; i < t.size(); ++i) {
        if (used_t[t[i] - 'a'] == 0) {
            used_t[t[i] - 'a'] = cnt;
            v_t[cnt].push_back(i);
            ++cnt;
        }
        else {
            v_t[used_t[t[i] - 'a']].push_back(i);
        }
    }

    for (int i = 0; i < 200009; ++i) {
        if (v_s[i].size() != v_t[i].size()) {
            cout << "No" << endl;
            return 0;
        }
        for (int j = 0; j < v_s[i].size(); ++j) {
            if (v_s[i][j] != v_t[i][j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 12248
n=int(input())
a = list(map(int, input().split()))

ans = 1
list.sort(a, reverse = True)
ones = a.count(1)
for i in range(len(a)-ones):
    if 0 in a:
        ans =0
        break
    ans = ans * a[i]
    if ans >10**18:
        break

if ans >10**18:
    print(-1)
else:
    print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) 
    cin >> V.at(i);
  
  vector<int> W(N,200000);
  W.at(0) = 0;
  
  for (int j = 0; j < N - 1; j++) {
    if (j < N - 2)
      W.at(j + 2) = W.at(j) + abs(V.at(j) - V.at(j + 2));
    W.at(j + 1) = min(W.at(j + 1), W.at(j) + abs(V.at(j) - V.at(j + 1)));  
  }
  
  cout << W.at(N - 1) << endl;
                              
}


Measured memory_bytes: 4032
#codng utf-8
import math
N,H=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b
A.sort(reverse=True)
B.sort(reverse=True)
flg=0
for i in range(N):
    if B[i]<A[0]:
        l=i
        flg=1
        break
ans=0
tmp=0
if flg==0:
    for i in range(N):
        ans+=1
        tmp+=B[i]
        if tmp>=H:
            break
    if tmp<H:
        ans+=math.ceil((H-tmp)/A[0])
else:
    for i in range(l):
        ans+=1
        tmp+=B[i]
        if tmp>=H:
            break
    if tmp<H:
        ans+=math.ceil((H-tmp)/A[0])
        
print(ans)

Measured memory_bytes: 11312
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,m,i,l,r,ans=INF,tmp;
	std::string s,t;
	std::cin >> s >> t;
	n = s.l_ength();
	m = t.l_ength();
	for(r=m; r<=n; ++r){
		l = r-m; tmp = 0;
		for(i=0; i<m; ++i){
			if(s[l]!=t[i]){
				++tmp;
			}
			++l;
		}
		ans = std::min(ans,tmp);
	}
	std::cout << ans << std::endl;
	return 0;
}


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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int n = S.size();
    vector<int> ans(n, 0);
    int l = 0, r = 0;
    while (r < n) {
        while (r < n && S[r] == 'R') r++;
        ans[r - 1] += (r - l + 1) / 2;
        ans[r] += (r - l) / 2;
        l = r;
        while (r < n && S[r] == 'L') r++;
        ans[l - 1] += (r - l) / 2;
        ans[l] += (r - l + 1) / 2;
        l = r;
    }
    rep(i, n) {
        cout << ans[i];
        if (i == n - 1) cout << "\n";
        else cout << " ";
    }
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
import heapq

def main():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    a = []
    for i in A:
        heapq.heappush(a, -i)

    for _ in range(M):
        m = heapq.heappop(a)
        heapq.heappush(a, -(-m // 2))

    sum = 0
    for i in a:
        sum += i
    print(-sum)
    return 

if __name__ == '__main__':
    main()


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for(int i = 1; i <= B; ++i) {
    if( ((A * i) % B) == C ) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli INF = 1e9+5;
int main(){
    lli n;
    cin >> n;
    vector <lli> v(n);
    for(int i =0;i<n;++i)cin >> v[i];
    vector <lli> dp(n,INF);
    dp[0] = 0;
    for(int i =1;i<n;i++){
        dp[i] = min(dp[i],dp[i-1]+abs(v[i]-v[i-1]));
        if(i-2>=0)
            dp[i] = min(dp[i],dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout << dp[n-1] << endl;

}


Measured memory_bytes: 1792
def skind(x,y):
  ans,s=0,[]
  for i in range(len(x)):
    if x[i] in y and not x[i] in s:
      ans+=1
      s.append(x[i])
  return ans
n,s,ans=int(input()),input(),0
for i in range(n-1):ans=max(ans,skind(s[:i+1],s[i+1:]))
print(ans)

Measured memory_bytes: 3060
using System;

namespace AtCoder
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int result = 0;

            for(int i = a; i <= b; i++)
            {
                var cArray = i.ToString().ToCharArray();
                bool flag = true;

                for (int j = 0; j < cArray.Length / 2; j++)
                {
                    if (cArray[j] != cArray[cArray.Length - j - 1])
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    result++;
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 15184
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	string s; cin >> s;
	for (unsigned int i = 0; i < (s.length() - 1); ++i) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return;
		}
	}
	cout << "Good" << endl;
    return;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll T = 0, S = A[0] + A[1];
    repe(i, 2, N) T ^= A[i];

    if((T^A[0]^A[1]) == 0){
        cout << 0 << endl;
        return 0;
    }

    if((S+T)%2){
        cout << -1 << endl;
        return 0;
    }

    if(T<A[1]-A[0]){
        cout << -1 << endl;
        return 0;
    }

    ll st = S - T;
    
    if(st<0){
        cout << -1 << endl;
        return 0;
    }

    st >>= 1;
    ll a = 0, b = 0;
    rep(i, 40) if (st >> i & 1) a += 1ll << i, b += 1ll << i;

    if(a>A[0]){
        cout << -1 << endl;
        return 0;
    }

    repr(i, 40){
        if ((T >> i & 1) and (a ^ 1ll << i) <= A[0]) a ^= 1ll << i;
    }

    b = S - a;
    if(a!=0 and (a^b^T)==0){
        cout << A[0] - a << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3616
moji_arr = input()

change=0
now_moji = moji_arr[0]

for v in moji_arr[1:]:
    if v==now_moji:
        change += 1
        if v=='0':
            now_moji = '1'
        elif v=='1':
            now_moji = '0'
    else:
        now_moji = v

print(change)

Measured memory_bytes: 3188
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int _;

int main() {
	INIT
	int n;
	cin >> n;
	map<string, int> A;
	rep (i, 0, n) {
		string s;
		cin >> s;
		A[s]++;
	}
	cout << A.size();

	return 0;
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N >> M;
  ;
}
void solve() {
  if (N >= 10) {
    cout << M << endl;
  } else {
    cout << M + (100 * (10 - N)) << endl;
  };
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;

  map<char, int> cnt;
  for (auto e : s) {
    cnt[e]++;
  }

  bool yes = true;
  if (cnt['N'] && !cnt['S']) yes = false;
  if (cnt['S'] && !cnt['N']) yes = false;
  if (cnt['W'] && !cnt['E']) yes = false;
  if (cnt['E'] && !cnt['W']) yes = false;

  cout << (yes ? "Yes" : "No") << "\n";

  return 0;
}

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

#define ll long long

int n;

int deposit(int num, int yen){
    int cnt=0,num_max=1;
    while(num_max <= yen) num_max *= num;
    num_max /= max(1,num);
    while(0<yen){
        cnt++;
        yen -= num_max;
        while(yen != 0 && yen < num_max) num_max = max(1, num_max/num);
    }
    return cnt;
}

int main(void){
    cin >> n;
    int ans=pow(10,9);
    for(int i=0;i<=n;i++){
        int tmp = deposit(6,i) + deposit(9,n-i);
        if(tmp < ans) ans = tmp;
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
	int n;cin>>n;
	string s;cin >>s;
	string out;
	if(n%2!=0){
		out = "No";
	} else {
		auto sub1 = s.substr(0,n/2);
		auto sub2 = s.substr(n/2,n/2);
		if(sub1==sub2){
			out = "Yes";
		} else {
			out = "No";
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
//#include <stack>

using namespace std;

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

#define max_n 100

long long T1, T2;
long long A1, A2;
long long B1, B2;


int main() {

	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	long long s1,s2;
	s1 = (A1 - B1)*T1;
	s2 = (A2 - B2)*T2;

	if ((s1 > 0 && s1 + s2 < 0) || (s1 < 0 && s1 + s2>0)) {
		if(abs(s1) % abs(s1 + s2)== 0)cout << (abs(s1) / abs(s1 + s2) + 1) * 2 - 2 << endl;
		else cout << (abs(s1)/abs(s1+s2)+1)*2 -1 << endl;
	}
	else if(s1 + s2 == 0){
		cout << "infinity" << endl;
	}
	else cout << "0" << endl;
	

	

	return 0;
}


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

typedef long long ll;

int main() {

  ll n;
  ll a[100];
  cin >> n;
  for(int i=0; i<n; ++i) cin >> a[i];

  ll money = 1000;   //所持金
  ll stock = 0;      //現在の株の所持数

  for(int i=0; i<n-1; ++i) {
    if(a[i]<a[i+1]) {
      //買う処理
      stock = money/a[i];
      money = money%a[i];
      //売る処理
      money = money + stock*a[i+1];
      stock = 0;
    }
  }

  cout << money << endl;

  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
double n,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	ans=(n/3.0)*(n/3.0)*(n/3.0);
	printf("%.12lf",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    // 1 <= k <= 5
    string str;
    cin >> str;
    int k;
    cin >> k;
    vector<string> v;
    rep(i, SZ(str)) {
        string tmp;
        rep3(j, i, i + 5) {
            if (j == SZ(str)) break;
            tmp += str[j];
            v.eb(tmp);
        }
    }
    sort(all(v));
    //outa(v, SZ(v));
    auto l = unique(all(v));
    // v.erase(l, v.end());
    out(v[k - 1]);
    //outa(v, SZ(v));
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	if(n%3==0||m%3==0||(n+m)%3==0) {
		puts("Possible");
		return 0; 
	}
	else {
		puts("Impossible");
		return 0;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int x1, x2, x3, x4, y1, y2, y3, y4, x, y;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  x = x2 - x1;
  y = y2 - y1;
  x3 = x2 + (-1)*y;
  y3 = y2 + x;
  x4 = x3 + (-1)*x;
  y4 = y3 + (-1)*y;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


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

ll dp[109][100009];
int wt[109];
ll v[109];
ll knapSack(int n,int w){

    if(n<0) return 0;
    else if(wt[n]>w) knapSack(n-1,w);
    else if(dp[n][w]!= -1) return dp[n][w];
    else{

        dp[n][w] = max(v[n]+knapSack(n-1,w-wt[n]),knapSack(n-1,w));
        return dp[n][w];
    }

}


int main(){
    //freopen("input","r",stdin);
    memset(dp,-1,sizeof(dp));
    int n,w;
    cin >> n >> w;
    for(int i=0;i<n;i++) cin >> wt[i] >> v[i];
    cout << knapSack(n-1,w) << endl;



return 0;
}


Measured memory_bytes: 85376
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    int flag=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        if (a%2==0) {
            if (a%3!=0&&a%5!=0) {
                flag=1;
                break;
            }
        }
    }
    if (flag==0) {
        cout<<"APPROVED"<<endl;
    } else {
        cout<<"DENIED"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
int h,w,d;
int main(){
	scanf("%d%d%d",&h,&w,&d);
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			int x=(i+j)/d%2;
			int y=(1000+i-j)/d%2;
			char c="RGBY"[2*x+y];
			printf("%c",c);
		}
		printf("\n");
	}		
}

Measured memory_bytes: 384
//##Moh_K_Imar .......
//27/08/2020  ...  8.20
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9)cout<<"hon"<<endl;
    else if(a%10==0||a%10==1||a%10==6||a%10==8)cout<<"pon"<<endl;
    else cout<<"bon"<<endl;


    return 0;
}



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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
    ll n;
    cin>>n;
    vector<string> a(n);
    vector<ll> j;
    vector<string> w;

    rep(i,n){
        cin>>a.at(i);
    }

    sort(a.begin(),a.end());

    ll co=1,ma=0;
    rep(i,n){
        if(i==n-1){
            ma = max(ma,co);
            j.push_back(co);
            w.push_back(a.at(i));
            co=1;
            break;
        }
        if(a.at(i)==a.at(i+1))co++;
        else{
            ma = max(ma,co);
            j.push_back(co);
            w.push_back(a.at(i));
            co=1;
        }
    }

    for(ll i=0;i<j.size();i++){
        if(j.at(i)==ma){
            cout<<w.at(i)<<endl;
        }
    }

}

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

int main() {
    std::string S, T;
    std::cin >> S >> T;
    for (int i = 0; i + T.length() - 1 < S.length(); ++i) {
        bool judge = true;
        for (int j = 0; j < T.length(); ++j) {
            if (S[i + j] != T[j]) judge = false;
        }
        if (judge) std::cout << i << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>

 
int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 1;i < 10; i++){
		if (n % i == 0 && n / i < 10){
			puts("Yes\n");
			break;
		}
		
		else if (i == 9) {
			puts("No\n");
		}
	}
	return 0;
}
 

Measured memory_bytes: 1624
import java.io.*;
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        try{
            new Main();
        }catch(IOException err){
            err.printStackTrace();
        }
    }
     
    int[][] offset = new int[][]{
            {-1, 0}, {1, 0}, {0, -1}, {0, 1}
    };
 
 
    public Main() throws IOException, StackOverflowError{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        List<Integer> Ans = new ArrayList<Integer>();
        String line;
 
        while((line = in.readLine()) != null){
            String[] dst = line.split(" ");
            int h = Integer.parseInt(dst[0]);
            int w = Integer.parseInt(dst[1]);
 
            if(h==0 && w==0){
                break;
            }
 
            int[][] data = new int[h+2][w+2];
            int[][] label = new int[h+2][w+2];
            for(int j=1; j<=h; j++){
                line = in.readLine();
                for(int i=1; i<=w; i++){
                    String c = line.substring(i-1, i);
                    if(c.equals("@")){
                        data[j][i] = 1;
                    }
                    else if(c.equals("#")){
                        data[j][i] = 2;
                    }
                    else if(c.equals("*")){
                        data[j][i] = 3;
                    }
                    label[j][i] = 0;
                }
            }
             
            for(int j=0; j<h+2; j++){
                data[j][0] = 0;
                data[j][w+1] = 0;
                label[j][0] = -1;
                label[j][w+1] = -1;
            }
             
            for(int i=0; i<w+2; i++){
                data[0][i] = 0;
                data[h+1][i] = 0;
                label[0][i] = -1;
                label[h+1][i] = -1;
            }
             
 
            int count = 0;
            for(int j=1; j<=h; j++){
                for(int i=1; i<=w; i++){
                    if(label[j][i] == 0){
                        count++;
                        label[j][i] = count;
                        grouping(data, label, i, j);
                    }
                }
            }
 
            Ans.add(count);
        }
 
        for(int n=0; n<Ans.size(); n++){
            System.out.println(Ans.get(n));
        }
    }
 
    public void grouping(int[][] data, int[][] label, int x, int y){
        List<point> cue = new ArrayList<point>();
        cue.add(new point(x, y));
        while(cue.size() != 0){
            point p = cue.get(0);
            cue.remove(0);
            for(int d=0; d<4; d++){
                int xx = p.x + offset[d][0];
                int yy = p.y + offset[d][1];
                if(label[yy][xx] == 0 && data[yy][xx] == data[p.y][p.x]){
                    label[yy][xx] = label[p.y][p.x];
                    cue.add(new point(xx, yy));
                }
            }
        }
    }
}
 
class point{
    int x;
    int y;
     
    public point(int x, int y){
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 27388
N, x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] > x:
    ans += a[0] - x
    a[0] = x

for i in range(N-1):
    if a[i] + a[i+1] > x:
        ans += a[i] + a[i+1] - x
        a[i + 1] = x - a[i]
print(ans)


Measured memory_bytes: 14540
#include <stdio.h>


int main(){
	long long int x, n=0;
	

	scanf("%lld", &x);
	
	// 6,5,6,5....の順に転がした時の回数
	n = x / 11;
	n *= 2;
	
	x %= 11;
	//のこり10以下
	if(x != 0){
		if(x <= 6){
			n++;
		}else{
			n+=2;
		}
	}

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

	return 0;

}


Measured memory_bytes: 128
n,m,x,y=gets.split.map(&:to_i)
xs=gets.split.map(&:to_i).sort
ys=gets.split.map(&:to_i).sort
for z in x+1..y
  if xs[-1]<z && z<=ys[0]
    puts "No War"
    exit;
  end
end
puts "War"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int maxn=25005;
const int maxk=405;
const int mod=1000*1000*1000+7;
inline void up(int&x,int y){
  if(x+=y,x>=mod)x-=mod;
}
int Pow(long long x,int y){
  long long t=1;
  for(;y;y>>=1){
    if(y&1)t=t*x%mod;
    x=x*x%mod;
  }
  return (int)t;
}
int n,m,K,a[maxn];
int fac[maxn],fac_inv[maxn];
int f[maxn][maxk],cnt[maxn][maxk],gL[maxn],gR[maxn];
int vis[maxk];
int main(){
  //freopen("aa.in","r",stdin);
  fac[0]=1;
  for(int i=1;i<maxn;i++)fac[i]=1LL*fac[i-1]*i%mod;
  fac_inv[maxn-1]=Pow(fac[maxn-1],mod-2);
  for(int i=maxn-1;i;i--)fac_inv[i-1]=1LL*fac_inv[i]*i%mod;
  scanf("%d%d%d",&n,&K,&m);
  for(int i=1;i<=m;i++)scanf("%d",a+i);
  int ans=1LL*Pow(K,n-m)*(n-m+1)%mod;
  int max_len=0;
  int pre_pos=1;
  for(int i=1;i<=m;i++){
    for(;vis[a[i]];pre_pos++){
      vis[a[pre_pos]]--;
    }
    vis[a[i]]++;
    max_len=max(max_len,i-pre_pos+1);
  }
  if(max_len==K)return printf("%d\n",ans),0;
  f[1][1]=K;
  for(int i=1;i<n;i++){
    for(int j=1;j<K;j++){
      up(f[i+1][1],f[i][j]);
      up(f[i+1][j+1],mod-f[i][j]);
    }
    for(int j=1;j<K;j++){
      up(f[i+1][j],f[i+1][j-1]);
    }
    for(int j=1;j<K;j++){
      up(f[i+1][j+1],1LL*f[i][j]*(K-j)%mod);
    }
  }
  int L,R;
  memset(vis,0,sizeof(vis));
  for(L=1;L<=m&&!vis[a[L]];L++)vis[a[L]]=1;L--;
  memset(vis,0,sizeof(vis));
  for(R=1;R<=m&&!vis[a[m-R+1]];R++)vis[a[m-R+1]]=1;R--;
  if(L==m){
    //printf("ans %d\n",ans);
    for(int i=1;i<=n;i++){
      for(int j=1;j<K;j++){
        if(j>=m)up(cnt[i][j],f[i][j]);
        up(cnt[i+1][1],cnt[i][j]);
        up(cnt[i+1][j+1],mod-cnt[i][j]);
      }
      for(int j=1;j<K;j++){
        up(cnt[i+1][j],cnt[i+1][j-1]);
      }
      for(int j=1;j<K;j++){
        up(cnt[i+1][j+1],1LL*cnt[i][j]*(K-j)%mod);
        //if(j>=m)up(cnt[i][j],f[i][j]);
      }
    }
    int res=0;
    for(int i=1;i<K;i++)up(res,cnt[n][i]);
    //printf("res %d\n",res);
    res=1LL*res*fac[K-m]%mod*fac_inv[K]%mod;
    up(ans,mod-res);
  }else{
    for(int i=0;i+L<=n;i++){
      for(int j=L;j<K;j++){
        up(gL[i],1LL*f[i+L][j]*fac[K-L]%mod*fac_inv[K]%mod);
      }
    }
    for(int i=0;i+R<=n;i++){
      for(int j=R;j<K;j++){
        up(gR[i],1LL*f[i+R][j]*fac[K-R]%mod*fac_inv[K]%mod);
      }
    }
    for(int i=0;i+m<=n;i++){
      up(ans,mod-1LL*gL[i]*gR[n-m-i]%mod);
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 79616
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll x, k, d;
    cin >> x >> k >> d;
    ll xx = abs(x);

        ll q = xx/d;
        if (q > k) {
            cout << xx-k*d;
        }
        else if ((q+k)&1) {
            cout << d - xx%d;
        }
        else cout << xx%d;
    
    return 0;
}


Measured memory_bytes: 3644
/*input
qq
81
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define fore( i ,st) for ( int i= 0 ; i < (int)(st) ; i ++)
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bug(x) cout <<__LINE__ << ":"<<__FILE__ << " : " <<   #x  << " = " << x << "\n";

#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

const int maxn =1e5 + 5;

void solve(int test ) 
{	
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.length();
	int st=0 , en= n-1;
	if ( s[n-1] == s[0] ){
		while( s[st] == s[0] && st < n-1) st++;
		while( s[en] == s[n-1] && en > st) en--;
	}
	int ans =0 ;

	if (st == en){
		cout << (n * k ) /2 ;
		return; 
	}
	
	for ( int i = st ; i < en+1 ; i++)
	{
		char x =s[i];
		int j = i;
		while( s[i] == x && i < en+1) i++;
		i--;
		ans += (( i - j +1) /2 ) ;
	}
	ans *= k;

	int x = st+ n - en-1;
	if ( k >1){
		ans += (( st  + n - en-1) /2)  *(k-1); 
		ans += (st)/2 + (n -en-1)/2;
	}
	cout << ans;




}
signed main(){
	// bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	for ( int i = 0 ; i < t; i++)
	solve(i+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
int main() {
  int n;
  while(cin>>n)
    {
        int a[100000];
        int i;
        for(i=0; i<n; i++)
            cin>>a[i];
        sort(a,a+n);
        int Min=a[0],Max=a[n-1];
        for(i=1; i<n-1; i++)
        {
            if(a[i]>=0)
                Min-=a[i];
            else
                Max-=a[i];
        }
        cout<<Max-Min<<endl;
        Max=a[n-1];
        Min=a[0];
        for(i=1; i<n-1; i++)
        {
            if(a[i]>=0)
            {
                cout<<Min<<' '<<a[i]<<endl;
                Min-=a[i];
            }
            else
            {
                cout<<Max<<' '<<a[i]<<endl;
                Max-=a[i];
            }
        }
        cout<<Max<<' '<<Min<<endl;
    }
}

Measured memory_bytes: 2304
s=int(input())
a=s//1000
b=(s-a*1000)//100
c=(s-a*1000-b*100)//10
d=s-a*1000-b*100-c*10
if a==b :
    print("Bad")
elif b==c:
    print("Bad")
elif c==d:
    print("Bad")
else:
    print("Good")

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) cout << "A" << endl;
    if(abs(x - a) > abs(x - b)) cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
#-*- using:utf-8 -*-

N, K = map(int, input().split())
S = [False] * N
cnt=0
while cnt < K:
    d = int(input())
    A = list(map(int, input().split()))
    i=0
    while i < d:
        S[A[i] - 1] = True
        i += 1
    cnt += 1
n = sum(x==False for x in S)

print(n)

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) { cin >> p[i]; }
  int min_p = n + 10;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (p[i] < min_p) ans++;
    min_p = min(min_p, p[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 2147483647
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f

#define ll long long
#define rei register int
#define inv inline void
#define ull unsigned long long
#define il inline

#define bl putchar(' ')
#define ed putchar('\n')
#define test cout<<"this:" 

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x){
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 1000005
int n; 
int main(){
	read(n);
	int cnt=0;
	for(rei i=1;i<=n;++i) if(i&1) ++cnt;
	cout<<cnt*1.0/n;
	return 0;
}

Measured memory_bytes: 256
def examB():
    N = I()
    S = SI()
    lim = ord("Z")
    ans = ""
    for s in S:
        cur = ord(s)+N
        if cur>lim:
            cur -=26
        ans += chr(cur)
    print(ans)
    return

def examC():
    return

def examD():
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

#include <vector>
#include <functional>
using namespace std;

template <typename T>
class SegTree {
private:
    int n;
    vector<T> data;
    T id;
    function<T(T, T)> update;
    function<T(T, T)> merge;

    T _query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return id;
        if(a <= l && r <= b) return data[k];
        
        T vl = _query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = _query(a, b, 2 * k + 2, (l + r) / 2, r);
        return merge(vl, vr);
    }

public:
    SegTree(int _n, T _id, function<T(T, T)> _update, function<T(T, T)> _merge)
    : id(_id), update(_update), merge(_merge) {
        n = 1;
        while(n < _n) n <<= 1;
        data = vector<T>(2 * n - 1, id);
    }

    void change(int k, T x) {
        k += n - 1;
        data[k] = update(data[k], x);
        while(k > 0) {
            k = (k - 1) / 2;
            data[k] = merge(data[2 * k + 1], data[2 * k + 2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](int k) {
        return data[k + n - 1];
    }
};

const int INF = 1001001001;

int main() {
    int N, K;
    cin >> N >> K;
    int P[200000];
    SegTree<int> st1(N, INF, [](int a, int b){return b;}, [](int a, int b){return min(a, b);});
    SegTree<int> st2(N, -INF, [](int a, int b){return b;}, [](int a, int b){return max(a, b);});
    for(int i=0; i<N; ++i) {
        cin >> P[i];
        st1.change(i, P[i]);
        st2.change(i, P[i]);
    }

    vector<int> U;
    int cnt = 1;
    for(int i=0; i+1<N; ++i) {
        if(P[i] < P[i + 1]) {
            ++cnt;
            if(cnt >= K) U.push_back(i + 1);
        } else {
            cnt = 1;
        }
    }

    int res = 1;
    bool flag = false;
    if(U.size() > 0 && U[0] == K - 1) flag = true;
    for(int l=0; l+K<N; ++l) {
        int r = l + K;
        if(st1.query(l, r) == P[l] && st2.query(l, r + 1) == P[r]) continue;
        int tmp = upper_bound(begin(U), end(U), r) - lower_bound(begin(U), end(U), r);
        if(tmp == 1) {
            if(flag) continue;
            flag = true;
        }
        ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e6+5;

int main() 
{ 
    BOOST
    
    int n,k;
    cin>>n>>k;
    int a[n];

    for(int i=0;i<n;i++)
        cin>>a[i];
    
    int ans[n];

    // memset(ans,1e9,sizeof(ans));
    for(int i=0;i<n;i++)    ans[i]=1e9;
    
    ans[0]=0;
    for(int i=1; i<n; i++)
        for(int j=1; j<=min(k,i); j++)
            ans[i] = min(ans[i], abs(a[i]-a[i-j])+ans[i-j]);

    cout<<ans[n-1]<<"\n";
    return 0; 
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int h, w, m;
	cin >> h >> w >> m;
	vector<pair<int, int>> arr(m);
	for (int i = 0; i < m; i++)
		cin >> arr[i].first >> arr[i].second;

	set<pair<int, int>> st;
	for (int i = 0; i < m; i++)
		st.insert(arr[i]);

	map<int, int> mpw, mph;
	for (int i = 0; i < m; i++)
		mpw[arr[i].first]++, mph[arr[i].second]++;

	int maxw = 0, maxh = 0;
	for (auto x : mpw)
		maxw = max(x.second, maxw);
	for (auto x : mph)
		maxh = max(x.second, maxh);

	set<int> stw, sth;
	for (auto x : mpw)
		if (x.second == maxw)
			stw.insert(x.first);

	for (auto x : mph)
		if (x.second == maxh)
			sth.insert(x.first);

	for (auto x : stw) {
		for (auto y : sth) {
			if (st.find({x, y}) == st.end()) {
				cout << maxw + maxh;
				return 0;
			}
		}
	}
	cout << maxw + maxh - 1;
	return 0;
}

Measured memory_bytes: 92056
/* Author : fenwick123 */

#include <bits/stdc++.h>
using namespace std;

int main(){
    int x , n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++){
       int t;
       cin >> t;
       s.insert (t);
    }
    int ans = -1;
    int disl = -1;
    for (int tt = x; tt >= -500; --tt){
        if (s.find (tt) == s.end()){
            ans = tt;
            // cout << "tt : " << tt << " and x : " << x << endl;
            disl = abs (tt - x);
            break;
        }
    }
    // cout <<" ans : " << ans << endl;
    // cout << " disl = " << disl << endl;
    int  disr = -1;
    int ansr = -1;
    for (int tt = x; tt <= 500; tt++){
        if (s.find (tt) == s.end()){
            ansr = tt;
            disr = abs (tt - x);
            break;
        }
    }
    // cout << "ansr : " << ansr << endl;
    // cout << "disr : " << disr << endl;
    if (disl == -1) cout << ansr << endl;
    else{
        if (disl <= disr)  cout << ans << endl;
        else cout << ansr << endl;
    }
    // if (disl <= disr) cout << ans << endl;
        
    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<int> ve[N];
priority_queue<int>qe; 
int main()
{
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
    	cin>>a>>b;
    	if(m-a+1<1) continue;
    	ve[m-a+1].push_back(b);
    }
    int anx=0;
    for(int i=m;i>=1;i--)
    {
    	for(int j=0;j<ve[i].size();j++) qe.push(ve[i][j]);
    	if(!qe.empty())
    	{
    		anx+=qe.top();
    		qe.pop();
    	}
    }
    cout<<anx<<"\n";
}

Measured memory_bytes: 8932