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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 111;

int N;
int A[MAX];

string solve() {
    REP (i, N) if ((A[i]&1) == 0) {
        if (A[i]%3 != 0 && A[i]%5 != 0) return "DENIED";
    }
    return "APPROVED";
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

type Standard []string
func (S Standard) Len() int { return len(S) }
func (S Standard) Less(i, j int) bool { return S[i] < S[j] }
func (S Standard) Swap(i, j int) { S[i], S[j] = S[j], S[i] }

func DFS(S *[]string, M []rune, max, pos int) {
  if pos == len(M) {
   (*S) = append((*S), string(M))
    return
  }
  for r := 0; r <= max + 1; r++ {
    M[pos] = rune(r + int('a'))
    DFS(S, M, MaxInt(max, r), pos + 1)
  }
}

func Solve() {
  var N int
  NextInt(&N)
  S := make([]string, 0)
  M := make([]rune, N)
  DFS(&S, M, -1, 0)
  sort.Sort(Standard(S))
  for _, s := range S {
    Write(s)
  }
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 9856
N = int(input())
*A, = map(int, input().split())


d = {}


for i in range(N):
    if A[i] in d:
        d[A[i]] = d[A[i]] + 1
    else:
        d[A[i]] = 1

ans = 0
for i in d:
    num = d[i]
    if num<i:
        ans = ans + num
    elif num>i:
        ans = ans + (num-i)

print(ans)


Measured memory_bytes: 17780
N = int(input())
ans = [0] * 100000
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans[x*x+y*y+z*z+x*y+y*z+z*x-1] += 1
for i in range(N):
    print(ans[i])


Measured memory_bytes: 9712
#include <bits/stdc++.h>
#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);

	ll n, a, b;
	cin >> n >> a >> b;

	if(a + b - 1 > n || a * b < n){
		cout << -1 << endl;
		return 0;
	}

	ll t = n;
	vector<ll> v;
	for(ll i = b; i >= 1; i--){
		v.push_back(i);
		t--;
	}

	for(ll i = 2 * b; i <= a * b; i += b){
		v.push_back(i);
		t--;
		ll d = t - (a - i / b);
		for(ll j = 0; j < min(d, b - 1); j++){
			v.push_back(i - j - 1);
			t--;
		}
	}

	vector<ll> w(n);
	rep(i, n) w[i] = v[i];
	sort(w.begin(), w.end());

	rep(i, n){
		cout << lower_bound(w.begin(), w.end(), v[i]) - w.begin() + 1 << (i == n - 1 ? "\n" : " ");
	}

}


Measured memory_bytes: 8684
#include <stdio.h>

int n, m, q, a[50], b[50], c[50], d[50], t[10] = {0}, r = 0;

void traverse(int l) {
	if(l == n) {
		int u = 0, i;
		for(i = 0; i < q; i++) {
			if(t[b[i]] - t[a[i]] == c[i])
				u += d[i];
		}
		if(u > r)
			r = u;
	} else {
		int u = l ? t[l - 1] : 0, i;
		for(i = u; i < m; i++) {
			t[l] = i;
			traverse(l + 1);
		}
	}
}

int main() {
	int i;
	scanf("%d %d %d", &n, &m, &q);
	for(i = 0; i < q; i++) {
		scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
		a[i]--;
		b[i]--;
	}
	
	traverse(0);
	printf("%d", r);
	return 0;
}

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

class Dice {
    int face[6];
public:
    Dice(int f[]) {
        for (int i = 0; i < 6; i++) {
            face[i] = f[i];
        }
    }

    void play(char direct[]) {
        for (int i = 0; direct[i] != '\0'; i++) {
            if (direct[i] == 'E') {
                int t = face[5];
                face[5] = face[2];
                face[2] = face[0];
                face[0] = face[3];
                face[3] = t;
            } else if (direct[i] == 'N') {
                int t = face[4];
                face[4] = face[0];
                face[0] = face[1];
                face[1] = face[5];
                face[5] = t;
            } else if (direct[i] == 'S') {
                int t = face[4];
                face[4] = face[5];
                face[5] = face[1];
                face[1] = face[0];
                face[0] = t;
            } else if (direct[i] == 'W') {
                int t = face[5];
                face[5] = face[3];
                face[3] = face[0];
                face[0] = face[2];
                face[2] = t;
            }
        }
    }

    void print_top() {
        cout << face[0] << endl;
    }
};

int main() {
    int face[6];
    char direct[100];

    for (int i = 0; i < 6; i++) {
        cin >> face[i];
    }
    cin >> direct;

    Dice dice(face);
    dice.play(direct);
    dice.print_top();

    return 0;
}


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

int main(){
    int n;
    string s;
    string c = "Hoshina";
    cin >> n;
    cin.ignore();
    while(n--){
        getline(cin,s);
        while(s.find("Hoshino") != string::npos){
            s.replace(s.find("Hoshino"),c.size(),c);
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1212
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = int.Parse(Console.ReadLine());
            var p = test.ConvertIntArray(test.ReadInput());
            var match = false;
            var ans = 0;
            var min = p[0];
            var max = p[0];
            for (var i = 0; i < n; i++)
            {
                if (p[i] <= max && p[i] <= min)
                {
                    ans++;
                }

                min = Math.Min(p[i], min);
                max = Math.Max(p[i], max);
            }
            Console.WriteLine(ans);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 29404
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, s;
	cin >> a >> b;
	s = a + b;
	s = max(s, a - b);
	s = max(s, a * b);
	cout << s << endl;

}

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

signed main() {
    int N;
    cin >> N;
    
    map<int, int> A;
    for( int i = 0; i < N-1; i++ ){
        int B;
        cin >> B;
        if( A.count(B) ) A.at(B)++;
        else A[B] = 1;
    }
    
    for( int i = 1; i <= N; i++ ){
        if( A.count(i) ) cout << A.at(i) << endl;
        else cout << 0 << endl;
    }
    
    
}


Measured memory_bytes: 16052
#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()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    ll n,a,b; cin >> n >> a >> b;
    ll h[n];
    rep(i,n) cin >> h[i];
    ll l = 0, r = 10000000000;
    while(r-l > 1){
        ll m = (r+l)/2;
        ll s[n];
        rep(i,n) s[i] = h[i]-b*m;
        ll cnt = 0, div = a-b;
        rep(i,n) if(s[i] > 0) cnt += (s[i]+div-1)/div;
        if(cnt > m) l = m;
        else r = m;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
int A[101010], B[101010], C[101010];
i64 ba[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", A + i);
	for (int i = 0; i < N; ++i) scanf("%d", B + i);
	for (int i = 0; i < N; ++i) scanf("%d", C + i);
	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);

	for (int i = 0; i < N; ++i) {
		ba[i] = lower_bound(A, A + N, B[i]) - A;
		if (i > 0) ba[i] += ba[i - 1];
	}

	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		int idx = lower_bound(B, B + N, C[i]) - B;
		if (idx > 0) ret += ba[idx - 1];
	}
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        string s = cin.Next();

        int pre = int.Parse(s.Substring(0, 2));
        int suf = int.Parse(s.Substring(2, 2));

        if (1 <= pre && pre <= 12 && 1 <= suf && suf <= 12)
        {
            Console.WriteLine("AMBIGUOUS");
        }
        else if (pre == 0 && 1 <= suf && suf <= 12)
        {
            Console.WriteLine("YYMM");
        }
        else if (1 <= pre && pre <= 12 && suf == 0)
        {
            Console.WriteLine("MMYY");
        }
        else if (1 <= pre && pre <= 12 && 13 <= suf)
        {
            Console.WriteLine("MMYY");
        }
        else if (1 <= suf && suf <= 12 && 13 <= pre)
        {
            Console.WriteLine("YYMM");
        }
        else
        {
            Console.WriteLine("NA");
        }

    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

ll dp[110][100010]={0};

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

  ll n,w;
  std::cin>>n>>w;

  rep(i,0,n){
    ll wa,v;
    std::cin>>wa>>v;
    rep(j,0,100010){
      dp[i+1][j]=dp[i][j];
      if(j>=wa)chmax(dp[i+1][j],dp[i][j-wa]+v);
    }
  }

  std::cout<<dp[n][w]<<"\n";

  return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	string s;
	cin >> s;

	if (s == "AAA" || s == "BBB")
	{
		cout << "No";
	}
	else
		cout << "Yes";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#n=int(input())
k=int(input())
a,b=map(int,input().split())
#a=list(map(int,input().split()))
#a=[int(input()) for i in range(n)]
#ab=[list(map(int,input().split())) for i in range(n)]
ans='NG'
for i in range(a,b+1):
  if i%k==0:
    ans='OK'
print(ans)

Measured memory_bytes: 9164
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/fenwicktree>
using namespace atcoder;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
//#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    cini(q);
    
    fenwick_tree<ll> fen(n);
    for(int i=0; i<n; i++) {
        cini(a);
        fen.add(i,a);
    }

    for(int i=0; i<q; i++) {
        cini(t);
        if(t==0) {
            cini(p);
            cini(x);
            fen.add(p,x);
        } else {
            cini(l);
            cini(r);
            cout<<fen.sum(l,r)<<endl;
        }
    }
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 8248
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(48 - a);
    }
}

Measured memory_bytes: 35676
#include <stack>
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>
#include <cstdio>
using namespace std;
struct edge { int to, cap, rev; };
vector<edge>map[103];
bool used[103];
int dfs(int v,int t,int f){
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < map[v].size(); i++) {
		edge &e = map[v][i];
		if (!used[e.to] && e.cap>0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				map[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int main()
{
	int V, E;
	int a, b, c;
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> a >> b >> c;
		edge ed = { b,c,map[b].size() };
		map[a].push_back(ed);
		edge edg = { a,0,map[a].size() - 1 };
		map[b].push_back(edg);
	}int ans = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(0, V - 1, 9999999);
		if (f == 0)break;
		ans += f;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define rep(i, begin, end) for(int i = begin; i < (end); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	cin >> n;
  	vector<int> a(n), b(n), c(n);
  	rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
  
  	int dp[100005][3];
  	dp[0][0] = a[0];    	
  	dp[0][1] = b[0];
  	dp[0][2] = c[0];  	
  	rep(i, 1, n+1){
    	dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    	dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
  
  	int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
  	cout << ans << endl;	
}	

Measured memory_bytes: 2560
import sys
import math
import collections
import bisect
import copy
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    bit = [[0] * 20 for _ in range(n)]
    bitidx = [[] * 20 for _ in range(20)]

    for i, ai in enumerate(a):
        cnt = 0
        while ai > 0:
            if ai & 1:
                bit[i][cnt] = 1
                bitidx[cnt].append(i)
            cnt += 1
            ai >>= 1

    ans = n

    for i in range(n):
        min_idx = n
        for j in range(20):
            # jbit目でiの次に1になるidxを探す　ない場合はlen(bitidx[j])が返ってくる
            tmp = bisect.bisect_left(bitidx[j], i + 1)
            if not bit[i][j]:
                # 0のときは2つ目の1を探す
                tmp += 1

            if tmp < len(bitidx[j]):
                tmp = bitidx[j][tmp]
            else:
                tmp = n
                
            min_idx = min(min_idx, tmp)
        ans += min_idx - i - 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 220996
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

template <class S>
auto rle(const S& s) {
  vector<pair<typename S::value_type, int>> res;
  for (auto c : s)
    if (empty(res) or res.back().first != c)
      res.emplace_back(c, 1);
    else
      ++res.back().second;
  return res;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  string s;
  cin >> s;
  int res = 0;
  for (auto [c, len] : rle(s)) {
    if (c == 'R') res = max(res, len);
  }
  cout << res << '\n';
}


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

char F[102][102];
bool MazeJudge;
int xg,yg;

char ItoC(int i){
	if(i==1){
		return '1';
	}else if(i==2){
		return '2';
	}else if(i==3){
		return '3';
	}else if(i==4){
		return '4';
	}else if(i==5){
		return '5';
	}
}

void DFS(int X,int Y,char C)
{
	if(F[X][Y]!=C)
		return;

	F[X][Y] = '.';

	if(X==xg&&Y==yg){
		MazeJudge = true;
		return;
	}
	
	DFS(X-1,Y  ,C);
	DFS(X  ,Y+1,C);
	DFS(X+1,Y  ,C);
	DFS(X  ,Y-1,C);
}
	

int main()
{
	while(true){
		for(int j=0;j<102;j++){
			for(int i=0;i<102;i++){
				F[i][j] = '0';
			}
		}

		MazeJudge = false;
		int w,h;
		cin >> w >> h;
		if(w==0&&h==0)
			break;

		int xs,ys;
		cin >> xs >> ys >> xg >> yg;

		int n;
		cin >> n;
		for(int i=0;i<n;i++){
			int c,d,x,y;
			cin >> c >> d >> x >> y;
    			char color = ItoC(c);
			if(d==0){
				F[x  ][y  ] = color;
				F[x+1][y  ] = color;
				F[x+2][y  ] = color;
				F[x+3][y  ] = color;
				F[x  ][y+1] = color;
				F[x+1][y+1] = color;
				F[x+2][y+1] = color;
				F[x+3][y+1] = color;
			}else if(d==1){
				F[x  ][y  ] = color;
				F[x+1][y  ] = color;
				F[x  ][y+1] = color;
				F[x+1][y+1] = color;
				F[x  ][y+2] = color;
				F[x+1][y+2] = color;
				F[x  ][y+3] = color;
				F[x+1][y+3] = color;		
			}
		}
		
		//デバッグ用迷路表示
		/*for(int j=0;j<102;j++){
			for(int i=0;i<102;i++){
				cout << F[i][j];
			}
			cout << endl;
		}*/

		char rc = F[xs][ys];
		DFS(xs,ys,rc);
		if(MazeJudge==true){
			cout << "OK" << endl;
		}else if(MazeJudge==false){
			cout << "NG" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3304
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

ll rec(string n, ll b, ll k) {
  if (k == 0) return 1LL;
  if ((ll)n.length() < k) return 0;
  if (n == "") return 1LL;

  ll ans = 0;
  string nn = n.size() >= 2 ? n.substr(1, n.size() - 1) : "";
  ll d = n[0] - '0';
  if (b == 0) {
    if(d == 0){
      ans += rec(nn, 0, k);
    } else {
      ans += rec(nn, 0, k-1);
      ans += rec(nn, 1, k);
      ans += (d-1)*rec(nn, 1, k-1);
    }
  } else {
    ans += rec(nn, 1, k);
    ans += 9*rec(nn, 1, k-1);
  }
  return ans;
}

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

  ll ans = rec(n, 0LL, k);

  cout << ans << endl;

  return 0;
}


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

bool func(int n);

int main(){
    int n;
    cin >> n;
    for(int i=n;;i++){
        if(func(i)){
            cout << i << endl;
            break;
        }
    }
}

bool func(int n){
    bool yes = true;
    for(int i=2;i<n;i++){
        if(n%i==0){
            yes = false;
        }
    }
    return yes;
}

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

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

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

	int i,x,cnt=0;
	for (i=1; i<=N; i++){
        cin >> x;
        if (x%2) cnt++;
	}

	if (cnt%2) cout << "NO\n";
	else cout << "YES\n";
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<string> S(N);
	for(int i = 0; i < N; i++) cin >> S[i];
	int ans = 0;
	for(int A = 0; A < N; A++) {
		vector<string> T(N);
		for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) T[i] += 'a';
		for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) T[i][(j+A)%N] = S[i][j];
		bool ok = true;
		for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) if(T[i][j] != T[j][i]) ok = false;
		if(ok) ans += N;
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll N; cin >> N;
	ll n = (-1 + sqrt(1 + 8 * N)) / 2;
	ll rest = N - n * (n + 1) / 2;
	if (rest - (n + 1) >= 0) {
		n++;
		rest -= n;
	}
	if (rest != 0) n++;

	for (ll i = n; i >= 0; i--) {
		if (i >= N) {
			cout << N << endl;
			return 0;
		}
		N -= i;
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int f(int x)
{int r=0;
while(x>0)
{r++;
x/=10;
}
return r;
}
int main() {
int n,i,ans=0;
cin>>n;
for(i=1;i<=n;i++)
if(f(i)&1)ans++;
	cout<<ans;
}

Measured memory_bytes: 256
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    def __mul__(self, other):
        return Point(self.x * other, self.y * other)
    def __floordiv__(self, other):
        return Point(self.x / other, self.y / other)
    def __repr__(self):
        return str(self.x) + ' ' + str(self.y)

class Vector(Point):
    pass

class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

def points_to_vector(p1, p2):
    x = p1.x - p2.x
    y = p1.y - p2.y
    return Vector(x, y)

def vector(p):
    return Vector(p.x, p.y)

def dot(v1, v2):
    return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
    return v1.x * v2.y - v1.y * v2.x

def norm(v):
    return v.x**2 + v.y**2

def project(s, p):
    base = points_to_vector(s.p1, s.p2)
    hypo = points_to_vector(p, s.p1)
    r = dot(hypo, base) / norm(base)
    return s.p1 + base * r

def reflect(s, p):
    return p + (project(s, p) -p) * 2

import sys
# sys.stdin = open('input.txt')

s = list(map(int, input().split()))
p1 = Point(s[0], s[1])
p2 = Point(s[2], s[3])
segment = Segment(p1, p2)

q = int(input())
for i in range(q):
    x, y = map(int, input().split())
    p = Point(x, y)
    ans = reflect(segment, p)
    print(ans)


Measured memory_bytes: 5648
n,m = map(int,input().split())
t = [0 for i in range(n)]
e = [True for i in range(n)]
b = ""
a = False
for i in range(m):
    s,c = map(int,input().split())
    if e[s-1]:
        if s == 1 and c == 0:
            a = True
            if n == 1:
                print(0)
                exit()
        else:
            t[s-1] = c
            e[s-1] = False
    else:
        if t[s-1] != c:
            a = True
for i in range(n):
    b += str(t[i])
if a:
    print(-1)
elif n > 1 and b[0] == '0':
    print(str(1)+b[1:3])
else:
    print(b)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    for (ll i = 1; i * i <= M; ++i) {
        if (M % i == 0) {
            if (M / i >= N) {
                ans = max(ans, i);
            }
            auto j = M / i;
            if (M / j >= N) {
                ans = max(ans, j);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# 標準出力を取得（strデータ）
# A タップの口数　B 必要な口数
A, B = input().split()

# A, B を integerに変換
A = int(A)
B = int(B)

# OAタップの数を表す変数の初期値を 1 とする
num = 1

# B(必要な口数) が 1 の時はタップは必要ない
if B == 1:
    num = 0
else:
    while (A - 1) * (num - 1) + A < B:
        num = num + 1

# 結果を出力
print(num)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());
    
    ivec x(5);
    while (read(x)) {

        forn(i, x.size()) {
            if (x[i] == 0) {
                cout << i + 1 << endl;
                break;
            }
        }
    }

}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define ll long long
//#define scanf scanf_s

char isl[1005][1005];
int s[3][1005][1005];//0-J 1-O 2-I

int main()
{
	int m, n, q;
	cin >> m >> n >> q;
	FOR(i, 1, m + 1)FOR(j, 1, n + 1) cin >> isl[i][j];
	REP(i, m + 1)REP(k, 3) s[k][i][0] = 0;
	REP(j, n + 1)REP(k, 3) s[k][0][j] = 0;
	FOR(i, 1, m + 1)FOR(j, 1, n + 1)
	{
		REP(k, 3) s[k][i][j] = s[k][i - 1][j] + s[k][i][j - 1] - s[k][i - 1][j - 1];
		if (isl[i][j] == 'J') s[0][i][j]++;
		else if (isl[i][j] == 'O') s[1][i][j]++;
		else s[2][i][j]++;
	}
	
	int a, b, c, d, J, O, I;
	REP(l, q)
	{
		cin >> a >> b >> c >> d;
		J = s[0][c][d] - s[0][c][b - 1] - s[0][a - 1][d] + s[0][a - 1][b - 1];
		O = s[1][c][d] - s[1][c][b - 1] - s[1][a - 1][d] + s[1][a - 1][b - 1];
		I = s[2][c][d] - s[2][c][b - 1] - s[2][a - 1][d] + s[2][a - 1][b - 1];
		cout << J << " " << O << " " << I << endl;
	}
	return 0;
}

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

int main() {
	int n, x;
	int no;
	int i, j, k;
	while(1) {
		cin >> n >> x;
		no = 0;
		if (n == 0 && x == 0) break;
		for (i = 1; i <= n; i++) {
			for (j = i+1; j <= n; j++) {
				for (k = j+1; k <= n; k++) {
					if (!(i == j || j == k || k == i)) {
						if ((i+j+k) == x) no++;
					}
				}
			}
		}
		cout << no << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>

int main(){
    int n,m;
    int i,j;
    int l;
    int a[51],b[51],c[51],d[51]; //0~50
    int ans[51],num[51];
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(j=0;j<m;j++){
        scanf("%d%d",&c[j],&d[j]);
    }
    for(i=0;i<n;i++){
        ans[i] = 400000005;
        for(j=0;j<m;j++){
            l=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(ans[i] > l){
                ans[i] = l;
                num[i] = j;
            }
        }
        printf("%d\n",num[i] + 1);
    }
}


Measured memory_bytes: 128
x1, y1, x2, y2 = gets.split.map(&:to_i)
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<ll> H(n);
    cin >> H[0];
    int ans = 0, cnt = 0;
    rrep(i, n - 1) {
        cin >> H[i];
        if(H[i] <= H[i - 1]) cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    if(x + y + z >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

vector<vector<int> > G;
vector<int> used;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    map<string, string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";
    cout << m[s];
    return 0;
}  


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

int main() {
    string s,t;
    cin>>s>>t;
    ll flag=0;
    for(ll i=0;i<min(s.size(),t.size());++i){
        if(s[i]!=t[i]) {flag++;break;}
    }
    if(flag==0 && t.size()==s.size()+1)  cout<<"Yes\n";
    else    cout<<"No\n";
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

    int S1 = 0;
    int S2 = 0;

    vector<int> W(N);
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
        S2 += W[i];
    }
    
    int ans = 100000000;
    for (int i = 0; i < N; i++)
    {
        S1 += W[i];
        S2 -= W[i];

        if (S1 == S2)
        {
            ans = 0;
            break;
        }

        if (S1 > S2)
        {
            ans = S1 - S2;
            ans = min((S2+W[i] - (S1-W[i])), ans);
            break;
        }
        
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ
const int MAX = 100001 ;
struct Node {int p,l,r;} ;
Node T[MAX] ;
int d[MAX] ;

int rec(int u, int p){
  d[u] = p ;
  if(T[u].r!=NIL){
    rec(T[u].r, p) ;
  }
  if(T[u].l!=NIL){
    rec(T[u].l, p+1) ;
  }
}

void print(int h){
  cout<<"node "<<h<<": ";
  cout<<"parent = "<<T[h].p<<", ";
  cout<<"depth = "<<d[h]<<", ";
  
  if(T[h].p==NIL){
    cout<<"root, ";
  }
  else if(T[h].l==NIL){
    cout<<"leaf, ";
  }
  else{
    cout<<"internal node, ";
  }
  
  cout<<"[";
  
  if(T[h].l!=NIL){
    int hh = T[h].l ;
    while(hh!=NIL){
      cout <<hh;
      hh = T[hh].r ;
      if(hh!=NIL){
        cout<<", ";
      }
    }
  }
  cout <<"]"<<endl;
}
    
  



//-------------------------------------------------


int main()
{
  int n ;
  cin >> n ;
  
  for(int i=0;i<n;i++){
    T[i].p=NIL ;
    T[i].r=NIL ;
    T[i].l=NIL ;
  }
  
  for(int i=0;i<n;i++){
    int u, k ;
    cin >> u >> k ;
    for(int j=0;j<k;j++){
      int c ;
      int e ;
      cin >> c ;
      if(T[u].l==NIL){
        T[u].l = c ;
      }
      else{
        T[e].r = c ;
      }
      e = c ;
      T[c].p = u ;
    }
  }
  
  int r ;
  
  for(int i=0;i<n;i++){
    if(T[i].p==NIL){
      r = i ;
    }
  }
  
  rec(r,0) ;
  
  for(int i=0; i<n;i++){
    print(i) ;
  }
  
        
  

  return 0 ;
}







Measured memory_bytes: 7712
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main ( void ){
	//左手で打つ文字列
	string left = "qwertasdfgzxcvb";
	//入力文字列変数
	string inputs;
	while(1){
		//入力文字列の取得
		cin >> inputs;
		//端末処理
		if(inputs.at(0)=='#') break;
		//打った手を保持するスタック
		stack<char> seq;
		//打ち替え回数保持変数
		int cnt=0;
		//入力文字列を先頭から１文字ずつ走査
		for( int i=0;i<inputs.length();i++){
			//左手か右手か保持するchar変数
			char pos;
			//文字列が左手で打つなら posにr 左手なら l
			if(left.find(inputs.at(i))!=-1)	pos='r';
			else pos='l';
			//最後に打った手がposと違うならカウントアップ
			if(seq.size()!=0 && seq.top()!=pos)	cnt++;
			//スタックに今打った手を積む
			seq.push(pos);
		}
		//結果の出力
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
struct UnionFind{
    vl data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    ll size(int x){
        return -data[root(x)];
    }
};
int main(){
    ll n,m;
    cin>>n>>m;
    UnionFind uf(n);
    vl ans(m);
    ll now=n*(n-1)/2;
    vi a(m),b(m);
    REP(i,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
    }
    reverse(all(a));
    reverse(all(b));
    REP(i,m){
        ans[i]=now;
        if(!uf.find(a[i],b[i])){
            now-=uf.size(a[i])*uf.size(b[i]);
            uf.unite(a[i],b[i]);
        }
    }
    reverse(all(ans));
    REP(i,m){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
# return x^{-1} % mod
# it takes O(log{mod})
def mod_inverse(x, mod):
    return pow(x, mod-2, mod)

# return nCk % mod
# it takes O(k)
def mod_comb(n, k, mod):
    numer, denom = 1, 1
    for i in range(k):
        # numer: 分子, denom: 分母
        numer = numer * ((n-i) % mod) % mod
        denom = denom * ((i+1) % mod) % mod

    return numer * mod_inverse(denom, mod) % mod


n, a, b = map(int, input().split())
mod = 1000000007
ans = pow(2, n, mod) - 1
ans = (ans - mod_comb(n, a, mod)) % mod
ans = (ans - mod_comb(n, b, mod)) % mod
print( (ans + mod) % mod )

Measured memory_bytes: 3064
n = gets.chomp.to_i
a = n.times.map{gets.to_i}
b = a.dup

max = a.max
b.delete(max)
max2 = -1
if b.length == 0 || (a.length - b.length) > 1
  max2 = max
else
  max2 = b.max
end

(0..(n-1)).each do |i|
	if a[i] == max
      puts max2
    else
      puts max
    end
end


Measured memory_bytes: 7476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q,x;
  char com[20];
  cin.tie(0);
  ios::sync_with_stdio(false);
  list<int> v;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>com;
    if(com[0]=='i'){
      cin>>x;
      v.push_front(x);
    }else if(com[6]=='L'){
      v.pop_back();
    }else if(com[6]=='F'){
      v.pop_front();
    }else{
      cin>>x;
      for(list<int>::iterator j=v.begin();j!=v.end();j++){
        if(*j==x){
          v.erase(j);
          break;
        }
      }
    }
  }
  int i=0;
  for(list<int>::iterator it=v.begin();it!=v.end();it++){
    if(i++) printf(" ");
    printf("%d",*it);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 34472
#include<iostream>

using namespace std;

int main(){
 long n;
  cin >> n;
  
  bool res=true;
  int k=1;
  
  while(n>9){
    k++;
    if(n%10!=9) res=false;
    n/=10;
  }

 if(res) cout << n+(k-1)*9 << endl;
 else cout << n+(k-1)*9-1 << endl;

}

Measured memory_bytes: 256