akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       s: chars
    }
    let mut a = s.clone();
    a.sort();
    a.dedup();
    if a.len() == s.len() {
        println!("yes");
    } else {
        println!("no");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,s,d;
    string in;
    
    cin >> in;
    
    a = stoi(in.substr(0,4));
    s = stoi(in.substr(5,2));
    d = stoi(in.substr(8.2));
    int x = d + s *100 + a * 100*100;
    
    if(x <= 20190430)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	int n,sum;
	cin>>n>>sum;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n-i;j++)
		{
			if(i*10000+j*5000+(n-i-j)*1000==sum)
			{
				cout<<i<<" "<<j<<" "<<n-i-j<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,n,m,s,c;
    vector<int>v;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>k;v.push_back(k);
    }
    sort(v.begin(),v.end());
    m=v[(n+1)/2]-v[(n-1)/2];
    cout<<m<<endl;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int[] s = new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        out.println(s[in.ni()-1]);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int A,B,C;cin>>A>>B>>C;A-=C;
    cout<<A/(B+C)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n,k;
    cin >> n >> k;
    int l[n];
    REP(i,0,n) cin >> l[i];
    int ans = 0;
    //処理
    SRTAG(l,n);
    REP(i,0,k) ans += l[i];
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, k, ans, w[200000], c[2000], dp[200][200000];
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i ++)
		cin >> w[i] >> c[i];
		
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= k; j ++)
		{
			if (j-w[i] < 0)
				dp[i][j] = max (dp[i][j-1], dp[i-1][j]);
					else
			dp[i][j] = max (dp[i-1][j-w[i]] + c[i], max (dp[i][j-1], dp[i-1][j]));		
		}
	}	
	
	for (int j = 1; j <= k; j ++)
	{
		ans = max (ans, dp[n][j]);
	//	if (ans == 110) cout << j << endl;
	}
		
//	for (int i = 1; i <= n; i ++)
//	{
	//	for (int j = 1; j <= k; j ++)
//			cout << dp[i][j] << " ";
//		cout << endl;
//	}
	cout << ans;
}

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

const int mod = 1e9+7;

int32_t main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
////////////////////////////////

    int n;
    
    cin >> n;
    int arr[n],pref[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
        if (i==0) pref[i] = arr[i];
        else pref[i] = (pref[i-1] + arr[i])%mod;
    }

    int ans = 0;
    for (int i=1;i<n;i++){
        ans += (arr[i] * pref[i-1])%mod;
    }

    cout<<ans%mod;


}


Measured memory_bytes: 6744
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<long long> sum(N + 1), sumxor(N + 1);
    for(int i = 0; i < N; i++){
        sum[i + 1] = sum[i] + A[i];
        sumxor[i + 1] = sumxor[i] ^ A[i];
    }
    int l = 0, r = 0;
    long long ans = 0;
    for(l = 0; l <= N; l++){
        if(l == r) r++;
        while(r <= N){
            long long t = sumxor[r] ^ sumxor[l];
            if(t != sum[r] - sum[l]) break;
            ans += r - l;
            r++;
        }
    }
    cout << ans << endl;
}

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

long double dis(int a1, int b1, int a2, int b2){
  long double d1=(a2-a1)*(a2-a1);
  long double d2=(b2-b1)*(b2-b1);
  return pow(d1+d2, 0.5);
}

int fact(int N){
  if(N==1) return 1;
  else return N*fact(N-1);
}

int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  for(int i=0; i<N; i++) cin >> x[i] >> y[i];
  
  vector<int> num(N);
  for(int i=0; i<N; i++) num[i]=i+1;
  
  long double dist=0;
  do{
    for(int i=0; i+1<N; i++) dist+=dis(x[num[i]-1], y[num[i]-1], x[num[i+1]-1], y[num[i+1]-1]);
  }while(next_permutation(num.begin(), num.end()));
  
  long double ans=(long double)dist/fact(N);
  cout << fixed << setprecision(10) << ans <<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
b = []
c = []
d = []

for i in range(N):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
for i in range(M):
    C, D = map(int, input().split())
    c.append(C)
    d.append(D)

