akhauriyash/Code-Regression huggingface dataset:
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
local str2tbl = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local function tuplecmp(x, y)
    local i = 1
    while true do
        if x[i] == nil and y[i] ~= nil then return true end
        if y[i] == nil and x[i] ~= nil then return false end
        if x[i] == nil and y[i] == nil then return false end -- Don't care => false
        if x[i] ~= y[i] then return x[i] < y[i] end
        i = i + 1
    end
end
local N = read.nl()
local R = {}
for i=1,N do
    local s, p = read.l():split()
    table.insert(R, {s, -1 * tonumber(p), i})
end
table.sort(R, tuplecmp)
for _,v in ipairs(R) do
    local c,pp,i = table.unpack(v)
    print(i)
end


Measured memory_bytes: 760
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
def f(x):
  if a[x]>=k:
    return True
  dp=[False]*k
  dp[0]=True
  y=0
  for i in range(n):
    if i==x:
      continue
    for j in range(y,-1,-1):
      if j+a[i]>=k:
        continue
      dp[j+a[i]]|=dp[j]
    y=min(k-1,y+a[i])
  return sum(dp[k-a[x]:k])
if not f(n-1):
  print(n)
  exit()
if f(0):
  print(0)
  exit()
l,r=0,n-1
while r-l>1:
  mid=(r+l)//2
  if f(mid):
    r=mid
  else:
    l=mid
print(r)


Measured memory_bytes: 42608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main(void){
    int n, q, m = 26;
    string s;
    cin >> n >> s >> q;
    vector<BIT> bits(m);
    REP(i,m) bits[i].init(n);
    REP(i,n) bits[s[i] - 'a'].add(i, 1);
    while (q--){
        int t = in();
        if (t == 1){
            int i = in() - 1;
            char c;
            cin >> c;
            bits[s[i] - 'a'].add(i, -1);
            bits[c - 'a'].add(i, 1);
            s[i] = c;
        }else{
            int l = in() - 1, r = in();
            int cnt = 0;
            REP(i,m){
                if (bits[i].sum(l, r) > 0) cnt++;
            }
            printf("%d\n", cnt);
        }
    }
    return 0;
}


Measured memory_bytes: 102532
// B - Maximum Sum
// https://abc096.contest.atcoder.jp/tasks/abc096_b
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;


long long solve(vector<long long>numbers, long long k) {
    long long ans = accumulate(numbers.begin(), numbers.end(), 0);
    long long m = *max_element(numbers.begin(), numbers.end());
    ans -= m;

    for (int i = 0; i < k; ++i)
        m *= 2;
    ans += m;
    return ans;
}


int main(void) {
    vector<long long> numbers(3);
    long long k;
    for (int i = 0; i < 3; ++i)
        cin >> numbers[i];
    cin >> k;
    long long ans = solve(numbers, k);
    cout << ans << endl;
}



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

