akhauriyash/Code-Regression huggingface dataset:
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = LIST()
count = 0
flag = 0
for i in range(n):
        if s[i] == i+1 and flag == 0:
                count += 1
                flag = 1
        else:
                flag = 0
        
print(count)

Measured memory_bytes: 21392
#include <cstdio>
#define MOD 998244353
typedef long long ll; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
ll fact[500005], inv[500005]; 
inline ll C(int n, int m)
{
	if (n < m || m < 0)
		return 0; 
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD; 
}
int main()
{
	// freopen("AGC021-E.in", "r", stdin); 
	int n, k;
	scanf("%d%d", &n, &k); 
	fact[0] = inv[0] = 1; 
	for (int i = 1; i <= k; i++)
	{
		fact[i] = fact[i - 1] * i % MOD; 
		inv[i] = quick_pow(fact[i], MOD - 2); 
	}
	ll ans = 0; 
	for (int r = n; r <= k; r++)
	{
		if (r < k - r)
			continue; 
		(ans += C(k, r) - C(k, 2 * r - n + 1)) %= MOD; 
		if (r + r == k)
			(ans += C(k - 1, n - 1) - C(k - 1, r)) %= MOD; 
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0; 
}


Measured memory_bytes: 7936
# Problem D - Lunlun Number

# input
K = int(input())

# initialization
num_queue = []
k = 1

# count
while True:
    if k>=1 and k<=9: # 1桁の場合
        num_queue.append(k)
        k += 1
    else: # 2桁以降の場合
        min_num = str(num_queue.pop(0))
        keta_1 = int(min_num[-1])
        if keta_1==0:
            for i in range(2):
                tmp = int(min_num + str(i))
                num_queue.append(tmp)
                k += 1
                if k>K:
                    break
        elif keta_1==9:
            for i in range(keta_1-1, keta_1+1):
                tmp = int(min_num + str(i))
                num_queue.append(tmp)
                k += 1
                if k>K:
                    break
        else:
            for i in range(keta_1-1, keta_1+2):
                tmp = int(min_num + str(i))
                num_queue.append(tmp)
                k += 1
                if k>K:
                    break
    if k>K:
        break

# output
print(num_queue[-1])


Measured memory_bytes: 46940
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	int l = s.length();
	char c = s[0];
	int ans = 0;
	FOR(i, 1, l-1) {
		if (c != s[i]) {
			ans++;
			c = s[i];
		}
	}

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

Measured memory_bytes: 1020
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=800000+19;

struct Edge{
	int y,nxt;
} E[N*2];
int las[N],A[N],B[N],chk[N],val[N],vis[N];
int n,x,cnt;

void Link(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,las[y]};las[y]=cnt++;
}
void dfs(int x){
	for (int i=las[x];~i;i=las[x]){
		las[x]=E[i].nxt;
		if (!vis[i/2]){
			vis[i/2]=1;
			chk[i]=1;
			dfs(E[i].y);
		}
	}
}

