akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}



int main(){
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    //solve(S, W);
    if(W>=S){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}


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

using namespace std;

int N;
int G[205];
int bit;

int grundy(int a,int k){
  if(a<k) return 0;
  if(a%k==0) return a/k;
  if(a%k){
    int n1=a%k;
    int n2=(a/k)+1;
    int m=n1/n2;
    if(m) return grundy(a-m*n2,k);
    else return grundy(a-n2,k);
  }
  return 0;
}

int main() {

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

cin>>N; 

for(int i=0; i<N; i++){
  int A,K;
  cin>>A>>K;
  G[i]=grundy(A,K);
}

for(int i=0; i<N; i++){
  bit^=G[i];
}

if(bit){
  cout<<"Takahashi"<<endl;
}else{
  cout<<"Aoki"<<endl;
}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool f(string s,ll i,ll j)
{
	while(i<=j)
	{
		if(s[i]!=s[j])
			return 0;
		i++;
		j--;
	}
	return 1;
}
int main() {
	string s;
	cin>>s;
	if(f(s,0,s.size()/2 -1)&&f(s,(s.size()+1)/2,s.size()-1)&&f(s,0,s.size()-1))
		cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, w, m int
	fmt.Scan(&N)
	a := make([]int, 100010)
	for i := 0; i < N; i++ {
		fmt.Scan(&w)
		a[w]++
	}
	for i := 1; i < 99999; i++ {
		m = max(m, a[i-1]+a[i]+a[i+1])
	}
	fmt.Println(m)
}

func max(a, b int) int {
	if b > a {
		return b
	}
	return a
}


Measured memory_bytes: 5504
#include<iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) {
        swap(a, b);
    }
    if (b > c) {
        swap(b, c);
    }
    if (a > b) {
        swap(a, b);
    }
    std::cout << a << ' ' << b << ' ' << c <<std::endl;
    return 0;
}



Measured memory_bytes: 3104
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)                \
    cerr << #v << ": ";             \
    REP(__i, (v).size())            \
        cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int res;
    if (13 <= A) res = B;
    else if (6 <= A) res = B / 2;
    else res = 0;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;
string s;
int q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> s;
    deque<char> t;
    bool rv = 0;
    for(auto c : s)t.pb(c);
    cin >> q;
    while(q--){
        int type;cin >> type;
        if(type == 1){
            rv ^= 1;
        }else{
            int f;cin >> f;--f;
            char x;cin >> x;
            if(f == rv)t.push_front(x);
            else t.pb(x);
        }
    }
    if(rv)reverse(t.begin(),t.end());
    for(auto c : t)cout << c;
}




Measured memory_bytes: 976
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int gcd(int a, int b)
{
    if (a < b)
        int c = a, a = b, b = c;
    return a % b == 0 ? b : gcd(b, a % b);
}

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

    int n, ma, mb, a[50], b[50], c[50];

    cin >> n >> ma >> mb;
    REP(i, n)
    cin >> a[i] >> b[i] >> c[i];

    int dp[2][500][500];

    REP(i, 500)
    REP(j, 500)
    {
        dp[0][i][j] = 10000;
        dp[1][i][j] = 10000;
    }

    int res = 0;

    dp[0][0][0] = 0;

    auto cur = dp[0];
    auto next = dp[1];

    REP(i, n)
    {
        REP(j, 500)
        {
            REP(k, 500)
            {
                next[j][k] = min(next[j][k], cur[j][k]);

                int at = j + a[i];
                int bt = k + b[i];
                if (at >= 500 || bt >= 500)
                    continue;

                next[at][bt] = min(next[at][bt], cur[j][k] + c[i]);
            }
        }

        swap(cur, next);
    }

    int ca = ma;
    int cb = mb;

    res = 10000;

    while (ca < 500 & cb < 500)
    {
        res = min(res, cur[ca][cb]);
        ca += ma;
        cb += mb;
    }

    cout << (res == 10000 ? -1 : res) << endl;

    return 0;
}

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