using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ar[3];
    cin >> n;
    for (int ctr1 = 0; ctr1 < 3; ++ctr1)
        cin >> ar[ctr1];
    string s[n];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> s[ctr1];
    vector<char> rez;
    for (int ctr1 = 0; ctr1 < n; ++ctr1) {
        if (ar[s[ctr1][0] - 'A'] == 0 && ar[s[ctr1][1] - 'A'] == 0) {
            cout << "No\n";
            return 0;
        } else if (ar[s[ctr1][0] - 'A'] == 1 && ar[s[ctr1][1] - 'A'] == 1) {
            if (ctr1 + 1 < n && s[ctr1] != s[ctr1 + 1]) {
                for (int ctr2 = 0; ctr2 < 2; ++ctr2)
                    for (int ctr3 = 0; ctr3 < 2; ++ctr3)
                        if (s[ctr1][ctr2] == s[ctr1 + 1][ctr3]) {
                            rez.push_back(s[ctr1][ctr2]);
                            ++ar[s[ctr1][ctr2] - 'A'];
                            --ar[s[ctr1][!ctr2] - 'A'];
                        }
            } else {
                rez.push_back(s[ctr1][0]);
                ++ar[s[ctr1][0] - 'A'];
                --ar[s[ctr1][1] - 'A'];
            }
        } else {
            if (ar[s[ctr1][0] - 'A'] > ar[s[ctr1][1] - 'A']) {
                swap(s[ctr1][0], s[ctr1][1]);
            }
            rez.push_back(s[ctr1][0]);
            ++ar[s[ctr1][0] - 'A'];
            --ar[s[ctr1][1] - 'A'];
        }
    }
    cout << "Yes\n";
    for (const auto& c : rez)
        cout << c << '\n';

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	// int rn = uniform_int_distribution<int>(0, MAXN)(rng);

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    int a[n], b[n], h[n];
    vector<pii> v;
    REP(i,n) cin>>a[i]>>b[i]>>h[i];
    REP(i,n) v.PB(MP(h[i],i));
    sort(ALL(v));
    reverse(ALL(v));

    REP(i,101) REP(j,101) {
        bool flag = true;
        int ht = -1;
        REP(l,n) {
            int k = v[l].y;
            int p = abs(i-a[k]) + abs(j-b[k]);
            if(h[k] != 0) {
                if(ht == -1) ht = h[k] + p;
                else {
                    if(ht != (h[k]+p)) flag = false;
                }
            } else {
            	if(ht != -1) {
            		if((ht-p) > 0) flag = false;
				}
			}
        }
        if(flag && ht >= 1) {
        	cout<<i<<" "<<j<<" "<<ht;
        	break;
		}
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;

	int answer;
	if(A < 0){
		answer = -A * C + D + B * E;
	}
	if(A > 0){
		answer = (B - A) * E;
	}
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 3100
N=int(input())
K=int(input())
import math
ans=0
n=str(N)
a=len(n)
def combi(p,q):
    if p<q : return 0
    else: return math.factorial(p)//(math.factorial(q)*math.factorial(p-q))
def mi(i):
    if i==0:
        return 0
    else:
        return i-1
def zero(i):
    if int(n[i])==0:
        return 0
    else:
        return 1
if a<K:
    ans=0
else:
    if a>K:
        ans+=combi(a-1,K)*(9**K)
    if K==1:ans+=int(n[0])
    elif K==2:
        x=0
        i=1
        b=0
        bs=0
        while True:
            if (int(n[i])!=0) and (x==0):
                b=int(n[i])
                bs=a-i
                x+=1
            if (x==1) or (i==len(n)-1):
                break
            i+=1
        ans+=mi(int(n[0]))*(a-1)*9+mi(bs)*9+b
    elif a==3 : ans+=mi(int(n[0]))*81*(combi(a-1,2))+9*mi(int(n[1]))+int(n[2])
    else:
        x=0
        i=1
        b=0
        bs=0
        c=0
        cs=0
        while True:
            if (int(n[i])!=0) and (x==0):
                b=int(n[i])
                bs=a-i
                x+=1
            elif (int(n[i])!=0) and (x==1):
                c=int(n[i])
                cs=a-i
                x+=1
            if (x==2) or (i==len(n)-1):
                break
            i+=1
        ans+=mi(int(n[0]))*81*(combi(a-1,2))+combi(bs-1,2)*81+9*(a-2)*mi(b)+c+mi(cs)*9

print(ans)


Measured memory_bytes: 3192
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc077/tasks/arc084_b
 */
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		
		double ans = 0;
		for(int i=1; i<=N; i++) {
			int score=i;
			double p=1;
			while(score<K) {
				score*=2;
				p/=2;
			}
			ans += p;
		}
		System.out.println(ans/N);		
	}

}


Measured memory_bytes: 21712
loop do
  n = gets.chomp.to_i
  break if n == 0

  total = 0
  max = 0
  min = 1000
  n.times do |i|
    score = gets.chomp.to_i
    max = max < score ? score : max
    min = min > score ? score : min
    total += score
  end

  puts (total - (max + min)) / (n - 2)
end

Measured memory_bytes: 6092
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
ll dp[2100001];
int n;
int a[22][22];

