akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    return


def main():
    N = int(input())
    S = input()

    N %= 26

    ans = ""
    for i in range(len(S)):
        x = ((ord(S[i]) - ord('A')) + N) % 26
        ans += chr(x + ord('A'))
    print(ans)

if __name__ == '__main__':
    main()


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

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    private static int[] readIntArray(final int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = readInt();
        return a;
    }

    static class SegmentTree {
        int size;
        int[] max;

        SegmentTree(int n) {
            size = 1;
            while (size < n) size *= 2;
            max = new int[size * 2];
            Arrays.fill(max, Integer.MIN_VALUE);
        }

        void set(int i, int v, int x, int lx, int rx) {
            if (rx - lx == 1) {
                max[x] = v;
                return;
            }
            int m = (lx + rx) / 2;
            if (i < m) {
                set(i, v, 2 * x + 1, lx, m);
            } else {
                set(i, v, 2 * x + 2, m, rx);
            }
            max[x] = Math.max(max[2 * x + 1], max[2 * x + 2]);
        }

        void set(int i, int v) {
            set(i, v, 0, 0, size);
        }

        int max(int l, int r) {
            return max(l, r, 0, 0, size);
        }

        int max(int l, int r, int x, int lx, int rx) {
            if (lx >= r || rx <= l) return Integer.MIN_VALUE;
            if (lx >= l && rx <= r) return max[x];
            int m = (lx + rx) / 2;
            int maxL = max(l, r, 2 * x + 1, lx, m);
            int maxR = max(l, r, 2 * x + 2, m, rx);
            return Math.max(maxL, maxR);
        }
    }

    static final int MAX_INDEX = 300000;
    static final int MIN_INDEX = 0;

    public static void main(String[] args) throws IOException {
        int n = readInt();
        int k = readInt();

        SegmentTree st = new SegmentTree(MAX_INDEX + 1);
        for (int i = 0; i < n; i++) {
            int a = readInt();
            int maxForA = st.max(Math.max(0, a - k), Math.min(MAX_INDEX, a + k) + 1);
            st.set(a, Math.max(1, maxForA + 1));
        }

        System.out.println(st.max(0, MAX_INDEX + 1));
    }
}

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

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int N=sc.nextInt();
		int array[] = new int[N*2];
		for(int i=0; i<N*2;i++){
			array[i]=sc.nextInt();
		}
		Arrays.sort(array);
		int count=0;
		for(int i=0;i<N*2;i=i+2){
			count+=array[i];
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 9684
#include<cstdio>

using namespace std;

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 0;
    if (a >= c && a >= b) {
        ans = 10 * a + b + c;
    }else if (b >= c && b >= a) {
        ans = 10 * b + a + c;
    }else if (c >= a && c >= b) {
        ans = 10 * c + b + a;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main(){
  FIO;
  // ifstream cin("input");
  string a;
  cin>>a;
  int flag=0;
  if(a[2]==a[3] && a[4] == a[5]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;  
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

string S;

signed main()
{
    cin >> S;

    int del = 0;
    int s = 0;
    REP(i, S.length()) {
        if(S[i] == 'T') {
            if(s > 0) {
                s--;
                del += 2;
            }
        } else {
            s++;
        }
    }
    printf("%lld\n", (ll)S.length() - del);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

#define ll long long
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll K;
    string S;
    ll tmp=0;
    cin >> S >> K;
    // while(S[tmp] == '1'){
    //     tmp++;
    // }
    // cout<< S[tmp] << endl;
    while(K > 0){
        int t = ctoi(S[tmp]);
        ll c = 5 * pow(10,15);
        // cout << t << endl;
        // cout << c << endl;
        K -= pow( t, c);
        tmp++;
        // cout << K << endl;
    }
    cout << S[tmp-1] << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}


void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      
    j = right;                    
    pivot = x[(left + right) / 2]; 
    while (1) {                    
        while (x[i] < pivot)       
            i++;                  

        while (pivot < x[j])       
            j--;                   
        if (i >= j)               
            break;                 

        Swap(x, i, j);            
        i++;                      
        j--;
    }
 
    if (left < i - 1)              
        QSort(x, left, i - 1);    
    if (j + 1 <  right)           
        QSort(x, j + 1, right);   
}

int main(void){
  int n,i;
  int l[210];
  scanf("%d",&n);
  for(i=0;i<2*n;i++){
    scanf("%d",&l[i]);
  }
 
  QSort(l,0,2*n-1);

  int sum = 0;
  for(i=0;i<2*n;i++){
    if(i%2 == 0){
      sum += l[i];
    }
  }

  printf("%d\n",sum);

  return 0;
}


Measured memory_bytes: 128
import Data.List
import Data.Ratio

main = do
  n <- readLn
  print $ phi n

phi :: Int -> Int
--phi 1 = 1
phi n = numerator $ foldl (\acc x -> acc * (1 - (1 % x)))
                          (n % 1) $ nub $ primeFactor n

factors :: Int -> [Int]
factors n = [d | d <- [1..n], n `mod` d == 0]

isPrime :: Int -> Bool
isPrime x = null [y | y <- [2..(sqr x)], x `mod` y == 0]
  where sqr a = floor $ sqrt $ fromIntegral a

primeFactor :: Int -> [Int]
primeFactor n
  | isPrime n = [n]
  | otherwise = reverse $ go [] n
  where
    go res 1 = res
    go res n = go (d : res) (n `div` d)
      where d = factors n !! 1

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  ll a , b , k; cin >> a >> b >> k ;
  
  rep(i,k){
    if(i%2==0){
      if(a%2==1) a--;
      b+=a/2;
      a/=2;
    }
    else{
      if(b%2==1) b--;
      a+=b/2;
      b/=2;
    }
  }
  cout<<a<<" "<<b<<endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    map<lint,lint> cnt;
    rep(i,N) cin >> A[i];
    rep(i,N) A[i]-=i;
    rep(i,N){
        cnt[A[i]]++;
    }
    lint ans=0;
    rep(i,N){
        lint key=-i*2-A[i];
        ans+=cnt[key];
        cnt[A[i]]--;
    }
    cout << ans << endl;
}

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

const int inf = 1e9;
const ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

class Combination
{
private:
    vector<mint> _fact, _inv_fact;
    
public:
    Combination(int size) : _fact(size + 1), _inv_fact(size + 1) {
        _fact[0] = 1;
        for (int i = 1; i <= size; i++) _fact[i] = _fact[i-1] * i;
        _inv_fact[size] = _fact[size].inv();
        for (int i = size - 1; i >= 0; i--) _inv_fact[i] = _inv_fact[i+1] * (i+1);
    }

    mint fact(int k) const {return _fact[k];}
    mint inv_fact(int k) const {return _inv_fact[k];}

    mint P(int n, int r) {
        if (r < 0 || n < r) return 0;
        else return fact(n) * inv_fact(n - r);
    }

    mint C(int n, int r) {
        if (r < 0 || n < r) return 0;
        else return fact(n) * inv_fact(r) * inv_fact(n - r);
    }

    mint H(int n, int r) {
        if (n < 0 || r < 0) return 0;
        else return r == 0 ? 1 : C(n + r - 1, r);
    }
};

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

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    Combination comb(r2 + c2 + 2);

    auto f = [&](int r, int c) {
        return comb.C(r + c + 2, r + 1) - 1;
    };

    mint ans = f(r2, c2) - f(r2, c1 - 1) - f(r1 - 1, c2) + f(r1 - 1, c1 - 1);

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

Measured memory_bytes: 31488
//ABC166 D

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint x;
double a,b;
lint a5,b5;


int main() {
  cin >> x;

/*   rep(i,n){
    scanf("%lld",&h[i]);
  } */
  
  int flag = 1;
  reps(i,1,1000){
    a = pow(i,5)-x;
    if(a > 0) flag = 1;
    else flag = -1;
    b = pow(abs(a),0.2);
    if(abs(b - floor(b)) < 0.00001){
      a5 = i;
      b5 = (lint)(b*flag);
      printf("%lld %lld\n",a5,b5);
      break;
    }
  }
  
  //printf("%lld\n",ans);
}


Measured memory_bytes: 4160
package main

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

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	fmt.Printf("%d", (n-1)/2+1)
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] n = in.next().toCharArray();
        for (int i = 0; i < n.length; i += 2){

            System.out.print(n[i]);
        }

    }
}














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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0; i < N; i++){
    cin >> v.at(i);
    //cout << v.at(i) << endl;
  }
  
  int i=0;
  int count=0, result;

  while(i < N-1){
    if(v.at(i) >= v.at(i+1)){
      count++;
    }
    else{
      if(result < count){
        result = count;
      }
      count =0;
    }
    //cout << i << " " << count << " " << result << endl;
    
    if(i == N-2){
      if(result < count){
        result = count;
      }
    }
    
    i++;
  }
  cout << result << endl;
}