int main() {
    int s;
    cin >> s;

    int ans = 0;
    queue<int64_t> q;
    q.push(0);
    while (!q.empty()) {
        int64_t n = q.front();
        q.pop();

        if (s < n) continue;

        int c3 = 0, c5 = 0, c7 = 0;

        for (int64_t d = 1; d < n; d *= 10) {
            if (n / d % 10 == 3) c3++;
            if (n / d % 10 == 5) c5++;
            if (n / d % 10 == 7) c7++;
        }

        if (c3 && c5 && c7) ans++;

        q.push(n * 10 + 3);
        q.push(n * 10 + 5);
        q.push(n * 10 + 7);
    }

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

vector<pair<ll,ll>> factorize(ll n) {
    vector<pair<ll,ll>> res;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i) continue;
        res.emplace_back(i,0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}

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

    ll n;
    cin>>n;

    map<ll,ll> mp;
    REP(m,2,n+1){
        vector<pair<ll,ll>> res = factorize(m);
        Each(elm,res){
            mp[elm.fi] += elm.se;
        }
    }
    Vec x;
    Each(elm,mp){
        x.pb(elm.se+1);
    }
    ll ans=0;

    rep(i,x.size()){
        if(x[i]>=75){
            ans++;
        }
    }

    rep(j,x.size())rep(i,j){
        if(x[i]>=25&&x[j]>=3)ans++;
        if(x[i]>=3&&x[j]>=25)ans++;
        if(x[i]>=15&&x[j]>=5)ans++;
        if(x[i]>=5&&x[j]>=15)ans++;
    }

    rep(k,x.size())rep(j,k)rep(i,j){
                if(x[i]>=5&&x[j]>=5&&x[k]>=3)ans++;
                if(x[i]>=3&&x[j]>=5&&x[k]>=5)ans++;
                if(x[i]>=5&&x[j]>=3&&x[k]>=5)ans++;
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int S[] = new int[n];
		int count = 0;
		
		for (int k = 0; k <= n - 1; k++) {
			int x = scanner.nextInt();
			S[k] = x;
		}
		
		int q = scanner.nextInt();
		int T[] = new int[q];
		
		for (int k = 0; k <= q - 1; k++) {
			int x = scanner.nextInt();
			T[k] = x;
		}//SとTを配列にいれる

		for (int i = 0; i <= q - 1; i++) {
			for (int j = 0; j <= n - 1; j++) {
				if (S[j] == T[i]) {
					count += 1;
					break;
				}
			}
		}
		System.out.println (count);
}
}


Measured memory_bytes: 39992
[n, k, q] = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(list(map(int, input().split()))[0])
    
import numpy as np

player = [k] * n
player = np.array(player)

for _a in a:
    player[_a-1] += 1
    
player -= q
           
for _p in player:
    if _p > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 17888
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
	int N;
    cin >> N;
    vector<int> data(N - 1);
    rep(i, N - 1) cin >> data.at(i);
    vector<int> cnt(N);

    for(int i : data) {
        cnt.at(i - 1)++;
    }

    for(int i : cnt) {
        cout << i << endl;
    }
}

Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    long long int n;
    cin>>n;
    vector<long long int> v(n);
    REP(i,n){
        cin >> v[i];
    }
    long long int result = n, tmpnum = 0, l=0;
    REP(r,n){
        while(tmpnum&v[r]){
            tmpnum -= v[l];
            l++;
        }
        result += r-l;
        tmpnum += v[r];
    }
    cout << result << endl;


    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;



void Main(){
    string S;
    cin >> S;
    ll N = S.size();
    ll next_up = 0;
    ll num = 0;
    bool no_zero = false;
    vector<ll> nums(N+1);
    vector<ll> pay(N+1);
    vector<ll> res(N+1);
    for(ll i=N-1;i>=0;--i){
        ll this_d = S[i] - '0';
        no_zero = no_zero || (this_d != 0);
        if(this_d+next_up >= 6){
            pay[N-i-1] = 0;
            res[N-i-1] = 10 - (this_d + next_up);
            ll this_add = next_up == 1;
            num += (10 - this_d - this_add);
            nums[N-1-i] = (10 - this_d - this_add);
            next_up = 1;
        }else{
            if(this_d + next_up == 5 && i!= 0 && (S[i-1]-'0')>=5){
                pay[N-i-1] = 0;
                res[N-i-1] = 10 - (this_d + next_up);
                ll this_add = next_up == 1;
                num += (10 - this_d - this_add);
                nums[N-1-i] = (10 - this_d - this_add);
                next_up = 1;
            }else{
                pay[N-i-1] = this_d + next_up;
                res[N-i-1] = 0;
                num += this_d + next_up;
                nums[N-1-i] = this_d + next_up;
                next_up = 0;
            }
        }
    }
    num += next_up;
    nums[N] = next_up;
    pay[N] = next_up;
    res[N] = 0;
    // cout << " pay " <<endl;
    // rep(i, N+1){
    //     cout << pay[N-i];
    // }
    // cout << endl;
    // cout << " res " <<endl;

    // rep(i, N+1){
    //     cout << res[N-i];
    // }
    // cout << endl;

    // rep(i, N+1){
    //     cout << nums[N-i];
    // }
    // cout << endl;
    cout << num <<endl;

}

