akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    if(n==111)cout<<999<<endl;
    if(n==119)cout<<991<<endl;
    if(n==191)cout<<919<<endl;
    if(n==199)cout<<911<<endl;
    if(n==911)cout<<199<<endl;
    if(n==919)cout<<191<<endl;
    if(n==991)cout<<119<<endl;
    if(n==999)cout<<111<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
ll ans = 1;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 1, n+1) ans = ans * i % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<memory.h>
#include<list>
#include<set>
using namespace std;

#define ll long long
#define vi vector<int>
#define vii vector<vi>
const int N = 200000 + 10;
int main() {
	long long a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ta = 4 * a;
	int tb = 2 * b;
	if (d > 2 * c || d > 2*tb || d > 2*ta || e < 2)
		d = 0;
	if (c > tb||c > ta)
		c = 0;
	if (tb > ta)
		tb = 0;
	long long res = 0;
	if (d) {
		res += (e / 2)*d;
		e -= (2*(e / 2));
	}
	if (c&&e > 0) {
		res += e*c;
	}
	else if (tb&&e > 0) {
		res += e*tb;
	}
	else if(ta && e > 0){
		res += e*ta;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        s:[i64;n],
    }
    let mut res = 0;
    for p in 1..n {
        let mut tmp = 0;
        let mut cur = 0;
        let mut i = 0;
        let mut j = n - 1;
        if (n - 1) % p == 0 {
            while i < j {
                cur += s[i] + s[j];
                tmp = max(tmp, cur);
                i += p;
                j -= p;
            }
        } else {
            while i < n - 1 && j > p {
                cur += s[i] + s[j];
                tmp = max(tmp, cur);
                i += p;
                j -= p;
            }
        }
        res = max(res, tmp);
    }
    println!("{}", res);
}


Measured memory_bytes: 3704
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int []result = new int[N];
        
        for (int i = 0; i < M; i++){
            int key = sc.nextInt();
            int value = sc.nextInt();
            
            if ((result[key-1] != 0 && result[key-1] != value) || (N >= 2 && key == 1 && value == 0)){
                System.out.println(-1);
                return;
            }
            result[key-1] = value; 
        }
            
        if (N >= 2 && result[0] == 0){
            result[0] = 1;
        }
        
        for (int i = 0; i < result.length; i++){
            System.out.print(result[i]);
        } 
        
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

#define endl "\n"

using namespace std;

template<typename T>
void printArray(T a) {
    for(auto i : a)
        cout << i << " ";

    cout << endl;
}

