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

int main(void){
  int H, W;
  cin >> H >> W;
  char A[H][W];
  int d[H][W];
  const int INF = 1e9;
  queue<pair<int, int>> que;
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      char tmp;
      cin >> tmp;
      d[i][j] = INF;
      if(tmp == '#') {
        d[i][j] = 0;
        que.push(make_pair(i, j));
      }
    }
  }
  
  while(que.size()>=1){
    auto p = que.front(); que.pop();
//    cout << "x, y = " << p.first << ", " << p.second << endl;
//    cout << "d[3][0]: " << d[3][0] << endl;

    if(p.first - 1 >=0) {
      if(d[p.first -1][p.second] > d[p.first][p.second]+1){
        d[p.first-1][p.second] = d[p.first][p.second]+1;
        que.push(make_pair(p.first-1, p.second));
      }
    }
    if(p.second - 1 >=0) {
      if(d[p.first][p.second-1] > d[p.first][p.second]+1){
        d[p.first][p.second-1] = d[p.first][p.second]+1;
        que.push(make_pair(p.first, p.second-1));
      }
    }
    if(p.first + 1 < H) {
      if(d[p.first +1][p.second] > d[p.first][p.second]+1){
        d[p.first+1][p.second] = d[p.first][p.second]+1;
        que.push(make_pair(p.first+1, p.second));
      }
    }
    if(p.second + 1 < W) {
      if(d[p.first][p.second+1] > d[p.first][p.second]+1){
        d[p.first][p.second+1] = d[p.first][p.second]+1;
        que.push(make_pair(p.first, p.second+1));
      }
    }    
  }
  int ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      ans = max(ans, d[i][j]);      
//      cout << d[i][j] << " ";
    }
//    cout << endl;
  }
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 12304
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	vector<int> ABC = igets(3);
  	sort(ABC.begin(),ABC.end());
  	if(ABC[0]==5&&ABC[1]==5&&ABC[2]==7)
		cout << "YES" << endl;
  	else cout << "NO" << endl;
  	 
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

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

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

