akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second
 
/*
//functions from gfg
 
long long int power(long long int x,long long int y,long long  int p)
{
    long long int res = 1;     // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            {//d=(long double)x/p;
            res = (res*x) % p;
            }
 
        // y must be even now
        y = y>>1; // y = y/2
        x=(x*x)%p;
        
    }
    return res%p;
}
 
long long int gcd(long long int a,long long int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
 
long long int binomialCoeff(long long int n, ll k) 
{ 
    ll res = 1; 
  
    // Since C(n, k) = C(n, n-k) 
    if (k > n - k) 
        k = n - k; 
  
    // Calculate value of [n*(n-1)*---*(n-k+1)] / [k*(k-1)*---*1] 
    for (ll i = 0; i < k; ++i) 
    { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
  
    return res; 
} 
 

void sieve(int n, vector<ll> &primes) 
{ 
    vector<int> prime(n,1);
    ll p;
    for ( p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == 1) 
        { 
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 0; 
        } 
    } 
  
    for(p=2;p<=n;p++)
    {
        if(prime[p])
        primes.pb(p);
    }
   
} 


void dfs(vector<ll> adj[] ,ll src,vector<ll> &vis)
{
    vis[src]=1;
    for(ll i=0;i<adj[src].size();i++)
    {
        if(vis[adj[src][i]]==0)
        dfs(adj,adj[src][i],vis)
    }
}
 
*/

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    
	ll n,i,j,p,k,m,ans=0;
    cin>>n;
    string a;
    cin>>a;
    vector<int> val(26,0);
    for(i=0;i<n;i++)
    {
        val[a[i]-'a']++;
    }
    ans=1;
    for(i=0;i<26;i++)
    {
        ans*=(val[i]+1);
        ans%=mod;
    }
    ans--;
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;
    
    
    
    
    
    
    // for(i=0;i<n;i++)
    // {
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i].first;
        A[i].second = i + 1;
    }
    sort(begin(A), end(A));

    for(int i=0; i<N; ++i) cout << A[i].second << (i+1==N ? '\n' : ' ');
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------

struct UnionFind {
	vector< int > data;
	UnionFind(int size) : data(size, -1) {}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y], data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int n, m;
int p[100000];
int x[100000], y[100000];

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

	cin >> n >> m;
	UnionFind uf(n);
	REP(i, n) {
		cin >> p[i];
		p[i]--;
	}
	REP(i, m) {
		cin >> x[i] >> y[i];
		x[i]--, y[i]--;
		uf.unite(x[i], y[i]);
	}
	int ans = 0;
	REP(i, n) {
		if(uf.same(i, p[i]) || i == p[i]) ans++;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import numpy


def F(A, B):
    count = 0
    while A > 0 or B > 0:
        A //= 10
        B //= 10
        count += 1
    return count


N = int(input())
res = 10
for A in range(1, int(numpy.sqrt(N)) + 1):
    if N % A == 0:
        B = N // A
        res = min(res, F(A, B))
print(res)

Measured memory_bytes: 12488
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fs first
#define ss second



int main(){
 

  int l;
  cin >> l;
  double a = l/3.0;
  double b = l/3.0;
  double c = l - a - b;

  cout << fixed <<setprecision(9) << a*b*c <<endl;



}

Measured memory_bytes: 256
using System;

namespace A
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] tmp = Console.ReadLine().Split(' ');
			int N = int.Parse(tmp[0]);
			int M = int.Parse(tmp[1]);

			Console.WriteLine(N*(N-1)/2 + M*(M-1)/2);
		}
	}
}


Measured memory_bytes: 13140
#include <stdio.h>

#define max 100

