akhauriyash/Code-Regression huggingface dataset:
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)

    const m = Array(N + 1).fill(0)
    for (let i = 0; i < N; i++) {
        m[A[i]]++
    }

    const f = (n, m, d = 1) => {
        let sum = n
        let add = n
        for (let i = 1; i < m; i++) {
            add += d
            sum += add
        }
        return sum
    }

    let s = 0
    for (let i = 1; i <= N; i++) {
        if (m[i] < 2) continue
        s += f(1, m[i] - 1)
    }

    for (let k = 0; k < N; k++) {
        const ans = s - (m[A[k]] - 1)
        console.log(ans)
    }

})(input)


Measured memory_bytes: 62120
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <cstdio>
#include <sstream>
#include <algorithm>
#define endl '\n'
#define all(var) var.begin(), var.end()
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;

 
int main(){
    int n; cin >> n;
    vector < string > v(n);
    map < string , int > mp;

    for(auto &i: v){
        cin >> i;
        mp.insert({i, 0});
    }
    int mx = 0;
    for(auto i: v){
        mp[i]++;
        mx = max(mx, mp[i]);
    }
    for(auto i: mp)
        if(i.second == mx)
            cout << i.first << endl;
    

}


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

int main() {
    int n; cin >> n;
    for(int i = n; i <= 999; i ++) {
        if(i/100==i%10 && i%10==i%100/10) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n; cin>>n;
    msl m;
    while(n--){
        string s; cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"];
}


Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
 
int main(){
  char s[11];
  scanf("%s",s);
  int n;
  n = strlen(s);
  
  if(s[0]!='h'||s[n-1]!='i'){
    printf("No");
    return 0;
  }
  
  for(int i=0;i<n;i++){
    if(i%2==0){
    if(s[i]!='h'){
      printf("No");
      return 0;
    }
    }
    else{
      if(s[i]!='i'){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mp make_pair

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;
#define MAX 500000

#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];

int cnt;


void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];

    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }

}

void mergeSort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
    return;
}

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];


    mergeSort(A, n, 0, n);
    for (i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }

    cout << endl;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6968
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,a[100],f=0;
  cin>>n;
  for(int i=0;i<n;i++){
	cin>>a[i];
  }
  for(int i=1;i<n-1;i++){
    if(a[i-1]>a[i] &&  a[i+1]<a[i]){
      f++;
    }
    if(a[i-1]<a[i] && a[i+1]>a[i]){
      f++;
    }
  }
  cout<<f<<"\n";
  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll lcmCD = C / __gcd(C, D) * D;
  cout << (B - B / C - B / D + B / lcmCD)
        - ((A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / lcmCD) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a1, a2, a3 int
	fmt.Scanf("%d %d %d", &a1, &a2, &a3)

	if a1 + a2 + a3 >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

Measured memory_bytes: 512
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m, q = rm()
li = [rl() for _ in range(q)]
max_ = 0
for A in list(itertools.combinations_with_replacement(list(range(1, m+1)), n)):
    score = 0
    for abcd in li:
        a, b, c, d = abcd
        a -= 1
        b -= 1
        if A[b] - A[a] == c:
            score += d
    else:
        max_ = max(score, max_)
print(max_)

Measured memory_bytes: 39312
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#define INF 1000000007
using namespace std;
typedef long long ll;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> arr(n);
	int sm = 0;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		sm += arr[i];
	}
	vector<int> ys;
	for(int i = 1; i <= sqrt(sm); i++) {
		if((sm%i)==0) {
			ys.push_back(i);
			if((sm/i)!=i) ys.push_back(sm/i);
		}
	}
	int ans = 1;
	for(int md_index = 0; md_index < ys.size(); md_index++) {
		int md_num = ys[md_index];
		vector<int> df(n);
		for(int i = 0; i < n; i++) {
			df[i] = arr[i]-(arr[i]/md_num)*md_num;
		}
		sort(df.begin(),df.end());
		ll act_cnt = 0;
		int l = 0;
		int r = n-1;
		while(df[l]==0&&l<n) l++;
		while(l!=r+1) {
			int d = min(df[l],md_num-df[r]);
			df[l] -= d;
			df[r] += d;
			act_cnt += d;
			if(df[l]==0) l++;
			if(df[r]==md_num) r--;
		}
		if(act_cnt<=k) ans = max(ans,md_num);
	}
	cout << ans << endl;
}


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

