akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

static class SortingFiveNumbers
{
    static void Main()
    {
        Console.WriteLine( Console.ReadLine()
            .Split( ' ' )
            .Select( int.Parse )
            .OrderByDescending( x => x )
            .Select( x => x.ToString() )
            .Aggregate( (x, y) => x + " " + y ) );
    }
}

Measured memory_bytes: 14584
import math
def main():
  M,D = map(int,input().split())
  if D < 22:
       print(0)
       return
  cnt = 0
  for i in range(D + 1):
      if 2 <= (i/10) and 2 <= (i%10) and math.floor(i/10)*(i%10) <= M:
          cnt += 1
  print(cnt)
  
main()

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main(){
	string s;
	cin >> s;
	int i = 0, c = 0,
	maxi = 0;
	while (i < 3) {
		if (s[i] == 'S') {
			i++;
			c = 0;
			continue;
		}
		if (s[i] == 'R' && i < 3) {
			c++;
			i++;
		}
		maxi = max(maxi, c);
	}
	cout << maxi << "\n";
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int ax = 0;
        int bx = 0;
        int cx = 0;
        int ans = 0;

        for (int i = 0; i < 1001; i++) {
            if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
                ax = (b / 2) + (c / 2);
                bx = (a / 2) + (c / 2);
                cx = (a / 2) + (b / 2);
                a = ax;
                b = bx;
                c = cx;
                ans += 1;
            } else {
                break;
            }
        }
        if (ans >= 1000) {
            ans = -1;
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 22612
def calc(s, ary)
    if ary[0] == 0 && ary[1] == 0
        if $j
            $ans[-1] = $j
            ary[0] = 1
            ary[1] = 1
            ary[2] = 0
            $ans << ($j == s[0] ? s[1] : s[0])
            true
        else
            false
        end
    elsif ary[0] == 1 && ary[1] == 1
        $j = s[1]
        ary[0] = 2
        ary[1] = 0
        $ans << s[0]
        true
    else
        if ary[0] < ary[1]
            $ans << s[0]
            ary[0] += 1
            ary[1] -= 1
        else
            $ans << s[1]
            ary[0] -= 1
            ary[1] += 1
        end
        true
    end
end

n, *abc = gets.split.map(&:to_i)
$ans = []
i = true
$j = nil

n.times do 
    s = gets.chomp
    next if !i

    if s == "AB"
        i = calc(s, abc)
    elsif s == "BC"
        i = calc(s, abc.rotate!)
        abc.rotate!(2)
    else
        i = calc("CA", abc.rotate!(2))
        abc.rotate!
    end
end

if i
    puts "Yes"
    puts $ans
else
    puts "No"
end

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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i =0 ;i<n;i++)cin >> a[i];
	vector<int> col(k+1);
	int sum = 0;
	queue<int> Q;
	int ans = n+1;
	for(int i = 0;i<n;)
	{
		//cout<<sum<<';'<<i<<endl;
		if(sum<k)
		{
			if(a[i]<=k&&col[a[i]]==0)
			{
				
				sum++;
			}
			Q.push(a[i]);
			if(a[i]<=k)col[a[i]]++;
			i++;
		}
		else
		{
			//cout<<i<<endl;
			ans = min(ans,(int)Q.size());
			int x = Q.front();
			if(x<=k)
			{
				col[x]--;
				if(col[x]==0)sum--;
			}
			Q.pop();
		}
	}
	while(sum==k)
	{
		ans = min(ans,(int)Q.size());
		int x = Q.front();
		if(x<=k)
		{
			col[x]--;
			if(col[x]==0)sum--;
		}
		Q.pop();
	}
	cout<<(ans==n+1?0:ans)<<endl;

}


Measured memory_bytes: 4176
import math

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

p = 0
if (n-(k-1) >= 1):
    p += (n-(k-1))/n
    for i in range(1, k):
        a = math.ceil(math.log2(k/i))
        p += (1/n) * ((1/2)**a)
else:
    for i in range(1, n+1):
        a = math.ceil(math.log2(k/i))
        p += (1/n) * ((1/2)**a)
    
print(p)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static List<Edge>[] tree;
    static bool[] ans;
    static void Main()
    {
        tree = new List<Edge>[int.Parse(ReadLine())];
        ans = new bool[tree.Length];
        for (int i = 0; i < tree.Length; i++) tree[i] = new List<Edge>();
        for (int i = 0; i < tree.Length - 1; i++)
        {
            var line = ReadLine().Split(' ');
            var u = int.Parse(line[0]) - 1;
            var v = int.Parse(line[1]) - 1;
            var w = int.Parse(line[2]);
            tree[u].Add(new Edge { to = v, dist = w });
            tree[v].Add(new Edge { to = u, dist = w });
        }
        DFS(0, -1, false);
        foreach (var c in ans) WriteLine(c ? "1" : "0");
    }

    static void DFS(int v, int p, bool c)
    {
        ans[v] = c;
        foreach (var a in tree[v]) if (a.to != p) DFS(a.to, v, a.dist % 2 == 0 ? c : !c);
    }
}

