akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "KIHBR") cout << "YES" << endl;
    else if(s == "AKIHBR") cout << "YES" << endl;
    else if(s == "KIHABR") cout << "YES" << endl;
    else if(s == "KIHBAR") cout << "YES" << endl;
    else if(s == "KIHBRA") cout << "YES" << endl;
    else if(s == "AKIHABR") cout << "YES" << endl;
    else if(s == "AKIHBAR") cout << "YES" << endl;
    else if(s == "AKIHBRA") cout << "YES" << endl;
    else if(s == "KIHABAR") cout << "YES" << endl;
    else if(s == "KIHABRA") cout << "YES" << endl;
    else if(s == "KIHBARA") cout << "YES" << endl;
    else if(s == "AKIHABAR") cout << "YES" << endl;
    else if(s == "AKIHABRA") cout << "YES" << endl;
    else if(s == "AKIHBARA") cout << "YES" << endl;
    else if(s == "KIHABARA") cout << "YES" << endl;
    else if(s == "AKIHABARA") cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,count=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
  if(c%i==0)
    count++;
    }
    cout<<count<<"\n";
  return 0;
}



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

//ABC125D
int compare_lli(const void *a, const void *b) {
  long *A=(long long *) a;
  long *B=(long long *) b;
  if(*A>*B) return 1;
  if(*A<*B) return -1;
  return 0;
}
int main(void) {
  int n, k, i, cou=0;
  scanf("%d", &n);
  long long a[n], tmp, sum=0, min=1e10;
  for(i=0; i<n; i++){
    scanf("%lld", &tmp);
    if(tmp<0) cou++;
    a[i]=abs(tmp);
    sum+=a[i];
    if(min>a[i]) min=a[i];
  }
  if(cou%2==0) printf("%lld", sum);
  else printf("%lld", sum-2*min);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ran 100010
int n,res,W;
vector<int> e[ran];
int sz[ran];
void dfs1(int x,int fat){
	int cnt = 0;
	sz[x] = 0;
	for(vector<int>::iterator it = e[x].begin(); it != e[x].end(); it++){
		int y = *it;
		if(y == fat)continue;
		dfs1(y, x);
		cnt ++;
		sz[x] += sz[y];
	}
	sz[x] += cnt / 2;
	if(x == fat)sz[x] += cnt % 2;
}
bool dfs(int x,int fat){
	vector<int> e;
	for(vector<int>::iterator it = ::e[x].begin(); it != ::e[x].end(); it++){
		int y = *it;
		if(y == fat)continue;
		if(!dfs(y, x))return false;
		e.push_back(sz[y] + 1);
	}
	if(x == fat){
		if(e.size() % 2)e.push_back(0);
		sort(e.begin(), e.end());
		int L = e.size();
		for(int i=0,j=L-1; i<j; i++,j--)
			if(e[i] + e[j] > W)
				return false;
		return true;
	}
	if(e.size() % 2 == 0)e.push_back(0);
	sort(e.begin(), e.end());
	int L = e.size();
	int lo = 0, hi = L;
	while(lo != hi){
		int mi = (lo + hi)/2;
		bool flag = true;
		for(int i=0,j=L-1;;){
			if(i==mi)i++;
			if(j==mi)j--;
			if(i>j)break;
			if(e[i] + e[j] > W){
				flag = false;
				break;
			}
			i++;j--;
		}
		if(flag)
			hi = mi;
		else
			lo = mi+1;
	}
	if(hi == L)return false;
	sz[x] = e[lo];
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs1(1,1);
	printf("%d ",sz[1]);
	int lo = 1, hi = n-1;
	while(lo != hi){
		W = (lo + hi)/2;
		if(dfs(1, 1))
			hi = W;
		else
			lo = W+1;
	}
	printf("%d\n",lo);
	return 0;
}


Measured memory_bytes: 16768
import java.util.*

fun main(args:Array<String>):Unit {
    while(true){
        val (n, p, q) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && p == 0 && q == 0) return
        val stack:Stack<Pair<Int, Boolean>> = Stack()
        repeat(n) {
            stack.push(Pair(p, false))
            stack.push(Pair(q, true))
        }
        repeat(n){
            readLine()
            readLine()!!.trim().split(' ').map(String::toInt).forEachIndexed { index, s ->
                stack.push(Pair(s, index % 2 == 0))
            }
        }
        val sorted = stack.sortedWith(compareBy(Pair<Int, Boolean>::first, Pair<Int, Boolean>::second))
        var max = 0
        var count = 0
        var startTime = 0
        for ((time, isStart) in sorted){
            if (!isStart){
                if (count == 0) startTime = time
                ++count
            }else{
                --count
                if (count == 0){
                    if (max < time - startTime)
                        max = time - startTime
                }
            }
        }
        println((max / 100) * 60 + max % 100)
    }
}