int main()
{
    int a, b, c, flag=0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if((a==b&&a!=c)){
        flag++;
    }else if(b==c&&b!=a){
        flag++;
    }else if(a==c&&a!=b){
        flag++;
    }
    
    if(flag>0)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 200005;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int D = 60;
/* function */
/* main */
int main(){
    int n; ll k;
    cin >> n >> k;
    // Doublingでの解法
    // to[k][i]: start i -> 2^k進んだ時の場所
    vector<vector<int>> to(D, vector<int>(MAX));
    for (int i = 0; i < n; i++) {
        cin >> to[0][i];
        to[0][i]--;
    }

    // i -> 2^{k + 1}進む
    // <=>   i  -> 1. 2^{k} 進む   -> 2. 2^{k}進む
    // 1. to[k][i]
    // 2. to[k][to[k][i]]
    // -> to[k + 1][i] = to[k][to[k][i]]
    for (int k = 0; k < D - 1; k++) {
        for (int i = 0; i < n; i++) {
            to[k + 1][i] = to[k][to[k][i]];
        }
    }

    int v = 0;
    for (int i = D - 1; i >= 0; --i) {
        ll b = 1LL << i;
        if (k & b) {
            v = to[i][v];
        }
    }
    cout << v + 1 << '\n';
}


Measured memory_bytes: 50992
import itertools


def main():

    N, K = map(int, input().split())
    mod = 1000000007
    s = list(itertools.accumulate(range(0, N+1)))

    ans = 1
    for k in range(K, N+1):
        ans = (ans + s[N] - s[N-k] - s[k-1] + 1) % mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74824
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int y = sc.nextInt();
		int MOD = 1000000007;
		
		// 計算
		long result = 0;
		if((x + y)%3 != 0 || 2*x-y < 0 || 2*y-x < 0){
		    System.out.println(result);
		    return;
		}
		
		result = combination((x+y)/3, (2*x-y)/3, MOD);
		
		// 出力
		System.out.println(result);
	}
	
	public static long pow(long a, long n, long MOD) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%MOD;
	        }
	        a=(a*a)%MOD;
	        n>>=1;
	    }
	    return res%MOD;
	}
	
	public static long[] fact(int n, long MOD) {
	    long[] f = new long[n+1];
	    for(int i = 0; i < n+1; i++){
	        if(i == 0) f[i] = 1;
	        if(i > 0) f[i] = (f[i-1]*i)%MOD;
	    }
	    return f;
	}
	
	public static long combination(int n, int k, long MOD) {
	    if(n < k) return 0;
	    long[] f = fact(n, MOD);
	    long a = f[n];
	    long b = pow(f[k], MOD - 2, MOD);
	    long c = pow(f[n - k], MOD - 2, MOD);
	    return (((a*b)%MOD)*c)%MOD;
	}
}


Measured memory_bytes: 31828
s = gets.chomp.split(//)
n = s.size
ans = Array.new(n,0)
a = 0
s.each_with_index do |c,i| #前から
  if c == "R"
    a += 1
  elsif a != 0
    ans[i] += a/2
    ans[i-1] += (a+1)/2
    a = 0
  end
end
ans.reverse!
s.reverse_each.with_index do |c,j| # 後ろから
  if c == "L"
    a += 1
  elsif a != 0
    ans[j] += a/2
    ans[j-1] += (a+1)/2
    a = 0
  end
end
puts ans.reverse.join(" ")


Measured memory_bytes: 11516
c=0
def doublet(n,f):
    global c
    if n<f:
        c=c+1
        return doublet(2*n,f)
    else:
        return c
num,k=input().split()
num=int(num)
k=int(k)
#k=eval(input())
if (num>=1 and num<=10**5) and (k>=1 and k<=10**5):
    sum_power=0.0
    for i in range(1,(num+1),1):
        count=doublet(i,k)
        p=pow(2,count)*num
        sum_power=sum_power+(1/p)
        c=0
    print(sum_power)


    


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

constexpr int MAXN = 2000;
int L[MAXN];

bool pred(int i, int j, int k) {
    int total = L[i] + L[j] + L[k];
    int m = max(L[i], max(L[j], L[k]));
    return 2 * m < total;
}

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> L[i];
    sort(L, L+N);

    long long cnt = 0;
    for (int i = 0; i < N-2; i++)
        for (int j = i+1; j < N-1; j++) {
            int lo = j+1;
            int hi = N-1;
            while (lo <= hi) {
                int mid = lo + (hi-lo)/2;
                if (pred(i, j, mid)) lo = mid+1;
                else hi = mid - 1;
            }
            cnt += hi - j;
        }

    cout << cnt << "\n";
}


Measured memory_bytes: 256
import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
max_vale = c.most_common()[0][1]

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)

Measured memory_bytes: 121424
s=input()
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print(i+1,i+2)
        break
    if i+2<len(s):
        if s[i]==s[i+2]:
            print(i+1,i+3)
            break
else:
    print(-1,-1)

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

namespace ALDS1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var list = new LinkedList<int>();
            while (n-- > 0)
            {
                var line = Console.ReadLine().Split(' ');
                switch (line[0])
                {
                    case "insert": list.AddFirst(int.Parse(line[1])); break;
                    case "delete": list.Remove(int.Parse(line[1])); break;
                    case "deleteFirst": list.RemoveFirst(); break;
                    case "deleteLast": list.RemoveLast(); break;
                }
            }
            Console.WriteLine(string.Join(" ", Array.ConvertAll(list.ToArray(), (s) => s.ToString())));
        }
    }
}

Measured memory_bytes: 82540
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int n;

void input() {
	cin >> n;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	input();
 
	if(n == 25){
	    cout << "Christmas" << "\n";
	}else if(n == 24){
	    cout << "Christmas Eve" << "\n";
	}else if(n == 23){
	    cout << "Christmas Eve Eve" << "\n";
	}else if(n == 22){
	    cout << "Christmas Eve Eve Eve" << "\n";
	}
 
	return 0;
}


Measured memory_bytes: 256
def divisor(n):
    d = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            d.append(i)
    return d

n = int(input())
def solve():
    for a in divisor(n):
        b = n // a
        yield max(len(str(a)), len(str(b)))

