akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i--)
#define F first
#define S second
int main()
{    
    
   string s,t;
   cin>>s>>t;
   ll a,b;
   cin>>a>>b;
   string c;
   cin>>c;
   if(c==s){a--;}
   else{b--;}
   cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

ll binary_method(ll a,ll b){
    if(b==0) return (ll)1;
    ll temp = binary_method(a,b>>1);
    if(b%2){
        return (((temp*temp)%mod)*a)%mod;
    } else{
        return (temp*temp)%mod;
    }
}

int main(){
    string L;
    cin>>L;
    ll N = L.size();
    ll ans = 0;
    ll one_count=0;
    rep(i,N){
        if(L[i]=='0') continue;
        else{
            ans = (ans + binary_method(2,one_count)*binary_method(3,N-1-i))%mod;
            one_count++;
        }
    }
    ans = (ans + binary_method(2,one_count))%mod;
    cout<<ans<<endl;
    return 0;
}

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

// a>b
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a%b);
}

int main()
{
	int p, q;
	cin >> p >> q;
	
	q /= gcd(p, q);
	int ans = 1;
	for (int i = 2; i*i <= q; i++) {
		if (q%i == 0) {
			ans *= i;
			while (q%i == 0) q /= i;
		}
	}

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

Measured memory_bytes: 3088
N, K = map(int, input().split())
P = 10**9+7
R = int(N**0.5)+1
A = [i for i in range(R)] + [N//i for i in range(1, R)][::-1]
M = len(A)
X = [0] + [1] * (M-1)
for i in range(1, K+1):
    NX = [0] * M
    for j in range(1, M):
        NX[j] = (NX[j-1] + X[M-j]*(A[j]-A[j-1])) % P
    X = NX
print(X[-1])

Measured memory_bytes: 55916
import java.util.Scanner;

public class Main {
	static final int MAX_LENGTH = 150;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h + w == 0)
				break;
			int min = Integer.MAX_VALUE;
			int root = h * h + w * w;
			int min_h = 0;
			int min_w = 0;
			for (int i = 1; i <= MAX_LENGTH; i++) {
				for (int j = i + 1; j <= MAX_LENGTH; j++) {
					if (root < i * i + j * j || (root == i * i + j * j && i > h)) {
						if (min > i * i + j * j || (root == i * i + j * j && i < min_h)) {
							min = Math.min(min, i * i + j * j);
							min_h = i;
							min_w = j;
						}
					}
				}
			}
			System.out.println(min_h + " " + min_w);
		}
	}

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

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

