akhauriyash/Code-Regression huggingface dataset:
N,M=[int(i) for i in input().split()]
flag=[True for i in range(N)]

for i in range(M):
        for j in input().split():
                j=int(j)-1
                flag[j]=flag[j]^True
#答え
ans=True
for i in flag:
        if not i:
                ans=False
                break
if ans:
        print("YES")
else:
        print("NO")

Measured memory_bytes: 3964
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    long long N, M, L[100001], R[100001], i, left=0, right=1000000;

    cin >> N >> M;

    for(i=1; i<=M; i++){
        cin >> L[i] >> R[i];

        if(left < L[i]){
            left = L[i];
        }

        if(right > R[i]){
            right = R[i];
        }
    }

    if(left <= right){
        cout << right-left+1 << endl;
    }

    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<math.h>
using namespace std;
const int MAX = 1000000;
int prime(int n)
{
	int ans = 0;
	bool prime[MAX];
	memset(prime, 0, sizeof(prime));
	for (int i = 2; i < n;i++)  
	{ 
		for (int j = 2; j <= n / i; j++)
		{
			if (i*j <= n)
				prime[i*j] = 1;
		}
	}
	for (int i = 2; i <= n; i++)
	{
		if (!prime[i])
			ans++;
	}
	return ans;
}
int main()
{
	int n, m = 0;
	while (cin >> n&&m<30)
	{
		cout << prime(n) << endl;
		m++;
	}
	return 0;
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100;
const int MAX_W = 10000;

int n,W;
int w[MAX_N];
int v[MAX_N];
int m[MAX_N];
int dp[MAX_W+1];
int deq[MAX_W+1];
int deqv[MAX_W+1];

int main()
{
	cin >> n >> W;
	rep(i,n){
		scanf("%d%d%d",&v[i],&w[i],&m[i]);
	}
	rep(i,n){
		rep(a,w[i]){
			int s=0,t=0;
			for(int j=0;j*w[i]+a<=W;j++){
				int val = dp[j*w[i]+a]-j*v[i];
				while(s<t&&deqv[t-1]<=val){
					t--;
				}
				deq[t] = j;
				deqv[t++] = val;
				dp[j*w[i]+a] = deqv[s] + j*v[i];
				if(deq[s] == j-m[i]){
					s++;
				}
			}
		}
	}
	cout << dp[W] << "\n";
	return 0;
}

Measured memory_bytes: 3284
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}


//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){ //除算のみO(log mod)なので注意。割る数が小さいならnCrのinvを使うこと
		ll exp = mod - 2;
		while(exp > 0){ 
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

//さらにnCrのために、x!とその逆元を配列で持つ
const int NMAX = 500000; // 10^7くらいまではいけそう
ll fact[NMAX], finv[NMAX], inv[NMAX];

void ncr_init(){ //はじめにinitすること
	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < NMAX; i++){
		fact[i] = fact[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i-1]* inv[i] % mod;
	}
}
ll ncr(int n, int r){
	if(n<r) return 0;
	if(n<0 || r<0) return 0;
	return fact[n] * (finv[n-r] * finv[r] % mod) % mod;
}
//

int main() {
	modint ans = 1;
	ll tmp;
	int n, m; cin >> n >> m;
	vector<int> a(n), b(m);
	cin >> a; cin >> b;
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	bool ch = true;
	REP(i, n - 1) if(a[i] == a[i+1]) {ch = false; ans = 0;}
	REP(i, m - 1) if(b[i] == b[i+1]) {ch = false; ans = 0;}
	a.push_back(0); b.push_back(0);
	//REP(i, n) cout << a[i] << " "; cout << endl;
	//REP(i, m) cout << b[i] << " "; cout << endl;
	if(ch){
		int i = 0, j = 0;
		int no = 0, ao = 0, bo = 0, ry = 1;
		int kake = 0;
		for(int x = n*m; x >= 1; x--){
			if(a[i]==x && b[j]==x){
				ans *= ry;
				kake = ry;
				no += ao + bo;
				if(i<n)ao++; if(j<m)bo++;
				i++; j++;
			}
			else if(a[i] == x){
				ans *= ao;
				kake = ao;
				no += ao - 1;
				if(i<n)bo++;
				i++;
			}
			else if(b[j] == x){
				ans *= bo;
				kake = bo;
				no += bo - 1;
				if(j<m)ao++;
				j++;
			}
			else{
				ans *= no;
				kake = no;
				no--;
			}
			//cout << x << " " << kake << " " << no << endl;
		}
		
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        int n,i,sum1=0;
        int[] score;
        double ave,div,sum2=0;

        score = new int[1000];

        while(true){
            n=scan.nextInt();
            if(n==0){
                break;
            }

            for(i=0;i<n;i++){
                score[i]=scan.nextInt();
                sum1+=score[i];
            }

            ave=(double)sum1/n;
            
            for(i=0;i<n;i++){
                sum2+=((score[i]-ave)*(score[i]-ave));
            }
            div=(double)sum2/n;

            System.out.println(Math.sqrt(div));

            sum1=0;
            sum2=0;
        }

    }
}


