akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define mod (ll)(1e9+7)
using namespace std;
ll big[2001];
ll big2[2001];
int a[2001];
ll n,k;
ll ans;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            if(a[j]<a[i]) big[i]++;
    for(int i=0;i<n;i++)
        for(int j=0;j<i;j++)
            if(a[j]<a[i]) big2[i]++;
    for(int i=0;i<n;i++){
        ans=(ans+big[i]*((k+1)*k/2%mod)%mod)%mod;
        ans=(ans+big2[i]*(k*(k-1)/2%mod)%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    int n;
    scanf("%d",&n);

    int p[50];
    for(int i=1; i<=n; i++){
        scanf("%d",&p[i]);
    }

    int cnt = 0;
    
    for(int i=1; i<=n; i++){
        if(p[i]!=i){
            cnt++;
        }
    }

    if(cnt==2 || cnt==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = input()
t = input()


flag = 0
right = 0
left = 0
up = 0
down = 0

for i in range(n):
    if s[i] == "R":
        right += 1
    if right >= w - sc + 1:
        flag = 1
        break
    if t[i] == "L" and -right < sc - 1:
        right -= 1


    if s[i] == "L":
        left += 1
    if left >= sc:
        flag = 1
        break
    if t[i] == "R" and -left < w - sc:
        left -= 1

    if s[i] == "U":
        up += 1
    if up >= sr:
        flag = 1
        break
    if t[i] == "D" and -up < h - sr:
        up -= 1

    if s[i] == "D":
        down += 1
    if down >= h - sr + 1:
        flag = 1
        break
    if t[i] == "U" and -down < sr - 1:
        down -= 1


if flag:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 49484
d, g = map(int, input().split())
p = [0]*d
c = [0]*d
for i in range(d):
  p[i], c[i] = map(int, input().split())
 
ans = 10**6

for i in range(2**d):
  cnt = 0
  sum = 0
  k = -1
  for j in range(d):
    if (i >> j) & 1:
      sum += (j+1)*100*p[j]+c[j]
      cnt += p[j]
    else:
      k = j
  if sum < g:
    s1 = 100 * (k + 1)
    need = (g - sum + s1 - 1) // s1
    if need >= p[k]:
      continue
    cnt += need
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;


int data[201];

bool ch(int n){
	int taro=0,hanako=0;
	for(int i=1;i<=2*n;i++){
		if(data[i]==1)taro++;
		if(data[i]==2)hanako++;
	}
	if(taro==0 || hanako==0)return false;
	else return true;
}
int main(){
	int n;
	while(cin>>n && n!=0){
		fill(data,data+201,2);
		for(int i=0;i<n;i++){
			int k;
			cin>>k;
			data[k]=1;
		}
		int t=1;
		while(ch(n)){
			for(int i=1;i<=2*n;i++){
				if(data[i]==t){
					data[i]=0;
					if(t==2)t=1;
					else t=2;
				}
				if(!ch(n))break;
			}
			if(t==2)t=1;
			else t=2;
		}
		
		int taro=0,hanako=0;
		for(int i=1;i<=2*n;i++){
			if(data[i]==2)taro++;
			if(data[i]==1)hanako++;
		}
		cout<<taro<<endl<<hanako<<endl;
	}
}

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

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;

		int* word = new int[N];
		for (int i = 0; i < N; i++) word[i] = i + 1; //まず0番目の単語を入れておく

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
			}
			else {
				bubblenum = bubblehist.rbegin()->second + 1;
				/*it = bubblehist.find(word[i] + 1);
				if (it != bubblehist.end()){
					bubblenum = it->second;
				}
				else{
					bubblenum = 0;
					for (int j = 0; j < i; j++){
						if (word[j] < word[i]) bubblenum++;
					}
				}*/
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			bubblehist.insert(--it, p);
			for (map<int, int>::iterator it2 = bubblehist.upper_bound(word[i]); it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}

		delete[] word;
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}

	delete[] factmodary;
	return 0;
}

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

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

    int cnt = 0;
    for (int i = A; i <= B; i++)
    {
        if (i % 10 == i / 10000)
        {
            if ((i % 100) / 10 == (i / 1000) % 10)
            {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
bit = [0]*60
ans = 0
mod = 10**9+7
for i in a:
    cnt = 1
    while i:
        bit[-cnt] += i%2
        i //= 2
        cnt += 1
for i in range(60):
    ans += (n-bit[-1-i])*bit[-1-i] * pow(2,i,mod)
print(ans%mod)

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

namespace ABC145A
{
  class Program
  {
    static void Main(string[] args)
    {
      int r, x;
      
      r = int.Parse(Console.ReadLine());
      
      x = r * r;
      
      Console.WriteLine(x);
      
      Console.ReadKey();
    }
  }
}

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

int main(){
int N;
  cin>>N;
  int A[N][2],B[N][2];
  for(int i=0;i<2;i++){
    for(int j=0;j<N;j++){
      cin>>A[j][i];
      B[j][i]=0;
    }
  }
  B[0][0]=A[0][0];
  B[0][1]=A[0][0]+A[0][1];
      for(int j=1;j<N;j++){
      B[j][0]=B[j-1][0]+A[j][0];
    }
        for(int j=1;j<N;j++){
      B[j][1]=max(B[j][0],B[j-1][1])+A[j][1];
    }
    cout<<B[N-1][1]<<endl;
}


Measured memory_bytes: 256
n = gets.to_i
i = 1
result = []

def check_num(x)
  return x % 3 == 0
end

def include3(x)
  return x % 10 == 3
end

i..n.times do
  x = i
  if check_num(x)
    result << i
    i += 1
    next
  end
  if include3(x)
    result << i
    i += 1
    next
  end
  x /= 10
  if (x) && include3(x)
    result << i
    i += 1
    next
  end
  x /= 10
  if (x) && include3(x)
    result << i
    i += 1
    next
  end
  x /= 10
  if (x) && include3(x)
    result << i
    i += 1
    next
  end
  x /= 10
  if (x) && include3(x)
    result << i
    i += 1
    next
  end
  i += 1
end

puts ' ' + result.join(' ')



Measured memory_bytes: 8872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define X first
#define Y second

string s, t;
int dp[3005][3005];
pair<int, int> pred[3005][3005];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j < t.size(); ++j) {
			if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1, pred[i + 1][j + 1] = {i, j};
			else {
				if (dp[i + 1][j] >= dp[i][j + 1]) dp[i + 1][j + 1] = dp[i + 1][j], pred[i + 1][j + 1] = {i + 1, j};
				else dp[i + 1][j + 1] = dp[i][j + 1], pred[i + 1][j + 1] = {i, j + 1};
			}
		}
	}
	string out = "";
	int i = s.size(), j = t.size();
	while(i != 0 && j != 0) {
		if (dp[i][j] != dp[pred[i][j].X][pred[i][j].Y]) out += s[i - 1];
		int p = i;
		i = pred[i][j].X;
		j = pred[p][j].Y;
	}
	reverse(out.begin(), out.end());
	cout << out << '\n';
    return 0;
}



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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a'||c == 'e'||c == 'i'||c == 'o'||c == 'u'){
    cout << "vowel"<< endl;
  }else{
    cout << "consonant"<< endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

const LL M = 1e9 + 7;
LL mul(LL a, LL b) { return a * b % M; }
int main() {
  LL n, m;
  cin >> n >> m;
  VEC<LL> A(n), B(m);
  REP(i, 0, n) { cin >> A[i]; }
  REP(i, 0, m) { cin >> B[i]; }
  sort(ALL(A), greater<int>());
  sort(ALL(B), greater<int>());
  REP(i, 0, n - 1) {
    if (A[i] == A[i + 1]) {
      cout << 0;
      return 0;
    }
  }
  REP(i, 0, m - 1) {
    if (B[i] == B[i + 1]) {
      cout << 0;
      return 0;
    }
  }
  A.push_back(-1);
  B.push_back(-1);

  LL ai = 0, bi = 0;
  LL ans = 1;
  for (int x = n * m; x > 0; --x) {
    if (A[ai] == x && B[bi] == x) {
      ++ai;
      ++bi;
    } else if (A[ai] == x) {
      ++ai;
      ans = mul(ans, bi);
    } else if (B[bi] == x) {
      ++bi;
      ans = mul(ans, ai);
    } else {
      ans = mul(ans, ai * bi - (n * m - x));
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> s1(n), s2(n);
    for(int i = 0; i < n; i++){
        cin >> s1[i];
    }
    for(int i = 0; i < n; i++){
        cin >> s2[i];
    }
    vector<int> s_v1(n),  s_v2(n);
    s_v1 = s1;
    s_v2 = s2;
    sort(s_v1.begin(), s_v1.end());
    sort(s_v2.begin(), s_v2.end());
    int a, b;
    int i = 0;
    int j = 0; 
    do{
        if(s_v1 == s1){
            a = i;
            break;
        }
        i++;
    }while(next_permutation(s_v1.begin(), s_v1.end()));

    do{
        if(s_v2 == s2){
            b = j;
            break;
        }
        j++;   
    }while(next_permutation(s_v2.begin(), s_v2.end()));
//    cout << a << b;
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>

using namespace std;

string input[4] = {"AC","WA","TLE","RE"};

int main(){
  int N=0;
  int M=sizeof(input)/sizeof(string);
  vector<int> S(M,0);
  cin >> N;
  for(int i=0;i<N;i++){
    string C;
    cin >> C;
    for(int i=0;i<M;i++){
      if(C==input[i]){
	S[i]++;
	break;
      }
    }
  }

  for(int i=0;i<M;i++){
    cout << input[i] << " x " << S[i] << endl;
  }    
}

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

int main(){
  int A,B;
  string S;
  cin >> A >> B >> S;
  for (int i=0;i<A;i++){
    if (S[i]<'0' or S[i]>'9'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(S[A]!='-'){
    cout << "No" << endl;
    return 0;
  }
  for (int i=A+1;i<A+B+1;i++){
    if (S[i]<'0' or S[i]>'9'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
 }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int x = (b - a) * (b - a + 1) / 2;
        System.out.println(x - b);
    }
}

Measured memory_bytes: 23124
# solution
import io
import math

data=int(input())

nim=list(map(int,input().split()))

mike=list(map(int,input().split()))

counter=0

for i in range(data):
	counter+=min(nim[i],mike[i])
	mike[i]=max(mike[i]-nim[i],0)
	counter+=min(nim[i+1],mike[i])
	nim[i+1]=max(0,nim[i+1]-mike[i])

print(counter)

Measured memory_bytes: 19244
import sys
input = sys.stdin.readline
INF = 10**20
MOD = 10**9 + 7
import numpy as np

def main():
    n,a,b = map(int,input().split())
    H = np.array([int(input()) for _ in range(n)])

    a -= b
    def ok(x): #x回の爆発で倒せるか
        list = (H - b * x + a - 1)//a
        return sum(list[list>0]) <=  x
    
    l = -1
    r = 10 ** 10
    while r - l > 1:
        mid = (r + l)//2
        if ok(mid):
            r = mid
        else:
            l = mid  
    print(r)

if __name__=='__main__':
    main()

Measured memory_bytes: 18948
#include <stdio.h>
#include<vector>
#include<math.h>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;





int main(){
	int A, X;
	scanf("%d%d", &X, &A);
	if (X < A) {
		printf("%d", 0);
	}else {
		printf("%d", 10);
	}
}

Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int L = in.nextInt();
      	double side = (double) L / 3;
        System.out.println(side * side * side);
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define lli long long
#define llmax LLONG_MAX   //ranges are defined in climits
#define llmin LLONG_MIN
#define imax INT_MAX
#define imin INT_MIN
#define pb push_back
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
  lli n;cin>>n;
  lli result=1,mod=1e9+7;
  vector<bool>prime(n+1,true);
  vector<lli>primes;
  for(lli p=2;p*p<=n;p++)
  {
    if(prime[p]==true)
    {
      for(lli i=p*2;i<=n;i+=p)
      {
        prime[i]=false;
      }
    }
  }
  for(int i=2;i<=n;i++)
    if(prime[i])  primes.pb(i);
  
  result=1;
  for(auto prime : primes)
  {
    lli exp=0,p=prime;
    while(p<=n)
    {
      exp += (n/p);
      exp%=mod;
      p*=prime;
    }
    exp%=mod;
    result*=(exp+1);
    result%=mod;
  }
  cout<<result;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> par;
vector<int> rankk;

void init(int n) {
  par.resize(n);
  rankk.resize(n);
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rankk[i] = 0;
  }
}

int root(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = root(par[x]);
  }
}

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;

  par[x] = y;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  init(n);

  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    unite(x, y);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (same(i, p[i] - 1)) {
      count++;
    }
  }

  cout << count << endl;
}

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

int main(void) {
    int N, M;
    cin >> N >> M;

    int a[10010] = {0};
    long sum = 0;

    for (int i=0; i<M; i++) {
        cin >> a[i];
        sum += a[i];
    }

    if (sum > N) cout << -1 << endl;
    else cout << N - sum << endl;

    return 0;
}

Measured memory_bytes: 3604
# coding:utf-8

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

S = input().rstrip('\n')
N = len(S)

if is_kaibun(S) and is_kaibun(S[:(N-1)//2]) and is_kaibun(S[(N+3)//2-1:]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
n,k = map(int,input().split())
a = list(map(int,input().split()))
lsn = a[:]
for _ in range(k):
  lsc = lsn[:]
  lsn = [0]*(n+1)
  for i in range(n):
    x = lsc[i]
    lsn[max(0,i-x)] += 1
    lsn[min(n,i+x+1)] -= 1
  for i in range(1,n+1):
    lsn[i] += lsn[i-1]
  if lsn.count(n) == n:
    break
print(*lsn[:n])

Measured memory_bytes: 129840
n, t = map(int, input().split())

for x in range(n+1):
    for y in range(n+1 -x):
        z = n - x - y
        if z < 0:
            z = 0
        if x*10000 + y*5000 + z*1000 == t:
            print(x, y , z)
            exit()

print("-1 -1 -1")

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << sz(mp) << endl;
}

Measured memory_bytes: 19196
A,B = [int(x) for x in input().split()]
S = input()
for i in range(A+B+1):
  if i==A and S[i]!="-":
    print("No")
    exit()
  if i!=A and (S[i]=="-" or int(S[i])>=10):
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 38256
from collections import deque
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]
d = deque()
for i in range(N):
    p = bisect.bisect_left(d, A[i])
    if p == 0:
        d.appendleft(A[i])
    else:
        d[p - 1] = A[i]
ans = len(d)
print(ans)

Measured memory_bytes: 8060
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
aa = 0
for i  in range(a+1):
    for j  in range(b+1): 
        for k  in range(c+1):
            aa = i * 500 + j * 100 + k * 50;
            if aa == x: ans += 1

print(ans)


Measured memory_bytes: 3060
#pragma GCC optmize ("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
typedef long double ld;
ll n, a, b;
inline void solve()
{

}
int main()
{
	spIO;
	cin >> n >> a >> b;
	cout << a * (n / (a + b)) + (n - n / (a + b) * (a + b) <= a ? n - n / (a + b) * (a + b) : a);
}

Measured memory_bytes: 256
def main():
    n = int(input())
    data = list(map(int, input().split()))

    if n == 1:
        print(data[0])
    else:
        result = [None] * n

        if n % 2 == 0:
            center = int(n / 2)
            for index, value in enumerate(data):
                if index % 2 == 0:
                    result[center + int(index / 2)] = value
                else:
                    result[center - int((index + 1) / 2)] = value
            print(" ".join(str(n) for n in result))
        else:
            center = int(n / 2)
            for index, value in enumerate(data):
                if index % 2 == 0:
                    result[center - int(index / 2)] = value
                else:
                    result[center + int((index + 1) / 2)] = value
            print(" ".join(str(n) for n in result))

if __name__ == '__main__':
    main()

Measured memory_bytes: 119380
n = int(input())
a = [int(val) for val in input().split(' ')]

# 左からn番目の初期値
check = 1
for i in range(n):
    # 同じなら壊さず次の数を探す
    if a[i] == check:
        check += 1
    # 違ったら壊す
    else:
        a[i] = 0

if a.count(0) == n:
    print(-1)
else:
    print(a.count(0))

Measured memory_bytes: 24744
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define M 1000000007
typedef long long ll;

ll fact(ll a){
	//a!を返す
	//a*a-1*a-2***1
	for(ll i = a-1;i>=1;i--){
		a = (a*i)%M;
	}
	return a;
}

int main(){
	ll n,m;
	cin >> n>>m;
	if (abs(n-m)>=2) {
		cout << "0" << endl;
	}
	else if (abs(n-m)==1) {
		ll ans = (fact(n)*fact(m))%M;
		cout << ans << endl;
	}
	else {
		ll ans = (fact(n)*fact(n)*2)%M;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const char* A = "AKIHABARA";

int main() {
  char S[64];
  scanf("%s", S);

  for (int u = 0; u < 16; ++u) {
    char P[64];
    int ps = 0;
    for (int i = 0, j = 0; A[i]; ++i) {
      if (A[i] == 'A') {
        if (u & (1 << j)) P[ps++] = 'A';
        ++j;
      } else {
        P[ps++] = A[i];
      }
    }
    P[ps] = 0;
    if (strcmp(S, P) == 0) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");

  return 0;
}


Measured memory_bytes: 256
// AtCoder ABC103: A - Task Scheduling Problem
// 2019.10.17 bal4u

#include <stdio.h>

int main()
{
	int a1, a2, a3, t;
	
	scanf("%d%d%d", &a1, &a2, &a3);
    if (a1 > a2) t = a1, a1 = a2, a2 = t;
    if (a2 > a3) t = a2, a2 = a3, a3 = t;
    if (a1 > a2) t = a1, a1 = a2, a2 = t;
    printf("%d\n", a3-a1);
	return 0;
}

Measured memory_bytes: 128
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ‘ ‘
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 1000;

int main(){
    
    int h,w,a,b;
    
    cin >> h>>w>>a>>b;
    
    
    
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i<=b&&j<=a)cout << 0;
            else if(j>=a&&i<=b)cout << 1;
            else if(i>=b&&j<=a)cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> ab(n);
	// iが行、座標first = a、second = b
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		ab.at(i) = make_pair(a, b);
	}
	vector<pair<int, int>> cd(m);
	// jが行、座標first = c、second = d
	rep(i, m)
	{
		int c, d;
		cin >> c >> d;
		cd.at(i) = make_pair(c, d);
	}
	rep(i, n)
	{
		int min_dist = abs(ab.at(i).first - cd.at(0).first) + abs(ab.at(i).second - cd.at(0).second);
		int checkpoint = 1;
		for (int j = 1; j < m; ++j) //0はmin_distでやってるから1スタート
		{
			int cur_dist = abs(ab.at(i).first - cd.at(j).first) + abs(ab.at(i).second - cd.at(j).second);
			if(min_dist > cur_dist) {
				min_dist = cur_dist;
				checkpoint = j + 1; //0スタートなので実際のチェックポイント番号は+1する
			}
		}
		cout << checkpoint << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	string S;
	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else if (S == "Rainy") {
		cout << "Sunny" << endl;
	}

}






Measured memory_bytes: 3484
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		boolean flg = true;
		for(int i=N-1;i>=1;i--) {
			if(flg==false) {
				break;
			}
			for(int j=i-1;j>=0;j--) {
				if(H[i]+2<=H[j]) {
					flg = false;
				}
			}
		}
		if(flg) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 59564
n = int(input())
x_L = list(map(int,input().split()))

a_L = list(sorted(x_L))

center_l = a_L[int(n/2)-1]
center_r = a_L[int(n/2)]

for i in x_L:
    if i <= center_l:
        print(center_r)
    elif i >= center_r:
        print(center_l)

    
    


Measured memory_bytes: 95316
#include <iostream>

using namespace std;

int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

int main() {
    int N;
    int i, j, k;
    int num;
    int c[sizeof(prime) / sizeof(int)] = {0};
    int ans = 0;
    int count3 = 0, count5 = 0, count15 = 0, count25 = 0, count75 = 0;

    cin >> N;

    for (j = 2; j <= N; j++) {
        i = 0;
        num = j;
        while (i < sizeof(prime) / sizeof(int)) {
            while (num % prime[i] == 0) {
                c[i]++;
                num = num / prime[i];
            }
            i++;
        }
    }
    // for (i = 0; i < sizeof(prime) / sizeof(int); i++) {
    //     cout << c[i] << endl;
    // }

    for (i = 0; i < sizeof(prime) / sizeof(int); i++) {
        if (c[i] >= 2) {
            count3++;
            if (c[i] >= 4) {
                count5++;
                if (c[i] >= 14) {
                    count15++;
                    if (c[i] >= 24) {
                        count25++;
                        if (c[i] >= 74) {
                            count75++;
                        }
                    }
                }
            }
        }
        else {
            break;
        }
    }

    ans += count75;
    ans += count25 * count3 - count25;
    ans += count15 * count5 - count15;
    ans += (count3 - count5) * (count5 * (count5 - 1)) / 2 + count5 * ((count5 - 1) * (count5 - 2)) / 2;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,M,f[MAXN],g[MAXN],ans[MAXN];
vector<int> G[MAXN];
void add_edge(ll u,ll v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}
void dfs(ll v,ll p)
{
    f[v]=1;
    vector<int> pre,suf;
    for(auto to:G[v])
    {
        if(to==p) continue;
        dfs(to,v);
        f[v]=1LL*f[v]*(f[to]+1)%M;
    }
    pre.clear();suf.clear();
    for(ll i=0;i<(int)G[v].size();i++)
    {
        ll to=G[v][i];
        if(to==p) continue;
        pre.push_back(f[to]+1); suf.push_back(f[to]+1);
    }
    ll sz=(int)pre.size();
    if(sz==0) return;
    if(sz==1)
    {
        for(auto to:G[v]) 
        {
            if(to==p) continue;
            else g[to]=1;
        }
        return;
    }
    for(ll i=1;i<sz;i++) pre[i]=1LL*pre[i-1]*pre[i]%M;
    for(ll i=sz-2;i>=0;i--) suf[i]=1LL*suf[i+1]*suf[i]%M;
    ll cnt=0;
    for(ll i=0;i<(int)G[v].size();i++)
    {
        ll to=G[v][i];
        if(to==p) continue;
        if(cnt==0) g[to]=suf[1]%M;
        else if(cnt==sz-1) g[to]=pre[sz-2]%M;
        else g[to]=1LL*pre[cnt-1]*suf[cnt+1]%M;
        cnt++;
    }
}
void dfs2(ll v,ll p)
{
    ans[v]=1LL*f[v]*(g[v]+1)%M;
    for(auto to:G[v])
    {
        if(to==p) continue;
        g[to]=1LL*g[to]*(g[v]+1)%M;
        dfs2(to,v);
    }
}
int main()
{
    scanf("%lld%lld",&n,&M);
    for(ll i=0;i<n-1;i++)
    {
        ll u,v;
        scanf("%lld%lld",&u,&v);add_edge(u,v);
    }
    dfs(1,0);
    g[1]=0;dfs2(1,0);
    for(ll i=1;i<=n;i++) printf("%lld\n",ans[i]%M);
    return 0;
}



Measured memory_bytes: 20352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define N (300000)
using namespace std;
int a[N],n,f[N],g[N],ans=0;
int main()
{
	scanf("%d",&n);
	for (int i=0; i<=(1<<n)-1; ++i)
		scanf("%d",&a[i]);
	for (int i=0; i<=(1<<n)-1; ++i)
	{
		int x=i;
		for(int j=x;true;)
		{
    		
			if (a[j]>=f[i]) g[i]=f[i],f[i]=a[j];
			else g[i]=max(g[i],a[j]);
			if(!j)break;
			j=(j-1)&x;
		}
	}
	for (int i=1; i<=(1<<n)-1; ++i)
	{
		ans=max(ans,g[i]+f[i]);
		cout<<ans<<endl;
	}
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M, C;
  cin >> N >> M >> C;
  llvec B(M);
  rep(i, M)cin >> B[i];
  ll ans = 0;
  rep(i, N){
    ll tmp = C;
    rep(j, M){
      ll a; cin >> a;
      tmp +=B[j]*a;
    }
    ans += (tmp>0)?1:0;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
const ll mod=1000000009;
const ll INF=(ll)1000000007*1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int N,M,X,Y; cin >> N >> M >> X >> Y;
  int x_max=-mod; int y_min=mod;
  rep(i,N){
    int x; cin >> x;
    if(x>x_max){
      x_max=x;
    }
  }
  rep(i,M){
    int y; cin >> y;
    if(y<y_min){
      y_min=y;
    }
  }
  if(X<x_max && x_max<y_min && y_min<=Y){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int func(int num) { return num % 2 == 0 ? num / 2 : 3 * num + 1; }
signed main()
{
	int s;
	cin >> s;
	vector<int>a;
	a.push_back(s);
	set<int>se;
	se.insert(s);
	int i = 0;
	while (1)
	{
		int num = se.size();
		a.push_back(func(a[i]));
		se.insert(func(a[i]));
		if (num == se.size())break;
		i++;
	}
	cout << i + 2;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=sc.nextInt();
		}
		Arrays.sort(arr);
		int count =0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				for(int k=j+1;k<n;k++) {
					if(arr[i]+arr[j]>arr[k]) {
						count++;
					}
					if(arr[i]+arr[j]<=arr[k]) {
						break;
					}
				}
			}
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 27236
N, K = map(int, input().split())
n=set(range(1,N+1))
d=[0]*K
A=[0]*K
Aset=set()

for i in range(K):
    d[i]=int(input())
    A[i]=list(map(int, input().split()))
    Aset.update(set(A[i]))
nA_dif=n-Aset
print(len(nA_dif))

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

int main(){
  int n, q, query, t, x;
  cin >> n >> q;
  vector<vector<int>> A(n);
  for(int i = 0; i < q; i++){
    cin >> query;
    if(query == 0){
      cin >> t >> x;
      A[t].push_back(x);
    }else if(query == 1){
      cin >> t;
      for(int i = 0; i < A[t].size(); i++){
        if(i > 0) cout << " ";
        cout << A[t][i];
      }
      cout << endl;
    }else{
      cin >> t;
      A[t].clear();
    }
  }
  return 0;
}


Measured memory_bytes: 5820
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, K = map(int, input().split())
print(N*K)




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

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

int main() {
    int N;
    cin >> N;
    vector<string> A(3);

    rep(i, 3) {
        cin >> A.at(i);
    }

    int sum = 0;
    rep(i, N) {
        if ((A.at(0).at(i) == A.at(1).at(i)) && (A.at(1).at(i) == A.at(2).at(i))) {
            ;
        }
        else if (A.at(0).at(i) == A.at(1).at(i))
            sum++;
        else if (A.at(1).at(i) == A.at(2).at(i))
            sum++;
        else if (A.at(0).at(i) == A.at(2).at(i))
            sum++;
        else
            sum += 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
package main

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

var counts = make([]int, 10000000+10)

func main() {
	N := nextInt()

	for i := 1; i < len(counts); i++ {
		for j := i; j < len(counts); j += i {
			counts[j]++
		}
	}

	s := int64(0)

	for i := 1; i <= N; i++ {
		s += int64(i) * int64(counts[i])
	}

	fmt.Println(s)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

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


Measured memory_bytes: 82540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;

	const int d = __builtin_popcount(a ^ b);
	if(d % 2 == 0){
		cout << "NO" << endl;
		return 0;
	}

	const int m = (1 << n);
	vector<int> r(m);
	for(int i = 0; i < m; ++i){
		r[i] = i ^ (i >> 1);
	}

	const int g = a ^ b;
	while(r.back() != g){
		const int last = r.back();
		int p = -1;
		for(int i = 0; i < m; ++i){
			if(r[i] == g){ break; }
			if(__builtin_popcount(last ^ r[i]) == 1){ p = i + 1; }
		}
		reverse(r.begin() + p, r.end());
	}

	cout << "YES" << endl;
	for(int i = 0; i < m; ++i){
		cout << (a ^ r[i]) << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	vector<LLPair> xy(n);
	vector<int> parm(n);
	rep(i, n){
		cin >> xy[i].first >> xy[i].second;
		parm[i] = i;
	}

	double ans = 0;
	do{
		for(int i=0; i<n-1; i++){
			double a = (double)(xy[parm[i]].first-xy[parm[i+1]].first) * (double)(xy[parm[i]].first-xy[parm[i+1]].first);
			double b = (double)(xy[parm[i]].second-xy[parm[i+1]].second) * (double)(xy[parm[i]].second-xy[parm[i+1]].second);
			ans += sqrt(a+b);
		}
	} while(next_permutation(ALL(parm)));
	
	for(int i=1; i<=n; i++){
		ans /=  i;
	}
	printf("%.10lf\n", ans);
	return 0;
}

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

int main(){
  int n, m; cin >> n >> m;
  priority_queue<int> qu;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    qu.push(a);
  }

  for(int i=m; i>0; i--){
    int b = qu.top() / 2;
    qu.pop();
    qu.push(b);
  }

  long long int ans = 0;
  while(!qu.empty()){
    ans += qu.top();
    qu.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<queue>
#include<map>
using namespace std;struct D{string s;int n;};main(){map<int,int>C;string s;int i,n,F;for(C[217]=98,C[201]='r',C[212]='g';cin>>s,s!="0";F?puts("NA"):printf("%d\n",n)){map<string,int>M;queue<D>q;D d={s,0};q.push(d);for(M[s]=1;q.size();){d=q.front();q.pop();s=d.s;n=d.n;for(i=F=0;++i<s.size();)if(s[i-1]-s[i]){D d={s,n+1};d.s[i-1]=d.s[i]=C[s[i-1]+s[i]];if(M.find(d.s)==M.end())q.push(d);F=M[d.s]=1;}if(!F)break;}}}

Measured memory_bytes: 0
n, m = map(int, input().split())
issafe = [True] * (n +1)
for _ in range(m):
    a = int(input())
    issafe[a] = False

dp = [0] * (n + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, n + 1):
    if  issafe[i - 1]:
        dp[i] = dp[i] + dp[i - 1]
    if issafe[i -  2]:
        dp[i] = dp[i - 2] + dp[i] 
    
    dp[i] %= 1000000007
    
print(dp[n])

Measured memory_bytes: 13560
import math
n = int(input())
anagram = {}
while n > 0:
    wordbef = list(input())
    wordbef.sort()
    word = "".join(wordbef)
    if word in anagram:
        anagram[word] = anagram[word] + 1
    else:
        anagram[word] = 1
    n -= 1
total = 0
for x in anagram:
    total += (anagram[x] * (anagram[x] - 1))/2
print(int(total))

Measured memory_bytes: 17932
#include <bits/stdc++.h>
#define INF 9e+18
using namespace std;

typedef long long ll;

int N, K;
int xy[55][2];
int x[55], y[55];

int f[60][60];
int dp[60][60];

ll ans = INF, area;

map<int, int> map_x, map_y, rmap_x, rmap_y;

void solve() {
    sort(x, x + N); // 制約より重複なし
    sort(y, y + N); // 制約より重複なし
    for (int i = 0; i < N; i++) {
        map_x[x[i]] = i + 1;
        map_y[y[i]] = i + 1;
        rmap_x[i + 1] = x[i];
        rmap_y[i + 1] = y[i];
    }
    for (int i = 0; i < N; i++) {
        int c_x = map_x[xy[i][0]];
        int c_y = map_y[xy[i][1]];
        f[c_y][c_x] = 1;
    }
    for (int i = 0; i < 55; i++) {
        for (int j = 0; j < 55; j++) {
            dp[i + 1][j + 1] = f[i + 1][j + 1] + dp[i][j + 1] + dp[i + 1][j] - dp[i][j];
        }
    }
    for (int a = 0; a < N; a++) {
        for (int b = a + 1; b < N; b++) {
            for (int c = 0; c < N; c++) {
                for (int d = c + 1; d < N; d++) {
                    int x1 = min(min(xy[a][0], xy[b][0]), min(xy[c][0], xy[d][0]));
                    int x2 = max(max(xy[a][0], xy[b][0]), max(xy[c][0], xy[d][0]));
                    int y1 = min(min(xy[a][1], xy[b][1]), min(xy[c][1], xy[d][1]));
                    int y2 = max(max(xy[a][1], xy[b][1]), max(xy[c][1], xy[d][1]));

                    int c_x1 = map_x[x1];
                    int c_x2 = map_x[x2];
                    int c_y1 = map_y[y1];
                    int c_y2 = map_y[y2];

                    ll area = ((ll)x2 - (ll)x1) * ((ll)y2 -(ll)y1);
                    int cnt = dp[c_y2][c_x2] - dp[c_y2][c_x1 - 1] - dp[c_y1 - 1][c_x2] + dp[c_y1 - 1][c_x1 - 1];

                    if (cnt >= K) {
                        ans = min(ans, area);
                    }
                }
            }
        }
    }
    #if 0
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    #endif

    cout << ans << endl;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> xy[i][0] >> xy[i][1];
        x[i] = xy[i][0];
        y[i] = xy[i][1];
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int t;
    string s;
    cin>>s;
    t=s.length();
    vector <int> final(t,-1);
    for(int i=0;i<t;i++){
        if(s[i]=='0'){
             final.push_back(0);
        }
        else if(s[i]=='1') final.push_back(1);
        else final.pop_back();
    }
    auto it=final.begin();
    for(;*it==-1;it++){}
    for(;it!=final.end();it++){
        cout<<*it;
    }
    cout<<endl;
    

    return 0;
}


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

int N, M, L, R, A[1 << 18];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> L >> R;
		A[L]++; A[R + 1]--;
	}
	for (int i = 1; i <= N + 1; i++) A[i] += A[i - 1];
	
	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (A[i] == M) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int main() {
  // な
  // 　な　た
  // 　　めて
  // 　よこまるた
  // 　　　るる
  // 　　　た　た

  int N, A[1000];
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      if(abs(A[i] - A[j]) % (N - 1) == 0) {
        cout << A[i] << " " << A[j] << endl;
        return (0);
      }
    }
  }
}


Measured memory_bytes: 3104
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}



Measured memory_bytes: 3292
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

const ll MOD = 2019;

int main(void) {
  ll l, r;
  cin >> l >> r;
  r = min(l + MOD*2, r);
  ll res = MOD;
  for(ll j = l; j <= r; ++j) {
    for(ll i = l; i < j; ++i) {
      res = min(res, i*j%MOD);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
import sys
input = sys.stdin.readline

A,B,K = list(map(int,input().split()))
num_lis = []
for i in range(A,A+K):
    if i <= B:
        num_lis.append(i)
    else:
        break
    
for i in range(B,B-K,-1):
    if i>= A:
        num_lis.append(i)
    else:
        break
b = sorted(list(set(num_lis)))

for i in range(len(b)):
    print(b[i])


Measured memory_bytes: 9188
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

idx = 0
for i in range(N):
	if idx+1 == A[i]:
		idx += 1
if idx == 0:
	print(-1)
else:
	print(N-idx)


Measured memory_bytes: 70988
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    var array = arrayOfNulls<Int>(3)

    for (i in array.indices) {
        array[i]= sc.nextInt()
    }

    if (array[0]!! + array[1]!! == array[2]!! ||
            array[0]!! + array[2]!! == array[1]!! ||
            array[1]!! + array[2]!! == array[0]!!) {
        println("Yes")
    } else {
        println("No")
    }
}

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

int main(){
 double r;
 cin >> r;

 double area, cirumference;
 double pi = 3.141592653589;
 area = r*r*pi;
 cirumference = 2*r*pi;

 cout << fixed << setprecision(6) << area << " " << fixed << setprecision(6) << cirumference << endl;

 return 0;
}


Measured memory_bytes: 3244
import std.stdio;
import std.string;
import std.range;
import std.conv;

void main()
{
	/*auto N = readln.chomp.to!int;
	auto D = readln.chomp.to!int;
	*/
	auto ip = readln.split.to!(int[]), D = ip[0], N = ip[1];
	if(N==100){
		writeln(101*100^^D);
	}else{
		writeln(100^^D*N);
	}
}

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    FAST;
    int h,w;
    string str;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        cin>>str;
        cout<<str<<endl<<str<<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() 
{
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if(r <= x && x <= w-r && r <= y && y <= h-r){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3136
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int n,m;
      cin>>n>>m;
      int cnt[m];
      fill(cnt,cnt+m,0);
      rep0(i,n){
            int k;
            cin>>k;
            rep0(j,k){
                  int a;
                  cin>>a;
                  a--;
                  cnt[a]++;
            }
      }
      int cc;
      cc=0;
      rep0(i,m){
            if(cnt[i]==n){
                  cc++;
            }
      }
      cout<<cc<<endl;
      return 0;
}

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

for i in range(2**3):
    status=[0]*3
    s=""
    for j in range(3):
        if ((i>>j)&1):
            status[j]="+"
        else:
            status[j]="-"
    for x,y in zip(a,status):
        s+=x
        s+=y
    s+=a[-1]
    if eval(s)==7:
        print(s+"=7")
        exit()

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;
int main(){ int W,H,x,y,r; 
 
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
if((x >= r && x <= W-r) && (y >= r && y <= H-r)) printf("Yes\n");
 
else{ printf("No\n"); 
     
}
} 


Measured memory_bytes: 2692