template<typename T>
void print2DArray(T a) {
    for(auto i : a) {
        for(auto j : i)
            cout << j << " ";

        cout << endl;
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

    unsigned long long int n = 1;
    cin >> n;

    unsigned long long int sum = 0;
    if (n == 2) {
        sum = 1;
    }
    else {
        sum = (n * (n + 1)) / 2 - n;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n = 0;
  int m = 0;
  int a[100][100];
  int b[100][1];
  int i, j;
  int sum = 0;
  
  scanf("%d %d", &n, &m);

  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++)
      scanf("%d ", &a[i][j]);
  }

  for(i = 0; i < m; i++){
    scanf("%d ", &b[0][i]);
  }
    
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++)
      sum += a[i][j] * b[j][0];

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

    sum = 0;
  }

  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	vector<int> dat(10, 0);
	rep(i, 10) { cin >> dat[i]; }
	sort(all(dat));
	rep(i, 3) { printf("%d\n", dat[9 - i]); }

	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main(void){
    int n,k,tmp,i;
    char str[10];
    scanf("%d",&n);
    scanf("%s",str);
    scanf("%d",&k);
    tmp=str[k-1];
    for(i=0;i<n;i++){
        if(str[i]!=tmp){
            str[i]='*';
        }
    }
    printf("%s",str);
    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef set<ll> Set;

typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;

int main(){
    ll n,x,y;
    cin >> n >> x >> y;
    ll a[n+10];
    rep(i,n+10) a[i]=0;
    for(ll i=2;i<x;i++){
        for(ll j=1;j<i;j++){
            a[i-j]++;
        }
    }
    for(ll i=x;i<=y;i++){
        for(ll j=1;j<i;j++){
            if(j<=x){
                ll cost=min(i-x,y-i+1)+(x-j);
                a[cost]++;
            }
            else{
                ll cost=min(i-j,y-i+1+j-x);
                a[cost]++;
            }
        }
    }
    for(ll i=y+1;i<=n;i++){
        for(ll j=1;j<i;j++){
            if(j<=x){
                ll cost=x-j+1+i-y;
                a[cost]++;
            }
            else if(y<=j){
                ll cost=i-j;
                a[cost]++;
            }
            else{
                ll cost=min(i-j,i-y+1+j-x);
                a[cost]++;
            }
        }
    }
    for(ll i=1;i<=n-1;i++){
        kaku(a[i]);
    }
    
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int tmp, N, M, C, count = 0;
	vector<int>	B;

	cin >> N >> M >> C;

	REP(i, M) {
		cin >> tmp;
		B.push_back(tmp);
	}

	REP(i, N) {
		vector<int> sources;
		REP(j, M) {
			cin >> tmp;
			sources.push_back(tmp*B[j]);
		}
		tmp = accumulate(sources.begin(), sources.end(), 0) + C;
		if (tmp > 0) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 5005

int n;
vector <int> g[MAXN];
int a[MAXN];
int d[MAXN];

int dfs(int v, int pr = -1) {
	d[v] = 0;
	for (const int& v2 : g[v]) {
		if (v2 == pr) continue;
		if (!dfs(v2, v) && a[v] > a[v2])
			d[v] = 1;
	}
	return d[v];
}


int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

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

	for (int i = 0; i < n - 1; ++i) {
		int v1, v2;
		scanf("%d%d", &v1, &v2);
		--v1, --v2;
		g[v1].pb(v2);
		g[v2].pb(v1);
	}

	vector <int> ans;
	for (int i = 0; i < n; ++i) {
		if (dfs(i)) {
			ans.pb(i);
		}
	}

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

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    string a,b;
    cin>>a>>b;
    
    int c = 0;
    rep(i,a.size()){
        c *= 10;
        c += a[i]-'0';
    }
    rep(i,b.size()){
        c *= 10;
        c += b[i]-'0';
    }
    puts(sqrt(c)==(int)sqrt(c) ? "Yes":"No");
    
    
    return 0;
}

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


int main(){
    ll N, M; cin >> N >> M;
    ll N2 = pow(2, N);
    vector<vector<ll>> DP(M+1, vector<ll>(N2));
    for(int i = 0; i < M+1; i++){
        for(int j = 0; j < N2; j++){
            if(j == 0) DP[i][j] = 0;
            else DP[i][j] = 1e9;
        }
    }
    for(int i = 1; i < M+1; i++){
        ll a, b; cin >> a >> b;
        bitset<12> C;
        for(int j = 0; j < b; j++) {
            ll c; cin >> c; c--;C.set(c);
        }
        for(int j = 0; j < N2; j++){
            bitset<12> B = j;
            ll temp = (C|B).to_ullong();
            DP[i][j] = min(DP[i-1][j], DP[i][j]); // unused
            DP[i][temp] = min(min(DP[i-1][temp], DP[i][temp]), DP[i-1][j]+a); // used
            
        }
    }
    if(DP[M][N2-1] == 1e9) cout << -1 << endl;
    else cout << DP[M][N2-1] << endl;

}


Measured memory_bytes: 32384
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    int ans = 0;
    int now = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.next());
      if(now == n){
        now = 0;
        ans++;
      }else{
        now = n;
      }
    }
      
    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:1
*Problem:Antennas on Tree
*Date:2018-2-7
*Algorithm:ZYC's Dp and my implementation :D
*Stats:Unknown*/

bool debug=false;

int n;
vector<int> nei[100005];
int dp[100005];

void dfs(int r,int p){
	int sm=0,nz=0;
	for(int i=0;i<nei[r].size();i++){
		if(nei[r][i]!=p){
			dfs(nei[r][i],r);
			sm+=dp[nei[r][i]];
			nz+=(dp[nei[r][i]]!=0);
		}
	}
	
	sm+=max(int(nei[r].size())-(p!=-1)-nz-1,0);
	dp[r]=sm;
}
int main(int argc,char* argv[]){
	scanf("%d",&n);
	if(n==2){
		cout<<1;
		return 0;
	}
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	
	int mx=0;
	for(int i=1;i<n;i++){
		if(nei[i].size()>nei[mx].size()){
			mx=i;
		}
	}
	
	dfs(mx,-1);
	
	printf("%d",dp[mx]);
	return 0;
}