int main() {
  int n;
  cin >> n;
  map<int64_t, int64_t> m;
  int64_t sum = 0;
  m[sum]++;

  int64_t res = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    sum += x;
    res += m[sum];
    m[sum]++;
  }

  cout << res << endl;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main(){
    int n, p;
    cin >> n >> p;
    while(n || p){
        ll m = p, idx = 0;
        vector<ll> stone(n);
        for(;;){
            if(m > 0){
                m--;
                stone[idx]++;
            }
            else if(stone[idx] < p){
                m = stone[idx];
                stone[idx] = 0;
            }
            else{
                cout << idx << endl;
                break;
            }
            idx++;
            idx %= n;
        }
        
        cin >> n >> p;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#endif

int main() {
    ll N;
    cin >> N;
    if (N == 1) {
        PR(0);
        return 0;
    }

    ll all   = 1;
    ll not9  = 1;
    ll not09 = 1;
    for (ll i = 0; i < N; ++i) {
        all *= 10;
        all %= MOD;
        not9 *= 9;
        not9 %= MOD;
        not09 *= 8;
        not09 %= MOD;
    }

    ll not9_0 = (not9 * 2) % MOD;
    ll ans    = (all + not09) % MOD;
    ans -= not9_0;
    ans %= MOD;
    if (ans < 0) {
        ans += MOD;
    }

    PR(ans);
}

Measured memory_bytes: 3568
#include <bits/stdc++.h> 
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std; 
int main() 
{ 
    int c=0;
	string s ;
	cin>>s;
	 
  
    
	   if(s[1]=='R')
	   {
	   
	  
       cout<<"ABC"<<endl;
   }
   
   else 
	   cout<<"ARC"<<endl;
	return 0; 
} 


Measured memory_bytes: 3548
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static int[] t;
    static int[] x;
    static int[] y;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        PriorityQueue<Point> points = new PriorityQueue<>(Comparator.comparingInt(x -> x.t));
        for (int i = 0; i < n; i++) {
            points.add(new Point(scan.nextInt(), scan.nextInt(), scan.nextInt()));
        }
        Point c = new Point(0, 0, 0);
        while (!points.isEmpty()) {
            Point next = points.poll();
            int dis = Math.abs(c.x - next.x) + Math.abs(c.y - next.y);
            int time = next.t  -c.t;
            if (dis > time || Math.abs(dis - time) % 2 == 1) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

    static class Point {
        int t;
        int x;
        int y;

        public Point(int t, int x, int y) {
            this.t = t;
            this.x = x;
            this.y = y;
        }
    }
}



Measured memory_bytes: 93216
N = int(input())

count = 0


def calc(n, n3, n5, n7):
    global count
    if n > N:
        return
    if 1 <= n <= N and n3 and n5 and n7:
        count += 1
    calc(10 * n + 3, 1, n5, n7)
    calc(10 * n + 5, n3, 1, n7)
    calc(10 * n + 7, n3, n5, 1)


calc(0, 0, 0, 0)
print(count)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
#define mod 1000000007
/****************************/
using namespace std;
int n,m;
int main()
{
	cin>>n;
	if(n==0) cout<<"1";
	else cout<<"0";
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m1 = Integer.parseInt(sc.next());
        int m2 = Integer.parseInt(sc.next());
        int d1 = Integer.parseInt(sc.next());
        int d2 = Integer.parseInt(sc.next());

        if (d2 == 1) {
            System.out.println("1");
        } else {
            System.out.println("0");
        }
    }
}


Measured memory_bytes: 35604
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i=0;i<N; i++)
        cin >> X.at(i);
    vector<int> P(101);
    for (int i = 1; i<=100; i++){
        for(int j=0; j<N; j++){
            P.at(i)+=(X.at(j)-i)*(X.at(j)-i);
        }
    }
    int min = P.at(1);
    for (int i=2; i<=100; i++){
        if(P.at(i)<min)
            min = P.at(i);
    }
    cout << min;
}

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

ac=0
wa=0
tle=0
re=0
for i in range(n):
    s = input()
    if s == "AC":
        ac+=1
    elif s=="WA":
        wa+=1
    elif s=="TLE":
        tle+=1
    elif s=="RE":
        re+=1

print("AC x %d" %ac)
print("WA x %d" %wa)
print("TLE x %d" %tle)
print("RE x %d" %re)

Measured memory_bytes: 9204
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  string s;
  cin>>s;
  int n=s.length();
  int ans=0;
  rep(i,0,n-1)
  {
    int start=i;
    char ch=s[start];
    while(start<n && s[start]==ch)
    start++;

    if(ch=='R')
    ans=max(ans,start-i);
  }
  cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double PI=acos(-1.0);