struct Edge
{
    public int to;
    public int dist;
}


Measured memory_bytes: 33264
#include <stdio.h>
#define MAX 100000
struct Card{
  char a;
  int b;
};
struct Card L[MAX/2+2], R[MAX/2+2];
int n;
 
void merge(struct Card A[], int left, int mid, int right){
  int n1, n2, i, j, k;
 
  n1 = mid - left;
  n2 = right - mid;
 
  for(i = 0; i <= n1-1; i++) L[i] = A[left + i];
  for(i = 0; i <= n2-1; i++) R[i] = A[mid + i];
  L[n1].b = 1000000001;
  R[n2].b = 1000000001;
  i = j = 0;
  for(k = left; k <= right-1; k++){
    if(L[i].b <= R[j].b){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card A[], int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left, mid);
    mergeSort(A,mid, right);
    merge(A,left, mid, right);
  }
}
int partition(struct Card A[], int p, int r){
  int i, j;
  struct Card x, t;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j].b <= x.b){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}
 
void Quicksort(struct Card A[], int p, int r){
  int q;
  if(p < r){
    q = partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}
int main()
{
  int i, v, f = 0;
  struct Card x[MAX], y[MAX];
  char s[10];
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%s %d", s, &v);
    x[i].a = y[i].a = s[0];
    x[i].b = y[i].b = v;
  }
  Quicksort(x, 0, n-1);
  mergeSort(y, 0, n);
 
  for(i = 0; i < n; i++){
    if(x[i].a != y[i].a) f = 1;
  }
  if(f == 0) printf("Stable\n");
  else printf("Not stable\n");
 
  for(i = 0; i < n; i++) printf("%c %d\n", x[i].a, x[i].b);
  return 0;
}

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

using namespace std;
 