typedef long long ll;

 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i]--;
  }
  int s=0;
  for(int i=0; i<n; i++){
    s = a[s];
    if(s==1){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

using namespace std;

int main(){
  int N,K,step;
  cin>>N>>K;
  
     for(int i=0;i<N;i++){
         int x;
         cin>>x;
     	
        if(K-x<x){
          step+=(K-x)*2;
        }else{
          step+=2*x;
        }
     }
  cout<<step<<endl;
  
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
z = 'Yes'
for i in range(n//2):
    if s[i] != s[-1-i]:
        z = 'No'
if z == 'Yes':
    for h in range(len(s[:(n-1)//2])):
        if s[:(n-1)//2][h] != s[:(n-1)//2][-1-h]:
            z = 'No'
            break
if z == 'Yes':
    for j in range(len(s[((n+3)//2)-1:])):
        if s[((n+3)//2)-1:][j] != s[((n+3)//2)-1:][-1-j]:
            z = 'No'
            break
print(z)

Measured memory_bytes: 9092
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; ++i) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}


int main()
{
    int n;
    cin >> n;
    set<string> s;
    REP(i,n){
        string in;
        cin >> in;
        s.insert(in);
    }
    cout << s.size() << endl;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    vector<int> p(M);
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            int a;
            cin >> a;
            s[i].push_back(a);
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    int COUNT = 0;

    for (int i = 0; i < (1 << N); i++) {
        bool allon = true;
        for (int j = 0; j < M; j++) {
            bool on = false;
            int count = 0;
            for (int l = 0; l < k[j]; l++) {
                if (i & (1 << s[j][l]-1)) count ++;
            }
            if (count % 2 == p[j]) on = true;
            if (!(on)) allon = false;
        }
        if (allon) COUNT ++;
    }

    cout << COUNT << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  LL answer = 0;
  map<string,LL> exist;
  REP(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    answer += exist[s];
    ++exist[s];
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i =>int.Parse(i)).ToArray();

        Console.WriteLine(input[0]<=input[2]&&input[2]<=input[1]?"Yes":"No");

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13268
fun main(args: Array<String>) {
    val(N,K) = readLine()!!.split(" ").map{it.toLong()}
    val n = N/K
    if(K%2==1L){
        println(n*n*n)
    }else{
        val z= N/(K/2) - N/K
        println(n*n*n+z*z*z)
    }

}

Measured memory_bytes: 37896
#include<stdio.h>

int main(){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0) break;
		for(i = 0;i<H;i++){
			for(j = 0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B, C, D;

  IN(A,B,C,D);

  while(true){
    C-=B;
    if(C<=0){
      OUT("Yes");
      break;
    }
    A-=D;
    if(A<=0){
      OUT("No");
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include <math.h>
int prime(int num)
{
	if(num == 1)
	{
		return 0;
	}
	int tmp = sqrt(num) + 1;
	for(int i = 2; i < tmp; i++)
	{
		if(num % i == 0)
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	int n,i,j,k;
	scanf("%d",&n);
	
	
	printf("%d:",n);
	if(prime(n))
	{
		printf(" %d\n", n);
		return 0;
	}
	for(i=2;n!=1;)
	{
		if(n%i!=0)
		{
			//if(n==2)
			i++;
			//else
			//i+=2;
		}
		else
		{
			printf(" %d",i);
			n/=i;
		}
	}
	printf("\n");
	
}


Measured memory_bytes: 2732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

long long mergecount(vector<long long> &a) {
  long long count = 0;
  int n = a.size();
  if (n > 1) {
    vector<long long> b(a.begin(), a.begin() + n/2);
    vector<long long> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (int i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}

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

    string S;
    cin >> S;
    int N = S.size();
    map<char, long long> mp;
    for(char c : S) mp[c]++;

    int od = 0;
    for(int i=0; i<26; i++){
        char c = 'a' + i;
        if(mp[c] % 2 == 1) od++;
    }
    if(od >= 2){
        cout << -1 << endl;
        return 0;
    }
    char c0 = ' ';
    if(N % 2 == 1){
        for(int i=0; i<26; i++){
            char c = 'a' + i;
            if(mp[c] % 2 == 1)
                c0 = c;
        }
    }

    vector<long long> pos(N, 0);
    map<char, long long> mp2;
    for(int i=0; i<N; i++){
        char c = S[i];
        if(mp2[c] < mp[c] / 2) pos[i] = -1;
        else pos[i] = 1;
        if(c == c0){
            if(mp2[c0] == mp[c0] / 2)
                pos[i] = 0;
        }
        mp2[c]++;
    }

    int cnt1 = 0, cnt2 = N/2, cnt3 = (N+1)/2;
    vector<long long> pos2(N);
    for(int i=0; i<N; i++){
        if(pos[i] == -1){
            pos2[i] = cnt1;
            cnt1++;
        }else if(pos[i] == 0){
            pos2[i] = cnt2;
        }else{
            pos2[i] = cnt3;
            cnt3++;
        }
    }

    long long ans = mergecount(pos2);

    int M = N / 2;
    vector<char> le(M), ri(M);
    cnt1 = 0; cnt2 = 0;
    for(int i=0; i<N; i++){
        if(pos[i] == -1){
            le[cnt1] = S[i];
            cnt1++;
        }
        else if(pos[i] == 1){
            ri[cnt2] = S[i];
            cnt2++;
        }
    }
    reverse(ri.begin(), ri.end());

    map<pair<char, long long>, long long> mp3;
    map<char, long long> mp4;
    int cnt = 1;
    for(int i=0; i<M; i++){
        char c = ri[i];
        long long num = mp4[c];
        mp3[make_pair(c, num)] = cnt;
        mp4[c]++;
        cnt++;
    }
    map<char, long long> mp5;
    vector<long long> le2(M);
    for(int i=0; i<M; i++){
        char c = le[i];
        le2[i] = mp3[make_pair(c, mp5[c])];
        mp5[c]++;
    }
    ans += mergecount(le2);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int ll

void find_number(int N){
	vector<int> arr(N+1);
	queue<ll> q;
	for(int i = 1 ; i <= 9 ;i++)
		q.push(i);
	for(int i = 1 ; i <= N ; i++){
		arr[i] = q.front();
		q.pop();
		if(arr[i]%10 != 0)
			q.push(arr[i]*10 + arr[i]%10-1);
		q.push(arr[i]*10+arr[i]%10);
		if(arr[i]%10 != 9)
			q.push(arr[i]*10+arr[i]%10+1);
		}
		cout<<arr[N]<<"\n";
	}

void test_case(){
	int n; cin >> n;
	find_number(n);
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 5568
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()) {
			int a = s.nextInt();
			int b = s.nextInt();
			int c = a + b;
			System.out.println(Integer.toString(c).length());
		}
	}
}

Measured memory_bytes: 20444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int K;
  cin>>K;
  VVL ans(10,VL());
  rep(i,9) ans[0].pb(i+1);
  rep(i,9){
    rep(j,ans[i].size()){
      ll tmp=ans[i][j];
      ll F=tmp%10;
      if(F) ans[i+1].pb(tmp*10+F-1);
      ans[i+1].pb(tmp*10+F);
      if(F!=9) ans[i+1].pb(tmp*10+F+1);
    }
  }
  VL ans2;
  rep(i,10) rep(j,ans[i].size()) ans2.pb(ans[i][j]);
  sort(all(ans2));
  cout<<ans2[K-1]<<endl;
}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll N, X; cin >> N >> X;
	ll res = 3LL*(N-__gcd(N,X));

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i = 0;
    long long x;
    long long c = 0;
    long long t = 0;

    scanf("%lld",&x);

    while(1){
        i++;
        c += i;
        t++;
        if(c >= x){
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    S = input()[-1]

    if S in ['0','1','6','8']:
        print('pon')
    elif S == '3':
        print('bon')
    else:
        print('hon')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            //入力読取。
            string strWord = Console.ReadLine();
            
            //大文字、小文字変換。
            char[] chWord = strWord.ToCharArray();
            for (int suffix = 0; suffix < chWord.Length; suffix++)
            {
                if (char.IsUpper(chWord[suffix]))
                {
                    chWord[suffix] = char.ToLower(chWord[suffix]);
                }
                else
                {
                    chWord[suffix] = char.ToUpper(chWord[suffix]);
                }
            }

            //出力
            foreach(char changeWord in chWord){
                Console.Write(changeWord);    
            }
            Console.WriteLine();
            
        }
    }

}



Measured memory_bytes: 17828
a = [0 for i in range(101)]  #101個の0がリストに入ってる
while True:
  try:
    n = int(input())
    a[n] += 1
  except EOFError:
    break
m = 0
for i in range(1, 101):    #最頻値の最頻回数ｍを求めている
  m = max(m, a[i])
for i in range(1, 101): 
    if a[i] == m:          #最頻回数と一致するものをみつけて最頻値を出力
        print(i)



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

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << (s < t ? "Yes\n" : "No\n");
    return 0;
}

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll solve(int n, ll m, vector<ll> a) {
    while (a[0] % 2 == 0) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        m /= 2;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) return 0;
    }
    ll lcm = 1;
    for (int i = 0; i < n; ++i) {
        ll g = gcd(lcm, a[i]);
        lcm = lcm / g * a[i];
        if (lcm > m) return 0;
    }
    return (m / lcm + 1) / 2;
}

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    cout << solve(n, m, a) << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int dp[31];
int solve(int d){
    if(dp[d] != -1)
        return dp[d];
    else
        return dp[d] = solve(d-1) + solve(d-2) + solve(d-3);
}

int main(){
    int n;
    for(int i = 0; i < 31; i++)
        dp[i] = -1;
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    while(cin >> n,n){
        if(n == 1 || n == 2 || n == 3)
            cout << 1 << endl;
        else
            cout << solve(n) / 10 / 365 + 1 << endl;
    }
}

Measured memory_bytes: 3088
N,D,A=map(int,input().split())
XH=sorted([list(map(int,input().split())) for i in range(N)])
l,r=0,0
a=0
dp=0
dm=[0]*(N+1)
while l<N:
    while r<N and XH[r][0]<=XH[l][0]+2*D:
        r+=1
    dp+=dm[l]
    x=-(-max(0,XH[l][1]-dp)//A)
    a+=x
    dp+=x*A
    dm[r]-=x*A
    l+=1
print(a)

Measured memory_bytes: 83928
#include <bits/stdc++.h>
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++)


int main() {
  long n;
  cin>>n;
  vector<string>a(n);
  map<string,int>memo;
  rep(i,n){
    cin>>a.at(i);
    memo[a.at(i)]++;
  }
  cout<<"AC x ";
  cout<<memo["AC"]<<endl;
  cout<<"WA x ";
  cout<<memo["WA"]<<endl;
  cout<<"TLE x ";
  cout<<memo["TLE"]<<endl;
  cout<<"RE x ";
  cout<<memo["RE"]<<endl;

}




Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
vi occur[26];
int main(){

   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
        
    string s,t;cin>>s>>t;

    ll n = s.size();
    forn(i,n){
    	occur[s[i] - 'a'].pb(i);
    }
    forn(i,26)occur[i].pb(n);
    ll ptr = -1;
    for(char c: t){	
    	ll idx = (ll)(upper_bound(all(occur[c - 'a']), ptr%n) - occur[c - 'a'].begin());
    	ll p = occur[c - 'a'][idx];
    	if(p == n){
    		ptr = (ptr/n + 1)*n;
    		idx = (ll)(upper_bound(all(occur[c - 'a']), ptr%n-1) - occur[c - 'a'].begin());
    		p = occur[c - 'a'][idx];
    	}
    	if(p == n){
    		cout<<-1<<endl;
    		return 0;
    	}
    	ptr += p-(ptr%n);
    }
    cout<<ptr+1<<endl;
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 1736
from collections import deque

n = int(input())
gr = { i:[] for i in range(1, n + 1)}
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    gr[a].append((b, c))
    gr[b].append((a, c))
q, k = map(int, input().split())
dmax = 10**14 + 1
dist = [dmax for _ in range(n + 1)]
dist[k] = 0
ls = deque([k])
while 0 < len(ls):
    u = ls.popleft()
    for v, c in gr[u]:
        if dist[v] == dmax:
            dist[v] = dist[u] + c
            ls.append(v)

for _ in range(q):
    x, y = map(int, input().split())
    print(dist[x] + dist[y])

Measured memory_bytes: 52196
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    ll N,K;
    cin >> N >> K;
    if (500 * N >= K){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> p(n), m(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    if (i >= 1) m[i] = min(m[i-1], p[i]);
    else m[0] = p[0];

  }
  
  for (int i = 0; i < n; ++i) {
    if (p[i] <= m[i]) ++ans;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	long n;
	cin >> n;
	string s[n];
	vector<int> MRC(5,0);
	int val=0;
	long M_cnt=0,A_cnt=0,R_cnt=0,C_cnt=0,H_cnt=0;
	long ans=0,sum=1;
	int calc_f=0;
	
	for(int i=0;i<n;i++){
		cin >> s[i];
		if(s[i][0]=='M'){
			if(MRC[0]==0){
				val++;
			}
			MRC[0]++;
		}
		if(s[i][0]=='A'){
			if(MRC[1]==0){
				val++;
			}
			MRC[1]++;
		}
		if(s[i][0]=='R'){
			if(MRC[2]==0){
				val++;
			}
			MRC[2]++;
		}
		if(s[i][0]=='C'){
			if(MRC[3]==0){
				val++;
			}
			MRC[3]++;
		}
		if(s[i][0]=='H'){
			if(MRC[4]==0){
				val++;
			}
			MRC[4]++;
		}
	}

	if(val<3){
		cout << "0" << endl;
		return 0;
	}
	
	if(val==3){
		for(int i=0;i<5;i++){
			if(MRC[i]!=0){
				sum*=MRC[i];
			}
		}
		ans=sum;
		cout << ans << endl;
		return 0;
	}
	
	if(val==4){
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				if(j==i)continue;
				if(MRC[j]!=0 && j!=i){
					sum=sum*MRC[j];
					calc_f++;
				}
			}
			if(calc_f==3)ans+=sum;
			sum=1;
			calc_f=0;
		}
		cout << ans << endl;
		return 0;
	}
	
	if(val==5){
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				for(int k=0;k<5;k++){
					if(k!=i && k!=j){
						sum=sum*MRC[k];
						calc_f++;
					}
				}
				if(calc_f==3){
					ans+=sum;
				}
				sum=1;
				calc_f=0;
			}
		}
		cout << ans/2 << endl;
		return 0;
	}
	
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int N, K, Q; cin >> N >> K >> Q;
    int S[N];
    rep(i, 0, N) S[i] = K;
    rep(i, 0, N) S[i] -= Q;
    rep(i, 0, Q) {
        int n; cin >> n;
        S[n-1] += 1;
    }
    rep(i, 0, N) {
        if (S[i] <= 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 4024
//-----------------------
// author : xyqkoala
// time : 2020-09-14
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();
void solve1();

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve1();
	}
	return 0;
}


int dfs(vector<int> &dp,int x){
	if(x<0) return 0;
	if(dp[x] != -1) return dp[x];
	if(x==0) return dp[x];
	if(x<3) return 0;
	dp[x] = 0;
	for(int i=3;i<=x;i++){
		dp[x] = (dp[x]+dfs(dp,x-i))%MOD;
	}
	return dp[x];
}
void solve(){
	int n;
	cin>>n;
	vector<int> dp(n+1,-1);
	dp[0] = 1;
	cout<<dfs(dp,n)<<endl;
}


void solve1(){
	int n;
	cin>>n;
	vector<int> dp(n+1,0);
	dp[0] = 1;
	LL s = 1;
	for(int i=3;i<=n;i++){
		dp[i] = s;
		s = (s+dp[i-2])%MOD;
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ColorfulBlocks solver = new ColorfulBlocks();
        solver.solve(1, in, out);
        out.close();
    }

    static class ColorfulBlocks {
        public static int MOD = 998244353;
        static long[] fac;
        static long[] finv;
        static long[] inv;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int k = in.nextInt();

            comInit(n);

            long ans = 0;
            for (int i = 0; i <= k; i++) {
                long c = com(n - 1, i);
                ans = (ans + (c * m % MOD * modPow(m - 1, n - i - 1, MOD)) % MOD) % MOD;
            }
            out.append(String.valueOf(ans));
        }

        static void comInit(int max) {
            fac = new long[max + 1];
            finv = new long[max + 1];
            inv = new long[max + 1];

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

        static long com(int n, int k) {
            if (n < k) {
                return 0;
            }
            return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
        }

        static long modPow(long x, long n, long mod) {
            if (n == 0) {
                return 1;
            }
            long result = modPow(x, n / 2, mod);

            if (n % 2 == 0) {
                return (result * result) % mod;
            }
            return (((result * result) % mod) * x) % mod;
        }

    }
}



Measured memory_bytes: 40528
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<ll> dp(n+1),a(n);
    rep(i,0,m){
        int b;cin>>b;
        a[b-1] = 1;
    }
    dp[0] = 1;
    if (a[0]==0) dp[1] = 1;
    rep(i,1,n){
        if (a[i]!=1){
            dp[i+1] = (dp[i]+dp[i-1])%mod;
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4788
import collections
import sys
sa=input()
sb=input()
sc=input()
a=collections.deque([])
b=collections.deque([])
c=collections.deque([])
for i in range(len(sa)):
  a.append(sa[i])
for i in range(len(sb)):
  b.append(sb[i])
for i in range(len(sc)):
  c.append(sc[i])
current='a'
while True:
  if current=='a':
    if a:
      current=a.popleft()
    else:
      print('A')
      sys.exit()
  if current=='b':
    if b:
      current=b.popleft()
    else:
      print('B')
      sys.exit()
  if current=='c':
    if c:
      current=c.popleft()
    else:
      print('C')
      sys.exit()


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

int main(void) {
	int N;
	scanf("%d", &N);
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	sort(d.begin(), d.end());
	int centerIdx = d.size() / 2;
	int ans;
	ans = d[centerIdx] - d[centerIdx - 1];
	printf("%d", ans);

	return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        Robot[] robots = new Robot[n];
        for (int i = 0; i < n; i++) {
            robots[i] = new Robot(br.readLine());
        }
        Arrays.sort(robots);
        int count = 0;
        int left = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            if (left <= robots[i].left) {
                count++;
                left = robots[i].right;
            }
        }
        System.out.println(count);
    }

    static class Robot implements Comparable<Robot> {
        int point;
        int length;
        int left;
        int right;
        
        public Robot (String arg) {
            String[] arr = arg.split(" ", 2);
            point = Integer.parseInt(arr[0]);
            length = Integer.parseInt(arr[1]);
            left = point - length;
            right = point + length;
        }
        
        public int compareTo(Robot another) {
            return right - another.right;
        }
    }
}


Measured memory_bytes: 46932
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> T MV(T v) { return v; }
template<typename T, typename ... U> auto MV(T v, int a, U ... b) { return vector<decltype(MV(v, b ...))>(a, MV(v, b ...)); }

int main() {
	IN(string, s);
	IN(int, k);
	int n = SI(s);
	
	auto dp = MV(0, n + 1, 2, k + 2);
	dp[0][0][0] = 1;
	inc(i, n) {
	inc(f, 2) {
	inc(c, k + 1) {
	inc(d, 10) {
		if(f == 0 && d > s[i] - '0') { continue; }
		int ff = (f == 0 && d == s[i] - '0' ? 0 : 1);
		int cc = c + (d == 0 ? 0 : 1);
		dp[i + 1][ff][cc] += dp[i][f][c];
	}
	}
	}
	}
	
	OUT(dp[n][0][k] + dp[n][1][k]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f,g,h,i;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
  puts((a+e+i==b+f+g&&a+e+i==c+d+h?"Yes":"No"));
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int X,Y;
  cin >> X >> Y;
  string ans="Yes";
  if(Y%2==1) ans="No";
  else if(Y/2-X<0) ans="No";
  else if(2*X-Y/2<0) ans="No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

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

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	vint a(3);
	rep(i, 3)cin >> a[i];
	sort(a);
	reve(a);
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << rt;

	please AC;
}

Measured memory_bytes: 256
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

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

const int N = 500;

using namespace std;

int main() {
	int n, max = 0, k;
	vector<int> v, a;

	cin >> n;

	rep(i, 0, n) {
		cin >> k;
		v.push_back(k);
		a.push_back(k);
	}

	sort(a.begin(), a.end(), greater<int>());

	rep(i, 0, n) {
		if (v[i] != a[max]) {
			cout << a[max] << endl;
		} else {
			cout << a[max + 1] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3436
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
constexpr long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

vector<long> a[26];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    REP(i,n) a[s[i]-'a'].push_back(i);
    REP(i,m) {
        if(a[t[i]-'a'].empty()){
            cout << -1 << endl;
            return 0;
        }
    }


    long ans = 0, pos = a[t[0]-'a'][0];
    for(int i = 1; i < m; ++i) {
        int idx = t[i]-'a';
        auto itr = upper_bound(a[idx].begin(), a[idx].end(), pos);
        if(itr == a[idx].end()) {
            ans += n;
            pos = a[idx][0];
        } else pos = *itr;
    }

    cout << ans + pos + 1 << endl;

    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,n;
    cin >> n;
    ll ara[n+10],sum = 0 ;
    for(ll i=1; i<=n; i++)
    {
        cin >> ara[i];
        sum += ara[i];
    }
    ll m;
    cin >> m;
    for(ll i=1; i<=m; i++)
    {
        ll x,y;
        cin >> x >> y;
        ll temp = sum ;
        temp -= ara[x] ;
        temp += y;
        cout << temp << endl;
    }


}


Measured memory_bytes: 3612