#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(Point p) {return Point(x*p.x-y*p.y,x*p.y+y*p.x);}
    Point operator*(double k){return Point(x*k,y*k);}
    Point operator/(double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}
    double arg(){return atan2(y,x);}
    double dot(Point p){return x*p.x+y*p.y;}
    double det(Point p){return x*p.y-y*p.x;}
};
int n;
void f(int cnt,Point l,Point r){
    if(cnt==n) return;
    Point ml=(l*2+r)/3,mr=(r*2+l)/3;
    Point mm=ml+(mr-ml)*Point(cos(PI/3.0),sin(PI/3.0));
    f(cnt+1,l,ml);
    cout<<ml.x<<" "<<ml.y<<endl;
    f(cnt+1,ml,mm);
    cout<<mm.x<<" "<<mm.y<<endl;
    f(cnt+1,mm,mr);
    cout<<mr.x<<" "<<mr.y<<endl;
    f(cnt+1,mr,r);
}
int main(){
    cin>>n;
    Point l(0.0,0.0),r(100.0,0.0);
    cout<<fixed<<setprecision(12);
    cout<<l.x<<" "<<l.y<<endl;
    f(0,l,r);
    cout<<r.x<<" "<<r.y<<endl;
    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 1<<21
typedef long long int ll;
int dp[N];
int rel[21][21];
void self(int a,int b)
{
    dp[a]+=b;
    if(dp[a]>=M)
        dp[a]-=M;
    return ;
}
int onbit(int x)
{
    int c=0;
    while(x>0)
        c+=(1&x),x/=2;
    return c;
}
int main()
{
    int n,i,j,a,c;
    in(n);
    rep(i,n)
    {
        rep(j,n)
            in(rel[i][j]);
    }
    dp[0]=1;
    int mask;
    for(mask=0;mask<(1<<n);mask++)
    {
        if(dp[mask]>0)
        {
            c=onbit(mask);
            rep(i,n)
            {
                if((1&(mask>>i))==0 && rel[c][i])
                {
                    a=((1<<i)|mask);
                    self(a,dp[mask]);
                }
            }
        }
    }
    mask=(1<<n)-1;
    out(dp[mask]);
}





Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    char c;cin>>c;
    if('a'<=c and c<='z') cout<<"a"<<endl;
    else cout<<"A"<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    ll n, r, b;
    cin >> n >> b >> r;
    if (b == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << n/(b+r)*b+min(n%(b+r), b);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
s = list(S)

a = int(s[0] + s[1])
b = int(s[2] + s[3])

YYMM = 0
MMYY = 0

if (a >= 1) & (a <= 12):
    MMYY += 1

if (b >= 1) & (b <= 12):
    YYMM += 1

if (YYMM == 1) & (MMYY == 1):
    print('AMBIGUOUS')
elif (YYMM == 0) & (MMYY == 0):
    print('NA')
if (YYMM == 1) & (MMYY == 0):
    print('YYMM')
if (YYMM == 0) & (MMYY == 1):
    print('MMYY')




Measured memory_bytes: 3064
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

# n = int(input())
h, n = map(int, input().split())
# a = list(map(int, input().split()))
a, b = [0] * n, [0] * n

for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = [10**9+7] * (h+1)
dp[0] = 0

for i in range(n):

    for j in range(h):

        dp[min(j+a[i], h)] = min(dp[min(j+a[i],h)], dp[j]+b[i])


print(dp[h])

Measured memory_bytes: 41964
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cmath>
#include<string>

using namespace std;

#define maxn l005
#define ll long long

int main() {
	string o;
	string e;
	cin >> o >> e;
	int len = min(o.size(), e.size());
	for (int i = 0; i < len; i++)
		cout << o[i] << e[i];
	if (o.size() > len) cout << o[len];
	if (e.size() > len) cout << e[len];
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int w,h;
	for(;;){
		std::cin >> h>>w;
		if(w==0)exit(0);
		rep(i,w)std::cout << "#" ;
		std::cout << std::endl;
		rep(i,h-2){
			std::cout << "#" ;
			rep(j,w-2){
				std::cout << ".";
			}
			std::cout << "#" ;
			std::cout << std::endl;
		}
		rep(i,w)std::cout << "#" ;
		std::cout << std::endl;
		std::cout << std::endl;
	}
}


Measured memory_bytes: 3008
#include <iostream>
#include <string>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int N;
 	string a;
 	cin >> a;
 	for (int i = 0; i < 4; i++) {
 		if(a.substr(i,1)=="+"){
 			N++;
 		}else{
 			N--;
 		}
 	}
 	cout << N << endl;
 }

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <map>
#include <math.h>
#include <set>
#include <vector>
#define ll long long
const int INF = 0x3f3f3f3f;
const int NINF = -INF - 1;
const int mod=1e9+7;
const int N=1e5+5;
using namespace std;
int a[4];
int vis[4];
int vi[4][10];
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        if(x==1&&y==0&&n!=1) {printf("-1\n");return 0;}
        if(!vis[x])
        {
         vis[x]=1;vi[x][y]=1;a[x]=y;
        }
        else
        {
            if(vi[x][y]==1) a[x]=y;
            else {printf("-1\n");return 0;}
        }
    }
    if(a[1]==0&&n!=1) a[1]=1;
    for(int i=1;i<=n;i++) printf("%d",a[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt(); // N匹のスライム
		String S = next(); // スライムの色情報
		char[] C = S.toCharArray();
		int cnt = 1;
		if(N == 1) {
			out.println(cnt);
			return;
		}
		for(int i=1;i<N;i++) {
			if(C[i-1]!=C[i])cnt++;
		}

		out.println(cnt);
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 27604
use std::io;
use std::cmp;

fn main() {
    let x = read_one::<usize>();

    if x == 1 {
        println!("1");
    } else {
        let mut max = 0;

        for i in 2..32 {
            let b = i;
            let mut p = 2;
            let mut c = b;
            while c <= x {
                c = i.pow(p);
                if c <= x {
                    max = cmp::max(max, c);
                }
                p += 1;
            }
        }
        println!("{}", max);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;

int dfs(int v, int i, vector<int> &a) {
  if (i == a.size()) {
    return (v % 2 == 0);
  }
  int x = dfs(v * (a[i] - 1), i + 1, a);
  int y = dfs(v * a[i], i + 1, a);
  int z = dfs(v * (a[i] + 1), i + 1, a);
  return x + y + z;
}

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

  cout << dfs(1, 0, a) << endl;

  return 0;
}

Measured memory_bytes: 256
n,m = list(map(int,input().split()))

data = [int(s) for s in input().split()]
data.sort()
l = []
if n >= m:
    print(0)
else:
    for i in range(m-1):
        l.append(data[i+1]-data[i])
    l.sort(reverse = True)

    x = 0
    for i in range(n-1):
        x += l[i]
    print(data[m-1] - data[0] - x)


Measured memory_bytes: 13840
from statistics import median, mean

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

INF = float('inf')
res = INF
for a in range(min(X), max(X)+1):
  tmp = 0
  for x in X:
    tmp += (x-a) * (x-a)
  res = min(tmp, res)
  
print(res)

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

int main() {
	uint32_t A, B, C, D;
	cin >> A >> B >> C >> D;

	cout <<
		((uint32_t)((C + B - 1) / B) <= (uint32_t)((A + D - 1) / D) ? "Yes\n":"No\n");
	return 0;
}



Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,M;
    cin >> N >> M;
    pint A[M];
    rep(i,M) cin >> A[i].second >> A[i].first;
    int bridge=1,ans=0;
    sort(A,A+M);
    rep(i,M){
        if(A[i].second>=bridge) ans++,bridge=A[i].first;
    }
    cout << ans << endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a == b && b != c) cout << c << endl;
    else if(a == c && c != b) cout << b << endl;
    if(c == b && b != a) cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var s = o.l().sort((a,b)=>b-a);
  var dp = Array(x+1).fill(0);
  dp[x] = 1;
  for(var i = 0; i < n; i++){
    var dp2 = Array(x+1).fill(0);
    for(var j = 0; j <= x; j++){
      dp2[j] += dp[j] * (n-i-1);
      dp2[j] %= mod;
      var m = j % s[i];
      dp2[m] += dp[j];
      dp2[m] %= mod;
    }
    dp = dp2;
  }
  var ans = 0;
  for(i = 0; i < s[n-1]; i++){
    ans += abmod(i,dp[i]);
  }
  return ans % mod;
}

Measured memory_bytes: 42004
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;

using namespace std;
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;
}

