akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

vector<pair<ll,ll>> v;
ll dp[200][100005];

ll solve(ll i,ll s,ll n)
{
    if(s==0)    return 0;
    if(s < 0)   return INT_MIN;
    
    if(i==n)    return 0;
    if(dp[i][s]!=-1)    return dp[i][s];
    
    ll ans = 0;
    ans = max(ans,solve(i+1,s-v[i].ff,n)+v[i].ss);
    
    ans = max(ans,solve(i+1,s,n));
    
    dp[i][s] = ans;
    
    return ans;
}

int main() {
    
    memset(dp,-1,sizeof(dp));
    
    ll n,s;
    cin >> n >> s;
    
    for(ll i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        v.push_back({a,b});
    }    
    
    cout<<solve(0,s,n);
    
	return 0;
}

Measured memory_bytes: 156544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = RArInt();
            vs = vs.OrderByDescending(x => x).ToArray();

            int res = 0;
            res += vs[0];
            vs[0]--;

            vs = vs.OrderByDescending(x => x).ToArray();
            res += vs[0];

            Console.WriteLine(res);

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> graph;
const long long mod = 1000000007LL;

int n, q;
int cnt[220000];
int dist[220000];

void dfs_dist(int v, int d, vector<vi> &g) {
  if(dist[v]!=-1) return;
  dist[v] = d;
  for(auto to : g[v]) dfs_dist(to,d+1,g);
}

void dfs(int now, vector<vi> &g) {
  for(auto to : g[now]) {
    if(dist[to]>dist[now]) {
      cnt[to] += cnt[now];
      dfs(to,g);
    }
  }
  return;
}

int main() {
  cin >> n >> q;
  graph g(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i,220000) dist[i] = -1;
  dfs_dist(0,0,g);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    cnt[p] += x;
  }
  dfs(0,g);
  rep(i,n) {
    cout << cnt[i];
    if(i != n-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 24320
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  for(int i=1;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  for(int i=1;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c = fac[n];
  c *= finv[k];c %= MOD;
  c *= finv[n-k];c %= MOD;
  return c;
}



int main(){
  int n;
  string s;
  cin >> n >> s;
  string ans = "";
  string ref = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char convert[26];
  for(int i=0;i<26;i++){
    convert[i] = ref[i];
  }
  int temp;
  for(int i=0;i<s.length();i++){
    temp = s[i]-'A';
    temp += n;
    temp %= 26;
    ans += convert[temp];
  }
  cout << ans << endl;
  //cout << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/* Author - Neel Aryan (@neelaryan2) */
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
vector<int> a, ans;
vector<vi> adj;
set<int> s;
void dfs(int v, int p = -1) {
    auto it = s.lower_bound(a[v]);
    int val = (it != s.end()) ? *it : -1;
    if (it != s.end())
        s.erase(it);
    s.insert(a[v]);
    ans[v] = s.size();
    for (int u : adj[v])
        if (u != p) dfs(u, v);
    s.erase(a[v]);
    if (val != -1) s.insert(val);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    a.resize(n);
    ans.resize(n);
    adj.resize(n);
    for (int& e : a) cin >> e;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(0);
    for (int i : ans) cout << i << '\n';
}


Measured memory_bytes: 27640
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int x = scn.nextInt();

        while (n != 0 || x != 0) {
            System.out.println(combination(n, x));
            n = scn.nextInt();
            x = scn.nextInt();
        }

        scn.close();

    }

    static int combination(int n, int x) {

        int ans = 0;
        int sum;

        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    sum = i + j + k;
                    if (sum == x) {
                        ans += 1;
                    }
                }
            }
        }

        return ans;

    }


}




Measured memory_bytes: 26452
#include<bits/stdc++.h>
using namespace std;
int x,ans=1;
int main(){
	scanf("%d",&x);
	for(int i=2;i<=x;i++){
		int v=i*i;
		while(v<=x){
			ans=max(ans,v);
			v*=i;
		}
	}
	printf("%d",ans);
}

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