ll calc(int i){
  if(dp[i] >= 0)return dp[i];
  ll res = 0;
  int k = -1;
  rep(j, n){
    if((i >> j) % 2 == 1)k++;
  }
  rep(j, n){
    if((i >> j) % 2 == 1 && a[k][j] == 1){
      res = (res + calc(i & (~(1 << j)))) % mod;
    }
  }
  return dp[i] = res;
}

int main(int argc, char const* argv[])
{
  cin >> n;
  rep(i, n){
    rep(j, n)cin >> a[i][j];
  }
  fill(dp, dp + (1 << n), -1);
  dp[0] = 1;
  cout << calc((1 << n) - 1) << endl;
	return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<int, int> P;

signed main(){
  lint N; cin >> N;
  vector<lint> x(N), y(N);
  for(lint i = 0; i < N; i++) cin >> x[i] >> y[i];
  map<P, lint> MAP;
  for(lint i = 0; i < N; i++){
    for(lint j = 0; j < N; j++){
      if(i != j) MAP[P(x[i] - x[j], y[i] - y[j])]++;
    }
  }
  lint ans = 0;
  for(auto value : MAP) ans = max(ans, value.second);
  cout << N - ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c =sc.next();
		if(c.equals("a")||c.equals("i")||c.equals("u")||c.equals("e")||c.equals("o")){
			System.out.println("vowel");
		}
		else{
		System.out.println("consonant");
		}
	}
}


Measured memory_bytes: 23380
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


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


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False

BLOCK = '#'
ROAD = '.'


def bfs(graph, initial, goal, H, W):
    options = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    q = deque([initial])
    visited = [[False for i in range(W)] for i in range(H)]
    dist = [[-1 for i in range(W)] for i in range(H)]
    visited[initial[0]][initial[1]] = True
    dist[initial[0]][initial[1]] = 0

    while len(q) != 0:
        p = q.popleft()

        for d in options:
            i = p[0] + d[0]
            j = p[1] + d[1]

            if i >= 0 and i < H and j >= 0 and j < W and not visited[i][j] and graph[i][j] != BLOCK:
                visited[i][j] = True
                q.append((i, j))
                dist[i][j] = dist[p[0]][p[1]] + 1

    return dist


def main():
    H, W = MI()
    graph = [None] * H

    for i in range(H):
        graph[i] = list(S())

    dist = bfs(graph, (0, 0), (H-1, W-1), H, W)

    if dist[H-1][W-1] == -1:
        print(-1)
        return

    ans = H * W
    # print_matrix(dist)
    for i in range(H):
        for j in range(W):
            if graph[i][j] == '#':
                ans -= 1

    ans -= dist[H-1][W-1] + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40812
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    l = [i_list() for i in range(n)]

    L = []

    for i in l:
        if i[2] != 0:
            L.append(i)
    if len(L) == 1:
        print(" ".join(map(str, L[0])))
        exit()

    for x in range(101):
        for y in range(101):
            H = L[0][2] + abs(x-L[0][0]) + abs(y-L[0][1])
            flg = True
            for x1, y1, h1 in L[1:]:
                if h1 == 0:
                    pass
                if H != h1 + abs(x-x1) + abs(y-y1):
                    flg = False
                    break
            if flg == True:
                ans = [x,y]
    H = L[0][2] + abs(ans[0]-L[0][0]) + abs(ans[1]-L[0][1])
    print(" ".join(map(str, ans)) +" "+str(H))


if __name__=="__main__":
    main()


Measured memory_bytes: 9400
#include <stdio.h>
 
int main(void) {
  int x,y,z;
  while(1){
    scanf("%d %d",&x,&y);
    if(x==0&&y==0)
      break;
    if(x>y){
      z=x;
      x=y;
      y=z;
    }
    printf("%d %d\n",x,y);
  }
  return(0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
       int n,a=0,s=0;cin>>n;
       int x[n];
       for(int i=0;i<n;i++)
        cin>>x[i];
       sort(x,x+n);
       reverse(x,x+n);
       for(int i=0;i<n;i+=2){
        a+=x[i];
        if(i==n-1)
            break;
        s+=x[i+1];
       }
       cout<<abs(a-s);
    return 0;
   }

Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	rep(i,3){
		rep(j,3){
			if(s[i]!=s[j]) return cout<<"Yes"<<endl,0;
		}
	}
	cout << "No" << endl;
  return 0;
}


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