print(min(solve()))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rg register
int n,m;
char a[2000][2000];
char b[2000][2000];
char h;
int main()
{
	cin>>n>>m;
	for(rg int i=1;i<=n;++i)
	{
		for(rg int j=1;j<=m;++j)
		{
			a[i][j]='.';
			b[i][j]='.';
		}
	}
	for(rg int i=1;i<=n;i+=2)
	{
		for(rg int j=1;j<=m;++j)
		{
			a[i][j]='#';
		}
	}
	for(rg int i=2;i<=n;i+=2)
	{
		for(rg int j=1;j<=m;++j)
		{
			b[i][j]='#';
		}
	}
	for(rg int i=1;i<=n;++i)
	{
		for(rg int j=1;j<=m;++j)
		{
			cin>>h;
			if(h=='#')
			{
				a[i][j]=h;
				b[i][j]=h;
			}
			
		}
//		char hs=getchar();
	}
//	putchar('\n');
	for(rg int i=1;i<=n;++i)
	{
		a[i][1]='#';
		b[i][1]='.';
        a[i][m]='.';
		b[i][m]='#';	
	}
	for(rg int i=1;i<=n;++i)
	{
		for(rg int j=1;j<=m;++j)
		{
			printf("%c",a[i][j]);
		}
		cout<<endl;
	}
	putchar('\n');
	for(rg int i=1;i<=n;++i)
	{
		for(rg int j=1;j<=m;++j)
		{
			printf("%c",b[i][j]);
		}
		putchar('\n');
	}
}

Measured memory_bytes: 5760
n, m = map(int, input().split())
S = [] # 鍵が空けることのできる宝箱(bit表現)
C = [] # 鍵のコスト
for _ in range(m):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  C.append(a)
  s = sum([2 ** (i - 1) for i in c])
  S.append(s)

# dp：それぞれの鍵について、空けることができる(1)/できない(0)の二つの状態を表す。
INF = 10 ** 19
dp = [INF] * (1 << n) # 1 << n は2 ** n と同じ
dp[0] = 0
for s, c in zip(S, C):
  for i in range(1 << n):
    j = i | s # jは鍵を使った後の状態。 i -> (sを開ける) -> j 
    x = dp[i] + c
    dp[j] = min(dp[j], x)
    
ans = dp[-1]
if ans == INF:
  print(-1)
else:
  print(ans)

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

int main() {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long x,y,z,w;
    x = a * c; //cout << x << endl;
    y = a * d; //cout << y << endl;
    z = b * c; //cout << z << endl;
    w = b * d; //cout << w << endl;
    long long ans = max(x,max(y,max(z,w)));
    cout << ans << endl;
}


Measured memory_bytes: 3632
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->skipInput();
	data->getInput();

	AtCoder::Num num = data->getNum();

	const int max = num.size() ;
	
	int ans = 0;
	for (int i = 0; i < max; i++) {
		if (0 == (i + 1) % 2) {
			continue;
		}
		if (0 != num[i] % 2) {
			ans++;
		}
	}

	printf("%d\n", ans);

	delete(data);

	return 0;
}


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