cpp_int M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	cpp_int ans=1;
	bool zero=false;
	vector<cpp_int>a(n);
	rep(i,n){
		cin>>a[i];
		if(a[i]==0){
			zero=true;
			cout<<0<<endl;
			return ;
		}
	}
	rep(i,n){
		ans*=a[i];
		if(ans>(cpp_int)1e18){
			cout<<-1<<endl;
			return ;
		}
	}
		if(ans>(cpp_int)1e18){
			cout<<-1<<endl;
			return ;
		}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;

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

  int n, m;
  cin >> n >> m;
  
  int mm = 4 * m;

  int *a = new int[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  double min = ((double)sum) / mm;

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < min) {
    }
    else {
      cnt++;
    }
  }

  cout << ((cnt >= m) ? "Yes" : "No");

  delete[] a;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

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

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int N, M;

#define MAX_V 1000000
typedef int DistanceT;
const DistanceT DIST_INF = numeric_limits<DistanceT>::max() / 2;
struct edge {int to; DistanceT cost; };
typedef pair<DistanceT, int> P; // (minimum distance, vertex id)

vector<edge> G[MAX_V];
DistanceT d[MAX_V];

// O((|V|+|E|)log|V|)
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + MAX_V, DIST_INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        // can't 'relax
        if (d[v] < p.first) {
            continue;
        }
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            // relax
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(int argc, char const* argv[])
{
    cin >> N >> M;
    REP(i, M) {
        int a, b; cin >> a >> b;
        G[a].PB(edge{b, 1});
        G[b].PB(edge{a, 1});
    }
    dijkstra(1);
    if (d[N] == 2) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


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

int main(){
  int a,b;
  int num=0;
  cin>>a>>b;
  int c=b-a+1;
  for(int i=0;i<c;i++){
    std::string x=std::to_string(a);
    if(x.at(0)==x.at(4)&&x.at(1)==x.at(3)){
      num++;
    }
    a++;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        sc.close();

        int odd = 0;

        for (int i = 1; i <= N; i++) {

            if(!(i % 2 == 0)) {

                odd++;
            }
        }

        double ans = (double)odd/(double)N;

        BigDecimal ansBig = new BigDecimal(ans);
        ansBig.setScale(6, RoundingMode.HALF_UP);

        System.out.print(decimalToString10(ansBig));

    }

    public static String decimalToString10(BigDecimal big) {

        DecimalFormat format = new DecimalFormat("#.#");

        // 小数点以下の最小値
        format.setMinimumFractionDigits(10);
        // 小数点以下の最大値
        format.setMaximumFractionDigits(10);

        return format.format(big);
    }

}

Measured memory_bytes: 21972
def dice():
    import random as ran

    dnum = list(map(int,input().split()))
    dcnum = list(map(int,input().split()))


    up = dnum[0]
    un = dnum[5]
    ri = dnum[2]
    le = dnum[3]
    fr = dnum[1]
    ba = dnum[4]
    tmp = int(0)
    tmp2 = int(0)
    order = ["S","N","E","W"]
    count = int(0)

    while count <= 1000  :
        x = ran.choice(order)
        if (x == "S"):
            tmp = fr
            tmp2 = un
            fr = up
            up = ba
            un = tmp
            ba = tmp2

        elif (x == "N"):
            tmp = un
            tmp2 = up
            up = fr
            un = ba
            fr = tmp
            ba = tmp2

        elif (x == "E"):
            tmp = up
            tmp2 = un
            up = le
            un = ri
            ri = tmp
            le = tmp2

        elif (x == "W"):
            tmp = un
            tmp2 = up
            up = ri
            un = le
            ri = tmp
            le = tmp2

        if (up == dcnum[0] and un == dcnum[5] and ri == dcnum[2] and le == dcnum[3] and fr == dcnum[1] and ba == dcnum[4]):
            print("Yes")
            break

        if (count == 1000):
            print("No")

        count += 1
dice()



Measured memory_bytes: 8184
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  vector<string> ss;
  map<string,bool> exist;
  string cs="";
  int len=s.size();
  REP(i,len){
    for(int j=0;j<min(k,len-i);j++){
      for(int r=0;r<=j;r++){
        cs += s[i+r];
      }
      if(exist[cs]){
        cs = "";
        continue;
      }else{
        exist[cs]=true;
        ss.push_back(cs);
        cs = "";
      }
    }
  }
  sort(ss.begin(),ss.end());
  cout<<ss[k-1]<<endl;
  return 0;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    map<char,vector<int>> mp;
    rep(i,n) mp[s[i]].push_back(i);
    rep(i,m) if(mp[t[i]].empty()){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    int now = -1;
    rep(i,m){
        char c = t[i];
        int idx = upper_bound(mp[c].begin(), mp[c].end(), now) - mp[c].begin();
        if(idx == mp[c].size()){
            ans += n - now + mp[c][0];
            now = mp[c][0];
        }
        else{
            ans += mp[c][idx] - now;
            now = mp[c][idx];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4252
program sample
implicit none
integer(8) N,A(200000),B(200000),i
read(*,*) N
read(*,*) (A(i),i=2,N)
do i=2,N
B(A(i))=B(A(i))+1
end do
do i=1,N
write(*,'(i0)') B(i)
end do

stop
end program sample

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


// Larsson-Sadakane's Suffix array Construction: O(n (log n)^2)
struct SAComp {
  const int h, *g;
  SAComp(int h, int* g) : h(h), g(g) {}
  bool operator() (int a, int b) {
    return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
  }
};
int *buildSA(char* t, int n) {
  int g[n+1], b[n+1], *v = new int[n+1];
  REP(i,n+1) v[i] = i, g[i] = t[i];
  b[0] = 0; b[n] = 0;

  sort(v, v+n+1, SAComp(0, g));
  for(int h = 1; b[n] != n ; h *= 2) {
    SAComp comp(h, g);
    sort(v, v+n+1, comp);
    REP(i, n) b[i+1] = b[i] + comp(v[i], v[i+1]);
    REP(i, n+1) g[v[i]] = b[i];
  }
  return v;
}

// call RMQ = buildRMQ(lcp, n+1)
int *buildRMQ(int *a, int n) {
  int logn = 1;
  for (int k = 1; k < n; k *= 2) ++logn;
  int *r = new int[n * logn];
  int *b = r; copy(a, a+n, b);
  for (int k = 1; k < n; k *= 2) {
    copy(b, b+n, b+n); b += n;
    REP(i, n-k) b[i] = min(b[i], b[i+k]);
  }
  return r;
}
// inner LCP computation with RMQ: O(1)
int minimum(int x, int y, int *rmq, int n) {
  int z = y - x, k = 0, e = 1, s; // y - x >= e = 2^k ???????????§ k
  s = ( (z & 0xffff0000) != 0 ) << 4; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x0000ff00) != 0 ) << 3; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x000000f0) != 0 ) << 2; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x0000000c) != 0 ) << 1; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x00000002) != 0 ) << 0; z >>= s; e <<= s; k |= s;
  return min( rmq[x+n*k], rmq[y+n*k-e+1] );
}

