akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private int N;
    private int A;
    private int B;
    private long[] v;

    private long count;

    private void solve(Scanner sc) {
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        v = new long[N];
        for (int i = 0; i < N; ++i) {
            v[i] = sc.nextLong();
        }
        Arrays.sort(v);
        for (int i = 0; i < N / 2; ++i) {
            long t = v[i];
            v[i] = v[N - i - 1];
            v[N - i - 1] = t;
        }

        double avg = avg(v, 0, A - 1);
        long count;
        if (v[0] != v[A - 1]) {
            int x = 0;
            for (int i = 0; i < N; ++i) {
                if (v[A - 1] == v[i]) {
                    ++x;
                }
            }
            int y = 0;
            for (int i = 0; i < A; ++i) {
                if (v[A - 1] == v[i]) {
                    ++y;
                }
            }
            count = C(x, y).longValue();
        } else {
            int x = 0;
            for (int i = 0; i < N; ++i) {
                if (v[0] == v[i]) {
                    ++x;
                }
            }
            count = 0;
            for (int i = A; i <= B; ++i) {
                count += C(x, i).longValue();
            }
        }

        _out.printf("%.6f%n", avg);
        _out.println(count);
    }
    private double avg(long[] ary, int from, int to) {
        long sum = 0;
        for (int i = from; i <= to; ++i) {
            sum += ary[i];
        }
        return 1d * sum / (to - from + 1);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<stdio.h>
#define MAX 20000000
using namespace std;

int n, p, H;
int T[MAX + 1] = {-1};

void insert(int num) {
	if (num == 1) {
		return;
	}
	p = H/2;
	while (T[p] < T[num] && p!=0) {
		swap(T[p], T[num]);
		num = p;
		p = p/2;
	}
	return;
	
}

void extract() {
	cout << T[1] << endl;
	T[1] = T[H];
	T[H] = -1;
	H--;
	if (H == 0) {
		T[0] = -1;
		return;
	}
	int now = 1;
	while (T[now*2] > T[now] || T[now * 2+1] > T[now]) {
		if (T[now * 2] > T[now * 2 + 1]) {
			swap(T[now * 2], T[now]);
			now = now * 2;
		}
		else if (T[now * 2] <= T[now * 2 + 1]) {
			swap(T[now * 2+1], T[now]);
			now = now * 2+1;
		}
	}
	return;
}

int main() {
	string com;
	H = 0;
	while (1) {
		cin >> com;
		if (com == "insert") {
			H++;
			cin >> T[H];
			insert(H);
		}
		else if (com == "extract") {
			extract();
		}
		else {
			break;
		}
	}
}



Measured memory_bytes: 11004
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=h//2*(w//2)
c=h%2and w%2
b=(h*w-a*4-c)//2
for i in set(s.replace('\n','')):
  i=s.count(i)
  while i>3and a:
    i-=4
    a-=1
  while i>1and b:
    i-=2
    b-=1
  if i and c:
    i-=1
    c-=1
print('YNeos'[any(t for t in(a,b,c))::2])

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

int n, m;
string g[1000];
string h[2];

int check(int r, int c)
{
	if (r < 0 || n <= r + 1) return 0;
	if (c < 0 || m <= c + 1) return 0;
	return g[r][c] == h[0][0]
		&& g[r + 1][c] == h[1][0]
		&& g[r][c + 1] == h[0][1]
		&& g[r + 1][c + 1] == h[1][1];
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> g[i];
	}
	cin >> h[0] >> h[1];

	int c = 0;
	for (int i = 0; i < n - 1; i++){
		for (int j = 0; j < m - 1; j++){
			c += check(i, j);
		}
	}
	
	int res = c;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			for (int k = 0; k < 3; k++){
				int t = c;
				char ct = g[i][j];
				for (int dx = -1; dx < 1; dx++){
					for (int dy = -1; dy < 1; dy++){
						t -= check(i + dx, j + dy);
					}
				}
				g[i][j] = "JOI"[k];
				for (int dx = -1; dx < 1; dx++){
					for (int dy = -1; dy < 1; dy++){
						t += check(i + dx, j + dy);
					}
				}
				res = max(res, t);
				g[i][j] = ct;
			}
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n; cin >> n;
  std::cout << n*n << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s, t; cin >> s >> t;
  int n = s.size();

  bool ok = false;
  rep(i, n){
    if(s == t){
      ok = true;
      break;
    }
    s = s.back() + s.substr(0, n-1);
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;



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

	int N, M;
	cin >> N >> M;
	vector<pair<int,int>> pa(M);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		pa[i] = { b,a };
	}
	sort(pa.begin(), pa.end());
	int right = 0;
	int res = 0;
	REP(i, M) {
		if (pa[i].second >= right) {
			right = pa[i].first;
			res++;
		}
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define INF 2000000000
#define N 1002
using namespace std;
int StoI(string);

int main(){
  int n,d[N],flag,minv,maxv,cnt;
  string a[N];
  while(1){
    cin>>n;
    if(!n) break;
    flag=0;
    for(int i=1;i<=n;i++){
      cin>>a[i];
      if(a[i]=="x") continue;
      d[i]=StoI(a[i]);
    }
    for(int i=1;i<n;i++)
      if(a[i]=="x"&&a[i+1]=="x") flag=1;
    for(int i=1;i<n;i++){
      if(a[i]=="x"||a[i+1]=="x") continue;
      if((i%2)&&d[i]>=d[i+1]) flag=1;
      else if(!(i%2)&&d[i]<=d[i+1]) flag=1;
    }
    if(!flag){
      d[0]=maxv=INF;
      minv=-INF;
      (n%2)?d[n+1]=INF:d[n+1]=-INF;
      for(int i=1;i<=n;i++){
	if(a[i]!="x") continue;
	if((i%2)&&(d[i-1]<=maxv||maxv>=d[i+1])) maxv=min(min(maxv,d[i-1]-1),d[i+1]-1);
	else if(!(i%2)&&(d[i-1]>=minv||minv<=d[i+1])) minv=max(max(minv,d[i-1]+1),d[i+1]+1);
      }
    }
    if(flag||maxv<minv) cout<<"none"<<endl;
    else if(maxv==minv) cout<<maxv<<endl;
    else cout<<"ambiguous"<<endl;
  }
  return 0;
}

int StoI(string s){
  int ret=0,k=0;
  if(s[0]=='-') k++; 
  for(int i=k;i<(int)s.size();i++) ret=ret*10+(s[i]-'0');
  if(k) ret*=-1;
  return ret;
}

Measured memory_bytes: 1292
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int mod = 998244353;
const int maxn = 3005;
ll dp[maxn][maxn][3],a[maxn];
int main(int argc, char const *argv[])
{
	ll n,S;
	cin>>n>>S;
	for(int i = 0;i < n; ++i)
	{
		scanf("%lld",&a[i]);
	}
	dp[0][0][0] = 1;
	for(int i = 0;i < n; ++i)
	{
		for(int j = 0;j <= S; ++j)
		{
			(dp[i + 1][j][0] += dp[i][j][0]) %= mod;
			(dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
			(dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
			if(j + a[i] <= S)
			{
				(dp[i + 1][j + a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
				(dp[i + 1][j + a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
			}
		}
	}
	printf("%lld\n",dp[n][S][2]);
	return 0;
}

Measured memory_bytes: 211584
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int co = 0;
	while(n > 0) {
		co++;
		n /= k;
	}
	cout << co;
	return 0;
}


Measured memory_bytes: 256
# abc114_a.py
# https://atcoder.jp/contests/abc114/tasks/abc114_a

# A - 753 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 七五三とは、7歳、5 歳そして 3歳の子どもの成長を祝うとある国の行事です。
# いま、高橋くんは X歳です。今回の七五三で、高橋くんの成長は祝われるでしょうか？

# 制約
#     1≤X≤9
#     Xは整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# X


# 出力
# 高橋くんの成長が祝われるなら YES, 祝われないなら NO と出力せよ。

# 入力例 1
# 5

# 出力例 1
# YES

# 5歳の子どもの成長は祝われます。

# 入力例 2
# 6

# 出力例 2
# NO

# また来年。


def calculation(lines):
    X = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    if X in [3, 5, 7]:
        return ['YES']
    else:
        return ['NO']


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5']
        lines_export = ['YES']
    if pattern == 2:
        lines_input = ['6']
        lines_export = ['NO']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
n = int(input())

print(((10 ** n) % (10 ** 9 + 7) - (9 ** n) % (10 ** 9 + 7) - (9 ** n) % (10 ** 9 + 7) + (8 ** n) % (10 ** 9 + 7)) % (10 ** 9 + 7))


Measured memory_bytes: 10688
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int h[n];
	rep(i, n) scanf("%d", &h[i]);
	vector<vector<int>> path(n);
	rep(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	int ans = 0;
	rep(i, n) {
		int cnt = 0;
		if (path[i].size() == 0)
			ans++;
		else {
			for (auto p : path[i]) {
				if (h[i] <= h[p]) cnt++;
			}
			if (!cnt) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;									//XD
#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
//#define kill(x) {cout<<x; return;}
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);         
#endif
}

const int mod = 1e9+7;
const int maxn = 2e3+5;
int h[maxn]={};
void solve(){
	int n, m, k; cin>>n>>m>>k;
	vi a(n), b(m);
	stack <int> p, q;
	rep(i, 0, n){
		cin>>a[i]; if(i) a[i] += a[i-1];
	}
	rep(i, 0, m){
		cin>>b[i]; if(i) b[i] += b[i-1];
	}
	int ans = 0;
	rep(i, 0, n){
		int z = k-a[i];
		if(z >= 0){
			int r = upper_bound(all(b), z)-b.begin();
			ans = max(ans, r+i+1);
		}else
			break;
		
	}
    int r = upper_bound(all(b), k)-b.begin();
    ans = max(ans, r);
	cout<<ans;
}
signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); io();
    //cout<<setprecision(100);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }

    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif

    return 0;
}



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

int main(){
  long long i,n,m;
  scanf("%lld %lld",&n,&m);

  if(n==1){
    if(m==1){
      printf("1");
      return 0;
    }else if(m==2){
      printf("0");
      return 0;
    }else{
      printf("%lld",m-2);
      return 0;
    }
  }
  if(m==1){
    printf("%lld",n-2);
    return 0;
  }
  if(m==2||n==2){
    printf("0");
    return 0;
  }
  printf("%lld",m*n-2*(m+n)+4);
  return 0;
}


Measured memory_bytes: 256
until (num = gets.chomp.to_i) == 0 
team = Hash::new
list = Array.new
num.times do
   temp = gets.chomp.split.map &:to_i
   team.store(temp[0],temp[1]*60 + temp[2]+ temp[3]*60 + temp[4]+ temp[5]*60 + temp[6] + temp[7]*60 + temp[8])
end
list = team.sort {|a,b| a[1]<=>b[1]}  
p list[0][0],list[1][0],list[num-2][0]
end

Measured memory_bytes: 6376
#include "bits/stdc++.h"
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int>A(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    long long check = sum / (4 * M);
    if (sum % (4 * M) != 0) check++;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (A.at(i) >= check) ans++;
    }
    if (ans >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int n;
    cin >> n;
    map<char,int> m;
    for(int i=0;i<n;i++){
        char c;
        cin >> c;
        m[c]++;
    }
    if(m.size() == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
}

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

int n;
const int MAX = 2000000;

void maxHeapify(int *A,int i){
    int l = 2 * i, r = 2 * i + 1, largest;
    if(l <= n && A[l-1] > A[i-1]) largest = l;
    else largest = i;
    if(r <= n && A[r-1] > A[largest-1]) largest = r;
    if(largest != i){
        swap(A[i-1], A[largest-1]);
        maxHeapify(A, largest);
    }
}

void heapIncreaseKey(int *A, int i, int key){
    if(key < A[i-1]){
        printf("Exception: the new key is smaller than the present key.");
        return;
    }
    A[i-1] = key;
    while(i > 1 && A[i/2-1] < A[i-1]){
        swap(A[i/2-1], A[i-1]);
        i = i/2;
    }
}

void maxHeapInsert(int *A, int key){
    A[n++] = -1;
    heapIncreaseKey(A, n, key);
}

int heapExtractMax(int *A){
    if(n < 1){
        printf("Exception: Heap Under Flow");
    } else {
        int max = A[0];
        A[0] = A[--n];
        maxHeapify(A, 1);
        return max;
    }
}

int main(){
    static int A[MAX];
    n = 0;
    char str[10];
    while(scanf("%s",str)){
        if(str[0] == 'e' && str[1] == 'n') break;
        else if(str[0] == 'i'){
            int a;
            scanf("%d",&a);
            maxHeapInsert(A, a);
        } else printf("%d\n",heapExtractMax(A));
    }
}

Measured memory_bytes: 4800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();

			long ret = 0;
			long min = Long.MAX_VALUE;
			boolean zero = false;
			boolean plus = true;
			for (int i = 0; i < N; i++) {
				long a = s.nextLong();
				if (a < 0) {
					plus = !plus;
				} else if (a == 0) {
					zero = true;
				}

				ret += Math.abs(a);
				min = Math.min(min, Math.abs(a));
			}
			if (!zero && !plus) {
				ret = ret - min * 2;
			}
			System.out.println(ret);
		}
	}
}


Measured memory_bytes: 48176
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  vvi side = {{2,4,5,3}, {1,3,6,4}, {1,5,6,2}, {1,2,6,5}, {1,4,6,3}, {3,5,4,2}};
  vvi right(6, vi(6, 0));
  vector<vector<vector<pii> > > sides_t_f(6, vector<vector<pii>>(6));
  for(int i = 0; i < 6; i++){
    for(int j = 0; j < 6; j++){
      int t = -1;
      for(int l = 0; l < 4; l++){
        if(side[i][l] == j+1) t = l;
      }
      if(t == -1) continue;
      for(int k = 0; k < 4; k++, t++){
        sides_t_f[i][j].push_back({side[i][t%4], (k+2)%4});
      }
      sort(sides_t_f[i][j].begin(), sides_t_f[i][j].end(), greater<pii>());
    }
  }

  int n;
  while(cin >> n && n){
    vi ans(6, 0);
    vector< vector<pair<int, int> > > table(199, vector<pair<int, int> >(199, {-1, 0}));
    for(int i = 0; i < n; i++){
      int t, f;
      cin >> t >> f;
      t--, f--;
      int nowx = 100, nowy = 100;
      bool flag = true;
      while(flag){
        flag = false;
        // cout <<"t,f: " <<  t+1 << ' ' << f+1 << endl;
        for(int j = 0; j < 4; j++){
          int s = sides_t_f[t][f][j].first, d = sides_t_f[t][f][j].second;
          if(s < 4) continue;
          int nexty = nowy + f_dir[0][d], nextx = nowx + f_dir[1][d];
          if(table[nexty][nextx].second < table[nowy][nowx].second){
            if(d == 0){
              int a = f;
              f = 5 - t;
              t = a;
              nowy = nexty, nowx = nextx;
              flag = true;
              break;
            }
            else if(d == 1){
              t = 5 - (s-1);
              nowy = nexty, nowx = nextx;
              flag = true;
              break;
            }
            else if(d == 2){
              int a = f;
              f = t;
              t = 5 - a;
              nowy = nexty, nowx = nextx;
              flag = true;
              break;
            }
            else if(d == 3){
              t = 5 - (s-1);
              nowy = nexty, nowx = nextx;
              flag = true;
              break;
            }
          }
        }
        // cout << i << ' ' << nowy << ' ' << nowx << endl;
      }
      table[nowy][nowx].first = t;
      table[nowy][nowx].second++;
    }

    for(int i = 0; i < 199; i++){
      for(int j = 0; j < 199; j++){
        // cout << '{' << table[i][j].first+1 << ',' << table[i][j].second << '}' << ' ';
        if(table[i][j].first >= 0)ans[table[i][j].first]++;
      }
      // cout << endl;
    }
    for(int i = 0; i < 5; i++) cout << ans[i] << ' ';
    cout << ans[5] << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n = 1, x, cnt = 1;
	string s;
	if ( cin >> n >> x );
	else return false;
	
	vcL num( n, 0 );
	
	lli _min = INT_MAX, _max = 0;
	
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
		x -= num[i];
		if ( x >= 0 ) cnt++ ;
	}
	
	cout << cnt << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}



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

using namespace std; 
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin >> s;
	if(s=="SUN"){
		cout << 7 << endl;
	}
	else if(s=="SAT"){
		cout << 1 << endl;
	}
	else if(s[0]=='M'){
		cout << 6 << endl;
	}
	else if(s=="THU"){
		cout << 3 << endl;
	}
	else if(s[0]=='T'){
		cout << 5 << endl;
	}
	else if(s[0]=='W'){
		cout << 4 << endl;
	}
	else{
		cout << 2 << endl;
	}
}


Measured memory_bytes: 3580
#include<iostream>
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
using namespace std;

int cnt;
int L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(int S[], int left, int mid, int right)
{
	int n1, n2, i = 0, j = 0;

	n1 = mid - left;
	n2 = right - mid;

	for (i = 0; i < n1; i++) {
		L[i] = S[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = S[mid + i];
	}

	L[n1] = R[n2] = SENTINEL;
	
	i=0;

	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			S[k] = L[i++];
		}
		else {
			S[k] = R[j++];
		}
	}
}

void mergesort(int S[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergesort(S, left, mid);
		mergesort(S, mid, right);
		merge(S, left, mid, right);
	}
}

int main()
{
	int n, S[MAX];

	cnt = 0;

	scanf("%d", &n);

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

	mergesort(S, 0, n);

	for (int i = 0; i < n; i++) {
		if (i)  cout << " ";
		cout << S[i];
	}
	cout << endl;
	cout << cnt << endl;

	return 0;

}


Measured memory_bytes: 7140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll q, h, s, d; cin >> q >> h >> s >> d;
  ll n; cin >> n;
  ll ans = min({8 * q, 4 * h, 2 * s, d}) * (n / 2);
  n %= 2;
  if (n == 1) outl(ans + min({4 * q, 2 * h, s}));
  else outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
S=input()
if S[0]!="A":
  print("WA")
  exit()
if "C" not in list(S[2:-1]):
  print("WA")
  exit()
S=list(S)
ans=0
for i in S:
  if i.islower()==True:
    ans+=1
if ans!=(len(S)-2):
  print("WA")
  exit()
print("AC")

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	cin >> n;

	vector<ll> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	vector<ll> b(n);

	REP(i, n) {
		cin >> b[i];
	}

	vector<ll> v(n);
	vector<ll> vv(n);
	ll sum = 0;

	REP(i, n) {
		v[i] = a[i] - b[i];
		sum += v[i];
	}

	if (sum < 0) {
		cout << -1 << endl;
		return 0;
	}

	sort(v.begin(), v.end());

	sum = 0;
	ll ans = 0;

	REP(i, n) {
		if (v[i] >= 0) {
			break;
		}
		sum += v[i];
		ans++;
	}

	RREP(i, n) {
		if (sum >= 0) {
			break;
		}
		sum += v[i];
		ans++;
	}

	cout << ans << endl;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> grid;

const int INF = 1e9;
const int dx[6] = {0,1,1,1,0,-1}, dy[6] = {-1,-1,0,1,1,0};
int h,w;

grid bfs(int y, int x){
  grid res(h,vi(w,INF));
  res[y][x] = 0;
  queue<int> q;
  q.push(y*w+x);
  
  while(q.size()){
    y = q.front()/w; x = q.front()%w; q.pop();
    int c = res[y][x];

    for(int i=0;i<6;i++){
      int ny = y+dy[i], nx = x+dx[i] + ((y%2==0 && i%3!=2)?-1:0);
      if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
      if(res[ny][nx]>c+1){
	res[ny][nx] = c+1;
	q.push(ny*w+nx);
      }
    }
  }
  return res;
}

int main(){
  while(cin >> w >> h, w){
    grid g(h,vi(w,INF));

    int s;
    cin >> s;
    for(int z=0;z<s;z++){
      int a,b; cin >> a >> b; a--; b--;
      grid tmp = bfs(b,a);

      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)g[i][j] = min(g[i][j], tmp[i][j]);
      }
    }

    int t, res = 0;
    cin >> t;
    for(int z=0;z<t;z++){
      int a,b; cin >> a >> b; a--; b--;
      grid tmp = bfs(b,a);
      int cover = 0;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  if(g[i][j] > tmp[i][j])cover++;
	}
      }
      res = max(res, cover);
    }
    
    cout << res << endl;
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

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

  ll k;
  cin >> k;

  ll ans = 0;
  FOR(i, 1, k + 1) {
    FOR(j, 1, k + 1) {
      ll res = gcd(i, j);
      FOR(l, 1, k + 1) {
        ans += gcd(res, l);
      }
    }
  }
  cout << ans << endl;


  

  
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)