Measured memory_bytes: 13824
#include<stdio.h>
int main(){
	int n,i,c;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for (i=1;i<=n;i++){
		c=1;
		for(int k=0;k<n;k++){
			printf("%d",a[k]);
			if(k==n-1){
				c=0;
			}
			if(c){
				printf(" ");
			}else{
				printf("\n");
			}
		}
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
	}

	return 0;
}

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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

using namespace std;
//#define int long long;
#define mod 1000000007
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
using namespace std;

signed main() {
  ll a;
  cin >> a;
  ll a10 = 1;
  ll a9 = 1;
  ll a8 = 1;
  if (a==2){
      cout << 2;
      return 0;
  }else if(a==1){
      cout << 0;
      return 0;
  }
  
  rep(i,a){
      a10 *= 10;
      a10 %= mod;
  }
  rep(i,a){
      a9 *= 9;
      a9 %= mod;
  }
  rep(i,a){
      a8 *= 8;
      a8 %= mod;
  }
  ll ans = a10+a8;
  ans %= mod;
  ans -= a9+a9;
  ans += mod+mod;
  ans %= mod;
 cout<< ans;

}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

long long n, a, b, k, i;
int main()
{
	cin >> n;
	while (n--) {
		scanf ("%lld %lld", &a, &b);
		k = sqrt(a * b);
		if (a != b && k * k == a * b) k--;
		if (k * (k + 1) < a * b) printf("%lld\n", k * 2 - 1);
		else printf("%lld\n", k * 2 - 2);
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i = 0; (1 << 3) > i; i++){
    int nw = s[0]-'0';
    for(int j = 0; 2 >= j; j++){
      if(i & (1<<j)){
        nw += s[j+1]-'0';
      }else{
        nw -= s[j+1]-'0';
      }
    }
    if(nw==7){
      cout << s[0] << (i & (1 << 0) ? "+":"-")<< s[1] << (i & (1 << 1) ? "+":"-")<< s[2] <<(i & (1 << 2) ? "+":"-") << s[3] << "=7" << endl;
      return 0;
    }
  }
}

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

const int N = 2e5 + 5;