int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(u == s){
        a--;
    }
    else
    {
        b--;
    }
    cout << a << " " << b;
    
    
    cout << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int x,n,a;
	cin>>x>>n;
	set<int> myset;
	for (int i = 0; i <= 200; ++i)
	{
		myset.insert(i);
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		myset.erase(a);
	}
	int ans=INF,idx=-1;
	for(auto it:myset){
		if(abs(it-x)<ans){
			ans=abs(it-x),idx=it;
		}
	}
	cout<<idx<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int ans(0);

    rep(i,6){
        char x;  cin >> x;
        if(x=='1')   ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

map<ll, int> mp;
void prime_factorization(ll N) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(mp.count(i)) mp[i]++;
      else mp[i] = 1;
      n /= i;
    }
    if(i == 2) i++;
    else i += 2;
  }
  if(n != 1) {
    if(mp.count(n)) mp[n]++;
    else mp[n] = 1;
  }
}


int main() {
  int N;
  cin >> N;
  REP(i, 1, N+1)
    prime_factorization(i);
  ll ans = 1;
  for(auto m: mp) {
    ans *= (1 + m.second);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
a.sort!

if n.odd?
  n.times do |i|
    t = if i == 0
          0
        else
          i.odd? ? i+1 : i
        end
    if a[i] != t
      p 0
      exit
    end
  end
else
  n.times do |i|
    t = i.even? ? i+1 : i
    if a[i] != t
      p 0
      exit
    end
  end
end

p 2 ** (n/2) % (10 ** 9 + 7)


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

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

    int n = 3;
    set<int> st;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        st.insert(a);
    }

    cout << (int)st.size() << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf   1000000009
#define minf -1000000009
vector<string>V;
signed main() {
	string s, t;
	cin >> s >> t;
	int sz = s.size(), tz = t. size();
	for (int i = 0; i <= sz-tz; i++) {
		int flg = 0;
		for (int j = i; j < i + tz; j++) {
			if (s[j]!='?'&&s[j]!=t[j-i]) {
				flg++;
			}
		}
		if (!flg) {
			string sa = s;
			for (int j = i; j < i + tz; j++) {
				sa[j] = t[j - i];
			}
			for (int j = 0; j < sz; j++) {
				if (sa[j] == '?')sa[j] = 'a';
			}
			V.push_back(sa);
		}
	}
	if(V.empty())puts("UNRESTORABLE");
	else {
		sort(V.begin(), V.end());
		cout << V[0] << endl;
	}
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readLine()!!
    var ans = true
    S.forEachIndexed { index, char ->
        if (index % 2 == 0) {
            if (char != 'R' && char != 'U' && char != 'D') { ans = false }
        } else {
            if (char != 'L' && char != 'U' && char != 'D') { ans = false }
        }
    }
    println(if (ans) "Yes" else "No")
}

Measured memory_bytes: 31900
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		BitSet set = new BitSet();
		boolean hasWild = false;
		while ((n != k) && (n != 0)) {
			set.clear();
			hasWild = false;
			for (int i = 0; i < k; i++) {
				final int nextInt = in.nextInt();
				if (nextInt != 0) {
					set.set(nextInt);
				} else {
					hasWild = true;
				}
			}
			int start = set.nextSetBit(0);
			int sizeMax = 0;
			while (start != -1) {
				int end = set.nextClearBit(start);
				int nextStart = set.nextSetBit(end);
				if (hasWild && set.get(++end)) {
					end = set.nextClearBit(end);
				}
				sizeMax = Math.max(sizeMax, end - start);
				start = nextStart;
			}
			System.out.println(sizeMax);
			n = in.nextInt();
			k = in.nextInt();
		}
	}

}

Measured memory_bytes: 62016
input_str = input()

each_str_array = input_str.split()

# input_strが"1 2"の場合、
# each_str_array = ["1", "2"]

first = int(each_str_array[0])
second = int(each_str_array[1])

if(first >= 10):
  print("-1")
elif(second >= 10):
  print("-1")
else:
  print(str(first * second))


Measured memory_bytes: 2940
import collections

n = int(input())
V = list(map(int, input().split()))


def map_all(li):
    return all([e == li[0] for e in li[1:]]) if li else False


evel = collections.Counter()
evel2 = []
odd = collections.Counter()
odd2 = []
for index, v in enumerate(V):
    if index % 2 == 0:
        evel[v] += 1
        evel2.append(v)
    else:
        odd[v] += 1
        odd2.append(v)

