akhauriyash/Code-Regression huggingface dataset:
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<double, double>;
using tp = tuple<int, int, int>;
using tp4 = tuple<int, int, int, int>;
using tp5 = tuple<int, int, int, int, int>;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

int w, h;
char g[1024][1024];
int dist[1024][1024];

void bfs(int x, int y, int d)
{
	queue<pi> q;
	dist[x][y] = d;
	q.emplace(x, y);
	while (q.size()){
		int x, y;
		tie(x, y) = q.front(); q.pop();
		rep(i, 4){
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (g[nx][ny] == '#') continue;
			if (~dist[nx][ny]) continue;
			dist[nx][ny] = d;
			q.emplace(nx, ny);
		}
	}
}

int main()
{
	memset(g, '#', sizeof(g));
	memset(dist, -1, sizeof(dist));
	cin >> w >> h;
	int *p;
	rep(i, h) rep(j, w){
		cin >> g[i + 1][j + 1];
		if (g[i + 1][j + 1] == 't'){
			p = &dist[i + 1][j + 1];
		}
	}
	
	bfs(1, 1, 0);

	int n;
	cin >> n;
	rep(i, n){
		int x, y;
		cin >> y >> x, x++, y++;
		if (g[x][y] == '#'){
			g[x][y] = '.';
			bool f = false;
			rep(j, 4){
				if (~dist[x + dx[j]][y + dy[j]]) f = true;
			}
			if (f) bfs(x, y, i + 1);
		}
	}
	
	cout << *p << endl;
}

Measured memory_bytes: 8300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll n;


int main(){
	cin >> n;
	n--;
	
	ll keta = 1;
	ll num = 26;
	while ( n >= num ){
		n -= num;
		keta++;
		num *= 26;
	}
	
	vector<char> v;
	for ( int i = 0; i < keta; i++ ){
		v.push_back(n%26 + 'a');
		n = n / 26;
	}
	
	for ( int i = v.size()-1; i >= 0; i-- ){
		cout << v[i];
	}
	
	cout << endl;
	return 0;
}




Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<string,int> P;

int V[2][8000];
bool dp[4100][16100];

