akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<ll,ll> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int w,h,bx,by,sum=0;
char m[21][21];

void dfs(int x,int y)
{
    if(m[y][x]=='#')return;
    if(m[y][x]=='.'){sum++;m[y][x]='#';}
    REP(i,4)
    {
        int xx=x+dx[i];
        int yy=y+dy[i];
        if(xx>=0&&xx<w&&yy>=0&&yy<h)dfs(xx,yy);
    }
}

int main()
{   
    while(cin>>w>>h,w){
    sum=0;
    REP(i,h)REP(j,w)
    {
        cin>>m[i][j];
        if(m[i][j]=='@'){bx=j;by=i;m[i][j]='.';}
    }
    dfs(bx,by);
    cout<<sum<<endl;
    }
}


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

int main(){
  int N; cin>>N;
  vector<int> dan(N);
  for(int i=0; i<N; i++){
    int H; cin>>H;
    dan[i]=H;
  }
  bool dekiru=1;
  reverse(dan.begin(), dan.end()); //右から左、単調非増加
  for(int i=1; i<N; i++){
    if(dan.at(i)-dan.at(i-1)==1) dan.at(i)--;
    else if(dan.at(i)-dan.at(i-1)>1) dekiru=0;
  }
  if(dekiru) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 640
import java.io.*;
import java.io.InputStreamReader;
import java.util.*;
public class Main
{
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        HashSet<Integer>set = new HashSet<>();
        long ans = 0;
        for(int i = 1;i <= n;i++) {
            st = new StringTokenizer(br.readLine());
            int l = Integer.parseInt(st.nextToken());
            int r = Integer.parseInt(st.nextToken());
            ans += r - l + 1;
        }
        System.out.println(ans);
 
    }
}
 

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
//static const int INF = 1000010000;
//static const int NIL = -1;
//static const int MOD = 1000000007;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
//#define int ll

signed main(){
    int n;
    int a[214514];
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);

    int b;
    b = n/2;

    int ans[214514];
    for(int i=1;i<=n;i++){
        ans[b] = a[i-1];
        if(n%2==0 && i%2==1) b -= i;
        else if(n%2==0 && i%2==0) b += i;
        else if(n%2==1 && i%2==1) b += i;
        else b -= i;
    }

    for(int i=0;i<n;i++) printf("%d ",ans[i]);
    printf("\n");

    return 0;
}

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

using namespace std;

int main(void)
{
    int r, g, b, n;
    cin >> r >> g >> b;
    n = r * 100 + g * 10 + b;
    if (n % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<vector<int>> P;
    vector<int> V;
    fori(i,n) V.pb(i+1);

    do {
        P.pb(V);
    } while (next_permutation(V.begin(),V.end()));

    vector<int> a(n), b(n);
    fori(i,n) cin >> a[i];
    fori(i,n) cin >> b[i];

    int ai,bi;
    fori(k,P.size()) {
        auto& p = P[k];
        int ok = 1;
        fori(i,n) ok &= a[i]==p[i];
        if(ok) ai = k;

        ok = 1;
        fori(i,n) ok &= b[i]==p[i];
        if(ok) bi = k;
    }

    cout << abs(ai-bi) << endl;
    return 0;
}


Measured memory_bytes: 3384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



int l;
LL a[200010];
LL dp[200010][5];

void init() {

}

void input() {
  cin >> l;
  REP(i, l) cin >> a[i];
}

LL calc(LL A, LL j) {
  if (j == 1){
    if (A == 0) return 2;
    return A%2;
  }
  if (j == 2){
    return ((A+1)%2);
  }
  if (j == 3){
    if (A == 0) return 2;
    return A%2;
  }
  return A;
}

void solve() {
  REP(i, 5) dp[0][i] = 0;
  FOR(i, 1, l+1) REP(j, 5) dp[i][j] = 1LL<<50;
  REP(i, l) {
    dp[i+1][0] = dp[i][0] + a[i];
    FOR(j, 1, 5) {
      dp[i+1][j] = min(dp[i+1][j-1], dp[i][j] + calc(a[i], j));
    }
  }
  cout << dp[l][4] << endl;
}

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


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return a.first*b.second<a.second*b.first;
}

