akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long int n;
    cin>>n;
    long long int a[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    map<long long int,long long int> m;
    for(int i=0;i<n;i++){
        m[i-a[i]]++;
    }

    long long int ans = 0;
    for(int i=0;i<n;i++){
        ans += m[i+a[i]];
    }
    cout<<ans;
}

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

int main(){
    int N;
    bool flag = false;
    cin >> N;

    for(int i=1; i<=9; i++){
        if(flag) break;
        for(int j=1; j<=9; j++){
            if(N == i*j) flag = true;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
S = list(str(input()))
N = len(S)
K = int(input())

ans1 = 0
old = ""
flag = 0
for i in range(N):
    if old == "":
        old = S[i]
    else:
        if old == S[i]:
            old = ""
            ans1+=1
        else:
            old = S[i]
            
    if i == N-1:
        if old == S[i] and S[0] == S[-1]:
            flag = 1

if flag == 0:
    print(ans1*K)
else:
    ans2 = 0
    old = ""
    for i in range(N):
        if i == 0:
            if S[0] == S[-1]:
                ans2+=1
        elif old == "":
            old = S[i]
        else:
            if old == S[i]:
                old = ""
                ans2+=1
            else:
                old = S[i]
    if i == N-1:
        if old == S[i] and S[0] == S[-1]:
            flag = 2
    
    k = K//2
    if flag == 2:
        print(ans1*1+ans2*(K-1))
    else:
        print(ans1*(K-k)+ans2*(k))

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

int main()
{
	set<int> s;
	int n;
	cin >> n;

	while (n--)
	{
		int a;
		cin >> a;
		if (s.count(a)) s.erase(a);
		else s.insert(a);
	}

	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

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

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (100005)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;

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

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

    int CD = C*D/gcd(C,D);

    int ac = (A-1)/C, ad = (A-1)/D, acd = (A-1)/(CD);
    int bc = B/C, bd = B/D, bcd = B/(CD);
    DEBUG3(ac,ad,acd);
    DEBUG3(bc,bd,bcd);
    int a = (A-1) - (ac+ad-acd), b = B - (bc+bd-bcd);
    cout << b - a << endl;

}

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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  for (int i = 0; i < A; i++) cin >> a.at(i);
  vector<int> b(B);
  for (int i = 0; i < B; i++) cin >> b.at(i);

  int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, a.at(x - 1) + b.at(y - 1) - c);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
void gcd(int, int);
int main() {
	int x, y;
	while(~fscanf(stdin,"%d%d", &x, &y),x||y) gcd(x, y);
	return 0;
}

void gcd(int x, int y) {
	int tmp;
	static int cnt;
	cnt++;
	if (x < y) { tmp = x; x = y; y = tmp; }
	if (x%y == 0) {
		fprintf(stdout, "%d %d\n", y, cnt);
		cnt = 0;
		return;
	}
	gcd(x%y, y);
}

Measured memory_bytes: 604
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
using ll = long long;

int main(){
  ll a,b,x;
  ll ans;
  cin >> a >> b >> x;
  ans = (b-a+1)/x;
  a += ans * x;
  ll c = a % x;
  c = c==0?x:c;
  if (a + x - c <= b) {
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if(a.substr(a.length()-1,1)==b.substr(0,1)&&b.substr(b.length()-1,1)==c.substr(0,1)){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  cout << endl;
  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int ball_count[N];
    bool if_red[N];
    fill(ball_count, ball_count + N, 1);
    fill(if_red + 1, if_red + N, false);
    if_red[0] = true;
    for(int i = 0; i < M; i++){
        int start, goal;
        cin >> start >> goal;
        if(ball_count[start - 1] == 1 && if_red[start - 1]){
            if_red[start - 1] = false;
            if_red[goal - 1] = true;
        }else if(if_red[start - 1]){
            if_red[goal - 1] = true;
        }
        ball_count[start - 1]--;
        ball_count[goal - 1]++;
    }
    cout << accumulate(if_red, if_red + N, 0) << endl;
}


Measured memory_bytes: 768
#include<vector>

using namespace std;

#define S_MAX 3001

class CNum{
public:
	int num;
	int sums[S_MAX];
	CNum(int num){
		this->num = num;
		for(int i = 0; i < S_MAX; i++){
			sums[i] = 0;
		}
	}
};

typedef vector<CNum> Line;

int main(void){
	while( 1 ){
		int cnt = 0;
		int N, M, S;
		Line line;
		

		cin >> N >> M >> S;
		if( N == 0 && M == 0 && S == 0 ){
			break;
		}

		for(int i = 0; i < N * N; i++){
			CNum cnum(i + 1);
			if( i == 0 ){
				cnum.sums[i + 1] = 1;
			}else if( i > 0 ){
				for(int j = 0; j < S_MAX; j++){
					if( line[i - 1].sums[j] > 0 ){
						cnum.sums[ cnum.num + j] = line[i - 1].sums[j];
					}
				}
			}
			line.push_back( cnum );
		}

		for(int h = 1; h < M + 1 - N * N; h++){
			for(int i = 0; i < N * N; i++){
				int &numref = line[i].num;
				if( i == 0 ){
					numref++;
					line[i].sums[ numref ]++;
				}else{
					numref++;
					for(int j = 0; j <= S; j++){
						if( j + numref <= S ){
							line[i].sums[j + numref ] += line[i - 1].sums[j];
							line[i].sums[j + numref ] %= 100000;
						}
					}
				}
			}
		}

		cout << line[N * N - 1].sums[S] << endl;
	}
	return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> A(N);
   for(int i=0; i<N; ++i){
      std::cin >> A[i];
      A[i] -= i+1;
   }   
   std::sort(A.begin(),A.end());

   long long ans = 0;
   for(int i=0; i<N/2; ++i){
      ans += A[N-1-i] - A[i];
   }  
    std::cout << ans << std::endl;
   return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=[0]+[(-1)**i*x for i,x in enumerate(map(int,input().split()))]
import itertools
cumsum=list(itertools.accumulate(A))
print(*[(-1)**(i-1)*(cumsum[-1]-cumsum[i-1]-cumsum[i-1]) for i in range(1,N+1)])

Measured memory_bytes: 17060
import java.util.*;

public class Main {
    private static Integer res= 0;
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            count += r - l +1;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24916
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(){
  long A, B, C, K, ans = 0;
  scanf("%ld %ld %ld %ld", &A, &B, &C, &K);
  if (K > A) {
    ans += A;
    K -= A;
  }
  else {
    ans += K;
    K = 0;
  }

  if (K > B) {
    K -= B;
  }
  else {
    K = 0;
  }

  if (K > C) {
    ans -= C;
  }
  else {
    ans -= K;
  }
  printf("%ld", ans);
  return 0;
}


Measured memory_bytes: 1720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	cout << min(A, B) << " " << max(0, A + B - N) << endl;
	return 0;
}

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

int main(){
    vector<char> alphabet = {'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'};
    int n;
    string s;
    string ans = "";

    std::cin >> n >> s;

    for(int i = 0; i < s.size(); i++){
        int pos = s.at(i) - 'A';
        int nextpos = (pos + n) % 26;
        ans += alphabet[nextpos];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll X;
    cin >> X;
    ll a[1000];
    rep(i, 1000){
        a[i] = 1;
        rep(j, 5) a[i] *= i; 
    }
    rep(i, 1000){
        rep(j, 1000){
            if(a[i]-a[j] == X){
                cout << i << ' ' << j << endl;
                return 0;
            }
            if(a[i]+a[j] == X){
                cout << i << ' ' << -j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    ll a=0,b=0,c=0;
    a=A*X+B*Y;
    b=C*max(X,Y)*2;
    if(X>Y) {
        c+=Y*2*C;
        c+=(X-Y)*A;
    }
    else if(X<Y) {
        c+=2*X*C;
        c+=(Y-X)*B;
    }
    else if(X==Y) {
        c+=X*2*C;
    }
    cout<<min(a,min(b,c))<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x, n := scanInt(), scanInt()
	c := map[int]bool{}
	for i := 0; i < n; i++ {
		c[scanInt()] = true
	}

	ans := 0
	ab := 1 << 50

	for i := -200; i < 200; i++ {
		if c[i] {
			continue
		}

		if ab > abs(i-x) {
			ans = i
			ab = abs(i - x)
		}
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1780
import itertools

N,M,Q = list(map(int, input().split()))
arr= [list(map(int,input().split())) for i in range(Q)]

ans=0
for com in itertools.combinations_with_replacement(range(1, M + 1), N):
    tmp=0
    for a,b,c,d in arr:
        if com[b-1]-com[a-1]==c:
            tmp+=d
            ans=max(ans,tmp)

print(ans)

Measured memory_bytes: 9084
import math
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input


class FenwickTree:
    def __init__(self, a_list, f, default):
        # 0-indexed
        self.N = len(a_list)
        self.bit = a_list[:]
        self.f = f
        self.default = default
        for _ in range(self.N, 1 << int(math.ceil(math.log(self.N, 2)))):
            self.bit.append(self.default)
        for i in range(self.N - 1):
            self.bit[i | (i + 1)] = self.f(self.bit[i | (i + 1)], self.bit[i])

    def update(self, i, val):
        while i < self.N:
            self.bit[i] = self.f(self.bit[i], val)
            i |= i + 1

    def query(self, n):
        # [0, n]
        ret = 0
        while n >= 0:
            ret = self.f(ret, self.bit[n])
            n = (n & (n + 1)) - 1
        return ret


N = int(input())
X = [int(x) for x in input().split()]
dp = FenwickTree([0] * N, lambda x, y: max(x, y), 0)
for x in X:
    dp.update(x - 1, dp.query(x - 1) + x)
print(N * (N + 1) // 2 - dp.query(N - 1))

Measured memory_bytes: 18960
#include <bits/stdc++.h>
using namespace std;
int n,w,x,y,i;
long long res;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>w;
    vector<long long>dp(w+1);
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        for(int z=w-x;z>=0;z--)
        {
            dp[z+x]=max(dp[z+x],dp[z]+y);
        }


    }
         for(i=0;i<=w;i++)
                res=max(res,dp[i]);



    cout << res<< endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int N = in.nextInt();
        int[] A = new int[N];
        int max = 0;
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
            max = max > A[i] ? max : A[i];
        }

        int[] hist = new int[max + 1];
        for (int a : A) {
            hist[a]++;
        }

        int count = 0;
        int amari = 0;
        for (int h : hist) {
            if (h > 0) {
                count++;
                amari += h - 1;
            }
        }
        int ans = count - (amari % 2);
        System.out.println(ans);
    }
}

Measured memory_bytes: 46652
#include<stdlib.h>
#include<stdio.h>
int main(){
	int sum=0;
	int n,a[105],i=1,j,k,t;
	scanf("%d",&n);
	for(t=1;t<=n;t++)
		scanf("%d",&a[t]);
	for( j=1;j<=n;j++)
		for(k=j+1;k<=n;k++)
			sum+=a[j]*a[k];
	printf("%d",sum);

	return 0;
}

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

#define     ll          long long
#define     ld          long double
#define     sz(s)       s.size()
#define     pb          push_back
#define     ff          first
#define     ss          second
#define     mk          make_pair
#define     pii         pair<int, int>
#define     pll         pair<long long int, long long int>
#define     ALL(s)      (s).begin(), (s).end()
#define     rALL(s)     (s).rbegin(), (s).rend()
#define     fast        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     show(x)     cout << #x << " : "<< x << endl;
#define     f0(n)       for(int i=0; i<n; i++)
#define     f1(n)       for(int i=1; i<=n; i++)
#define     vi(v,n)     for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define     vll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define     M           100005
#define     limit       -pow(2, 32)
#define     pi          acos(-1)
#define     fuck        return 0;

using namespace std;




int main()
{
   int k, n, m;
   cin >>k >>n >>m;
   bool is = false;
   for(int i=n; i<=m; i++)
   {
       if(i%k==0){
        is = true;
       }
   }

   cout << (is?"OK":"NG") << endl;
}


Measured memory_bytes: 3620
line = list(map(int, input().split(" ")))
ans = 0
digitsum = 0
for i in range(1, line[0]+1):
    digitsum = i % 10 + (i // 10) % 10 + (i // 100) % 10 + (i // 1000) % 10 + (i // 10000)
    ans += i if line[1] <= digitsum <= line[2] else 0
print(ans)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	n := scanInt(sc)
	var last byte
	used := make(map[string]struct{}, n)
	for i := 0; i < n; i++ {
		w := scanString(sc)
		if _, ok := used[w]; ok {
			fmt.Println("No")
			return
		}
		used[w] = struct{}{}
		if i > 0 {
			if last != w[0] {
				fmt.Println("No")
				return
			}
		}
		last = w[len(w)-1]
	}
	fmt.Println("Yes")
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int maxN= 50;
const ll INF =ll(1e18)+5;
ll dp[maxN][maxN][maxN];
ll V[maxN];
ll N,K;

ll dfs(int l,int r,int stay){
    if(l>N-1-r || l+r+stay ==K){
        //  cerr <<"l="<<l <<"r="<<r <<"stay=" << stay << ", 0 value"  << endl;
        return 0;
    }
    if(l +r + stay>K){
        return -INF;
    }
   
    if(dp[l][r][stay] != -1){
        return dp[l][r][stay];
    }
    ll temp;
    temp = max(dfs(l+1,r,stay) + V[l],dfs(l,r+1,stay) + V[N-1-r]);
    if(l+r+stay+1<K){
        temp = max(temp,dfs(l+1,r,stay+1));
        temp = max(temp,dfs(l,r+1,stay+1));
    }
    temp = max(temp,0LL);
    dp[l][r][stay] =temp;
    // cerr <<"l="<<l <<"r="<<r <<"stay=" << stay << "val=" << dp[l][r][stay] << endl;
    return dp[l][r][stay];
}

int main() {
    cin >> N >>K;
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    memset(dp,-1,sizeof(dp));
    dfs(0,0,0);
    cout << dp[0][0][0] << endl;
    return 0;
}

Measured memory_bytes: 4616
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
 
 
def display(x, y):
    sx = chr(ord('A') + x)
    sy = str(y + 1)
    print("{}{}".format(sx, sy))
 
def main():
    H, W = map(int, input().split())
 
    for y in range(H):
        row = input().split()
        for x in range(W):
            if row[x] == "snuke":
                display(x, y)
                return
 
if __name__ == "__main__": main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
ll power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
const int MX=5e5+5;
vector<vector<int>>BIT(MX,vector<int>(26));
int n; 
string s;
void update(int x, int d, int p){
      for(;x<=n;x+=x&-x)
	      BIT[x][d]+=p;
}
vector<int> query(int x){
	 vector<int>ans(26);	
     for(;x>0;x-=x&-x){
		 for(int i=0;i<26;i++)
			ans[i]+=BIT[x][i];
	 }
     return ans;
}

void solve(){
	cin>>n;
	cin>>s;
	for (int i=1;i<=n;i++){
		update(i,s[i-1]-'a',1);
	}
	int q;
	cin>>q;
	while(q--){
		int t,l,r,cnt=0;
		cin>>t>>l;
		if(t==1){
			char c;
			cin>>c;
			if(s[l-1]!=c){
				update(l,c-'a',1);
				update(l,s[l-1]-'a',-1);
				s[l-1]=c;
			}
		}
		else{
			cin>>r;
			vector<int>v1,v2;
			v1=query(l-1);
			v2=query(r);
			for(int i=0;i<26;i++){
				v2[i]-=v1[i];
				if(v2[i])
					cnt++;
			}
			cout<<cnt<<endl;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--)
		solve();
}


Measured memory_bytes: 70264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int N;
        double M,SUM;
 
        try {
            while((N = Integer.parseInt(br.readLine())) != 0){
 
                String input[] = br.readLine().split("\\s+");
                double array[] = new double[input.length];
 
                SUM = 0;
 
                for(int i = 0; i < input.length; i++){
                    array[i] = Double.parseDouble(input[i]);
                    SUM += array[i];
                }
 
                M = SUM/(double)N;
                SUM = 0;
 
                for(int i = 0; i < array.length; i++){
                    SUM += (array[i]-M)*(array[i]-M);
                }
 
                System.out.printf("%.10f\n", Math.sqrt(SUM/(double)N));
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 27916
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef unsigned long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a; cin>>a;
    long double b; cin>>b;
    long double c=(a*b);
    cout<<(ll)c<<endl;
    
    
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[100005];

template<typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    SegmentTree(F func, T id)
            : merge(func), identity(id) {}

    void init(ll n) {
        offset = 1;
        while (offset < n)
            offset <<= 1;
        node.assign(offset << 1, identity);
    }

    void build(const vector<T> &v) {
        int n = static_cast<int>(v.size());
        init(n);
        for (int i = 0; i < n; ++i) {
            node[offset + i] = v[i];
        }
        for (int i = offset - 1; i >= 0; --i) {
            node[i] = merge(node[(1 << i) | 0], node[(1 << i) | 1]);
        }
    }

    void set(int index, T value) {
        index += offset;
        node[index] = value;
        while (index >>= 1) {
            node[index] = merge(node[(index << 1) | 0], node[(index << 1) | 1]);
        }
    }

    //! [left, right]
    T get(int left, int right) {
        left += offset;
        right += offset + 1;

        T val = identity;
        while (left < right) {
            if (left & 1)
                val = merge(val, node[left++]);
            if (right & 1)
                val = merge(val, node[--right]);

            left >>= 1;
            right >>= 1;
        }
        return val;
    }

    T identity;
    F merge;
    vector<T> node;
    int offset;
};

int main() {
    ll N;
    cin >> N;
    vector<ll> v;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
        v.push_back(A[i].first + A[i].second);
    }
    v.push_back(-INF);
    v.push_back(INF);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    sort(A, A + N, [](pll a, pll b) { return a.first < b.first; });

    SegmentTree<ll> seg([](ll a, ll b) { return std::max(a, b); }, 0);
    seg.init(v.size());

    ll ans = 0;
    vector<ll> dp(v.size(), 0);
    REP(i, N) {
        ll ri = lower_bound(v.begin(), v.end(), A[i].first + A[i].second) - v.begin();
        ll x = A[i].first - A[i].second;
#if true
        ll li = 0, ng = v.size();
        while (abs(li - ng) > 1) {
            ll mid = (li + ng) / 2;
            if (v[mid] <= x)
                li = mid;
            else
                ng = mid;
        }
#endif
        //      ll li = lower_bound(v.begin(), v.end(), x) - v.begin();
        ll m = seg.get(0, li) + 1;
        ans = std::max(ans, m);
        // dp[ri] = std::max(dp[ri], m);
        seg.set(ri, std::max(m, seg.get(ri, ri)));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5492
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a = 1
    m = 10**18
    A.sort()
    for i in A:
        a *= i
        if a > 10**18:
            return -1
        elif a == 0:
            return 0
    return a
print(main())


Measured memory_bytes: 84668
#include<bits/stdc++.h>
using namespace std;
const int N=1001000;
int a[N],n,cnt[4],le[N],ri[N];
char s[N];
vector<int>del,vec[4],ans;

void erase(int x){cnt[a[x]]--;ri[le[x]]=ri[x];le[ri[x]]=le[x];}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>(s+1);
	for(int i=1;s[i];++i)if(s[i]!=s[i-1])a[++n]=s[i]-'A'+1,cnt[a[n]]++;
	int u=3;if(cnt[1]>cnt[u])u=1;if(cnt[2]>cnt[u])u=2;
	for(int i=1;i<=n;++i)if(a[i]==u){
		if(i!=1&&i!=n&&a[i-1]==a[i+1])vec[a[i-1]].push_back(i);
		else del.push_back(i);
	}
	for(int i=1;i<=n;++i)le[i]=i-1,ri[i]=i+1;le[n+1]=n;ri[0]=1;
	int v=1,w=2;if(v==u)v=3;if(w==u)w=3;
	if(cnt[v]>cnt[w])swap(v,w);
	while(cnt[u]>cnt[w]){
		if(!del.empty())erase(del.back()),del.pop_back();
		else erase(vec[w].back()),erase(ri[vec[w].back()]),vec[w].pop_back();		
		if(cnt[v]>cnt[w])swap(v,w);
	}
	for(int i=ri[0];i<=n;i=ri[i]){
		if(!ans.empty()&&((ans.back()==u&&a[i]==w)||(ans.back()==w&&a[i]==u))&&cnt[u]>cnt[v]&&(ans.size()==1||ri[i]>n||ans[ans.size()-2]!=a[ri[i]]))ans.pop_back(),--cnt[u];
		else ans.push_back(a[i]);
	}
	assert(cnt[u]==cnt[v]);
	for(int i:ans)cout<<char('A'+i-1);
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 20464
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N;
	string S, T, ans;
	cin >> N >> S >> T;
	rep(i, N)
	{
		cout << S[i] << T[i];
	}
	return 0;
}


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    int cc = 0;

    while(b <= a)
    {
        b*=2;
        cc++;
    }
    while(c <= b)
    {
        c*=2;
        cc++;
    }
    if(cc > k)
        cout << "No\n";
    else
        cout << "Yes\n";


    return 0;
}


Measured memory_bytes: 3644
A,B = map(int,input().split())
ak = []
bk = []
for k in range(-int((-A/0.08)//1),-int(-(A/0.08+12.5)//1)):
  ak.append(k)
for k in range(-int((-B/0.10)//1),-int(-(B/0.10+10.0)//1)):
  bk.append(k)
ans = min(set(ak) & set(bk)) if len(set(ak) & set(bk)) > 0 else -1
print(ans)


Measured memory_bytes: 3064
h,w=map(int,input().split())
s=[input() for i in range(h)]
v=[(-1,0),(1,0),(0,-1),(0,1)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            ans=True
            for k in v:
                if 0<=i+k[0]<h and 0<=j+k[1]<w and s[i+k[0]][j+k[1]]=="#":
                    ans=False
                    break
            if ans:
                #print(i,j)
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
import Control.Applicative

import Control.Monad
    (when)

type Problem = (Int, Int)

type Result = [String]

solve :: Problem -> Result

solve (h, w)
    = [line] ++ replicate (h - 2) hole ++ [line] where
        line = replicate w '#'
        hole = "#" ++ replicate (w - 2) '.' ++ "#"

input :: IO Problem

input
    = do
        [h, w] <- map read.words <$> getLine
        return (h, w)

output :: Result -> IO ()

output xs
    = putStrLn $ concat [x ++ "\n" | x <- xs]
    
main :: IO ()

main
    = do
        xs <- input
        when (xs /= (0, 0)) $ do
            output $ solve xs
            main

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

using namespace std;

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

	int H, W, N;
	cin >> H >> W >> N;

	vector<pair<int, int>> dots;
	dots.reserve(N*9);

	for (int i=0 ; i<N ; i++)
	{
		int h, w;
		cin >> h >> w;

		for (int dh=-1 ; dh<=1 ; dh++)
		{
			for (int dw=-1 ; dw<=1 ; dw++)
			{
				int th=h+dh, tw=w+dw;
				if (th>=2 && tw>=2 && th<H && tw<W)
				{
					dots.emplace_back(tw, th);
				}
			}
		}
	}

	std::sort(dots.begin(), dots.end());

	vector<int> sum(11, 0);

	pair<int, int> cmp = make_pair(-1, -1);
	int count = 10;

	for (pair<int, int>& dot : dots)
	{
		if (dot == cmp)
		{
			count++;
		}
		else
		{
			sum[count]++;

			cmp = dot;
			count = 1;
		}
	}
	sum[count]++;

	uint64_t empty = 1;
	empty *= W - 2;
	empty *= H - 2;
	for (int i=1 ; i<=9 ; i++)
	{
		empty -= sum[i];
	}

	cout << empty << "\n";

	for (int i=1 ; i<=9 ; i++)
	{
		cout << sum[i] << "\n";
	}
}


Measured memory_bytes: 7296
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const int MOD = 998244353;
const int INF = 1000000010;

int n;
string s[MAXN];

int main()
{
	
	cin >> n;
	set<string> a;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> s[i];
		a.insert(s[i]);
	}
	int flag = 0;
	if (a.size() != n) flag = 1;
	for (int i = 1; i < n; ++ i)
		if (s[i][s[i].size()-1] != s[i+1][0]) flag = 1;
	puts(flag ? "No" : "Yes");
	
	return 0;
}


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

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

        while(true){
            int n = Integer.parseInt(br.readLine());

            if(n == 0){
                break;
            }

            long[] input = new long[n];
            for(int i = 0; i < n; i++){
                input[i] = Long.parseLong(br.readLine());
            }

            SubArray subArray = new SubArray(input, 0, input.length - 1);

            System.out.println(maxSubarray(subArray));
        }
    }

    static long maxSubarray(SubArray input){
        int left = input.left;
        int right = input.right;
        long maxSum = input.array[input.left];

        for(int i = input.left ; i <= input.right ;i++){
            int sum = 0;

            for(int j = i; j <= input.right; j++){
                sum += input.array[j];

                if(maxSum < sum){
                    left = i;
                    right = j;
                    maxSum = sum;
                }
            }
        }

        input.left = left;
        input.right = right;

        return maxSum;
    }
}

class SubArray {
    long[] array;
    int left;
    int right;

    public SubArray (long[] array, int left, int right){
        this.array = array;
        this.left = left;
        this.right = right;
    }
}


Measured memory_bytes: 25116
S = input()
S = S[::-1]
words = ['dream','dreamer','erase','eraser']

i = 0
while i < len(S):
    for word in words:
        if S[i:].startswith(word[::-1]):
            i += len(word)
            break
    else:
        print('NO')
        exit()
print('YES')

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

using namespace std;

string s[200005], an[1000005];
map<string, int> mp;

int main(){
	int n, ans = 0, cnt = 0 ; cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> s[i];
		++mp[s[i]];
		ans = max(ans, mp[s[i]]);
	}
	for(int i = 1; i <= n; ++i)
		if(mp[s[i]] == ans){
			--mp[s[i]]; an[++cnt] = s[i];
		}
	sort(an + 1, an + 1 + cnt);
	for(int i = 1; i <= cnt; ++i)
		cout << an[i] << endl;
	return 0;
}

Measured memory_bytes: 34560
n = int(input())
p = [int(x) for x in input().split(' ')]

s = p.copy()
s.sort()
cnt = 0

for a in range(n) :
    if(p[a] != s[a]) :
        cnt += 1


if (cnt > 2) :
    print('NO')
else : 
    print('YES')


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

void fnInput(vector<int>& rvnNum)
{
  for (int& rnElm : rvnNum)
    cin >> rnElm;
}

int fnSameIntTimes(const vector<int>& cnrvnNum)
{
  auto itMaxNum = max_element(begin(cnrvnNum), end(cnrvnNum));

  int  nSum = 0;
  for (int nElm : cnrvnNum)
    nSum += nElm;

  int nSameIntTimes;
  if (*itMaxNum * 3 % 2 == nSum % 2)                 // ３数の最大値×３と３数の和のパリティが等しい
    nSameIntTimes = (*itMaxNum * 3 - nSum) / 2;        // ３数の最大値が３数が等しくなる数
  else                                               //  上記以外
    nSameIntTimes = ((*itMaxNum + 1) * 3 - nSum) / 2;  // ３数の最大値＋１が３数の等しくなる数

  return nSameIntTimes;
}

int main()
{
  vector<int> vnNum(3);

  fnInput(vnNum);
  cout << fnSameIntTimes(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,i,j,k;
    bool flag;
    flag=false;
    cin >> N;
    for (i=1;i<=9;i++){
        for (j=1;j<=9;j++){
            if(i*j==N){
                flag=true;
            }
        }
    }
    
    if (flag==true){
        cout << "Yes" <<endl;
        
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a,b,h;
void input(){
    fast_io();
    cin >> a >> b >> h;
}

int solve(){
    cout << (a+b)*h/2 << endl;
    return 0;
}   

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <sstream>

#include <array>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>

#include <algorithm>
#include <numeric>

#include <cstdint>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>
#include <chrono>
#include <climits>
#include <fstream>
#include <ios>

#include <iterator>
#include <utility>
#include <complex>
#include <memory>

using namespace std;

//#define MY_DEBUG

#define DESYNC_IO


#ifdef MY_DEBUG
#define DEBUG_STDERR(x) cerr << x << endl;
#else
#define DEBUG_STDERR(x)
#endif // MY_DEBUG


void Solve() {
    int a, b;
    cin >> a >> b;
    cout << a + b / 2;
}

void Run() {
#ifdef MY_DEBUG
    chrono::high_resolution_clock::time_point start{ chrono::high_resolution_clock::now() };
#endif // MY_DEBUG

#ifdef DESYNC_IO
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif // DESYNC_IO

#ifdef MY_DEBUG
    ifstream input{ "input.txt" };
    cin.rdbuf(input.rdbuf());
#endif // MY_DEBUG

    Solve();

#ifdef MY_DEBUG
    auto dt{ std::chrono::high_resolution_clock::now() - start };
    auto dt_millisec{ std::chrono::duration_cast<std::chrono::milliseconds>(dt) };
#endif // MY_DEBUG
    DEBUG_STDERR("\ntime spent: " << dt_millisec.count() << " miilliseconds");
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int n;

signed main()
{
    cin >> n;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    bool any = false;
    rep(i, n) {
        rep(j, n) {
            any |= (s[i][j] == '#');
        }
    }
    if (!any) {
        cout << "-1" << endl;
        return 0;
    }
    int cnt[n], blk[n];
    memset(cnt, 0, sizeof(cnt));
    memset(blk, 0, sizeof(blk));
    rep(i, n) {
        rep(j, n) {
            if (s[i][j] == '.') { 
                cnt[i]++;
            } else {
                blk[j]++;
            }
        }
    }
    int ans = (int) 1e9;
    rep(i, n) {
        if (blk[i]) {
            ans = min(ans, cnt[i]);
        } else {
            ans = min(ans, cnt[i]+1);
        }
    }
    int nn = 0;
    rep(i, n) {
        if (blk[i] != n) {
            nn++;
        }
    }
    cout << ans + nn << endl;
    return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
mod=10**9+7
A=[1]*(n+1)
for i in range(m):
  A[int(input())]=0
B=[1]*(n+1)
if A[1]==0:
  B[1]=0
for i in range(2,n+1):
  B[i]=A[i]*(B[i-1]+B[i-2])%mod
print(B[n])

Measured memory_bytes: 7668
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n:i64 = read();
    let k:i64 = read();
    let pl:i64 = n%k;
    let pm:i64 = k-pl;
    if pl < pm{
	println!("{}",pl);
    }else{
	println!("{}",pm);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int tr[1100][2]={0},dp[1100][1100]={0};
int main(){
  for(int c=1;;c++){
    int w,n,ans = 0,q;
    cin >>w;
    if(w == 0) break;
    cin >>n;
    for(int i=0; i<1100; i++){
      tr[i][0] = tr[i][1] = 0;
      for(int j=0; j<1100; j++) dp[i][j] = 0;
    }
    for(int i=1; i<=n; i++) scanf("%d,%d",&tr[i][0],&tr[i][1]);
    for(int i=1; i<=n; i++){
      for(int j=0; j<=w; j++){
	if(j == 0) dp[i][tr[i][1]] = max(dp[i][tr[i][1]],tr[i][0]);
	if(dp[i-1][j]!=0){
	  if(j+tr[i][1]<=w) dp[i][j+tr[i][1]] = max(dp[i][j+tr[i][1]],dp[i-1][j]+tr[i][0]);
	  dp[i][j] = max(dp[i][j],dp[i-1][j]);
	}
      }
    }
    for(int i=0; i<=w; i++){
      if(ans<dp[n][i]){
	ans = dp[n][i];
	q = i;
      }
    }
    cout <<"Case "<<c<<":"<<endl<<ans<<endl<<q<<endl;
  }
  return 0;
}

Measured memory_bytes: 5980
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	long x;
	long ans[300001];
	int i, j;
	int tmp;
	
	sl(N); sl(x);
	for(i=1;i<2*N;i++) ans[i] = i;
	
	if(x == 1 || x == 2 * N - 1) {
		printf("No\n");
		return 0;
	}
	
	printf("Yes\n");
	if(x == N - 1) {
		ans[N-2] = N;
		ans[N] = N-2;
	} else if(x == N + 1) {
		ans[N+2] = N;
		ans[N] = N+2;
	} else if(x < N) {
		ans[x-1] = N-1;
		ans[x] = N;
		ans[N-1] = x-1;
		ans[N] = x;
	} else {
		ans[x] = N;
		ans[x+1] = N+1;
		ans[N] = x;
		ans[N+1] = x+1;
	}
	
	for(i=1;i<2*N;i++) pl(ans[i]);
	
	return 0;
}

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

int main() {
 int A,B,C;
  cin >> A >> B >> C;
  if(A == B && B == C){
    cout << 1 << endl;
  }
  else if(A == B|| B == C|| A == C){
  cout << 2 << endl;
  }
else{
  cout << 3 << endl;
}
}


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

int main(){
  
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
  
  int A = d.at(N/2-1);
  int B = d.at(N/2);
  
  cout << B - A << endl;
  
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int co=1;
  vector<bool> ans(0);
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  while(n!=0){
    if(n%2!=0){
      ans.push_back(true);
      n-=co;
    }
    else
      ans.push_back(false);
    n/=-2;
    //cout << n << endl;
  }
  for(int i=ans.size()-1;i>-1;i--){
    if(ans[i])
      cout << 1;
    else
      cout << 0;
  }
  cout << endl;
}


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

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
  Z = X*Y/2;
    cout << Z << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC"){
            ac++;
        }else if(s=="WA"){
            wa++;
        }else if(s=="TLE"){
            tle++;
        }else if(s=="RE"){
            re++;
        }
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
    return(0);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        cout<<s[i];
    }
    cout<<" ";
    for(int j=4;j<12;j++){
        cout<<s[j];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  if (n == 1) return cout << "Hello World" << '\n', 0;
  int a, b; cin >> a >> b;
  cout << a + b << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
void YES(bool che){
    if(che)cout<<"YES\n";
    else cout<<"NO\n";
}
void Yes(bool che){
    if(che)cout<<"Yes\n";
    else cout<<"No\n";
}
set<char>x;
int n,a;
int main(void){
   cin>>n;
   for(int i=0;i<n;i++){
       char c;
       cin>>c;
       if(x.find(c)==x.end())a++;
       x.insert(c);
   }
    if(a==3)cout<<"Three\n";
    else cout<<"Four\n";
}


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

int main() {
  string SA, SB, SC;
  cin >> SA >> SB >>SC;
  
  string Turn = "a";
  
  for ( int i = 0; i < 300 ; i++ ){
    if (Turn == "a"){
      if (SA.size() == 0){
        break;
      }
      Turn = SA.at(0);
      SA.erase(0, 1);
    }
    else if (Turn == "b"){
      if (SB.size() == 0){
        break;
      }
      Turn = SB.at(0);
      SB.erase(0, 1);
    }
    else if (Turn == "c"){
      if (SC.size() == 0){
        break;
      }
      Turn = SC.at(0);
      SC.erase(0, 1);
    }
  }
  
  if ( Turn == "a" ){
    cout << "A" ;
  }
  else if (Turn == "b" ){
    cout << "B" ;
  }
  else if ( Turn == "c" ){
    cout << "C" ;
  }
}


Measured memory_bytes: 256
K,A,B = map(int,input().split())
K += 1
if K >= A + 1 and A + 2 < B:
  ans = int((K - A) / 2) * (B - A) + A + (1 if (K - A) % 2 == 1 else 0)
  print(ans)
else:
  ans = K
  print(ans)

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

using namespace std; 

int main(){
  
  string s;
  cin>>s;
  
  int cnt=0;

  for(int i=0; i<s.size(); i++){
    if(s[i]=='R'){
      cnt++;
    }
  }

  if(cnt==2 and s[1]=='S'){
    cnt=1;
  }

  cout<<cnt<<endl;

}


Measured memory_bytes: 3620