// Naive matching O(m log n)
int find(char *t, int n, char *p, int m, int *sa,int *rmq) {
  int a = 0, b = n;
  while (a < b) {
    int c = (a + b) / 2;
    if (strncmp(t+sa[c], p, m) < 0) a = c+1; else b = c;
  }
  int l = a;
  a = 0, b = n;
  while (a < b) {
    int c = (a + b+1) / 2;
    if (strncmp(t+sa[c], p, m) <= 0) a = c; else b = c-1;
  }
  int r = a;
  if( strncmp(t+sa[l],p,m) != 0 ) return -1;
  if( l > r ) return -1;
  else {
  	return minimum(l,r,rmq,n+1);
  }
}


char str[200010];
char str_r[200010];

char a[200010],b[200010];
int main(){
	cin >> str;

	int m;
	cin >> m;

	int n = strlen(str);
	int *sa = buildSA(str,n);
	int *rmq2 = buildRMQ(sa, n+1);
	
	strcpy(str_r,str);
	reverse(str_r,str_r+n);
	int *sa_r = buildSA(str_r,n);
	int *rmq2_r = buildRMQ(sa_r, n+1);

	for(int i = 0 ; i < m ; i++){
		cin >> a >> b;
		int A = strlen(a);
		int B = strlen(b);
		reverse(b,b+B);
		int p1 = find(str,n,a,A,sa,rmq2);
		int p2 = find(str_r,n,b,B,sa_r,rmq2_r);
		//cout << p2 << 
		if( p1 == -1 || p2 == -1 ){
			cout << 0 << endl;
		}else{
			p2 = n - p2 - 1;
			if( p2 < p1 || p1 + A > p2 + B ){
				cout << 0 << endl;
			}else{
				cout << p2 - p1 + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 36496
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int main()
{
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(6);

	int n, t, l, b;
	while (cin >> n >> t >> l >> b, n)
	{
		bool lose[128], back[128];
		static double dp[128][128];
		CL(lose, 0);
		CL(back, 0);
		CL(dp, 0);
		for (int a; l--; )
			cin >> a, lose[a] = true;
		for (int a; b--; )
			cin >> a, back[a] = true;

		dp[0][0] = 1;
		for (int i = 0; i < t; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				for (int k = 1; k <= 6; ++k)
				{
					int to = j + k, turn = i + 1;
					if (to > n)
						to = n - (to - n);

					if (lose[to])
						++turn;
					else if (back[to])
						to = 0;

					dp[turn][to] += dp[i][j] / 6;
				}
			}
		}
		double res = 0;
		for (int i = 0; i <= t; ++i)
			res += dp[i][n];

		cout << res << endl;
	}
}

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

int main(){
  int n,x;
  cin >> n >> x;
  int d=0;
  int ans=1;
  int l;
  for(int i=0; i<n; i++){
    cin >> l;
    d = d + l;
    if(d>x){break;}
    ans = i + 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
 
#define SENTINEL (1000000001)
#define putChar(c) ; *p = (char)(c); ++p;
 
int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500010];
char *p = str;
 
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    } 
    ++p;
    return n;
}
 
void putNum(int n) {
    int d;
    if (n < 10) {
        putChar( '0' + n );
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    putChar( '0' + (n % 10) );
}
 
void Merge(int A[], int left, int mid, int right) {
    int i = 0, j = 0, k = left;
    int n1 = mid - left;
    int n2 = right - mid;
    memcpy(L, A + left, n1 * sizeof(int));
    memcpy(R, A + mid, n2 * sizeof(int));
    L[n1] = R[n2] = SENTINEL;
    for (; k < right; ++k) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
        } else {
            A[k] = R[j];
            ++j;
        }
    }
}
 
void MergeSort(int A[], int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) >> 1;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
        c += right - left;
    }
}
 