Measured memory_bytes: 640
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	text := stdin.Text()
	text_array := strings.Split(text," ")
	large_t, _ := strconv.Atoi(text_array[0])
	large_x, _ := strconv.Atoi(text_array[1])
	fmt.Printf("%f",float32(large_t)/float32(large_x))
}


Measured memory_bytes: 640
n = int(input())
ps = list(map(int, input().split()))

count = 0
for i in range(1, n-2+1):
    if ps[i-1] < ps[i] < ps[i+1]:
        count += 1
    elif ps[i-1] > ps[i] > ps[i+1]:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>        //sort(v.begin(), v.end(), [std::greater()]);  第3引数をなしにすると昇順。
#include <utility>  
#include <vector>           
#include <iterator>         //vector入力で使う istream_iterator(cin)
#include <iomanip>          //doubleやfloatなどの少数の桁数を指定する setprecision(桁数) 

/*----------- 定義 -----------*/
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef long long int lli;
/*----------------------------*/


/*----------- 入力 -----------*/
lli N;
string S;
vector<int> vec;
/*----------------------------*/
 
 
 
int main(void){
    cin >> N;
    cin >> S;
    
    string T;
    lli count = 0;
    
    if(N%2 == 0){
        rep(i,N/2){
            if(S[i] == S[i+N/2]){
                ;
            }else{
                count++;
            }
        }
    }else{
        count++;
    }
    
    if(count == 0){
        cout << "Yes";
    }else{
        cout << "No";     
    }
    
        
        
    
    

    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 sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<vector<vector<vector<ll>>>> dp(105,vector<vector<vector<ll>>>(4,vector<vector<ll>>(4,vector<ll>(4))));
    dp[0][3][3][3]=1;
    rep(i,N){
        rep(x,4)rep(y,4)rep(z,4){
            if(x==0 && z==2){
                dp[i+1][y][z][0]+=dp[i][x][y][z];
                dp[i+1][y][z][0]%=MOD;
                dp[i+1][y][z][2]+=dp[i][x][y][z];
                dp[i+1][y][z][2]%=MOD;
                dp[i+1][y][z][3]+=dp[i][x][y][z];
                dp[i+1][y][z][3]%=MOD;
            }
            else if(y==0 && z==2){
                dp[i+1][y][z][0]+=dp[i][x][y][z];
                dp[i+1][y][z][0]%=MOD;
                dp[i+1][y][z][2]+=dp[i][x][y][z];
                dp[i+1][y][z][2]%=MOD;
                dp[i+1][y][z][3]+=dp[i][x][y][z];
                dp[i+1][y][z][3]%=MOD;
            }
            else if(y==2 && z==0){
                dp[i+1][y][z][0]+=dp[i][x][y][z];
                dp[i+1][y][z][0]%=MOD;
                dp[i+1][y][z][2]+=dp[i][x][y][z];
                dp[i+1][y][z][2]%=MOD;
                dp[i+1][y][z][3]+=dp[i][x][y][z];
                dp[i+1][y][z][3]%=MOD;
            }
            else if(y==0 && z==1){
                dp[i+1][y][z][0]+=dp[i][x][y][z];
                dp[i+1][y][z][0]%=MOD;
                dp[i+1][y][z][1]+=dp[i][x][y][z];
                dp[i+1][y][z][1]%=MOD;
                dp[i+1][y][z][3]+=dp[i][x][y][z];
                dp[i+1][y][z][3]%=MOD;
            }
            else if(x==0 && y==2){
                dp[i+1][y][z][0]+=dp[i][x][y][z];
                dp[i+1][y][z][0]%=MOD;
                dp[i+1][y][z][2]+=dp[i][x][y][z];
                dp[i+1][y][z][2]%=MOD;
                dp[i+1][y][z][3]+=dp[i][x][y][z];
                dp[i+1][y][z][3]%=MOD;
            }
            else{
                dp[i+1][y][z][0]+=dp[i][x][y][z];
                dp[i+1][y][z][0]%=MOD;
                dp[i+1][y][z][1]+=dp[i][x][y][z];
                dp[i+1][y][z][1]%=MOD;
                dp[i+1][y][z][2]+=dp[i][x][y][z];
                dp[i+1][y][z][2]%=MOD;
                dp[i+1][y][z][3]+=dp[i][x][y][z];
                dp[i+1][y][z][3]%=MOD;
            }
        }
    }
    ll ans=0;
    rep(x,4)rep(y,4)rep(z,4){
        ans+=dp[N][x][y][z];
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
#define ll long long
const int N = 200;
using namespace std;
int gcd(int, int);
int q[N];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);


	int x, n;
	cin >> x >> n;
	int t;
	int ans = x;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		q[t] = 1;
	}

	for (int i = 0;; i++)
	{
		if (q[x - i] == 0)
		{
			ans = x - i;
			break;
		}
		else if (q[x + i] == 0)
		{
			ans = x + i;
			break;
		}

	}

	cout << ans;

	return 0;
}
int gcd(int m, int n)
{
	return n == 0 ? m : gcd(n, m % n);
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
using namespace std;
bool in[100000], out[100000];
bool solve(int n) {
    for(int a0 = 0; a0 <= 1; a0++)
        for(int a1 = 0; a1 <= 1; a1++) {
            out[0] = a0, out[1] = a1;
            for(int j = 2; j < n; j++)
                out[j] = in[j - 1] ^ out[j - 1] ^ out[j - 2];
            if((out[n - 1] ^ out[0] ^ out[1]) != in[0])
                continue;
            if((out[n - 2] ^ out[n - 1] ^ out[0]) != in[n - 1])
                continue;
            return true;
        }
    return false;
}
char s[100001];
int main() {
    int n;
    scanf("%d %s", &n, s);
    for(int i = 0; i < n; i++)
        in[i] = s[i] != 'o';
    if(solve(n)) {
        for(int i = 0; i < n; i++)
            putchar(out[i] ? 'W' : 'S');
        putchar('\n');
    } else {
        puts("-1");
    }
}



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

struct Destination
{
	int t=0;
	int x=0,y=0;
};

bool isPossible(Destination now, Destination next)
{
	int t = next.t - now.t;
	int x = abs(next.x - now.x);
	int y = abs(next.y - now.y);

	if ( x+y > t) return false;
	if (( t - (x+y) ) % 2 == 1) return false;
	return true;
}


int main()
{
	int n, m;
	cin >> n >> m;
	int ans=0;

	if (n>0)
	{
		ans += n*(n-1)/2;
	}

	if (m > 0)
	{
		ans += m*(m-1)/2;
	}

	cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[200010],num[200010],ans=0;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		num[a[i]]++;
	}
	repn(i,n) ans+=num[i]*(num[i]-1)/2;
	rep(i,n) cout<<ans-max(0LL,num[a[i]]-1)<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

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

//const double pi = 3.1415926535;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v(m);
    int sum = 0;
    rep(i, m) {
        cin >> v[i];
        sum += v[i];
    }
    if (sum<=n)
        cout << n - sum << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define all(x) x.begin(),x.end()
#define YES {cout << "YES\n"; return;}
#define NO {cout << "NO\n"; return;}

const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
vi shortestPath(vector<vi>adj,int src,int dst){
    vi bfsParetns=bfsParents(adj,src);
    vi ans;
    while(src!=dst){
        if(bfsParetns[src]==INF)
            return {};
        ans.push_back(src);
        src=bfsParetns[src];
    }
    return ans;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

ll gcd(ll a,ll b){if(a%b==0) return b; else return gcd(b,a%b);}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll power(ll base, ll exp){ll res=1;while(exp){exp--;res*=base;}return res;}

void solve();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
  //  cin >> t;
    while(t--)
        solve();
    return 0;
}
void solve () {

    int n;
    cin >> n;
    map<string,int>m;
    while(n--){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << "\n";
    cout << "WA x "<<m["WA"] << "\n";
    cout << "TLE x "<<m["TLE"] << "\n";
    cout << "RE x "<<m["RE"] << "\n";


}


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

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    string b = "Yes";
    for (int i=0; i<n; i++) {
        if (i % 2 == 0 && s.at(i) == 'L') {
            b = "No";
        } else if (i % 2 == 1 && s.at(i) == 'R') {
            b = "No";
        }
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

score=sum(b)
for i in range(n-1):
    if a[i+1]-a[i]==1:
        score += c[a[i]-1]
print(score)

Measured memory_bytes: 3064
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, D, X;
	cin >> N >> D >> X;
	
	int A;
	rep(i, 0, N)
	{
		cin >> A;
		if (A == 1)
		{
			X += D;
		}
		else
		{
			rep(j, 1, D + 1)
			{
				if (j%A == 1)
				{
					X++;
				}
			}
		}
	}

	cout << X << endl;

	return 0;
}

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

//関数
//main関数
int main() {
    
    
    //入力
    string S;
    cin>>S;
    //計算
    long match=0;
    long N=S.size();
    for(int i=0;i<N;i++){
        if((i%2==0 && S.at(i)=='0') || (i%2==1 && S.at(i)=='1')){
            match++;
        }
    }
    //cout<<match<<endl;
    //出力
    cout<<min(match,N-match)<<endl;
}





Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	double D[3];
	while(cin>>D[0]>>D[1]>>D[2],D[0]||D[1]||D[2]){
		sort(D,D+3);
		double x = D[0], y = D[1];
		double r = sqrt(x*x+y*y);
		int N;
		cin>>N;
		for(int i=0;i<N;i++){
			double R;
			cin>>R;
			if(r<R*2) puts("OK");
			else puts("NA");
		}
	}
}

Measured memory_bytes: 1200
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	S := "CODEFESTIVAL2016"
	ans := 0
	for i := 0; i < len(s); i++ {
		if s[i] != S[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


int main()
{
	int h, w;
	cin >> h >> w;
	char p[h+2][w+2];
	for (int i = 0; i < h + 2; i++)
	{
		for (int j = 0; j < w + 2; j++)
		{
			if (i == 0 || i == h + 1 || j == 0 || j == w + 1)		
				cout << "#";
			else
			{
				cin >> p[i][j];
				cout << p[i][j];
			}
		}
		cout << "\n";
	}
}



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

int main(void)
{
  char s[100001];
  int k;
  int i = 0;
  cin >> s;
  cin >> k;
  while ( k > 0 && s[i] != '\0' ) {
    if ( (s[i] + k > 'z') && s[i] != 'a' ) {
      k -= ('z' - s[i] + 1);
      s[i] = 'a';
    }
    i++;
  }
  if ( k > 0 ) {
    s[i-1] = ((s[i-1]-'a' + k) % ('z'-'a'+1)) + 'a';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
int N;

int main(){
  scanf("%d", &N);
  
  vector<double> v(N);
  for(int i=0; i<N; i++) scanf("%lf", &v[i]);
  sort(v.begin(), v.end(), std::greater<double>());
  
  double ans=0;
  double devider=2;
  for(int i=0; i<N; i++){
    if(i==N-1){
      ans += v[i]/devider*2;
    }else{
      ans += v[i]/devider;
    }
    devider *= 2;
  }
  printf("%lf\n", ans);
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n, k; cin >> n >> k;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	ll ans = 0;
	sort(ALL(v));
	rep(i, k) ans += v[i];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
h, w = map(int, input().split())
s = [[*map(lambda c:c == ".", input())] for _ in [0] * h]
for i in "LRUD":
    exec(i + "= [[0] * w for _ in [0] * h]")
for i in range(h):
    for j in range(w):
        L[i][j]    = L[i][j-1] + 1 if s[i][j]    else 0
        R[i][-j-1] = R[i][-j]  + 1 if s[i][-j-1] else 0
for j in range(w):
    for i in range(h):
        U[i][j]    = U[i-1][j] + 1 if s[i][j]    else 0
        D[-i-1][j] = D[-i][j]  + 1 if s[-i-1][j] else 0
print(max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(h) for j in range(w)))

Measured memory_bytes: 234672
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// vector<pair<int, int>> v;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.second > b.second);
// }
// bool spOrder(const pair<int, int> &a,
//              const pair<int, int> &b)
// {
//     if (a.second == b.first)
//         return true;
//     return a.first < b.first;
// }
// void gen(int x,int y)
// {

// }
void solve()
{
    long double a, b;
    cin >> a >> b;
    cout.precision(0);
    cout << fixed << floor(a * b) << lin;
}

int main()
{
    auto start = clock();
    fast_io;
    // freopen("test.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin >>a >>b >>c;
  if (a<=c && b<=c)cout << a*b/2 <<endl;
	else if (a<=b && c<=b)cout << a*c/2<<endl;
	else cout << b*c/2 <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
  int N , M,ans=0;
  bool OK=false;
  cin>>N;
  if(N>81) OK=false;
  else{
    if(N==1) OK=true;
  if(N%2==0){if(N/2<=9){OK=true;}}
 if(N%3==0){if(N/3<=9){OK=true;}}
 if(N%4==0){if(N/4<=9) {OK=true;}}
 if(N%5==0){if(N/5<=9) {OK=true;}}
 if(N%6==0){if(N/6<=9) {OK=true;}}
 if(N%7==0){if(N/7<=9) {OK=true;}}
 if(N%8==0){if(N/8<=9) {OK=true;}}
 if(N%9==0){if(N/9<=9) {OK=true;}}
  }
  if(OK) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from collections import Counter

mod = 10**9 +7
N = int(input())
A = list(map(int,input().split()))

lcm = Counter([])
for a in A:
    tmp = []
    d = 2
    while d*d <= a:
        while a%d == 0:
            tmp.append(d)
            a //= d
        d += 1
    if a != 1:
        tmp.append(a)
    tmp = Counter(tmp)
    for k,v in tmp.items():
        if k not in lcm or v > lcm[k]:
            lcm[k] = v

LCM = 1
for k,v in lcm.items():
    LCM = LCM * pow(k,v,mod) % mod

ans = 0
for a in A:
    ans += LCM * pow(a,mod-2,mod) % mod
    ans %= mod

print(ans)



Measured memory_bytes: 75660
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 998244353


n = I()
P = IR(n)
LIS = [0] * (n + 1)
for i in range(n):
    LIS[P[i]] = LIS[P[i] - 1] + 1



print(n - max(LIS))

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD 998244353
 


ll N,M[5];
vector<ll> vv[5][101010];
ll gr[5][101010];
vector<ll> grmk[5][101010];
ll mk[101010], mk2[101010],mk3[101010];
ll pans[505050];
ll i, j, k;
ll ans;


int main(){
    scanf("%lld", &N);
    fornum(i,0,3){
        scanf("%lld", &M[i]);
        fornum(j,0,M[i]){
            ll a, b;
            scanf("%lld%lld", &a, &b);
            vv[i][a].push_back(b);
            vv[i][b].push_back(a);
        }
    }
    pans[0] = 1;
    pans[1] = (ll)1e18 % MOD;
    fornum(i,0,3*N){
        pans[i + 1] = pans[i] * pans[1] % MOD;
    }

    fornum(i,0,3){
        for (j = N; j >= 1;--j){
            ll a = 0;
            sort(grmk[i][j].begin(), grmk[i][j].end());
            fornum(k,0,grmk[i][j].size()){
                if(a<grmk[i][j][k]){
                    break;
                }
                a = grmk[i][j][k] + 1;
            }
            gr[i][j] = a;
            fornum(k,0,vv[i][j].size()){
                ll b = vv[i][j][k];
                grmk[i][b].push_back(gr[i][j]);
            }
        }
    }
    mk[0] = 1;
    fornum(i,0,3){
        fornum(j,0,1010){
            mk2[j] = mk[j];
            mk3[j] = mk[j] = 0;
        }
        fornum(j,0,N){
            mk3[gr[i][j + 1]] += pans[j + 1];
            mk3[gr[i][j + 1]] %= MOD;
        }
        fornum(j,0,1010){
            fornum(k,0,1010){
                mk[j ^ k] += mk2[j] * mk3[k] % MOD;
                mk[j ^ k] %= MOD;
            }
        }
        
    }
    printf("%lld\n", mk[0]);
    return 0;
}

Measured memory_bytes: 54528
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int pow(int x,int n){
    int ret=1;
    while(n){
        if(n&1)
            (ret*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}
int inv(int x){
    return pow(x,mod-2);
}
bool prime[1000];
signed main(){
    int n,a[10000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=2;i<1000;i++)
        prime[i]=1;
    for(int i=2;i*i<1000;i++)
        if(prime[i])
            for(int j=i*i;j<1000;j+=i)
                prime[j]=0;
    map<int,int>mps[10000];
    for(int i=0;i<n;i++){
        int tmp=a[i];
        for(int j=2;j<1000;j++){
            while(tmp%j==0){
                mps[i][j]++;
                tmp/=j;
            }
        }
        if(tmp!=1)
            mps[i][tmp]++;
    }
    map<int,int>mp;
    for(int i=0;i<n;i++)
        for(auto x:mps[i])
            mp[x.first]=max(x.second,mp[x.first]);
    int lcm=1;
    for(auto x:mp)
        (lcm*=pow(x.first,x.second))%=mod;
    int ans=0;
    for(int i=0;i<n;i++)
        (ans+=lcm*inv(a[i]))%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 3968
#include <stdio.h>
int main(){
  int N,K,k;
  int n=1;
  scanf("%d %d",&N,&K);
  k=K;
  while(1){
    if(N<k) break;
    k=k*K;
    n++;
  }
  printf("%d",n);
  return 0;
}

Measured memory_bytes: 256
def aa
    y,m,d = gets.chomp.split(/\//).map{|x| x.to_i}

    if y < 2019
        puts 'Heisei'
    elsif y == 2019 and m < 4
        puts 'Heisei'
    elsif y == 2019 and m == 4 and d < 31
        puts 'Heisei'
    else
        puts 'TBD'
    end
end

aa


Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int A, B;

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

    if (A > 9 || B > 9) {
        cout << -1 << endl;
        return 0;
    }
    cout << A * B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;

int main()
{
  IOS
  ll n;
  cin>>n;
  ll ans=(n-2)*180;
  cout<<ans;

  return 0; 
}

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

int main(){
  int n;
  cin >> n;
  vector<char> a(n);
  int ans = 1;

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

  for (int i = 0;i < n - 1;i++) {
    if (a[i] != a[i + 1]) ans++;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	int N,K;
	cin >> N >> K;
	int dp[N+5],h[N+5];
	for(int i=0;i<N;i++){
		cin >> h[i];
		dp[i] = INF;
	}
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<N;i++){
		for(int j=1;j<=K;j++){
			if(i-j>=0)dp[i] = min(abs(h[i]-h[i-j])+dp[i-j],dp[i]);
		}
	}
	cout << dp[N-1] << endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    int sum = accumulate(all(b),0);
    rep(i,n-1){
        if (a[i]+1 == a[i+1]) sum += c[a[i]];
    }
    cout << sum << endl;

    return 0;
}


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

#define fi first
#define se second
#define int long long

const int N = 100100;
const int mod = 1e9 + 7;

using namespace std;


signed main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        int n;
        cin >> n;
        int cnt = 0;
        for(int i = 0; i < n; i++){
                int x;
                cin >> x;
                cnt += (x & 1);
        }
        cout << (cnt % 2 == 0 ? "YES" : "NO") << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MaxN = 2e5 + 5;
 
int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	LL sum = 0;
	for(int i = 1; i <= n; i++) {
		if(n / i > 0) {
			sum += (n/i) * max(0, (i - k));
			if(n % i >= k) sum += n % i - k + 1;
		}
		else sum += max(0, n%k - k + 1);
	}
	if(k == 0) sum -= n;
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int ans = 0;

    sort(a.begin(),a.end());
    for(int i = 0;i < n-1;i ++){
        if(a.at(i) == a.at(i+1)){
            a.at(i) = 0;
            a.at(i+1) = 0;
        }
    }

    for(int i = 0;i < n;i ++){
        if(a.at(i)) ans ++;
    }

    cout << ans << endl;


    
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c,d;
    string s;
    cin >> s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';

    rp(i,8){
        bool op1=false,op2=false,op3=false;
        if(i&1) op1=true;
        if(i&2) op2=true;
        if(i&4) op3=true;
        int sum=a;
        if(op1) sum+=b;
        else sum-=b;
        if(op2) sum+=c;
        else sum-=c;
        if(op3) sum+=d;
        else sum-=d;
        if(sum==7){
            cout << a;
            if(op1) cout << '+';
            else cout << '-';
            cout << b;
            if(op2) cout << '+';
            else cout << '-';
            cout << c;
            if(op3) cout << '+';
            else cout << '-';
            cout << d << "=7" << endl;
            return;
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H[] = new int[N];
		int max = 0;
		int answer = 0;

		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}

		for (int i = 0; i < N - 1; i++) {
			answer = 0;
			for (int j = 0; j < N - i - 1; j++) {
				if (H[i + j] < H[i + j + 1]) {
					break;
				} else {
					answer++;
				}
			}
			if (max < answer) max = answer;
			if (N - i <= max) break;
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 49124
// https://atcoder.jp/contests/abc115/tasks/abc115_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int d;
  string r[] = {
      "Christmas Eve Eve Eve",
      "Christmas Eve Eve",
      "Christmas Eve",
      "Christmas"};

  cin >> d;

  cout << r[d - 22] << '\n';

  return 0;
}


Measured memory_bytes: 256