int main(){
    Main();
    // string S = "ksdfjl";
    // char v = S[3];
    // S[3] = 'a';
    // cout << S <<endl;
}

Measured memory_bytes: 27368
# puts i

k = gets.chomp.to_i
i = 1
a = 7 % k
h = a
if k != 7
    until a == 0 
        a = (7 + a * 10) % k
        if a == h || i == k
            puts "-1"
            exit
        end
        i += 1
    end
else
    puts "1"
    exit
end
puts i

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

void cout_array(int n,int a[]){
    for(int i = 0; i < n; i++){
        cout << a[i];
        if(i < n-1) cout << ' ';
    }
    cout << endl;
}

int main(){
    int n, A[100], times = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    
    int flag = 1;
    int i = 0;//未ソート部分の先頭インデクス
    while(flag){
        flag = 0;
        for(int j = n-1; j >= i+1 ; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                times++;
            }
        }
        i++;
    }
    cout_array(n, A);
    cout << times << endl;
    return 0;
}


Measured memory_bytes: 3084
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	str := sc.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var a []int
	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}
	ans := solve(a)
	fmt.Println(ans)
}

func solve(a []int) float64 {
	result := 0.0
	for _, ai := range a {
		result += 1.0 / float64(ai)
	}
	result = 1.0 / result
	return result
}


Measured memory_bytes: 640
A, B, K = map(int, input().split())

if B - A > ((2 * K) - 2):
    for a in range(A, A + K):
        print(a)
    for b in range(B - K + 1, B + 1):
        print(b)