int main(void) {
    register int i;
    int n;
     
    fread(str, 1, 5500000, stdin);
    n = getNum();
    for (i = 0; i < n; ++i) {
        S[i] = getNum();
    }
     
    MergeSort(S, 0, n);
     
    --n;
    p = str;
    for (i = 0; i < n; ++i) {
        putNum(S[i]);
        putChar( ' ' );
    }
    putNum(S[i]);
    putChar( '\n' );
     
    putNum(c);
    putChar( '\0' );
     
    puts(str);
 
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(3));
  vector<vector<int>> dp(n+1,vector<int>(3));
  rep(i,n){
    rep(j,3) cin>>a[i][j];
  }
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j==k) continue;
        maxs(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  int ans=0;
  rep(i,3){
    maxs(ans,dp[n][i]);
  }
  cout<<ans<<endl;
}    


Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t begin = clock();
	string s;
	cin >> s;
	s = "$" + s;
	int n = s.size();
	vector<vector<int>>dp(n + 2, vector<int>(2, 0));
	for (int i = 0; i < n ; i++) {
		if (s[i] != s[i + 1]) {
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + 1);
		}
		dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + 1);
		dp[i + 2][1] = max(dp[i + 2][1], 1 + dp[i][0]);
	}
	cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
	clock_t end = clock();
	cerr << "Time run: " << (float)(end - begin) / CLOCKS_PER_SEC << " s" << endl;
}

