akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a = Integer.parseInt(scanner.next());
    int b = Integer.parseInt(scanner.next());
    int c = Integer.parseInt(scanner.next());
    
    if(a > c){
     System.out.println("NO"); 
    }
    else if (a + b < c){
      System.out.println("NO");
    }
    else{
      System.out.println("YES");
    }
    scanner.close();
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(j=a;j>=b;j--)
#define vi vector<int>
#define pi 3.14159265358979323846
using namespace std;

void koch(int n, pair<double,double> a, pair<double,double> b);
int main(){
	int n,i,j;
	cin>>n;
	pair<double,double> a(0,0),b(100,0);
	printf("%.8lf %.8lf\n",a.first,a.second);
	koch(n,a,b);
	printf("%.8lf %.8lf\n",b.first,b.second);
}

void koch(int n, pair<double,double> a, pair<double,double> b){
	if(n==0){
		return;
	}
	double th=M_PI/3.0;
	pair<double,double> s((2*a.first+b.first)/3.0,(2*a.second+b.second)/3.0);
	pair<double,double> t((a.first+2*b.first)/3.0,(a.second+2*b.second)/3.0);
	pair<double,double> u((t.first-s.first)*cos(th)-(t.second-s.second)*sin(th)+s.first,(t.first-s.first)*sin(th)+(t.second-s.second)*cos(th)+s.second);
	koch(n-1,a,s);
	printf("%.8lf %.8lf\n",s.first,s.second);
	koch(n-1,s,u);
	printf("%.8lf %.8lf\n",u.first,u.second);
	koch(n-1,u,t);
	printf("%.8lf %.8lf\n",t.first,t.second);
	koch(n-1,t,b);
}