int main() {
    string s; cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}



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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
    if(l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m+1, r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0, pre.size());
    for(int i=0; i<n; i++){
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

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

    for(int i=0; i<n; i++){
        cin >> k;
        pre.push_back(k);
    }

    for(int i=0; i<n; i++){
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}


Measured memory_bytes: 3172
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

char calc(string s, long k) {
    int p = -1;
    for (int i = 0; i < s.length; i++) {
        if (s[i] == '1') p = i;
        else break;
    }

    if (k <= p + 1) return '1';
    return s[p+1];
}

void main() {
    string s = read!string;
    long k = read!long;
    writeln(calc(s, k));
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int N;
    int ans;
    string A, B, C;

    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    for (int i = 0; i < N; i++) {
        set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        ans += (s.size()-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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


int main() {
  using dt=LL;
  dt N, X, T; scanf("%lld %lld %lld" ,&N, &X, &T);
  dt t = 0;
  while(N>0){
    t += T;
    N -= X;
  }
  printf("%ld\n",t);
  return 0;
}



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

using namespace std;

int n;
int v[200001];
int a[200001];

int main()
{
    cin >> n;

    int i;
    for(i = 1; i <= n; i ++)
        cin >> v[i], a[i] = v[i];

    sort(v + 1, v + n + 1);

    for(i = 1; i <= n; i ++)
    {
        if(n % 2)
        {
            int poz = (n + 1) / 2;

            if(a[i] >= v[poz])
                cout << v[poz - 1] << "\n";

            else
                if(a[i] < v[poz])
                    cout << v[poz] << "\n";
        }

        else
        {
            int poz = (n + 1) / 2;

          //  cout << poz << " " << v[poz] << " " <<

            if(a[i] > v[poz])
                cout << v[poz] << "\n";

            else
                if(a[i] <= v[poz])
                    cout << v[poz + 1] << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3712
import java.math.BigInteger;
import java.util.*;

public class Main {
    static final Map<Long, Integer> primes = new HashMap<>();

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        while(N>1) {
            if(N%2L!=0L) break;
            add(2L);
            N/=2L;
            continue;
        }
        long div = 3L;
        while(N>1 && div*div<=N) {
            if(N%div!=0L) {
                div+=2L;
                continue;
            }
            add(div);
            N/=div;
        }
        if(N>1) {
            add(N);
        }
//        for(long key : primes.keySet()) {
//            System.out.println(String.format("%d:%d", key, primes.get(key)));
//        }
        int count = 0;
        for(long key: primes.keySet()) {
            int c = primes.get(key);
            int t = 1;
            while(c>=t) {
                count++;
                c-=t;
                t++;
            }
        }
        System.out.println(count);
    }

    static void add(long t) {
        if(primes.containsKey(t)) {
            int pow = primes.get(t);
            primes.put(t, pow+1);
        } else {
            primes.put(t, 1);
        }
    }
}


Measured memory_bytes: 35808
#include<iostream>
using namespace std ;
int main() {

    int k,dest1,dest2 ;
    cin >> k >> dest1 >> dest2 ;
    for(;dest1<=dest2;dest1++) {
        if(dest1%k==0) {
            cout << "OK" << endl ;
            break ;
        }
    }
    if(dest1>dest2) cout << "NG" << endl ;
    
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner  sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x =sc.nextInt();
        int count=0;
        for (int i=0; i<= a;i++){
            for (int j=0;j<= b;j++){
                for (int k=0;k<=c;k++){
                    int total = 500 *i +100*j +50*k;
                    if (total ==x){
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

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

list<int> lst;

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

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    if(s.size() > 6){
      if(s == "deleteFirst") lst.pop_front();
      if(s == "deleteLast") lst.pop_back();
    }
    else {
      int t; cin >> t;
      if(s == "insert") lst.push_front(t);
      if(s == "delete"){
        for(auto p = lst.begin(); p != lst.end(); p++){
          if(*p == t){
            lst.erase(p);
            break;
          }
        }
      }  
    }
  }

  for(auto p = lst.begin(); p != lst.end(); p++){
    if(p == lst.begin()) cout << *p;
    else cout << " " << *p;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 34404
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int MAX = 31;
const int MAX_D = 4;
const int INF = 1<<27;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int cost[MAX][MAX][MAX_D],g[MAX][MAX],order[MAX_D];
int n,m;

struct State{
  int x,y,d,cost;
  State(){}
  State(int _x,int _y,int _d,int _cost) : x(_x), y(_y) ,d(_d), cost(_cost){}

  bool operator > (const State &s) const {
    return cost > s.cost;
  }
};

int ans(){
  priority_queue<State,vector<State>, greater<State> >Q; 
  fill(cost[0][0],cost[MAX][0],INF);
  Q.push(State(0,0,0,0));
  cost[0][0][0] = 0;

  while(!Q.empty()){
    const State t = Q.top(); Q.pop();
    if(t.x == m-1 && t.y == n-1) return t.cost;
    for(int i = 0 ; i < 4 ; i++){
      State u = t;
      u.cost += (g[t.y][t.x] == i ? 0 : order[i]);
      u.d = (t.d + i) % 4;
      u.x += dx[u.d],u.y += dy[u.d];
      if(0 <= u.y && u.y < n && 0 <= u.x && u.x < m &&
	 cost[u.y][u.x][u.d] > u.cost){
	cost[u.y][u.x][u.d] = u.cost;
	Q.push(u);
      }
    }
  }
  return -1;
}

int main(){
  while(cin >> m >> n ,n+m){
    for(int i = 0 ; i < n ; i++)
      for(int j = 0 ; j < m ; j++)
	cin >> g[i][j];

    for(int i = 0 ; i < 4 ; i++) cin >> order[i];

    cout << ans() << endl;
  }

  return 0;
}

Measured memory_bytes: 1332
//A Fifty-Fifty
#include <bits/stdc++.h>
using namespace std;

int main()
{
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)&&s.at(2)==s.at(3))
  {
    if(s.at(1)==s.at(2))
    {
      cout<<"No"<<endl;
    }
    else
    {
      cout<<"Yes"<<endl;
    }
  }
  else if(s.at(0)==s.at(2)&&s.at(1)==s.at(3))
  {
    if(s.at(0)==s.at(1))
    {
      cout<<"No"<<endl;
    }
    else
    {
      cout<<"Yes"<<endl;
    }
  }
  else if(s.at(0)==s.at(3)&&s.at(1)==s.at(2))
  {
    if(s.at(0)==s.at(1))
    {
      cout<<"No"<<endl;
    }
    else
    {
      cout<<"Yes"<<endl;
    }
  }
  else
  {
    cout<<"No"<<endl;
  }
}


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

// typedef
typedef unsigned long long ull;
typedef unsigned int uint;

// macro
#define REP(index, num) for (auto index = 0; index < num; index++)

using namespace std;

void Set753Number(uint inNum, uint inNumSize, vector<uint> &inAll753Numbers);

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

  vector<uint> all753Numbers;

  for (auto index = 0; index <= 9; index++)
    Set753Number(0, index, all753Numbers);  //753数をセット

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

  // Nに一番近い、N以下の753数を探す
  int count = 0;
  for (auto &&val : all753Numbers)
  {
    if (val <= N)
      count++;
    else
      break;
  }

  cout << count << endl;

}

void Set753Number(uint inNum, uint inNumSize, vector<uint> &inAll753Numbers)
{
  uint num = inNum * 10;  //一桁ずらす

  if (inNumSize)
  {
    Set753Number(num + 3, inNumSize - 1 ,inAll753Numbers);
    Set753Number(num + 5, inNumSize - 1 ,inAll753Numbers);
    Set753Number(num + 7, inNumSize - 1 ,inAll753Numbers);
  }
  else
  {
    bool flag3 = false;
    bool flag5 = false;
    bool flag7 = false;

    uint cpInNum = inNum;
    while (cpInNum)
    {
      switch (cpInNum % 10)
      {
      case 3:
        flag3 = true;
        break;
      case 5:
        flag5 = true;
        break;
      case 7:
        flag7 = true;
        break;
      default:
        break;
      }
      cpInNum /= 10;
    }

    // 753数になっていれば追加
    if (flag3 * flag5 * flag7)
      inAll753Numbers.push_back(inNum);

  }

}

Measured memory_bytes: 512
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            int[] Xvectors = new int[150];
            int[] Yvectors = new int[150];
            int n = int.Parse(Console.ReadLine());
            string[] line1 = Console.ReadLine().Split();
            string[] line2 = Console.ReadLine().Split();
            double p1sigma = 0;
            double p2sigma = 0;
            double p3sigma = 0;
            double pmaxsigma = 0;
            double three = 1;
            three = three / 3;
            for (int i = 0; i < line1.Length; i++)
            {
                Xvectors[i] = int.Parse(line1[i]);
                Yvectors[i] = int.Parse(line2[i]);
            }
            for (int i = 0; i < n; i++) p1sigma += Math.Abs(Xvectors[i] - Yvectors[i]);
            Console.WriteLine(p1sigma);
            for (int i = 0; i < n; i++) p2sigma += Math.Pow(Math.Abs(Xvectors[i] - Yvectors[i]), 2);
            Console.WriteLine(Math.Sqrt(p2sigma));
            for (int i = 0; i < n; i++) p3sigma += Math.Pow(Math.Abs(Xvectors[i] - Yvectors[i]), 3);
            Console.WriteLine(Math.Pow(p3sigma,three));
            //Console.WriteLine(Math.Cbrt(p3sigma));
            for (int i = 0; i < n; i++) pmaxsigma = Math.Max(pmaxsigma, Math.Abs(Xvectors[i] - Yvectors[i]));
            Console.WriteLine(pmaxsigma);
        }
    }
}


Measured memory_bytes: 18072
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


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

	int M;
	scanf("%d",&M);

	int Q[M];
	for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
	sort(Q,Q+M);

	int left = 0,right,m,count = 0;

	for(int i = 0; i < M; i++){
		right = N-1;
		m = (left+right)/2;

		while(left <= right){
			if(S[m] == Q[i]){
				count++;
				left= m+1;
				break;
			}else if(S[m] > Q[i]){
				right = m-1;
			}else{ //S[m] < Q[i]
				left = m+1;
			}
			m = (left+right)/2;
		}
	}
	printf("%d\n",count);
}



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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  int n,l;cin>>n>>l;
  int ans;
  int eat;
  if(l>=0){
    eat=1;
  }else if(l>=1-n){
    eat=1-l;
  }else{
    eat=n;
  }
  ans=n*(l-1)+n*(n+1)/2-(l+eat-1);
  cout << ans << endl;
}


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

int main(){
    int64_t X, Y;
    cin >> X >> Y;
    int64_t Z = Y/X;
    int64_t i = 1;
    int count = 0;
    while (Z>=i){
        i *= 2;
        count ++;
    }
    cout << count << endl;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	if(n <= k){
		cout << x * n << endl;
	}else{
		cout << (x*k) + (y*(n-k)) << endl;
	}

	return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;

class Main {
    final static int k = 10001;
  static int[] C = new int[k];

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int size = sc.nextInt();
    int current = 0;
    int[] A = new int[size];
    int[] B = new int[size];

    for (int i = 0; i < size; i++) {
      A[i] = Integer.parseInt(sc.next());
      C[A[i]]++;
    }

    for (int i = 1; i < k; i++) {
      C[i] += C[i - 1];
    }

    for (int i = size - 1; i >= 0; i--) {
      B[--C[A[i]]] = A[i];
    }
    System.out.println(Arrays.stream(B).boxed().map(n -> n.toString()).collect(joining(" ")));
  }
}



Measured memory_bytes: 329272
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
var line = chunk.toString().split('\n');
var seconds = Number(line[0]);
var hour_sec = 60*60;
var minute_sec = 60;

var hour = Math.floor(seconds / hour_sec);
var minute =  Math.floor((seconds % hour_sec) / minute_sec);
var sec = seconds % hour_sec % minute_sec;

console.log(hour + ':'+minute+':'+sec);
});

Measured memory_bytes: 15588
#include <iostream>
#include <set>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>

using namespace std;

const int WALL = 100;

struct Data {
	char field[22][22];
	char x, y;
	char step;
	bool operator<(const Data& a) const {
		return (0 < memcmp(field, a.field, sizeof(field)));
	}
};

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

int main(void)
{
	int h, w, cnt = 0;
	int start[2];
	char f[22][22];
	while (cin >> w >> h){
		cnt++;
		if (h == 0 && w == 0){
			break;
		}
		for (int i = 0; i < 22; i++){
			for (int j = 0; j < 22; j++){
				f[i][j] = WALL;
			}
		}

		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				int v;
				scanf("%d", &v);
				f[i][j] = v;
				if (v == 2){
					start[0] = i, start[1] = j;
					f[i][j] = 0;
				}
			}
		}

		queue < Data > q;
		set < Data > vis;
		Data d;
		memcpy(d.field, f, sizeof(f));
		d.step = 0;
		d.x = start[1], d.y = start[0];
		for (q.push(d); !q.empty(); q.pop()){
			Data& data2 = q.front();
			// if (vis.count(data2)) continue;
			// vis.insert(data2);

			// if (cnt == 21){
			// 	cerr << endl;
			// 	for (int i = 1; i <= h; i++){
			// 		for (int j = 1; j <= w; j++){
			// 			if (i == data2.y && j == data2.x){
			// 				cerr << "* ";
			// 			}
			// 			else {
			// 				cerr << (int)data2.field[i][j] << " ";
			// 			}
			// 		}
			// 		cerr << endl;
			// 	}
			// 	cin >> ddd;
			// }

			if (data2.step + 1 > 10){
				continue;
			}
			for (int i = 0; i < 4; i++){
				Data data = data2;
				int ny = data.y, nx = data.x;
				if (data.field[ny + dy[i]][nx + dx[i]] == 1){
					continue;
				}
				while (1){
					ny += dy[i], nx += dx[i];
					if (data.step + 1 <= 10 && data.field[ny][nx] == 3){
						// goal
						cout << data.step + 1 << endl;
						goto GOAL;
					}
					if (data.field[ny][nx] == WALL){
						// fault
						break;
					}
					if (data.field[ny][nx] == 1){
						// wall
						data.field[ny][nx] = 0;
						data.y = ny - dy[i], data.x = nx - dx[i];
						data.step++;
						q.push(data);
						break;
					}
				}
			}
		}
		// cout << "size " << q.size() << endl;
		cout << -1 << endl;
		GOAL :;
	}
	return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

    if ( N*A < B ) {
    cout << N*A << endl;
  }
  if ( N*A == B) {
    cout << N*A << endl;
  }
    if ( N*A > B) {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string strRep(int n,string str){
  if(n<=0)return "";
  string ret=str;
  for(int i=1;i<n;i++)ret+=str;
	return ret;
}
  
int main(){
    int D;cin>>D;
  	string ans;
  ans="Christmas"+ strRep(25-D," Eve");
  cout <<ans<<endl;
}

Measured memory_bytes: 384
function Main(input) {
  input = input.split("\n");
  var R = parseInt(input[0].split(" ")[0]);
  var G = parseInt(input[0].split(" ")[1]);
  var B = parseInt(input[0].split(" ")[2]);
  var N = parseInt(input[0].split(" ")[3]);
  var ans=new Array(N+1);
  ans[0]=[1,0,0];
  for(var i=1;i<N+1;i++){
    tmp = new Array(3).fill(0);
    ans[i]=tmp;
  }
  var rgb=[R,G,B];
  rgb.sort(function(a, b){return a-b});
  R=rgb[0];
  G=rgb[1];
  B=rgb[2];
  for(var i=1;i<N+1;i++){
    if(i>=R){
      ans[i]=[ans[i][0]+ans[i-R][0],ans[i][0]+ans[i-R][0],ans[i][2]];
    }
    if(i>=G){
      ans[i]=[ans[i][0]+(ans[i-G][0]-ans[i-G][1]),ans[i][1],(ans[i-G][0]-ans[i-G][1])];
    }
    if(i>=B){
      ans[i]=[ans[i][0]+(ans[i-B][0]-ans[i-B][1]-ans[i-B][2]),ans[i][1],ans[i][2]];
    }
  }
  var ans=ans[N][0];
  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x1,x2,x3,x4,x5,ans;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0)
        ans=1;
    else if(x2==0)
        ans=2;
        else if(x3==0)
        ans=3;
        else if(x4==0)
        ans=4;
        else if(x5==0)
        ans=5;
        cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N+1);
    vector<ll> minus;
    vector<ll> expression(N+1);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
        if(i == 0 or minus.empty() or minus.back() != i - 1) {
            expression[i+1] = expression[i] + A[i];
        } else {
            expression[i+1] = expression[i] - A[i];
        }
        //cerr << i << " " << expression[i+1] << endl;
        if(i != N - 1) {
            char a;
            cin >> a;
            if(a == '-') minus.push_back(i);
        }
    }
    ll ans = expression.back();
    for(int i = 0; i + 1 < minus.size(); i++) {
        ll tmp = expression[minus[i]+1];
        tmp -= (sum[minus[i+1]+1] - sum[minus[i]+1]);
        tmp += sum[N] - sum[minus[i+1]+1];
        //cerr << i << " " << minus[i] << " " << minus[i+1] << " " << tmp << endl;
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704
n = int(input())
a = [int(input()) for _ in range(n)]

ret = 0

for i in range(n):
    if a[i] == 0:
        continue
    b = a[i] // 2
    if a[i] % 2 == 0:
        ret += b - 1
        a[i] = 2
    else:
        ret += b
        a[i] = 1

for i in range(n-1):
    if a[i] == 1 and a[i+1] > 0:
        ret +=1
        a[i+1] -= 1
    if a[i] == 2:
        ret += 1

if a[-1] == 2:
    ret += 1
print(ret)


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

# 文字列参照用
c = "abcdefghijklmnopqrstuvwxyz"

ans = ""

while True:
    x = n % 26
    
    if x == 0:
        x = 26
    ans += c[x-1]
    
    n -= x
    
    if n == 0:
        break
        
    n //= 26
    
print(ans[::-1])

Measured memory_bytes: 9188
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > G;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};
string Psb[2] = {"Impossible", "Possible"};
string psb[2] = {"impossible", "possible"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int j = 0; j < n; j++)
    {
        int tr = 1;
        for (int i = j; i < n; i++)
        {
            if (s[i] != t[i - j]) tr = 0;
        }
        if (tr) cout << n + j, exit(0);
    }
    cout << n + n;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