int main(){
    bool flag=false;
    string s;
    int x,y,temp=0,count[2]={-1,-1};
    cin>>s>>x>>y;

    for(int i=0;i<(int)s.size();i++){
        if(!flag && s[i]=='F') x--;
        else if(s[i]=='F') V[temp][count[temp]]++;
        else{
            temp=temp^1;
            count[temp]++;
            flag=true;
        } 
    }

    for(int i=0;i<4100;i++){
        for(int j=0;j<16100;j++){
            dp[i][j]=false;
        }
    } 

    dp[0][8000]=true;
    x+=8000; y+=8000;

    for(int i=0;i<=count[0];i++){
        for(int j=0;j<=16000;j++){
                dp[i+1][j+V[0][i]]=dp[i][j] || dp[i+1][j+V[0][i]];
                dp[i+1][j-V[0][i]]=dp[i][j] || dp[i+1][j-V[0][i]];                
        }
    }

    //for(int i=8000;i<=8004;i++) cout<<dp[i]<<endl;
    if(x<0 || x>16000 || !dp[count[0]+1][x]){
        cout<<"No"<<endl; return 0;
    }

    for(int i=0;i<4100;i++){
        for(int j=0;j<16100;j++){
            dp[i][j]=false;
        }
    } 

    dp[0][8000]=true;

    for(int i=0;i<=count[1];i++){
        for(int j=0;j<=16000;j++){
                dp[i+1][j+V[1][i]]=dp[i][j] || dp[i+1][j+V[1][i]];
                dp[i+1][j-V[1][i]]=dp[i][j] || dp[i+1][j-V[1][i]];
        }                
    }
        //cout<<dp[1][8002]<<endl;

    

    if(y<=16000 && y>=0 && dp[count[1]+1][y]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 64768
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class Program
	{
		// ABC106-C
		static void Main(string[] args)
		{
			string S = Console.ReadLine();
			long K = long.Parse(Console.ReadLine());

			int count = 0;
			for (int i = 0; i < S.Length; i++) {
				if (S[i] == '1') {
					count++;
					if (count == K) {
						Console.WriteLine(S[i]);
						break;
					}
				} else {
					Console.WriteLine(S[i]);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 11092
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	int ans = 0;
	rep(i,s.size()-1){
		if(s[i]!=s[i+1]) ans++;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

class Point {
public:
	double x, y;
	Point(int x, int y) : x(x), y(y) {}

	bool operator < (const Point &a) const {
		return x != a.x ? x < a.x : y < a.y;
	}
};

Point operator-(const Point &a, const Point &b) {
	return Point(a.x - b.x, a.y - b.y);
}

bool isClockwise(const Point &a, const Point &b, const Point &c);
vector<Point> makeConvexHull();
void print(const vector<Point> &v);
double minY = 1 << 30;
int n;
vector<Point> points;
const double e = 1e-10;

int main() {

	cin >> n;
	for (int i = 0; i < n; ++i) {
		double x, y;
		cin >> x >> y;
		minY = min(minY, y);
		points.push_back(Point(x, y));
	}

	vector<Point> answer = makeConvexHull();

	cout << answer.size() << endl;

	for (int i = 0; i < answer.size(); ++i)
		cout << answer[i].x << " " << answer[i].y << endl;

	return 0;

}

vector<Point> makeConvexHull() {

	if (points.size() < 3)
		return points;

	vector<Point> top;
	vector<Point> under;
	
	sort(points.begin(), points.end());

	top.push_back(points[0]);
	top.push_back(points[1]);
	under.push_back(points[n - 1]);
	under.push_back(points[n - 2]);

	for (int i = 2; i < n; ++i) {
		for (int j = top.size(); j > 1; --j) {
			if (isClockwise(top[j - 2], top[j - 1], points[i]) != true)
				top.pop_back();
			else
				break;
		}
		top.push_back(points[i]);
	}

	for (int i = n - 3; i >= 0; --i) {
		for (int j = under.size(); j > 1; --j) {
			if (isClockwise(under[j - 2], under[j - 1], points[i]) != true)
				under.pop_back();
			else
				break;
		}
		under.push_back(points[i]);
	}

	/*
	cout << "top" << endl;
	print(top);
	cout << endl << "under" << endl;
	print(under);
	cout << endl << endl;
	*/

	vector<Point> answerPoint;
	vector<Point> tempPoint;
	int startIndex = 0;

	reverse(under.begin(), under.end());



	while (under[startIndex].y > minY) {
		tempPoint.push_back(under[startIndex]);
		startIndex++;
	}

	for(int i = startIndex; i < under.size(); ++i) 
		answerPoint.push_back(under[i]);

	for (int i = top.size() - 2; i >= 1; --i)
		answerPoint.push_back(top[i]);

	for (int i = 0; i < tempPoint.size(); ++i)
		answerPoint.push_back(tempPoint[i]);
	return answerPoint;

			

}

bool isClockwise(const Point &a, const Point &b, const Point &c) {

	Point a2b = b - a;
	Point a2c = c - a;

	return a2b.x * a2c.y - a2b.y * a2c.x < e;

}

void print(const vector<Point> &v) {
	for (int i = 0; i < v.size(); ++i)
		cout << v[i].x << " " << v[i].y << endl;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    int a[n], b[n - 1];
    for (int i = 0; i < n - 1; i++) {
        cin >> b[i];
        a[i] = 0;
    }
    a[n - 1] = 0;
    for (int i = 0; i < n - 1; i++) {
        a[i] = min(b[i], a[i]);
        a[i + 1] = b[i];
    }
    int res = 0;
    a[0] = b[0];
    for (int i = 0; i < n; i++) {
        res += a[i];
    }
    cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;



int main(){
    int m,n;
    while(cin>>m>>n){
        
        bool order[21][21]={0};
        
        for(int i=0; i<n; i++){
            int x,y;
            cin>>x>>y;
            order[x][y]=1;
        }
        int outputted[21]={0};
        for(int i=1; i<=m; i++){
            bool flag = true;
            for(int j=1; j<=m; j++){
                if(order[j][i]){
                    flag=false;
                    break;
                }
            }
            if(flag&&outputted[i]!=1){
                cout<<i<<endl;
                outputted[i]=1;
                for(int j=1; j<=m; j++){
                    order[i][j]=0;
                }
                i=0;
            }
        }
    }
    
    

}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K,H,W;
ll ans;
ll A[100001];
ll M = 1000000007;
ll ac;
P minminus= P(M,0);
P maxminus = P(M,0);
P minplus = P(M,0);
P maxplus = P(M,0);
bool found = true;

int main() {
    cin >> N;
    ll n = sqrt(N);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                A[i*i+j*j+k*k+i*j+k*j+i*k] +=1;
            }
        }
    }
    for(int i=1;i<=N;i++){
        cout << A[i] << endl;
    }
}


Measured memory_bytes: 3988
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> num(K);

    for (int64_t i = 1; i <= N; ++i) {
        num[i%K]++;
    }

    int64_t ans = 0;
    // a%Kは [0,K)
    for (int64_t a = 0; a < K; ++a) {
        // mod KではBもCも同じになる...
        auto b = (K-a)%K;
        auto c = b;
        if ((b+c)%K != 0) {
            continue;
        }

        ans += num[a] * num[b] * num[c];
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int A,B,C;
    cin>>A>>B>>C;

    
    if (A==B&&A!=C&&B!=C) {
        cout<<C<<endl;
    }else 
    if (A==C&&A!=B&&B!=C) {
        cout<<B<<endl;
    }
    else
    {
        cout<<A<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
dq = deque()
for _ in range(n):
    p, t = map(str, input().split())
    dq.append([p, int(t)])
total = 0
while dq:
    pt = dq.popleft()
    if pt[1] <= q:
        total += pt[1]
        print(pt[0], total)
    else:
        total += q
        dq.append([pt[0], pt[1]-q])

Measured memory_bytes: 16096
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ll cnt = 100;
  while (cnt < x) {
    cnt += cnt / 100;
    ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main() {
	int x, y;
	cin >> x;
	if (x < 1200)cout << "ABC" << endl;
	else if(x<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

}

Measured memory_bytes: 256
import sys
from collections import deque

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


def main():
    N = int(readline())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, readline().split())
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    color = [0] * N

    def dfs(v, p, c):
        color[v] = c
        for nv, w in G[v]:
            if nv == p:
                continue
            if w % 2:
                dfs(nv, v, 1 - c)
            else:
                dfs(nv, v, c)

    dfs(0, -1, 0)
    print(*color, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 164600
#include <bits/stdc++.h>
#include <array>
#include <bitset>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	ll a, b;
	CI a >> b;
	CO a* b/ gcd(a, b) EN;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll ways = 0;
	int n;
	cin >> n;
	vector<ll> b(n), count(n, 0);
	for ( int i = 0 ; i < n ; i++ ){
		cin >> b[i];
		b[i]--;
		count[b[i]]++;
	}
	for ( auto c : count ) 
		ways += c > 1 ? (c * (c-1)) / 2 : 0;

	for ( auto ba : b ) {
		if ( count[ba] > 1 )
			cout << ways - (count[ba] * (count[ba] - 1)) / 2 + ((count[ba]-1) * (count[ba] - 2)) / 2 << "\n";
		else
			cout << ways << "\n";
	}

	return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		final String DREAM		= "dream";
		final String DREAMER	= "dreamer";
		final String ERASE		= "erase";
		final String ERASER		= "eraser";

		// TODO ABC_049_C
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String S = sc.nextLine();
		// Scannerクラスのインスタンスをクローズ
		sc.close();

//		String T = "";
		String res = "YES";

		while(S.length() > 0) {

//			switch(S) {
//				case DREAM:
//					break;
//				case DREAMER:
//					break;
//				case ERASE:
//					break;
//				case ERASER:
//					break;
//			}
			if(S.length() < 5) {
				res = "NO";
				break;
			}
			if(DREAM.equals(S)) {
				break;
			} else if(DREAMER.equals(S)) {
				break;
			} else if(ERASE.equals(S)) {
				break;
			} else if(ERASER.equals(S)) {
				break;
			}

			if(S.substring(0,1).equals("d")) {
				if(S.substring(0,5).equals("dream")) {
					if(S.substring(5,7).equals("er")) {
						if(S.substring(7,8).equals("a")) {
							// dreamerase
							S = S.substring(5);
							continue;
						} else {
							// deramer
							S = S.substring(7);
							continue;
						}
					} else {
						// dream
						S = S.substring(5);
						continue;
					}
				} else {
					res = "NO";
					break;
				}
			}
			else if(S.substring(0,1).equals("e")) {
				if(S.substring(0,5).equals("erase")) {
					if(S.substring(5,6).equals("r")) {
						// eraser
						// deramer
						S = S.substring(6);
						continue;
					} else {
						// erase
						S = S.substring(5);
						continue;
					}
				} else {
					res = "NO";
					break;
				}
			}
			else {
				res = "NO";
				break;
			}

		}

		System.out.println(res);
	}
}


Measured memory_bytes: 56852
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    long n,k;
    cin >> n >> k;
    long b = abs(n-k);
    if(n < k){cout << min(b,n) << endl;}//
    else if (n == k){
        cout << "0" << endl;
    }else
    {
        long a = n % k ;
        if(abs(a - k) < a ){
            a = abs(a - k);
        }
        cout << min(a,b) << endl;
    }
//--------------------
    return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if (a > 0) {
        cout << "Positive" << endl;
    } else if (a == 0) {
        cout << "Zero" << endl;
    } else {
        if (b >= 0) {
            cout << "Zero" << endl;
        } else {
            if (((b - a) + 1) % 2) {
                cout << "Negative" << endl;
            } else {
                cout << "Positive" << endl;
            }
        }
    }
    
    return 0;
}



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

ll mod = 1e9 + 7;
int main() {
    ll n;
    string s;
    map<char, ll> mp;
    cin >> n >> s;
    for (int i = 0; i < n; i++) mp[s[i]]++;
    ll ans = 1;
    for (auto e : mp) {
        ans *= (e.second + 1);
        ans %= mod;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
s = input()
N = s.count('N')
W = s.count('W')
S = s.count('S')
E = s.count('E')

ans = 'No'
if (N >= 1 and S >= 1) or (N == S == 0):
  if (W >= 1 and E >= 1) or (W == E == 0):
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[11];
int main(){
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d",arr+i);
	sort(arr,arr+N);
	int sum=0;
	for(int i=0;i<N-1;i++) sum+=arr[i];
	printf("%s",arr[N-1]>=sum?"No":"Yes");
}

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



int main()
{
	int n;
	cin>>n;
	const int num=2999;
	double p[num+1];
	double dp[num+1][num+1]={};//iはコインの総数 jは表枚数
	for(int i=0;i<n;i++)
	{
		cin>>p[i+1];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j]*(1-p[i])+(j>0?dp[i-1][j-1]*p[i]:0);
		}
	}
	double ans=0;
	for(int i=(n+1)/2;i<=n;i++)
	{
		ans+=dp[n][i];
	}
	cout<<setprecision(10)<<ans<<endl;
}
	

Measured memory_bytes: 70528
S = gets.chomp.split('')
h = {'N'=>0, 'W'=>0, 'S'=>0, 'E'=>0}
S.each do |s|
    h[s]+=1
end
if h['N'] == 0 && h['S'] == 0 && h['W'] != 0 && h['E'] != 0 then
    puts "Yes"
elsif h['N'] != 0 && h['S'] != 0 && h['W'] == 0 && h['E'] == 0 then
    puts "Yes"
elsif h['N'] != 0 && h['S'] != 0 && h['W'] != 0 && h['E'] != 0 then
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#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 all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    int black_count = 1;
    int white_count = 1;
    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 50; i++){
        for (int j = 0; j < 100; j++){
            if (i % 2 == 0) cout << ".";
            else if (j % 2 == 0) cout << ".";
            else{
                if (black_count < B){
                    cout << "#";
                    black_count++;
                }
                else{
                    cout << ".";
                }
            }
        }
        cout << endl;
    }
    for (int i = 0; i < 50; i++){
        for (int j = 0; j < 100; j++){
            if (i % 2 == 0) cout << "#";
            else if (j % 2 == 0) cout << "#";
            else{
                if (white_count < A){
                    cout << ".";
                    white_count++;
                }
                else{
                    cout << "#";
                }
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3620
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner kbd = new Scanner(System.in);

    String s;

    void run(){
	while(kbd.hasNext()){
	    s = kbd.next();
	    solve();
	}
    }

    void solve(){
	int i, j;
	int ansJ=0;
	int ansI = 0;
	for(i=0; i<s.length()-2; i++){
	    String a = s.substring(i, i+3);
	    //System.out.println(a);
	    if(a.equals("JOI"))
		ansJ++;
	    if(a.equals("IOI"))
		ansI++;
	}
	
	System.out.println(ansJ);
	System.out.println(ansI);
    }
}

Measured memory_bytes: 23540
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int sum = 0;
  rep (i, 10) {
  int si;
  cin >> si;
  sum += si;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3136
import sys

X, K, D = map(int,input().split())

if abs(X) > K * D:
    print(abs(abs(X) - K * D))
    sys.exit()

Appr = X // D
Near = X - (X // D) * D

if (K - Appr) % 2 != 0:
    print(abs(Near - D))
else:
    print(abs(Near))

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int a[maxn],t[maxn],n,vis[maxn],f[maxn],sta[maxn],top;
ll k;
set<int > s[maxn];

int main() {
    read(n);scanf("%lld",&k);k--;
    for(int i=1;i<=n;i++) read(a[i]),!t[a[i]]?t[a[i]]=i:0,s[a[i]].insert(i);
    for(int i=n;i;i--) {
        auto x=s[a[i]].lower_bound(i);++x;
        if(x==s[a[i]].end()) f[i]=a[i];
        else f[i]=f[*x+1];
    }int cnt=0,x=0;
    // for(int i=1;i<=n;i++) printf("%d ",f[i]);puts("");
    while(!vis[x]) {
        // write(x);
        vis[x]=1,cnt++;
        x=f[t[x]+1];
    }
    k%=cnt;x=0;
    // write(cnt);
    for(int i=1;i<=k;i++) x=f[t[x]+1];//write(x);
    memset(vis,0,sizeof vis);if(x) sta[++top]=x,vis[x]=1;
    for(int i=1;i<=n;i++) {
        if(!vis[a[i]]) sta[++top]=a[i],vis[a[i]]=1;
        else {while(sta[top]!=a[i]) vis[sta[top]]=0,top--;vis[sta[top]]=0,top--;}
        // write(top);
    }
    for(int i=1;i<=top;i++) printf("%d ",sta[i]);puts("");
    return 0;
}


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

int main(){
	int n,m; cin>>n>>m;
	vector<vector<char>> v(n,vector<char>(n));
	rep(i,n){
		string s; cin>>s;
		rep(j,n){
			v[i][j]=s[j];
		}
	}
	string ts;
	rep(i,m){
		string s; cin>>s;
		ts+=s;
	}
	rep(i,n-m+1){
		rep(j,n-m+1){
			string vs;
			for(int k=i; k<i+m; k++){
				for(int l=j; l<j+m; l++){
					vs+=v[k][l];
				}
			}
			if(vs==ts) {cout<<"Yes"<<endl; return 0;}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3560
S = input()
s = list(S)

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
  print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
  print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9036
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

int main(){
    int n, m;
    std::cin >> n >> m;

    int k, index;
    std::vector<std::string> likes(m, std::string(n, '.'));
    for(int i = 0; i < n; ++i){
        std::cin >> k;
        for(int j = 0; j < k; ++j){
            std::cin >> index;
            likes.at(index - 1).at(i) = '#';
        }
    }

    std::cout << std::count(likes.begin(), likes.end(), std::string(n, '#')) << std::endl;

    return 0;
}


Measured memory_bytes: 888
N = int(input())
a = list(map(int,input().split()))
flag = 0
for i in range(N):
	if a[i]%2 == 0:
		if a[i]%3 != 0 and a[i]%5 != 0:
			flag = 1

if flag == 1:
	print("DENIED")
else:
	print("APPROVED")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k)
  {
    cout << s << endl;
  }
  else
  {
    cout << s.substr(0, k) << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll n, h; cin >> n >> h;
    ll ans = 0;
    REP(i, h){
        ll tmp; cin >> tmp;
        ans += tmp;
    }
    if(ans >= n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

char s[100010];

int main()
{
	scanf("%s",s);
	int n=strlen(s);
	if(s[0]=='0' || s[n-1]=='1') {printf("-1");return 0;}
	for(int i=0;i<n/2;i++)
		if(s[i]!=s[n-i-2]) {printf("-1");return 0;}
	int fa=1;
	for(int i=2;i<=n;i++)
	{
		printf("%d %d\n",fa,i);
		if(s[i-2]=='1') fa=i;
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  string s;
  cin >> s;

  int t = s.length() - 1;
  while(t > 1){
    if(t % 2 == 1) --t;
    bool even = true;
    for(int i = 0; i < t / 2; i++){
      if(s[i] != s[t / 2 + i])
        even = false;
    }
    if(even) break;
    --t;
  }

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
const int maxn = 300;
const ll oo = 300e9;
int n,a[maxn+1][maxn+1];
ll d[maxn+1][maxn+1];
ll res;

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	for (int i=1; i<=n; i++)
	for (int j=1; j<=n; j++)
	cin >> a[i][j];
	for (int i=1; i<=n; i++)
	for (int j=1; j<=n; j++)
	if (i!=j) d[i][j]=oo;
	else d[i][j]=0;
	res=0;
	for (int i=1; i<=n; i++)
	for (int j=i+1; j<=n; j++)
	{
		bool flag=true;
		for (int z=1; z<=n; z++)
		if (z!=i and z!=j)
			if (a[i][z]+a[z][j]==a[i][j]) 
			{
				flag=false;	
				break;
			}
		if (flag)
		{
			d[i][j]=a[i][j];
			d[j][i]=a[i][j];
			res+=d[i][j];
		}
	}
	for (int k=1; k<=n; k++)
	for (int i=1; i<=n; i++)
	for (int j=1; j<=n; j++)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	/*for (int i=1; i<=n; i++)
	{
		for (int j=1; j<=n; j++)
			cout << d[i][j] << ' ';
		cout << '\n';
	}*/
	for (int i=1; i<=n; i++)
	for (int j=1; j<=n; j++)
	if (a[i][j]!=d[i][j])
	{
		res=-1;
		break;
	}
	cout << res;
	return 0;
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

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

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

	const int V_MAX = 100000;

	int n;
	cin >> n;

	vector<int> a(V_MAX + 1), b(V_MAX + 1);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (i & 1) {
			a[x]++;
		} else {
			b[x]++;
		}
	}

	int mx = INT_MIN, sec = 0, pos = 0;
	for (int i = 1; i <= 1e5; i++) {
		if (a[i] > mx) {
			sec = mx;
			mx = a[i];
			pos = i;
		} else {
			sec = max(sec, a[i]);
		}
	}

	int ans = 0;
	for (int i = 1; i <= 1e5; i++) {
		ans = max(ans, b[i] + (i == pos ? sec : mx));
	}

	ans = n - ans;
	cout << ans << endl;
	return 0;
}


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

int n;
int cost[555][555];
bool a[555][555];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

int solve(int y, int x){

  typedef pair < int, int > P;
  queue < P > que;

  que.push( P(y, x) );

  while(que.size()){
    int ny = que.front().first, nx = que.front().second; que.pop();

    for(int i=0;i<4;i++){
      int xx = nx + dx[i], yy = ny + dy[i];
      if(xx < 0 || yy < 0 || xx == n || yy == n) continue;

      if(cost[yy][xx] > cost[ny][nx]+a[ny][nx]){
        cost[yy][xx] = cost[ny][nx]+a[ny][nx];
        que.push( P(yy, xx) );
      }
    }
  }
  return cost[y][x];
}

int main(){

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cost[i][j] = min(min(i, j), min(n-i-1, n-j-1));
      a[i][j] = 1;
    }
  }

  int ans = 0;
  for(int i=0;i<n*n;i++){
    int p;
    cin >> p; p--;
    int y = p/n, x = p%n;
    a[y][x] = 0;
    ans += solve(y, x);

  }

  cout << ans << endl;

}


Measured memory_bytes: 4928
n=int(input())
a = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    a[i].append(a[i][0]-a[i][1])
    a[i].append(a[i][0]+a[i][1])

a.sort(key=lambda x: x[3])

left=-float('inf')
count=0
for i in range(n):
    if a[i][2]>=left:
        count+=1
        left=a[i][3]

print(count)

Measured memory_bytes: 65112
#include <bits/stdc++.h>
using namespace std;vector<int>e[1<<17],o(1<<17,0);void d(int w){if(o[w])return;for(auto x:e[w])d(x),o[w]=max(o[w],o[x]+1);}main(){int a=0,u,v,n,m;cin>>n>>m;while(m--)cin>>u>>v,e[u].push_back(v);for(;m++<n;)d(m),a=max(a,o[m]);cout<<a;}

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

int main(){
	int N,num=0,ans=0; cin>>N;
	vector<int>a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	bool even;
	 for(int i=0;i<N;i++){
		while(a[i]%2==0){
			a[i]=a[i]/2;
			ans++;
		}
	 }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	vector<int> list;
	for (;;) {
		int buf;
		cin >> buf;
		if (!buf)break;
		list.push_back(buf);
	}
	for (int n : list) {
		int cnt = 0;
		for (int a = 1; a < n; a++) {
			for (int b = 1; (a*2 + b)*(b+1) <=n*2; b++) {
				if ((a*2 + b)*(b+1) == n * 2)cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        
        var p = 0d;
        for (int i = 0; i < n; i++)
        {
            var x = i + 1;
            while (x < k)
            {
                x *= 2;
            }
            p += 1d / (x / (i + 1)) / n;
        }
        Console.WriteLine(p.ToString("F12"));
    }
}


Measured memory_bytes: 13396
def main():
    N = int(input())

    #6**6=46656, 6**7=279936
    #9**5=59049, 9**6=531441
    list = [1]
    list.extend([6 ** i for i in range(1, 7)])
    list.extend([9 ** i for i in range(1, 6)])

    dp = [float("inf")] * 100001
    dp[0] = 0

    for i in range(N+1):
        for j in list:
            if i + j > 100000:
                continue
            else:
                dp[i+j] = min(dp[i+j], dp[i]+1)

    print(dp[N])

if __name__ == "__main__":
    main()



Measured memory_bytes: 46540
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(let ((n (read))
      (a (read))
      (b (read)))
  (loop repeat n
        for c = (read-char)
        do
           (block main
             (when (and (char= c #\a) (null (zerop a)))
               (format t "Yes~%")
               (decf a)
               (return-from main))
             (when (and (or (char= c #\a) (char= c #\b)) (null (zerop b)))
               (format t "Yes~%")
               (decf b)
               (return-from main))
             (format t "No~%"))))


Measured memory_bytes: 20284
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n;
    cin >> n;
    double d;
    map<pair<int, int>, ll> m;
    REP(i, n) {
        cin >> d;
        // auto l = prime_factorization(llround(d * 1000000000));
        auto l = llround(d * 1000000000);
        int two = 0;
        while (l % 2 == 0) {
            two++;
            l /= 2;
        }
        int five = 0;
        while (l % 5 == 0) {
            five++;
            l /= 5;
        }
        m[make_pair(two, five)]++;
    }

    ll ans = 0;
    for (auto e : m) {
        for (auto f : m) {
            if (e.first.first + f.first.first >= 18 and e.first.second + f.first.second >= 18) {
                if (e.first == f.first) {
                    ans += e.second * (e.second - 1);
                } else {
                    ans += e.second * f.second;
                }
            }
        }
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	int n,a[110];
	cin>>n;
	rep(i,n)cin>>a[i];
	int ans=0;
	rep(i,n){
		if(i%2==0&&a[i]%2==1)ans++;
	}
	cout<<ans<<endl;
}


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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int vis[102];
int main(int argc, char const *argv[])
{
	int x,n,p;
	scanf("%d%d",&x,&n);
	for(register int i = 1;i <= n;i++)
		scanf("%d",&p),vis[p]++;
	for(register int i = 0;i <= 101;i++)
	{
		int l,r;
		l = x - i;
		r = x + i;
		if(l >= 0 && !vis[l])
			return 0*printf("%d\n",l);
		if(r <= 101 && !vis[r])
			return 0*printf("%d\n",r );
	}
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  REP(i,1,n+1){
    double p = 1;
    int x = i;
    while (x < k){
      p /= 2;
      x *= 2;
    }
    ans += p / n;
  }
  printf("%.10f", ans);
  return 0;
}


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 15 == 0) continue;
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    ans += (long long) i;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	int n = s.size();
	vector<long long> m(n + 1), cnt(2019);
	cnt[0] = 1;
	int mul = 1;
	for (int i = n - 1; i >= 0; --i) {
		m[i] = ((s[i] - '0') * mul + m[i + 1]) % 2019;
		(mul *= 10) %= 2019;
		++cnt[m[i]];
	}
	long long ans = 0;
	for (int i = 0; i < 2019; ++i) ans += cnt[i] * (cnt[i] - 1) / 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5136
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 100

int mo[5] = {0,1,0,-1,0};

struct STICK{
    int l_l,l_r,s_l,s_r;
};

STICK stick[SIZE+10];

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

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

int dfs(int s_num){
    int v_l,v_r,af_l,af_r,times;
    
    if(stick[s_num].s_l == 0 && stick[s_num].s_r == 0) return stick[s_num].l_l + stick[s_num].l_r;
    
    if(stick[s_num].s_l > 0){
        v_l = dfs(stick[s_num].s_l);
    }else{
        v_l = 1;
    }
    
    if(stick[s_num].s_r > 0){
        v_r = dfs(stick[s_num].s_r);
    }else{
        v_r = 1;
    }
    
    
    af_r=lcm(stick[s_num].l_l,v_r);
    af_l=lcm(stick[s_num].l_r,v_l);
    
    times = lcm(af_r/stick[s_num].l_l,af_l/stick[s_num].l_r);
    
    return (stick[s_num].l_l+stick[s_num].l_r) * times;
}

void calc(int n){
    bool top[SIZE+1]={0};
    
    
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d",&stick[i].l_l,&stick[i].l_r,&stick[i].s_l,&stick[i].s_r);
        
        int G = gcd(stick[i].l_l,stick[i].l_r);
        
        stick[i].l_l/=G;
        stick[i].l_r/=G;
        
        top[stick[i].s_l] =true;
        top[stick[i].s_r] =true;
    }
    
    for(int i=1;i<=n;i++){
        if(top[i]==false){
            printf("%d\n",dfs(i));
            return;
        }
    }
    
}

int main(){
    int n;
    
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        calc(n);
    }
    
    return 0;
}

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

int s[100000], t[100000], c[100000];
int tim[200002], sum[200002] = {};

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

    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i] >> c[i];
    }

    for(int i = 1; i <= C; i++){
        for(int j = 0; j < 200002; j++) tim[j] = 0;
        for(int j = 0; j < n; j++)  if(c[j] == i)   tim[s[j]*2-1]++, tim[t[j]*2]--;
        for(int j = 1; j < 200002; j++) tim[j] += tim[j-1];
        for(int j = 0; j < 200002; j++) if(tim[j] > 0)  sum[j]++;
    }
    int ans = 0;
    for(int i = 0; i < 200002; i++) ans = max(ans, sum[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string t;
    cin >> t;
    ll n = len(t);
    rep(i, n) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


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

int main() {
    string s; cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

int main()
{
	int A, B; 
	char S[255], T[255], U[255];
	scanf("%s %s", &S,&T);
	scanf("%d %d" ,&A,&B);
	scanf("%s", &U);
	
	if(strcmp(S, U)==0) 
	{
		A--;
	}
	else if(strcmp(T, U)==0)
	{
		B--;
	}
	
	printf("%d %d", A, B);
	return 0;
}

Measured memory_bytes: 1688
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,K = inpl()
A = []
for i in range(N):
    a = int(input())
    A.append(a)

a_max = 300001

UNITE = 0
N0 = 2**(a_max-1).bit_length()
data = [UNITE]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = UNITE
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

for a in A:
    segmax = query(max(0,a-K),min(a_max,a+K)+1)
    update(a,segmax+1)

print(max(data))

Measured memory_bytes: 104004