Measured memory_bytes: 31296
import sys
from collections import defaultdict
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
towns = [1]
town_dic = defaultdict(lambda : 0)
prev = 1
count = 0
while True:
    next = a[prev - 1]
    count += 1
    if count == k:
        print(next)
        sys.exit()
    if town_dic[next] == 1:
        break
    else:
        town_dic[next] += 1
    towns.append(next)
    prev = next
i = towns.index(next)
repeat = towns[i:]
unit = len(repeat)
rest = k - count + 1
print(repeat[(rest % unit) - 1])

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

using namespace std;

int main(int argc, char * argv[]) {
    int n;
    cin >> n;

    bool can = false;
    for (int x = 1; x <= 9; ++x) {
        for (int y = 1; y <= 9; ++y) {
            if (x * y == n)
                can = true;
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
"""

AtCoder Beginner Contest 129  E - Sum Equals Xor

XORは桁上がりがないので、A xor B がA+Bより大きくなることはない（最大でもA+Bまで）
なので、 A xor B = A + B が成立するのは、AとBを二進数でみたときに、両方1が立っているbitがないこと。

桁DPの文脈で考えると、
dp1,2[i] : AやBの左からi文字目までを決めたときに、
・dp2 : その時点でのA+BがL以下になることがわかっている（左からi番目までについて、A+Bのp桁目は0だが、Lのp桁目は1、みたいなのが存在する（先頭～p-1までは一致））AとBの組の個数
・dp1 : その時点ではA+BがL以下になるか分からないAとBの組の個数（その時点まではLのi桁目までと一致する組の数）



遷移について、
Lのi桁目が
・0の場合
 - dp1 : dp2から遷移するとL以下になることが確定するので、dp2から遷移してくることはない＆A+Bのiビット目に1が立つとLを上回るので、0になるしかなく、i桁目は両方0の１通りで遷移
 - dp2 : dp1から遷移してきてi番目に0をいれても、L以下になるか確定しないので、dp1からの遷移はない。一方で。dp2から遷移してくる場合、既にL以下であることが確定しているので、A,B = 1,1以外の３パターンをとれる
・1の場合
 - dp1 : dp2から遷移してくるのを考えると、dp2の時点で既にL以下になるのが確定しているので、dp2からは遷移できない。一方で、dp1から遷移してくる場合、i桁目までLと同じになるので、A,Bの一方が1で他方が0の２通りをとれる
 - dp2 : dp1から遷移して A,B=0,0 をとればL以下が確定＆dp2から遷移して 1,1 以外の3通りの遷移

"""


L = input()
N = len(L)
MOD = 10**9 + 7

dp1 = [0] * (N+1)
dp2 = [0] * (N+1)
dp1[0] = 1


for i in range(N):
    if L[i] == "0":
        dp1[i+1] = dp1[i] # (0,0)
        dp2[i+1] = dp2[i] * 3 # (1,1)以外の3つ
    else:
        dp1[i+1] = dp1[i] * 2 # (1,0), (0,1)
        dp2[i+1] = dp2[i] * 3 + dp1[i] # dp2から遷移してくる場合は(1,1)以外の3つ、dp1から遷移してくる場合は1にならないとよいので(0,0)

    dp1[i+1] %= MOD
    dp2[i+1] %= MOD

print((dp1[-1] + dp2[-1]) % MOD)

Measured memory_bytes: 11124
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(read())
l = len(str(N)) - 1
c_mat = [[0] * 10 for _ in range(10)]

for i in range(1, N + 1):
    acc = str(i)
    c_mat[int(acc[0])][int(acc[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c_mat[i][j] * c_mat[j][i]
print(ans)


Measured memory_bytes: 3188
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<int> st;
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){	
	
	long long N,M,K;
	string s;
    
	//std::cin >> N;
    std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
	//std::vector<long long> v(N);
	//std::vector<long long> w(N);
    //std::cin >> s;
    
    
    // 配列入力
    /*
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	*/
	
	
	
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    /*
    
    //S.substr(i, 5);
    //S.size();
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			st.erase(v[i]);
		}
	}
	*/

    
    long long sum,sum1;
	sum=0;
	sum1=0;
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	long long max;
	int max1;
	max=0;
	max1=0;
	long long min;
	int min1;
	min=INF;
	min1=INF;

	int work1,work2,work3,work4;
	work1=0;
	work2=0;
	work3=0;
	work4=0;

	//int a[4];
	int value;
	value=0;
	/*
	a[0] = (value % 10); 
	value /= 10;// 1桁目を取り出す
	a[1] = (value % 10); 
	value /= 10;// 2桁目を取り出す
	a[2] = (value % 10); 
	value /= 10;// 3桁目を取り出す
	a[3] = (value % 10); 
	value /= 10;// 4桁目を取り出す
    work1=a[0]+10*a[1];
    work2=a[2]+10*a[3];
    */
	long long a;
	long long b;
	a=0;
	b=0;
	max=N;
	min=0;
	for(long long i=0; i<M; i++){
		std::cin >> a >> b;
		if(min<=a){
			min=a;
		}
		if(b<=max){
			max=b;
		}
	}
	
	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/
    if(min<=max){
    	printf("%llu",max-min+1);
    	//puts("Yes");
    	//printf("%d",st.size());
    	//文字列の出力
    	//std::cout << s << std::endl;
    	//printf("%.12f\n",ret);
    	//cout << sum << endl;
	}
	else{
		printf("%llu",0);
		//puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    rep(i, N) cin >> v.at(i);

    map<int, int> mp;
    for (int n : v)
    {
        if (mp.count(n))
        {
            mp.at(n)++;
        }
        else
        {
            mp[n] = 1;
        }
    }
    vector<int> counts;
    for (auto key : mp)
    {
        counts.push_back(key.second);
    }
    sort(counts.begin(), counts.end());
    int ans = 0;
    rep(i, counts.size() - K)
    {
        ans += counts.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11516
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

int n, s, k, a[N];
int main()
{
	int i;
//	freopen ("input.txt", "r", stdin);
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
	}
	if (n == 1) {
		if (a[0] == k) cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	sort(a,a + n);
	int num = a[0];
	for (i = 1; i < n; i++) {
		int t = a[i] - a[i - 1];
		if (t != 0) num = min(num, t);
		num = min(num, a[i]);
	}
	for (i = 0; i < n; i++) {
		if (a[i] >= k && (a[i] - k) % num == 0) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;


signed main(){
    ll n,k;
    cin >> n >> k;
    ll sum = 0;
    rep(i,0,n){
        ll x;
        cin >> x;
        sum += min(abs(x),abs(k-x));
    }
    cout << 2*sum << endl;

    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> eng(N);
    for(auto& i : eng)cin >> i.first >> i.second;
    auto d = static_cast<unsigned long>(partition(eng.begin(), eng.end(), [](auto i){return i.first == 0 ? i.second > 0 : i.first > 0;}) - eng.begin());
    for(unsigned long i = 0; i < N; ++i)eng.emplace_back(-eng[i].first, -eng[i].second);
    for(unsigned long i = 0; i < d; ++i)eng.emplace_back(eng[i].first, eng[i].second);
    auto cmp = [](auto i, auto j){return i.first * j.second > i.second * j.first;};
    sort(eng.begin(), eng.begin() + d, cmp);
    sort(eng.begin() + d, eng.begin() + d + N, cmp);
    sort(eng.begin() + d + N, eng.end(), cmp);
    long a{0}, b{0};
    unsigned long ans{0};
    for(unsigned long i = 0; i < 2 * N + d; ++i){
        a += eng[i].first;
        b += eng[i].second;
        ans = max<unsigned long>(ans, a * a + b * b);
    }
    printf("%.12Lf\n", sqrt(static_cast<long double>(ans)));
    return 0;
}

Measured memory_bytes: 256
// $%U%$
// $%D%$/$%M%$/$%Y%$
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
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;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int t = nxt();
    while(t--) printf("ACL");
    return 0;
}




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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define ff first
#define endl "\n"
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fr(i,x,n) for(ll i=x;i>=n;i--)
inline ll min(ll a, ll b, ll c) { return min(min(a, b), c);}
inline ll max(ll a, ll b, ll c) { return max(max(a, b), c);}
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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



int main() {
	fastio();

	int n; cin >> n;
	vector<double> p(n + 1); f(i, 1, n) cin >> p[i];
	// debug(p);
	vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0)); //STATE(No of coins, No. of Heads)
	dp[0][0]=1;
	// dp[1][1] = p[1];
	// dp[1][0] = 1-p[1];
	double ans = 0;
	f(i, 1, n) {
		f(j, 0, i) {
			dp[i][j] = ((dp[i - 1][j - 1] * p[i]) + (dp[i - 1][j] * ((double)1 - p[i])));
		}
	}
	// debug(dp);
	cout << fixed << setprecision(15) ;
	f(j, 1, n) if (j > n - j) ans += dp[n][j];
	cout << ans;



	return 0;
}

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

struct prob {
    bool state;
    int count;
};

int main() {
    int n, m, ac{0}, wa{0};
    cin >> n >> m;
    prob probs[n]{};
    for (int i = 0; i < m; i++) {
        int num;
        string state;
        cin >> num >> state;
        --num;
        if (!probs[num].state) {
            if (state == "WA") {
                ++probs[num].count;
            } else if (state == "AC") {
                probs[num].state = true;
            }
        }
    }
    for (auto &&i : probs) {
        if (i.state) {
            wa += i.count;
            ++ac;
        }
    }

    cout << ac << " " << wa;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <string>    // useful for reading and writing
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream



int main()
{
    int n;
    std::cin >> n;
    int p[n];
    for(int i = 0; i < n; i++)
    {
        std::cin >> p[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(i!=0){std::cout << " ";}
        std::cout << p[n-1-i];
    }
    std::cout << std::endl;
    return 0;
}


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int q; cin >> q;
    REP(i, q)
    {
        string a, b; cin >> a >> b;
        vvi dp(a.length()+1, vi(b.length()+1));
        REP(j, a.length())
        {
            REP(k, b.length())
            {
                if(a[j] == b[k]) dp[j+1][k+1] = dp[j][k]+1;
                chmax(dp[j+1][k+1], dp[j][k+1]);
                chmax(dp[j+1][k+1], dp[j+1][k]);
            }
        }
        cout << dp[a.length()][b.length()] << endl;
    }
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n), cnt(13, 0);
    cnt[0] = 1;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        cnt[d[i]]++;
    }
    vector<int> t, t2;
    for (int i = 0; i <= 12; i++) {
        if (cnt[i] >= 3) {
            cout << 0 << endl;
            return 0;
        } else if (cnt[i] == 2) {
            t2.push_back(i);
            t2.push_back(24 - i);
        } else if (cnt[i] == 1) {
            t.push_back(i);
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << t.size()); i++) {
        vector<int> t3(t2);
        for (int j = 0; j < t.size(); j++) {
            if (i & (1 << j)) t3.push_back(24 - t[j]);
            else t3.push_back(t[j]);
        }
        int hoge = 114514;
        for (int j = 0; j < t3.size(); j++) {
            for (int k = j + 1; k < t3.size(); k++) {
                int tmp = abs(t3[j] - t3[k]);
                hoge = min(hoge, min(tmp, 24 - tmp));
            }
        }
        ans = max(ans, hoge);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S[107]; int n, dp[107], a[107]; map<string, int>M;
int main() {
	cin >> n; for (int i = 0; i <= n; i++) { a[i] = -1; dp[i] = 9999; }
	for (int i = 0; i < n; i++) {
		while (S[i] == "")getline(cin, S[i]); dp[0] = 0;
		if (S[i].size() <= 5 || S[i][4] != ' ')M[S[i].substr(0, S[i].size() - 1)] = i;
	}
	for (int i = 0; i < n; i++) { if (S[i].size() >= 5 && S[i][4] == ' ')a[i] = M[S[i].substr(5, S[i].size() - 6)]; }
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < n; i++) {
			if (a[i] >= 0) { dp[a[i]] = min(dp[a[i]], dp[i]); dp[i + 1] = min(dp[i + 1], dp[i] + 1); }
			else { dp[i + 1] = min(dp[i + 1], dp[i]); }
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 998244353;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	ll n;
	std::cin >> n;
	std::vector<ll> d(n);
	rep(i, n) std::cin >> d[i];

	if (d[0] != 0) {
		std::cout << 0 << std::endl;
		return 0;
	}

	ll ans = 1LL;

	std::sort(allof(d));

	std::vector<ll> cnt(n + 2, 0);

	Rep(i, 0, n) {
		++cnt[d[i]];
	}

	// 0が二つあるとアウト
	if (cnt[0] >= 2) {
		std::cout << 0 << std::endl;
		return 0;
	}

	rep(i, n) {
		if (d[i] == 0) continue;
		ans *= cnt[d[i] - 1];
		ans %= mod;
	}

	std::cout << ans << std::endl;

	return 0;
}

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
int n;
int a[1000];
ll d[1000][1000];
int main()
{while (1){
    FOR (i,1,300){
        FOR (j,1,300){
            d[i][j]=0;
        }
    }
    cin>> n;
    if (n==0) return 0;
    FOR (i,1,n){
        cin>> a[i];
    }
    for (int i=1; i<=n;i++){
        if (sq(a[i]-a[i-1])<=1) d[i-1][i]=0;
        else d[i-1][i]=2;
        d[i][i]=1;
        for (int j=i-2; j>=1;j--){ int u=2;d[j][i]=INF;
            if (sq(a[i]-a[j])<=1) u=0;
            if (d[j+1][i-1]==0){
                d[j][i]=u;
            }
            FOR (k,j,i-1){
                d[j][i]=min(d[j][i],d[j][k]+d[k+1][i]);
            }

        }

    }
    /*FOR(j,1,n){
        FOR(i,1,n){
            cout<<j<<" "<<i<<" "<<d[j][i]<<endl;
        }
    }*/
    cout<<n-d[1][n]<<endl;
}

         return 0;
}

Measured memory_bytes: 4912
/*
power and fast-scan code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 100001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

// void fastscan(int &number) 
// { 
//     //variable to indicate sign of input number 
//     bool negative = false; 
//     register int c; 
  
//     number = 0; 
  
//     // extract current character from buffer 
//     c = getchar(); 
//     if (c=='-') 
//     { 
//         // number is negative 
//         negative = true; 
  
//         // extract the next character from the buffer 
//         c = getchar(); 
//     } 
  
//     // Keep on extracting characters if they are integers 
//     // i.e ASCII Value lies from '0'(48) to '9' (57) 
//     for (; (c>47 && c<58); c=getchar()) 
//         number = number *10 + c - 48; 
  
//     // if scanned input has a negative sign, negate the 
//     // value of the input number 
//     if (negative) 
//         number *= -1; 
// } 

bool comp(ll &a, ll &b){
    return a>b;
}

bool _pal(string s){
    ll n=s.length();
    for(ll i=0, j=n-1;i<j;i++, j--){
        if(s[i]!=s[j]){
            return false;
        }
    }
    return true;

}

int main(){


    // #ifndef ONLINE_JUDGE 

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 

    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout); 
    // #endif 


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;
    ll n=s.length();
    if(n%2==0){
        cout<<"No"<<endl;
        return 0;
    }
    bool ans=_pal(s);
    ans=ans && _pal(s.substr(0, n/2));
    
    ll idx=(n/2)+(n%2);
    ans=ans && _pal(s.substr(idx, n/2));
    if(ans){
        cout<<"Yes\n";
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
def comb(n, k, mod=10 ** 9 + 7):
    denominator = 1
    numerator = 1
    for i in range(1, k + 1):
        denominator = denominator * i % mod
    for i in range(n - k + 1, n + 1):
        numerator = numerator * i % mod
    return numerator * pow(denominator, mod - 2, mod) % mod


def main():
    n = int(input())
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(1, n):
        if n - 3 * i < 0:
            break
        ans += comb(n - 2 * i - 1, n - 3 * i, mod)
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();

            var count = new long[100002];
            for (int i = 0; i < N; i++)
            {
                count[a[i]]++;
                if (a[i] != 0)
                {
                    count[a[i] - 1]++;
                }
                count[a[i] + 1]++;
            }

            return count.Max();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 37144
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int h[21];
    for(int i=0; i<n; i++) cin>>h[i];
    int ans=0;
    for(int i=0; i<n; i++){
        bool ok=1;
        for(int j=0; j<i; j++){
            if(h[j]>h[i]){
                ok=0;
            }
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int getMedium(vector<int> v) {
    int s = v.size();
    sort(v.begin(), v.end());
    if (s % 2 == 1)
        return v[s/2];
    return v[s/2] + v[s/2-1];
}

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N)
        cin >> A[i] >> B[i];
    int a = getMedium(A);
    int b = getMedium(B);
    cout << b-a+1 << endl;
    return 0;
}

Measured memory_bytes: 5632
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0; i < N; i++) {
			int A = Integer.valueOf(s.next());
			map.put(A, map.getOrDefault(A, 0) + 1);
		}
		int Q = Integer.valueOf(s.next());
		long[] ret = new long[Q+1];
		for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
			ret[0] += entry.getKey() * entry.getValue();
		}
		
		for(int i = 0; i < Q; i++) {
			int before = Integer.valueOf(s.next());
			int after = Integer.valueOf(s.next());
			
			ret[i+1] = ret[i] + (after - before) * map.getOrDefault(before, 0);
			map.put(after, map.getOrDefault(after, 0) + map.getOrDefault(before, 0));
			map.remove(before);
		}
		
		for(int i = 1; i <= Q; i++) {
			System.out.println(ret[i]);
		}
	}
}

Measured memory_bytes: 70328
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// Eratosthenes's sieve
// create list of prime numbers in O(N)
// check if the given number is prime in O(1)

struct Sieve {
    vector<bool> isPrime;
    Sieve(size_t max) : isPrime(max + 1, true) {
        isPrime[0] = false;
        isPrime[1] = false;

        for (size_t i = 2; i * i <= max; ++i)         // 0からsqrt(max)まで調べる
            if (isPrime[i])                           // iが素数ならば
                for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
                    isPrime[i * j] = false;           // 素数ではない
    }
    bool operator()(size_t n) { return isPrime[n]; }
};

int main() {
    int x;
    cin >> x;
    Sieve si(200000);
    for (int i = x; i < 200000; ++i) {
        if (si(i)) {
            cout << i << "\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y,ll b){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1,b)*x)%b;
    ll t=expm(x,y/2,b);
    return (t*t)%b;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}/*
ll inv(ll x){
    return expm(x,big-2);
}
*/

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    ll n;cin >> n;
    if(n%2==0||n%5==0){
        cout << -1 << endl;
    }
    else{
        ll ans=0;
        rep(i,100000000){
            ans+=expm(10,i,n)*7%n;
            ans%=n;
            if(ans==0){
                cout << i+1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define int long long

auto main() -> signed {
    int H, W;
    cin >> H >> W;
    if(H%3==0||W%3==0) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1e+9;
    for(int h=1; h<H; ++h) {
        int a = h*W;
        int bw = W/2;
        int b = bw*(H-h);
        int c = (W-bw)*(H-h);
        vector<int> v;
        v.push_back(a);
        v.push_back(b);
        v.push_back(c);
        sort(v.begin(), v.end());
        ans = min(ans, v[2]-v[0]);

        if(H-h>=2) {
            int bh = (H-h)/2;
            b = bh*W;
            c = (H-h-bh)*W;
            v.clear();
            v.push_back(a);
            v.push_back(b);
            v.push_back(c);
            sort(v.begin(), v.end());
            ans = min(ans, v[2]-v[0]);
        }
    }

    for(int w=1; w<W; ++w) {
        int a = w*H;
        int bh = H/2;
        int b = bh*(W-w);
        int c = (W-w)*(H-bh);
        vector<int> v;
        v.push_back(a);
        v.push_back(b);
        v.push_back(c);
        sort(v.begin(), v.end());
        ans = min(ans, v[2]-v[0]);

        if(W-w>=2) {
            int bw = (W-w)/2;
            b = bw*H;
            c = (W-w-bw)*H;
            v.clear();
            v.push_back(a);
            v.push_back(b);
            v.push_back(c);
            sort(v.begin(), v.end());
            ans = min(ans, v[2]-v[0]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  Atcoder
//
//  Created by Keita on 2020/06/21.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

void doProblemA(){
    char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
    cin >> s;
    //>> a >> A >> b >> B >> c >> C >> d >> D >> e >> E >> f >> F >> g >> G >> h >> H >> i >> I >> j >> J >> k >> K >> l >> L >> m >> M >> n >> N >> o >> O >> p >> P >> q >> Q >> r >> R >> s >> S >> t >> T >> u >> U >> v >> V >> w >> W >> x >> X >> y >> Y >> z >> Z;
    if(s >= 'A' && s <= 'Z'){
  //if(isupper(s)){
       //α == a or α == b or α == c or α == d or α == e or α == f or α == g or α == h or α == i or α == j or α == k or α == l or α == m or α == n or α == o or α == p or α == q or α == r or α == s or α == t or α == u or α == v or α == w or α == x or α == y or α == z){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }
}

void doProblemB(){
    int N, K;
    cin >> N >> K;
    vector<int> v;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    
    sort(v.begin(),v.end());
    
    int answer;
    
    for(int i = 0; i < K; i++){
        answer += v[i];
    }
    
    cout << answer << endl;
}

void doProblemC(){
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

void doProblemD(){
    int ans;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i])ans++;
    }
    cout << ans << endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    doProblemD();
    return 0;
}
 


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    REP(i, n - 1) {
        if (k == 0) break;
        int d = (('z' - s[i]) + 1) % 26;
        if (d > k) continue;
        s[i] = 'a';
        k -= d;
    }
    if (k > 0) {
        k %= 26;
        if (s[n - 1] + k > 'z') {
            s[n - 1] += k - 26;
        } else {
            s[n - 1] += k;
        }
    }
  
    cout << s << endl;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll now=0;
  rep(i,0,n)if(a[i]==now+1)now++;
  ans(now==0,-1,n-now);
  return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))

if p.count(x) == 0:
    print(x)
else:
    ans_large = x
    ans_small = x
    cycle = 1
    while ans_large == x and ans_small == x:
        # 負の方向
        if p.count(x - cycle) == 0:
            ans_small -= cycle
            break
        # 正の方向
        if p.count(x + cycle) == 0:
            ans_large += cycle
            ans_small = 101 # smallを範囲から外す
        cycle += 1
    print(min(ans_large, ans_small))


Measured memory_bytes: 9200
/**
 *    Author:  Oak_limy
 *    Created: 2020-08-29 20:33:51
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
char a[1001],b[1001];
ll x[1001],y[1001];
ll minv=bql-1,ans;
int main(){
    cin>>(a+1)>>(b+1);
    //cout<<strlen(a+1)<<endl;
    rp(i,1,strlen(a+1)-strlen(b+1)+1){
        ans=0;
        rp(j,1,strlen(b+1)){
            //cout<<a[j]<<' '<<b[j]<<endl;
            if(a[j+i-1]-b[j]!=0)ans++;
        }
        //cout<<endl;
        minv=min(minv,ans);
        //cout<<minv<<endl;
    }
    cout<<minv<<endl;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

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

int main() {
	int m, n;
	cin >> n >> m;
	int a[n][m], b;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++)
		cin >> a[i][j];	
	}
	for (int i = 0; i < m; i++){
		cin >> b;
		for (int j = 0; j < n; j++)
		a[j][i] *= b;
	}
	for (int i = 0; i < n; i++){
		int sum = 0;
		for (int j = 0; j < m; j++)
		sum += a[i][j];
	cout << sum << endl;	
	}
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> b(n);
	rep(i, n + 1) cin >> a.at(i);
	rep(i, n) cin >> b.at(i);

	ll ans = 0;
	rep(i, n) {
		if (b.at(i) >= a.at(i)) {
			ans += a.at(i);
			b.at(i) = b.at(i) - a.at(i);
			a.at(i) = 0;
			if (b.at(i) >= a.at(i + 1)) {
				ans += a.at(i + 1);
				a.at(i + 1) = 0;
			}
			else if (b.at(i) < a.at(i + 1)) {
				ans += b.at(i);
				a.at(i + 1) = a.at(i + 1) - b.at(i);
			}
		}
		else if (b.at(i) < a.at(i)) {
			ans += b.at(i);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    long ans = 0;
    cin >> n;
    vector<long> table(n + 1, 0);

    for (int i = 1; i < n + 1; i++)
    {

        for (int j = i; j < n + 1; j += i)
        {
            table[j]++;
        }
    }
    for (long i = 1; i < n + 1; i++)
    {
        ans += i * table[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81400