Measured memory_bytes: 3228
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["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"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    l, r, d = [int(x) for x in stdin.readline().rstrip().split()]
    print(r//d - (l-1)//d)
main()

Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (a < c && c < b) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<map>
using namespace std;
int main()
{
    int n;
    int minn=1e9;
    int num;
    int sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        if(num<minn)
        {
            minn=num;
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
A = []
for si in s:
  if si == "#":
    A.append(1)
  else:
    A.append(0)
for i in range(1, len(A)):
  A[i] += A[i-1]

ans = n - A[n-1]
for i in range(n):
  b2w = A[i]
  w2b = n - i - 1 - (A[n-1] - A[i])
  if ans > b2w + w2b:
    ans = b2w + w2b

print(ans)



Measured memory_bytes: 88288
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  map<string, int> mp;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    mp[S]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  string ret = "APPROVED";
  rep(i, N) {
    if (c[i] % 2 == 0) {
      if (c[i] % 3 != 0 && c[i] % 5 != 0) {
        ret = "DENIED";
      }
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,l,s=0,p,k,r=1,m,t,j,i;
cin>>n>>k;
if(k<22)
cout<<0;
else{
    for(i=1;i<=n;i++){
        for(j=22;j<=k;j++){r=j;
            m=r%10;
            r=r/10;
            t=r%10;
            if(m*t==i&&m>=2&&t>=2){
            s++;}
        }
    }cout<<s;
}


    return 0;
}


Measured memory_bytes: 256
class Car
  num = 1
  
  define_method(:initialize) do |time|
    @num = num
    num += 1
    @time = time
  end
  attr_accessor :num, :time
  
  define_singleton_method(:clear) {num = 1}
end

class ParkingLot
  Space = Struct.new(:upper, :lower)
  
  def initialize(num)
    @spaces = num.times.map {|i| Space.new}
  end
  
  def add_car(waiting_time)
    idx = @spaces.index {|sp| sp.lower.nil?}
    if idx
      @spaces[idx].lower = Car.new(waiting_time)   #下のスペースが空いている
    else
      return false if @spaces.all?(&:upper)        #満車
      
      #下は空いていないが満車でない場合
      idxs = @spaces.map.with_index {|sp, i| i unless sp.upper}.compact
      idx = idxs.map do |i|
        diff = @spaces[i].lower.time - waiting_time
        diff >= 0 ? [diff, i] : nil
      end.compact.sort.first&.last
      unless idx
        idx = idxs.map {|i| [waiting_time - @spaces[i].lower.time, i]}.sort.first.last
      end
      
      @spaces[idx].upper = @spaces[idx].lower.dup
      @spaces[idx].lower = Car.new(waiting_time)
    end
    true
  end
  
  def next
    @spaces.each do |sp|
      if sp.lower
        sp.lower.time -= 1
        sp.upper.time -= 1 if sp.upper
      end
    end
    
    result = []
    @spaces.each do |sp|
      if sp.lower and sp.lower.time <= 0
        result << sp.lower.num
        sp.lower = sp.upper.dup
        sp.upper = nil
      end
    end
    @spaces.each do |sp|
      if sp.lower and sp.lower.time <= 0
        result << sp.lower.num
        sp.lower = nil
      end
    end
    
    result
  end
  
  #車庫が空か
  def empty?
    @spaces.all? {|sp| sp.lower.nil?}
  end
end


until (given = gets.split.map(&:to_i)) == [0, 0]
  m, n = given
  parking_time = n.times.map {gets.to_i}
  pl = ParkingLot.new(m)
  result = []
  wait = []
  Car.clear
  t = 0
  
  loop do
    result += pl.next
    
    wait << parking_time.shift if (t % 10).zero?
    t += 1
    while (waiting = wait.shift)
      unless pl.add_car(waiting)
        wait.unshift(waiting)    #満車の場合
        break
      end
    end
    
    break if pl.empty?
  end
  
  puts result.join(" ")
end


Measured memory_bytes: 6880
#include <stdio.h>

int main(void)
{
	char ch[6];
	scanf("%s", ch);
	int count = 0;
	for(int i = 1;ch[i] != '\0'; i++)
	{
		if (ch[i-1] == 'A' && ch[i] == 'C')
		{
			count++;
		}
	}
	if (count >= 1)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
const int inf = 1e9 + 1;
using namespace std;
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
   // freopen("input.txt", "r", stdin);
    cout << setprecision(20);
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9){
        cout<<a*b;
    } else {
        cout<<"-1";
    }
    //    int n;
//    ll k;
//    cin >> n >> k;
//    vector<ll> a(n);
//    for (int i = 0; i < n; i++) {
//        cin >> a[i];
//    }
//    vector<ll> b(n);
//    for (int j = 0; j < n; j++) {
//        cin >> b[j];
//    }
//    sort(a.begin(), a.end());
//    sort(b.begin(), b.end());
//    ll ans = 0;
//
////    for (int i = 0; i < n; i++) {
////        cout << a[i] << " ";
////    }
////    cout << endl;
////    for (int j = 0; j < n; j++) {
////        cout << b[j] << " ";
////    }
////    cout << endl;
//    set<pair<ll,int>> x;
//    for (int i = 0; i < n; i++) {
//        if (k >= a[i]) {
//            k -= a[i];
//        } else {
//            ans += (a[i] - k) * b[n - 1 - i];
//            k = 0;
//        }
//        cout << ans << " ";
//    }
//    cout << ans;
    return 0;
}


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

const int MAX_N = 100000;
vector<int> G[MAX_N];
bool used[MAX_N];

const int p = 1000000007;

long long dfs(int v, int k, int ancestor, int sibling) {
	long long ans = k - ancestor - sibling;
	used[v] = true;
	ancestor++;
	if(ancestor > 2) ancestor = 2;
	sibling = 0;
	for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) {
		long long r = dfs(G[v][i], k, ancestor, sibling);
		sibling++;
		ans = (ans * r) % p;
	}
	return ans;
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i=0;i<n-1;i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<n;i++) used[i] = false;
	printf("%lld\n", dfs(0, k, 0, 0));
	return 0;
}


Measured memory_bytes: 11648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int dp[100010];

    int main(){
      int n,k;
      cin >> n >> k;
      int h[n];
      rep(i,n)cin >> h[i];
      for(int i=1;i<=k-1;i++){
        dp[i]=abs(h[0]-h[i]);
       for(int j=1;j<=i-1;j++){
        dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i])); 
       }
      }
      for(int i=0;i<=n-k-1;i++){
        dp[i+k]=inf;
        for(int j=1;j<=k;j++){
          dp[i+k]=min(dp[i+k],dp[i+k-j]+abs(h[i+k]-h[i+k-j]));
        }
      }
      cout << dp[n-1] << endl;
      return 0;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n,x);
	VEC(int,a,n);

	sort(ALL(a));
	int ans = 0;
	REP(i,n){
		x -= a[i];
		if(x<0) break;
		if(i==n-1 && x!=0) break;
		++ans;
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int a, b, c, min, max;
    scanf("%d%d%d", &a, &b, &c);
    if (a <= b && a <= c) min = a;
    else if (b <= c && b <= a) min = b;
    else min = c;
    if (a >= b && a >= c) max = a;
    else if (b >= c && b >= a) max = b;
    else max = c;
    printf("%d %d\n", min, max);
    return 0;
}


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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count = 0;
  int sum = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0;j <= B; j++){
      for(int k = 0;k <= C; k++){
        sum = 500*i + 100*j + 50*k;
        if(sum == X){
          count++;
        }
      }
    }
  }
  cout << count;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll N;