int main(){
	int N;
	cin>>N;
	int h[101]; int m[101];
	for(int i=0; i<N; i++){
		cin>>h[i]>>m[i];
	}
	h[N] = 24; m[N] = 0;

	int M;
	cin>>M;
	int k[101]; int g[101];
	for(int j=0; j<M; j++){
		cin>>k[j]>>g[j];
	}
	k[M] = 24; g[M] = 0;

	for(int i=0,j=0; i<N||j<M;){
		if(h[i]==k[j]&&m[i]==g[j]){
			cout<<h[i]<<':'<<m[i]/10<<m[i]%10;
			i++; j++;
		}
		else if(h[i]<k[j]||(h[i]==k[j]&&m[i]<g[j])){
			cout<<h[i]<<':'<<m[i]/10<<m[i]%10;
			i++;
		}
		else{
			cout<<k[j]<<':'<<g[j]/10<<g[j]%10;
			j++;
		}
		
		if(i==N && j==M){
			cout<<endl;
		}
		else{
			cout<<' ';
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
	long long number = 0;
	string s;
	getline(cin, s);
	
	
	for(int i = 0; i < s.size(); i++){
		// cout << "number" << number << endl << "s[i]" << s[i];
		number += (int)(s[i]-48);
	}
	// cout << number;
	if(number % 9 == 0 || number == 0){
		cout << "Yes";
	} 
	else{
		cout << "No";
	}
		
	return 0;
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int N=gi();
        int L=gi();
        int c=0;
        if (L>0) {
        	for (int i=2; i<=N; i++) {
        		c+=L+i-1;
        	}
        } else if(N+L>0) {
        	for (int i=1; i<=N; i++) {
        		c+=L+i-1;
        	}
        } else {
        	for (int i=1; i<=N-1; i++) {
        		c+=L+i-1;
        	}
        }
        
        System.out.print(c);

//        if (s>L[n-2]) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35420
#include <iostream>

int main() {
	int n;
	
	while (std::cin >> n, n) {
		int ans = 0;

		for (int i = 0; i < n / 4; ++i) {
			int x;
			std::cin >> x;

			ans += x;
		}

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

Measured memory_bytes: 3076
n = int(input())
A = [int(input()) for i in range(n)]

B = A[:]
A.sort()
B.sort(reverse=True)
A = [A[(n-1)//2]] + [A[0]] + A[1:n//2]

ans = 0
prev = A[0]
for i in range(n):
    if i % 2 == 0:
        ans += abs(prev-A[i//2])
        prev = A[i//2]
    else:
        ans += abs(prev-B[i//2])
        prev = B[i//2]

A = B[:]
A.sort()
B = [B[(n-1)//2]] + [B[0]] + B[1:n//2]

ans2 = 0
prev = B[0]

for i in range(n):
    if i % 2 == 1:
        ans2 += abs(prev-A[i//2])
        prev = A[i//2]
    else:
        ans2 += abs(prev-B[i//2])
        prev = B[i//2]

print(max(ans, ans2))

Measured memory_bytes: 8540
#include <iostream>
#include <string>

using namespace std;

// 最初の入力：イニング数
// 1イニングは3アウトになるまで
// シングルヒットの場合
// 1つずつ押し出されるため、走者は消えない。
// 3塁に走者がいる場合は1点を返す。
// ホームランの場合
// 1点＋走者の数。走者はすべて消滅

// 塁の状態を管理する
struct Diamond {
	bool first;
	bool second;
	bool third;
	Diamond() : first(), second(), third(){};

	int onHit() {
		int result = 0;
		if (third != false) {
			result = 1;
		}
		if (second != false) {
			third = true;
		}
		if (first != false) {
			second = true;
		}
		first = true;
		return result;
	}
	int onHomeRun() {
		// 最低でも1点なので1で初期化
		int result = 1;
		if (third != false) {
			result++;
		}
		if (second != false) {
			result++;
		}
		if (first != false) {
			result++;
		}
		first = false;
		second = false;
		third = false;
		return result;
	}
};

int main() {

	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		int out_count = 0;
		int point = 0;
		Diamond dia;
		while (out_count < 3) {
			string temp;
			cin >> temp;

			if (temp == "HIT") {
				point += dia.onHit();
			}
			else if (temp == "HOMERUN") {
				point += dia.onHomeRun();
			}
			else {
				// その他をOUTとしておく。
				out_count++;
			}
		}
		cout << point << endl;
	}
	return 0;
}

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

Measured memory_bytes: 600
def is_intersection(x0, y0, x1, y1, x2, y2, x3, y3)
  if x0 < x1 && ((x2 < x0 && x3 < x0) || (x1 < x2 && x1 < x3))
    return false
  elsif x1 <= x0 && ((x2 < x1 && x3 < x1) || (x0 < x2 && x0 < x3))
    return false
  elsif y0 < y1 && ((y2 < y0 && y3 < y0) || (y1 < y2 && y1 < y3))
    return false
  elsif y1 <= y0 && ((y2 < y1 && y3 < y1) || (y0 < y2 && y0 < y3))
    return false
  else
    t0 = (x0-x1) * (y2-y0) + (y0-y1) * (x0-x2)
    t1 = (x0-x1) * (y3-y0) + (y0-y1) * (x0-x3)
    t2 = (x2-x3) * (y0-y2) + (y2-y3) * (x2-x0)
    t3 = (x2-x3) * (y1-y2) + (y2-y3) * (x2-x1)
    if t0 * t1 <= 0 && t2 * t3 <= 0
      return true
    else
      return false
    end
  end
end

def distance(x0, y0, x1, y1, qx, qy)
  v0 = [x1 - x0, y1 - y0]
  v1 = [qx - x0, qy - y0]
  inner_product = v0[0]*v1[0]+v0[1]*v1[1]
  if inner_product <= 0
    return Math.sqrt(v1[0]*v1[0]+v1[1]*v1[1])
  elsif inner_product < v0[0]*v0[0]+v0[1]*v0[1]
    d22 = inner_product * inner_product / (v0[0]*v0[0]+v0[1]*v0[1])
    return Math.sqrt(v1[0]*v1[0]+v1[1]*v1[1] - d22)
  else
    v1 = [qx - x1, qy - y1]
    return Math.sqrt(v1[0]*v1[0]+v1[1]*v1[1])
  end
end

q = gets.to_i
q.times{
  x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
  if is_intersection(x0, y0, x1, y1, x2, y2, x3, y3)
    puts 0.0
  else
    p [distance(x0, y0, x1, y1, x2, y2), distance(x0, y0, x1, y1, x3, y3), distance(x2, y2, x3, y3, x0, y0), distance(x2, y2, x3, y3, x1, y1)].min
  end
}

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

int main(){
	int deg[4] = {0, 0 , 0, 0};
	for(int i=0; i<3; i++){
		int a, b;
		cin>>a>>b;
		a--;
		b--;
		deg[a]++;
		deg[b]++;
	}
	for(int i=0; i<4; i++){
		if(deg[i]>2){
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
 
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
 
#define LL_MOD          (ll)1000000007
#define LL_INF          (ll)1 << 62
#define INT_INF         (int)1 << 30
 
#define rSort(a)        sort(a.rbegin(),a.rend())
#define Sort(a)         sort(a.begin(),a.end())
#define Reverse(a)      reverse(a.begin(),a.end())
#define Sum(a)          accumulate(a.begin(), a.end(), 0)
#define REP(i, n)       for(ui i = 0;i < n;i++)
#define REPR(i, n)      for(ui i = n;i >= 0;i--)
#define FOR(i, m, n)    for(ui i = m;i < n;i++)
#define pb(i)           push_back(i)
#define mp              make_pair
#define SWAP(x,y)       ((x != y)&&(x ^= y,y ^= x,x ^= y))
 
 
int main(int argc, char* argv[]) {
 
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S,T;
	int ans = 0;
 
	cin >> S;
	cin >> T;
 
	for(ll i=0;i<S.length();i++){
		if(S[i]==T[i]){
			ans++;
		}
	}
  
	cout << ans << endl;
 
	return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

#define fi first
#define se second

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

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

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}

int main() {
 ll N;
 cin >> N;

 ll ans = log10(N) + 1;

 for (ll i = 2; i * i <= N; i++) {
   if (N % i == 0) {
     ll F = max((int)(log10(N / i) + 1), (int)(log10(i) + 1));
     ans = min(ans, F);
   }
 }

 cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
class Main{

	public static void main (String[] args) {

		Main main = new Main();

		java.util.Scanner sc = new java.util.Scanner(System.in);

		long X = sc.nextLong();
		long K = sc.nextLong();
		long D = sc.nextLong();

		long nowplace = X;

		if (X>0) {
			long count = X/D;
			if (X%D!=0) {
				count++;
			}
			if (count<K) {
				nowplace = X-(count*D);
				if (count==K) {
					System.out.println(Math.abs(nowplace));
				} else if ((K-count)%2==0) {
					System.out.println(Math.abs(nowplace));
				} else {
					System.out.println(Math.abs(nowplace+D));
				}
			} else {
				nowplace = X-(K*D);
				System.out.println(Math.abs(nowplace));
			}
		} else {
			long count = Math.abs(X)/D;
			if (X%D!=0) {
				count++;
			}
			if (count<K) {
				nowplace = X+(count*D);
				if (count==K) {
					System.out.println(Math.abs(nowplace));
				}
				if ((K-count)%2==0) {
					System.out.println(Math.abs(nowplace));
				} else {
					System.out.println(Math.abs(nowplace-D));
				}
			} else {
				nowplace = X+(K*D);
				System.out.println(Math.abs(nowplace));
		}
		sc.close();
		}
	}
}

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	string s;
	cin >> s;

	int n = s.size();
	vector<int> v(3);
	v[0] = count(s.begin(), s.end(), 'a');
	v[1] = count(s.begin(), s.end(), 'b');
	v[2] = count(s.begin(), s.end(), 'c');
	sort(v.begin(), v.end(), greater<int>());

	int arr1 = n / 3 + (n % 3 >= 1);
	int arr2 = n / 3 + (n % 3 >= 2);
	int arr3 = n / 3;
	cout << (arr1 > v[0] || arr2 > v[1] || arr3 > v[2] ? "NO" : "YES") << endl;
}


Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef struct{
    int p;
    int l;
    int r;
    int s;
    int deg;
    int dep;
    int h;
}node;

node* nd;

int calc(int id, int dep){
    if(id<0)return 0;
    nd[id].dep = dep;
    int lh = calc(nd[id].l, dep+1);
    int lr = calc(nd[id].r, dep+1);
    nd[id].h = max(lh,lr);
    return nd[id].h+1;
}

void print(int id){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",id,nd[id].p,nd[id].s,nd[id].deg,nd[id].dep,nd[id].h);
    if(nd[id].p < 0)printf("root\n");
    else if(nd[id].deg == 0)printf("leaf\n");
    else printf("internal node\n");
}

int main(){
    int i, n, id, l, r, p;
    scanf("%d",&n);
    nd = (node*)malloc(sizeof(node)*n);
    for(i=0;i<n;i++){
        nd[i].p = -1;
        nd[i].deg = 0;
        nd[i].s = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d %d %d",&id,&l,&r);
        nd[id].l = l;
        nd[id].r = r;
        nd[l].s = r;
        nd[r].s = l;
        if(l>=0){
            nd[l].p = id;
            nd[id].deg++;
        }
        if(r>=0){
            nd[r].p = id;
            nd[id].deg++;
        }
    }
    int root;
    for(root = 0; root<n; root++){
        if(nd[root].p < 0)break;
    }
    int h = calc(root,0);
    for(i=0;i<n;i++)print(i);
    return 0;
}



Measured memory_bytes: 2764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y


N = int(readline())
A = [None]*N
temp = read().split()
for i,s in enumerate(temp):
    s = s.decode().rstrip()
    if '.' in s:
        a,b = s.split('.')
        n = int(a+b)*10**(9-len(b))
    else:
        n = int(s)*10**9
    A[i] = n

def conv(n):
    c2 = 0
    while n%2 == 0:
        n //= 2
        c2 += 1
    c5 = 0
    while n%5 == 0:
        n //= 5
        c5 += 1
    return (c2,c5)

A = [conv(a) for a in A]
grid = [[0]*19 for _ in range(19)]

for x,y in A:
    grid[min2(x,18)][min2(y,18)] += 1

temp = [[0]*20 for _ in range(19)]
for i in range(19):
    c = 0
    for j in reversed(range(19)):
        c += grid[i][j]
        temp[i][j] = c

acc = [[0]*20 for _ in range(20)]

for j in range(20):
    c = 0
    for i in reversed(range(19)):
        c += temp[i][j]
        acc[i][j] = c

cnt = 0
for x,y in A:
    p,q = max2(0,18-x),max2(0,18-y)
    cnt += acc[p][q]
    if x*2 >= 18 and y*2 >= 18:
        cnt -= 1

print(cnt//2)

Measured memory_bytes: 111144
import sys
b=sys.stdin.buffer
import numpy as np
H,W=map(int,b.readline().split());p=min(H,W)+1
S=np.pad((np.frombuffer(b.read(),dtype='S1')==b'#').reshape(H,-1)[:,:W].astype(int),(p,p),'constant')
a=0
for _ in[0]*4:
  d=S[p:,p:].copy()
  for n in range(H+p):d[n,:W]+=d[n-1,1:W+1]
  for n in range(p):a+=(S[1+p:H+1+p,1-n+p:W+1-n+p]*S[1-n+p:H+1-n+p,1+p:W+1+p]*(d[1+n:H+1+n,1:W+1]-d[1:H+1,1+n:W+1+n])).sum()
  S = S.T[::-1,:];H,W=W,H
print(a)

Measured memory_bytes: 27240
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>


typedef long double ld;
typedef long long ll;
using namespace std;
const ll MX=5e6+9;
const ld pi = acos(-1);
const ll mod = 1e9+7;

//bool cmp ( int a,int b ) { return a>b; }

ll po ( ll a , ll b )
{
    if ( b==0 ) { return 1; }
    ll x = po ( a , b/2 );
    x *= x%mod;
    if ( b%2 ) { x*=a%mod; }
    return x%mod;
}

ll gcd (  ll a , ll b )
{
    if ( b==0 ) return a;
    else { gcd( b , a%b ); }
}
bool cmp ( int a , int b ) { return (a>b); }
int dx[]={ 0 , 0 , -1 , 1 , 1 , -1 , -1 , 1 };
int dy[]={ 1 , -1 , 0 , 0 , 1 , -1 , 1 , -1 };
ll a[MX],b[MX],c[MX];
int n,m,l;


ll bs ( ll x , ll id )
{
    ll st,en,mid;
    if ( id==2 )
    {
        st=0,en=m;
    }
    else { st=0,en=l; }
    ll ans=0;
    if ( id==2 ){
    ans=m-1;
    while ( st<=en )
    {
        mid = st+(en-st)/2;
        if ( b[mid]>=x ) { ans=mid; en=mid-1; }
        else { st=mid+1; }
    }
    }
    else
    {
    ans=l-1;
    while ( st<=en )
    {
        mid = st+(en-st)/2;
        if ( c[mid]>=x ) { ans=mid; en=mid-1; }
        else { st=mid+1; }
    }
    }
    return ans;
}

ll p[MX];

void f ( int x )
{
    int i=2;
    while(i<=x)
    {
        int c=0;
        while ( x%i==0 )
        {
            c++;
            x/=i;
        }
        p[i] += c;
        i++;
    }

}

int main()
{
    int n;
    cin>>n;
    ll c=0;
    ll ans=1;
    for ( int i=1 ; i<=n ; i++ )
    {
        f(i);
    }

    for ( int i=2 ; i<=n ; i++ )
    {
        if ( !ans ) { if ( p[i] )ans=p[i]+1; }
        else { if ( p[i] ) { ans = (ans*(p[i]+1))%mod; }  }
    }

    cout<<ans;



	return 0;
}


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

int main() {
  int K;
  cin >> K;
  if(K%2==0 || K%5==0){
    cout << -1 << endl;
  }
  else{
    long long i = 0;
    long long mod = 7 % K;
    long long mod_add = mod;
    while(mod != 0){
      i++;
      mod_add = (mod_add * 10) % K;
      mod = (mod + mod_add) % K;
    }
    i++;
    cout << i << endl;
  }
}

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

long long int n,m,sum;
int main(){
    cin>>n>>m;
    sum = n+m;
    if(sum%2==0){
        cout<<sum/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

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

int main(){
	int open[ 3 ];

	while ( cin >> open[ 0 ] >> open[ 1 ] >> open[ 2 ] ){
		int allow = 20 - open[ 0 ] - open[ 1 ];
		int high = 0;
		for ( int i = 10; i > 0; --i ){
			if ( ( i ==  open[ 0 ] ) || ( i == open[ 1 ] ) || ( i == open[ 2 ] ) ) continue;
			if ( i > allow ){
				++high;
				if ( high == 4 ) break;
			}
		}

		if ( high == 4 ){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
	}

	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

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

int main() {
	double n, k;
	cin >> n >> k;
	vector<double> ruijou(25);
	ruijou[0] = 1;
	FOR(i, 1, 24) {
		ruijou[i] = ruijou[i - 1] * 2;
	}
	double sum = 0;
	FOR(i, 1, n) {
		double bai = k / i;
		double omotecnt = lower_bound(ALL(ruijou), bai) - ruijou.begin();
		double p = 1.0f / n;
		FOR(j, 1, omotecnt) {
			p /= 2.0f;
		}
		sum += p;
	}
	cout << setprecision(16) << sum << endl;
	return(0);
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int a;
cin>>a;
cout<<a+a*a+a*a*a<<endl;
return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

vector<string> M;

int main(){

    
    while(true){
    int w,h;
    cin>>w>>h;
        
        if(w==0&&h==0)break;
        
    M.clear();
        
    REP(i,h){
        string s; cin>>s;
        M.push_back(s);
    }
    
    int x,y = 0;
    for(x=0;x<w;x++){
        for(y=0;y<h;y++){
            if(M[y][x]=='@')goto nexts;
        }
    }
    
nexts:;
    
    int ans=0;
    stack<pair<int,int>> sta;
    sta.push(make_pair(x,y));
    while(sta.size()!=0){
        int xt=sta.top().first,yt=sta.top().second;
        sta.pop();
        
        if(M[yt][xt]=='.'){
            M[yt][xt]= '#';
            ans++;
        }
        
        if(xt<w-1)if(M[yt][xt+1]=='.')sta.push(make_pair(xt+1,yt));
        if(xt>0)if(M[yt][xt-1]=='.')sta.push(make_pair(xt-1,yt));
        if(yt<h-1)if(M[yt+1][xt]=='.')sta.push(make_pair(xt,yt+1));
        if(yt>0)if(M[yt-1][xt]=='.')sta.push(make_pair(xt,yt-1));
        
    }
    
    cout<<ans+1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int K, X;
    cin >> K >> X;
    for(int i = 0; i < 2*K - 1; i++)
    {
        cout << i + X - K + 1 << " " ;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    vector<ll> use;
    vector<ll> tmp;
    rep(i, N) {
        if (tmp.empty() || tmp.back() != A[i]) {
            tmp.push_back(A[i]);
        } else {
            tmp.pop_back();
            use.push_back(A[i]);
        }
    }
    sort(all(use));
    ll ans = 0;
    if (use.size() >= 2) {
        ll a = use[use.size()-1];
        ll b = use[use.size()-2];
        ans = a * b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
fn dfs(v: usize, adjl: &Vec<Vec<usize>>, s: usize, res: &mut usize) {
    for &u in &adjl[v] {
        // 未訪問
        if s >> u & 1 == 0 {
            dfs(u, adjl, s | 1 << u, res);
        }
    }
    // これが全部の条件
    if s == (1 << adjl.len()) - 1 {
        *res += 1;
    }
}

fn solve() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut adjl = vec![vec![]; n];
    for _ in 0..m {
        let (a, b): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        adjl[a].push(b);
        adjl[b].push(a);
    }
    let mut res = 0;
    dfs(0, &adjl, 1, &mut res);
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <string.h>
#include <math.h>

using namespace std;

vector<int> n;
string ans = "", in;

void df(int c, int sum, string s) {
	if (ans != "") return;
	if (c == n.size()) {
		if (sum == 7)ans = s;
		return;
	}
	df(c + 1, sum + n[c], s + "+" + in[c]);
	df(c + 1, sum - n[c], s + "-" + in[c]);
	return;
}

int main()
{
	cin >> in;

	for (int i = 0; i < in.size(); i++) n.push_back(in[i] - '0');
	df(1, n[0], std::to_string(n[0]));
	cout << ans << "=7" << endl;

	return 0;
}


Measured memory_bytes: 256
s, t = input(), input()


def d(s, t):
    cnt = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            cnt += 1
    return cnt


n = len(s)
m = len(t)
ans = 1000000
for i in range(n - m + 1):
    ans = min(ans, d(s[i:i + m], t))
print(ans)


Measured memory_bytes: 67228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;

const int MAX = 2e5;

int bit[MAX+1];

void add(int i, int x) {
    while (i <= MAX) {
        bit[i] += x;
        i += i & -i;
    }
}

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

int main() {
    // input
    int n;
    cin >> n;
    int p[n];
    rep(i, n) {
        cin >> p[i];
    }
    // solve
    int cnt = 0;
    rep(i, n) {
        if (sum(p[i]) == 0) cnt++;
        add(p[i], 1);
    }
    // output
    cout << cnt << endl;
}

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

int main()
{
  int N;
  string S;
  cin >> N >> S;
  long ans = 1;
  char slime = S[0];

  rep(i, N - 1)
  {
    if (S[i + 1] != slime)
    {
      slime = S[i + 1];
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

typedef pair<float, float> point;
const float rad = (M_PI*60) / 180.0;
int n;

void koch(int d, point p1, point p2) {
  if (!d) return;

  float sx = (2*p1.first + 1*p2.first) / 3;
  float sy = (2*p1.second + 1*p2.second) / 3;
  float tx = (1*p1.first + 2*p2.first) / 3;
  float ty = (1*p1.second + 2*p2.second) / 3;
  float ux = (tx-sx)*cos(rad) - (ty-sy)*sin(rad)+sx;
  float uy = (tx-sx)*sin(rad) + (ty-sy)*cos(rad)+sy;
  
  cout << fixed << setprecision(10);

  koch(d-1, p1, point(sx, sy));
  cout << sx << ' ' << sy << endl;

  koch(d-1, point(sx, sy), point(ux, uy));
  cout << ux << ' ' << uy << endl;

  koch(d-1, point(ux, uy), point(tx, ty));
  cout << tx << ' ' << ty << endl;

  koch(d-1, point(tx, ty), p2);
}

int main() {
  cin >> n;

  cout << fixed << setprecision(10);
  cout << 0.0 << ' ' << 0.0 << endl;  
  koch(n, point(0, 0), point(100, 0));
  cout << 100.0 << ' ' << 0.0 << endl;  
  return 0;
}

Measured memory_bytes: 1248
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
from collections import deque,defaultdict
import heapq
from itertools import combinations
import bisect
from decimal import Decimal


a,b=map(str,input().split())
b=Decimal(b)
a=int(a)
p=list(str(a*b))
ans=''
for i in p:
    if i=='.':
        break
    ans+=i
print(ans)


Measured memory_bytes: 9936
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/math.hpp>

using namespace std;
using ll = long long;

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

  int t; cin>>t;
  while (t--) {
    int n,m,a,b; cin>>n>>m>>a>>b;
    cout << atcoder::floor_sum(n, m, a, b) << endl;
  }

  return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define m 1000000007
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define scan(a,n) for (ll i = 0; i < n; ++i) cin >> a[i]

int main() 
{  
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n,c=0,d=0;
	cin>>n;
	while(n--)
	{
		ll a,b;
		cin>>a>>b;
		if(a==b)
		{
			c++;
			if(c==3)
			d=c;
		}
		else
			c=0;
	}
	if(d==3)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
} 

Measured memory_bytes: 3652
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split();
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);

        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var dp = new int[n];
        for (int i = 1; i < n; i++) dp[i] = (int)1e9;

        for (int i = 1; i < n; i++)
        {
            for (int j = 1; j <= k; j++)
            {
                if (j <= i)
                {
                    dp[i] = Math.Min(dp[i],
                        dp[i - j] + Math.Abs(h[i] - h[i - j]));
                }
            }
        }

        Console.WriteLine(dp[n - 1]);
    }
}


Measured memory_bytes: 18912
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   string s, t;
   cin >> s >> t;
   int cnt = 0;
   for (int i = 0; i < (int)s.length(); i++){
	   cnt += s[i] != t[i];  
	 }
   int ret = s.length() - cnt;
   cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


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

using namespace std;

int main()
{
    string lower_case_alphabet = "abcdefghijklmnopqrstuvwxyz";
    vector<bool> solve_check(26,false);
    string s;
    cin >> s;
    vector<char> s_check;
    for(int i=0;i < lower_case_alphabet.length();i ++)
    {
        bool flag = false;
        for(int j=0;j < s.length();j ++)
        {
            if(s[j] == lower_case_alphabet[i])
            {
                flag = true;
                solve_check[i] = true;
            }
        }
        if(count(solve_check.begin(),solve_check.end(),true) == 26)
        {
            cout << "None" << endl;
        }
        else if(!flag)
        {
            cout << lower_case_alphabet[i] << endl;
            break;
        }
    }
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}

template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
 
ll fac[SIZE], inv[SIZE], facinv[SIZE];
void make() {
	fac[0] = fac[1] = 1; inv[1] = 1; facinv[0] = facinv[1] = 1;
	for (ll i = 2; i < SIZE; i++) {
		fac[i] = (fac[i-1] * i) % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		facinv[i] = facinv[i-1] * inv[i] % MOD;
	}
}
ll combi(ll a, ll b) {
	if (a < b) return 0;
	return fac[a] * (facinv[b] * facinv[a-b] % MOD) % MOD;
}

int main() {
	ll a, b;
	string ans;
	scanf ("%lld %lld", &a, &b);
	if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
		ans = "Possible";
	} else {
		ans = "Impossible";
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256