for i in range(N):
    distmin = 500000000
    for j in range(M):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        distmin = min(dist, distmin)
        
    for j in range(M):
        if distmin == abs(a[i]-c[j]) + abs(b[i]-d[j]):
            print(j+1)
            break


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	x %= 11;
	if(x == 0) ;
	else if(x <= 6) ++ans;
	else ans += 2;
	cout << ans << endl;
	return 0;
}

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

long long binary(long long level, long long obj){
	long long mid = powl(2, level-1)*4-1;
	if(obj == mid){
		return powl(2, level);
	}else if(obj == 2*mid-1){
		return 2*(powl(2, level) - 1) + 1;
	}else if(obj == 0){
		return 0;
	}else if(obj > mid) {
		obj -= mid;
		return powl(2, level) + binary(level - 1, obj);
	}else if(obj < mid){
		--obj;
		return binary(level - 1, obj);
	}
}

int main(){
	long long n, x; cin >> n >> x;

	cout << binary(n, x) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[200005], b[200005], vis[200005], pos = 1, p;
ll k;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	while (!vis[pos])
	{
		b[p] = pos;
		vis[pos]++;
		pos = a[pos];
		p++;
	}
	for (int i = 0; i < p; i++)
	{
		if (b[i] == pos)
		{
			if (k > i)
			{
				cout << b[(int)((k - i) % (ll)(p - i)) + i] << endl;
			}
			else
			{
				cout << b[k] << endl;
			}
			return 0;
		}
	}
}

Measured memory_bytes: 5840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using pint = pair<int, int>;

int main()
{
    int h, a;
    cin >> h >> a;

    if (h % a != 0)
        h += a;
    cout << h / a << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    int a[100];
    cin>>n;

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

    for(i=1; i<=n; i++)

        if(a[i]%2==0 && a[i]%3!=0 &&a [i]%5!=0)
        {
            cout<<"DENIED"<<endl;
            return 0;
        }
    cout<<"APPROVED"<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	defer write.Flush()

	var n int
	var s string
	fmt.Fscan(read, &n, &s)

	fmt.Fprintln(write, strings.Count(s, "ABC"))
}


Measured memory_bytes: 640
// @supudo
// g++ -O2 -std=gnu++14 -Wall -Wextra -Wfatal-errors -Wshadow -Wno-vla-extension -pedantic -o ./build/abc137_a abc137_a.cpp -DLOCALHOST -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
// ./build/abc137_a

#include <iostream>
using namespace std;
#define _ ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10);

