akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<queue>
#include<map>
using namespace std;
typedef pair<int, int> P;

const int MAX_H = 22;
const int MAX_W = 22;

char grid[MAX_H][MAX_W];
bool is_checked[MAX_H][MAX_W];

void solve(int W, int H) {
    map<P, bool> is_exist;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
            is_checked[i][j] = false;
            is_exist[P(i, j)] = true;
        }
    }
    queue<P> Q;
    int dh[4] = {-1, 0, 1, 0}, dw[4] = {0, -1, 0, 1};
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '@') {
                Q.push(P(i, j));
                is_checked[i][j] = true;
                while (!Q.empty()) {
                    P now_pos = Q.front();
                    Q.pop();
                    for (int k = 0; k < 4; k++) {
                        P new_pos = P(now_pos.first + dh[k], now_pos.second + dw[k]);
                        if (!is_exist[new_pos] || is_checked[new_pos.first][new_pos.second]) continue;
                        if (grid[new_pos.first][new_pos.second] == '#') continue;
                        is_checked[new_pos.first][new_pos.second] = true;
                        Q.push(new_pos);
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (is_checked[i][j]) ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H;
    while (true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        solve(W, H);
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	int h, w, n;
	cin >> h >> w >> n;

	int max_v = max(h, w);

	cout << (n - 1) / max_v + 1 << endl;  
	
	return 0;
}

Measured memory_bytes: 888
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string s;
    cin >> s;
    string ans;
    for (char c : s) {
        if (c == '0') {
            ans += '0';
        } else if (c == '1') {
            ans += '1';
        } else {
            if (ans.end() == ans.begin()) {
                continue;
            }
            ans.erase(ans.end() - 1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
s,t=gets.chomp.split

ans=""
n.times do |i|
  ans<<(s[i]<<t[i])
end
puts ans

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

int N;
string str[5];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	cin >> str[0] >> str[1] >> str[2];
	
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (str[0][i] == str[1][i] && str[1][i] == str[2][i]) {
			// nothing
		} else if (str[0][i] == str[1][i] || str[1][i] == str[2][i] || str[2][i] == str[0][i]) {
			ans++;
		} else {
			ans += 2;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  long double A,B; cin>>A>>B;
  ll ans=A*B;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}



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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
    cout << 700+counter*100 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,m,k,i,j,c=0,t;
	int a[31]={0};
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&k);
		for(j=0;j<k;j++){
			scanf("%d",&t);
			a[t]++;
		}
	}
	for(i=1;i<=m;i++){
		if(a[i]==n)
			c++;
	}
	printf("%d",c);
	return 0;
}

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

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

int min(int a, int b){
    return a < b? a: b;
}
void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
   cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 888
import java.util.*;
public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new  Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int K=sc.nextInt();
        int cA =0;
        int cB =0;
        for(int i=0;i<K;i++){
        if(A%2==1){
        A--;
        }
       cA=A/2;
       A/=2;
       B+=cA;
       i++;
       if(i>=K)break;
       if(B%2==1){
        B--;
        }
       cB=B/2;
       B/=2;
       A+=cB; 
        }
    System.out.println(A+" "+B);
    }
}

Measured memory_bytes: 21844
#include<cstdio>
using namespace std;
int main(){
	for(;;){
		double matrix[2][2],reverse[2][2],ans[2],x,y,det;
		if(scanf("%lf %lf %lf %lf %lf %lf",&matrix[0][0],&matrix[1][0],&ans[0],&matrix[0][1],&matrix[1][1],&ans[1]) == EOF){break;}
		det = matrix[0][0]*matrix[1][1]-matrix[0][1]*matrix[1][0];
		reverse[0][0] = matrix[1][1]/det;
		reverse[1][0] = -matrix[1][0]/det;
		reverse[0][1] = -matrix[0][1]/det;
		reverse[1][1] = matrix[0][0]/det;
		x = ans[0]*reverse[0][0]+ans[1]*reverse[1][0];
		y = ans[0]*reverse[0][1]+ans[1]*reverse[1][1];
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

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

using namespace std;
int cnt[5];

int main()
{
    int a,b;  cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
    for(int i = 1;i<=3;i++)  if(!cnt[i])  return cout << i , 0;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector <int> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  int64_t n=0;
  for(int i=0;i<N;i++){
    while(true){
      if(v.at(i)%2==0){
        n++;
        v.at(i)/=2;
      }else{
        break;
      }
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
// AOJ 2021: Princess in Danger
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 50000
typedef struct { int t, node, s, prev; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t, int s, int p)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t, que[i].s = s, que[i].prev = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x07070707

typedef struct { int to[101], t[101]; } TBL;
TBL tbl[101];
int len[101];
char f[101];
char mk[101][101];

int dijkstra(int start, int goal, int m)
{
	int i, s, t, k, p, s2, t2, k2;

	memset(mk, 0, sizeof(mk));
	qsize = 0;
	enq(start, 0, m, start);
	while (qsize) {
		s = que[0].node, t = que[0].t, k = que[0].s; p = que[0].prev; deq();
		if (s == goal) {
			t2 = t;	if (t2 > m) t2 += t - m;
			return t2;
		}
		if (mk[p][s]) continue;
		mk[p][s] = 1;
		if (f[s]) k = m, p = s;
		for (i = 0; i < len[s]; i++) {
			s2 = tbl[s].to[i], t2 = t + tbl[s].t[i];
			k2 = k - tbl[s].t[i];
			if (k2 < 0) continue;
			enq(s2, t2, k2, p);
		}
	}
	return INF;
}

char buf[400], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int n, m, l, k, a, h, i, x, y, t, ans;

	while (fgets(p=buf, 60, stdin) && *p != '0') {
		n = getint(), m = getint(), l = getint();
		k = getint(), a = getint(), h = getint();

		memset(f, 0, sizeof(f));
		if (l > 0) {
			fgets(p=buf, sizeof(buf), stdin);
			while (l--) f[getint()] = 1;
		}

		memset(len, 0, sizeof(len));
		while (k--) {
			fgets(p=buf, 20, stdin);
			x = getint(), y = getint(), t = getint();
			if (t > m) continue;
			i = len[x]++, tbl[x].to[i] = y, tbl[x].t[i] = t;
			i = len[y]++, tbl[y].to[i] = x, tbl[y].t[i] = t;
		}

		ans = dijkstra(a, h, m);
		if (ans == INF) puts("Help!");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2356
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

#define vint vector<int>
#define vll vector<ll>

#define INF 1e9
#define PI 3.14159265359

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

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    float d, t, s;
    cin >> d >> t >> s;
    if(t >= d/s){
        p("Yes");
    } else {
        p("No");
    }

    return 0;
}


Measured memory_bytes: 3688
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int l = fs.nextInt();
        int r = fs.nextInt();
        int min = 2019;
        for(int i=l;i<l+2019&&i<=r;i++){
            for(int j=i+1; j<i+1+2019 && j<=r;j++){
                min = Math.min(min,(int)((long)i*j%2019));
            }
        }
        System.out.println(min);
    }
    static 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 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: 22484
#include <stdio.h>

int main(void) {
    int matrix[3][3];
    int status[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};

    int i, j;
    for(i = 0; i < 3; i++) {
        while (!scanf("%d %d %d", &matrix[i][0], &matrix[i][1], &matrix[i][2]))
            ;
    }

    int num;
    while (!scanf("%d", &num))
        ;
    for (; 0 < num; num--) {
        int b;
        while (!scanf("%d", &b))
            ;
        for (i = 0; i < 3; i++) {
            for (j = 0; j < 3; j++) {
                if (matrix[i][j] == b) status[i][j] = 1;
            }
        }
        if (check(status) == 1) {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
}

int check(int status[3][3]) {
    int i, j, loop;
    for (i = 0; i < 3; i++) {
        loop = 0;
        for (j = 0; j < 3; j++) {
            if (status[i][j] == 0) break;
            loop++;
        }
        if (loop == 3) return 1;
    }

    for (j = 0; j < 3; j++) {
        loop = 0;
        for (i = 0; i < 3; i++) {
            if (status[i][j] == 0) break;
            loop++;
        }
        if (loop == 3) return 1;
    }

    for (i = 0; i < 3; i++) {
        if (status[i][i] == 0) { break; }
        if (i == 2) {return 1; }
    }
    for (i = 0; i < 3; i++) {
        if (status[i][2 - i] == 0) break;
        if (i == 2) return 1;
    }
}

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

char s[10000], t[10000];

int main() {
	scanf("%s", s + 0);
	scanf("%s", t + 0);
	int n = strlen(s+0);
	int m =	strlen(t+0);
	if (n != m) { puts("No"); return 0;}
	for (int i = 0; i < n; ++i) {
		s[i+n] = s[i];
	}
	for (int i = 0; i < n; ++i){
		bool a = true;
		for (int j = 0; j < n; ++j) {
			
			if (s[j + i] != t[j]) a = false;
			
		}
		if (a) { puts("Yes"); return 0;}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,X;
  cin>>N>>X;
  
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  
  
  vector<int> D(N);
  D[0]=0;
  for(int i=1;i<=N;i++){
    D[i]=D[i-1]+L[i-1];
  }
  
  int check=0;
  
  for(int i=0;i<=N;i++){
    if(D[i]<=X){
      check++;
    }
  }
  
  
  cout<<check<<endl;
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(W>=x+r&&H>=y+r&&x-r>=0&&y-r>=0){
    puts("Yes");
}else{
    puts("No");
}

return 0;
}


Measured memory_bytes: 2140
import math
a, b, h, m = map(int, input().split())
hang = (h * (360 / 12)) + m * 1/2;
mang = m * (360 / 60);
ang = abs(hang - mang);
if ang>180:
    ang=360-ang
print(math.sqrt(pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(ang))))

Measured memory_bytes: 9436
main = do
    str <- getLine
    let (lhd:op:rhd:_) = words str
    if op == "?" then
        return ()
    else do
        print $ solve op (read lhd) (read rhd)
        main

solve :: Integral a => String -> (a -> a -> a)
solve "+" = (+)
solve "-" = (-)
solve "*" = (*)
solve "/" = div

Measured memory_bytes: 4036
#n:
#m:
#k:
n,m,k=map(int,input().split())
friend={}
block={}
result=[]
friendGroup=[]
for i in range(1,n+1):
    friend[i]=set([])
    block[i]=set([])
    result.append(0)
    friendGroup.append(0)

for _ in range(m):
    a,b=map(int,input().split())
    friend[a].add(b)
    friend[b].add(a)

checked=set([])
bfbf=[]
for i in range(1,n+1):
    #print(i,checked)
    if i not in checked:
        checked.add(i)
        group=set([i])
        bf=set([i])
        friendGroup[i-1]=i
        while len(group)!= 0:
            temp=group.pop()
            for item in friend[temp]:
                if item not in checked:
                    checked.add(item)
                    group.add(item)
                    bf.add(item)
                    friendGroup[item-1]=i
        lenbf=len(bf)
        for item1 in bf:
            result[item1-1]=lenbf-1-len(list(friend[item1]))

for _ in range(k):
    a,b=map(int,input().split())
    if friendGroup[a-1]!=0 and friendGroup[a-1]==friendGroup[b-1]:
        result[a-1]-=1
        result[b-1]-=1

result=list(map(str,result))
print(" ".join(result))







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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;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--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, Q; cin >> N;
    map<ll, ll> x;
    ll ans = 0;

    rep(i, N){
        ll a; cin >> a;
        if (x.find(a) != x.end()){
            x[a]++;
        } else {
            x[a] = 1;
        }
        ans += a;
    }

    vector<ll> y;
    cin >> Q;
    rep(i, Q){
        ll b, c;
        cin >> b >> c;
        if (x.find(b) != x.end()){
            ans -= b * x[b];
            ans += c * x[b];
            if (x.find(c) != x.end()){
                x[c] += x[b];
            } else {
                x[c] = x[b];
            }
            x[b] = 0;
        }
        y.push_back(ans);
    }
    for (auto a: y){cout << a << endl;}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 9084
#include <iostream>

int main() {
    int i = 1;
    int num;
    while (true) {
        std::cin >> num;
        if (num == 0) {
            break;
        }
        std::cout << "Case " << i << ": " << num << '\n';
        i++;
    }
    return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <list>
#include <stack>
#define lar(a, b) ((a>b) ? (a):(b))
#define sml(a, b) ((a<b) ? (a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> p;

int main(void) {
    ll n, m;
    vector<ll> v1, v2;
    cin >> n >> m;
    ll i, a[m], b[m];
    for(i=0; i<m; i++) {
        cin >> a[i] >> b[i];
    }
    
    for(i=0; i<m; i++) {
        if(a[i]==1)
            v1.push_back(b[i]);
        if(b[i]==n)
            v2.push_back(a[i]);
    }
    
    sort(v2.begin(), v2.end());
    
    for(i=0; i<v1.size(); i++) {
        if(binary_search(v2.begin(), v2.end(), v1[i])) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    
}


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

long long int M = 1000000007;

long long int power(long long int m , long long int n){
    if(n == 1)
        return m;
    else if(n % 2 == 0)
        return power((m * m) % M, (n / 2));
    else
        return (power((m * m) % M, (n / 2)) * m % M);
}

int main(void){
    long long int m, n;
    cin >> m >> n;
    cout << (power(m, n) % M) << endl;
}



Measured memory_bytes: 3112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,l;
  int a[SIZE];
  
  scanf("%d%d",&n,&l);

  for(int i=0;i<n;i++){
    scanf("%d",a+i);

    if(i > 0){
      if(a[i] + a[i-1] >= l){
        puts("Possible");

        for(int j=1;j<i;j++){
          printf("%d\n",j);
        }
        for(int j=n-1;j>i;j--){
          printf("%d\n",j);
        }

        printf("%d\n",i);
        return 0;
      }
    }
  }
  
  puts("Impossible");
  
  return 0;
}


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

int main(){
	int n, m;
	int sugoroku[1000];
	int dice[1000];

	while(cin >> n >> m, n || m){
		int location = 1;
		int count = 0;
		for(int i=1; i <= n; i++){
			cin >> sugoroku[i];
		}
		for(int j=1; j <= m; j++){
			cin >> dice[j];
		}

		while(location < n){
			count++;
			location += dice[count];
			if(n <= location) break;
			location += sugoroku[location];
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1168
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head,tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1 ) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a,int b) { return a < b ? a : b; }

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	for (i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head = 1; tail=n+1;
	
	while ( head != tail ){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if ( u.t > 0 )enqueue(u);
		else{
			printf("%s %d\n",u.name, elaps);
		}
	}
	
	return 0;
}


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

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    ll n,m;
    n = s.size();
    m = t.size();
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    ll num=min(n,m);

    for(ll i=0;i<num;++i){
        if(s[i]==t[i]){
            continue;
        }else if(s[i]<t[i]){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(n<m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int n, k, INF = (int)1e9;
	static int[] h, memo;
	
	public static int dp(int i) {
		if(i == n - 1)
			return 0;
		if(memo[i] != -1)
			return memo[i];
		
		int min = INF;
		for(int j = i + 1; j < Math.min(n, i + k + 1); j++)
			min = Math.min(min, Math.abs(h[i] - h[j]) + dp(j));
		return memo[i] = min;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		
		h = new int[n];
		for(int i = 0; i < n; i++)
			h[i] = sc.nextInt();
		
		memo = new int[n];
		Arrays.fill(memo, -1);
		System.out.println(dp(0));
	}
}


Measured memory_bytes: 59900
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    int N, tmp;
    vector<int> vec(26, 0);

    string s;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> s;
        vector<int> tmp_vec(26, 0);
        //int size = s.size;
        for(int j = 0; j < s.size(); j++)
        {
            tmp = s[j] - 'a';
            tmp_vec[tmp]++;
        }
        for(int k = 0; k < 26; k++)
        {
            if( (i!= 0) && (tmp_vec[k] <= vec[k]))
            {
                vec[k] = tmp_vec[k];
            }
            else if (i == 0)
            {
                vec[k] = tmp_vec[k];
            }
        }
        //cout << s << endl;
    }
    //cout << N;
    char tmp_char;
    for(int i = 0; i < 26; i++)
    {
        for(int j = 0; j < vec[i]; j++)
        {
           tmp_char = 'a' + i;
           cout << tmp_char;
        }
    }
    cout << endl;
}

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

using namespace std;
int w[10][10];
void floyd()
{
    for(int k=0;k<10;k++)
    {
        for(int i=0;i<10;i++)
        {
            for(int j=0;j<10;j++)
            {
                if(w[i][j]>w[i][k]+w[k][j])
                    w[i][j]=w[i][k]+w[k][j];
            }
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            cin>>w[i][j];
        }
    }
    floyd();
    int tot=0;
    int val;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>val;
            if(val!=-1)
            {
                tot+=w[val][1];
            }
        }
    }
    cout<<tot<<endl;
    //main();
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
function main(input){
    const args = input.split(' ');
    const a = parseInt(args[0],10);
    const b = parseInt(args[1],10);
    
    if((a*b) % 2 === 0){
        console.log('Even');
    }else{
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7500
import java.util.*;

public class Main{
  static int[] ans;
  static Map<Integer, Integer> map;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    int D = Integer.parseInt(sc.next());
    int E = Integer.parseInt(sc.next());
    
    int n = 10;
    if(A%10 != 0){
      n = n > A%10 ? A%10 : n;
      A = A+ 10-A%10;
    }
    if(B%10 != 0){
      n = n > B%10 ? B%10 : n;
      B = B+ 10-B%10;
    }
    if(C%10 != 0){
      n = n > C%10 ? C%10 : n;
      C = C+ 10-C%10;
    }
    if(D%10 != 0){
      n = n > D%10 ? D%10 : n;
      D = D+ 10-D%10;
    }
    if(E%10 != 0){
      n = n > E%10 ? E%10 : n;
      E = E+ 10-E%10;
    }
    
    n = 10-n;
    int ans = A+B+C+D+E-n;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using lint = long long;

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

    std::vector<int> ls(n);
    for (auto& l : ls) std::cin >> l;
    std::sort(ls.begin(), ls.end());

    lint ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            int r = std::lower_bound(ls.begin(), ls.end(), ls[i] + ls[j]) - ls.begin();
            int l = std::upper_bound(ls.begin(), ls.end(), ls[i] - ls[j]) - ls.begin();
            ans += r - l;
            if (l <= i && i < r) --ans;
            if (l <= j && j < r) --ans;
        }
    }

    std::cout << ans / 3 << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
import math
sqrt_n = int(math.sqrt(n)) + 1

div = len(list(str(n)))

for v in range(1,sqrt_n):
    if n%v == 0:
        b = int(n / v)
        a_div = len(list(str(v)))
        b_div = len(list(str(b)))
    
        if a_div < b_div:
            if div >= b_div:
                div = b_div
        else:
            if div >= a_div:
                div = a_div
print(div)  

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int a,b,c,i,ans=0;
	
	scanf("%d %d %d",&a,&b,&c);
	for(i=a ; i<=b ; i++)
		if(c%i==0)ans++;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 1848
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;


int bubbleSort(vector<int> A,int N) { // N 個の要素を含む 0-オリジンの配列 A
	int flag = 1;
	int count = 0;
	int i = 0;
	while (flag) {
		flag = 0;
		for (int j = N - 1;i+ 1 <= j; --j) {
			if (A[j] < A[j - 1]) {
				int tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				flag = 1;
				count++;
			}
		}
		i++;
	}
	rep(i, N - 1) {
		cout << A[i] << " ";
	}
	cout << A[N - 1] << endl;
	return count;
}
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i,N) {
		cin >> a[i];
	}
	int count= bubbleSort(a,N);
	cout << count << endl;
	return 0;
}





Measured memory_bytes: 3168
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
char in[100];
string yk[]={"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};
int num[20];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<20;i++)num[i]=0;
		for(int i=0;i<a;i++){
			scanf("%s",in);
			string tmp=in;
			for(int j=0;j<15;j++)if(yk[j]==tmp)num[j]++;
		}
		int ret=-1;
		for(int i=0;i<15;i++){
			if(!num[i])continue;
			bool ok1=false;
			bool ok2=true;
			for(int j=1;j<=7;j++)if(num[(i+j)%15])ok1=true;
			for(int j=8;j<=14;j++)if(num[(i+j)%15])ok2=false;
			if(ok1&&ok2)ret=i;
		}
		if(ret==-1)printf("Draw\n");
		else printf("%s\n",yk[ret].c_str());
	}
}

Measured memory_bytes: 1060
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


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

Measured memory_bytes: 3576
S = input()
judge = "No"
for i in range(len(S)):
    if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
        judge = "Yes"
    elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
        judge = "Yes"
    elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
        judge = "Yes"

print(judge)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

long long int ipow(int x, int y) {
    long long int temp = 1;
    for (int i = 0; i < y; i++) {
        temp *= x;
    }
    return temp;
}

int kurai(long long int x,int y) {
    return (x % ipow(10, y)) / ipow(10, y-1);
}

int digit(long long int x) {
    long long int temp = x;
    int y = 0;
    while (temp != 0)
    {
        temp /= 10;
        y++;
    }
    return y;
}

void makenum(long long int &x, int y , int z ,vector<long long int> &ans) {//変化を加える値,現在の桁数,存在する最下位の数字
    if (y == 10) {
        if (x != 0) {
            ans.push_back(x);
        }

        //cout << x << "\n";
    } else {
        if (x == 0) {
            for (int i = 0; i < 10; i++) {
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += i * ipow(10, 9 - y);
                makenum(x, y + 1, i, ans);
            }
            
        } else {
            if (z == 0) {
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += 0 * ipow(10, 9 - y);
                makenum(x, y + 1, 0, ans);
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += 1 * ipow(10, 9 - y);
                makenum(x, y + 1, 1, ans);
            } else if (z > 0 && z < 9) {
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += (z - 1) * ipow(10, 9 - y);
                makenum(x, y + 1, (z - 1), ans);
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += z * ipow(10, 9 - y);
                makenum(x, y + 1, z, ans);
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += (z + 1) * ipow(10, 9 - y);
                makenum(x, y + 1, (z + 1), ans);
            } else {
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += 8 * ipow(10, 9 - y);
                makenum(x, y + 1, 8, ans);
                x -= kurai(x, 10 - y) * ipow(10, 9 - y);
                x += 9 * ipow(10, 9 - y);
                makenum(x, y + 1, 9, ans);
            }
        }
    }
}

int main() {
    int k;

    cin >> k;

    //long long int m = 3234566667;//たかが10けた
    /*long long int m = 2000000;
    vector<long long int> ans;
    int temp;

    for (long long int i = 0; i < m+1; i++) {//文字
        for (int j = 0; j < digit(i); j++) {//桁数
            if (j == 0) {
                temp = kurai(i, j + 1);
            } else {
                if (abs(temp - kurai(i, j + 1)) > 1) {
                    //cout << temp << " " << kurai(i, j + 1) << " ";
                    break;
                    
                }
            }

            if (j == digit(i) - 1) {
                ans.push_back(i);
                //cout << i << "add\n";
            }
        }
    }

    */

    vector<long long int> ans;

    long long int temp = 0;


    makenum(temp, 1, 0, ans);
    temp = 1000000000;
    makenum(temp, 1, 1, ans);
    temp = 2000000000;
    makenum(temp, 1, 2, ans);
    temp = 3000000000;
    makenum(temp, 1, 3, ans);
    //cout << "end";

    cout << ans[k - 1];


    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
regex reg("A?KIHA?BA?RA?");
string s;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	puts(regex_match(s,reg) ? "YES" : "NO");
}

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

using namespace std;

int main()
{
    string s;

    cin >> s;

    long long ans = 0;

    for(int i = 0; s[i]; i++){
        ans += (s[i]-'0');
    }

    if(ans%9 == 0) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3676
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn calc(n: u64, k: u64) -> u64
{
    if n < k { return 0; }
    n / k + calc(n, k * 5)
}

fn main() {
    let n: u64 = read();

    // nが奇数の場合、末尾は0にならない.
    if n % 2 == 1 { println!("0"); return; }

    println!("{}", calc(n, 10));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[114514],b[114514],x[114514];
int main(){
	ll n;
	cin>>n;
	ll suma=0,sumb=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		suma+=a[i];
	}
	ll num=0,ans=0;
	for(int i=0;i<n;i++){
		cin>>b[i];
		sumb+=b[i];
		x[i]=a[i]-b[i];
		if(x[i]<0){
			num-=x[i];
			ans++;
		}
	}
	if(suma<sumb){
		cout<<-1;
		return 0;
	}
	sort(x,x+n);
	ll i=n-1;
	while(1){
		if(num<=0){
			cout<<ans;
			return 0;
		}
		num-=x[i];
		i--;
		ans++;
	}
	return 0;
}

Measured memory_bytes: 2560
n,m = map(int, input().split())
A = [0 for _ in range(n+1)]
for i in range(m):
    A[int(input())] = 1
#print(A)

sum1 = 0
sum2 = 0
for i in range(n+1):
    if i == 0:
        sum1 = 1
        continue
    else:
        if A[i]==1 and i != 1:
            sum1 = sum2
            sum2 = 0
        elif i == 1:
            if A[i] == 1:
                sum1 = 1
                sum2 = 0
            else:
                sum2 = 1
        else:
            sum3 = sum1
            sum1 = sum2
            sum2 = sum3 + sum2
            #print(sum2)
print(sum2%1000000007)

Measured memory_bytes: 3888
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = 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")
}
fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    a.sort();
    let mut sums: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        sums[i + 1] = a[i] + sums[i];
    }

    let mut ans = n;
    let mut t = 0;
    for i in 0..n {
        if sums[i] * 2 < a[i] {
            t = i;
        }
    }
    println!("{}", ans - t);
}


Measured memory_bytes: 3384
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int h,n;
int main()
{
	h=read(); n=read();
	int ans=h/n;
	if(h%n) ans++;
	printf("%d",ans);
}

Measured memory_bytes: 256
def dyn(n,d00,d01,d02,d03,d10,d11,d12,d13):
    D00 = d00 + d10*int(n != 0)
    D10 = d10*int(n==0)
    D01 = d00*9 + d10*(n-1+int(n==0)) + d01 + d11*int(n!=0)
    D11 = d10*(int(n!=0)) + d11*(int(n==0))
    D02 = d01*9 + d11*(n-1+int(n==0)) + d02 + d12*int(n!=0)
    D12 = d11*(int(n!=0)) + d12*(int(n==0))
    D03 = d02*9 + d12*(n-1+int(n==0)) + d03 + d13*int(n!=0)
    D13 = d12*(int(n!=0)) + d13*(int(n==0))
    return D00,D01,D02,D03,D10,D11,D12,D13

N = str(input())
K = int(input())
S = len(N)
D00=0
D01=0
D02=0
D03=0
D10=1
D11=0
D12=0
D13=0

for i in range(S):
    [D00,D01,D02,D03,D10,D11,D12,D13] = dyn(int(N[i]),D00,D01,D02,D03,D10,D11,D12,D13)
    #print(int(N[i]),D00,D01,D02,D03,D10,D11,D12,D13)
if K == 1:
    print(D01+D11)
elif K==2:
    print(D02+D12)
else:
    print(D03+D13)


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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

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

  int N, D, X;

  cin >> N;
  cin >> D >> X;

  std::vector<int> a(N);

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

  int ans = X;

  for (int i = 0; i < N; ++i) {
    for (int day = 1; day <= D; day += a[i]) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 * There is no end though there is a start in space. ---Infinity.
 * It has own power, it ruins, and it goes though there is a start also in the star. ---Finite.
 * Only the person who was wisdom can read the most foolish one from the history.
 * The fish that lives in the sea doesn't know the world in the land.
 * It also ruins and goes if they have wisdom.
 * It is funnier that man exceeds the speed of light than fish start living in the land.
 * It can be said that this is an final ultimatum from the god to the people who can fight.
 *
 * Steins;Gate
 */
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j; i <= k; ++i)
#define dep(i, j, k) for(int i = j; i >= k; --i)
#define SIZE(x) (int)(x.size())

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 5;

int n, a[maxn], even[maxn], odd[maxn], pre1[maxn], pre2[maxn], suf1[maxn], suf2[maxn], ans = 0x3f3f3f3f;

inline int read() {
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar(); }
	while(isdigit(ch))  { u = u * 10 + ch - 48; ch = getchar(); } return u * f;
}

int main() {
//	freopen("1.in", "r", stdin);
	n = read();
	rep(i, 1, n) a[i] = read();
	for(int i = 1; i <= n; i += 2) odd[a[i]]++, even[a[i + 1]]++;
	for(int i = 1; i <= 1e5; i++) pre1[i] = max(pre1[i - 1], odd[i]), pre2[i] = max(pre2[i - 1], even[i]);
	for(int i = 1e5; i >= 1; i--) suf1[i] = max(suf1[i + 1], odd[i]), suf2[i] = max(suf2[i + 1], even[i]);
	for(int i = 1; i <= 1e5; i++) {
		ans = min(ans, n - (odd[i] + max(pre2[i - 1], suf2[i + 1])));
		ans = min(ans, n - (even[i] + max(pre1[i - 1], suf1[i + 1])));
	} cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/



void solve() {
	int n, x, t; cin >> n >> x >> t;
	cout << (((n % x) != 0) + n / x)*t << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

int main()
{
  char N[11];
  int n, len;
  int res=0;
  cin >> N;
  n = atoi(N);
  len = strlen(N);

  rep(i,len){
    res += N[i]-48;
  }
  if(n%res==0) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
typedef double ld;

ld dp[301][301][301];
int cnt[4]; int n;

int main() {
	cin >> n; dp[0][0][0] = 0.0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x; cnt[x]++;
	}
	for(int z = 0; z <= cnt[3]; z++)
		for(int y = 0; y <= cnt[2] + cnt[3] - z; y++)
			for (int x = 0; x <= n - z - y; x++) if (x + y + z) {
				ld one = x ? (x + 0.0) / (x + y + z + 0.0) * dp[x - 1][y][z] : 0.0;
				ld two = y ? (y + 0.0) / (x + y + z + 0.0) * dp[x + 1][y - 1][z] : 0.0;
				ld thr = z ? (z + 0.0) / (x + y + z + 0.0) * dp[x][y + 1][z - 1] : 0.0;
				dp[x][y][z] = (n + 0.0) / (x + y + z + 0.0) + one + two + thr;
			}
	cout << fixed << setprecision(10) << dp[cnt[1]][cnt[2]][cnt[3]] << '\n';
	cin.ignore(2); return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> vec(M);
  int m=0;
  for(int i=0;i<M;i++) {
    cin>>vec.at(i);
    m+=vec.at(i);
  }
  if(N<m) cout<<-1<<endl;
  else cout<<N-m<<endl;
}
  

Measured memory_bytes: 3636
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);

    ll sum = 0;
    rep(i, N) sum += A.at(i);

    string ans = "No";
    if (H <= sum) {
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1)return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  ll n, m, a, b;
  cin >> n >> m;
  UnionFind uf(n);
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }

  int ans = 0;
  vector<bool> seen(n, false);
  for(int i = 0; i < n; ++i)
  {
    int r = uf.root(i);
    ans += !seen[r];
    seen[r] = true;
  }
  cout << ans - 1;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3972
#include <cstdio>

long long int h[100005];

int main(){
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	for(int i=0; i<N; ++i)
		scanf("%lld", h+i);
	long long int good = 1e9, bad = 0, cnt;
	while(good - bad > 1){
		long long int m = (good + bad) / 2;
		cnt=0;
		for(int i=0; i<N; ++i){
			if(m*B < h[i])
				cnt += (h[i] - m*B + A-B-1) / (A-B);
		}
		if(cnt > m){
			bad = m;
		}else{
			good=m;
		}
	}
	printf("%lld\n", good);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if ( S == "SSS" ){
    cout << 0 << endl;}
  else if ( S == "SSR" || S == "SRS" || S == "RSS" || S == "RSR"){
    cout << 1 << endl;}
  else if ( S == "SRR" || S == "RRS" ){
    cout << 2 << endl;}
  else if ( S == "RRR"){ 
    cout << 3 << endl;}
  
 
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int color[100005] = {};
vector<int> e_e[100005];
vector<int> e_o[100005];

void dfs(int u, int p, int c){
    color[u] = c;
    for(auto s:e_e[u]){
        if(s==p){
            continue;
        }
        dfs(s,u, c);
    }
    for(auto s:e_o[u]){
        if(s==p){
            continue;
        }
        dfs(s,u, c ^ 1);
    }
}
int main() {
    int n;cin >> n;
    int u,v,w;
    rep(i,n-1){
        cin >> u >> v >> w;
        u--,v--;
        if(w&1){
            e_o[u].push_back(v);
            e_o[v].push_back(u);
        }else {
    e_e[u].push_back(v);
            e_e[v].push_back(u);
        }
    }
    dfs(0,-1,0);
    rep(i,n)
    {
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 12928