const ll mod = 1e9+7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    //clock_t tm = clock();
    fastio;
    int n,m=1e9,x;
    cin>>n;
    int ans=0;
    f(i,0,n){
        cin>>x;
        if(x<m)
            ans++;
        m=min(x,m);
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int l(N);
    rep(i,N)cin>>l.at(i);

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

    int index=0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            if(l.at(j)==l.at(i))continue;
            for(int k=j+1;k<N;k++){
                if(l.at(j)==l.at(k))continue;
                if(l.at(i)+l.at(j)>l.at(k))index++;
            }
        }
    }
    cout<<index<<endl;

    return 0;
}

Measured memory_bytes: 3628
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    k,a,b=parseMap(split(readline()))
    if b-a<=2
        println(k+1)
    else
        tmp=k-(a-1)
        res=tmp÷2
        ans=a
        for i in 1:res
            ans+=b-a
        end
        println(max(ans+tmp%2,k+1))
    end
end
main()

Measured memory_bytes: 111952
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int ARMS = 32;

string solve(int x, int y, int length) {
  if (length == -1) return "";

  long long currentLength = pow(2, length);

  // cout << "x: " << x << endl;
  // cout << "y: " << y << endl;
  // cout << "length: " << length << endl;
  // cout << "currentLength: " << currentLength << endl;
  if (abs(x - currentLength) + abs(y) < currentLength) {
    return solve(x - currentLength, y, length - 1) + "R";
  } else if (abs(x + currentLength) + abs(y) < currentLength) {
    return solve(x + currentLength, y, length - 1) + "L";
  } else if (abs(x) + abs(y - currentLength) < currentLength) {
    return solve(x, y - currentLength, length - 1) + "U";
  } else if (abs(x) + abs(y + currentLength) < currentLength) {
    return solve(x, y + currentLength, length - 1) + "D";
  } else {
    return "error";
  }
}

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

  vector<pair<int, int>> XY;
  int flag = -1;
  bool gameOver = false;
  for (int i = 0; i < N; i++) {
    int X, Y;
    cin >> X >> Y;
    XY.emplace_back(X, Y);

    if (flag == -1) {
      flag = (abs(X) + abs(Y)) % 2;
    } else {
      if (flag != (abs(X) + abs(Y)) % 2) {
        gameOver = true;
      }
    }
  }

  if (gameOver) {
    cout << -1 << endl;
    return 0;
  }

  cout << (!flag ? ARMS + 1 : ARMS) << endl;
  for (int i = 0; i < ARMS; i++) {
    cout << (long long)pow(2, i) << " ";
  }
  if (!flag) cout << 1 << " ";
  cout << endl;

  for (int i = 0; i < N; i++) {
    if (!flag) {
      cout << solve(XY[i].first - 1, XY[i].second, ARMS - 1) + "R" << endl;
    } else {
      cout << solve(XY[i].first, XY[i].second, ARMS - 1) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int n;
    cin>>n;
    int tmp=0;
    for(int i=1;i<=9;i++){
        if(n%i==0){
            if(n/i<=9){  
                tmp=1;
                break;
            } 
        }
    }
    if(tmp==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main(){
	int n; cin>>n;
	int arr[n];
	for(int i=0;i<n;++i)
		cin>>arr[i];
	int mn=arr[0];
	int c=1;
	for(int i=1;i<n;++i){
		if(mn>arr[i]){
			mn=arr[i];
			c++;
		}
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

#define Num 100

int main(void){

    int l, n, i, k, j = 1, count = 0;
    int a[Num];

    scanf("%d", &l); 

    for (i = 0; i <= l-1; i++) {
        scanf("%d", &a[i]); 
    }

    while (j > 0) {
        j = 0;
        for (i = l-1; i >= 1; i--) {
            if(a[i-1] > a[i]){
                n = a[i-1];
                a[i-1] = a[i];
                a[i] = n;
                j = 1;
                count++;
            }
        }
    }
    
    for (i = 0; i <= l-2; i++) {
        printf("%d ", a[i]); 
    }
    printf("%d\n", a[i]);
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 1992
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	double x1, y1, x2, y2, xq, yq;
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF)
	{
		double x, y;
		if (x1 != x2 && y1 != y2)
		{
			double a1 = (y1-y2)/(x1-x2);
			double b1 = y1 - a1*x1;
			double a2 = -1/a1;
			double b2 = yq - a2*xq;
			double xc = (b2-b1)/(a1-a2);
			double yc = a1*xc + b1;
			x = 2*xc - xq;
			y = 2*yc - yq;
		}
		else if (x1 == x2)
		{
			x = 2*x1 - xq;
			y = yq;
		}
		else
		{
			x = xq;
			y = 2*y1 - yq;
		}

		printf("%.6f %.6f\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 0
H,W=map(int,input().split())
p=10**9+7
ma=[]
dp=[[0]*(W+2) for j in range(H+2)]
an=[]
dp[1][1]=1
for i in range(H):
     ma.append(list(input()))
     for j in range(W):
         if i==j==0:
             continue
         if ma[i][j]=="#":
             dp[i + 1][j + 1]=0
         else:
             dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%p
print(dp[H][W])
#print(tin[an.index(ans)])


Measured memory_bytes: 88792
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = Math.PI * r * r;
        double peri = 2.0 * Math.PI * r;
        System.out.println(String.format("%.6f %.6f", area, peri));
    }
}


Measured memory_bytes: 28336
N = int(input())
S = [1 if a == "x" else 0 for a in input()]
for a, b in ((0, 0), (0, 1), (1, 0), (1, 1)):
    X = [a, b]
    for i in range(N):
        X.append(X[-1]^X[-2]^S[i])
    if X[-2:] == X[:2]:
        print("".join(["W" if x else "S" for x in X[1:-1]]))
        break
else:
    print(-1)

Measured memory_bytes: 6280
#include <iostream>
 
using namespace std;
 
int main(void){
  int a,b;
  cin >> a;
  cin >> b;
  
  if(b % a == 0){
    cout << (a+b) << endl;
  }else{
    cout << (b-a) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
/*
 
anchal24
 
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define INF 1000000000  
#define MOD 1000000007
#define M 998244353
#define N 1000010
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define trr(c,i) for(typeof((c).rbegin() i = (c).rbegin(); i != (c).rend(); i++)
 
# define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
 
//Variables Start
 
//Variables End
 
ll modularExponentiation(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%MOD,n/2);
    else                             //n is odd
        
        return (x*modularExponentiation((x*x)%MOD,(n-1)/2))%MOD;
 
}
ll modInverse(ll n) 
{ 
    return modularExponentiation(n,MOD-2); 
}



int main()
{
        ios;
    ll s,n=1;
    while(n)
    {cin>>s;
   
    	for(; s!=0; s=s/10)
    	{
    		if(s%10==7)
    			{
    				cout<<"Yes";
    				return 0;
    			}
    	}
n--;
    }
    
    
cout<<"No";    
   
     return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
	int i,n;
	Scanner sca = new Scanner(System.in);
	n=sca.nextInt();
	for(i=0;i<n;i++){
	    System.out.println(solveLCS(sca.next(),sca.next()));
	}
    }
    public static int solveLCS(String a,String b){
	int i,j;
	String[]x=a.split("");
	String[]y=b.split("");
	int[][]cont=new int[x.length+1][y.length+1];
	for(i=0;i<=x.length;i++)cont[i][0]=0;
	for(i=0;i<=y.length;i++)cont[0][i]=0;
	for(i=1;i<=x.length;i++){
	    for(j=1;j<=y.length;j++){
		if(x[i-1].equals(y[j-1])){
		    cont[i][j]=cont[i-1][j-1]+1;
		}else if(cont[i][j-1]>cont[i-1][j]){
			cont[i][j]=cont[i][j-1];
	        }else{
		    cont[i][j]=cont[i-1][j];
		    }
		
		}
	}
	    return cont[x.length][y.length];
    }
}




Measured memory_bytes: 63540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int A, B;
  cin >> A >> B;
  
  if ((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  
}

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

using namespace std;



int main(){
 
    int a,b, k =0, p;
    cin>>a>>b;

    while (b--)
    {
        cin >> p;
        k+=p;
    }
    if(k>=a) cout<<"Yes\n";
    else cout<<"No\n";
  

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if (a == 1) {
			a = a * 14;
		}
		if (b == 1) {
			b = b * 14;
		}
		if (a > b) {
			System.out.println("Alice");
		} else if (b > a) {
			System.out.println("Bob");
		} else {
			System.out.println("Draw");
		}
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    vector<ll>a(3*n);
    rep(i,3*n)cin>>a[i];
    sort(all(a));
    ll ans=0;
    REP(i,n,3*n){
        if((i-n)%2==0)ans+=a[i];
    }
    cout<<ans<<endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  map<int, int> mp;
  rep(i,k){
    cin >> d[i];
    rep(j, d[i]){
      int a;
      cin >> a;
      mp[a]++;
    }
  }
  int ans = 0;
  for (auto i : mp){
    if(i.second > 0)n--;
  }
  cout << n << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  string S;
  cin >> S;
  int cnt = 0;
  string tmp = "", privious = "";

  for(int i = 0; i < S.size(); i++) {
    tmp += S[i];
    if(tmp == privious) {
      continue;
    }
    else {
      privious = tmp;
      tmp = "";
      cnt++;
    }
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3720
#import time

def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    As = [0]+As
    ikisaki = As[1]
    aru = {1}
    itta = [1]
    imaitta = 1
  
    while not ikisaki in aru:
        imaitta = ikisaki
        ikisaki = As[ikisaki]
        itta.append(imaitta)
        aru.add(imaitta)
    ind = itta.index(ikisaki)
    kurikaesi = itta[ind:]
    itidokiri = itta[:ind]
    ans = itidokiri[K] if len(itidokiri) > K else kurikaesi[(K-len(itidokiri))%len(kurikaesi)]


    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

Measured memory_bytes: 32348
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
//#define double long double
//#define double float
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200060;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;




void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	int ok = N, ng = 0;
	while (abs(ok - ng) > 1) {
		int K = (ok + ng) / 2;
		map<int, int>mp;
		bool can = true;
		FOR(i, 1, N) {
			if (can == false)break;
			if (A[i] <= A[i - 1]) {
				if (K == 1) { can = false; break; }
				auto itr = mp.begin();
				while (itr != mp.end()) {
					if (itr->first >= A[i])itr = mp.erase(itr);
					else itr++;
				}
				bool done = false;
				FORR(j, A[i], 0) {
					if (mp[j] == K - 1) { mp.erase(mp.find(j)); }
					else { done = true; mp[j]++; break; }
				}
				if (!done) { can = false; break; }
			}
		}
		if (can)ok = K; else ng = K;
	}
	print(ok);
}

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


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        string s = Console.ReadLine();
        Dictionary<char,int> d = new Dictionary<char,int>();
        for(int i = 0;i < s.Length;i++){
            if(d.ContainsKey(s[i])){
                d[s[i]]++;
            }else{
                d[s[i]] = 1;
            }
        }
        foreach(var x in d){
            if(x.Value % 2 == 1){
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 13152
A, B, N = [int(x) for x in input().split()]

# val = (int(A * i / B) - A * int(i / B) for i in range(1, N+1))
# print(max(val))

x = B - 1
if x > N:
    x = N
print(int(A * x / B) - A * int(x / B))


Measured memory_bytes: 9156
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? (s[z]=0; z=i) : (s[i]=0) end }
}
L,M,N = [-1]*27,8,3
def calc(d,n)
  s = S[d]
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    next t[i]  if n == 0 || d+1 >= D || t[i] == 0
    l,L[i] = L[i],d
    calc(d+1,n-1)[1].tap {L[i]=l}
  }
  [i, t[i]]
end
D.times { p 1 + i=calc(_1,N)[0]; L[i]=_1 }

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, q;
string s[2000];

int c[2001][2001];
int v[2001][2001];
int h[2001][2001];

int main() {
	cin >> n >> m >> q;
	inc(i, n) { cin >> s[i]; }
	
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] = s[i - 1][j - 1] - '0';
		v[i][j] = (j < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 1][j - 2] == '1');
		h[i][j] = (i < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 2][j - 1] == '1');
	}
	}
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] += c[i - 1][j];
		v[i][j] += v[i - 1][j];
		h[i][j] += h[i - 1][j];
	}
	}
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] += c[i][j - 1];
		v[i][j] += v[i][j - 1];
		h[i][j] += h[i][j - 1];
	}
	}
	
	inc(qq, q) {
		int x1, y1, x2, y2;
		// cin >> x1 >> y1 >> x2 >> y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1--;
		y1--;
		
		#define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
		int C = R(c, x1    , y1    , x2, y2);
		int V = R(v, x1    , y1 + 1, x2, y2);
		int H = R(h, x1 + 1, y1    , x2, y2);
		
		// cout << (C - V - H) << "\n";
		printf("%d\n", C - V - H);
	}
	
	return 0;
}


Measured memory_bytes: 52864
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;

int V;
vector<int> G[2000];
int match[2000];
bool used[2000];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i],w=match[u];

    if( w<0 || !used[w] && dfs(w) ){

      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}


int m,n;
int b[500],r[500];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin>>m>>n){
    if(m==0&&n==0)break;

    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>r[i];

    for(int i=0;i<2000;i++)G[i].clear();

    //for(int i=0;i<m;i++)add_edge(n+m,i);
    //for(int i=0;i<n;i++)add_edge(m+i,n+m+1);

    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	if( __gcd(b[i],r[j])> 1 )add_edge(i,m+j);
      }
    }

    V=m;
    cout<<bipartite_matching()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<long long> A(1<<N);
	
	long long B = 1000000;
	
	for(int i=0;i<(1<<N);i++){
		scanf("%lld",&A[i]);
		A[i]*=B;
		A[i]+=i;
	}
	
	vector<vector<pair<long long,long long>>> dp((1<<N),vector<pair<long long,long long>> (N+1));
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<(1<<N);j++){
			if(i==0){
				dp[j][i] = make_pair(0,A[j]);
			}
			else{
				vector<long long> V;
				V.push_back(dp[j][i-1].first);
				V.push_back(dp[j][i-1].second);
				if((j>>(i-1))&1){
					V.push_back(dp[j&(~(1<<(i-1)))][i-1].first);
					V.push_back(dp[j&(~(1<<(i-1)))][i-1].second);
				}
				sort(V.rbegin(),V.rend());
				V.erase(unique(V.begin(),V.end()),V.end());
				dp[j][i].first = V[0];
				dp[j][i].second = V[1];
			}
		}
	}
	
	vector<long long> ans(1<<N);
	
	for(int i=0;i<(1<<N);i++){
		ans[i] = dp[i][N].first/B + dp[i][N].second/B;
		if(i!=0)ans[i] = max(ans[i],ans[i-1]);
	}
	
	for(int i=1;i<(1<<N);i++){
		printf("%lld\n",ans[i]);
		//cout<<ans[i]<<endl;
	}
	
	
	
    return 0;
}

Measured memory_bytes: 95232
#include <climits>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int n, m;
bool freeze[100];

struct state {
	int town, rest, time;
	state(int town, int rest, int time):town(town), rest(rest), time(time){}

	bool operator> (const state& s) const {
		return time > s.time;
	}
};

struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c){}
};

vector<vector<edge> > es;

int dijkstra(int s, int t) {
	priority_queue<state, vector<state>, greater<state> > que;
	vector<vector<int> > time(n, vector<int>(m + 1, INT_MAX));
	que.push(state(s, m, 0));
	time[s][m] = 0;
	
	while(!que.empty()) {
		const state s = que.top();
		que.pop();

		if(time[s.town][s.rest] < s.time)
			continue;

		if(s.town == t)
			return s.time;

		if(freeze[s.town] && s.rest < m) {
			if(time[s.town][s.rest + 1] > time[s.town][s.rest] + 1) {
				time[s.town][s.rest + 1] = time[s.town][s.rest] + 1;
				que.push(state(s.town, s.rest + 1, time[s.town][s.rest + 1]));
			}
		}

		for(int i = 0; i < (int)es[s.town].size(); ++i) {
			const edge& e = es[s.town][i];
			const int next = s.rest - e.cost;

			if(next >= 0 && time[e.to][next] > time[s.town][s.rest] + e.cost) {
				time[e.to][next] = time[s.town][s.rest] + e.cost;
				que.push(state(e.to, next, time[e.to][next]));
			}
		}
	}

	return -1;
}


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

	for(int l, k, s, t; cin >> n >> m >> l >> k >> s >> t, n;) {
		memset(freeze, false, sizeof(freeze));
		for(int i = 0; i < l; ++i) {
			int town;
			cin >> town;
			freeze[town] = true;
		}

		es.clear();
		es.resize(n);
		for(int i = 0; i < k; ++i) {
			int x, y, time;
			cin >> x >> y >> time;
			es[x].push_back(edge(y, time));
			es[y].push_back(edge(x, time));
		}

		const int ans = dijkstra(s, t);
		if(ans == -1)
			cout << "Help!" << endl;
		else
			cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T>
inline bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b);}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<bool> flag(n, false);
    int j = 1;
    int s;
    int count = 0;
    rep(i,n){
        if (flag[j - 1]){
            s = j;
            break;
        }
        flag[j - 1] = true;
        j = a[j - 1];
        count++;
    }
    vector<ll> ne;
    ll aa = s;
    do{
        ne.push_back(aa);
        aa = a[aa - 1];
    } while (aa != s);
    ll non_rep = count - ne.size() - 1;
    if (k<=non_rep){
        ll as = 1;
        rep(i,k){
            as = a[as - 1];
        }
        cout << as << endl;
        return 0;
    }
    ll ass = (k - non_rep) % ne.size();
    if (ass == 0){
        cout << ne.back() << endl;
        return 0;
    }
    else
        cout << ne[ass-1] << endl;
}

Measured memory_bytes: 6764
#include <stdio.h>
 
char ch[12];
char s[12], idx;
 
int main(void)
{
  int i;
  
  scanf("%s", ch);
  for (i = 0; ch[i]; ++i)
  {
    if (ch[i] == 'B')
    {
      if (idx != 0) idx--;
    }
    else s[idx++] = ch[i];
  }
  s[idx] = 0;
  printf("%s\n", s);
  
  return 0;
}

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

int main(){

	int h, w;
	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		string top_bottom;
		top_bottom.resize(w, '#');
		string left_right;
		left_right.resize(w);
		left_right[0] = '#';
		*(left_right.end() - 1) = '#';
		fill(left_right.begin() + 1, left_right.end() - 1, '.');

		cout << top_bottom << endl;
		for (int i = 1; i < h - 1; ++i) {
			cout << left_right << endl;
		}
		cout << top_bottom << endl << endl;
	}


	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=325,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,depth[N],a[N][N],h[N],ans;
char ch[N];
void work(int x,int d){
	if (h[x]==d) return;
	if (h[x]<0) h[x]=d;
	if (h[x]!=d) {puts("-1");exit(0);}
	for (int i=1;i<=n;i++)
	if (a[x][i]) work(i,d^1);
}
int main(){
//	freopen("balance.in","r",stdin);
//	freopen("balance.out","w",stdout);
	n=read();
	memset(h,-1,sizeof(h));
	for (int i=1;i<=n;i++){
		scanf(" %s",ch+1);
		for (int j=1;j<=n;j++) a[i][j]=ch[j]-'0';
	}
	work(1,0);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) if (!a[i][j]) a[i][j]=(i==j) ? 0 : inf;
	for (int k=1;k<=n;k++)
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	if (a[i][k]+a[k][j]<a[i][j]) a[i][j]=a[i][k]+a[k][j];
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) ans=max(ans,a[i][j]);
	printf("%d\n",ans+1);
	return 0;
}

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

int main()
{
    int64_t n; cin >> n;
    vector<int64_t> lucas(n + 1);
    lucas.at(0) = 2; lucas.at(1) = 1;

    for(int i = 0; i < n-1; i++){
        lucas.at(i + 2) = lucas.at(i) + lucas.at(i + 1);
    }
    printf("%ld\n", lucas.at(n));
}

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

int N;

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

    cin >> N;

    int sum = 0;
    for(int i = 0; i < N; ++i){
        int l, r;
        cin >> l >> r;
        sum += (r - l + 1);
    }
    cout << sum << endl;

    return 0;
}

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

int main(){
    int N, A[100];
    int count = 0;
    
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    for (int i = 0; i < N - 1; i++) {
        int m = i;
        for (int j = i + 1; j < N; j++) {
            if (A[j] < A[m]) {
                m = j;
            }
        }
        int min = A[m];
        A[m] = A[i];
        A[i] = min;
        if(A[m] != A[i]) count++;

    }

    for (int i = 0; i < N; i++) {
        if(i < N-1) cout << A[i] << " ";
        else cout << A[i] << "";
    }
    cout << endl;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
#define MOD 1000000007
using namespace std;

long long f(long long x, long long n) {
  long long fact = 1;
  for (long long i = 0; i < n; ++i) {
    fact = fact * x % MOD;
  }
  return fact;
}

int main() {
  long long n;
  cin >> n;
  long long ans = f(10, n) - (f(9, n) + f(9, n) - f(8, n));
  ans %= MOD;
  ans = (ans + MOD) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    vector<ll>a(3*n);
    rep(i,3*n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    int c = 0;
    rep(i,3*n){
        if(i%2==1){
            ans+=a[3*n-i-1];
            c++;
            if(c==n)break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
/*=====Bismillahir Rahmanir Rahim=====*\
!                                      !
!(^,^)Ron is back(-o,o-)               !
!         MD. TAREK MAHMUD RONY        !
!            CSE 12th Batch            !
!           Comilla University         !
\*====================================*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define test             ll t;cin>>t;while(t--)
#define nl               endl
#define mp(a,b)          make_pair(a,b)
#define F                first
#define S                second
#define vc               vector<int>
#define vcl              vector<ll>
#define pb               push_back
#define vc_sum(a)        accumulate(a.begin(),a.end(),0)
#define vc_max(a)        *max_element(a.begin(),a.end())
#define vc_min(a)        *min_element(a.begin(),a.end())
#define vc_sort(a)       sort(a.begin(),a.end())
#define vc_gsort(a)      sort(a.begin(),a.end(),greater<int>())
#define vc_uni(a)        a.erase(unique(a.begin(),a.end()),a.end())
#define ulta(a)          reverse(a.begin(),a.end())
#define RON              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define yes              cout<<"YES"<<nl
#define no               cout<<"NO"<<nl
#define M                1000000007
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
using namespace std;
int main()
{
    RON;
    string s, t;
    cin>>s;
    cin>>t;
    ll cnt=0;
    ll i;
    for(i=0; i<t.size(); i++)
    {
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<nl;
    return 0;
}



Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
// vector<pair<int, int>> v;
vector<pi> v;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }
// bool spOrder(const pair<int, int> &a,
//              const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first > b.first;
//  }
long double arr[100010];
void solve()
{
    ll n;
    cin >> n;
    rep(i, n)
    {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    long double m = 1;
    rep(i, n)
    {
        m *= arr[i];
        if (m > 1e18)
        {
            cout << -1 << lin;
            return;
        }
    }
    if (m > 1e18)
    {
        cout << -1 << lin;
        return;
    }
    cout.precision(0);
    cout << fixed << m << lin;
}

int main()
{
    auto start = clock();
    fast_io;
    // freopen("test.txt", "r", stdin);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>

#define Inf             987654321
using namespace std;

typedef long long int   ll;
typedef pair<ll, ll>    pii;
typedef vector<ll>      vi;
typedef vector<vi>      vii;
/*************************************************/


int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    ll A, B, K;
    cin >> A >> B >> K;

    A -= K;
    if (A >= 0) {
        cout << A << " " << B << endl;
    }
    else {
        B += A;
        cout << 0 << " ";
        if (B >= 0)
            cout << B << endl;
        else
            cout << 0 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[205];
int main(){
	int n,l,sum=0,num1=1e9,num2=-1e9;
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		a[i]=l+i-1;sum+=a[i];
		if(a[i]>0) num1=min(num1,a[i]);
		else num2=max(num2,a[i]);

	}
	if(abs(num1)<abs(num2)) cout<<sum-num1<<endl;
	else cout<<sum-num2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    int K;
    cin >> K;
    int N = S.size();
    vector<v2ll> dp(N + 1, v2ll(10, vll(3 + 1)));
    vector<v2ll> dp2(N + 1, v2ll(10, vll(3 + 1)));
    dp[0][0][0] = 1;
    dp2[0][0][0] = 1;
    reverse(S.begin(), S.end());
    REP(i, 1, N + 1) {
        REP(j, 0, 10) {
            REP(k, 0, 4) {
                if (j != 0) {
                    if (k == 0) continue;
                    REP(l, 0, 10) {
                        dp[i][j][k] += dp[i - 1][l][k - 1];
                    }
                }
                else {
                    REP(l, 0, 10) {
                        dp[i][j][k] += dp[i - 1][l][k];
                    }
                }
            }
        }

        REP(j, 0, 10) {
            REP(k, 0, 4) {
                if (j < S[i - 1] - 0x30) {
                    if (j != 0) {
                        if (k == 0) continue;
                        REP(l, 0, 10) {
                            dp2[i][j][k] += dp[i - 1][l][k - 1];
                        }
                    }
                    else {
                        REP(l, 0, 10) {
                            dp2[i][j][k] += dp[i - 1][l][k];
                        }
                    }
                }
                else if (j == S[i - 1] - 0x30) {
                    if (j != 0) {
                        if (k == 0) continue;
                        REP(l, 0, 10) {
                            dp2[i][j][k] += dp2[i - 1][l][k - 1];
                        }
                    }
                    else {
                        REP(l, 0, 10) {
                            dp2[i][j][k] += dp2[i - 1][l][k];
                        }
                    }
                }
            }
        }
    }

    ll ans = 0;
    REP(i, 0, 10) 
        ans += dp2[N][i][K];
    //if (S[N - 1] < S[N - 2]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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



/*************** using variables **************/
int n;
vector<int> a;
/**********************************************/

// 2^20 = 10^6
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    a.resize(n);
    REP(i, n) cin >> a[i];
    
    int sum = 0; int xsum = 0;
    int ans = 0;

    for(int l = 0, r = 0; r < n; l++){
        while(1){
            if(r >= n) break;
            if(sum + a[r] != (xsum xor a[r])) break;
            sum += a[r]; xsum = (xsum xor a[r]);
            ans += r-l+1;
            r++;
        }
        sum -= a[l]; xsum = (xsum xor a[l]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int A,B,sum,sub,mul;
    cin>>A>>B;
    sum=A+B;
    mul=A*B;
    sub=A-B;
    if(sum>=mul&&sum>=sub){
        cout<<sum<<endl;

    }
    else if(mul>=sum&&mul>=sub){
            cout<<mul<<endl;
    }

    else if(sub>=sum&&sub>=mul){
            cout<<sub;

 }







    return 0;
}


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

const ll mod = 1000000007;

ll powmod(ll a, ll n, ll m){
	ll p = 1;
	while(n > 0){
		if(n & 1) p = p * a % m;
		a = a * a % m;
		n >>= 1; 
	}
	return p;
}

ll modinv(ll a, ll m){
	return powmod(a, m - 2, m);
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll x, y; cin >> x >> y;
	if((x + y) % 3 != 0) cout << 0 << endl;
	else{
		ll n, m;
		n = (2*x-y)/3; m = (2*y-x)/3;
		if(n < 0 || m < 0){
			cout << 0 << endl;
			return 0;
		}
		ll a = 1, b = 1;
		for(ll i = 1; i <= n; i++){
			b *= modinv(i, mod);
			b %= mod;
		}
		for(ll i = n + m; i > m; i--){
			a *= i;
			a %= mod;
		}
		cout << a * b % mod << endl;
	}
} 

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
import math

N, D = list(map(int, input().split()))


ans = 0

for i in range(N):
    point = list(map(int, input().split()))
    
    distance = math.sqrt(point[0]**2 + point[1]**2)
    
    if D >= distance:
        ans += 1
        
        
print(ans)
    
    

Measured memory_bytes: 9080