int main(){
	memset(las,-1,sizeof(las));
	n=IN();
	For(i,1,n+1){
		x=IN();
		if (x==-1){
			Link(i,0);
		} else{
			A[x]++;
			Link(x,i);
		}
	}
	For(i,1,n+1){
		x=IN();
		if (x==-1){
			Link(i+n,0);
		} else{
			B[x]++;
			Link(x+n,i+n);
		}
	}
	For(i,1,n+1) if (A[i]%2!=B[i]%2){
		puts("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	For(i,1,n+1) if (A[i]%2==0){
		val[i]=cnt;
		Link(i,i+n);
	}
	dfs(1);
	For(i,1,n+1){
		if (A[i]%2==1){
			printf("0 ");
		} lf (chk[val[i]]){
			printf("1 ");
		} else{
			printf("-1 ");
		}
	}
	puts("");
}

Measured memory_bytes: 24832
# -*- coding:utf-8 -*-

def main():
    LIST=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]

    while True:
        try:
            count=3
            M,D=map(int,input().split())
            if M==0:
                break

            if M in [1,4,7]:
                pass
            elif M in [10]:
                count+=1
            elif M in [5]:
                count+=2
            elif M in [2,8]:
                count+=3
            elif M in [3,11]:
                count+=4
            elif M in [6]:
                count+=5
            elif M in [9,12]:
                count+=6

            count+=D%7

            print(LIST[count%7])

        except:
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 7612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a, b;
    cin>>a>>b;
    if(min(a,b) == a)
    {
        for(ll i=0; i<b; i++)
        {
            cout<<a;
        }
        cout<<endl;
    }
    else
    {
        for(ll i=0; i<a; i++)
        {
            cout<<b;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3680
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(500*i + 100*j + 50*k == X):
                ans += 1
print(str(ans))

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define imp() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define endl "\n"
#define lli long long int 
#define ll long long 
#define f(i,a,b) for(i=(int)a;i<(int)b;i++)
lli gccd(lli a,lli b)
{
    if(b==0)
    return a;
    //else
    return (b,a%b);
}
lli  sum(string str)
{
    lli s=0;
    for(lli i=0;i<str.size();i++)
    {
        s+=str[i]-'0';
    }
    return s;
}
int main() {
	// your code goes here
	imp();
int n;cin>>n;lli arr[n];lli c=0;lli maxx=INT_MIN;lli pos=0;
for(int i=0;i<n;i++)
{
    cin>>arr[i];//maxx=max(arr[i],maxx);
}
maxx=arr[0];
for(int i=1;i<n;i++)
{
    if(arr[i]<maxx)
    c+=maxx-arr[i];
    else if(arr[i]>maxx)
    maxx=arr[i];
}
cout<<c<<"\n";
	return 0;
}


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

int main(){
	long long int n,i,j,tmp,mx,price[4000][2],a,b,c;
	bool flag;
	while(cin >> n && n){
		flag = false;
		mx = 0;
		memset(price,'\0',sizeof(price));
		for(i = 0;i < n;++i){
			cin >> a >> b >> c;
			for(j = 0;j < mx;++j){
				if(price[j][0] == a){
					tmp = j;
					flag = true;
				}
			}
			if(flag) price[tmp][1] += (b * c);
			else {
				price[mx][1] += (b * c);
				price[mx][0] = a;
				++mx;
			}
			flag = false;
		}
		flag = false;
		for(i = 0;i < mx;++i){
			if(price[i][1] >= 1000000){
				cout << price[i][0] << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

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

int main()
{
  ifstream fIn("input.txt");
  if (fIn.is_open())
    cin.rdbuf(fIn.rdbuf());

  int N, L;
  cin >> N >> L;
  
  int S;
  int m = L;
  for(int i = 0; i < N; i++){
    S += L + i;
    if(abs(m) > abs(L + i)){
      m = L + i;
    }
  }
      cout << S - m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int n, a[110];
	bool flag = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) flag = true; 
		} 
		if (flag) break; 
	}
	if (flag) cout << "DENIED" << endl;
	else cout << "APPROVED"  << endl;
	return 0;
} 

Measured memory_bytes: 256
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, y = list(map(int, readline().split()))
    if (x + y) % 3 != 0 or x < 0 or y < 0:
        print(0)
    else:
        t = (x + y) // 3
        for i in range(0, t + 1):
            if i * 2 + (t - i) == x and i + (t - i) * 2 == y:
                print(alg_combination_mod(t, i, mod))
                exit()
        print(0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38896
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, status[256] = {0};
    char buf[256];
    fgets(buf, sizeof(buf), stdin);
    for ( i = 0; buf[i] != '\0'; i++ ){
        if ( status[ (int)buf[i] ] != 0 ){
            printf("no\n");
            return 0;
        }
        status[ (int)buf[i] ] = 1;
    }
    printf("yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

int main() {

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    int count = 0;
    int now = 1;

    rep(i,N) {
        if (a[i] == now) now++;
        else count++;
    }

    if (count == N) cout << -1 << endl;
    else cout << count << endl;
    
    return 0;
}

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

using namespace std;

int main()
{
    string s, s2;
    int n, sizeSet;
    set<string> ss;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> s;
        sizeSet = ss.size();
        ss.insert(s);
        if (i == 0)
        {
            s2 = s;
            continue;
        }
        if (s2[s2.size() - 1] != s[0] || sizeSet == ss.size())
        {
            cout << "No";
            return 0;
        }
        s2 = s;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int n, x, y;
	scanf("%d %d %d", &n, &x, &y);
	int i, j;
	int p = y - x - 1;
	long long int s[2001] = {0};
	
	for(i = 1; i < n; i++)
	{
		for(j = i + 1; j <= n; j++)
		{
			if(j >= y && i <= x)
			{
				s[j - i - p]++;
			}
			else
			{
				if(i > x && j >= y && j - i > i - x + j - y + 1)
				{
					s[i - x + j - y + 1]++;
				}
				else if(j < y && i <= x && j - i > x - i + y - j + 1)
				{
					s[x - i + y - j + 1]++;
				}
				else if(j < y && i > x && j - i > i - x + y - j + 1)
				{
					s[i - x + y - j + 1]++;
				}
				else s[j - i]++;
			}
		}
	}
	for(i = 1; i < n; i++)
	{
		printf("%lld\n", s[i]);
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


bool solve(){
	int n, s;
	cin>> n>> s;
	if(n==0 && s==0) return false;
	vector<int> r(n);
	for(int i=0;i<n;i++){
		cin>> r[i];
	}
	sort(r.rbegin(), r.rend());
	int ans = 0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int p = r[i] + r[j];
			if(p > s){
//				cout<< r[i]<< " "<< r[j]<< endl;
				ans++;
			}else{
				break;
			}
		}
	}
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1236
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {

int i,j,k,n;

cin >> n;

vector<string> r(n);
vector<int> s(n);


for(i=0;i<=n-1;i++){
cin >> r.at(i) >> s.at(i);
}

for(k=1;k<=13;++k){
j=0;
for(i=0;i<=n-1;++i){
if(r.at(i)=="S" && s.at(i)==k){
++j;
}
}
if(j==0){cout << "S" << " " << k << endl;}
}

for(k=1;k<=13;++k){
j=0;
for(i=0;i<=n-1;++i){
if(r.at(i)=="H" && s.at(i)==k){
++j;
}
}
if(j==0){cout << "H" << " " << k << endl;}
}

for(k=1;k<=13;++k){
j=0;
for(i=0;i<=n-1;++i){
if(r.at(i)=="C" && s.at(i)==k){
++j;
}
}
if(j==0){cout << "C" << " " << k << endl;}
}

for(k=1;k<=13;++k){
j=0;
for(i=0;i<=n-1;++i){
if(r.at(i)=="D" && s.at(i)==k){
++j;
}
}
if(j==0){cout << "D" << " " << k << endl;}
}

}


Measured memory_bytes: 3144
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


void MAIN() {
    LL R, G, B;
    scanf("%lld%lld%lld", &R, &G, &B);
    int K;
    scanf("%d", &K);

    int cnt = 0;
    while (G <= R) {
	G += G;
	cnt++;
    }
    while (B <= G) {
	B += B;
	cnt++;
    }

    if (cnt <= K) puts("Yes");
    else puts("No");

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin>>n;
    ll sum=0,mini=mod;
    bool same=true;
    lol(i,n){
	ll a,b;cin>>a>>b;
	if(a!=b)same=false;
	sum+=b;
	if(a>b)mini=min(mini,b);
    }
    if(same)cout<<"0"<<endl;
    else cout<<sum-mini<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n;
  cin >> n;
  Sieve sieve(55556);
  vi ans;
  srep(i,2,55556){
    if(sieve.isPrime(i) && i%5==1)ans.push_back(i);
  }
  rep(i,n)cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
double in;
int a[4]={0},b[4]={0};
while(cin>>in){
if(in>=1.1)a[0]++;
else if(in>=0.6)a[1]++;
else if(in>=0.2)a[2]++;
else a[3]++;
cin>>in;
if(in>=1.1)b[0]++;
else if(in>=0.6)b[1]++;
else if(in>=0.2)b[2]++;
else b[3]++;
}
rep(i,4)cout<<a[i]<<" "<<b[i]<<endl;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int x, n;
	cin >> x >> n;
	int ans = INF;
	set<int> s;
	for(int i = 0; i <= 101; i++) s.insert(i);
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		s.erase(t);
	}
	for(int i = 0; i <= 101; i++) {
		if(s.count(i) == 0) continue;
		if(abs(i - x) < abs(ans - x))
			ans = i;
	}
	cout << ans << endl;
	
}





Measured memory_bytes: 3672
#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    ios_base::sync_with_stdio(0), cin.tie(0);
    assert(freopen("in", "r", stdin));
    assert(freopen("out", "w", stdout));
#endif
    
    int n;
    cin >> n;

    vector<ll> a(n);
    vector<ll> b(n + 1);
    b[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i + 1] = b[i] + a[i];  // sum [0..i]
    }

    ll cnt = 0;
    unordered_map<ll, ll> m;
    for (int i = 0; i < n + 1; i++)
        m[b[i]]++;

    for (pair<ll, ll> p : m)
        cnt += p.second * (p.second - 1) / 2;

    cout << cnt;

    return 0;
}







































Measured memory_bytes: 11592
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end

def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(ym){Array.new(l,d)}}end

def yn(f) return (f)? "Yes": "No" end

def ynb(f) return (f)? "YES": "NO" end

def ap(a) a.each{|u| p u} end

def bit(n) n.to_s(2).split("").map(&:to_i) end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

s = gets.chomp
mae = ""
ans = ""
cc = 0
s.each_char do |c|
  ans += c
  if(ans != mae)
    mae = ans
    ans = ""
    cc += 1
  end
end
p cc

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

int main() {
  int h,m,s,recs[2],recm[2],rech[2];
  while(cin >> h >> m >> s) {
    if((h == -1)&&(m == -1)&&(s == -1)) break;
    s += m * 60 + h * 3600;
    recs[0] = 7200 - s;
    recs[1] = recs[0] * 3;
    for(int i=0;i<2;i++) {
      rech[i] = recs[i] / 3600;
      recm[i] = (recs[i] % 3600) / 60;
      recs[i] = (recs[i] % 60);
    }
    for(int i=0;i<2;i++) {
      if(recm[i] >= 10) {
      if(recs[i]<10)
        cout << "0" << rech[i] << ":" << recm[i] << ":" << "0" << recs[i] << endl;
      else
        cout << "0" << rech[i] << ":" << recm[i] << ":" << recs[i] << endl;
      }
      else {
      if(recs[i]<10)
        cout << "0" << rech[i] << ":" << "0" << recm[i] << ":" << "0" << recs[i] << endl\
;
      else
        cout << "0" << rech[i] << ":" << "0" << recm[i] << ":" << recs[i] << endl;
      }
    }
  }
}

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

int keisan(int i){
  int wa= 0;
  while (i > 0) { // n が 0 になるまで
    wa += i % 10;
    i /= 10;
  }
  return wa;
}

int main()
{
  int N,A,B;
  cin >> N >> A >> B;
  int count=0;
  int wa;
  int sum =0;
  for(int i=1;i<=N;i++){    
    int wa = keisan(i);
    	if( A<=wa && wa<=B){
			sum += i;
    	}
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll max_len = max(A, max(B, C)), rest;
    if (max_len == A) rest = B * C;
    else if (max_len == B) rest = C * A;
    else rest = A * B;
    cout << (max_len % 2) * rest << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,max,min,i,a;
  long long sum;
  sum=0;
  max=-1000000;
  min=1000000;
  scanf("%d", &n);
  for(i=0;i < n;i++){
    scanf("%d", &a);
    if(a > max){
      max=a;
    }
    if(a < min){
      min=a;
    }
    sum=sum+a;
  }
  printf("%d %d %lld\n", min, max, sum);
  return 0;
}



Measured memory_bytes: 2144
using System.Linq.Expressions;
using System;
namespace ExpressionQiita
{
    class Program
    {
        static void Main(string[] args)
        {
            int min = 0;
            int N = int.Parse(Console.ReadLine());
            for (int A = 1;A < N;A++)
            {
                int B = N - A;
                int sum = isum(A) + isum(B);
                min = (min > sum || min == 0)?sum:min;
            }
            Console.WriteLine(min);
        }

        public static int isum(int num)
        {
            int sum = 0;
            do
            {
                int dig = num % 10;
                sum += dig;
                num = num / 10;
            } while (num != 0);
            return sum;
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static final char a = 'A';
	public static final char c = 'C';
	public static final char g = 'G';
	public static final char t = 'T';

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		StringBuilder maxSub = new StringBuilder();
		for (int i = 0; i < S.length(); i++) {
			char SAti = S.charAt(i);
			if (judgeContains(SAti)) {
				StringBuilder subS = new StringBuilder();
				subS = subS.append(SAti);
				for (int j = i+1; j < S.length(); j++) {
					char SAtj = S.charAt(j);
					if (judgeContains(SAtj)) {
						subS = subS.append(SAtj);
						continue;
					}
					break;
				}
				maxSub = subS.length() > maxSub.length() ? subS : maxSub;
			}
		}
		System.out.print(maxSub.length());
		scanner.close();
	}

	public static boolean judgeContains(char chr) {
		if (chr == a || chr == c || chr == g || chr == t) {
			return true;
		}
		return false;
	}
}

Measured memory_bytes: 23764
def digits_of(num)
  num.to_s.chars
end

def palindrome?(num)
  ds = digits_of(num)
  ds.size.times do |i|
    if ds[i] != ds[-(i + 1)]
      return false
    end
  end

  true
end

a, b = gets.split.map(&:to_i)

puts a.upto(b).count { |n| palindrome?(n) }


Measured memory_bytes: 1788
#include <stdio.h>

int main(void){

  int i, a[1000], n, v, j, k;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for(i = 1; i < n+1; i++){
    for(k = 0; k < n; k++){
      printf("%d", a[k]);
      if(k == n-1) printf("\n");
      else printf(" ");
    }
    v = a[i];
    j = i - 1;
    while((j >= 0) && (a[j] > v)){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    
  }
  return 0;
}

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

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

            string[] myArgs = Console.ReadLine().Split(' ');
            int numA = int.Parse(myArgs[0]);
            int numB = int.Parse(myArgs[1]);
            int result = 0;

            if(numA > numB && numB <= numA/2)
            {
                result = numA - (numB * 2);
            }
            Console.Write(result.ToString());
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
K = gets.to_i

N = 50
a = [*0...N].map { |n| n + K / N }

(K % N).times do |i|
  N.times do |j|
    if i == j
      a[j] += N
    else
      a[j] -= 1
    end
  end
end

puts N
puts a.join(' ')


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll x, y;
	cin >> x >> y;

	ll res = 0;
	while (x <= y) {
		x *= 2;
		res++;
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n; cin>>n;
    int a=0,b=0,c=0,d=0;
    while(n--)
    {
      string s; cin>>s;
      if(s=="AC")a++;
      if(s=="WA")b++;
      if(s=="TLE")c++;
      if(s=="RE")d++;
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d<<"\n";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main()
{
    // data (from stdin)
    int a,b,c,ans;
    int ab,bc,ca;
    std::cin >> a >> b >> c;
    ab = abs(a-b);
    bc = abs(b-c);
    ca = abs(c-a);
    if(ab + bc <= ab + ca && ab + bc <= bc + ca){ ans = ab + bc;}
    else if(ab + ca <= ab + bc && ab + ca <= bc + ca){ ans = ab + ca;}
    else { ans = bc + ca; }
    std::cout << ans << endl;
}



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

int main(){
	int n,x,t;
	cin>>n>>x>>t;
	int ans;
	if(n%x==0)
	    ans = (n/x)*t;
	else
	    ans = (n/x + 1)*t;
	cout<<ans<<endl;    
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


int main(){

    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    VSORT(a);
    ll count = 0;
    for(ll i = 0;i < n;i++){
        if(x-a[i] >= 0){
            count++;
            x-=a[i];
            if(x>0 && i == n-1){
                count--;
            }
        }
        if(x<a[i]){
            break;
        }
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
=end

def pair4(n)
  f=[]
  0.upto(9){|a|
    0.upto(9){|b|
      0.upto(9){|c|
        0.upto(9){|d|
          if a+b+c+d == n then
            f.push([a,b,c,d])
          end
        }
      }
    }
  }
  return f
end

while STDIN.gets do
  n = $_.to_i
  puts pair4(n).length
end

Measured memory_bytes: 8916
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
const ll INF=1000000000000LL;

int n,l;
ll a[100001];
bool used[100001];
priority_queue<P> pq;

void neighborSearch(int left,ll diff){
    if(!used[left]&&(left==0||a[left]>a[left-1])&&(left==n-1||a[left]>a[left+1])){
        used[left]=true;
        pq.push(P(a[left]-diff,left));
    }
}

int main(){
    cin>>n>>l;
    fill(used,used+100001,false);
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < n; i++)
        neighborSearch(i,0);
    ll diff=0;
    while(pq.size()){
        ll length=0;
        vector<int> nums;
        while(pq.size()){
            if(length==0||length==pq.top().first){
                if(length==0)
                    diff+=l-pq.top().first;
                l=pq.top().first;
                length=l;
                nums.push_back(pq.top().second);
                a[pq.top().second]=-INF;
                pq.pop();
            }
            else
                break;
        }
        for(int i = 0; i < nums.size(); i++){
            int left=nums[i]-1;
            int right=nums[i]+1;
            if(left>=0)
                neighborSearch(left,diff);
            if(right<n)
                neighborSearch(right,diff);
        }
    }
    cout<<diff<<endl;
    return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n;
  vl dis(n);
  
  rep(i,n) cin >> dis[i];
  
  sort(all(dis));
  
  cout << dis[n-1] - dis[0] << endl;
  
  
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
const ll mod = 1e9+7;

int main(){
	int n, a;
	cin >> n >> a;
	cout << (n+a-1)/a << endl;
}


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

const int mod = 1e9 + 7;

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

    int n; cin >> n;
    vector<int> t(n), a(n);
    rep(i, n) cin >> t[i];
    rep(i, n) cin >> a[i];

    if (t[0] > a[0]) {
        cout << 0 << endl;
        return 0;
    }
    else if (a[n - 1] > t[n - 1]) {
        cout << 0 << endl;
        return 0;
    }

    int tma = *max_element(t.begin(), t.end());
    int ama = *max_element(a.begin(), a.end());

    int sa = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == t[i]) {
            sa = a[i];
            break;
        }
    }

    if (tma != ama) {
        cout << 0 << endl;
        return 0;
    }
    if (sa != tma) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;

    int res_ma = t[0];
    int idx = -1;
    if (res_ma != tma) {
        for (int i = 1; i < n - 1; ++i) {
            if (t[i] > a[i]) {
                cout << 0 << endl;
                return 0;
            }
            if (t[i] == tma) {
                idx = i;
                break;
            }
            else if (res_ma < t[i]) {
                res_ma = t[i];
            }
            else {
                ans = (ans * res_ma)%mod;
            }
        }
    }
    else {
        idx = 0;
    }

    if (idx == -1) {
        idx = n+1;
    }

    res_ma = a[n - 1];
    int idx_2 = -1;
    if (res_ma != ama) {
        for (int i = n - 2; i > 0; --i) {
            if (a[i] == ama) {
                idx_2 = i;
                break;
            }
            else if (res_ma < a[i]) {
                res_ma = a[i];
            }
            else {
                ans = (ans * res_ma)%mod;
            }
        }
    }
    else {
        idx_2 = n-1;
    }

    for (int i = idx+1; i < idx_2; ++i) {
        ans = ans * (ama)%mod;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 1e3 + 15;
const ll MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1);
const double E = 2.718281828459045;
const int BLOCK = 2000;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod(x, m) ((x) % m + (x < 0 ? m: 0))

inline void IO() {
#ifdef buyolitsez
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}


template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}


inline void solve() {
    ll n, k;
    cin >> n >> k;
    ll ans = n - (n / k) * k;
    ans = min(ans, abs(ans - k));
    cout << ans;
}

signed main() {
    IO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

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

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

int main(void){
    long long int i, j, k, n, b, ans=1, po=0, po0=0;
    scanf("%lld", &n);
    long long int a[n];
    for(i=0; i<n; i++) scanf("%lld", &a[i]);
    for(i=0; i<n; i++){
        if(log10((double) ans)+log10((double) a[i])>18) po++;
        ans = ans*a[i];
        if(ans>1000000000000000000) po++;
        if(a[i] == 0) po0++;
    }
    if(po0>0) printf("0");
    else if(po>0) printf("-1");
    else printf("%lld", ans);
    
}

Measured memory_bytes: 3208
#include <iostream>

using namespace std;

int main()
{
    int a,b;
   float res1,res2,res3;
    cin>>a>>b;
    res1=a-b;
    res2=a+b;
    res3=a*b;
    if(res1>=res2&&res1>=res3)
        cout<<res1;
    else if(res2>=res1&&res2>=res3)
         cout<<res2;
    else  
        cout<<res3;
    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int a,b,c,x,y;cin>>a>>b>>c>>x>>y;){
		int res=INF;
		rep(i,max(x,y)+1)
			chmin(res,c*i*2+a*max(x-i,0)+b*max(y-i,0));
		cout<<res<<endl;
	}
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	cnt := 0
	for i := 0; i < 4; i++ {
		f := strings.Index(s, strings.Repeat("R", i))
		if f != -1 {
			cnt = i
		}
	}

	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        int A=0,W=0,T=0,R=0;
        String AC = new String("AC");
        String WA = new String("WA");
        String TLE = new String("TLE");
        String RE = new String("RE");
        Scanner scan = new Scanner(System.in);
        String txt = new String();
        int N = scan.nextInt();
        for(int i = 0;i < N;i++){
            txt = scan.next();
            if(txt.equals(AC)){
                A++;
            }else if(txt.equals(WA)){
                W++;
            }else if(txt.equals(TLE)){
                T++;
            }else if(txt.equals(RE)){
                R++;
            }
        }
        scan.close();
        System.out.println("AC x " + A);
        System.out.println("WA x " + W);
        System.out.println("TLE x " + T);
        System.out.println("RE x " + R);
    }
}

Measured memory_bytes: 58216
N,K=list(map(int, input().split()))
A=[]
d=[]
for _ in range(K):
  d_temp=int(input())
  A_temp=list(map(int, input().split()))
  
  d.append(d_temp)
  A.append(A_temp)


B=[0 for i in range(N)]

for j in A:
  for k in j:
    B[k-1]+=1
C=B.count(0)

print(C)

Measured memory_bytes: 9284
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<queue>
#include<set>
using namespace std;
using Data = pair<long long, vector<int> >;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef long long int ll;
const int mod = 1e9+7;

int main() {
    vector<long long> N(3);
    int K;
    for (int i = 0; i < 3; ++i) cin >> N[i]; cin >> K;
    vector<vector<long long> > v(3);
    for (int iter = 0; iter < 3; ++iter) {
        v[iter].resize(N[iter]);
        for (int i = 0; i < N[iter]; ++i) cin >> v[iter][i];
        sort(v[iter].begin(), v[iter].end(), greater<long long>());
    }
    priority_queue<Data> que;
    set<Data> se;
    que.push(Data(v[0][0] + v[1][0] + v[2][0], vector<int>({0, 0, 0})));
    for (int k = 0; k < K; ++k) {
        auto c = que.top();que.pop();
        cout << c.first << endl;
        
        for (int iter = 0; iter < 3; ++iter) {
            if (c.second[iter] + 1 < N[iter]) {
                long long sum = c.first - v[iter][c.second[iter]] + v[iter][c.second[iter] + 1];
                auto num = c.second; num[iter]++;
                auto d = Data(sum, num);
                
                if (!se.count(d)) se.insert(d), que.push(d);
            }
        }
    }
}


Measured memory_bytes: 1408
X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        prize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
else:
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=998244353;
vector<ll>zh[100010];
ll n,m,i,j,k,x,y,ans,hh,f[3][100010],fac[500010],sg[3][100010];
int main(){
	scanf("%lld",&n);
	fac[0]=1;
	hh=1000000000000000000%p;
	for(i=1;i<=n*3;i++)fac[i]=fac[i-1]*hh%p;
	for(k=0;k<3;k++){
		scanf("%lld",&m);
		for(i=1;i<=n;i++)zh[i].clear();
		for(i=1;i<=m;i++){
			scanf("%lld%lld",&x,&y);
			if(x>y)swap(x,y);
			zh[x].push_back(y);
		}
		for(i=n;i;i--){
			std::set<ll>mex;
			for(j=0;j<zh[i].size();j++)mex.insert(sg[k][zh[i][j]]);
			while(mex.count(sg[k][i]))sg[k][i]++;
			(f[k][sg[k][i]]+=fac[i])%=p;
		}
	}
	for(i=0;i<500;i++)
	 for(j=0;j<500;j++)ans=(ans+f[0][i]*f[1][j]%p*f[2][i^j])%p;
	printf("%lld",ans);
}
/*
观察转移公式，发现跟博弈游戏一样。。
orz 
*/

Measured memory_bytes: 14464
#include<iostream>
#include<iomanip>
#include<complex>
#include<cmath>
using namespace std;

#define F(I,J,N) for(int I=J;I<N;I++)

typedef complex<double> P;
//外積
double cross(P a,P b){
	return (real(a)*imag(b)-imag(a)*real(b));
}

int main(){
	int n,x,y;
	double ans;
	P *p;
	int cnt=1;
	while(cin>>n){
		if(n==0) break;
		ans=0;
		p=new P[n+1];
		F(i,0,n){
			cin>>x>>y;
			p[i]=P(x,y);
		}
		p[n]=p[0];
		F(i,0,n) ans+=cross(p[i],p[i+1]);
		cout<<setprecision(1)<<setiosflags(ios::fixed)<<cnt<<" "<<abs(ans/2)<<endl;
		cnt++;
		delete []p;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll h, w, k;std::cin >> h >> w >> k;
  vector<string> s(h);
  re(i, h) std::cin >> s[i];
  ll b = h + w;
  ll ans = 0;
  for(int i=0;i<(1<<b);i++){
    ll cnt = 0;
    for(int x=0;x<h;x++){
      for(int y=0;y<w;y++){
        if((i>>x)&1) continue;
        if((i>>(h+y))&1) continue;
        if(s[x][y]=='#') cnt++;
      }
    }
    if(cnt==k) ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double[] ary = new double[n];
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = 1.0 / a;
        }
        double ans = 0.0;
        for (double a : ary) {
            ans += a;
        }
        System.out.println(1.0 / ans);
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <random>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),l(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int res=1;
	l[0]=a[0];
	for(int i=1;i<n;i++){
		if(l[res-1]<a[i]){
			l[res]=a[i];
			res++;
		}
		else{
			auto it=lower_bound(l.begin(),l.begin()+res,a[i]);
			l[it-l.begin()]=a[i];
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 3604