Measured memory_bytes: 31396
a, b = [int(i) for i in input().split()]

e_min = a/0.08
e_max = (a+1)/0.08

t_min = int(b/0.1)
t_max = int((b+1)/0.1)

num = -1
for i in range(t_min, t_max):
  if i >= e_min and e_max > i:
    num = i
    break
    
print(num)

Measured memory_bytes: 3064
# coding:utf-8
n = int(input())
num_list = [int(x) for x in input().split(' ')]

diff_list = []
for i, num in enumerate(num_list):
    if not i+1 == num:
        diff_list.append([i+1, num])
    if len(diff_list) > 2:
        break
if len(diff_list) == 2 and diff_list[0][0] == diff_list[1][1] and diff_list[0][1] == diff_list[1][0]:
    print('YES')
elif len(diff_list) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    lw = [0] * N
    re = [0] * N

    if(S[0] == 'W'):
        lw[0] = 1
    if(S[N-1] == 'E'):
        re[N-1] = 1

    for i in range(1,N):
        if(S[i] == 'W'):
            lw[i] = lw[i-1] + 1
        else:
            lw[i] = lw[i-1]

    for i in reversed(range(0, N-1)):
        if(S[i] == 'E'):
            re[i] = re[i+1] + 1
        else:
            re[i] = re[i+1]

    # print(lw)
    # print(re)

    ans = 1000000000
    for i in range(N):
        if(i == 0):
            ans = min(ans, re[i+1])
        elif(i == N-1):
            ans = min(ans, lw[i-1])
        else:
            ans = min(ans,lw[i-1]+re[i+1])

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef set<int> si;
typedef map<string, int> msi;

#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define sz(a) int((a).size())
#define clr(a) memset(a,0,sizeof(a))
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);
const int oo = 0x3f3f3f3f;

template<class T> inline T gcd(T a,T b) //NOTE:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

/////////////////////////////////////////////////////////////////////

/*bool sortby(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return (a.second < b.second);
}*/

const int MAX_N = 123456;

//int arr[MAX_N];