int main()
{
    cin >> N;
    N--;
    if(N == 0)
    {
        cout << 'a' << endl;
        return 0;
    }
    string ans = "";
    while(N >= 0)
    {
        char c = (N % 26) + 'a';
        string s(1, c);
        ans += c;
        N /= 26;
        N--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	if(a > b) swap(a,b);
	ll c = 0;
	for(ll i = a; i >= 1; i--){
		if(a%i == 0 && b%i == 0) ++c;
		if(c == k) {cout<<i<<"\n"; return 0;}
	}
	return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define Graph vector<vector<int>>
#define INF 1001001001

int masu[50][50];


int main() {
  
  int H,W;
  cin >> H >> W;

  int white = 0; //白いマス目の数

  rep(i,H){
    rep(j,W){
      char a;
      cin >> a;
      if( a == '.'){
        masu[i][j]=1;
        white++;
      }
      else masu[i][j]=0;    
    }
  }

  //最短距離を求める
  int gx = W-1, gy = H-1;


  vector<vector<int>> dist(50, vector<int>(50, -1));
  queue< pair<int,int> > que;

  vector<int> dx = { 0, 1, 0, -1 };
  vector<int> dy = { 1, 0, -1, 0 };

  dist.at(0).at(0) = 1;
  que.push( make_pair(0,0) ); 

  while( !que.empty() ){
        pair<int,int> v = que.front();
        que.pop();
        int x = v.first;
        int y = v.second;

        // v から辿れる頂点をすべて調べる
        rep(i,4) {
            int nv_x = x;
            int nv_y = y;
            nv_x += dx[i];
            nv_y += dy[i];

            //通れるか？
            if( nv_x < 0 || nv_x >= W ) continue; // すでに発見済みの頂点は探索しない
            if( nv_y < 0 || nv_y >= H ) continue;
            if( masu[nv_y][nv_x] == 0 ) continue;
                            
            //もう通っているか？
            if( dist[nv_y][nv_x] != -1 ||  nv_x == 0 && nv_y == 0 ) continue;
            if(dist[gy][gx] != -1) break;

       
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            que.push( make_pair(nv_x,nv_y) );
            dist[nv_y][nv_x] = dist[y][x] + 1;

        }
}
  
  if( dist[gy][gx] != -1 ) {
    printf("%d\n", white - dist[gy][gx]  );
    return 0;
  }
  
  
  cout << -1 << endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());

			int[] x = new int[a];
			for (int j = 0; j < a; j++) {
				x[j] = Integer.parseInt(sc.next());

			}
			int[] y = new int[a - 1];
			for (int j = 0; j < y.length; j++) {
				y[j] = x[j + 1] - x[j];
			}
			Arrays.sort(y);
			if (b > y.length) {
				System.out.println(0);
			} else {
				int sum = 0;
				for (int j = 0; j < y.length - b + 1; j++) {
					sum += y[j];
				}
				System.out.println(sum);
			}
		}
	}
}

Measured memory_bytes: 74220
S=input()
N=len(S)

ans=2**(N-1)*int(S[-1])
for i in range(1<<(N-1)):
    res=1
    for j in range(N-1):
        if (i>>j)%2==1:
            res*=10
        else:
            res=1
        ans+=res*int(S[N-2-j])
print(ans)


Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long n,k;
	cin >> n >> k;
	if(n>k)n=n%k;
	long long mn=n;
	for(int i=0;i<4;i++)
	{
		n=k-n;
		if(n<0)n*=(-1);
		if(n<mn)mn=n;
	}

	cout << mn << endl;



}


Measured memory_bytes: 256
package main

import "fmt"
import "strings"

func main() {
	var (
		num  int
		str1 string
		str2 string
	)

	ans := []string{}

	fmt.Scanf("%d", &num)
	fmt.Scanf("%s %s", &str1, &str2)

	for i := 0; i < num; i++ {
		ans = append(ans, str1[i:i+1])
		ans = append(ans, str2[i:i+1])
	}

	var ans_fmt string;
	ans_fmt = strings.Join(ans, "")

	fmt.Printf("%s", ans_fmt)
}


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