int main() { _
  int m1, m2;
  cin >> m1 >> m2;
  cout << max(m1 + m2, max(m1 - m2, m1 * m2));
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

bool good[100005];
string sa;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	cin>>sa;
	good[0]=true;
	for(i=0;i<n;i++){
		a=(int)sa[i]-(int)'0'+1;
		for(j=120;j>=0;j--){
			if(!good[j])continue;
			good[j*11+a]=true;
		}
	}
	a=0;
	for(i=121;i<1331;i++){
		if(good[i])a++;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq

n = int(input())
list_score = []
for i in range(n):
    list_score.append(int(input()))

list_ans = list_score.copy()
list_ans.sort()


for i in range(n):
    a = list_score[i]
    if a == list_ans[-1]:
        print(list_ans[-2])
    else:
        print(list_ans[-1])

Measured memory_bytes: 14180
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
    int n, answer = 0;
    cin >> n;
    vector<int> p(n);
    for (int count = 0; count < n; count++)
    {
        cin >> p.at(count);
    }
    for (int count = 1; count < n - 1; count++)
    {
        if (p.at(count - 1) < p.at(count) && p.at(count) < p.at(count + 1) ||
            (p.at(count - 1) > p.at(count) && p.at(count) > p.at(count + 1)))
        {
            answer++;
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, 2*n, a);
    Sort(a);
    int ans = 0;
    For(i, n) ans += a[2*i];
    Cout(ans);
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int k = ri();
	int a[n];
	for (auto &i : a) i = ri();
	for (int i = 0; i < k; i++) {
		int imos[n + 1];
		memset(imos, 0, sizeof(imos));
		for (int j = 0; j < n; j++) {
			imos[std::max(0, j - a[j])]++;
			imos[std::min(n, j + a[j] + 1)]--;
		}
		for (int j = 0; j < n; j++) imos[j + 1] += imos[j];
		if (!memcmp(imos, a, sizeof(a))) break;
		memcpy(a, imos, sizeof(a));
	}
	for (auto i : a) printf("%d ", i);
	puts("");
	return 0;
}


Measured memory_bytes: 5384
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  long x,t;
  cin >> x >> t;
  if(x>=t)
    P(x-t);
  else
    P(0);
  ret 0;
}

Measured memory_bytes: 256
inp = input()
split_input = inp.split()
w = int(split_input[0])
h = int(split_input[1])
x = int(split_input[2])
y = int(split_input[3])
small_area = w * h / 2
if x*2 == w and y*2 == h:
    print(str(small_area) + " " + str(1))
else:
    print(str(small_area) + " " + str(0))

Measured memory_bytes: 3064
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()


N,X,Y=map(int,input().split())
data=[[] for i in range(N+1)]
for i in range(1,N):
    a=i;b=i+1
    data[a].append(b)
    data[b].append(a)
data[X].append(Y)
data[Y].append(X)


dic=defaultdict(int)
for n in range(1,N+1):
    stack=deque([[n,0]])
    visited=set()
    while stack:
        #print(stack)
        a,m=stack.popleft()
        for p in data[a]:
            if not p in visited:
                visited.add(p)
                stack.append([p,m+1])
                if p>n:
                    dic[m+1]+=1


lst=[]
for i in range(N-1):
    print(dic[i+1])


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

typedef long long ll;
const int INF = 1e9;

int ans = 0;
int row[6] = {0};
int col[6] = {0};
char grid[6][6];
int h, w, k;

void solve(int depth){
	// assert(depth <= h+w);
	// cout<<depth<<'\n';
	if (depth == h + w){
		int cnt = 0;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (row[i] == 0 && col[j] == 0){
					cnt += (grid[i][j] == '#');
				}
			}
		}
		ans += (cnt == k);
		return;
	}
	if (depth < h){
		solve(depth + 1);
		row[depth] = 1;
		solve(depth + 1);
		row[depth] = 0;
	}else{
		// depth -= h;
		solve(depth + 1);
		col[depth - h] = 1;
		solve(depth + 1);
		col[depth - h] = 0;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>h>>w>>k;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin>>grid[i][j];
		}
	}
	solve(0);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3688
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	sort(A.begin(),A.end());
	int now = 0;
	int ans = 0;
	int count = 0;
	for(int i=0;i<N;++i){
		if( now != A[i] ){
			if( now > count ){
				ans += count;
			}else{
				ans += (count-now);
			}
			now = A[i];
			count = 1;
		}else{
			++count;
		}
	}
	{
		if( now > count ){
			ans += count;
		}else{
			ans += (count-now);
		}
	}
	cout << ans << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 640
#include<stdio.h>

int okachi[1001][1001];
int main(void)
{
	int w,cnt;
	int n;
	int i,j,k;

	int kachi,omosa,x,nkachi;
	int max,imax;

	cnt=0;
	while(1)	{
		cnt++;
		scanf("%d",&w);
		if(w==0)	break;
		scanf("%d",&n);
		for(i=0;i<=n;i++)	{
			for(j=0;j<=w;j++)	{
				okachi[i][j]=0;
			}
		}
		for(i=0;i<n;i++)	{
			scanf("%d,%d",&kachi,&omosa);
			for(j=0;j<=w;j++)	{
				if(okachi[i+1][j]<okachi[i][j])	{
					okachi[i+1][j]=okachi[i][j];
				}
				if(j+omosa<=w && okachi[i+1][j+omosa]<okachi[i][j]+kachi)	{
					okachi[i+1][j+omosa]=okachi[i][j]+kachi;
				}
			}
		}
		max=-1;
		for(j=0;j<=w;j++)	{
			if(max<okachi[n][j])	{
				max=okachi[n][j];
				imax=j;
			}
		}
		printf("Case %d:\n",cnt);
		printf("%d\n%d\n",max,imax);
	}
}


Measured memory_bytes: 4940
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const int Mod = 1000000007;
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = l[0], K = l[1];
            var cb = new long[N + 1, K + 1];

            for (var i = 0; i < N + 1; i++)
            {
                for (var j = 0; j < K + 1; j++)
                {
                    if (j == 0) cb[i, j] = 1;
                    else if (i == 0) cb[i, j] = 0;
                    else cb[i, j] = (cb[i - 1, j - 1] + cb[i - 1, j]) % Mod;
                }
            }

            for (var i = 0; i < K; i++)
                Console.WriteLine(cb[N - K + 1, i + 1] * cb[K - 1, i] % Mod);

        }
    }
}