int n, m, k, ans = 0;
int a[N], b[N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //   cin >> t;
    while (t--)
    {
        cin >> n >> m >> k;
        //cin >> a[0];
        for (int i = 1; i <= n; ++i)
        {
            cin >> a[i];
            a[i] += a[i - 1];
        }
        //  cin >> b[0];
        for (int i = 1; i <= m; ++i)
        {
            cin >> b[i];
            b[i] += b[i - 1];
        }
        int ans = 0;
        int idx = m;
        for (int i = 0; i <= n; ++i)
        {
            if (a[i] > k)
                break;
            while (a[i] + b[idx] > k)
                idx--;
            ans = max(ans, i + idx);
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 6688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b;
  cin >> a >> b;
  if(a>8||b>8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i=s;i<n;i++)
int main()
{
	int c[3][3];
	rep(i, 0, 3) {
		rep(j, 0, 3) {
			cin >> c[i][j];
		}
	}
	if (c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][2] - c[1][2] == c[0][1] - c[1][1] &&
		c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][2] - c[2][2] == c[1][1] - c[2][1] &&
		c[2][0] - c[0][0] == c[2][1] - c[0][1] && c[2][2] - c[0][2] == c[2][1] - c[0][1])
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MAX_V=1e3+5;
const int INF=1e9;
vector< vector<int> > board(25,vector<int>(25,0) );
int w,h;
int sy,sx,gy,gx;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int goal=100;
//Prototype
int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);


int number(string &s,int &i)
{
  int n=s[i++]-'0';
  while(isdigit(s[i])) n=n*10+s[i++]-'0';
  return n;
}

int factor(string &s,int &i)
{
  if(isdigit(s[i])) return number(s,i);
  assert(s[i]=='(');
  i++;
  int ret=expr(s,i);
  i++;
  return ret;
}
int term(string &s, int &i)
{
  int val;
  if(s[i]!='-')
    {
      val=factor(s,i);
    }
  while(s[i]=='-')
    {
      i++;
      int val2=term(s,i);
      if(val2==0) val=2;
      if(val2==1) val=1;
      if(val2==2) val=0;
    }
  return val;
}
int expr(string &s, int &i)
{
  int val=term(s,i);
  while(s[i]=='*' || s[i]=='+')
    {
      char op=s[i];
      i++;
      int val2=term(s,i);
      if(op=='*') val=min(val,val2);
      else if(op=='+') val=max(val,val2); 
    }
  return val;
}
int main(void)
{
  string s;
  while(cin >> s && s!=".")
    {
      int ans=0;
      string origin=s;
      for(int r=0;r<=2;r++)
	{
	  for(int p=0;p<=2;p++)
	    {
	      for(int q=0;q<=2;q++)
		{
		  s=origin;
		  for(int i=0;i<int(s.size());i++)
		    {
		      if(s[i]=='P') s[i]='0'+p;
		      if(s[i]=='Q') s[i]='0'+q;
		      if(s[i]=='R') s[i]='0'+r;
		    }
		  //cout << s << endl;
		  int i=0;
		  if(expr(s,i)==2) ans++;
		}
	    }
	}
      cout << ans << endl;
    }
  return 0;
 
}



Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=1e5+5;
const int M=1e9+7;
int main()
{
    int n;
    scanf("%d",&n);
    long long ans=1;
    for(int i=1;i<=n;i++)
    {
        ans=ans*i;
        ans=ans%M;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
     
    using namespace std;
    typedef long long ll;
    const int N = 2e5 + 5, MOD = 1e9+7;
     
    string s;
    int fr[27];
     
    int main(){
      	cin >> s;
      	sort(s.begin(),s.end());
      	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
          	printf("Yes");
      	else 
          	printf("No");
        return 0;
    }

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;


struct info {
	bool value;
	int count, start;
};

string to_string(string s) {
	return '"' + s + '"';
}
string to_string(const char* s) {
	return to_string((string) s);
}
string to_string(bool b) {
	return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

string to_string(info f) {
	return "(" + to_string(f.value) +
	       ", " + to_string(f.count) +
	       ", " + to_string(f.start) + ")";
}

template <typename A>
string to_string(A v) {
	bool first = true;  string res = "{";
	for (const auto &x : v) {
		if (!first) { res += ", "; }
		first = false; res += to_string(x);
	}
	res += "}";         return res;
}
void debug_out() {
	cerr << endl;
}
template <typename Head, typename ... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T ...);
}

//#define TRACE

#ifdef TRACE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
//============================================================================


void solve() {
	int i = 0, j = 0, k = 0, n = 0, m = 0, ans = 0;
	string T;
	cin >> T;
      n = sz(T);
	vector<info> v;
	T = '0' + T;
	// k = total number of 1s
	for(i = n; i > 0; ) {
		for(j = i; j > 0 and T[j] == T[i]; j--);
		if(T[i] - '0') {
			k += (i-j);
			if(i-j == 1 or (i-j)%2 == 0) {
				v.pb({1, i-j, i});
			} else {
				v.pb({1, i-j-1});
				v.pb({1, 1, i});
			}

		} else {
			v.pb({0, i - j});
		}
            i = j;
	}
	reverse(all(v));
	debug(v);
	for(auto& h: v) {
		if(h.value) {
			if(h.count % 2 == 0) continue;
			int t = (h.start & 1) + m;
			t >>= 1;
			ans += t;
		} else {
			m += h.count;
		}
	}
	int tot0 = m;
	debug(tot0, k);
	m = 0;
	for(i = sz(v) - 1; i >= 0; i--) {
		if(v[i].value) {
			if(v[i].count & 1) {
				ans += m;
			} else {
				int t = v[i].count/2 * tot0;
				ans += t;
			}
		} else {
			m += v[i].count;
		}
	}
      debug(ans);
	for(i = k; i > 0; i -= 2) ans += i;
	cout << ans << el;
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
	// cin >> T;
	for(int tc = 1; tc <= T; tc++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 9904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	double arr[n];
	for(int i=0;i<n;++i){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	double ans=arr[0]/pow(2,n-1);
	for(int i=1;i<n;++i){
		ans=ans+arr[i]/(pow(2,n-i));
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long K = sc.nextLong();
		
		
		
		if (K==1)
			System.out.println((S.charAt(0))-48);
		
		else {
			long digit = 0;
			int b = 0;
			while (digit<K){
				long a = (S.charAt(b))-48;
				
				if (a==1) {
					digit++;
					if (digit>=K)
						break;
					b++;
				}
				else {
					break;
				}
			}
			System.out.println((S.charAt(b))-48);
			
		}
	}

}


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

int main(){

    ll n,k;
    cin >> n >> k;

    ll ans=k;
    rep(i,n-1){
        ans*=k-1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count =1;
        int min = sc.nextInt();
        for(int i = 1;i<n;i++){
            int tmp = sc.nextInt();
            if(tmp<=min){
                count ++;
                min = tmp;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 58232
/*
LA3890 Most Distant Point from the Sea
题意：大海中央有一个凸n边形的小岛，求岛上离海最远的点，输出其距离
思路：
	二分答案，对于小岛的每条边，作一条相应的直线，若最后形成的半平面非空，
	那么可以满足。 
*/
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-6;
const double PI=acos(-1);

struct Point		//定义点or向量 
{
	double x,y;
	Point ( double x=0,double y=0 ) : x(x),y(y) {}
};
typedef Point Vector;		//区分点和向量，因为结构体一样 

Vector operator + ( Vector A,Vector B )
{
	return Vector( A.x+B.x,A.y+B.y );
} 

Vector operator - ( Point A,Point B )
{
	return Vector( A.x-B.x,A.y-B.y );
}

Vector operator * ( Vector A,double b )
{
	return Vector( A.x*b,A.y*b );
}

Vector operator / ( Vector A,double b )
{
	return Vector( A.x/b,A.y/b );
}

bool operator < ( const Point &a,const Point &b )
{
	return a.x<b.x || ( a.x==b.x && a.y<b.y );
}

int dcmp( double x )
{
	if ( fabs( x )<eps ) return 0;
	else return x<0 ? -1 : 1;
}

bool operator == ( const Point &a,const Point &b )
{
	return dcmp( a.x-b.x )==0 && dcmp( a.y-b.y )==0;
}

double Dot( Vector A,Vector B )		//求点积 
{
	return A.x*B.x+A.y*B.y;
}

double Length( Vector A )		//求向量的模 
{
	return sqrt( Dot( A,A ) );
}

double Cross( Vector A,Vector B )		//根据向量求叉积 
{
	return A.x*B.y-A.y*B.x;
}

Vector Normal( Vector A )		//左转九十度长度归一，注意不能是零向量
{
	double l=Length( A );
	return Vector( -A.y/l,A.x/l );
}

struct Line2		//有向直线
{
	Point P; Vector v; double ang;
	Line2() {}
	Line2( Point P,Vector v ) :P(P),v(v) {ang=atan2( v.y,v.x );}
	bool operator <( const Line2 &L ) const
	{
		return ang<L.ang;
	}
};

bool Onleft( Line2 L,Point p )		//点p在有向直线左边 
{
	return Cross( L.v,p-L.P ) >0;
}

Point GetLineIntersection( Line2 a,Line2 b )		//两直线交点 
{
	Vector u=a.P-b.P;
	double t=Cross( b.v,u )/Cross( a.v,b.v );
	return a.P+a.v*t;
}

int HalfPlaneIntersection( Line2 *L,int n,Point *poly )
{
	sort( L,L+n );
	int first,last; Point *p=new Point[n]; Line2 *q=new Line2[n];
	q[first=last=0]=L[0];
	for ( int i=1; i<n; i++ )
	{
		while ( first<last && !Onleft( L[i],p[last-1] ) ) last--;
		while ( first<last && !Onleft( L[i],p[first] ) ) first++;
		q[++last]=L[i];
		if ( fabs( Cross( q[last].v,q[last-1].v ) )<eps )
		{
			last--;
			if ( Onleft( q[last],L[i].P ) ) q[last]=L[i];
		}
		if ( first<last ) p[last-1]=GetLineIntersection( q[last-1],q[last] );
	}
	while (first<last && !Onleft( q[first],p[last-1] ) ) last--;
	if ( last-first<=1 ) return 0;
	p[last]=GetLineIntersection( q[last],q[first] );
	int m=0;
	for ( int i=first; i<=last; i++ )
		poly[m++]=p[i];
	return m;
}

Point p[210],poly[210];
Vector v[210],v2[210];
Line2 L[210];
int n;

int main()
{
	while ( scanf( "%d",&n ) && n )
	{
		int m;
		for ( int i=0,x,y; i<n; i++ )
		{
			scanf( "%d%d",&x,&y ); p[i]=Point( x,y );
		}
		
		for ( int i=0; i<n; i++ )
			v[i]=p[(i+1)%n]-p[i],v2[i]=Normal( v[i] );
		double left=0,right=20010;
		while ( dcmp( right-left) )
		{
			double mid=(left+right)/2;
			for ( int i=0; i<n; i++ )
				L[i]=Line2( p[i]+v2[i]*mid,v[i] );
			m=HalfPlaneIntersection( L,n,poly );
			if ( !m ) right=mid;
			else left=mid;
		}
		
		printf( "%.6lf\n",left );
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 62;

ll factorial(ll n,ll mod = mod){
  static ll dp[100000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

ll powl(ll x,ll r,ll mod = mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod = mod){
  return powl(x,mod-2,mod);
}

ll combination(ll n,ll m,ll mod = mod){
  if(n < m) return 0;
  return (((factorial(n)*inverse(factorial(m)))%mod)*inverse(factorial(n-m)))%mod;
}

ll n,m;
unordered_map<ll,ll> p;
ll ans = 1;

int main(){
  cin >> n >> m;
  for(ll x = 2;x <= m;x++){
    if(x*x > m){
      p[m]++;
      break;
    }
    while(m%x == 0){
      m /= x;
      p[x]++;
    }
  }
  for(auto x : p){
    ans *= ((factorial(x.second+n-1)*inverse(factorial(x.second))%mod)*inverse(factorial(n-1)))%mod;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4096
a,b,c,d=map(int,input().split())
taka_atc=c//b
if c%b>0:
    taka_atc+=1
aoki_atc=a//d
if a%d>0:
    aoki_atc+=1
if taka_atc<=aoki_atc:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9132
#include <iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int dijit;
  dijit = n%10;
  if (dijit == 3) cout << "bon" << endl;
  else if (dijit==0||dijit==1||dijit==6||dijit==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}
   

Measured memory_bytes: 3632
n = int(input())
s = list(input())
max_num = 0


def check_list_element(list):
    a = []
    for i in list:
        if i not in a:
            a.append(i)
    return a


for i in range(n):
    count = 0
    a = s[:i]
    b = s[i:]
    a = check_list_element(a)
    for j in range(len(a)):
        if a[j] in b:
            count += 1
    if count >= max_num:
        max_num = count


print(max_num)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

const int MAX=2100000;

int fac[MAX],finv[MAX],inv[MAX];
 
void t(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  repi(i,2,MAX){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
 
 
int calc(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 



signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  t();
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=0;
  ans+=calc(c+1+d+1,c+1);
  // cout<<ans<<endl;
  ans-=(calc(d+1+a,a)+MOD)%MOD;
  // cout<<ans<<endl;
  ans-=(calc(c+1+b,b)+MOD)%MOD;
  // cout<<ans<<endl;
  ans+=calc(a+b,a);
  while(ans<0) ans+=MOD;
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct SegTree {
	std::vector<int64_t> data;
	int n;
	SegTree(int n_) {
		for (n = 1; n < n_; n *= 2);
		data.resize(2 * n);
	}
	void add(int index, int64_t value) {
		for (index += n; index; index >>= 1) data[index] += value;
	}
	int64_t sum(int l, int r) {
		int64_t res = 0;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (r & 1) r--, res += data[r];
			if (l & 1) res += data[l], l++;
		}
		return res;
	}
	int bin_search() {
		int64_t big = sum(0, n);
		int index = (big + 1) / 2 - 1;
		int l = 0;
		int r = n;
		while (r - l > 1) {
			int m = l + (r - l) / 2;
			if (sum(0, m) > index) r = m; // out
			else l = m;
		}
		return l;
	}
};


struct Query {
	int type;
	int a;
	int b;
};

int main() {
	int q = ri();
	std::set<int> inserts;
	std::vector<Query> qs;
	for (int i = 0; i < q; i++) {
		int type = ri();
		if (type == 1) {
			int a = ri();
			int b = ri();
			qs.push_back({type, a, b});
			inserts.insert(a);
		} else qs.push_back({type, 0, 0});
	}
	SegTree tree(inserts.size());
	SegTree sum(inserts.size());
	std::vector<int> decomp;
	for (auto i : inserts) decomp.push_back(i);
	std::map<int, int> comp;
	for (size_t i = 0; i < decomp.size(); i++) comp[decomp[i]] = i;
	int64_t add = 0;
	int optimized = -1;
	for (int i = 0; i < q; i++) {
		if (qs[i].type == 1) { // add
			add += qs[i].b;
			tree.add(comp[qs[i].a], 1);
			sum.add(comp[qs[i].a], qs[i].a);
			optimized = tree.bin_search();
			assert(optimized >= 0 && optimized < inserts.size());
		} else {
			if (optimized == -1) std::cout << 0 << std::endl;
			else {
				int value = decomp[optimized];
				int64_t res = tree.sum(0, optimized) * value - sum.sum(0, optimized);
				res += sum.sum(optimized, inserts.size()) - tree.sum(optimized, inserts.size()) * value;
				std::cout << value << " " << res + add << std::endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 18864
#include<stdio.h>
#include<iostream>
using namespace std;
bool n[1299710]={};
int main(){
for(int i=3;i<1299710;i+=2){n[i]=true;
	for(int j=2;j*j<=i;j++)
		if(i%j==0){n[i]=false;break;}}
n[2]=true;
	int N;
while(1){
	cin>>N;if(N==0)break;
	int x=0;int y=0;int c=0;
	if(n[N]==true||N==1)c=0;
	else{
	for(int i=N;i<1299710;i++)
		if(n[i]==true){x=i;break;}
	for(int i=N;i>1;i--)
		if(n[i]==true){y=i;break;}
	c=x-y;
	
	}
	cout<<c<<endl;
}
return 0;
}

Measured memory_bytes: 2428
"""
2つの数字の積xに対して、x未満となる組み合わせの数がk未満となる
最大のxを二分探索で求める。
"""

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

inf = int(1e18) + 1
l = -inf
r = inf

while l + 1 < r:
    c = (l + r) // 2
    cnt = 0
    for i in range(n):
        if a[i] < 0:
            _l = i
            _r = n
            while _l + 1 < _r:
                _c = (_l + _r) // 2
                if a[i] * a[_c] >= c:
                    _l = _c
                else:
                    _r = _c
            if _r != n:
                cnt += (n - _r)
        else:
            _l = i
            _r = n
            while _l + 1 < _r:
                _c = (_l + _r) // 2
                if a[i] * a[_c] < c:
                    _l = _c
                else:
                    _r = _c
            if _l != i:
                cnt += _l - i
    if cnt < k:
        l = c
    else:
        r = c

print(l)

Measured memory_bytes: 104904
#include<iostream>
#include<string>
#include<cctype>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    cin>>n;
    int ans=0;
    for(int i=1;sqrt(n)*i<=n;i++)
    {
        if(n%i==0)
            ans=i;
    }
    ll a=n/ans;
    ll b=ans;
    ll na=0,nb=0;
    while(a)
    {
        na++;
        a/=10;
    }
    while(b)
    {
        nb++;
        b/=10;
    }
    cout<<max(na,nb)<<endl;
    return 0;
}



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

int main () {
    string S;
    cin >> S;
    char a=S.at(0);
    char b=S.at(1);
    char c=S.at(2);

    if (a==b && b==c) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


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

int main(){
        int n,k,i,inv=0,l=0,r=0,ans=0;
        char c;
        cin >> n >> k;
        vector<int> v(n);
        for(i=0;i<n;++i){
                cin >> c;
                v.at(i) = (int)c - 48;
        }
        if(v.at(0)==0) ++inv;
        while(r<n){
                while(inv<=2*k){
                        ++r;
                        if(r>=n) break;
                        if(v.at(r)!=v.at(r-1)) ++inv;
                }
                ans = max(ans, r-l);
                while(1){
                        ++l;
                        if(l>=n) break;
                        if(v.at(l)==1&&v.at(l-1)==0){
                                inv -= 2;
                                break;
                        }
                }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3784
N = int(input())
H = list(map(int,input().split()))
s = 0
l =[0]
for n in range(N-1):
  if H[n]>=H[n+1]:
    s += 1
    l.append(s)
  else:
    l.append(s)
    s = 0
print(max(l))

Measured memory_bytes: 14252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ld pi = 3.141592653589793;
ld a, b, h, m;
//ld ;
//string s;

int main() {
    cin >> a >> b >> h >> m;
    ld dist = (60.0 * h > 11.0 * m) ? 60.0*h - 11.0*m : 11.0*m - 60.0*h;
    ld rad = (2.0 * pi / 720.0) * (ld)dist;
    ld d2 = a*a + b*b - 2*a*b*cos(rad);
    ld d = sqrt(d2);
    cout << setprecision(20) << d << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int n;
  
  cin>>n;
  
  string str;
  
  vector<string> s;
  
  for(int i=0;i<n;i++)
  {
    cin>>str;
    
    s.push_back(str);
  }
  
  sort(s.begin(),s.end());
  
  int ans=1;
  string buf=s[0];
  
  for(int i=0;i<n;i++)
  {
	if(buf!=s[i])
    {
      ans++;
      buf=s[i];
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 11660
import Prelude
import Control.Monad
import Control.Applicative
import Data.Array
import qualified Data.Set as S

type Button = Array Int Int
type Log = S.Set Int

solver :: Button->Log->Int->Int
solver as log now |now==2 = S.size log
                     |now `S.member` log = -1
                     |otherwise = solver as (now `S.insert` log) $as!now

listButton :: [Int]->Button
listButton list = listArray (1, length list) list

main :: IO ()
main = do
	n <- readLn
	l <- replicateM n readLn
        putStrLn $ show $ solver (listButton l) S.empty 1

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

int main(void) {
    int N;
    int num = 0, buf;

    std::cin >> N;
    
    for(int i = 0; i < N; i++) {
        std::cin >> buf;
        num |= buf;
    }

    int ans = 0;
    for(;(num&1) == 0;num >>= 1, ans++);

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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int main() {
	int n;
	sd(n);
	for(int i = 1; i <= n; i++){
		sd(arr[i]);
	}
	int cnt=0;
	for(int i = 1; i <= n; i++){
		if(arr[i]==arr[i-1]){
			arr[i]=arr[i+1]-1;
			cnt++;
		}
	}
	pd(cnt);
	return 0;
}

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

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    if(m>=500){
        printf("Yes\n");
        return 0;
    }
    if(n%500==0){
        printf("Yes\n");
        return 0;
    }
    while(n>500){
        n=n-500;
    }
    if(n<=m) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

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

	int ans = 1;
	
	for (int i = 0; i < n; i++) {
		
		ans = min(ans * 2, ans + k);
		
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
    double a,b,t;
    while(~scanf("%lf %lf %lf",&a,&b,&t))
    {
        double sum=0;
        double p=a;
        while(a<=(t+0.5))
        {
            sum+=b;
            a+=p;
        }
        printf("%.0f\n",sum);
    }
    return 0;
}


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

int intpow10(int exp) {
  return exp == 0 ? 1 : 10 * intpow10(exp - 1);
}

int intlog10(int alog) {
  int d = alog / 10;
  return d == 0 ? 0 : 1 + intlog10(d);
}

int main() {
  int N, K;
  cin >> N >> K;
  int D[K];
  rep(i,K) cin >> D[i];
  while (true) {
    int i = N;
    int d = intlog10(N);
    while (d >= 0) {
      bool f = false;
      rep(j,K) {
        if (i / intpow10(d) == D[j]) {
          f = true;
          break;
        }
      }
      if (f) break;
      i %= intpow10(d--);
    }
    if (d < 0) {
      cout << N << endl;
      return 0;
    }
    N++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int A, B ; cin >> A >> B;
    string S; cin >> S;
    bool flag = true;
    rep(i, 0, S.size()){
        if(i != A) if('0' > S[i] || '9' < S[i]) flag = false;
        if(i == A) if(S[i] != '-') flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

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

	int Z=(int)'Z';
	string ans="";
	rep(i,S.length()){
		if(N+S[i]>Z){
			ans+=(char)(N+S[i]-26);
		}else{
			ans+=(char)(N+S[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  while (n--) {
    double x1, y1, x2, y2, x3, y3, px, py, r;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    px = ((y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2) - (y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3)) / (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3));
    py = ((x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) - (x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3)) / (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3));
    r = sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));
    cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
  }
}


Measured memory_bytes: 3208
#include <iostream>

int main()
{
    int i, j;
    scanf("%d %d", &i, &j);
    while (true)
    {
        if (i > j) i = i % j;
        else j = j % i;
        if (i == 0 || j == 0) break;
    }
    printf("%d\n", i+j);
}


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

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int N; string S;

int func(string S1, string S2){
    int ans =0;
    map<char,int> L{};
    map<char,int> R{};
    for(int i=0;i<S1.size();i++) L[S1[i]]=1;
    for(int i=0;i<S2.size();i++) R[S2[i]]=1;
    for(auto i=L.begin(); i!=L.end(); i++){
        char key = i ->first;
        ans += L[key]*R[key];
    }
    return ans;
}

int main() {
    cin >> N; cin >> S;
    int ans = 0;
    int len = S.size();
    for(int i=1;i<len-1; i++){
        int n = func(S.substr(0,i), S.substr(i,len-i));
        if(n > ans) ans = n;
    }
    cout << ans << endl;
}


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

int main() {
int N;
int y =0;
cin>>N; 
vector<string>vec(N);
for(int i=0;i<N;i++){
cin>>vec.at(i);
  if(vec.at(i)=="Y"){
  y=1;
  break;
  }
}//for
 
if(y==1)
cout<<"Four"<<endl;
else
cout<<"Three"<<endl;
}//main

Measured memory_bytes: 256