/*************************************************************************
	> File Name: 2.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/27 20:42:50
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register LL i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
LL ans=0;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	LL n=read(),x,y;
//	x=sqrt(n)+1;
//	cout<<x<<endl;
	For(i,1,n){
		y=n/i;
		ans+=(y*i+y*(y-1)/2*i);
	}
//	ans+=(x+1+n)*(n-x)/2;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

    int N, M; cin >> N >> M;
    P p[100100];
    rep(i, M) {
        int a, b; cin >> a >> b;
        p[i].second = a; p[i].first = b;
    }

    sort(p, p + M);

    int ans = 0;

    int ok = 0;
    rep(i, M) {
        if (ok <= p[i].second) {
            ans ++;
            ok = p[i].first;
        }
    }

    cout << ans << "\n";

    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s;int K;cin>>s>>K;
	vector<pair<char,int>>v;
	for(char c:s){
		if(v.empty()||v.back().first!=c)v.push_back({c,1});
		else v.back().second++;
	}
	if(v.size()==1){
		cout<<(s.size()*(ll)K)/2<<endl;
		return 0;
	}
	ll c=0;
	ll a=0,b=0;
	for(int i=1;i+1<v.size();i++){
		a+=v[i].second/2;
	}
	if(v.front().first==v.back().first){
		c+=v.front().second/2;
		c+=v.back().second/2;
		b+=(v.front().second+v.back().second)/2;
	}
	else{
		c+=v.front().second/2;
		c+=v.back().second/2;
		b+=v.front().second/2;
		b+=v.back().second/2;
	}
	cout<<a*K+b*(K-1)+c<<endl;
}

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

ll w,h,v,t,x,y,p,q;

int main(){
  cin >> w >> h >> v >> t >> x >> y >> p >> q;

  ll num = (v*t+y)/h;
  ll pos = num*h + ((num&1LL)?(h-q):q);

  ll res = 0;
  while(true){
    if(pos < -v*t+y)break;
    if(pos <= v*t+y){
      ll len = v*t*v*t - (pos-y)*(pos-y);
      ll l = 0, r = (v*t+w-1)/w+10LL;
      while(r-l>1){
	ll mid = (r+l)/2;
	ll pos = (mid-1)*w - x;
	if(mid&1LL)pos += p;
	else pos += w-p;
	if(pos*pos <= len)l = mid;
	else r = mid;
      }
      res += l;

      l = 0, r = (v*t+w-1)/w+10LL;
      while(r-l>1){
	ll mid = (r+l)/2;
	ll pos = (mid-1)*w + x;
	if(mid&1LL)pos += p;
	else pos += w-p;
	if(pos*pos <= len)l = mid;
	else r = mid;
      }
      res += l;
    }

    if(num&1LL)pos -= 2*(h-q);
    else pos -= 2*q;
    num--;
  }

  cout << res << endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    vector<double> a(n);
    FOR(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    double v=a[0];
    for(int i=1;i<n;++i){
        v = (v+a[i])/2.;
    }
    cout << setprecision(8) << fixed << v;
    return 0;
}



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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define vll vector <ll>
#define vull vector <ull>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define pb emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

int main ()

{
    fast;
    
    int n;
    cin >> n;
    
    ll sum = 0;
    for (ll i=1; i<=n; i++)
    {
        if (i%3 == 0 || i%5 == 0)
        continue;
        else sum += i;
    }
    
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main()
{
	char a[11],b[11];
	int i,x,y;
	gets(a);
	gets(b);
	x=strlen(a);
	y=strlen(b);
	for(i=1;i<y;i++)
	{
		b[i];
	}
	b[i-1]='\0';
	if (strcmp(a,b)==0)
          {
                    printf("Yes\n");
          }
          else
                    printf("No\n");
return 0;
}


Measured memory_bytes: 1484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll d,g;
	vector<ll> p,c;
	cin>>d>>g;
	FOR(i,0,d){
		ll a,b;cin>>a>>b;
		p.pb(a);
		c.pb(b);
	}
	REV(p);REV(c);
	ll ans = INF;
	FOR(i,0,1<<d){
		ll gg = g;
		priority_queue<ll> pp;
		ll w=0;
		FOR(j,0,d){
			if(i&(1<<j)){
				gg -= p[j]*(100*d-j*100);
				gg -= c[j];
				w+=p[j];
			}else{
				FOR(ll,0,p[j]-1)pp.push(100*d-j*100);
			}
		}
		if(gg<=0){
			ans = min(ans,w);
			continue;
		}		
		bool nextt=false;	
		while(gg>0){
			if(pp.empty()){
				nextt=true;
				break;
			}
			gg -= pp.top();
			pp.pop();
			w++;
		}
		if(nextt)continue;
		ans = min(ans,w);
	}
	pri(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}char a[maxn],b[maxn];
signed main(){
    //file(a);
    scanf("%s%s",a,b);int ans=0;
    // cout<<strlen(a)<<" "<<strlen(b)<<endl;
    rep(i,0,strlen(a)-1){
        int sum=0;
        if(i+strlen(b)-1>strlen(a)-1)break;
        rep(j,0,strlen(b)-1){
            if(a[i+j]==b[j])++sum;
        }ans=max(ans,sum);
    }printf("%d\n",strlen(b)-ans);

    return 0;
}


Measured memory_bytes: 3760
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        char[] ary = s.ToArray();

        string ans = "No";
        for (int i = 0; i < ary.Length - 1; i++)
        {
            if (ary[i] != ary[i + 1])            {
                ans = "Yes";
                break;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
#include<stdio.h>

#define MAX_CARD_STR_SIZE (101)

int main(void)
{
        int card_count, card_index, card_str_index, taro_point, hanako_point;
        char taro_card[MAX_CARD_STR_SIZE], hanako_card[MAX_CARD_STR_SIZE];

        taro_point = 0;
        hanako_point = 0;

        scanf("%d", &card_count);

        for(card_index=0; card_index < card_count; card_index++){
                scanf("%s %s", taro_card, hanako_card);

                for(card_str_index=0; card_str_index < MAX_CARD_STR_SIZE; card_str_index++){
                        if(taro_card[card_str_index] == '\0' && hanako_card[card_str_index] == '\0'){
                                taro_point++;
                                hanako_point++;
                                break;
                        }else if(taro_card[card_str_index] == '\0' && hanako_card[card_str_index] != '\0'){
                                hanako_point += 3;
                                break;
                        }else if(taro_card[card_str_index] != '\0' && hanako_card[card_str_index] == '\0'){
                                taro_point += 3;
                                break;
                        }

                        if(taro_card[card_str_index] == hanako_card[card_str_index]){
                                continue;
                        }else if(taro_card[card_str_index] > hanako_card[card_str_index]){
                                taro_point += 3;
                                break;
                        }else{
                                hanako_point +=3;
                                break;
                        }
                }
        }

        printf("%d %d\n", taro_point, hanako_point);

        return 0;
}


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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
         ll a[5];
         ll ans;
         for(int i =0 ; i < 5 ; i ++)
         {
             cin >> a[i];
             if(a[i] == 0)
             ans = i + 1;
         }    
         cout << ans << endl;
   }
}


Measured memory_bytes: 3604
A,B=map(int,input().split())

G=list()
for i in range(50):
  G.append(['#']*100)
for i in range(50):
  G.append(['.']*100)

for i in range(A-1):
  G[2*(i//50)][2*(i%50)]='.'
for i in range(B-1):
  G[50+2*(i//50)+1][2*(i%50)]='#'

print(100,100)
for i in range(100):
  print(''.join(G[i]))


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

vector<int> sieve(int n){
    vector<bool> f(n+1);
    for(int i=3; i<=n; i+=2) f[i] = 1;
    for(int i=3; i<=sqrt(n); i+=2) if(f[i]) for(int j=i*3; j<=n; j+=i) f[j] = 0;
    vector<int> res{2};
    for(int i=3; i<=n; i+=2) if(f[i]) res.push_back(i);
    return res;
}

const ll MAX_S = 10000000000ll;

int main(){
    int N, cnt, ans = 0;
    unordered_map<ll, pii> hoge;
    vi ps;
    ll x, y, z;
    
    ps = sieve(cbrt(MAX_S) + 0.5);

    cin >> N;
    vll S(N);
    rep(i, N)scanf("%lld", &S[i]);

    each(s, S){
        x = y = 1;
        each(p, ps){
            if(p > s)break;
            cnt = 0;
            while(s%p == 0){
                ++cnt;
                s /= p;
            }
            cnt %= 3;
            if(cnt == 1){
                x *= p;
                y *= p*p;
            } else if(cnt == 2){
                x *= p*p;
                y *= p;
            }
        }

        if(s > 1){
            x *= s;
            z = (ll)(sqrt(s) + 0.5);
            if(z*z == s){
                y *= z;
            } else{
                y *= s*s;
            }
        }

        if(x == 1){
            ans = 1;
        }else if(x < y){
            hoge[x].first++;
        } else{
            hoge[y].second++;
        }
    }

    each(a, hoge){
        ans += max(a.second.first, a.second.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5156
#include <stdio.h>
int main()
{
	char s[10],s1[10],c=0;
	scanf("%s",s);
	scanf("%s",s1);
	for(int i=0;i<3;i++)
	{
		if(s[i]==s1[i])
		{
			c++;
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define ll long long 
#define ull unsigned long long 
using namespace std;

char s[110];
int main()
{


	int a, b;
	cin >> a >> b;
	cin >> s;
	for(int i=0; i<strlen(s); ++i)
	{
		if(s[a]!='-')
		{
			cout << "No" << endl;
			return 0;
		}
		if(i!=a)
		{
			if(s[i]>'9' || s[i] <'0')
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s_lists = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
count = 0
for i in range(2**n):
  l = 1
  for p, S in zip(P, s_lists):
    l *= (sum([int(bin(i)[2:].zfill(n)[s-1]) for s in S]) % 2 == p)
  count += l
print(count)

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

int main() {
  int s;
  cin >> s;
  
  if (s == 0) cout << 0 << endl;
  else if (s % 3 == 1) cout << 1 << endl;
  else if (s % 3 == 2) cout << 2 << endl;
  else cout << 3 << endl;
  
}


Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, K, A[105];
bool DP[100005], visited[100005];

bool Calc(int turn){
  if (visited[turn] == true) return DP[turn];
  visited[turn] = true;
  if (turn == 0) return DP[0] = false;

  bool ans = false;
  for (int i = 0; i < N; i++){
    if (turn - A[i] < 0) continue;
    if (!Calc(turn - A[i])) ans = true;
  }
  return DP[turn] = ans;
}

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


  if (Calc(K)) printf("First\n");
  else printf("Second\n");

  return 0;
}


Measured memory_bytes: 6656
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n: usize = split.next().unwrap().parse().unwrap();
    let m: usize = split.next().unwrap().parse().unwrap();
    let mut adjacency = vec![Vec::new(); n];
    for _ in 0..m {
        let mut s = String::new();
        input.read_line(&mut s).unwrap();
        let mut split = s.split_whitespace();
        let a: usize = split.next().unwrap().parse().unwrap();
        let b: usize = split.next().unwrap().parse().unwrap();
        adjacency[a - 1].push(b - 1);
        adjacency[b - 1].push(a - 1);
    }
    for &i in &adjacency[0] {
        for &j in &adjacency[i] {
            if j == n - 1 {
                return writeln!(output, "POSSIBLE").unwrap();
            }
        }
    }
    writeln!(output, "IMPOSSIBLE").unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test(
            "3 2
1 2
2 3\n",
            "POSSIBLE\n",
        );
    }
    #[test]
    fn case2() {
        test(
            "4 3
1 2
2 3
3 4\n",
            "IMPOSSIBLE\n",
        );
    }
    #[test]
    fn case3() {
        test(
            "100000 1
1 99999\n",
            "IMPOSSIBLE\n",
        );
    }
    #[test]
    fn case4() {
        test(
            "5 5
1 3
4 5
2 3
2 4
1 4\n",
            "POSSIBLE\n",
        );
    }
}


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

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

    ll n;
    cin >> n;

    ll ans = n * (n - 1) / 2;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    string s;
    cin >> n >> s;
    vector<pair<ll,ll>> vp(n+1,{0,0});
    repp(i,1,n+1){
        vp[i] = vp[i-1];
        if(s[i-1] == '#')vp[i].first++;
        else vp[i].second++;
    }
    ll res = LONG_LONG_MAX;
    repp(i,1,n+1)res = min(res, vp[i-1].first + (vp[n].second - vp[i].second));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6764