if map_all(evel2) and map_all(odd2):
    # 各2数列全て同じ値
    if evel2[0] == odd2[0]:
        # 2つの数列全て同じ値
        print(int(n / 2))
    else:
        print(0)
else:
    el = evel.most_common(100)
    ol = odd.most_common(100)
    max_val = 0
    for index_e, num_e in el:
        for index_o, num_o in ol:
            if index_e != index_o:
                max_val = max(max_val, num_e + num_o)
    ans = n - max_val
    print(ans)


Measured memory_bytes: 17612
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    set<char> s;
    rep(i, S.size()) {
        s.insert(S[i]);
    }
    if (S.size() == s.size()) {
        cout << "yes" << endl;
    } else cout << "no" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int dp[110][110];
int a[110],b[110];
int f(int l,int r){
	if(dp[l][r])return dp[l][r];
	if(l+1==r)return 0;
	int ans=1e9;
	for(int m=l+1;m<r;m++)ans=min(ans,f(l,m)+f(m,r)+a[l]*a[m]*b[r-1]);
	return dp[l][r]=ans;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",a+i,b+i);
	printf("%d\n",f(0,n));
}


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

#define ff first
#define ss second
#define ll long long
#define W(x) cerr << "\033[31m"<< #x << " = " << x << "\033[0m" << endl;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;
ll oo2 = 1ll*oo*oo;  

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

    vi cnt(m+1, 0);
    int k;
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &k);
        int aux;
        while(k--) {
            scanf("%d", &aux);
            cnt[aux]++;
        }
    }
    int ans = 0;
    for(int k : cnt) ans += (k == n);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 100005;
const int SIZE = 1000;