using ll = long long int;
using P = std::pair<int, int>;

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

constexpr ll mod = 1e9 + 7;

int getDig(char ch)
{
    return atoi(&ch);
}

int main()
{
    std::string s;

    std::cin >> s;

    std::reverse(std::begin(s), std::end(s));

    std::vector<std::vector<ll>> dp(s.size(), std::vector<ll>(13));

    if (s[0] == '?')
    {
        rep(i, 10)
        {
            dp[0][i] = 1;
        }
    }
    else
    {
        dp[0][getDig(s[0])] = 1;
    }

    int x = 10;

    for (int i = 1; i < s.size(); ++i)
    {
        for (int j = 0; j < 13; ++j)
        {
            if (s[i] == '?')
            {
                for (int k = 0; k < 10; ++k)
                {
                    int prev = (j - k * x + 117) % 13;
                    dp[i][j] += dp[i - 1][prev];
                }
                dp[i][j] %= mod;
            }
            else
            {
                int prev = (j - getDig(s[i]) * x + 117) % 13;

                dp[i][j] = dp[i - 1][prev];
            }
        }
        x = x * 10 % 13;
    }

    //std::cerr << "DEBUG:" << s << std::endl;

    std::cout << dp[s.size() - 1][5] << std ::endl;

    return 0;
}

Measured memory_bytes: 13696
const input = require("fs").readFileSync("/dev/stdin", "utf8").split(/\s+/).filter(x=>x.length);
var h = +input.shift();
var w = +input.shift();
var a = [...Array(h)].map(() => Array(w));
input.forEach((x, i) => a[i / w | 0][i % w] = +x);
var i = 0, j = 0, ip, jp;
var result = "";
var N = 0;
while (true) {
    ip = i;
    jp = j;
    if (i % 2) {
        if (--j == -1) {
            j++;
            i++;
        }
    } else {
        if (++j == w) {
            j--;
            i++;
        }
    }
    if (i >= h) break;
    if (a[ip][jp] % 2) {
        a[ip][jp]--;
        a[i][j]++;
        result += "\n" + (ip+1) + " " + (jp+1) + " " + (i+1) + " " + (j+1);
        N++;
    }
}
console.log(N + result);

Measured memory_bytes: 63620
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<int> vi(n+1);
    for(int i=1; i<=n; i++){
        cin>>vi[i];
    }
    int ans=0;
    for(int i=1; i<n; i++){
        if(vi[i]==i){
            ans++;
            swap(vi[i],vi[i+1]);
        }
    }
    if(vi[n]==n) ans++;
    cout<<ans;
    
    
    
    
   
   
    
    return 0;
    
}

Measured memory_bytes: 640
#include <stdio.h> 


int main(void)
{
	long long int a, b, r, x, tmp;
	scanf("%lld", &a);
	scanf("%lld", &b);
	x = a * b;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	/* 最小公倍数を出力 */
	printf("%lld", x / b);

	return 0;


}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

long double dist(pair<double,double> a,pair<double,double> b){
    return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}
signed main(){
    int n; cin >> n;
    vector<pair<double,double>> p(n);
    rep(i,n) cin >> p[i].fi >> p[i].se;
    long double res=0;
    rep(i,n){
        rep(j,n){
            if(j<i) continue;
            res+=dist(p[i],p[j]);
        }
    }
    res/=n;
    res*=2.0;
    std::cout << std::setprecision(10) << res << endl;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.valueOf(sc.next());
        }

        List<Integer> totals = new ArrayList<>();
        for (int i = 1; i < 2 << (n-1); i++) {
            char[] c = new StringBuffer(Integer.toBinaryString(i)).reverse().toString().toCharArray();
            int total = 0;
            for (int j = 0; j < c.length; j++) {
                if (c[j] == 49) total += a[j];
            }
            totals.add(total);
        }

        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int m = Integer.parseInt(sc.next());
            System.out.println(totals.contains(m) ? "yes" : "no");
        }
    }
}



Measured memory_bytes: 152588
N=int(input())
A=list(map(int,input().split()))
M=max(A)

F=[0]*(M+1)

for i in range(N):
    a=A[i]
    b=a
    while b<=M:
        F[b]+=1
        b+=a
    

T=0
for i in range(N):
    if F[A[i]]==1:
        T+=1