int main(){
    int A,B;
    cin>>A>>B;
    if(A!=2 && B!=2)
        cout<<"Yes\n"<<endl;
    else
        cout<<"No\n"<<endl;
    return 0;
}


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

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

    int flag = 0;
    int ans = 0;
    while(1){
        flag = 0;
        for(int j = 2; j <= n / 2; j++){
            if(n % j == 0){
                flag = 1;
                break;
            }
        }

        if(flag == 0){
            ans = n;
            break;
        }
        n++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static int N =0;
static int INF = (int) (1e9+5);
    public static void main(String[] args) throws IOException {
	// write your code here
        N = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());
        int [] arr =new int[N];
        for (int i=0;i<N;i++)
            arr[i]  = Integer.parseInt(st.nextToken());
        int [] dp =new int[N];
        for (int i=0;i<N;i++)
            dp[i] = INF;
        dp[0] = 0;
     //   pw.println(INF+1000);
        for (int i=0;i<N;i++){
           for (int j=1;j<=2;j++) {
               int k= j+i;
               if (k<N) {
                   int u = dp[i] + Math.abs(arr[i] - arr[k]);
                   int v = dp[k];
                   //System.out.println(u+ " "+v);
                   dp[k] = Math.min(u, v);
               }
           }

        }
        pw.println(dp[N-1]);
        pw.flush();
    }
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c){
        cout << 1 << endl;;
    }
    else if(a == b || b == c || c == a){
        cout << 2 << endl;
    }
    else {
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
import sys
import numpy as np
from scipy.sparse import coo_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
read = sys.stdin.read

N, *xy = map(int, read().split())
xy = np.array(xy, np.int64).reshape(N, 2)
x = xy[:, 0]
y = xy[:, 1]

arg_x = np.argsort(x)
arg_x1 = arg_x[1:]
arg_x2 = arg_x[:-1]

arg_y = np.argsort(y)
arg_y1 = arg_y[1:]
arg_y2 = arg_y[:-1]

edges_x = x[arg_x1] - x[arg_x2]
edges_y = y[arg_y1] - y[arg_y2]

edges = np.concatenate([edges_x, edges_y])
towns_1 = np.concatenate([np.minimum(arg_x1, arg_x2), np.maximum(arg_y1, arg_y2)])
towns_2 = np.concatenate([np.maximum(arg_x1, arg_x2), np.minimum(arg_y1, arg_y2)])

graph = coo_matrix((edges, (towns_1, towns_2)), shape=(N, N)).tocsr()
tree = minimum_spanning_tree(graph, overwrite=True)
answer = int(tree.sum())

print(answer)

Measured memory_bytes: 36032
#include <iostream>

using namespace std;

int main()
{
	int nb5 = 0, nb7 = 0;
	for (int i = 0; i < 3; ++i) {
		int s;
		cin >> s;
		nb5 += s == 5;
		nb7 += s == 7;
	}
	cout << (nb5 == 2 && nb7 == 1 ? "YES" : "NO") << endl;
    return 0;
}


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

int n ;
string s ;

int a[] = {1,2,4,3,5,6,7} ;
int dp[1002][8] = {} ;

int bit_num( char m ){
	
	switch (m){
	case 'J' : return 1 ;
	case 'O' : return 2 ;
	case 'I' : return 4 ;
	}
}

int f( int day , int x ){
	if( day >= n ) return 1 ;
	if( dp[day][x] != 0 ) return dp[day][x] ;
	
	int ans = 0 ;
	for( int i=0 ; i<7 ; i++ ){
		if( ( x & a[i] ) && ( a[i] & bit_num( s[day] ) ) ){
			ans += f( day+1 , a[i] ) ;
			ans %= 10007 ;
		}
	}
	
	return dp[day][x] = ans ;
}

int main(){
	
	cin >> n ;
	cin >> s ;
	
	cout << f(0,1) << endl ;
	
return 0;
}

Measured memory_bytes: 1312
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    a = ni()
    print(a + a**2 + a**3)
    return

solve()


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

using namespace std;

int main(int argc, char const *argv[]) {
	std::vector<std::vector<int>> c;
	int temp;
	c.resize(3);
	for (size_t i = 0; i < 3; i++) {
		c[i].resize(3);
		std::cin >> c[i][0] >> c[i][1] >> c[i][2];
	}

	for (size_t i = 0; i < 3; i++) {
		for (size_t j = 0; j < 3; j++) {
			if (c[i][j] < 0) {
				std::cout << "No" << '\n';
				return 0;
			}
		}
	}

	// 縦方向に剣山
	for (size_t i = 0; i < 3; i++) {
		if ((c[0][i]-c[0][(i+1)%3] != c[1][i]-c[1][(i+1)%3]) || (c[0][i]-c[0][(i+1)%3] != c[2][i]-c[2][(i+1)%3])) {
			std::cout << "No" << '\n';
			return 0;
		}
		if ((c[i][0]-c[(i+1)%3][0] != c[i][1]-c[(i+1)%3][1]) || (c[i][0]-c[(i+1)%3][0] != c[i][2]-c[(i+1)%3][2])) {
			std::cout << "No" << '\n';
			return 0;
		}
	}

	std::cout << "Yes" << '\n';

	return 0;
}


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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
    int n, k;
	scanf("%d %d", &n, &k);
	vector<int> s(n + 1, 0);
	tr1::unordered_map<int, int> mp;
	++mp[0];
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		scanf("%d", &a);
		s[i] = (s[i - 1] + a) % k;
		if (i - k >= 0) {
			--mp[(s[i - k] - i % k + k) % k];
		}
		ans += mp[(s[i] - i % k + k) % k];
		++mp[(s[i] - i % k + k) % k];
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 9288
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
data=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    data[a].append(b)
    data[b].append(a)
def dfs(node,s):
    # print(node,s)
    if len(s)==n:
        global count
        count+=1
    s=s.copy()
    for vi in data[node]:
        if vi not in s:
            dfs(vi,s|{vi})
dfs(0,{0})
print(count)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 998244353;



///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int H1, H2, M1, M2;
int K;
int ans;

int main(){
    
    cin>>H1>>M1>>H2>>M2>>K;
    
    ans = max( 0, (H2*60+M2)-K-(H1*60+M1) );
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3124
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = nextInt();
        int[] d = new int[n];
        for(int i = 0; i < n; i++){
            d[i] = nextInt();
        }

        int Answer = 0;

        for (int i = 0; i < n - 1; i++) {
        	for (int j = i + 1; j < n; j++) {
        		Answer += d[i] * d[j];
        	}
        }

        println(Answer);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

}


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

using namespace std;

using ll = long long;

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

    string a, b;
    cin >> a >> b;
    if (a.size() > b.size()) cout << "GREATER\n";
    else if (a.size() < b.size()) cout << "LESS\n";
    else {
        const int size = a.size();
        bool is_equal = true;
        for (int i = 0; i < size; ++i) {
            if (a[i] != b[i]) {
                if (a[i] < b[i]) cout << "LESS\n";
                else cout << "GREATER\n";
                is_equal = false;
                break;
            }
        }
        if (is_equal) cout << "EQUAL\n";
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll H, W;
char S[21][21];
ll dh[4] = { 1,0,-1,0 };
ll dw[4] = { 0,1,0,-1 };

ll bfs(ll sh, ll sw) {
	vector<vector<ll>> dist(H, vector<ll>(W, INF));
	queue<P> q;

	auto update = [&](ll i, ll j, ll d) {
		if (dist[i][j] != INF) return;
		dist[i][j] = d;
		q.push(P(i, j));
	};

	update(sh, sw, 0);

	ll h, w;
	ll nh, nw;
	while (!q.empty()) {
		h = q.front().first;
		w = q.front().second;
		q.pop();
		rep(i, 4) {
			nh = h + dh[i];
			nw = w + dw[i];
			if (nh >= 0 && nh <= H - 1 && nw >= 0 && nw <= W - 1) {
				if (S[nh][nw] == '.') {
					update(nh, nw, dist[h][w] + 1);
				}
			}
		}
	}

	ll v = -1;

	rep(h, H) {
		rep(w, W) {
			if (dist[h][w] != INF) {
				v = max(v, dist[h][w]);
			}
		}
	}

	return v;
}

void solve_abc151() {
	ll ans;
	string tmp;
	cin >> H >> W;

	rep(i, H) {
		cin >> tmp;
		rep(j, W) {
			S[i][j] = tmp[j];
		}
	}

	ans = -1;
	rep(sh, H) {
		rep(sw, W) {
			if (S[sh][sw] != '#') {
				ans = max(ans, bfs(sh, sw));
			}
		}
	}

	cout << ans << "\n";
}

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

	solve_abc151();

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(M):
    A.append(list(map(int,input().split())))
A = A[::-1]


P = [[x+1] for x in range(N)]
n = [x+1 for x in range(N)]
an = [N*(N-1)/2]


for i in range(M-1):
    if an[i] == 0:
        an.append(0)
    else:        
        Aind = A[i][0]-1
        Bind = A[i][1]-1
        PAind = P[n[Aind]-1]
        PBind = P[n[Bind]-1]
        if n[Aind] != n[Bind]:
            if len(PAind) >= len(PBind):
                an.append(an[i]-len(PAind) * len(PBind))
                P[n[Aind]-1].extend(PBind)
                for j in PBind:
                    n[j-1] = n[Aind]
            else:
                an.append(an[i]-len(PAind) * len(PBind))
                P[n[Bind]-1].extend(PAind)
                for j in PAind:
                    n[j-1] = n[Bind]
        else:
            an.append(an[i])
            
        
an = an[::-1]
for k in range(M):
    print(int(an[k]))

Measured memory_bytes: 52752
class Dice():
    def __init__(self, spots):
        self.spots = [spots[i] for i in range(6)]
    
    def roll(self, direction):
        if direction == 0:
            self.spots = [self.spots[i] for i in [1, 5, 2, 3, 0, 4]]
        elif direction == 1:
            self.spots = [self.spots[i] for i in [3, 1, 0, 5, 4, 2]]
        elif direction == 2:
            self.spots = [self.spots[i] for i in [4, 0, 2, 3, 5, 1]]
        elif direction == 3:
            self.spots = [self.spots[i] for i in [2, 1, 5, 0, 4, 3]]
 

n = int(input())
my_dice = Dice(list(map(int, input().split())))

for _ in range(n - 1):
    my_target = list(map(int, input().split()))

    a, b = my_target[0], my_target[1]

    if b == my_dice.spots[0]:
        my_dice.roll(2)
    elif b == my_dice.spots[1]:
        pass
    elif b == my_dice.spots[2]:
        my_dice.roll(3)
        my_dice.roll(2)
    elif b == my_dice.spots[3]:
        my_dice.roll(1)
        my_dice.roll(2)
    elif b == my_dice.spots[4]:
        my_dice.roll(2)
        my_dice.roll(2)
    elif b == my_dice.spots[5]:
        my_dice.roll(0)

    if a == my_dice.spots[0]:
        pass
    elif a == my_dice.spots[2]:
        my_dice.roll(3)
    elif a == my_dice.spots[3]:
        my_dice.roll(1)
    elif a == my_dice.spots[5]:
        my_dice.roll(1)
        my_dice.roll(1)

    if my_dice.spots == my_target:
        print('No')
        break

else:
    print('Yes')


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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int i=0;
    while(true){
        if(pow(K, i)<=N&&N<pow(K,i+1)){
            cout << i+1 << endl;
            break;
        }
      i++;
      
    }   
}


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

int selectionSort(int N, int* A) {
	int minj = 0;
	int ret = 0;
	for (int i = 0; i < N; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		swap(A[i], A[minj]);
		if(i != minj) ret++;
	}
	return ret;
}

int main()
{
	int N = 0;
	int A[100] = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int selectNum = selectionSort(N, A);
	for (int j = 0; j < N; j++) {
		if (j == 0) cout << A[j];
		else cout << " " << A[j];
	}
	cout << endl << selectNum << endl;
    return 0;
}


Measured memory_bytes: 3104
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final long X = sc.nextLong();
        String ans = "";
        
        outer:
        for (int i = -500; i < 500; i++) {
            for (int j = -500; j < 500; j++) {
                if (Math.pow(i, 5) - Math.pow(j, 5) == X) {
                    ans = i + " " + j;
                    break outer;
                }
            }
        }

        out.println(ans);

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 36844
N, W = map(int, input().split())
items = [None] * N
for n in range(N):
    w, v = map(int, input().split())
    items[n] = (w, v)
V = 10 ** 5 + 1

dp = [[10 ** 9 + 1] * V for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(V):
        w, v = items[i]
        if j >= v:
            dp[i + 1][j] = min(dp[i][j - v] + w, dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]

ans = 0
for v in range(V):
    if dp[N][v] <= W:
        ans = v
print(ans)


Measured memory_bytes: 119644
import math

def gcd(x,y):
 if x > y:
   r = x % y
   while  r != 0:
    x = y
    y = r
    r = x % y
   return y
 else:
   r = y % x
   while  r != 0:
    y = x
    x = r
    r = y % x
   return x

x, y = (int(x) for x in input().split())

print(gcd(x,y))


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


const int MAX_N = 100005;
int h[MAX_N];
int dp[MAX_N];
int N;

void solve() {
    cin >> N;
    rep(i, N) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    rep(i, N){
        dp[i+2] = min(dp[i]+abs(h[i] - h[i+2]), dp[i+1]+abs(h[i+1]-h[i+2]));
    }

    cout << dp[N-1] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

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

int digit(ll x){
    string s = to_string(x);
    return s.length();
}

int f(ll a, ll b){
    int x, y;
    x = digit(a);
    y = digit(b);
    return max(x, y);
}

void solve(){
    ll n;
    int ans=INF;
    cin >> n;

    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            ans = min(ans, f(i, n/i));
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

string S, T;
int total = 0;
int main(){
    cin >> S >> T;
    for(int i=0; i<3; i++){
        if (S[i] == T[i]){
            total += 1;
        }
    
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string tarou, hanako;
    int n,pt=0,ph=0;
    
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>tarou>>hanako;
        if(tarou==hanako) pt++, ph++;
        else if(tarou>hanako) pt+=3;
        else ph+=3;
    }
    cout<<pt<<" "<<ph<<endl;
}


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

min_num = int(input())
max_num = 0
profit = -999999999

for i in range(0, n - 1):
    num = int(input())
    temp = num - min_num
    if temp > profit:
        profit = temp
    if num < min_num:  
        min_num = num
        max_num = num
    if num > max_num:
        max_num = num

print(profit)


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

int main(){
	int n,m;
	cin >> n >> m;
	vector<bool> broken(n+1);
	rep(i,m){
		int a;
		cin >> a;
		broken[a] = true;
	}
	vector<int> dp(n+2);
	const int mod = 1000000007;
	dp[n] = 1;
	for(int i = n-1; i >= 0; i--){
		if(broken[i]){
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i+1] + dp[i+2]) % mod;
	}
	cout << dp[0] << endl;
	return 0;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3720
n,h=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=set()
for i in range(n):
  a.add(l[i][0])
maxA=max(a)
b=[]
for i in range(n):
  if l[i][1]>maxA:
    b.append(l[i][1])
b.sort()
b.reverse()
damage=0
count=0
f=0
for i in range(len(b)):
  if damage>=h:
    f=1
    break
  else:
    if b[i]>maxA:
      damage+=b[i]
      count+=1
    else:
      break
if f==1:
  print(count)
else:
  count+=((h-damage-1)//maxA)+1
  print(count)

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

using ll = long long;
vector<ll> a;
ll compute(ll i, ll j, ll x, ll y);

ll dp(ll i, ll j, ll x, ll y){
    return compute(i, j, x, y);
}
ll compute(ll i, ll j, ll x, ll y){
    if(i + 1 == j) return a[i] * x + a[j] * y;
    ll best = 1e18;
    for(int k = i + 1; k < j; k++){
        best = min(best, compute(i, k, x, x+y) + compute(k, j, x+y, y) - a[k] * (x + y));
    }
    return best;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    cout << dp(0, n-1, 1, 1) << '\n';
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N;cin>>N;
    int cnt=0;
    REP(i,N)if(i%2!=0)cnt++;
    printf("%0.6f",(float)cnt/(float)N);
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
5 4
0 1
1 2
2 3
3 4

output:
1
2
3
"""

import sys

sys.setrecursionlimit(int(3e6))
UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
        # undirected graph
        init_adj_table[v_to].append(v_from)
    return init_adj_table


def graph_dfs(current, prev):
    global timer
    pre_v[current] = lowest_v[current] = timer
    timer += 1

    color[current] = VISITED_IN_STACK

    for adj in adj_table[current]:
        if color[adj] is UNVISITED:
            parent_v[adj] = current

            # recursive dfs
            graph_dfs(adj, current)

            lowest_v[current] = min(lowest_v[current], lowest_v[adj])
        elif adj is not prev:
            lowest_v[current] = min(lowest_v[current], pre_v[adj])

    return None


def art_points():
    graph_dfs(dfs_root, -1)

    np = 0
    for v in range(1, vertices):
        parent = parent_v[v]
        if parent is dfs_root:
            np += 1
        elif pre_v[parent] <= lowest_v[v]:
            art_set.add(parent)

    if np > 1:
        art_set.add(dfs_root)

    return art_set


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])
    pre_v, parent_v, lowest_v = ([0] * vertices for _ in range(3))
    init_adj_table = tuple([] for _ in range(vertices))

    timer = 1
    # root
    dfs_root = 0

    art_set = set()
    color = [UNVISITED] * vertices

    adj_table = generate_adj_table(v_info)

    res = art_points()
    if not res:
        pass
    else:
        # print(*sorted(art_points()), sep='\n')
        print(*sorted(res), sep='\n')

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

int main() {
  int n; cin >> n;
  int counter = 0, a[110];
  for(int i = 0; i < n; i++) cin >> a[i];

  //--- Selection Sort ---//
  for(int i = 0; i < n; i++) {
    //--- 未探索の先頭を minj にしておく ---//
    int minj = i;
    //--- 未探索部分の最小を探す ---//
    for(int j = i; j < n; j++) {
      if(a[j] < a[minj]) minj = j;
    }
    swap(a[i], a[minj]);
    //--- 未探索部分の先頭よりも小さいものが見つかった場合 ---//
    if(i != minj) counter++;
  }

  for(int i = 0; i < n; i++) cout << a[i] << (i == n-1 ? "\n" : " ");
  cout << counter << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 FOR(i,s,n) for(int i = s;i < (int)n;i++)
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;}
 
signed main(){
	string s;
	cin >> s;
	int N=s.size();
	int K;
	cin>>K;
	int flg = 1;
	REP(i,N-1)if(s[i]!=s[i+1])flg=0;
	if(flg){
		cout<<(int)N*K/2<<endl;
		return 0;
	}
	if(s[0]!=s[s.size()-1]){
		int ans = 0,now = 1;
		REP(i,s.size()){
			if(i+1!=s.size()&&s[i]==s[i+1]){
				now++;
			}else{
				ans+=now/2;
				now=1;
			}
		}
		cout<<ans*K<<endl;
		return 0;
	}
	int mae=1,usiro=1;
	REP(i,s.size()){
		if(s[i]!=s[i+1])break;
		mae++;
	}
	RREP(i,s.size()){
		if(s[i-1]!=s[i])break;
		usiro++;
	}
	int now=1,ans=0;
	FOR(i,mae,s.size()-usiro){
		if(i+usiro+1!=s.size()&&s[i]==s[i+1]){
			now++;
		}else{
			ans+=now/2;
			now=1;
		}
	}
	ans*=K;
	ans+=mae/2+usiro/2+(mae+usiro)/2*(K-1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int findSum(int n){
  int result = 0;
  while(n > 0){
    result += n % 10;
    n /= 10;
  }
  return result;
}

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



Measured memory_bytes: 256
/*
ex4_1
tomatokan
*/
#include<stdio.h>

int main(void){
    int apple,sight;
    scanf("%d",&apple);
    scanf("%d",&sight);
    if(apple%(2*sight+1)==0){
        printf("%d\n",apple/(2*sight+1));
    }else{
        printf("%d\n",1+apple/(2*sight+1));
    }
    return 0;
}

Measured memory_bytes: 128
fn main() {
  let _: i32 = read();
  let k: i32 = read();
  let vec : Vec<i32> = read_vec();
  
  let ans: i32 = vec.iter().map(|&x| std::cmp::min(x, (x-k).abs())*2).sum();
  println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2*1e5+10;
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;
string a;
string b;
int n;
int m;
int dp[3001][3001];
string s;
int ans = 0;

void printVector(vector<char> s){
    for(auto x:s){
        cout<<x<<"";
    }
    cout<<endl;
}
int rec(int i , int j){
//    cout<<i<<" "<<j<<endl;
    if(i==0 || j==0){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(a[i-1]==b[j-1]){
        return dp[i][j]  = 1 + rec(i-1 , j-1);
    }
    else{
        return dp[i][j]  = max(rec(i-1 , j) , rec(i,j-1));
    }
}

void f(int i , int j){
//    cout<<i<<" "<<j<<endl;
    if(i==0 || j==0){
        return;
    }

    if(a[i-1]==b[j-1]){
        s+=a[i-1];
        f(i-1 , j-1);
    }
    else{
        if (dp[i-1][j]>dp[i][j-1]){
            f(i-1,j);
        }
        else{
            f(i,j-1);
        }
    }
}

void solve(){
    cin>>a;
    cin>>b;
    for(int i = 0 ; i < 3001 ; i++) for(int j = 0 ; j < 3001 ; j++) dp[i][j] = -1;
    n = a.size();
    m = b.size();
    ans = rec(n,m);
    f(n,m);
    reverse(s.begin(),s.end());
//    cout<<ans<<endl;
    cout<<s<<endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
//    cin>>t;
    t = 1;
    for(int i = 0 ; i < t ; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 74272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<int> s;
    vector<int> s1;
    int ans=0;
    rep(i,N){
        int t;
        cin>>t;
        s.push_back(t);
        ans+=t;
        if(t%10!=0){
            s1.push_back(t);
        }
    }
    if(ans%10!=0){
        cout << ans << endl;
        return 0;
    }
    if(s1.size()==0){
        cout << 0 << endl;
        return 0;
    }

    sort(all(s1));
    ans-=s1.at(0);
    cout << ans << endl;


    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    string S; cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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

int main() {
    int n; cin >> n;
    vector<long long> cnt(128);
    while (n--) {
        string s; cin >> s;
        cnt[s[0]]++;
    }
    long long ans = 0;
    string march = "MARCH";
    rep(i, 5) rep(j, i) rep(k, j) {
        ans += cnt[march[i]] * cnt[march[j]] * cnt[march[k]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	m := map[int]int{}
	for i := range d {
		fmt.Scan(&d[i])
		m[d[i]]++
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using L64 = int64_t;

/* {x,y}という表現で格納される[x^y] */
inline vector<pair<L64, int>> prime_factorize(L64 N) {
  vector<pair<L64, int>> res;
  for (int a = 2; a * a <= N; ++a) {
    if (N % a != 0) {
      continue;
    }
    int ex = 0;
    while (N % a == 0) {
      ex++;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main(void) {
  int S;
  cin >> S;
  int up = S / 100;
  int low = S % 100;

  if ((1 <= up && up <= 12) && (1 <= low && low <= 12))
    cout << "AMBIGUOUS";
  else if (!(1 <= up && up <= 12) && (1 <= low && low <= 12))
    cout << "YYMM";
  else if ((1 <= up && up <= 12) && !(1 <= low && low <= 12))
    cout << "MMYY";
  else if (!(1 <= up && up <= 12) && !(1 <= low && low <= 12))
    cout << "NA";
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 1e7 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll inf = 1e16;

ll c[N], s[N], f[N];

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 1; i < n; ++i) {
		ll totalTime = c[i] + s[i];
		for (int j = i + 1; j < n; ++j) {
			if(totalTime < s[j]) {
				totalTime += (s[j] - totalTime) + c[j];
			} else {
				ll nw = totalTime - s[j];
				if(nw % f[j] == 0) {
					totalTime += c[j];
					continue;
				}
				ll req = nw % f[j];
				totalTime += (f[j] - req) + c[j];
			}
		}
		cout << totalTime << '\n';
	}
	cout << 0;
	return 0;
}


Measured memory_bytes: 2304
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    # 愚直解
    N,K=pin()
    A=lispin()
    B=[0]*N
    B[0]=A[0]
    for j in range(1,N):
        B[j]=A[j]-A[j-1]
    #print(B)

    for k in range(K):
        temp=0
        C=[0]*N
        for i in range(N):
            temp+=B[i]
            #print(temp)
            if i-temp<0:

                C[0]+=1
            else:C[i-temp]+=1

            if i+temp+1<N:
                C[i+temp+1]-=1
        B=C[:]
        if B[0]==N and sum(B)==N:
            break
    ans=[]
    x=0
    for c in C:
        x+=c
        ans.append(x)
    print(*ans)
    #after contest
    
#%%submit!
resolve()

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

const long n_max = 100000;
long a[n_max];
map<long, long> count{};

int main()
{
 long n;
 cin >> n;
 for(long i = 0; i < n; i++){
     cin >> a[i];
 }
 long minus_count = 0;
 for(long i = 0; i < n; i++){
     if(count[a[i]] == a[i]){
         minus_count++;
     }else{
         count[a[i]]++;
     }
 }

 for( auto i = count.begin(); i != count.end() ; ++i ) {
    if(i->first != i->second){
        minus_count += i->second;
    }
 }
 cout << minus_count << endl;
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,k;
  cin>>n>>k;
  long long int hoge=0;
  long long int huga=0;
  for(long long int i=1; i<=n; i++){
    if(i%k==0){
      hoge++;
    }
    if(i%k==k/2){
      huga++;
    }
  }
  long long int ans=hoge*hoge*hoge;
  if(k%2!=0){
    cout<<ans<<endl;
  }else{
    ans+=pow(huga,3);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define N 100005

vector<vector<int> > a(N);
int n;

int dfs(int u, int p){
    int ret = u;
    for(auto v:a[u]){
        if (v==p) continue;
        int rec = dfs(v,u);
        if (rec!=0){
            if (ret!=0){
                ret = 0;
            }
            else{
                cout << "First" << endl;
                exit(0);
            }
        }
    }
    return ret;
}

int main(){
    cin >> n;
    for(int i=1; i<=n-1; i++){
        int u,v; cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    if (dfs(1,1)==0) cout << "Second" << endl;
    else cout << "First" << endl;
}

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


int main(){
    string s, t;
    cin >> s >> t;
    sort(all(s)); //sはなるべく辞書順で早くなるよう昇順
    sort(all(t),greater<char>());//tはなるべく辞書順で遅くなるよう降順
    if(s<t) cout << "Yes" << endl;
    else cout <<"No" << endl;

}

Measured memory_bytes: 3636
# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_d
# 22:25-23:08 give up
# 12:18-12:31 done


def main():
    N, H = map(int, input().split())
    ab = [None] * N
    for i in range(N):
        ab[i] = list(map(int, input().split()))
    ab = sorted(ab, key=lambda x: x[1], reverse=True)

    a_max = max([a for a, _ in ab])

    throw_dmg = 0
    n_throw = 0
    for _, b in ab:
        if b > a_max:
            throw_dmg += b
            n_throw += 1
            if throw_dmg >= H:
                return n_throw
        else:
            break

    rest = H - throw_dmg

    if rest % a_max == 0:
        return rest // a_max + n_throw
    else:
        return rest // a_max + 1 + n_throw


print(main())


Measured memory_bytes: 29664
import numpy as np


N = int(input())
A = list(input())
B = list(input())
C = list(input())

R_A = [None] * N
R_B = [None] * N
R_C = [None] * N

for i in range(N):
    if A[i] == B[i] and A[i] == C[i]:
        R_A[i] = 0
    elif A[i] == B[i]:
        R_A[i] = 1
    elif A[i] == C[i]:
        R_A[i] = 1
    else:
        R_A[i] = 2

for i in range(N):
    if B[i] == A[i] and B[i] == C[i]:
        R_B[i] = 0
    elif B[i] == A[i]:
        R_B[i] = 1
    elif B[i] == C[i]:
        R_B[i] = 1
    else:
        R_B[i] = 2

for i in range(N):
    if C[i] == A[i] and C[i] == B[i]:
        R_C[i] = 0
    elif C[i] == A[i]:
        R_C[i] = 1
    elif C[i] == B[i]:
        R_C[i] = 1
    else:
        R_C[i] = 2

R = np.array([R_A, R_B, R_C])

print(sum(R.min(axis=0)))

Measured memory_bytes: 21512
#include <iostream>

using namespace std;

#define TRUE 1
#define FALSE 0

int is_include_three(int n) {
    do {
        if(n % 10 == 3) {
            return TRUE;
        }
    } while((n /= 10) != 0);
    
    return FALSE;
}

void awesome_call(int n) {
    for(int i=1; i<=n; i++) {
        if(i % 3 == 0) {
            cout << " " << i;
        } else if(is_include_three(i)) {
            cout << " " << i;
        }
    }
    cout << endl;
}

int main() {
  int n;
  cin >> n;
  
  awesome_call(n);
  
  return 0;
}



Measured memory_bytes: 3100
while True:
	try:
		a, b, c, d, e, f = map(float, input().split())
		x = (c*e - b*f) / (a*e - b*d)
		y = (c*d - a*f) / (b*d - a*e)
		print("{:.3f} {:.3f}".format(x+0, y+0))
	except EOFError:
		break

Measured memory_bytes: 7360