else:
    for n in range(A, B + 1):
        print(n)



Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){

    int h, w;
    int i, j;

    while(1){

        cin >> h >> w;

        if(h == 0 && w == 0){
            break;
        }else{
            for(i=1;i<=h;i++){
                for(j=1;j<=w;j++){
                    if(i == 1 || i == h || j == 1 || j == w){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3076
from math import gcd
from functools import reduce

def gcd_list(A):
    return reduce(gcd, A)

def primes(n):
    is_prime = [False] * 2 + [True] * (n - 1)
    for i in range(2, int(n ** 0.5) + 1): # 素数候補
        if not is_prime[i]: continue
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def pairwise_coprime(a):
    max_a = max(a)
    in_a = [False] * (max_a + 1)
    for num in a:
        if num >= 2 and in_a[num]:
            return False
        in_a[num] = True

    ps = primes(max_a)  # max(a)以下の素数

    for p in ps:
        cnt = 0
        for i in range(p, max_a + 1, p):
            if in_a[i]:
                cnt += 1
            if cnt > 1:
                return False

    return True



n = int(input())
a = [int(x) for x in input().split()]

if gcd_list(a) == 1:  # setwise coprime or pairwise coprime
    if pairwise_coprime(a):
        print('pairwise coprime')
    else:
        print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 208548
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int n;
	cin >> n;
	int a;
	int b;
	ll ans = 0;
	cin >> b;
	rep1(i,n) {
		cin >> a;
		if(a > b) ans++;
		b = a;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3096
/*
Author: CNYALI_LK
LANG: C++
PROG: e.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
int a[1048576];
int main(){
#ifdef cnyali_lk
	freopen("e.in","r",stdin);
	freopen("e.out","w",stdout);
#endif
	int n,m,ans=0,mx;
	n=read();m=1<<n;
	for(int i=0;i<m;++i)a[i]=read();
	for(int i=1;i<m;++i){
		mx=0;
		for(int j=i;j;j=(j-1)&i){
			chkmax(ans,a[j]+mx);
			chkmax(mx,a[j]);
		}
		chkmax(ans,a[0]+mx);
		printf("%d\n",ans);
	}	
	return 0;
}



Measured memory_bytes: 4096
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long area=0;
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		long D=sc.nextLong();
		area=Math.max(A*B, C*D);
		System.out.println(area);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define loop1(i, n) for(int i=1;i<=(int)n;++i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef pair<int, int> pll;
typedef vector<int> vll;
typedef vector<pll> vpll;	
typedef long double db;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 200005

int n;
int a[N];
int pre[N], suf[N];

int32_t main() {
	FAST_IO;
	
	cin >> n;
	loop1(i, n) cin >> a[i];
	loop1(i, n) {
		pre[i] = max(pre[i - 1], a[i]);
	}
	for (int i = n; i >= 1; i--) {
		suf[i] = max(suf[i + 1], a[i]);
	}
	loop1(i, n) {
		cout << max(pre[i - 1], suf[i + 1]) << '\n';
	}
	rtn 0;
}


Measured memory_bytes: 6272
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b,c = map(int,input().split())
    if a == b and a != c:
        print(c)
    elif a ==c and a != b:
        print(b)
    elif b == c and a != b:
        print(a)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int r, c; cin >> r >> c;
	vv(int, v, r + 1, c + 1, 0);
	rep(i, 0, r) {
		rep(j, 0, c) {
			cin >> v[i][j];
		}
		v[i][c] = accumulate(all(v[i]), 0);
	}
	rep(j, 0, c + 1) {
		int ans = 0;
		rep(i, 0, r) {
			ans += v[i][j];
		}
		v[r][j] = ans;
	}
	rep(i, 0, r + 1) {
		rep(j, 0, c + 1) {
			if(j != 0) cout << " ";
			cout << v[i][j];
		}
		P("");
	}
	return 0;
}

Measured memory_bytes: 3216
#include<stdio.h>
#include<math.h>
int main(void){
  int L,R,i,j,ans=0,count=1;
  scanf("%d %d",&L,&R);
  if(L%2019==0 || R%2019==0 || R%2019<L%2019){
    printf("0");
    return 0;
  }
  else if(R-L>=2019){
    printf("0");
    return 0;
  }
  else{
    int X[R-L+1],min;
    for(i=0;i<R-L+1;i++){
      X[i]=L+i;
    }
    for(i=0;i<R-L+1;i++){
      X[i]=X[i]%2019;
    }
    min=(X[0]*X[1])%2019;
    for(i=0;i<R-L;i++){
      for(j=i+1;j<R-L+1;j++){
        ans=(X[i]*X[j])%2019;
        if(min>ans){
          min=ans;
        }
      }
      count=1;
    }
    printf("%d",min);
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<map>
using namespace std;

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int ans;
  for (int i=0;i<k;i++){
    ans = s[i]-'0';
    if(ans != 1) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

const int N=1e6;

struct Query
{
	int l,r;
	int id;
	
	inline bool operator<(const Query& b)const;
};

int n,m,a[N+10];
Query q[N+10];
int c[N+10],Ans[N+10];
int pos[N+10],pre[N+10];

#define SIZ 1000000

inline char gc()
{
	static char buf[SIZ],*p1,*p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZ,stdin),p1==p2)?EOF:*p1++;
}

#undef SIZ

inline void read(int& x)
{
	x=0;int f=0;char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=gc();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=gc();
	if(f)x=-x;
}

inline bool Query::operator<(const Query& b)const
{
	return r<b.r;
}

#define lowbit(x) (x&(-x))

inline void modify(int i,int x)
{
	if(!i)return;
	for(;i<=n;i+=lowbit(i))c[i]+=x;
}

inline int query(int i)
{
	int ret=0;
	for(;i;i-=lowbit(i))ret+=c[i];
	return ret;
}

#undef lowbit

int main()
{
#ifndef ONLINE_JUDGE
//	freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
#endif
	read(n);read(m);
	for(int i=1;i<=n;i++)
		read(a[i]);
	for(int i=1;i<=n;i++)
	{
		pre[i]=pos[a[i]];
		pos[a[i]]=i;
	}
//	read(m);
	for(int i=1;i<=m;i++)
		read(q[i].l),read(q[i].r),q[i].id=i;
	std::sort(q+1,q+m+1);
	int j=1;
	for(int i=1;i<=m;i++)
	{
		for(;j<=q[i].r;j++)
		{
			modify(pre[j],-1);
			modify(j,1);
		}
		Ans[q[i].id]=query(q[i].r)-query(q[i].l-1);
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",Ans[i]);
	return 0;
}


Measured memory_bytes: 20252
#include <iostream>
using namespace std;
const int MOD = 1000000007;
int N;
int dig[60];
long long A[300100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
  
    long long ans = 0, dig = 1;
    for (int i = 0; i < 60; i++) {
        long long zero = 0, one = 0;
        for (int j = 0; j < N; j++) {
            long long bit = A[j];
            if ((bit >> i) & 1) one++;
            else zero++;
        }
        ans += (zero * one % MOD) * dig % MOD;
        ans %= MOD;
        dig *= 2;
        dig %= MOD; 
    }
    cout << ans << endl;
}   

Measured memory_bytes: 2560
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long x, y, z;

int main(){
    scanf("%ld%ld%ld", &x, &y, &z);
    printf("%ld %ld %ld\n", z, x, y);
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
 
        int inputInt;
        int i = 1;
        for (;;) {
            inputInt = Integer.parseInt(sc.nextLine());
            if (inputInt == 0) {
                break;
            }
            sb.append("Case " + i + ": " + inputInt + "\n");
            i++;
        }
 
        System.out.print(sb);
    }
}

Measured memory_bytes: 60148
#include<stdio.h>
int main()
{
    int n,i,x[100],j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(j=n-1;j>=0;j--){
            if(j!=0)
       printf("%d ",x[j]);
    else if(j==0)
        printf("%d\n",x[j]);
    }
    return 0;
}



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

using namespace std;

long long D[201][100001], MOD=1000000007;

int main()
{
    int n, x, a;
    cin >> n >> x;
    vector <int> A;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    for (int i = 0; i <= x; i++)
    {
        for (int y = 1; y <= n; y++)
        {
            D[y][i] = 0;
        }
        D[0][i] = i;
    }
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y <= x; y++)
        {
            D[i+1][y] += D[i][y] * i;
            D[i+1][y] %= MOD;
            D[i+1][y] += D[i][y % A[i]];
            D[i+1][y] %= MOD;
        }
    }
    cout << D[n][x];
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m; cin >> n >> m;
  vector<P> vec(m);
  rep(i, m) cin >> vec[i].first >> vec[i].second;
  auto comp = [&](P a, P b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
  };
  sort(ALL(vec), comp);
  int ans = 0;
  int lim = -INF;
  rep(i, m) {
    if(lim <= vec[i].first) {
      lim = vec[i].second;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <vector>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
	int b = 0, c = 0, d = 0, e = 0, f = 0;
  int a[6];
	for(int i = 0; i < 5; i++){
		cin >> a[i];
	}
	for(int i = 0; i < 4; i++){
		d = 10 - a[i] % 10;
		f = 10 - a[4] % 10;
		if(a[i] % 10 == 0){
			d = d - 10;
		}
		if(a[4] % 10 == 0){
			f = f - 10;
	  }
		if(d > f){
      e = a[4];
			a[4] = a[i];
			a[i] = e;
		}
	}
	for(int i = 0; i < 5; i ++){
		if(i == 4){
			c = a[i];
		}
    else{
      c = (10 - a[i] % 10) + a[i];
			if(a[i] % 10 == 0){
				c = c - 10;
			}
		}
		b += c;
	}
	cout << b;
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    S = list(map(int, readline().split()))
    T = list(map(int, readline().split()))

    dp = [[0] * (M + 1) for _ in range(N + 1)]
    sdp = [[0] * (M + 2) for _ in range(N + 2)]

    dp[0][0] = 1
    for i in range(N + 1):
        sdp[i][0] = 1
    for j in range(M + 1):
        sdp[0][j] = 1

    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                dp[i + 1][j + 1] = sdp[i][j]
            sdp[i + 1][j + 1] = (sdp[i][j + 1] + sdp[i + 1][j] - sdp[i][j] + dp[i + 1][j + 1]) % MOD

    print(sdp[N][M])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 134172
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u64,
        m: u64,
        x: u64,
        a: [u64; m],
    }
    let cost_z = a.iter().filter(|c| *c < &x).count();
    let cost_n = a.iter().filter(|c| *c > &x).count();

    println!("{}", min(cost_z, cost_n));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    double ret = 0.0;
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);
    do {
        for (int i = 1; i < n; ++i) {
            ret += sqrt((x[perm[i]] - x[perm[i - 1]]) * (x[perm[i]] - x[perm[i - 1]]) +
                        (y[perm[i]] - y[perm[i - 1]]) * (y[perm[i]] - y[perm[i - 1]]));
        }

    } while (next_permutation(perm.begin(), perm.end()));

    for (int i = 1; i <= n; ++i) {
        ret /= double(i);
    }
    cout << fixed << setprecision(10) << ret << "\n";
    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;

	long long ans = 0; int right = 0, sum = 0;
	for (int left = 0; left < n; left++) {
		while (right < n && (sum ^ a[right]) == sum + a[right]) {
			sum += a[right++];
		}
		ans += right - left;
		if (left == right)right++;
		else sum -= a[left];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    map<map<char,long long int>,long long int> mp;
    string s;
    long long int result=0;
    REP(i,n){
        map<char,long long int> tmpmp;
        cin>>s;
        for(auto x:s){
            tmpmp[x]++;
        }
        mp[tmpmp]++;

    }
    for(auto x:mp){
            result+=(x.second*(x.second-1))/2;
    }
    cout<<result<<endl;

    return 0;
}



Measured memory_bytes: 60800
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
	string s;
    ll k;
    cin>>s>>k;
    ll ans=0;
    set<ll>ss;
    rep(i,s.size())ss.insert(s[i]);
    ll cnt;
    vector<ll>v;
    rep(i,s.size()){
        cnt=1;
        while(i<s.size()-1&&s[i]==s[i+1]){
            ++cnt;
            ++i;
        }
        ans+=cnt/2;
        v.pb(cnt);
    }
    ans*=k;
    if(cnt%2==1&&(v.front()+v.back())%2==0&&s.front()==s.back()){
        ans+=k-1;
    }
    if(ss.size()==1&&s.size()%2==1){
        ans=((ll)s.size()*k)/2;
    }
    cout<<ans<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
div = 998244353
S = []
for i in range(k):
  S.append(tuple(map(int, input().split())))
#print(S)###

dp = [0] * (2 * n)
wa = [0] * k

dp[n] = 1
#print(dp)

for i in range(n + 1, 2 * n):
  for j in range(k):
    wa[j] += (dp[i - S[j][0]] - dp[i - S[j][1] - 1])
    dp[i] += wa[j]
  dp[i] %= div
#print(dp)
print(dp[-1])

Measured memory_bytes: 18484
n,m = map(int,raw_input().split(" "))

if n > m:
  n,m = m,n

if n == 1:
  if m == 1:
    print 1
  elif m == 2:
    print 0
  else:
    print m-2
  exit(0)

ans = (n-2) * (m-2)
print ans


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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    vector<long long> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];
    vector<long long> diff(N - 1);
    for (int i = 0; i < N - 1; i++)
        diff[i] = X[i + 1] - X[i];

    long long res = 0;
    for (int i = 0; i < N - 1; i++) {
        if (diff[i] * A < B) {
            res += diff[i] * A;
        } else {
            res += B;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int x, n;
    cin >> x >> n;
    map<int, bool> mp;
    for(int i=0; n>i; i++){
        int num;
        cin >> num;
        mp[num] = true;
    }
    for(int i=0; 200>i; i++){
        if(mp[x-i] == false){
            cout << x-i << endl;
            return 0;
        }
        if(mp[x+i] == false){
            cout << x+i<< endl;
            return 0;
        }
    }
}






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

int main(){
	int N, answer = 0;
	string S;
	cin >> N >> S;
	string oldsub = "";
	for(int i = 0; i < N; i++){
		string sub = S.substr(i, 1);
		if(oldsub != sub) answer++;
		oldsub = sub;
	}
	cout << answer << endl;
}

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

int main() {
    ll X;
    cin >> X;
    for (ll i = -1000; i <= 1000; i++) {
        for (ll j = -1000; j <= 1000; j++) {
            ll A = i * i * i * i * i;
            ll B = j * j * j * j * j;
            if (A - B == X) {

                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  int sum=0;
  int cnt=inf;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
    if(a[i]%10!=0) chmin(cnt,a[i]);
  }
  if(sum%10!=0){
    cout << sum << endl;
  }
  else if(cnt!=inf){
    cout << sum-cnt << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var a = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var n =a[0]
    var m = a[1]
    var d = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var z= d.sum()
    var ans = (n-z)
    if(ans<0)
        println("-1")
    else
        println(ans)
}


Measured memory_bytes: 44724