print(T)


Measured memory_bytes: 106328
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin >> N;
	int K = N - 1;
	vector<pair<int,int> > ans;
	if (N % 2) {
		eFOR(i, 1,N - 1) {
			eFOR(j, i + 1, N) {
				if (j == K)K--;
				else {
					ans.push_back(make_pair(i, j));
				}
			}
		}
	}
	else {
		K++;
		eFOR(i, 1,N - 1) {
			eFOR(j, i + 1, N) {
				if (j == K)K--;
				else {
					ans.push_back(make_pair(i, j));
				}
			}
		}
	}
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;

	cout << min(a * p, (p - c > 0 ? (p - c) * d + b : b) ) << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n,q;
  int l,r;
  cin >> n >> q >> s;
  vector<int> num(n);
  num[0] = 0;
  for(int i = 1;i < n;i++){
    if(s[i-1] == 'A' && s[i] == 'C') num.at(i) = num.at(i-1) + 1;
    else num.at(i) = num.at(i-1);
  }
  
  for(int i = 0;i < q;i++){
    cin >> l >> r;
    cout << num[r-1] - num[max(l-1,0)] << endl;;
  }
}
    
    
  

Measured memory_bytes: 1408
s=input()
k=int(input())
p=[chr(ord("a")+i)for i in range(26)]
l=[]
for i in range(26):
    if p[i] in s:
        h=[j for j,x in enumerate(s) if x==p[i]]
        for t in range(len(h)):
            for d in range(5):
                if h[t]+d>len(s)-1:
                    break
                else:
                    l.append(s[h[t]:h[t]+d+1])
        else:
            l=list(set(l))
            if len(l)>=k:
                l.sort()
                print(l[k-1])
                break

Measured memory_bytes: 4568
N = int(input())
Alist = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Clist = list(map(int, input().split()))

manzokudo = 0
for B in Blist:
    manzokudo += B
    
for i in range(0, N-1):
    if Alist[i]+1 == Alist[i+1]:
        manzokudo += Clist[Alist[i]-1]