#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;



using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,x,w,y,xcmp,ycmp,sum=0,xx,yy,black=0;

string s[100],qq;

vector<int> z;


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

bool mem[55][55];

int aa(){
	queue<pair<pair<int, int>,int>> que;
	que.push(pair<pair<int,int>,int>(pair<int,int>(0, 0), 1));
	while (!que.empty()) {
		pair<pair<int,int>,int> p=que.front(); que.pop();
		if (p.first.first==h - 1 && p.first.second==w - 1) return p.second;
		rep(i, 4) {
			int nx = p.first.second + dx[i], ny = p.first.first + dy[i];
			if (nx<0 || nx>=w || ny<0 || ny>=h || mem[ny][nx] || s[ny][nx]=='#') continue;
			mem[ny][nx] = true;
			que.push(pair<pair<int,int>,int>(pair<int,int>(ny,nx), p.second + 1));
		}
	}
}

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

       cin >> h >> w;
       rep(i,h){
        cin >> s[i];
        rep(j,w){
            if(s[i][j]=='#'){
                black++;
            }
        }
       }
       long long int cmp=aa();
       if(mem[h-1][w-1]){
           Cout(h*w-black-cmp);
       }
       else{
           Cout(-1);
       }
       
return 0;
}


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

int main(){
   int n,m;
   string s;
   cin >> n >> m;
   vector<int> h(n);
   rep(i,n) cin >> h[i];
   vector<vector<int>> g(n);
   rep(i,m){
      int a,b;
      cin >> a >> b;
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
   }
   int ans = 0;
   rep(i,n){
      if (g[i].size() == 0) ans++;
      else{
         bool f = true;
         for (auto nx:g[i]){
            if ( h[nx] >= h[i]) {
               f = false;
               break;
            }
         }
         if (f) ans++;
      }
      //printf("i %d ans = %d\n",i+1,ans);
   }
   cout << ans << endl;

   
   return 0;

}


Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	ini(a,b,c);
	if(a == b and b == c){
		out("No");
	}
	else if(a == b or a == c or b == c){
		out("Yes");
	}
	else{
		out("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,a;
  cin >> n >> a;

  cout << (max(n,a)<=8?"Yay!":":(") << endl;
  return 0;
}

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

int main()
{
    int H, W;

    cin >> H >> W;

    //#で初期化された配列
    string def = string(W + 2, '#');
    vector<string> pic(H + 2, def);

    for(int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            char c;
            cin >> c;
            pic.at(i).at(j) = c;
        }
    }
    for (int i = 0; i < H + 2; i++)
    {
        cout << pic.at(i) << endl;
    }
    
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define inf 1e16 + 1
#define ll long long
#define mm 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>

#define show(x) cout<<#x<<" "<<x<<'\n'
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int main()
{
    iosbase;
    int r;
    cin>>r;
    int ans=(int)pow(r,2);
    cout<<ans*3<<'\n';
    return 0;
}

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

using namespace std;

int main(){
    int N;
    int h[110];

    cin >> N;
    for(int i = 0; i < N; i++) cin >> h[i];

    int max_val = *max_element(h, h + N);    

    int ans = 0;

    int pre_exist = 0;

    for(int ih = 1; ih <= max_val; ih++){
        pre_exist = 0;
        for(int i = 0; i < N; i++){
            if(h[i] >= ih && pre_exist == 0) {
                ans++;
                pre_exist = 1;
            }
            if(h[i] < ih && pre_exist == 1) {
                pre_exist = 0;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n,m,l;
  int a[150][150];
  int b[150][150];
  long long c[150][150]={0};

  cin >> n >> m >> l;

  int i,j,k;

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

  for(j=0;j<m;j++)
    for(k=0;k<l;k++)
      cin >> b[j][k];

  for(i=0;i<n;i++){
    for(k=0;k<l;k++){
      for(j=0;j<m;j++){
	c[i][k]+=a[i][j]*b[j][k];
      }
    }
  }

  for(i=0;i<n;i++){
    cout << c[i][0];
    for(k=1;k<l;k++){
      cout << " " << c[i][k];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define flp(i ,a ,b) for(int  i = a ; i<b ; i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define blp(i, a , b) for(int  i = a ; i>=b ; i--)
#define lol 1000000007

ll fact[100001] ; 

void init()
{
	fact[0] = 1  ; 
	for( ll i = 1  ; i<100001 ; i++)
	{
		fact[i]= (i*fact[i-1])%lol ;
	}
}
long long binpow(long long a, long long b, long long m) {
	a %= m;
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}

ll modInverse(ll n, ll p) 
{ 
    return binpow(n, p-2, p); 
} 


ll solve(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
  
    return (fact[n]* ((modInverse(fact[r], p) *modInverse(fact[n-r], p) ) % p)) % p; 
} 


int main()
{	ios ; 
	ll n ; 
	cin>>n ; 
	int a[n] ; 
	flp(i,0,n)
	{
		cin>>a[i] ; 
	}
	int dp[n] ;
	dp[0] = 0  ; 
	flp(i,1 , n)
	{
		dp[i]= dp[i-1] + abs(a[i]-a[i-1]);
		if(i>1)
		{
			dp[i] =min(dp[i] ,dp[i-2] + abs(a[i]-a[i-2]));
		}


	} 
	cout<<dp[n-1]<<"\n" ; 





}

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

int main(){
    long long x;
    cin >> x;
    bool ok = true;
    long long money = 100;
    int ans = 0;
    while(ok){
        ans += 1;
        money += money / 100;
        if(money >= x){
            ok = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    string S,T;
    cin>>S>>T;
    int n=S.size(), m=T.size();
    vector<vector<int> > dp(n+1,vector<int>(m+1,0));
    //vector<vector<vector<char> > > c(n+1,vector<vector<char> >(m+1));
    for (int i=1;i<n+1;i++){
        for (int j=1;j<m+1;j++){
            if (S[i-1]==T[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
                //c[i][j]=c[i-1][j-1];
                //c[i][j].push_back(S[i-1]);    
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                //if (dp[i-1][j]>dp[i][j-1]) c[i][j]=c[i-1][j];
               // else c[i][j]=c[i][j-1];
            }
        }
    }
    stack<char> st;
    int a=n,b=m,d=dp[n][m];
    while(a>0&&b>0){
        if (dp[a][b]==dp[a][b-1]) b--;
        else if (dp[a][b]==dp[a-1][b]) a--;
        else{
            st.push(S[a-1]);
            a--;
            b--;
        }
    }


  // cout<<dp[n][m]<<endl;
    int l=st.size();
    rep (i,l){
        cout<<st.top();
        st.pop();
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend();
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	ll ans = 0;
	map<pair<int, int>, int> cnt;
	int n;
	cin >> n;
	while (n--) {
		ld x;
		cin >> x;
		ll y = llround(1e9 * x);
		int a = 0, b = 0;
		while (y % 2 == 0) {
			a++;
			y /= 2;
		}
		while (y % 5 == 0) {
			b++;
			y /= 5;
		}
		cnt[{a, b}]++;
	}
	for (auto e1 : cnt)
		for (auto e2 : cnt) {
			int x1 = e1.first.first;
			int x2 = e2.first.first;
			int y1 = e1.first.second;
			int y2 = e2.first.second;
			if (x1 + x2 < 18 || y1 + y2 < 18) continue;
			if (e1 == e2)
				ans += 1ll * e1.second * (e1.second - 1) / 2;
			else if (e1 < e2)
				ans += 1ll * e1.second * e2.second; 
		}
	cout << ans;
	return 0;
}

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

int main(){
  string S,T;
  bool yy  = true;
  cin >> S;
  cin >> T;
  for(int i=0; i<S.size(); i++){
    if(S[i]!=T[i]) yy = false;
  }
  if(yy) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t = "FESTIVAL";
	cout << s.substr(0, s.size() - t.size()) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong(),T=sc.nextLong(),pret=-T,t;
		long ans=0;
		for(int i=0;i<n;i++){
			t=sc.nextLong();
			ans+=T;
			if(t-pret<T){
				ans-=T-(t-pret);
			}
			pret=t;
		}
		System.out.println(ans);
	}

}


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

#define NIL -1
#define INF 1000000001

using namespace std;


int main(){
    int num_dataset;
    char temp[1000];
    scanf("%d",&num_dataset);
    int numSubSeq[1001][1001];
    for(int i = 0;i < 1001;i++) numSubSeq[i][0] = 0; 
    for(int i = 0;i < 1001;i++) numSubSeq[0][i] = 0;

    for(int i = 0;i < num_dataset;i++){
        scanf("%s",temp);
        string str_A = temp;
        int size_A = (int)str_A.size();
        str_A = ' ' + str_A;
  
        scanf("%s",temp);
        string str_B = temp;
        int size_B = (int)str_B.size();
        str_B = ' ' + str_B;
     
        for(int j = 1;j <= size_A;j++){
            for(int k = 1;k <= size_B;k++){    
                if(str_A[j] == str_B[k]){
                    numSubSeq[j][k] = numSubSeq[j-1][k-1] + 1;
                }else{
                    numSubSeq[j][k] = max(numSubSeq[j-1][k],numSubSeq[j][k-1]);
                }
            }
        }
        printf("%d\n",numSubSeq[size_A][size_B]);
    }
    return 0;
}


Measured memory_bytes: 7180
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1000*1000*1000;
const ll LINF = (ll)1e18;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M, A[100001];
    cin >> N >> M;
    REP(i, N){
        cin >> A[i];
    }
    map<int, int> cnt;
    cnt[0] = 1;
    ll ans = 0;
    ll tt = 0;
    REP(i, N){
        tt += A[i];
        ans += cnt[tt%M];
        cnt[tt%M]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }
 
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}
 
struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};
 
int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
  string A, B;
  cin >> A >> B;
 
  bool none = true;
  for (char c: B)
    if (c == '1') none = false;
  if (none) {
    bool ok = true;
    for (char c: A)
      if (c == '1') ok = false;
    if (ok) { cout << 0 << endl; return 0; }
    cout << -1 << endl;
    return 0;
  }
 
  const int n = A.size();
  vector<int> left(n, n), right(n, n);
  REP(i,n) {
    for (int j = 0; j <= n; ++j) {
      if (B[(i + n - j) % n] == '1') chmin(left[i], j);
      if (B[(i + j) % n] == '1') chmin(right[i], j);
    }
  }
  // REP(i,n) cout << left[i] << " " << right[i] << endl;
  int res = 1e9;
  for (int p = -2 * n; p <= 2 * n; ++p) {
    vector<pair<int,int>> vec;
    REP(i,n) {
      const int j = ((i + p) % n + n) % n;
      if (A[i] == B[j]) continue;
      if (p < 0) {
        int l = max(0, left[i] - abs(p));
        vec.emplace_back(l, right[i]);
      }
      else {
        int r = max(0, right[i] - abs(p));
        vec.emplace_back(left[i], r);
      }
    }
    sort(ALL(vec));
    int cnt = abs(p) + vec.size();
    const int m = vec.size();
    for (int i = m - 2; i >= 0; --i) {
      chmax(vec[i].second, vec[i + 1].second);
    }
    if (vec.empty()) {
      chmin(res, cnt);
    }
    else {
      chmin(res, cnt + vec.front().second * 2);
      chmin(res, cnt + vec.back().first * 2);
    }
    REP(i,m-1) {
      chmin(res, cnt + 2 * (vec[i].first + vec[i+1].second));
    }
  }
  cout << res << endl;
	return 0;
}

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

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

Measured memory_bytes: 3604
N = int(input())
L = list(map(int, input().split()))

counter = 0
if N < 3:
    print(counter)
else:
    for x in range(0, N - 2):
        for y in range(x + 1, N):
            for z in range(y + 1, N):
                if L[x] != L[y] and L[x] != L[z] and L[y] != L[z]:
                    if L[x] + L[y] > L[z] and L[x] + L[z] > L[y] and L[y] + L[z] > L[x]:
                        counter += 1
    print(counter)



Measured memory_bytes: 9148
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int i, cnt=0;
  string day;
  cin >> day;
  string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  //cout << s[0] << "\n";                                                                            
  for(i=0; i<=6; ++i){
    if (s[i] == day){
      cnt = 7 - i;
    }
  }
  cout << cnt << "\n";
}




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

int main(){
    int n,m;    cin >> n >> m;
    vector<vector<int> >s(m);
    rep(i, m){
        int k;  cin >> k;
        rep(j, k){
            int tmps;  cin >> tmps;
            s[i].push_back(--tmps);
        }
    }
    vector<int>p(m);
    rep(i, m)   cin >> p[i];
    //solve bit演算
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        vector<int>tmps(n); //1:on 0:off
        rep(j, n){
            if(i & (1 << j)){
                tmps[j] = 1;
            }
        }
        rep(j, m){
            int ons = 0;
            rep(k, s[j].size()){
                if(tmps[s[j][k]])   ons++;
            }
            if(ons%2 != p[j])   break;
            else if(j == m-1)   ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
total = 0
def cmb(n):
  return n*(n-1)//2

X = [0]*(max(A)+1)
for a in A:
  X[a] += 1
#print(X)

for x in X:
  total += cmb(x)
#print(total)

for a in A:
  ans = total
  ans -= cmb(X[a])
  ans += cmb(X[a]-1)
  print(ans)

Measured memory_bytes: 26140