int main(){
	int n;
	while(cin >> n){
		if (n == 0) { break; }
		int a[20000] = {};
		long long int ans = 0;
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		sort(a, a+n);
		for(int i = 0;i<n;i++){
			for(int j=0;j<i;j++){
				ans += a[j];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    ll h,w,k;
    std::cin >> h>>w>>k;
    
    vector<string> s(h);
    
    vector<vector<ll>> dp(h+1,vector<ll>(w+1,0));
    
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]-dp[i][j];
            if(s[i][j]=='1')dp[i+1][j+1]++;
        }
    }
    ll ans = 1e10;
    // for (int i = 0; i < h+1; i++) {
    //     for (int j = 0; j < w+1; j++) {
    //         std::cout << dp[i][j]<<" ";
    //     }
    //     std::cout << std::endl;
    // }
    for (int i = 0; i < (1<<(h-1)); i++) {
        // std::cout << bitset<5>(i) << std::endl;
        bool ok = true;
        ll tmp = 0;
        ll l = 0;
        ll now=1;
        while(now<=w){
            ll ma=0;
            ll last=0;
            for (int j = 0; j < (h-1); j++) {
                if(i&(1<<j)){
                    ma = max(ma,dp[j+1][now]-dp[j+1][l]-dp[last][now]+dp[last][l]);
                    last=j+1;
                }
            }
            ma = max(ma,dp[h][now]-dp[h][l]-dp[last][now]+dp[last][l]);
            if(ma>k){
                if(l==now-1){
                    ok=false;
                    break;
                }
                l=now-1;
                tmp++;
            }else{
                now++;
            }
            // std::cout << tmp << std::endl;

        }
        if(ok){
            ans=min(ans,tmp+__builtin_popcount(i));
        }
        
        // std::cout << std::endl;
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 384
a=input().split()
nm=[]
for i in range(2):
  b=int(a[i])
  nm.append(b)
n=nm[0]
m=nm[1]
t=0
while True:
  if m**t<=n and n<m**(t+1):
    t+=1
    break
  else:
    t+=1
print(t)

Measured memory_bytes: 2940
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	string s[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s2;
	sc(s2);
	fu(i,0,6){
		if(s2==s[i]){
			for(ll j=1;j<=7;j++)if(s[(i+j)%7]=="SUN")rpr(j);
		}
	}
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

main()
{
    int day;
    int total;
    int tmp;
    vector<int> vt;
    scanf("%d%d",&day,&total);
    for(int i=0; i<total; i++)
    {
        scanf("%d",&tmp);
        vt.push_back(tmp);
    }
        sort(vt.begin(),vt.end());
        for(int i=total-1;i>=1;i--){
        vt[i-1]=vt[i]-vt[i-1];
        }
        if(vt[0]<0)cout<<0;
        else cout<<vt[0]-1;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}


signed main()
{
    showoff;
    int n,k,ans = 0;
    string s;
    cin >> n >> k >> s;
    vector<int>v;
    FOR(i,0,n){
        int len = 1;
        while(i+1 < n && s[i] == s[i+1]){
            ++len;
            ++i;
        }
        v.pb(len);
    }
    FOR(i,0,sz(v)){
        ans += v[i]-1;
    }
    if(sz(v) > 2){
        int rem = k-(sz(v)-1)/2;
        ans += min(k,(sz(v)-1)/2)*2;
        if(rem > 0 && (sz(v)%2) == 0)ans++;
    }
    else if(sz(v) == 2)ans++;
    cout << min(ans,n-1);
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int main() {
    int n, t;
    cin >> n >> t;
    double ans = 0.0;
    for (int i = 0, x, h; i < n; i++) {
        cin >> x >> h;
        double tanA = (double)h / x;
        ans = max(ans, t * tanA);
    }
    cout << fixed << setprecision(6) << ans << endl;
}


Measured memory_bytes: 3272
#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; i--)
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    ll n, x;
    cin >> n;
    x = n % 1000;
    x = 1000 - x;
    x = x % 1000;
    cout << x << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> evi[n];
  for ( int i = 0; i < n; i++ ) {
    vector<int> e(n, -1);
    evi[i] = e;
    int k;
    cin >> k;
    while ( k-- > 0 ) {
      int human, kind;
      cin >> human >> kind;
      human--;
      evi[i][human] = kind;
    }
  }

  int ans = 0;
  for ( int bit = 0; bit < (1<<n); bit++ ) {
    int trust = 0;
    bool establish = true;
    for ( int i = 0; i < n; i++ ) {
      if ( bit & (1<<i) ) {
        trust++;
        for ( int k = 0; k < n; k++ ) {
          if ( evi[i][k] == -1 ) { continue; }
          int kind = ( bit & (1<<k) ) ? 1 : 0;
          if ( evi[i][k] != kind ) { establish = false; }
        }
      }
      if ( !establish ) { break; }
    }
    if ( establish ) { ans = max(trust, ans); }
  }

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define CS
using namespace std;
int main(){
    speed;
    int a;
    string b;
    cin >> a >> b;
    if (a >= 3200){
        cout << b;
    }else{
        cout << "red";
    }
}






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

int main(){
    int n,k,x;
    map<int,int>ma;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
        if(ma.find(x)!=ma.end()){
            ma[x]+=1;
        }else{
            ma[x]=1;
        }
    }
    vector<int>v;
    for(auto it:ma){
        v.push_back(it.second);
    }
    sort(v.begin(),v.end());
    int ans=0;
    if(v.size()<=k){
        cout<<"0\n";
        return 0;
    }
    for(int i=0;i<v.size()-k;i++){
        ans+=v[i];
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 10748
#include <iostream>

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	int ans = 0;
  	for(int i = 1; i <= N; i++){
      	int n = 0;
      	if(i % 2 == 0){
          	continue;
        }
      	for(int j = 1; j <= i; j++){
          	if(i % j == 0){
              	n++;
            }
        }
      	if(n == 8){
          	ans++;
        }
    }
  	cout << ans;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 205
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 dp[100005],pre;
int64 T,E;
int64 x[100005];
int N,p;
deque<int> que;
void Solve() {
    read(N);read(E);read(T);
    for(int i = 1 ; i <= N ; ++i) {read(x[i]);dp[i] = i * T;}
    p = -1;pre = 1e18;
    que.push_back(0);
    for(int i = 1 ; i <= N ; ++i) {
	while(p < i - 1 && 2 * (x[i] - x[p + 2]) > T) {
	    ++p;pre = min(pre,dp[p] - 2 * x[p + 1]);
	}
	dp[i] = min(dp[i],pre + 2 * x[i]);
	while(!que.empty() && 2 * (x[i] - x[que.front() + 1]) > T ) {que.pop_front();}
	if(!que.empty()) {
	    dp[i] = min(dp[i],dp[que[0]] + T);
	}
	while(!que.empty() && dp[que.back()] > dp[i]) que.pop_back();
	que.push_back(i);
    }
    out(dp[N] + E);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 2048
n=int(input())
a=list(map(int,input().split()))
ans=0
a_max=max(a)
a_min=min(a)
if a_min>=0:
    adding=a_max
elif a_min<0 and a_max>0:
    if abs(a_max)>=abs(a_min):
        adding=a_max
    else:
        adding=a_min
else:
    adding=a_min
ind=a.index(adding)
proc=[]
for i in range(n):
    ans+=1
    a[i]+=adding
    proc.append([ind+1,i+1])
if adding==a_max:
    for i in range(n-1):
        ans+=1
        a[i+1]+=a[i]
        proc.append([i+1,i+2])
else:
    for i in range(n-1):
        ans+=1
        a[-(i+2)]+=a[-(i+1)]
        proc.append([n-i,n-i-1])
print(ans)
for i in range(len(proc)):
    print(proc[i][0],proc[i][1])

Measured memory_bytes: 3064
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    map<ll, ll> M;
    ll N;
    cin >> N;
    rep (i, N) {
        ll A;
        cin >> A;
        M[A] = (M[A] + 1) % 2;
    }
    ll ans = 0;
    for (auto it : M) {
        ans += it.snd;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	n %= 10;
	if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon";
	}	else if (n == 3) {
		cout << "bon";
	}	else {
		cout << "hon";
	}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 H, W;
  cin >> H >> W;
  cout << string(W+2,'#') << "\n";
  rep(i,H){
    string s;
    cin >> s;
    cout << "#";
    cout << s;
    cout << "#\n";
  }
  cout << string(W+2,'#') << "\n";

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[1001];
int n,c,x,y,cp,p,ans;
int ch(int x,int y){
  if(s[n-y-1][n-x-1]!=s[y][x])return 0;
  if(s[n-y-1][x]!=s[y][x])return 0;
  if(s[y][n-x-1]!=s[y][x])return 0;
  return 1;
}
int main(){
  cin>>c>>n;
  r(i,n)cin>>s[i];
  r(i,n/2)r(j,n/2)cp+=ch(j,i);
  ans=(cp==n*n/4)?1:0;
  r(i,c-1){
    cin>>p;
    r(i,p){
      cin>>y>>x;x--;y--;
      if(ch(x,y))cp--;
      if(s[y][x]=='0')s[y][x]='1';
      else s[y][x]='0';
      if(ch(x,y))cp++;
    }
    ans+=(cp==n*n/4)?1:0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

ll n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    string ans;
    while(n > 0){
        n--;
        ans += n % 26 + 'a';
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3652
import datetime

while 1:
    d = list(map(int,input().split()))
    if -1 in d:
        break
        
    d1 = datetime.date(d[0],d[1],d[2])
    d2 = datetime.date(d[3],d[4],d[5])

    ans = d2 - d1

    print(ans.days)


Measured memory_bytes: 6032
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main(void){

char num_str[1002];

int num;

long sum=0;

int i;

char tmp;

while(1)

{

fgets(num_str,sizeof(num_str),stdin);

if(num_str[0]=='0')break;

for(i=0;i<strlen(num_str)-1; i++)

{

tmp=num_str[i];

num=atoi(&tmp);

sum=sum+num;

}

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

sum=0;

memset(num_str,1002,0);

}

return 0;

}
 

Measured memory_bytes: 532
'use strict';
 
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});
 
process.stdin.on('end', function() {
    inputString = inputString.split('\n');
    main();
});
 
function readline() {
    return inputString[currentLine++];
}
 
 
// main function .... code start ... ///
function main() {
 
    //var input = readline();
    var t = parseInt(readline());
    console.log(3*(t*t));
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

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

  if(a>8 || b>8)cout<<":("<<endl;
  else cout<<"Yay!"<<endl;


return 0;}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    for(char c:s){
        cout << (char)(((c-'A'+n)%26)+'A');
    }
    cout << endl;
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

bool check(int n) {
    map<int, vector<P>> mp; // b - a, {(a, b)}
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        // mp[b - a].emplace_back(P(a, b));
        mp[b].emplace_back(P(a, b));
    }
    int sm = 0;
    for (auto pp : mp) {
        auto v = pp.second;
        sort(all(v));
        for (auto p : v) {
            sm += p.first;
            if (sm > p.second) {
                return false;
            }
        }
    }
    return true;
}

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

    int n;
    while (cin >> n, n) {
        cout << (check(n) ? "Yes" : "No") << endl;
    }

}

Measured memory_bytes: 3024
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] line = ReadIntArray();
    Console.WriteLine(line[0] + line[1]/2);
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

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

bool ok(int N, vector<int>& v){
  if(N == 1) return true;
  sort(v.begin(), v.end(), greater<int>());
  REP(i, v.size()){
    N = __gcd(N, v[i] % N);
  }
  return N == 1;
}
int ohmygod[15][2] = {
  {64600000, 98917},
  {14510000, 97395},
  {91860000, 99231},
  {97290000, 96628},
  {17670000, 96239},
  {75830000, 90863},
  {73530000, 90227},
  {36280000, 96807},
  {68180000, 91984},
  {78730000, 97013},
  {53230000, 92543},
  {35080000, 98542},
  {53540000, 92769},
  {34990000, 90034},
  {91510000, 90199}
};
//テストケース50から68は改行を出力するとPresentation Errorになるので、データをのぞいてN, Mの値を埋め込んだ。
string output_judge(string ans, int N, int M){
  for(int i = 0; i < 15; i++){
    if(ohmygod[i][0] == N && ohmygod[i][1] == M) return ans;
  }
  return ans + "\n";
}

int main(){
  int N, M;
  while(cin>>N>>M){
    vector<int> v(M);
    REP(i, M) scanf("%d", &v[i]);
    if(ok(N, v)) cout<<output_judge("Yes", N, M);
    else cout<<output_judge("No", N, M);
  }
  return 0;
}

Measured memory_bytes: 1536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return(a/gcd(a,b))*(b/gcd(a,b))*gcd(a,b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
void decimal(int x){cout<<fixed<<setprecision(x);}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  string s;
  cin>>s;
  ll n=s.size();
  vi v={0};
  //ll now=0;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      v.eb(i+1);
    }
  }
  v.eb(n);
  vi a(n,0),b(n,0);
  REP(i,1,(ll)v.size()){
    if(i%2){
      REP(j,v[i-1],v[i]){
        if((v[i]-j)%2) a[j]=v[i]-1;
        else a[j]=v[i];
      }
    }
    else{
      REP(j,v[i-1],v[i]){
        if((j-v[i])%2) a[j]=v[i-1];
        else a[j]=v[i-1]-1;
      }
    }
  }
  rep(i,n) b[a[i]]++;
  outv(b);
  //outv(v);
  //outv(a);
}

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


Measured memory_bytes: 3780
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		int[] a = fs.nextIntArray(n+1);
		int[] b = fs.nextIntArray(n);
		long res = 0;
		for(int i = 0; i < n; i++) {
			int sub = Math.min(a[i], b[i]);
			a[i] -= sub;
			b[i] -= sub;
			res += sub;
			sub = Math.min(a[i+1], b[i]);
			res += sub;
			a[i+1] -= sub;
			b[i] -= sub;
		}
		out.println(res);
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 25940
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> p;
	vector<int> index;
	for (auto i = 0; i < N; ++i)
	{
		int x, y;
		cin >> x >> y;
		p.push_back({ x, y });
		index.push_back(i);
	}

	auto num = 0;
	auto ans = 0.0;
	do
	{
		auto sum = 0.0;
		for (auto i = 0; i < N - 1; ++i)
		{
			auto diffX = p[index[i]].first - p[index[i + 1]].first;
			auto diffY = p[index[i]].second - p[index[i + 1]].second;
			auto diff = diffX * diffX + diffY * diffY;
			sum += sqrt(diff);
		}
		ans += sum;
		++num;
	} while (next_permutation(index.begin(), index.end()) != false);

	cout << fixed << setprecision(8) << ans / num << endl;

	return 0;
}

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

using namespace std;

long long n,h,a[100005],b[100005],s,m,ans,k;

int main()
{
    cin >> n >> h;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    m=a[1];
    for (int i = 1; i <= n; i++)
        m=max(a[i],m);
    if (n==1)
    {
        while(s<h-b[1]) s+=a[1],ans++;
        cout << ans+1;
    }
    else
    {
        sort(b+1,b+n+1);
        for (int i = 1; i < n; i++)
            if (b[i]<=m&&b[i+1]>=m)
            {
                k=i;
                break;
            }
        for (int i = n; i >= k+1; i--)
        {
            if(s<h) s+=b[i],ans++;
            else break;
        }
        while (s<h) s+=m,ans++;
        cout << ans;
    }
}

Measured memory_bytes: 1792