Measured memory_bytes: 14560
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

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

using namespace std;

typedef long long ll;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n; cin >> n;
  vector<ll> a(n), b(n);

  rep(i, n) { cin >> a[i]; }
  rep(i, n) { cin >> b[i]; }

  ll need_dec = 0;
  ll extra = 0;

  rep(i, n) {
    if (a[i] > b[i]) {
      need_dec += a[i] - b[i];
    } else {
      extra += (b[i]-a[i]) / 2;
    }
  }

  cout << ( need_dec <= extra ? "Yes" : "No" ) << endl;

  return 0;
}

Measured memory_bytes: 384
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define N (4)

void solve_main()
{
	string inputS;

	cin >> inputS;

	REP(i, 1, N) {
		if (inputS[i] == inputS[i - 1]) {
			cout << "Bad" << endl;
			return;
		}
	}

	cout << "Good" << endl;
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 256
n,m  = list(map(int,input().split(" ")))
data = []
for i in range(m):
  p,y  = list(map(int,input().split(" ")))
  data.append((i,p,y))
data = sorted(data, key = lambda x:(x[1],x[2]))
ans = []
now_i = 0
now_p = 0
for d in data:
  i,p,y = d
  if(now_p != p):
    now_p = p
    now_i = 1
  else:
    now_i += 1
  ans.append((i,str(p).zfill(6)+str(now_i).zfill(6)))
ans = sorted(ans,key = lambda x:x[0])
for (i,t) in ans:
  print(t)


Measured memory_bytes: 36316