Measured memory_bytes: 42336
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cerrno>
#include <cfenv>
#include <math.h>
#include <iomanip>
#include <limits>
#define ll long long int

using namespace std;

int main(){

    int m,n_min,n_max;
    vector<int> data(200);

    while(true){

        cin >> m >> n_min >> n_max;

        if(m==0&&n_min==0&&n_max==0){
            break;
        }

        for(int i=0;i<m;i++){
            cin >> data[i];
        }

        vector<pair<int,int> > ans(200);

        int cnt=0;

        for(int i=n_min;i<=n_max;i++){
            ans[cnt] = make_pair(data[i-1]-data[i],i);;
            cnt++;
        }


        int max = ans[0].first;
        int max_num = ans[0].second;

        for(int i=1;i<n_max-n_min+1;i++){
            //cout << ans[i].first << " " << ans[i].second << endl;
            if(max<=ans[i].first){
                //cout << i << endl;
                max = ans[i].first;
                max_num = ans[i].second;
            }
        }

        cout << max_num << endl;

    }

    /*5 2 4
    100
    90
    80
    75
    65 */

    return 0;
}


Measured memory_bytes: 3016
#include<stdio.h>
int main(){
  int n,d[1000000],c,i,j,t;
  while(1){
    scanf("%d",&n);
    c=0;
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&d[i]);
    }
    for(i=0;i<n;i++){
      for(j=1;i+j<n;j++){
	if(d[j]<d[j-1]){
	  t=d[j];
	  d[j]=d[j-1];
	  d[j-1]=t;
	  c++;
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 604
n = int(input())
s = input()

def calc():
    min_cost = n
    left_cost = 0
    right_cost = s.count('.')

    cost = left_cost + right_cost
    if cost < min_cost:
        min_cost = cost

    for i in range(n):
        if s[i] == '#':
            left_cost += 1
        else:
            right_cost -= 1
        cost = left_cost + right_cost
        if cost < min_cost:
            min_cost = cost

    return(min_cost)

print(calc())


Measured memory_bytes: 3500
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int D, L;

int main()
{
	in >> D >> L;
	out << D / L + D % L << std::endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b + c - max(a, max(b, c))) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var d = int.Parse(list[1]);

        var count = d * 2 + 1;

        Console.WriteLine((n + count - 1) / count);
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13140
"""
dfs活用問題
- 2部グラフ作成
- https://atcoder.jp/contests/abc126/tasks/abc126_d
"""
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
    (u, v, w) = map(int, input().split())
    graph[u-1].append([v-1, w])
    graph[v-1].append([u-1, w])


def dfs_recursive(n, graph):
    def dfs(graph, colors, cur, depth):
        colors[cur] = depth % 2
        for child in graph[cur]:
            child_index = child[0]
            if -1 != colors[child_index]:
                continue
            dfs(graph, colors, child_index, depth + child[1])
    colors = [-1 for _ in range(n)]
    dfs(graph, colors, 0, 0)
    for i in colors:
        print(i)


def dfs_with_queue(n, grpah):
    q = deque()
    ans = [-1 for _ in range(n)]
    q.append(0)
    ans[0] = 0
    while 0 != len(q):
        v = q.popleft()
        for neigbhor in graph[v]:
            u = neigbhor[0]
            w = neigbhor[1]
            if -1 != ans[u]:
                continue
            ans[u] = (ans[v] + w) % 2
            q.append(u)
        for i in ans:
            print(i)


dfs_recursive(n, graph)


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int ans=INF;
int n,m,t,c;

int main(){
	cin>>n>>m;
	rep(i,n){
		cin>>c>>t;
		if (t<=m){
			ans=min(ans,c);
		}
	}
	if (ans==INF){
		cout<<"TLE";
	}else{
		cout<<ans;
	}
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
pair<ll, int> arr[mxN];
int n;
ll d;
int dsu[mxN];
int find(int a) {
    return a == dsu[a] ? a : dsu[a] = find(dsu[a]);
}
bool merge(int a, int b) {
    a = find(a);
    b = find(b);
    if(a==b)return false;
    dsu[b] = a;
    return true;
}
vector<pair<ll, pair<int, int>>> edges;
pair<ll, int> segL[2*mxN];
pair<ll, int> segR[2*mxN];
void init() {
    owo(i, 0, 2*mxN) {
        segL[i] = {INFLL, INF};
        segR[i] = {INFLL, INF};
    }
}
void updL(int p, ll val) {
    for(segL[p+=n] = {val, p}; p>1; p>>=1) segL[p>>1] = min(segL[p], segL[p^1]);
}
void updR(int p, ll val) {
    for(segR[p+=n] = {val, p}; p>1; p>>=1) segR[p>>1] = min(segR[p], segR[p^1]);
}
pair<ll, int> qminL(int l, int r) {
    pair<ll, int> res = {INFLL, INF};
    r++;
    for(l+=n, r+=n; l<r; l>>=1, r>>=1) {
        if(l&1)res = min(res, segL[l++]);
        if(r&1)res = min(res, segL[--r]);
    }
    return res;
}
pair<ll, int> qminR(int l, int r) {
    pair<ll, int> res = {INFLL, INF};
    r++;
    for(l+=n, r+=n; l<r; l>>=1, r>>=1) {
        if(l&1)res = min(res, segR[l++]);
        if(r&1)res = min(res, segR[--r]);
    }
    return res;
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>d;
    init();
    owo(i, 0, n) {
        dsu[i] = i;
    }
    ll ans = 0;
    owo(i, 0, n) {
        cin>>arr[i].first;
        arr[i].second = i;
    }
    sort(arr, arr+n);
    owo(i, 0, n) {
        int pos = arr[i].second;
        pair<ll, int> left = qminL(0, pos);
        pair<ll, int> right = qminR(pos, n-1);
        if(left.second<n) {
            edges.senpai({left.first + arr[i].first + 1LL*d*arr[i].second, {left.second, arr[i].second}});
        }
        if(right.second<n) {
            edges.senpai({right.first + arr[i].first - 1LL*d*arr[i].second, {right.second, arr[i].second}});
        }
        updL(pos, arr[i].first - 1LL*d*arr[i].second);
        updR(pos, arr[i].first + 1LL*d*arr[i].second);
    }
    sort(edges.begin(), edges.end());
    for(auto p: edges) {
        if(merge(p.second.first, p.second.second)) {
            ans+=p.first;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 27992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 10005,MOD = 1e9+7;
int n,m;
ll X;
struct Edge{
    int u,v,w;
    bool operator < (const Edge& A)const{
        return w<A.w;
    }
}e[N];
int f[N];
int find(int x){
    return f[x]==x ? x :f[x]=find(f[x]);
}
ll Kruskal(int edge){
    ll sum = 0;
    for(int i=0;i<=n+1;i++) f[i]=i;
    int fx,fy;
    if(edge){
        fx=find(e[edge].u),fy=find(e[edge].v);
        f[fx]=fy;sum+=e[edge].w;
    }
    for(int i=1;i<=m;i++){
        if(i==edge) continue ;
        fx=find(e[i].u);fy=find(e[i].v);
        if(fx!=fy){
            f[fx]=fy;
            sum+=e[i].w;
        }
    }
    return sum;
}
ll qp(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=a*ans%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans ;
}
int main(){
    scanf("%d%d%lld",&n,&m,&X);
    for(int i=1;i<=m;i++)
        scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    sort(e+1,e+m+1);
    ll t = Kruskal(0);
    if(t>X){cout<<0;return 0;}
    int cnt1=0,cnt2=0;
    for(int i=1;i<=m;i++){
        ll now = Kruskal(i);
        if(now==X) cnt1++;
        else if(now>X) cnt2++;
    }
    if(t==X) cout<<(qp(2,cnt1)-2)*qp(2,cnt2)%MOD;
    else cout<<((ll)2*qp(2,cnt1)-2)%MOD*qp(2,cnt2)%MOD;
    return 0;
}

Measured memory_bytes: 384
judge = 1
while judge == 1:
    H, W = (int(x) for x in input().split())

    if H == 0 and W == 0:
        judge = 0
        break
    print("#"*W)
    H -= 2
    while H > 0:
        print("#", end="")
        print("."*(W-2), end="")
        print("#")
        H -= 1

    print("#"*W)
    print()


Measured memory_bytes: 5640
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let s = buf.trim();
    let n: usize = s.len() / 2;
    let m: usize = s.chars().filter(|&x| x == 'p').count();
    println!("{}", if n > m { n - m } else { 0 });
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	//abc100-B
	
	int D,N,num;
	int a=1;

	scanf("%d",&D);
	scanf("%d",&N);
	
	for(int i;i<D;i++){
	a*=100;
	}
	
	if(D==0){
		if(N==100){
			N=101;
		}
		num=100*D+N;
		printf("%d\n",num);
	}else{
		if(N==100){
			N=101;
		}
		num=a*N;
		printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int N, K;
    cin >> N >> K;

    int ans = 0;

    FOR(b, K + 1, N + 1){
        int p = N / b;
        ans += (b - K) * p;
        int r = N % b;
        ans += max((int)0, r - K + 1);
        if(K == 0) ans--;
    }
    

    cout << ans;

    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 256
import numpy as np


def main():
    H, W = map(int, input().split())

    ps = np.zeros([H, W])
    for i in range(H):
        ps[i, :] = list(map(lambda x: -1 if x == "#" else 0, input()))
    hashnum = np.sum(ps)

    costs = np.zeros([H, W])
    s = (0, 0)
    g = (H-1, W-1)
    dd = ((1, 0), (-1, 0), (0, 1), (0, -1))
    q = [s]
    costs[s] = 1
    ps[s] = 1
    moves = 1
    dame = 1

    while q:
        qn = []
        moves += 1
        for x, y in q:
            for dx, dy in dd:
                nx, ny = int(x + dx), int(y + dy)
                if 0 <= nx < H and 0 <= ny < W:
                    if ps[nx, ny] == 0:
                        costs[nx, ny] = moves
                        ps[nx, ny] = 1
                        qn.append((nx, ny))

        q = qn
        if g in q:
            dame = 0
            break

    if dame == 0:
        print(int(H * W + hashnum - np.max(costs)))
    else:
        print(-1)


main()


Measured memory_bytes: 12444
#include <cstdio>
long long f[2003]={0,0,0,1};
int main(){
    int s;scanf("%d",&s);
    for(int i=4;i<=s;i++) f[i]=(f[i-1]+f[i-3])%1000000007;
    printf("%lld\n",f[s]);
    return 0;
}

Measured memory_bytes: 1716
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;

const ll mod = 1000000007;
vector<ll> dp;
int n;
int a[21][21];

ll rec(ll state, int c) {
  if (dp[state] != -1) return dp[state];
  ll r = 0;
  rep(i, n) {
    if ((state & (1 << i)) && a[c][i]) r += rec(state ^ (1 << i), c + 1);
  }
  dp[state] = r = r % mod;
  return r;
}

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

  cin >> n;
  rep(i, n) rep(j, n) cin >> a[i][j];
  dp = vector<ll>(1 << n, -1);
  dp[0] = 1;
  cout << rec((1 << n) - 1, 0) << endl;
}

Measured memory_bytes: 16640
#include <stdio.h>

int main(){
  int n,k,q;
  if(scanf("%d%d%d",&n,&k,&q)==1){}
  int a[q];int i;
  for(i=0;i<q;i++){
    if(scanf("%d",&a[i])==1){}
  }
  int score[n];
  for(i=0;i<n;i++){
    score[i]=k-q;
  }
  for(i=0;i<q;i++){
    score[a[i]-1]+=1;
  }
  for(i=0;i<n;i++){
    if(score[i]>0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	string S, T, U;
    int A, B;
	cin >> S >> T >> A >> B >> U;

	if (S == U) {
		A--;
	} else {
		B--;
	}

    cout << A << " " <<B <<  endl;
    return 0;
}


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

using namespace std;
using ll = long long;

static const ll N = 200001;
static const long long MOD = 998244353;

struct Combination {
    vector<ll> fact, inv, finv;
    Combination(int n): fact(n+1), inv(n+1), finv(n+1) {
        fact[0] = fact[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i=2; i<n+1; i++) {
            fact[i] = fact[i-1] * i % MOD;
            inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    int operator() (int n, int k) {
        if(k < 0 || k > n) return 0;
        return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
    }
};

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

    Combination cmb(200001);

    ll ans = 0, col = m;
    for(int x=n-1; x>=0; x--) {
        ll now = col;
        now *= cmb(n-1, x);
        now %= MOD;
        if(x <= k) ans = (ans + now) % MOD;
        col *= m-1;
        col %= MOD;
    }

    cout << ans << endl;

    return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			B();
		}

		public static void B()
		{
			Scanner cin = new Scanner();
			int r = cin.Int();
			int d = cin.Int();
			int x2000 = cin.Int();
			long value = x2000;
			for (int i = 0; i < 10; i++) {
				value = r * value - d;
				Console.WriteLine(value);
			}
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 11092
N = int(input())
A = [0] * 9
for a in list(map(int, input().split())):
    A[min(a//400, 8)] += 1

ans = len(list(filter(lambda x: x>0, A[:-1])))

max_ans = ans+A[-1]

if A[-1] > 0:
    min_ans = max(1, ans)
else:
    min_ans = ans
print(min_ans, end=" ")
print(max_ans)

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

const int INF = 2e9;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    char now = 'a';
    char ans;
    bool ok = true;
    while(ok){
        if(now == 'a'){
            if(a.size() == 0){
                ok = false;
                ans = 'A';
            }
            else{
                now = a[0];
                a = a.substr(1);
            }
        }
        if(now == 'b'){
            if(b.size() == 0){
                ok = false;
                ans = 'B';
            }
            else{
                now = b[0];
                b = b.substr(1);
            }
        }
        if(now == 'c'){
            if(c.size() == 0){
                ok = false;
                ans = 'C';
            }
            else{
                now = c[0];
                c = c.substr(1);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];
	
	sort(a, a + 3);
	
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

string c[5];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
    FOR(i, 4) {
        cin >> c[i];
    }
    bool ok = false;
    FOR(i, 4) FOR(j, 4) FOR(k, 4) FOR(l, 4) {
        if (i != j && i != k && i != l && j != k && j != l && k != l) {
            string x = c[i] + c[j] + c[k] + c[l];
            if (x == "1974") ok = true;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

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

int N, M, temp;
const int max1 = 1500, max2 = 1500000;
vector<int> h(max1), w(max1);
int ans;
int range_h[max2], range_w[max2];


int main() {
  while(cin >> N >> M && N > 0) {

    for(int i = 0; i < N; i++) {
      cin >> h.at(i);
    }
    for(int i = 0; i < M; i++) {
      cin >> w.at(i);
    }
    for(int i = 0; i < max2; i++) {
      range_h[i] = 0;
      range_w[i] = 0;
    }

    for(int i = 0; i < N; i++) {
      temp = 0;
      for(int j = i; j < N; j++) {
        temp += h.at(j);
        range_h[temp]++;
      }
    }
    for(int i = 0; i < M; i++) {
      temp = 0;
      for(int j = i; j < M; j++) {
        temp += w.at(j);
        range_w[temp]++;
      }
    }

    ans = 0;
    for(int i = 0; i < max2; i++) {
      ans += range_h[i]*range_w[i];
    }
    cout << ans << endl;
    /*for(int i = 0; i < 8; i++) {                                              
      cout << range_h[i] << ' ';                                                
    }                                                                           
    for(int i =0; i < 8; i++) {                                                 
      cout << range_w[i] << ' ';                                                
      }*/
  }
}



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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
const int MAX = 1e5 + 1;
int arr[MAX];

int main()
{
	//IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		for(int i = 1; i <= 100; ++i)
		{
			for(int j = 1; j <= 100; ++j)
			{
				for(int k = 1; k <= 100; ++k)
				{
					int ind = i * i + j * j + k * k + i * j + i * k + k * j;
					arr[ind] += 1;
				}
			}
		}
		for(int i = 1; i <= n; ++i)
			cout << arr[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3788
n=int(input())
b=list(map(int,input().split()))
a=[0 for _ in range(n+1)]
a[0]=b[0]
a[n-1]=b[n-2]
for i in range(n-2):
    a[i+1]=min(b[i],b[i+1])
print(sum(a))


Measured memory_bytes: 3060