print(manzokudo)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  deque<int> dq;
  rep(i, n){
    int a;
    cin >> a;
    if(i % 2 == 0) dq.push_back(a);
    else dq.push_front(a);
  }
  if(n % 2 == 0){
    while(!dq.empty()){
      cout << dq.front() << " ";
      dq.pop_front();
    }
    cout << endl;
  }else{
    while(!dq.empty()){
      cout << dq.back() << " ";
      dq.pop_back();
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define N 100000
int m[N]={0};
int s[N];
int main(){
    int n;
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        m[a]++;
    }
    rep(i,N){
        if(i==0){
            s[i]=m[i]+m[i+1];
        }else if(i==N-1){
            s[i]=m[i]+m[i-1];
        }else{
            s[i]=m[i-1]+m[i]+m[i+1];
        }
    }
    sort(s,s+N,greater<int>());
    cout<<s[0]<<endl;
    return 0;
}


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
//RNG based on mersenne_twister 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }


int _runtimeTerror_()
{
	ll n,b,a,q,i;
	cin>>a>>b>>n;
	ll x;
	if(n>=b)
		x=b-1;
	else x=n;
	cout<<(floor(a*x/b)-a*floor(x/b));
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	cerr<<"\n"<<_time_;
	return 0;
}


Measured memory_bytes: 3800
b = input()

if b.find('A') == 0:
    ac = b.replace('A','T')
elif b.find('T') == 0:
    ac = b.replace('T','A')
elif b.find('G') == 0:
    ac = b.replace('G','C')
elif b.find('C') == 0:
    ac = b.replace('C','G')

print(ac)

Measured memory_bytes: 2940
#include<stdio.h>
int main(){
  int a,b;
  int d,r;
  double f;
  scanf("%d%d", &a,&b);
  d=a/b;
  r=a%b;
  f=1.0*a/b;
  printf("%d %d %.5lf\n", d, r, f);
  return 0;
}


Measured memory_bytes: 2072
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] inputValue = (Console.ReadLine()).Split();
        int N = int.Parse(inputValue[0]);
        int D = int.Parse(inputValue[1]);

        int maxMonitor = 0;
        int numMonitor = 0;

        do {
            numMonitor++;
            maxMonitor = maxMonitor + 1 + D * 2;
        } while(maxMonitor < N);

        Console.WriteLine(numMonitor);
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>
int main () {
	int a , b;
	double x = 0 , y = 0 , rad = 0 , tmp;
	while ( scanf("%d,%d",&a,&b),a||b ) {
		y += a * cos(rad / 180 * M_PI );
		x += a * sin(rad / 180 * M_PI );
		rad += b;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 0
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int n;
	cin>>n;
	map<int,int> m;
	while(n--) {
		int val;
		cin>>val;
		m[val]++;
		m[val-1]++;
		m[val+1]++;
	}
	int mi=0,miv=0;
	for(auto i:m) {
		if(i.S>mi){
			mi=i.S;
			miv=i.F;
		}
	}
	cout<<mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll h, n;
  cin >> h >> n;
  vector<ll> a(n), b(n);
  REP(i, n) cin >> a[i] >> b[i];

  ll dp[n + 5][h + 10010];
  REP(i, n) REP(j, h + 10005) dp[i][j] = INF;
  REP(i, n + 1) dp[i][0] = 0;

  REP(i, n) REP(j, h + 10005) {
    if (j < a[i]) {
      dp[i + 1][j] = dp[i][j];
    } else {
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
    }
  }

  ll ans = INF;
  FOR(i, h, h + 10001) { ans = min(ans, dp[n][i]); }

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

Measured memory_bytes: 157056
N,A[1000][1000],id[1000],used[1000];
i,j;day;flag=2;
main(){
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		for(j=0;j<N-1;j++)scanf("%d",A[j]+i);
	}
	for(;flag&2;)
	{
		flag=1;
		day++;
		for(i=0;i<N;i++)
		{
			if(used[i]<day&&id[i]<N-1)
			{
				flag&=2;
				j=A[id[i]][i]-1;
				if(used[j]<day&&id[j]<N-1&&A[id[j]][j]==i+1)
				{
					used[i]=used[j]=day;
					id[i]++;
					id[j]++;
					flag=2;
				}
			}
		}
	}
	printf("%d",flag*day-1);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    set<char> s;
    REP(i, N){
        char c;
        cin >> c;
        s.insert(c);
    }
    if(s.size() == 4) cout << "Four" << "\n";
    else cout << "Three" << "\n";
    return 0;
}

Measured memory_bytes: 256
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$tot=0;
for($i=0;$i<$N;$i++) {
  $tot^=$A[$i];
}
for($i=0;$i<$N;$i++) {
  $res[]=$tot ^ $A[$i];
}
printf("%s\n",implode(" ",$res));


Measured memory_bytes: 43404
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N;
    cin >> N;
    if(N == 1){
        cout << 1 << endl;
        cout << 1 << endl;
        return 0;
    }
    if(N == 2){
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
        return 0;
    }
    cout << N - 1 << endl;
    vec<string> ans(N-1, "");
    for(int i = 0; i < N - 1;++i){
        rep(j, i+2){
            if(j == 0)ans[i].push_back('1');
            else if(j == i+1)ans[i].push_back('1');
            else{
                ans[i].push_back('0');
            }
        }
    }
    rep(i,N-1){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int n; ll a[10009],b[10009]; vi ans; map<int,int> mp;
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
void check(int x){
	int i;
	//cerr<<x<<'\n';
	for (i=0; i<x && i<=n; i++){
		int j,tmp=0;
		for (j=n; j>=0; j--){
			tmp=((ll)tmp*i+a[j])%x;
	//		cerr<<tmp<<'\n';
		}
		if (tmp) return;
	}
	ans.pb(x); mp[x]=1;
}
int main(){
	scanf("%d",&n);
	int i;
	for (i=n; i>=0; i--) scanf("%lld",&a[i]);
	int m=abs(a[n]);
	for (i=2; i*i<=m; i++) if (!(m%i)){
		check(i);
		for (; !(m%i); m/=i);
	}
	if (m>1) check(m);
	//cerr<<n<<'\n';
	for (i=2; i<=n+1; i++){
	//	cerr<<n<<' '<<i<<'\n';
		int x; for (x=2; x*x<=i; x++) if (!(i%x)) break;
		if (x*x>i){
	//		cerr<<i<<'\n';
			int j;
			memcpy(b,a,sizeof(b));
			for (j=n; j>=i-1; j--) b[j-(i-1)]+=b[j]; 
			for (j=0; j<i-1; j++) if (b[j]%i) break;
		//	cerr<<j<<'\n';
			if (j==i-1 && !mp[i] && !(a[0]%i)) ans.pb(i);
		}
	}
	sort(ans.begin(),ans.end());
	for (int p:ans) printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 384
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextLine()
	B := sc.NextLine()

	if A == B {
		fmt.Println(len(A))
		return
	}
	for i := N; i >= 0; i-- {
		if A[N - i:] == B[:i] {
			fmt.Println(N - i + N)
			return
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import sys
import os
sys.setrecursionlimit(1000000)
from collections import defaultdict
adj = defaultdict(list)
adj1=defaultdict(list)
szc = [ 0 for i in range(300000)]
which =[0 for i in range(300000)]
vis = [0 for i in range(300000)]
tot =0
def dfs1(u):
	global tot
	vis[u]=1
	which[u]=tot
	szc[tot]=szc[tot]+1
	for i in adj[u]:
		if vis[i]==1:
			continue
		dfs1(i)
def main():
	global tot
	n , m , k = map(int, input().split())
	bk =[0 for i in range(n+1)]
	fd =[0 for i in range(n+1)]
	for i in range(m):
		x, y = map(int ,input().split())
		adj[x].append(y)
		adj[y].append(x)
		fd[x]=fd[x]+1
		fd[y]=fd[y]+1
	for i in range(k):
		x, y = map(int , input().split())
		adj1[x].append(y)
		adj1[y].append(x)
	for i in range(1, n+1):
		if vis[i]!=1:
			tot = tot+1
			dfs1(i)
	ans=[]
	for i in range(1, n+1):
		res = szc[which[i]]
		res = res-fd[i]
		res = res-1
		for j in adj1[i]:
			if which[j]==which[i]:
				res =res -1
		ans.append(res)
	print(*ans)
		
if __name__=="__main__":
	main()

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

int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}

int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    qsort(h,n,sizeof(int),compare);
    ll sum=0;
    for(int i=0;i<n-k;i++) sum+=(ll)h[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 1788
package main

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

// BIT stands for binary indexed tree.
type BIT []int

func newBIT(n int) BIT {
	return make([]int, n+1)
}

func (bit *BIT) add(i, x int) {
	for i++; i <= len(*bit)-1; i += i & -i {
		(*bit)[i] += x
	}
}

func (bit *BIT) sum(i int) int {
	x := 0
	for i++; i != 0; i -= i & -i {
		x += (*bit)[i]
	}
	return x
}

type t struct {
	X int
	H int
}
type byX []t

func (a byX) Len() int           { return len(a) }
func (a byX) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byX) Less(i, j int) bool { return a[i].X < a[j].X }

func main() {
	N := readInt()
	D := readInt()
	A := readInt()
	XH := make([]t, N)
	for i := 0; i < N; i++ {
		XH[i].X = readInt()
		XH[i].H = (readInt() + A - 1) / A
	}

	sort.Sort(byX(XH))
	result := 0
	bit := newBIT(N + 1)
	for i := 0; i < N; i++ {
		x, h := XH[i].X, XH[i].H
		h -= bit.sum(i)
		if h <= 0 {
			continue
		}
		result += h
		bit.add(i, h)

		ok := i
		ng := N
		for ng-ok != 1 {
			m := ok + (ng-ok)/2
			if XH[m].X <= x+2*D {
				ok = m
			} else {
				ng = m
			}
		}
		bit.add(ng, -h)
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 11008
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = list(map(int,input().split()))
a1 = sorted(a)
cnt = {}
cnt1 = 1
for i in range(1,n):
    if a1[i] == a1[i-1]:
        cnt1 += 1
        if i == n-1:
            cnt[a1[i]] = cnt1
    else:
        cnt[a1[i-1]] = cnt1
        cnt1 = 1
        if i == n-1:
            cnt[a1[i]] = cnt1


cmb = {}
cmb[1] = 0
cmb_all = 0
for i in cnt.values():
    if i == 1:
        continue
    else:
        cmb1 = combinations_count(i,2)
        cmb_all += cmb1
        cmb[i] = cmb1

for i in a:
    cnt1 = cnt[i]
    if cnt1 == 1:
        print(cmb_all)
    else:
        ans = cmb_all + cmb[cnt1] * ((cnt1-2)/cnt1 - 1)
        print(int(ans))



Measured memory_bytes: 26652
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int a;cin>>a;cout<<(a/2)*((a+1)/2)<<endl;
  return 0;
}

Measured memory_bytes: 256
a = list()
z = list()

s = input()

for i in range(len(s)):
    if(s[i]=='A'):
        a.append(i)
    elif(s[i]=='Z'):
        z.append(i)
        
aa = min(a)
zz = max(z)

#print(a,z)

if(len(a)==0 or len(z)==0):
    print(0)
elif(aa<zz):
    print(zz-aa+1)
else:
    print(0)
    

Measured memory_bytes: 51680
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

using namespace std;
typedef long long ll;
const ll MAXN = 1e5+2;
vector<bool> used(MAXN,false);
int a[int(1e5+10)];

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    for(int i = 1; i <= q; i++){
        int x; cin >> x;
        a[x]++;
    }
    for(int i = 1; i <= n; i++){
        if(a[i]-q+k > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll A,B,C;
ll N;
string s[100005];
char abc[100005];
bool flag;
void dfs(ll n,ll a,ll b,ll c){
	if(a<0||b<0||c<0){
	  flag=true; return;
	}
	string s1=s[n];
	if(n==N-1){
		if(s1=="AB"){
			if(a>0) abc[n]='B'; 
			else if(b>0) abc[n]='A';
			else{
				flag=true; return;
			}
		}
		if(s1=="BC"){
			if(b>0) abc[n]='C'; 
			else if(c>0) abc[n]='B';
			else{
				flag=true; return;
			}
		}
		if(s1=="AC"){
			if(a>0) abc[n]='C';
			else if(c>0) abc[n]='A';
			else{
				flag=true; return;
			}
		}
		return;
	}
	string s2=s[n+1];
	if(s2=="AB"){
		//01? 10?　00?
		if(s1=="BC"){
			if(b<=c){
				abc[n]='B';
				dfs(n+1,a,b+1,c-1);
			}
			else{
				abc[n]='C';
				dfs(n+1,a,b-1,c+1);
			}
		}
		if(s1=="AB"){
			if(a>=b){
				abc[n]='B';
				dfs(n+1,a-1,b+1,c);
			}
			else{
				abc[n]='A';
				dfs(n+1,a+1,b-1,c);
			}
		}
		if(s1=="AC"){
			if(a<=c){
				abc[n]='A';
				dfs(n+1,a+1,b,c-1);
			}
			else{
				abc[n]='C';
				dfs(n+1,a-1,b,c+1);
			}
		}
	}
	if(s2=="BC"){
		//?01 ?10 ?00
		if(s1=="BC"){
			if(b>=c){
				abc[n]='C';
				dfs(n+1,a,b-1,c+1);
			}
			else{
				abc[n]='B';
				dfs(n+1,a,b+1,c-1);
			}
		}
		if(s1=="AB"){
			if(a>=b){
				abc[n]='B';
				dfs(n+1,a-1,b+1,c);
			}else{
				abc[n]='A';
				dfs(n+1,a+1,b-1,c);
			}
		}
		if(s1=="AC"){
			if(a>=c){
				abc[n]='C';
				dfs(n+1,a-1,b,c+1);
			}else{
				abc[n]='A';
				dfs(n+1,a+1,b,c-1);
			}
		}
	}
	if(s2=="AC"){
		//0?1 1?0 0?0
		if(s1=="BC"){
			if(b>=c){
				abc[n]='C';
				dfs(n+1,a,b-1,c+1);
			}else{
				abc[n]='B';
				dfs(n+1,a,b+1,c-1);
			}
		}
		if(s1=="AB"){
			if(a<=b){
				abc[n]='A';
				dfs(n+1,a+1,b-1,c);
			}else{
				abc[n]='B';
				dfs(n+1,a-1,b+1,c);
			}
		}
		if(s1=="AC"){
			if(a>=c){
				abc[n]='C';
				dfs(n+1,a-1,b,c+1);
			}else{
				abc[n]='A';
				dfs(n+1,a+1,b,c-1);
			}
		}
	}
	return;
}
int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>A>>B>>C;
rep(i,N) cin>>s[i];
dfs(0,A,B,C);
if(flag){
	cout<<"No"<<endl;
}else{
	cout<<"Yes"<<endl;
	rep(i,N) cout<<abc[i]<<endl;
}


}
	


Measured memory_bytes: 24060
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    string s;
    cin >> s;
    int k=s.size();
    int n=0;
    int sum=0;
    int r=pow(10,k-1);
    rep(i,k){
        n+=r*(s[i]-'0');
        sum+=s[i]-'0';
        r/=10;
    }
    if(n%sum==0) cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256