void solve() {
    int n;
    cin >> n;

    vector<vector<int>> v(n, vector<int>(4, 0));
    for (int i = 0; i < n; ++i) 
        cin >> v[i][1] >> v[i][2] >> v[i][3];

    // dp[i][j] maior felicidade no dia i não podendo fazer a atividade j
    // dp[i][j] = max(v[i][k] + dp[i-1][k]) para k != j
    int dp[n][4];
    memset(dp, -1, sizeof dp);

    function<int(int, int)> calc_dp = [&] (int i, int j) {
        if (dp[i][j] != -1) {
            return dp[i][j];
        }
        if (i == 0) {
            int best = -1;
            for (int k = 1; k <= 3; ++k) {
                if (k != j) {
                    best = max(best, v[0][k]);
                }
            }
            return best;
        }

        int best = -1;
        for (int k = 1; k <= 3; ++k) {
            if (k != j) {
                best = max(best, v[i][k] + calc_dp(i-1, k));
            }
        }
        dp[i][j] = best;
        return dp[i][j];
    };

    cout << max(max(calc_dp(n-1, 1), calc_dp(n-1, 2)), calc_dp(n-1, 3)) << endl;
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 21124
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from bisect import bisect_right
from itertools import accumulate
from functools import cmp_to_key

def cmp(store1, store2):
    if store1 == store2:
        return 0
    a1, b1 = store1
    a2, b2 = store2
    return -1 if a2 * (b1 + 1) <= a1 * (b2 + 1) else 1

def resolve():
    n, T = map(int, input().split())
    AB = []
    zero = []
    for _ in range(n):
        a, b = map(int, input().split())
        if a != 0:
            AB.append((a, b))
        else:
            zero.append(b + 1)

    AB.sort(key = cmp_to_key(cmp))
    zero.sort()
    zero = list(accumulate(zero))

    max_store = 30
    dp = [T + 1] * max_store
    dp[0] = 0
    for a, b in AB:
        for i in range(max_store - 2, -1, -1):
            t = dp[i]
            dp[i + 1] = min(dp[i + 1], (a + 1) * (t + 1) + b)

    res = 0
    for i in range(max_store):
        t = dp[i]
        if t > T:
            break
        rest = T - t
        res = max(res, i + bisect_right(zero, rest))

    print(res)
resolve()

Measured memory_bytes: 79248
import itertools
 
_, k = map(int, input().split())
S = input()
blocks = [(key, len(list(v))) for key, v in itertools.groupby(S)]
res = 0
i = 0
if blocks[i][0] == '0':
  res = max(res, sum([b[1] for b in blocks[i:i+2*k]]))
  i += 1

crr = sum([b[1] for b in blocks[i:i+2*k+1]])
res = max(res, crr)
while i+2*k + 2 < len(blocks):
  i += 2
  crr = crr + blocks[i+2*k-1][1] + blocks[i+2*k][1]
  crr = crr - blocks[i-1][1] - blocks[i-2][1]
  res = max(res, crr)

crr = sum([b[1] for b in blocks[-2*k:]])
res = max(res, crr)
print(res)


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

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

    vector<size_t> L(N);
    for (size_t &l : L)
    {
        cin >> l;
    }

    size_t ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i + 1; j < N; j++)
        {
            for (size_t k = j + 1; k < N; k++)
            {
                if (L[i] == L[j])
                {
                    continue;
                }
                if (L[j] == L[k])
                {
                    continue;
                }
                if (L[k] == L[i])
                {
                    continue;
                }
                if (L[i] + L[j] <= L[k])
                {
                    continue;
                }
                if (L[j] + L[k] <= L[i])
                {
                    continue;
                }
                if (L[k] + L[i] <= L[j])
                {
                    continue;
                }
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"strconv"
	"strings"
)

var (
	// ErrLineNotFound -
	ErrLineNotFound = errors.New("lines: line not found")
)

type onError int

const (
	onErrorPanic onError = iota
	onErrorError
)

// Lines represents multi line.
type Lines struct {
	r       io.Reader
	w       io.Writer
	onError onError

	store []string
}

// NewLines create lines from provided input reader.
func New(r io.Reader) *Lines {
	lines, err := newLines(r, ioutil.Discard, onErrorPanic)
	if err != nil {
		panic(err)
	}
	return lines
}

// Line represents single line.
type Line struct {
	store string
	field int
}

// Line return given n line.
func (ls *Lines) Line(n int) *Line {
	line, err := ls.line(n)
	if err != nil {
		panic(err)
	}
	return line
}

func (ls *Lines) line(n int) (*Line, error) {
	if n >= len(ls.store) {
		return nil, ErrLineNotFound
	}
	return &Line{store: ls.store[n]}, nil
}

func (l *Line) Ints() []int {
	ints, err := l.ints()
	if err != nil {
		panic(err)
	}
	return ints
}

func (l *Line) ints() ([]int, error) {
	var ints []int
	fields := strings.Fields(l.store)
	for _, s := range fields {
		i, err := strconv.Atoi(s)
		if err != nil {
			return nil, err
		}
		ints = append(ints, i)
	}
	return ints, nil
}

// Field specify current field scope.
func (l *Line) Field(n int) *Line {
	clone := l.clone()
	clone.field = n
	return clone
}

func (l *Line) Int() int {
	ints, err := l.ints()
	if err != nil {
		panic(err)
	}
	return ints[l.field]
}

func newLines(r io.Reader, w io.Writer, onError onError) (*Lines, error) {
	lines := &Lines{
		r:       r,
		w:       w,
		onError: onErrorError,
	}
	return lines, lines.init()
}

func (ls *Lines) init() error {
	s := bufio.NewScanner(ls.r)
	for s.Scan() {
		ls.store = append(ls.store, s.Text())
	}
	return s.Err()
}

func (l *Line) clone() *Line {
	clone := *l
	return &clone
}

func main() {
	lines := New(os.Stdin)
	ns := lines.Line(0).Ints()

	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	sum := 10*ns[0] + ns[1] + ns[2]
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int n, m;
int solve() {
  map<int, int> mp;
  REP(i, n) {
    int k;
    cin >> k;
    REP(l, k) {
      int a;
      cin >> a;
      ++mp[a];
    }
  }
  int ret;
  for (auto e : mp) {
    // cout << e.first << " " << e.second << endl;
    if (e.second == n)
      ++ret;
  }
  return ret;
}

int main() {
  cin >> n >> m;
  cout << solve() << endl;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int cnt = 0;
	long long scoa = 0;
	while (cnt < n - 1) {
		cnt++;
		scoa += a[cnt / 2];
	}
	cout << scoa << endl;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define max(a,b) ((a>b)? (a):(b))
int main()
{
  int n,m;
  cin>>n>>m;
  int i=1;
  vector<int> div;
  vector<int> ans;
  while(i<=sqrt(m)){
    if(m%i==0) {
      div.push_back(i);
      div.push_back(m/i);
    }
    i++;
  }
  for(auto &e:div){
    if(m/e>=n){
      ans.push_back(e);
    }
  }
  cout<<*max_element(ans.begin(),ans.end());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n;cin>>n;
    string s = to_string(n); 
    ll id = 0;  
    REP(i,s.size()){
        id += (s[i]-'0');
    }
    // cout<<id<<endl;
    if (n%id==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

long long gcd(long long a, long long b){
    if(a > b) swap(a,b);
    while(a != 0){
        b = b % a;
        swap(a,b);
    }

    return b;
}

int main(){
    long long A, B, C, D; cin >> A >> B >> C >> D;
    A--;
    cout << B - B/C - B/D + B/((C*D)/gcd(C,D)) - A + A/C + A/D - A/((C*D)/gcd(C,D)) << endl;
}

Measured memory_bytes: 256
#include <stdlib.h>

#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

/*
Drawing Lots

º}Ìæ¤È¢íÉ­¶ª èÜ·B±ÌáÅÍcüÌªT{ èAS{Ì¡üªø©êÄ¢Ü·B¡üÍcüðÜ½¢Åàæ¢ÆµÜ·B

}ÌãÅÍ 1, 2, 3, 4, 5 ÌÔÅ Á½àÌªAQÔÚÆSÔÚÌÔÅÌð·i±êð (2, 4) Ìæ¤É­jðµA³çÉA(3, 5)(1, 2)(3, 4) Ìð·ðµ½ÌÅA}ÌºÉ½Æ«ÍA4, 1, 2, 5, 3 ÉÈèÜµ½B

ÅÌóÔ@1, 2, 3, 4.... ªA^¦çê½¡_ÌXgi±ÌáÅÍA(2, 4)(3, 5)(1, 2)(3, 4) ðÊßµ½Ì¿AÇÌæ¤ÈÔÉÈé©ðoÍµÄI¹·évOðì¬µÄº³¢B
Input

cüÌ{ w (®Fw  30)
¡_Ì{ n (®Fn  30)
¡_Xg a1, b1 (®F¼pJ}æØè) ¡_Xg a2, b2 (®F¼pJ}æØè) .
.
.
¡_Xg an, bn (®F¼pJ}æØè)
Output

¶©çEÉA
1 ÔÚÌ_Éé
2 ÔÚÌ_Éé
.
.
w ÔÚÌ_Éé
Sample Input

5
4
2,4
3,5
1,2
3,4

Output for the Sample Input

4
1
2
5
3

*/

using namespace std;

void swap(int *a, int *b)
{
	int t = *a;
	*a = *b;
	*b = t;
}

int main()
{
	string s;
	int w, n;

	getline(cin, s);
	sscanf(s.c_str(), "%ld", &w);
	getline(cin, s);
	sscanf(s.c_str(), "%ld", &n);
	
	vector<int> v;
	for (int i = 0; i < w; i++)
	{
		v.push_back(i + 1);
	}
	
	for (int i = 0; i < n; i++)
	{
		int a, b;
		getline(cin, s);
		sscanf(s.c_str(), "%ld,%ld", &a, &b);
		swap(&v[a - 1], &v[b - 1]);
	}
	
	for (int i = 0; i < w; i++)
	{
		printf("%d\n", v[i]);
	}

	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        var H = new HashSet<int>();
        for (int i = 0; i < N; i++)
        {
            H.Add(cin.next[0]);
        }
        WriteLine(H.Count == 3 ? "Three" : "Four");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int main() {
  int n;
  cin >> n;
  int ini = 0, out = 0, hit = 0, cnt = 0  ;
  while (ini < n) {
    string s;
    cin >> s;
    if (s == "OUT") {
      out++;
      if (out == 3) {
        cout << cnt << endl;
        cnt = 0;
        hit = 0;
        out = 0;
        ini++;
      }
    }
    if (s == "HIT") {
      if (hit == 3) {
        cnt++;
      } else {
        hit++;
      }
    }

    if (s == "HOMERUN") {
      cnt += hit + 1;
      hit = 0;
    }
  }
}


Measured memory_bytes: 3156
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  std::string S, T;
  std::cin >> S >> T;
  int slength = S.length();
  int tlength = T.length();
  int ans = 1001001001;
  for (int i=0; i<=slength-tlength; i++) {
    int diff = 0;
    for (int j=0; j<tlength; j++) {
      if (S[i+j]!=T[j]) diff++;
    }
    ans = std::min(ans, diff);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3184
#include <vector>
#include <iostream>
#include <algorithm>
#include <list>
#include <climits>

using namespace std;

struct Point {
    int x, y;

    bool operator<(const Point& a) const {
        if(a.x == this->x) return this->y < a.y;
        else return this->x < a.x;
    }
};

ostream& operator<< (ostream& out, const Point& a) {
    out << a.x << " " << a.y;
    return out;
}

int isleft(Point a, Point b, Point c) {
    int diff = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
    if(diff > 0) {
        return 1;
    } else if(diff == 0) {
        return 0;
    } else {
        return -1;
    }
}

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

    int n; cin >> n;
    vector<Point> points;
    for(int i = 0; i < n; ++i) {
        Point p;
        cin >> p.x >> p.y;
        points.push_back(p);
    }

    sort(points.begin(), points.end());

    vector<Point> upper;
    upper.push_back(points[0]);
    upper.push_back(points[1]);
    for(int i = 2; i < n; ++i) {
        //cout << "LOOP" << endl;
        int sz = upper.size();
        while(sz > 1 && isleft(points[i], upper[sz - 1], upper[sz - 2]) == 1) {
            //cout << "sz: " << sz << endl;
            upper.pop_back();
            sz -= 1;
        }
        upper.push_back(points[i]);
        /*for(int i = 0; i < upper.size(); ++i) {
            cout << upper[i] << endl;
        }*/
    }

    vector<Point> lower;
    lower.push_back(points[n - 1]);
    lower.push_back(points[n - 2]);
    for(int i = n - 3; i >= 0; --i) {
        int sz = lower.size();
        while(sz > 1 && isleft(points[i], lower[sz - 1], lower[sz - 2]) == 1) {
            lower.pop_back();
            sz -= 1;
        }
        lower.push_back(points[i]);
    }

    vector<Point> full;

    cout << upper.size() + lower.size() - 2 << endl;

    for(int i = 0; i < upper.size(); ++i) {
        full.push_back(upper[i]);
    }

    for(int i = 1; i < lower.size() - 1; ++i) {
        full.push_back(lower[i]);
    }

    int mindex = 0;
    int minsofar = INT_MAX;
    int minx = INT_MAX;

    for(int i = 0; i < full.size(); ++i) {
        if(full[i].y < minsofar) {
            minsofar = full[i].y;
            minx = full[i].x;
            mindex = i;
        } else if(full[i].y == minsofar && full[i].x < minx) {
            minx = full[i].x;
            mindex = i;
        }
    }

    for(int i = mindex; i < mindex + full.size(); ++i) {
        cout << full[i % full.size()] << endl;
    }
}


Measured memory_bytes: 5724
#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, k; cin >> n >> k;
	vi v(n); rep(i, n) cin >> v[i];
	ll ans = 0;
	
	for(int i = max(0, n - k); i <= n; i++) for(int l = 0; l <= n - i; l++){
		ll tmp = 0;
		vi rem;
		rep(j, n){
			if(l <= j && j < l + i) continue;
			tmp += v[j];
			rem.pb(v[j]);
		}
		sort(all(rem));
		int cnt = min((int)rem.size(), k - n + i);
		rep(j, cnt) tmp -= min(0, rem[j]);
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define se second
#define sz(x) (int)(x.size())
#define ll long long
#define rep(i,x,y) for(int i = x; i <= y; ++i)
#define repr(i,x,y) for(int i = x; i >= y; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define ull unsigned ll
 
#define pi 3.14159265358979
 
 
using namespace std;
 
const int N = (int)(1e6) + 322;
const ll INF = 2e18 + 17;
const int inf = 2e9;
const int mod = 1000000007;
const double eps = 1e-9;
 
int gcd(int a, int b) { return b ? gcd (b, a % b) : a; }
 
int nbr_bits(int a){
	return log2(a)+1;
}
 
 
int binpow(int a, int n, int mod) {
    int res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

int fastpow(int a, int n, int mod) {
    if(n==0)
    	return 1;
    if(n%2==0){
    	int res = fastpow(a,n/2,mod);
    	res*=res;
    	res%=mod;
    	return res;
	}
	int res = (fastpow(a,n-1,mod)*a)%mod;
	return res;
    
}
 
// ----------------------------------------------------
 
signed main()
{
   
   int t ;
   cin >> t ;
   int ans = 0, fl = 0;
	while(t--){
	
	  int n1, n2;
	  cin >> n1 >> n2;
	  
	  if(n1 == n2) fl++;
	  else fl = 0;
	  
	  if(fl == 3){
	    ans = 1;
	  }
	
	}
	
	if(ans == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
   
	return 0;
}
	

Measured memory_bytes: 3680
#include "bits/stdc++.h"
#include <queue>

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	int n;
	cin >> n;
	VI X(n), A(n);
	rep(i, n) {
		cin >> X[i];
		A[i] = X[i];
	}

	sort(all(X));

	rep(i, n) {
		if (A[i] <= X[n / 2 - 1]) {
			cout << X[n / 2] << endl;
		}
		else {
			cout << X[n / 2 - 1] << endl;
		}
	}
}


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

	solve(); 
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int size,sum;
    vector<int> v1;
    while(cin>>size>>sum)
    {
        int cal=0;
        for(int i=0;i<size;i++)
        {
            int temp;
            cin>>temp;
            v1.push_back(temp);
        }
        sort(v1.begin(),v1.end());
        for(int i=0;i<sum;i++)
        {
            cal+=v1[i];
        }
        cout<<cal<<endl;
        v1.clear();
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define col second
#define num first
#define mo 1000000007
using namespace std;
pair<int,int> dt[200010];
int minn[200010];
vector <int> des[200010];
bool vis[200010];
map<int,int> mp;
int fac[200010],nifac[200010];
int getmi(int a,int x)
{
	int ans=1;
	while (x)
	{
		if (x&1) ans=(long long)ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
void adde(int x,int y){des[x].push_back(y);des[y].push_back(x);}
void dfs(int s)
{
	vis[s]=true;mp[dt[s].col]++;
	for (int k=0;k<des[s].size();k++) if (!vis[des[s][k]]) dfs(des[s][k]);
}
int main()
{
	int n,x,y;scanf("%d%d%d",&n,&x,&y);
	fac[0]=1;for (int i=1;i<=n;i++) fac[i]=(long long)fac[i-1]*i%mo;
	nifac[n]=getmi(fac[n],mo-2);
	for (int i=n-1;i>=0;i--) nifac[i]=(long long)nifac[i+1]*(i+1)%mo;
	
	for (int i=1;i<=n;i++) scanf("%d%d",&dt[i].col,&dt[i].num);
	sort(dt+1,dt+n+1);dt[0].num=1050000000;
	for (int i=1;i<=n;i++) if (dt[i].num<dt[minn[dt[i].col]].num) minn[dt[i].col]=i;
	for (int i=1;i<=n;i++) if (dt[i].num+dt[minn[dt[i].col]].num<=x) adde(i,minn[dt[i].col]);
	for (int d=1;d<=n;d<<=1)
	{
		int p0=0,p1=0;
		for (int i=1;i<=n;i++) if (!(dt[i].col&d)) {p0=i;break;}
		for (int i=1;i<=n;i++) if (dt[i].col&d) {p1=i;break;}
		if (dt[p0].num+dt[p1].num>y) continue;
		for (int i=1;i<=n;i++) if ((!(dt[i].col&d))&&(dt[i].num+dt[p1].num<=y)) adde(i,p1);
		for (int i=1;i<=n;i++) if ((dt[i].col&d)&&(dt[i].num+dt[p0].num<=y)) adde(i,p0);
	}
	int ans=1;
	for (int i=1;i<=n;i++) if (!vis[i])
	{
		mp.clear();
		dfs(i);
		int sum=0;
		for (map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		{
			ans=(long long)ans*nifac[it->second]%mo;
			sum+=it->second;
		}
		ans=(long long)ans*fac[sum]%mo;
	}
	printf("%d\n",ans);
}
		
		
		

Measured memory_bytes: 53596
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int ans=0,cnt=0;
  char prev='?';
  int prevmx=0;
  rep(i,s.size() ){
    if(prev!=s[i]){
      if(s[i]=='<'){
	ans+=0;
	ans+=max(cnt,prevmx);
	cnt=1;
      }else{
	prevmx=cnt;
	cnt=1;
      }
    }else{
      ans+=cnt;
      cnt++;
    }
    prev=s[i];
  }
  if(s[s.size() - 1]=='<') ans+=cnt;
  else ans+=max(cnt,prevmx);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000

//????¬????dp

int main(){
    int n; cin >> n;
    
    int ans = 0;
    while(n != 1){
        int r = n % 3;
        n = n / 3;
        if(r > 0) n++;

        ans++;
    }

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

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	
	int n;
	cin >> n;
	
	map<ll , int> mp;
	mp[0] = 1;
	ll x;
	ll sum = 0;
	ll ans = 0;

	rep(i , n){
		cin >> x;
		sum += x;
		ans += mp[sum]++;
	}
	
	
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 12800
h,w = map(int, input().split())
lis = []

for i in range(h):
    lis.append(list(input()))

for i in range(1,h-1):
    for j in range(1,w-1):
        if lis[i][j] == "#":
            if lis[i-1][j] == "." and lis[i+1][j] == "." and lis[i][j-1] == "." and lis[i][j+1] == ".":
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 9208
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli d;
    cin >> d;
    cout << "Christmas" << sp;
    rep(i, 25 - d) {
        cout << "Eve" << sp;
    }
}

Measured memory_bytes: 3576
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C = il()
    print('Yes' if A <= C <= B else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
X = int(input())
K = int(input())
R = list(map(int, input().split()))
Q = int(input())


ami = [0]*(K+1)
ama = [X] + [0]*K
cusummi = [0]*(K+1)
cusumma = [0]*(K+1)
cusum = [0]*(K+1)
pr = 0
for i, r in enumerate(R):
    d = pr-r if i%2==0 else r-pr
    cusum[i+1] = cusum[i] + d
    cusummi[i+1] = min(cusummi[i], cusum[i+1])
    cusumma[i+1] = max(cusumma[i], cusum[i+1])
    ami[i+1] = min(max(ami[i] + d, 0), X)
    ama[i+1] = min(max(ama[i] + d, 0), X)
    pr = r

import bisect
for _ in range(Q):
    t, a = map(int, input().split())
    i = bisect.bisect_right(R, t)
    t1 = R[i-1] if i!=0 else 0
    t2 = t-t1
    d = -t2 if i%2==0 else t2
    if ama[i]==ami[i]:
        print(min(max(ama[i] + d, 0), X))
        continue
    ans = a+cusum[i]
    if -cusummi[i]>a:
        ans += -cusummi[i]-a
    if cusumma[i]>(X-a):
        ans -= cusumma[i]-(X-a)
    print(min(max(ans+d, 0), X))


Measured memory_bytes: 23660
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    nm = 0
    sm = 0
    p = 1
    for i in a:
        ns = sm+i
        if p:
            if ns <= 0:
                nm += 1-ns
                sm = 1
            else:
                sm = ns
        else:
            if ns >= 0:
                nm += 1+ns
                sm = -1
            else:
                sm = ns
        p = 1-p
    mi = nm
    nm = 0
    sm = 0
    p = 0
    for i in a:
        ns = sm+i
        if p:
            if ns <= 0:
                nm += 1-ns
                sm = 1
            else:
                sm = ns
        else:
            if ns >= 0:
                nm += 1+ns
                sm = -1
            else:
                sm = ns
        p = 1-p

    print(min(nm,mi))

    return None

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    ll M = MIN(MIN(4*Q,2*H),S);
    ll ans = (N/2) * MIN(2*M,D) + (N%2) * M;
    PR(ans);

    


    return 0;
}

/*



*/

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		String S = scanner.next();

		int seikai = 0;


		for (int i = 0; i <=3; i++) {

		if(S.substring(i,i+1).equals("+")) {    //文字列の中身だけ比較する

			seikai++;
		}

			else {

			seikai--;
		}


}

		System.out.println(seikai);
}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll k, q;
    cin >> k >> q;
    vector<ll> d(k);
    rep(i, k) cin >> d[i];

    rep(_, q){
        ll n, x, m;
        cin >> n >> x >> m;
        --n, x %= m;
        vector<ll> D(k);
        ll sum = 0, z = 0;
        rep(i, k){
            D[i] = d[i] % m;
            sum += D[i];
            if(D[i] == 0) ++z;
        }

        ll ans = (n / k) * z, tot = x + (n / k) * sum;
        rep(i, n % k){
            tot += D[i];
            if(D[i] == 0) ++ans;
        }

        ans += tot / m;
        print(n - ans);
    }

    return 0;
}

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

using namespace std;

const int N = 24*60*60;

int a1, a2, a3;

int main()
{
  cin >> a1 >> a2 >> a3;
  int s = a1 + a2 + a3;
  if (s >= 22)
    cout << "bust";
  else
    cout << "win";
  return 0;
}


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

using namespace std;

const int max_n = 200222, mod = 1000000007;

int n, a, b, c, f[max_n];

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1 % mod;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int inv(int x) {
    return power(x, mod - 2);
}

int solve(int n, int a, int b, int c) {
    --n;
    int res = 0;
    for (int x = 0; x <= n; ++x) {
        int p, q;
        p = mul(c, power(a, n));
        p = mul(p, power(b, x));
        p = mul(p, f[n + x + 1]);
        q = mul(power((c + mod - 1) % mod, 2), f[n]);
        q = mul(q, f[x]);
        q = mul(q, power((1 + mod - c) % mod, n + x));
        res += mul(p, inv(q));
        res %= mod;

        p = (mod - n - 1 - x) % mod;
        p = mul(p, power(a, n));
        p = mul(p, power(b, x));
        p = mul(p, f[n + x]);
        q = mul((c + mod - 1) % mod, f[n]);
        q = mul(q, f[x]);
        q = mul(q, power((1 + mod - c) % mod, n + x));
        res += mul(p, inv(q));
        res %= mod;
    }
    return mul(res, a);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> a >> b >> c;
    a = mul(a, inv(100));
    b = mul(b, inv(100));
    c = mul(c, inv(100));
    f[0] = 1;
    for (int i = 1; i < max_n; ++i) {
        f[i] = mul(i, f[i - 1]);
    }
    int res = (solve(n, a, b, c) + solve(n, b, a, c)) % mod;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int n);
int pop();

int main(){
  int x,y;
  top = 0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(s[0]=='-'){
      y=pop();
      x=pop();
      push(x-y);
    }
    else if(s[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  return 0;
}

void push(int n){
  S[++top]=n;
}

int pop(){
  top--;
  return S[top+1];
}


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

#define MAXN (310)

int n, m;
int a[MAXN][MAXN], cnt[MAXN];
bool vis[MAXN];

void getcnt(){
	memset(cnt, 0, sizeof(cnt));
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= m; ++ j){
			if(vis[a[i][j]]){
				++ cnt[a[i][j]];
				break;
			}
		}
	}
}

int solve(){
	for(int i = 1; i <= m; ++ i) vis[i] = true;
	int ret = INT_MAX;
	for(int i = 1; i <= m; ++ i){
		getcnt();
		int sit = 0;
		for(int i = 1; i <= m; ++ i){
			if(!vis[i]) continue;
			if(cnt[i] > cnt[sit]){
				sit = i;
			}
		}
		ret = std::min(ret, cnt[sit]);
		vis[sit] = false;
	}
	return ret;
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= m; ++ j){
			scanf("%d", &a[i][j]);
		}
	}
	printf("%d\n", solve());
	return 0;
}

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

const int N = 1e5 + 5;
int a[N],b[N];

int main(){
	int n;
	scanf("%d",&n);

	for(int i = 0; i < n+1; i++){
		scanf("%d",&a[i]);
	}
	for(int i = 0; i < n; i++){
		scanf("%d",&b[i]);
	}	
	long long s = 0;
	for(int i = 0; i < n; i++){
		if(a[i] >= b[i]){
			s += b[i];
			b[i] = 0;
		}
		else if( a[i] < b[i] ){
			if(a[i]+a[i+1] >=b[i]){
				s += b[i];
				a[i+1] = a[i] + a[i+1] - b[i];
			}
			else {
				s += a[i]+a[i+1];
				a[i+1] = 0;	
			}					
		}
	}
	printf("%lld\n",s);
	return 0;
}


Measured memory_bytes: 1024
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        pass
        break
    if W%2==0:
        if H%2==0:
            for i in range(H//2):
                print("#." * (W//2))
                print(".#" * (W//2))
            print("")
        else:
            for i in range(H//2):
                print("#." * (W//2))
                print(".#" * (W//2))
            print("#." * (W//2))
            print("")
    else:    
        if H%2==0:
            for i in range(H//2):
                print("#." * (W//2)+"#")
                print(".#" * (W//2)+".")
            print("")
        else:
            if H==1 and W==1:
                print("#")
                print("")
            else:
                for i in range(H//2):
                    print("#." * (W//2)+"#")
                    print(".#" * (W//2)+".")
                print("#." * (W//2)+"#")
                print("")


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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n"
//cout << fixed << setprecision(2);

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int len = s.size();
    //cout << len << endl;
    string ke = "keyence";
    int j = 0;
    for(int i = 0; i <= 7; i++){
        //cout << s.substr(0, i) << " = " <<  s.substr(s.size()-7+i) << endl;
        if(s.substr(0, i) + s.substr(len-7+i) == ke){
           cout << "YES" << endl;
           return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 3596
mod = 10**9 + 7


def pwr(p, q):
    if q == 1:
        return p%mod
    elif q % 2 == 0:
        return (pwr(p, q//2)%mod)**2%mod
    else:
        return (pwr(p, q//2)%mod)**2*p%mod

x, y = map(int,input().split())
if (2*x-y)%3 != 0 or (2*y-x)%3 != 0:
    print(0)
else:
    n = (2*x-y)//3
    m = (2*y-x)//3
    if m == 0 or n == 0:
        print(1)
    elif m < 0 or n < 0:
        print(0)
    else:
        s1 = 1
        s2 = 1
        for i in range(m+1, n+m+1):
            s1 *= i
            s1 %= mod
        for i in range(n):
            s2 *= (i+1)
            s2 %= mod

        print(s1*pwr(s2, mod-2)%mod)

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

int main() {
	string s;
	cin >> s;
	int size = s.size();
	int k;
	cin >> k;

	long long dp[size+1][2][k+1];
	fill((long long *)dp, (long long *)dp + sizeof(dp)/sizeof(long long), 0);
	dp[0][0][0] = 1;
	for (int i = 0; i < size; ++i) {
		const int D = s[i] - '0';
		for (int smaller = 0; smaller <= 1; ++smaller) {
			for (int j = 0; j <= k; ++j) {
				int x_max = smaller ? 9 : D;
				for (int x = 0; x <= x_max; ++x) {
					int next_j = x==0 ? j : j+1;
					if (next_j > k) continue;
					dp[i+1][smaller || x<D][next_j] += dp[i][smaller][j];
				}
			}
		}
	}
	long long ans = dp[size][0][k] + dp[size][1][k];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll H,W;
	cin >> H >> W;
	string s;
	FOR(i,0,H){
		FOR(j,0,W){
			cin >> s;
			if(s=="snuke"){
				cout << char('A'+j) << i+1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int A,B,C,D,t;
	cin>>A>>B>>C>>D;
	if(1<=A<=1000
	    &&1<=B<=1000
		&&1<=C<=1000
		&&1<=D<=1000)
	{
		if(A>B)
		t=B;
		else t=A;
		if(C>D)
		t=t+D;
		else t=t+C;
		cout<<t;
	}
	else return 0; 
}

Measured memory_bytes: 256