int main() {
	int N, K;
	int w[SIZE][SIZE] = { {0} };
	int b[SIZE][SIZE] = { {0} };
	int wt[SIZE][SIZE] = { {0} };
	int bt[SIZE][SIZE] = { {0} };

	int ans = 0;
	int wn = 0;
	int bn = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;

		if ((x / K % 2 == 0) ^ (y / K % 2 == 0)) c = c == 'W' ? 'B' : 'W';

		if (c == 'W') {
			w[y % K][x % K] += 1;
			wn++;
		}
		else {
			b[y % K][x % K] += 1;
			bn++;
		}
	}

	ans = max(wn, max(ans, bn));

	for (int i = 0; i < SIZE; i++) {
		for (int j = 0; j < SIZE; j++) {
			if (i != 0) {
				wt[i][j] += wt[i - 1][j];
				bt[i][j] += bt[i - 1][j];
			}
			if (j != 0) {
				wt[i][j] += wt[i][j - 1];
				bt[i][j] += bt[i][j - 1];
			}
			if (i != 0 && j != 0) {
				wt[i][j] -= wt[i - 1][j - 1];
				bt[i][j] -= bt[i - 1][j - 1];
			}
			wt[i][j] += w[i][j];
			bt[i][j] += b[i][j];
		}
	}

	for (int i = 0; i < K; i++) {
		for (int j = 0; j < K; j++) {
			int w1 = wt[i][j];
			int w2 = wt[K - 1][K - 1] - ((wt[K - 1][j] - w1) + (wt[i][K - 1] - w1)) - w1;
			int b1 = bt[K - 1][j] - bt[i][j];
			int b2 = bt[i][K - 1] - bt[i][j];

			ans = max(ans, w1 + w2 + b1 + b2);
			ans = max(ans, (wn - w1 - w2) + (bn - b1 - b2));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  int n = s.size();

  int ans1 = 0, ans2 = 0;
  REP(i,n){
    if(i%2 == s[i]-'0') ans1++;
    else ans2++;
  }

  cout << min(ans1,ans2) << endl; 

  

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
int n, K;
int a[100];
int dp[101][101][256];
int fact[101];

signed main() {
	int i, j, k;
	
	fact[0] = 1;
	rep(i, 101) {
		fact[i + 1] = (i + 1) * fact[i];
		fact[i + 1] %= mod;
	}
	
	cin >> n >> K;
	rep(i, n) cin >> a[i];
	
	dp[0][0][0] = 1;
	rep(i, n) {
		rep(j, i + 1) {
			rep(k, 256) {
				dp[i + 1][j + 1][k ^ a[i]] += dp[i][j][k];
				dp[i + 1][j + 1][k ^ a[i]] %= mod;
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j][k] %= mod;
			}
		}
	}
	
	int ans = 0;
	for (i = 1; i <= n; i++) {
		ans += (fact[i] * dp[n][i][K]) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18688
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

ll xxor(ll n)
{
  if (n % 4 == 1)
  {
    return 1;
  }
  else
  if (n % 4 == 2)
  {
    return n + 1;
  }
  else
  if (n % 4 == 3)
  {
    return 0;
  }
  else
  {
    return n;
  }
}

int main()
{
  ll a, b;
  cin >> a >> b;
  if (a == 0)
  {
    a++;
  }
  ll ans = xxor(a - 1) ^ xxor(b);
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    char s[10001];
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){
        printf("%c",(s[i]-'A'+n)%26+'A');
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClarss
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		int r = 0;
		for(int i = 1; i <= n; i++)
		{
			if((i).ToString().Length%2==1)
				r++;
		}
		Console.WriteLine(r);
	}

	
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>

#define S 200000

int N;
long T, t[S];

int input(){
	std::cin >> N >> T;
	for( int i = 0; i < N; i++ ){
		std::cin >> t[i];
	}
	return 0;
}

int run(){
	long nt = 0, X = 0;
	for( int i = 0; i < N; i++ ){
		if( nt < t[i] ){ nt = t[i]; }
		X += T - (nt - t[i]);
		nt = t[i] + T;
	}
	std::cout << X << std::endl;
	return 0;
}

int main(){
	input();
	run();
	return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
N = 0
H = [0]


def set_inputs():
    global N, H
    N = get_int()
    H = get_list_of_int()


def main():
    set_inputs()
    cost = [inf] * N
    cost[0] = 0
    cost[1] = abs(H[0] - H[1])
    for i in range(2, N):
        cost[i] = min(
            cost[i-1] + abs(H[i] - H[i-1]),
            cost[i-2] + abs(H[i] - H[i-2])
        )
    print(cost[N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 54608
list=[int(i) for i in input().split()]



if list[0]>list[1]:
    a=list[0]
    b=list[1]
else:
    b=list[0]
    a=list[1]    


if a%b==0:
    print(b)
else:
    while b>0:
        c=a%b
        a=b
        b=c
    print(a)


Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll MOD = 1000000007, ans = 0;
	string L;
	cin >> L;
	int N;
	N = L.size();
	vector<bool> dig(N);
	rep(i, N){
		dig[i] = L[i] - '0';
	}
	VVL dp(N, VL (2, 0));
	dp[0][1] = 2;
	dp[0][0] = 1;

	FOR(i, 1, N-1){
		if(dig[i] == 1) dp[i][1] = dp[i-1][1] * 2 % MOD;
		else dp[i][1] = dp[i-1][1];

		dp[i][0] = dp[i-1][0] * 3 % MOD;
		if(dig[i] == 1){
			dp[i][0] += dp[i-1][1];
			dp[i][0] %= MOD;
		}
	}

	ans = dp[N-1][0] + dp[N-1][1];
	ans %= MOD;
	cout << ans << endl;




}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

using namespace std;

using i64 = long long int;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    vector<i64> v(4);
    rep(i, 4) cin >> v[i];
    sort(all(v));
    if(v[0] == v[1] && v[2] == v[3]) cout << "yes" << endl;
    else cout << "no" << endl;
}


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

using ll=long long;
using ld=long double;

void solve(){
	string s;
	cin>>s;
	ll sum=0;
	for(char c:s){
		sum+= (c-'0');
	}
	if(sum%9==0){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> b = a;
    sort(all(a)); reverse(all(a));
    if(a[0] == a[1]){
        for(int i = 0; i < n; i++){
            cout << a[0] << endl;
        }
    }else{
        for(int i = 0; i < n; i++){
            if(b[i] == a[0]){
                cout << a[1] << endl;
            }else{
                cout << a[0] << endl;
            }
        }
    }

    return 0;

}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s.at(i) =='R') {
            count++;
        }
    }
    if (count == 3) {
        cout << 3 << endl;
    }
    else if (count == 2) {
        if (s.at(1) == 'S') {
            cout << 1 << endl;
        }
        else {
            cout << 2 << endl;
        }
    }
    else if (count == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3580
int main(void){
  
  char s[2];
  int i;
  i=0;
  scanf("%s",&s);
  if(s[0]=='1')
    i++;
  if(s[1]=='1')
    i++;
  if(s[2]=='1')
    i++;
  printf("%d",i);
  return 0;
}




Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int n,k,si=0;
    char s[400000];
    scanf("%d %d",&n,&k);
    int tmp=k;
    while(1){
        if(n>=tmp){
            s[si++]=n%k+'0';
            n/=k;
        }
        else{
            s[si++]=n+'0';
            break;
        }
    }
    printf("%d\n",si);
    return 0;
}

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

int main() {
  int N, K, i, min = 1;
  cin >> N >> K;
  for(i = 1; i <= N; i++) {
    if (min <= K) {
      min *= 2;
    } else {
      min += K;
    }
  }
  cout << min;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int K, Q;
LL D[5011];
LL sums[5011];

void MAIN() {
    scanf("%d%d", &K, &Q);
    REP (i, K) scanf("%lld", D+i);

    REP ($, Q) {
	LL n, x, m;
	scanf("%lld%lld%lld", &n, &x, &m);
	REP (i, K) sums[i+1] = sums[i] + D[i] % m;

	LL last = x % m + (n-1) / K * sums[K] + sums[(n-1) % K];
	LL sub = last / m;
	LL zero = 0;
	REP (i, K) if (D[i] % m == 0) {
	    zero += (n-1) / K + (i < (n-1) % K? 1: 0);
	}
	LL ans = n - 1 - sub - zero;
	printf("%lld\n", ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<ll> L (87);
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int w, a, b, c;
    scanf("%d %d %d", &w, &a, &b);
    if (a > b) {
        c = a - b - w;
    } else {
        c = b - a - w;
    }
    printf("%d\n", c > 0 ? c : 0);
    return 0;
}


Measured memory_bytes: 128
mod = 10**9+7
# nCr
def calcComb(n,r):
  mul, div = 1, 1
  for i in range(r):
    mul *= (n-i)
    div *= (i+1)
    mul %= mod
    div %= mod

  return mul * pow(div,mod-2,mod) % mod

n,m = map(int, input().split())

i = 2
ans = 1
while i*i <= m:
  if m%i == 0:
    cnt = 0
    while m!=1 and m%i == 0:
      cnt += 1
      m //= i
    ans *= calcComb(n+cnt-1, n-1)
    ans %= mod
  i += 1

if m != 1:
  ans *= calcComb(n+1-1, n-1)
  ans %= mod

print(ans)


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    cout<<3*n*n;    

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <complex>
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
using namespace std;

typedef complex<double> P;

int n[2];
vector<vector<P>> p;
double ths[100*50*3];
bool solve(){
    if(n[0]==1 && n[1]==1)return true;

    int cnt=0;
    rep(x,2){
        rep(i,n[x])rep(j,i){
            P &p0=p[x][i], &p1=p[x][j];
            double th=arg(p0-p1);
            ths[cnt++]=th;
        }
    }
    rep(i,cnt){
        double th=ths[i];
        auto before = p;
        rep(i,2)rep(j,n[i]){
            p[i][j] /= polar(1. ,th);
        }
        double M[2]={-1e20,-1e20}, m[2]={1e20,1e20};
        rep(i,2)rep(j,n[i]){
            M[i] = max(M[i],p[i][j].imag());
            m[i] = min(m[i],p[i][j].imag());
        }
        if(M[0] < m[1] || M[1] < m[0]) return true;
        p = before;
    }
    return false;
}

int main(){
    while(~scanf("%d%d",&n[0],&n[1]) && n[0]){
        p={{},{}};
        rep(i,2){
            p[i].resize(n[i]);
            rep(j,n[i]){
                int x,y;
                scanf("%d%d",&x,&y);
                p[i][j] = P(x,y);
            }
        }
        puts(solve() ? "YES" : "NO");
    }
}

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

int main() {
  string str;
  while(cin >> str) {
    if(str == "0") break;
    int a = 0,b = 0;
    string s = str.substr(1);
    for(int i=0;i<s.size();i++) {
      if(s.substr(i,1) == "A") {
        a++;
      }
      else if(s.substr(i,1) == "B") {
        b++;
      }
    }
    if(a<b) {
      cout << a << " " << b+1 << endl;
      continue;
    }
    else {
      cout << a+1 << " " << b << endl;
      continue;
    }
  }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

ll n,m,v,p;
vector<ll> vec;
umap<ll,bool> mm;

bool ok(ll x){
  if(mm.count(x) > 0)return mm[x];
  ll wnt = (v - (n - x)) * m;
  ll y = vec[x] + m;
  {
    if(vec.rend()-upper_bound(vec.rbegin(), vec.rend(), y)>=p)return false;
    // ll pcnt = 0;
    
    // for(int i = 0; i < x; ++i){
    //   if(vec[i] > y)pcnt++;
    // }
    // if(pcnt >= p) return false;
  }
  for(int i = 0; i < x; ++i){
    if(vec[i] < y) wnt -= y - vec[i];
  }
  ll pcnt = 0;
  int idx = 0;
  while(wnt > 0){
    // debug(idx);
    // debug(wnt);
    // debug(pcnt);
    if(vec[idx] > y){
      pcnt++;
      wnt -= m;
    } else if(vec[idx] + m > y){
      pcnt++;
      wnt -= vec[idx] + m - y;
    }
    if(pcnt >= p) return false;
    idx++;
  }
  return true;
}

int main(){
  cin >> n >> m >> v >> p;
  vec.resize(n); cin >> vec;
  sort(vec.rbegin(),vec.rend());
  ll l = 0, r = n;
  while(r - l > 1){
    ll mid = (l + r) / 2;
    mm.insert({mid,ok(mid)});
    if(mm[mid]) l = mid;
    else r = mid;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#define INF 10000000
typedef struct{
	int node;
	int cost;
} List;

int dist[101];
List list[101][101];
int kazu[101];

int n;

void walk(int x,int step){
	dist[x]=step;
	for(int i=0;i<kazu[x];i++){
		if(dist[list[x][i].node]>step+list[x][i].cost) walk(list[x][i].node,step+list[x][i].cost);
	}
}

int main(void){
	int i,j,w;
	int num;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num);
		scanf("%d",kazu+num);
		for(j=0;j<kazu[num];j++)scanf("%d %d",&(list[num][j].node),&list[num][j].cost);
	}
	for(i=0;i<n;i++) dist[i]=INF;
	walk(0,0);
	
	for(i=0;i<n;i++){
		printf("%d %d\n",i,dist[i]);
	}
	return 0;
}

Measured memory_bytes: 1108
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#define MAXN 15
using namespace std;
char malt[MAXN][MAXN];
int n, m;
bool inMap(int x, int y)
{
    if(x < 0 || x >= n || y < 0 || y >= m) return false;
    else
        return true;
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%s", malt[i]);
    int num = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(malt[i][j] == '#') num++;
        }
    }
    bool flag = true;
    int x = 0, y = 0, tmp = 1;
    if(malt[0][0] != '#' || malt[n - 1][m - 1] != '#') flag = false;
    while(x != n - 1 || y != m - 1)
    {
        //cout << x << " " << y << endl;
        if(inMap(x + 1, y) && malt[x + 1][y] == '#')
        {
            tmp++;
            x = x + 1, y = y;
        }
        else if(inMap(x, y + 1) && malt[x][y + 1] == '#')
        {
            tmp++;
            x = x, y = y + 1;
        }
        else
        {
            flag = false;
            break;
        }
    }
    if(flag && tmp == num) puts("Possible");
    else
        puts("Impossible");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

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

    string sumS;
    rep(i, S.size()) {
        switch (S[i]) {
        case '0':
            sumS += '0';
            break;
        case'1':
            sumS += '1';
            break;
        case'B':
            if (!sumS.empty()) {
                sumS.erase(sumS.size() - 1, 1);
            }
            break;
        }
    }
    cout << sumS << endl;
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int n, ans = 0;
    cin >> n;
    rep1(i,n){
        ans += (n-1) / i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	/*
	なんでこれで通るんだ？
	*/
	
	int n, m; cin >> n >> m;
	vector<pi> e, ans;
	set<int> dead;
	rep(i, m){
		int a, b; cin >> a >> b; a--; b--;
		e.emplace_back(a, b);
	}
	
	rep(s, n){
		vi mark(n);
		mark[s] = 1;
		for(int i = m - 1; i >= 0; i--){
			int a = e[i].first, b = e[i].second;
			if(mark[a] && mark[b]){
				dead.insert(s);
				goto SKIP;
			}
			if(mark[a]) mark[b] = 1;
			else if(mark[b]) mark[a] = 1;
		}
		SKIP:;
	}
	
	rep(s, n) if(!dead.count(s)){
		vi mark(n);
		mark[s] = 1;
		for(int i = m - 1; i >= 0; i--){
			int a = e[i].first, b = e[i].second;
			if(mark[a] && mark[b]) goto NEXT;
			if(mark[a]) mark[b] = 1;
			else if(mark[b]) mark[a] = 1;
		}
		rep(i, m){
			int a = e[i].first, b = e[i].second;
			if(mark[a]) mark[b] = 1;
			else if(mark[b]) mark[a] = 1;
		}
		rep(i, s) if(!mark[i] && !dead.count(i)) ans.emplace_back(i, s);
		NEXT:;
	}
	cout << ans.size() << endl;
	//for(pi p : ans) dbg(p.first + 1, p.second + 1);
	
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
stack<char> sta;

int main(){
    int a; cin >> a;
    cout <<  a + a*a + a*a*a  << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll L = 0;
    ll ans = 1;
    REP(i, 2 * N) {
        if (S[i] == 'W') {
            if (L % 2 == 0) {
                ans = (ans * L) % MOD;
                L--;
            }
            else
                L++;
        }
        else {
            if (L % 2 == 0)
                L++;
            else {
                ans = (ans * L) % MOD;
                L--;
            }
        }
    }
    if (L != 0)
        ans = 0;

    REP(i, N) {
        ans = (ans * (i + 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
s=int(input())
a=[]
a.append(s)
def has_duplicates(seq):
    if len(seq) != len(set(seq)):
        return True
    else:
        return False
i=0
while has_duplicates(a)==False:
    if a[i]%2==0:
        a.append(int(a[i]/2))
    else:
        a.append(int(3*a[i]+1))
    i+=1
print(len(a))

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

int main()
{
    int n;
    ll ans = 1;
    cin >> n;
    vector<ll> A(n);
    ll max = pow(10,18);

    rep(i, n)
    {
        ll a;
        cin >> a;
        if (a == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        A[i] = a;
    }

    rep(i, n)
    {
        if (A[i] > max / ans)
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
}

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

int main(void){
    ll n, t, m=0, ans=0;
    cin >> n >> t;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        if(x+t>m){
            if(x>=m) ans+=t;
            else ans+=t-(m-x);
        }
        m=max(m, x+t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  int n;
  cin >> n;
  ll ans = 0;
  vl A(n);
  rep(i,n){
    cin >> A[i];
  }
  rep(i,n){
    if(A[i]==0) continue;
    ans+=A[i]/2;
    if(i+1 == n) continue;
    if(A[i]%2 == 0 || A[i+1]==0)continue;
    ans+=1;
    A[i+1]--;
  }

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

Measured memory_bytes: 1152
from math import factorial as fac

S = int(input())
ans = 0

if S == 1 or S == 2:
  print(0)
elif S == 3:
  print(1)
else:
  for k in range(1,S):
    if S-2*k-1 >= 0 and S-3*k >= 0:
      ans += fac(S-2*k-1)//(fac(k-1)*fac(S-3*k))
  print(ans%1000000007)

Measured memory_bytes: 9160
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.nextLine();
		
		char x = s1.charAt(0);
		if(x == 'S')
		    System.out.println("Cloudy");
		else if(x == 'C')
		    System.out.println("Rainy");
		if(x == 'R')
		    System.out.println("Sunny");
	}
}


Measured memory_bytes: 21844