akhauriyash/Code-Regression huggingface dataset:
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;


int x[50];

int main(){
ll dptable[51][51][2501];
int n,a;

	cin >> n >> a;


	for (int i=0;i<n;i++){
		cin >> x[i+1];
	}


	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

	for (int k=1;k<=n;k++){
		ans += dptable[n][k][k*a];
	}

	cout << ans << endl;
}

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

long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}

int main(){
  long long n, m; cin >> n >> m;
  string s, t; cin >> s >> t;
  long long ans = n * m / gcd(n, m);
  long long c = ans / m;
  long long d = ans / n;
  long long i1 = 0;
  while (i1 < ans) {
    if (i1 % d == 0) {
      if (s[i1/d] != t[i1/c]) {
        cout << -1 << endl;
        return 0;
      }
    }
    i1 += c;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;

	int l = n / 2;
	if (n % 2 == 0) {

		if (s.substr(0, l) == s.substr(l, n)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}

	}
	else {
		cout << "No" << endl;
	}
}



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

constexpr int64_t MOD = 1e9 + 7;
constexpr int64_t SIZE = 1e6;

array<int64_t, SIZE+10> fac, ifac;

int64_t modpow(int64_t x, int64_t n, int64_t m = 1) {
    return n == 0 ? m : modpow(x * x % MOD, n >> 1, n & 1 ? m * x % MOD : m);
}

int64_t comb(int64_t n, int64_t k) {
    return n == 0 && k == 0 ? 1
        : n < k || n < 0 ? 0
        : fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
}

int main() {
    fac[0] = ifac[0] = 1;
    for (int64_t i = 0; i+1 < SIZE + 10; i++) {
        fac[i+1] = fac[i] * (i+1) % MOD;
        ifac[i+1] = ifac[i] * modpow(i+1, MOD-2) % MOD;
    }

    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> a(n);
    for (auto& e : a) cin >> e;
    sort(begin(a), end(a));

    int64_t ans = a[k-1];
    for (int i = 1; i+k <= n; i++) {
        ans += a[i+k-1] * comb(i+k-1, k-1);
        ans %= MOD;
    }

    reverse(begin(a), end(a));
    ans -= a[k-1];
    for (int i = 1; i+k <= n; i++) {
        ans -= a[i+k-1] * comb(i+k-1, k-1);
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
typedef pair<int,int> P;
struct edge{int to, cost; };
int n;
vector< edge > g[114514];
int d[114514];
void dijkstra( int s ){
	priority_queue< P, vector<P>, greater<P> > que;
	for(int i=0;i<=n;i++){
		d[i] = LINF;
	}
	d[s] = 0;
	que.push( P(0,s) );
	while( !que.empty() ){
		P p = que.top(); que.pop();
		int v = p.second;
		if( d[v] < p.first ) continue;
		for(int i=0;i<g[v].size();i++){
			edge e = g[v][i];
			if( d[e.to] > d[v] + e.cost ){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
signed main(){
	int h,w;
	cin>>h>>w;
	n = h*w;
	vector< string > fi(h) ;
	for(int i=0;i<h;i++){
		cin>>fi[i];
	}
	int okc = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if( fi[i][j] == '.' ){
				okc ++ ;
				int cur = i*w+j;
				if( i != 0 && fi[i-1][j] == '.' ) g[cur].pb( (edge){ cur-w, 1 } );
				if( i != h-1 && fi[i+1][j] == '.' ) g[cur].pb( (edge){ cur + w, 1 }  );
				if( j != 0 && fi[i][j-1] == '.' ) g[cur].pb( (edge){ cur -1, 1} );
				if( j != w-1 && fi[i][j+1] == '.' ) g[cur].pb( (edge){ cur +1, 1} );
			}
		}
	}
	dijkstra(0);
	int ans = okc - d[ h*w-1 ] - 1;
	//cout<<d[h*w-1]<<endl;
	if( ans < 0 ){
		cout<<-1<<endl;
		return 0;
	}
	else{
		cout<<ans<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main()
{
	int x,y,z;
	scanf("%d %d %d", &x, &y, &z);
	if((x==y && x!=z) || (x==z && x!=y) || (y==z && y!=x)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;	
} 

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N;
    vector<ll> T(N);
    ll sum = 0;
    rep(0, i, N)
    {
        cin >> T.at(i);
        sum += T.at(i);
    }
    cin >> M;
    ll P, X;
    rep(0, i, M)
    {
        cin >> P >> X;
        cout << sum - T.at(P - 1) + X << endl;
    }
}

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

using namespace std;

int main() {
  string s;
  cin >> s;

  string org = "CODEFESTIVAL2016";
  int fix = 0;

  for (int i=0; i<16; i++) {
    if (s[i] != org[i]) {
      fix += 1;
    }
  }

  cout << fix << endl;

  return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//grobal変数


int main() {
	int n, x;
	cin >> n >> x;
	VI a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	sort(a.begin(), a.end());
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (x - a[i] >= 0) {
			if (n - 1 == i && x == a[i]) {
				cnt++;
				x -= a[i];
			}else if (i != n - 1) {
				x -= a[i];
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define Nmax 1000100
#define FOR(i, to) for (int i = 0; i < (to); ++i)
#define P 200003
using namespace std;
typedef long long ll;
const int MAX = 1<<20;

typedef ll value;
value a[MAX], b[MAX], cnt[P];
typedef complex<double> comp;
int N, p[MAX], ex[MAX], g[MAX];
comp omega[MAX], omega_tmp[MAX], a1[MAX], a2[MAX], z1[MAX], z2[MAX];

void fft(comp *a, comp *z) {
  FOR(i, N) z[i] = a[p[i]];
  int t = N;
  for (int size = 1; size < N; size *= 2) {
    t /= 2; FOR(j,size) omega_tmp[j] = omega[j*t];    
    for (int i = 0; i < N; i += 2*size) {
			FOR(j,size) {
			  comp c = omega_tmp[j] * z[i+j+size];
			  z[i+j+size] = z[i+j] - c; z[i+j] += c;
			}
    }
  }
}

void mult(value *a, value *b, value *c, int len) {
  N = 2*len; while (N & (N-1)) ++N;
  p[0] = 0; int k = 0, t = -1;
  while ((1 << k) < N) ++k;
  for(int i = 1; i < N; ++i) {
    if ((i&(i-1)) == 0) ++t;
    p[i] = p[i^(1<<t)]; p[i] |= 1 << (k-t-1);
  } 
  FOR (i, N) { a1[i] = 0; a2[i] = 0; }
  FOR (i, len) { a1[i] = double(a[i]); a2[i] = double(b[i]); }
  FOR (i, N/2) {
    omega[i] = polar(1.0, 2*M_PI/N*i);
    omega[N-i-1] = conj(omega[i]);
  }
  fft(a1, z1); fft(a2, z2);
  FOR (i, N) omega[i] = conj(omega[i]);
  FOR (i, N) a1[i] = z1[i] * z2[i] / comp(N, 0);
  fft(a1, z1);
  FOR (i, 2*len) c[i] = value(round(z1[i].real()));
}

int main() {
  int x = 1;
  ex[x] = 0;
  g[0] = x;
  a[0] = 0;
  for(int i=1;i<=P-2;++i) {
    x = (2LL*x) % P;
    ex[x] = i;
    g[i] = x;
    a[i] = 0;
  }
  
  int M;
  cin>>M;
  for(int i=0;i<M;++i) {
    cin>>x;
    if(!x) continue;
    ++a[ex[x]];
  }
  for(int i=0;i<=P-2;++i) {
    cnt[((2*i) % (P-1))] -= a[i]; 
  }
  
  mult(a, a, b, P-1);

  for(int i=0;i<2*P;++i) {
    cnt[i%(P-1)] += b[i];
  }
  ll ret = 0;
  for(int i=0;i<=P-2;++i) {
    ret += cnt[i] * g[i];
  }
  cout<<ret/2<<"\n";
  
  return 0;
}

Measured memory_bytes: 59000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,s;
  while(cin>>x>>y>>s, x){
    int ans=0;
    for(int i=1;i<s;++i){
      for(int j=1;j<s;++j){
        if((i*(100+x)/100 + j*(100+x)/100) == s)
          ans = max(ans, i*(100+y)/100 + j*(100+y)/100);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    s = input()

    if s in "aiueo":
        print("vowel")
    else:
        print("consonant")


main()


Measured memory_bytes: 4976
N =input()
a =input().split()
b,c,d =0,0,0
for i in range(0,int(N)):
    hoge = int(a[i])%2
    if hoge ==0:
        b =b+1
for i in range(0,int(N)):
    hoge = int(a[i])%4
    if hoge ==0:
        c =c+1
d = b-c
if d ==0:
    if c-(int(N)-b)+1>=0:
        print('Yes')
    else:
        print('No')
else:
    if c-(int(N)-b)>=0:
        print('Yes')
    else:
        print('No')


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

double wcz[4][2];

double a, b, c;

double o;
double p;
double w;

double kat;

double s1, s2;

double wyn;

double kwa(double v)
{
	return v*v;
}

int main()
{
	scanf("%lf%lf", &wcz[0][0], &wcz[0][1]);
	scanf("%lf%lf", &wcz[1][0], &wcz[1][1]);
	scanf("%lf%lf", &wcz[2][0], &wcz[2][1]);
	a=kwa(wcz[0][0]-wcz[1][0])+kwa(wcz[0][1]-wcz[1][1]);
	b=kwa(wcz[2][0]-wcz[1][0])+kwa(wcz[2][1]-wcz[1][1]);
	c=kwa(wcz[0][0]-wcz[2][0])+kwa(wcz[0][1]-wcz[2][1]);
	a=sqrt(a);
	b=sqrt(b);
	c=sqrt(c);
	for (int h=1; h<=3; h++)
	{
		o=(a+b+c)/2.0;
		p=sqrt(o*(o-a)*(o-b)*(o-c));
		w=2.0*p/a;
		
		kat=asin(w/b);
		kat/=2.0;
		s1=1.0/tan(kat);
		
		kat=asin(w/c);
		kat/=2.0;
		s2=1.0/tan(kat);
		
		wyn=max(wyn, a/(2.0+s1+s2));
		
		swap(a, b);
		swap(b, c);
	}
	printf("%.11lf\n", wyn);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;
const long long mod=1e9+7;


long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}


int32_t main(){

    fast
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<(a+b)){
        cout<<k;
        //cout<<"HERE";
    }
    else{
        int ans=a-(k-(a+b));
        cout<<ans;
    }



    return 0;
}



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

int n;
ll a[200005],dp[200005][3],ans=-0x3f3f3f3f3f3f3f3fll;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    memset(dp,0xc0,sizeof(dp));
    dp[0][1]=0;
    for(int i=1;i<=n;i++)
        for(int j=0;j<3;j++)
        {
            for(int k=i==1?1:2;k<=4;k++) if(i-k>=0)
                for(int g=0;g<3;g++) if(i/2+j-(i-k)/2-g==1)
                    dp[i][j]=max(dp[i][j],dp[i-k][g]+a[i]);
            if(i/2+j-1==n/2) ans=max(ans,dp[i][j]);
        }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 10052
#include<cstdio>
using namespace std;
int main(){
    int x,y;
    char z;
    while(1){
      scanf("%d %c %d",&x,&z,&y);
    if(z=='?'){
        return 0;
    }
    else if (z=='+'){
      printf("%d\n",x+y);
 
    }
    else if (z=='-'){
      printf("%d\n",x-y);
      
    }
    else if (z=='/'){
      printf("%d\n",x/y);
      
    }
    else if (z=='*'){
      printf("%d\n",x*y);
     
    }
    
    }
return 0;
    
}


Measured memory_bytes: 2732
/*input
1729
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll S;
	cin >> S;
	ll dp[S+1];
	memset(dp, 0, sizeof(dp));
	dp[0]=1;
	rep(s, S+1) {
		repl(i, 3, s+1) {
			dp[s]=(dp[s]+dp[s-i])%MOD;
		}
	}
	cout << dp[S];
	return 0;	
}

Measured memory_bytes: 3580
#if 0
    感想
#endif

#include <iostream>
#include <cmath>
using namespace std;
unsigned int e;

int calcMinimumSum() {
    int sum = 1000000;
    for (int z = 0; z*z*z <= e; z++) {
        for (int y = 0; y*y <= e - z*z*z; y++) {
            int x = e - (z*z*z) - (y*y);
            int temp = x + y + z;
            sum = sum < temp ? sum : temp;
        }
    }
    return sum;
}

int main () {
    while(cin >> e && e > 0) {
        cout << calcMinimumSum() << endl;
    }
}



Measured memory_bytes: 3064
/* ****Ragnar7 -SHINIGAMI- _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
const ll N = 100005;
vector<ll> v[N];
ll dp[N],vis[N];

ll dfs(ll s)
{
	vis[s] = 1;
	for(auto i:v[s])
	{
		dp[s] = max(1+dp[i],dp[s]);
		if(!vis[i])
			dp[s] = max(1+dfs(i),dp[s]);
	}
	return dp[s];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		ll n,m;
		cin>>n>>m;
		ll x,y;
		for(ll i=0;i<m;i++)
		{
			cin>>x>>y;
			v[x].push_back(y);
		}
		ll ans = 0;
		for(ll i=1;i<=n;i++)
		{
			if(!vis[i])
				dfs(i);
			ans=max(ans,dp[i]);
		}
		cout<<ans;
	}

	
	time
	return 0;
}

Measured memory_bytes: 12648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ull n,k,a,b,cnt[100001]={},sum=0;
  cin>>n>>k;
  for(ull i=0;i<n;i++){
    cin>>a>>b;
    cnt[a]+=b;
  }
  for(ull i=1;i<=100000;i++){
    sum+=cnt[i];
    if(k<=sum){
      cout<<i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#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>;
const int MOD=1000000007;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] t = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            t[i] = in.nextInt();
            total += t[i];
        }

        int m = in.nextInt();

        for (int i = 0; i < m; i++) {
            int p = in.nextInt();
            int x = in.nextInt();

            int sum = total;
            sum += x;
            sum -= t[p-1];

            System.out.println(sum);
        }
    }

}

Measured memory_bytes: 36208
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N;
    cin >> N;
    vec<lint> A_list(N), B_list(N), C_list(N - 1);
    range(i, 0, N) {
        cin >> A_list.at(i);
        A_list.at(i) -= 1;
    }
    range(i, 0, N) cin >> B_list.at(i);
    range(i, 0, N - 1) cin >> C_list.at(i);
    lint res = 0, prev = -2;
    for (const auto& A : A_list) {
        res += B_list.at(A);
        if (A == prev + 1) res += C_list.at(A - 1);
        prev = A;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		
		
		while(true) {
			if(a >= 10 ) {
				a = a - 10;
				
			}else {
				break;
			}
			
		}
		if(0 <= a && 10 > a ) {
			String s ;
			if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
				s = "hon";
			}
			else if(a == 0 || a == 1 || a == 6 || a == 8 ) {
				s = "pon";
			}else {
				s = "bon";
		}
			System.out.println(s);
		}
		
		
		

}
}


Measured memory_bytes: 35752
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

#define fr first
#define sc second

typedef pair< int, int > iP;

int w, h, b = 0;
char mas[100][100];

int bfs() {
    queue< pair< int, iP > > q;
    vector< vector< int > > cnt(h, vector< int >(w, 2 << 28));
    q.push(make_pair(1, iP(0, 0)));
    cnt[0][0] = 1;
    while(!q.empty()) {
        pair< int, iP > p = q.front(); q.pop();
        int x = p.sc.fr, y = p.sc.sc;
        // cout << x << ' ' << y << endl;
        if(x == w - 1 && y == h - 1) return p.fr;
        int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
        for(int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if(0 <= nx && nx < w && 0 <= ny && ny < h && mas[ny][nx] != '#' && cnt[ny][nx] > p.fr + 1) {
                q.push(make_pair(p.fr + 1, iP(nx, ny)));
                cnt[ny][nx] = p.fr + 1;
            }
        }
    }
    return -1;
}

int main() {
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> mas[i][j];
            if(mas[i][j] == '#') b++;
        }
    }

    int ret = bfs();
    if(~ret) cout << h * w - ret - b << endl;
    else cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  int cnt=0;
  for(int i=1;i<=N;i++){
    string k=to_string(i);
    if((int)k.size()%2!=0){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, P;
  while (cin >> N >> P) {
    vector<ll> w(N), b(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> b[i];
    vector<ll> vs;
    for (int i = 0; i < N; i++) {
      ll x = w[i];
      ll y = w[i] - b[i];
      ll v = 100 * x - P * y;
      vs.push_back(v);
    }
    sort(vs.rbegin(), vs.rend());
    ll B = accumulate(b.begin(), b.end(), 0ll);
    ll lim = P * B, sum = 0;
    int res = 0;
    for (ll x : vs) {
      sum += x;
      ++res;
      if (sum >= lim) break;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;

int main(){
    int n;
    while(cin >> n){
        cout << "ABC" << n << endl;
    }
    
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 100 * 1000 + 7;

bool win[MX];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& x : a) {
        cin >> x;
    }

    for (int i = 1; i <= k; i++) {
        for (int x : a) {
            if (x <= i && !win[i - x]) {
                win[i] = true;
            }
        }
    }

    if (win[k]) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
    return 0;
}



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

bool chekKaibun(string s) {
    string r;
    int i, n, hantei;

    //文字数を数える
    for(i=0; s[i] != 0x00; i++);
    n = i;

    //rにsの最後の文字から逆に代入
    for(i=0; i<n; i++){
        r[i] = s[n-1-i];
    }
    //最後に文字列の終わりのマークを代入
    r[n] = 0;

    //回文判定用変数の初期化
    hantei = 0;

    //sとrが同じかどうか、各要素を比較
    for(i=0; i<n-1; i++){
        if(s[i] != r[i]) {hantei++;}
    }

    //判定結果の表示
    if(hantei){
        return false;
    }else{
        return true;
    }
}

int main()
{
    int n = 0;
    string s;

    cin >> s;

    if(! chekKaibun(s)) {
        cout << "No" << endl;
        return 0;
    }

    n = s.length();

    if(! chekKaibun(s.substr(0, (n -1) / 2)) || ! chekKaibun(s.substr((n + 3)/2 - 1))) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

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

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

  int N, M;
  cin >> N >> M;

  float m_ = sqrt(M);
  int m = floor(m_);
  if (m*m > M) {
    m -= 1;
  }
  
  vector<int> ans(M+1), imos(M+2);
  int l, r, ll, rr, l_prev;
  int i;
  rep(j, N) {
    cin >> l >> r;
    rep (i_, m) {
        i = i_ + 1;
        ll = (l-1) / i + 1;
        rr = r / i;
        if (rr >= ll) {
          ans[i] += 1;
        }
    }
    imos[l] += 1;
    imos[r+1] -= 1;
    l_prev = l;
    rep(i_, m-1) {
      i = i_ + 2;
      ll = (l-1) / i + 1;
      rr = r / i;
      if (rr >= ll) {
        if (rr < l_prev) {
          imos[ll] += 1;
          imos[rr+1] -= 1;
        }
        else {
          imos[ll] += 1;
          imos[l_prev] -= 1;
        }
        l_prev = ll;
      }
    }
  }

  vector<int> ans2(M+1);
  rep(i_, M+1) {
    i = i_ + 1;
    ans2[i] = ans2[i-1] + imos[i];
  }
  rep(i_, m) {
    i = i_ + 1;
    cout << ans[i] << "\n";
  }
  rep(i_, M-m) {
    i = i_ + m + 1;
    cout << ans2[i] << "\n";
  }
}


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

int main() {
	int n;
	cin >> n;
	char s[n];
	int count = 1;
	for(int i=0;i<n;i++){
		cin >> s[i];
		if((i>0)&&(s[i]!=s[i-1])) count ++	;	
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{

	static int []a;
	static int []b;
	static int ans;
	static int count;
	public static void main(String[] args) {
		boolean b = false;
		a = new int [4];
		Scanner sc =  new Scanner(System.in);		//入s力
		int n = sc.nextInt();				//入力したのをint型に変換
		for(int i = 0;i<4;i++){
			int m = 1;
			for(int j = 3-i;j >0; j--){
				m *= 10;
			}
			a[i] = n/m;
			n -= (n/m)*m;

		}			//四つの数字をaに入れる
		int A = a[0];
		int B = a[1];
		int C = a[2];
		int D = a[3];



		if(A+B +C+D == 7)
			System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");

		else if(A-B+C+D == 7)
			System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");

		else if(A+B-C+D == 7)
			System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
		else if(A+B+C-D == 7)
			System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
		else if(A-B-C+D == 7)
			System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
		else if(A-B+C-D == 7)
			System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
		else if(A+B-C-D == 7)
			System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
		else if(A-B-C-D == 7)
			System.out.println(A+"-"+B+"-"+C+"-"+D+"=7");



	}



}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    int n;
    cin >> n;
    vector<char> s(n);
  rep(i,n){
    cin >> s[i];
  }
    int ans=0;
    rep(i, n)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D){
    std::cout << "Left" << std::endl;
  }else if(A+B < C+D){
    std::cout << "Right" << std::endl;
  }else{
    std::cout << "Balanced" << std::endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstring>

using namespace std;

typedef pair<int,int> P;

const int MAX=100000;

int n;
vector<int> G[MAX];
int order[MAX]={};
bool inS[MAX]={};
stack<int> roots,S;
int k;
vector<P> brg;

void visit(int v,int p)
{
	order[v]=++k;
	inS[v]=true;
	S.push(v);
	roots.push(v);
	for(int i=0;i<G[v].size();i++)
	{
		int to=G[v][i];
		if(order[to]==0)
		{
			visit(to,v);
		}
		else if(to!=p&&inS[to])
		{
			while(order[roots.top()]>order[to])roots.pop();
		}
	}
	if(v==roots.top())
	{
		if(p!=-1)brg.push_back(P(min(p,v),max(p,v)));
		while(1)
		{
			int node=S.top();S.pop();
			inS[node]=false;
			if(node==v)break;
		}
		roots.pop();
	}
	return;
}

void bridge()
{
	k=0;
	for(int i=0;i<n;i++)
	{
		if(order[i]==0)
		{
			visit(i,-1);
		}
	}
	return;
}

int main()
{
	cin>>n;
	int e;
	cin>>e;
	int u,v;
	for(int i=0;i<e;i++)
	{
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bridge();
	sort(brg.begin(),brg.end());
	for(int i=0;i<brg.size();i++)
	{
		cout<<brg[i].first<<" "<<brg[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 6844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 200003
#define MOD 1000000007
typedef int FLOW;

void chmax(int &a,int b){
  a=max(a,b);
}


int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();

  vector<vector<int>> dp(n+1,vector<int>(m+1,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s.at(i)==t.at(j)){
        chmax(dp[i+1][j+1],dp[i][j]+1);
      }else{
        chmax(dp[i+1][j+1],dp[i][j+1]);
        chmax(dp[i+1][j+1],dp[i+1][j]);
      }
    }
  }

  int i=n;
  int j=m;
  string ans;
  while(i>0&&j>0){
    if(dp[i-1][j-1]+1==dp[i][j]&&s[i-1]==t[j-1]){
      i--,j--;
      ans.push_back(s.at(i));
    }else{
      if(dp[i][j]==dp[i-1][j]){
        i--;
      }else{
        j--;
      }
    }
  }

  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}


Measured memory_bytes: 35584
#include<iostream>
#include<stack>

using namespace std;

int n;
int main(){
	string s1, s2;
	cin >> s1 >> s2;
	int cnt = 0;
	for(int i = 0; i < 3; i++){
		if(s1[i] == s2[i]) cnt++;
	}
	cout << cnt;
}



Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ans = 0;
            for(int i = 1; i <= N; i++)
            {
                ans += i;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
const ll inf=2e18;
int main()
{
	ll a,b,c,d;
	while(~sf("%lld %lld %lld %lld",&a,&b,&c,&d))
	{
		vector<ll>x;
		x.push_back(a);
		if(a+1<b)x.push_back(a+1);
		x.push_back(b);
		if(b-1>a)x.push_back(b-1);


		vector<ll>y;
		y.push_back(c);
		if(c+1<d)y.push_back(c+1);
		y.push_back(d);
		if(d-1>c)y.push_back(d-1);

		ll ans=-inf;
		for(ll ex:x)
		{
			for(ll ey:y)
			{
				ans=max(ans,ex*ey);
			}
		}
		pf("%lld\n",ans);
	}
    return 0;
}



































Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

long long modpow(long long a, long long n,long long mod) {
  long long res = 1;
  while(n > 0) {
    if(n % 2 == 1) {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a, long long mod) {
  return modpow(a,mod-2,mod);
}

long long conbi(long long n,long long k) {
  long long res = 1;
  long long inv;
  for(long long i = n-k+1; i <= n; i++) {
    res *= i;
    res %= P;
  }
  for(long long i = 1; i <= k; i++) {
    inv = modinv(i,P);
    res *= inv;
    res %= P;
  }
  return res;
}

int main() {
  int x,y;
  cin >> x >> y;
  if(((x+y) % 3 != 0) || (2*x - y < 0)) {
    cout << 0 << endl;
    return 0;
  }
  long long n = (x+y)/3;
  long long k = (2*x-y)/3;
  cout << conbi(n,k) << endl; 
  return 0;
}


Measured memory_bytes: 256
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0
if k != 0:
    ans.append(k)
print(max(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//140 B
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	rep(i, 0, n)cin >> a[i];
	vector<ll> manzoku = vector<ll>();
	rep(i, 0, n - 1) {
		if (a[i + 1] - a[i] == 1) manzoku.push_back(a[i]);
	}
	ll ans = 0;
	rep(i, 0, n) {
		ll b;
		cin >> b;
		ans += b;
	}
	vector<ll> c = vector<ll>(n);
	rep(i, 0, n-1)cin >> c[i];
	rep(i, 0, manzoku.size()) {
		ans += c[manzoku[i] - 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

stage = 0
count = 0
for i in range(N):
    if(S[i]=="A"):
        stage = 1
        continue
    if(stage==1) and (S[i]=="B"):
        stage = 2
        continue
    if(stage==2) and (S[i]=="C"):
        stage = 0
        count += 1
        continue
    stage = 0
    

print(count)

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        d: usize,
        g: i64,
        pc: [(i64, i64); d],
    };
    let mut ans = std::i64::MAX;
    for i in 0..(1 << d) {
        let mut score = 0;
        let mut count = 0;
        let mut unsolved_highest_index = None;
        for j in 0..d {
            if (i >> j & 1) == 1 {
                count += pc[j].0;
                score += pc[j].0 * (j + 1) as i64 * 100 + pc[j].1
            } else {
                unsolved_highest_index = Some(j);
            }
        }
        // println!("i:{} , count:{}, score:{}, uhi: {}", i, count, score, unsolved_highest_index.unwrap_or(std::u32::MAX as usize));
        match unsolved_highest_index {
            Some(j) => {
                if g > score {
                    let mut needed = (g - score - 1) / ((j + 1) as i64 * 100)+1;
                    if needed > pc[j].0 - 1 {
                        needed = 0;
                    }
                    score += needed * (j + 1) as i64 * 100;
                    count += needed;
                }
            }
            None => {}
        }
        // println!("i:{} , count:{}, score:{}", i, count, score);
        if score >= g && count < ans {
            ans = count;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	bool res = true;
	set<string> s;
	string old;
	for (int i = 0; i < n; i++)
	{
		string x;
		cin >> x;

		if (i > 0)
		{
			if (x.front() != old.back())
			{
				res = false;
			}

			if (s.count(x))
			{
				res = false;
			}
		}

		s.insert(x);
		old = x;
	}

	println((res ? "Yes" : "No"));
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#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(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
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 (a > b) { a = b; return true; } return false; }

signed main() {
	for (int w, d; cin >> w >> d&&w;) {
		vector<int> W(w); rep(i, 0, w) { cin >> W[i]; }
		vector<int> D(d); rep(i, 0, d) { cin >> D[i]; }
		int cntw[21] = {}, cntd[21] = {};
		rep(i, 0, w)cntw[W[i]]++;
		rep(i, 0, d)cntd[D[i]]++;
		int ans = 0;
		rep(i, 0, 21) {
			ans += max(cntw[i], cntd[i])*i;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <cstdio>

int main() {
  char s[3];
  scanf("%s", s);
  char t[3];
  scanf("%s", t);
  
  int ans = 0;
  for(int i = 0; i < 3; i++) {
    if(s[i] == t[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}
   

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n,q; cin >> n >> q;
  vvl G(n);
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vb visited(n);
  vl cost(n);
  rep(i,q){
    int node,co; cin >> node >> co;
    cost[--node]+=co;
  }
  queue<int> que;
  que.push(0);
  visited[0] = true;
  while(!que.empty()){
    int node = que.front();
    que.pop();
    for(auto nv:G[node]){
      if(visited[nv] == false){
        cost[nv]+=cost[node];
        que.push(nv);
        visited[nv] = true;
      }
    }
  }
  rep(i,n)out(cost[i]);
}

Measured memory_bytes: 17136
from itertools import permutations
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, C = map(int, input().split())

D = []
for _ in range(C):
    D.append(list(map(int, input().split())))


# それぞれのグループで、color_iが何個あるかをカウント
mod_0 = [0]*C
mod_1 = [0]*C
mod_2 = [0]*C

for i in range(N):
    l = list(map(int, input().split()))
    for j in range(N):
        m = i+j
        color = l[j]-1
        if m % 3 == 0:
            mod_0[color] += 1
        elif m % 3 == 1:
            mod_1[color] += 1
        else:
            mod_2[color] += 1


# 書き換え方を全通ためして、min
def solve():
    ans = float('inf')
    per = permutations(range(C), 3)

    for c1, c2, c3 in per:
        cost = 0
        for i in range(C):
            cost += D[i][c1]*mod_0[i]
        for i in range(C):
            cost += D[i][c2]*mod_1[i]
        for i in range(C):
            cost += D[i][c3]*mod_2[i]
        ans = min(ans, cost)

    return ans


print(solve())


Measured memory_bytes: 3188
a, b = map(int, input().split())

if (b - 1) % (a - 1) != 0:
    ans = (b - 1) // (a - 1) + 1
else:
    ans = (b - 1) // (a - 1)
# if b == 1:
#     ans = 0
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()
int N,M,table[100000+10],ans=0;
signed main(){
  cin >> N >> M;
  rep(i,M){
    int L,R;
    cin >> L >> R;
    L--,R;
    table[L]++;
    table[R]--;
  }
  rep(i,N){
    if(0<i) table[i]+=table[i-1];
  }
  rep(i,N) if(table[i]==M) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024