akhauriyash/Code-Regression huggingface dataset:
'''
参考
https://kakedashi-engineer.appspot.com/
https://note.com/sdestiny/n/nbd01567e6f7a
bit全探索を行う

※itertools.productについては以下を参照
https://note.nkmk.me/python-itertools-product/
'''
from itertools import product

N, M, X = map(int, input().split())
C = []
A = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

INF = 10**9    # 解（参考書合計価格の最小値）と比較するために便宜上設定
ans = INF

# N冊の参考書すべてについて、
# 「買う=1」「買わない=0」の組み合わせ全パターン作成し
# それぞれの組み合わせについて
# 「合計価格は最小か」「理解度はX以上になるか」を調べる
# （bit全探索）
for p in product([0, 1], repeat=N):
    skill = [0] * M     # 参考書によって上げることのできる理解度（初期化）
    cost = 0            # 参考書の価格
    for n in range(N):
        if p[n]:    # N冊目の参考書を「買う」場合
            for m in range(M):
                skill[m] += A[n][m] # その参考書で上げられる理解度を加算
            cost += C[n]
    
    if min(skill) >= X:
        ans = min(ans, cost)

if ans == INF:
    print(-1)   # ans が更新されていない（目標達成できない）
else:
    print(ans)


Measured memory_bytes: 8988
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	int N, K;
	cin >> N >> K;
	cout << (N + K - 3) / (K - 1);
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int L,a,b,c,d; scanf("%d%d%d%d%d",&L,&a,&b,&c,&d);
	printf("%d\n",L-max((a+c-1)/c,(b+d-1)/d));
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int h, w;
    cin >> h >> w;

    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Payment
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

char s[MAX_N + 4];
int dp[MAX_N + 1][2];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  for (int i = 0; i <= n; i++) dp[i][0] = dp[i][1] = INF;
  dp[0][0] = 0;

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int d = s[n - 1 - i] - '0';

    if (dp[i][0] < INF) {
      setmin(dp[i + 1][0], dp[i][0] + d);
      setmin(dp[i + 1][1], dp[i][0] + (10 - d));
    }
    if (dp[i][1] < INF) {
      setmin(dp[i + 1][0], dp[i][1] + d + 1);
      setmin(dp[i + 1][1], dp[i][1] + (10 - (d + 1)));
    }
  }

  printf("%d\n", min(dp[n][0], dp[n][1] + 1));
  return 0;
}


Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        String s =sc.next();
        char [] word = new char[s.length()];
        int len = s.length()-2;
        for(int i=0;i<s.length();i++){
            word[i] = s.charAt(i);
        }
        System.out.println(String.valueOf(word[0])+len+String.valueOf(word[s.length()-1]));
    }
}

Measured memory_bytes: 21844
l, r = map(int, input().split())
ans = float('inf')
for i in range(l, r):
    for j in range(i+1, r+1):
        if (i*j)%2019 == 0:
            print(0)
            exit()
        ans = min(ans, (i*j)%2019)
print(ans)

Measured memory_bytes: 9060
import collections

def U1(a,b):
    if b > a:
        b, a = a, b
    while a%b != 0:
        r = a%b
        a = b
        b = r
    return b

K = int(input())
c = 0
arr = []

for i in range(1,K+1):
    for j in range(1,K+1):
        arr.append(U1(i,j))

arr=collections.Counter(arr)

for key,value in arr.items():
    for k in range(1,K+1):
        c += U1(k,key)*value

print(c)

Measured memory_bytes: 9760
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	d := getInt()

	xs := make([][]int, n)
	for i := range xs {
		xs[i] = make([]int, d)
		for j := range xs[i] {
			xs[i][j] = getInt()
		}
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j <= n-1; j++ {
			distSquare := 0
			for k := 0; k < d; k++ {
				distSquare += (xs[i][k] - xs[j][k]) * (xs[i][k] - xs[j][k])
			}
			for k := 1; k*k <= distSquare; k++ {
				if k*k == distSquare {
					ans++
				}
			}
		}
	}

	fmt.Println(ans)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    int D,G;cin>>D>>G;
    int comp[D],num[D];
    rep(i,D){
        int p,c;cin>>p>>c;
        num[i]=p;
        comp[i]=(i+1)*100*p+c;
    }
    int ans=inf;
    rep(bit,1LL<<D){
        int score=0,now=0;
        rep(i,D){
            if(bit&(1LL<<i))score+=comp[i],now+=num[i];
        }
        if(G<=score){
            ans=min(ans,now);
            continue;
        }
        per(i,D){
            if(!(bit&(1LL<<i))){
                if(num[i]*(i+1)*100>G-score){
                    int p=(G-score+(i+1)*100-1)/((i+1)*100);
                    now+=p;
                    ans=min(ans,now);
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    int M, K; cin >> M >> K;
    if (M == 0) {
        cout << (K == 0 ? "0 0" : "-1") << "\n";
        return 0;
    }
    if (M == 1) {
        cout << (K == 0 ? "0 0 1 1" : "-1") << "\n";
        return 0;
    }
    if (1<<M <= K) {
        cout << "-1\n";
        return 0;
    }
    cout << K;
    for (int i = 0; i < 1<<M; i++)
        if (i != K) cout << " " << i;
    cout << " " << K;
    for (int i = (1<<M)-1; i >= 0; i--)
        if (i != K) cout << " " << i;
}

Measured memory_bytes: 1792
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>

using namespace std;

int comp(const int* a, const int* b) {
	if (*a < *b)
		return -1;
	else if (*a > *b)
		return 1;
	else
		return 0;
}

int main()
{
	while (true) {
		int n = 0, k = 0;
		cin >> n >> k;
		if (n == 0 && k == 0) break;

		int* cards = new int[k];
		bool blankCard = false;
		for (int i = 0; i < k; i++) {
			cin >> cards[i];
			if (cards[i] == 0) blankCard = true;
		}
		qsort(cards, k, sizeof(int), (int(*)(const void *, const void *))comp);

		int maxLength = 0;
		for (int i = 0; i < k;) {
			if (cards[i] > 0) {
				int prevNum = cards[i];
				int usedBlankCard = -1;
				int j = i + 1;
				int len = -1;
				for (; j < k; j++) {
					prevNum++;
					if (cards[j] != prevNum) {
						if (blankCard && usedBlankCard == -1 && cards[j] == prevNum + 1) {
							usedBlankCard = j;
							prevNum++;
						} else {
							len = cards[j - 1] - cards[i] + 1;
							break;
						}
					}
				}
				if (len == -1) len = cards[j - 1] - cards[i] + 1;
				if (len > maxLength) maxLength = len;
				if (usedBlankCard == -1) {
					i = j;
				} else {
					i = usedBlankCard;
				}
			} else {
				i++;
			}
		}
		cout << maxLength << endl;
	}

	return 0;
}

Measured memory_bytes: 1740
h, w = map(int, input().split())
s = [input() for _ in range(h)]
s = ['.'*(w+2)] + ['.'+l+'.' for l in s] + ['.'*(w+2)]
d = [0,1,0,-1,0]
check = True
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
            f = False
            for k in range(4):
                di = i+d[k+1]
                dj = j+d[k]
                if s[di][dj] == '#':
                    f = True
                    break
            if not f:
                check = False
                break
    if not check:
        break
print('Yes' if check else 'No')


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

int main(){
  int N, K; cin >> N >> K;
  
  int ans = 0;
  
  vector<int> h(N);
  for(int i=0; i<N; i++){
    cin >> h.at(i);
    if(h.at(i) >= K)
      ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
/*
 © 2020-09-19 07:00:13 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const int N = 1e6 + 5;
lli p[N];
lli fac(lli x){
  map<lli,lli> mp;
  lli res = 1;
  while(x > 1 and p[x] > 1){
    mp[p[x]]++;
    x /= p[x];
  }
  // cout << ": "; for(auto i : mp) cout << "(" << i.f << ',' << i.s << ") ";
  for(auto i : mp) res *= i.s + 1;
  return res;
}
lli div(lli x){
  lli res = 0;
  for(lli i = 1; i * i <= x; i++){
    if(x % i == 0){
      if(x/i == i) res++;
      else res += 2;
    }
  }
  return res;
}
int main(){ _
  iota(all(p), 0);
  p[0]= 1;
  for(lli i = 2; i * i <= N; i++) if(p[i] == i) for(lli j = i * i; j < N; j += i) p[j] = i;
  // fore(i, 0, 20) cout << p[i] << ' '; cout << ENDL;
  lli n; cin >> n;
  lli res = 0;
  fore(i, 1, n){
    // cout << n - i << ' ' << fac(n - i) << ENDL;
    res += fac(n - i);
  }
  cout << res << ENDL;
  return 0;
}


Measured memory_bytes: 11472
N = int(input())
A = list(map(int, input().split()))
import math
M = max(A)
MOD = 10 ** 9 + 7

def power_func(a, n, p):
    res = 1 #これは答え
    while n > 0:
        if n & 1:
            res = res * a % p
        a = a * a % p #1が立っているかどうかに関わらず次のaの累乗を用意しておく
        n = n >> 1
    return res

bucket = [0] * (M + 1)
for val in A:
    for i in range(2, math.floor(math.sqrt(val)) + 1):
        #print(val, i)
        temp = 0
        while val % i == 0:
            val //= i
            temp += 1
        bucket[i] = max(bucket[i], temp)
    if val != 1:
        bucket[val] = max(bucket[val], 1)
#print(bucket)

L = 1
for n in range(M + 1):
    L = (L * n ** bucket[n]) % MOD
#print(L)

ans = 0
for val in A:
    ans = (ans + power_func(val, MOD - 2, MOD))
ans = (ans * L) % MOD
print(ans)


Measured memory_bytes: 53212
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define M 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
const int INF = 1e18L+5;
const int LG = 20;
const int N = 1e5+9;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int power(int x,int y){int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}
bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}
int32_t main()
{
	//cout.precision(15);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int x,ans=0,a=100,i;
		cin>>x;
		for(i=1;i<=4000;i++)
		{
			a=a+a/100;
			if(a>=x)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
}


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

int main(){
  uint64_t N;
  cin >> N;
  
  set<string> S;

  for( uint64_t i = 0; i < N; ++i ){
    string temp_str;
    cin >> temp_str;
    S.insert(temp_str);
  }

  cout << S.size() << endl;

}

Measured memory_bytes: 19256
#include<stdio.h>
int main(void)
{
    int a,b,k,n;
    scanf("%d %d %d",&k,&a,&b);
    int i;
    for(i=a;i<=b;i++){
       if(i%k==0){
           printf("OK\n");
           return 0;
       }
    }
    printf("NG\n");

    return 0;
}

Measured memory_bytes: 1664
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  ll ans = 0;
  repr(i, 1, n+1){
    if(i%3!=0 && i%5!=0){
      ans += i;
    }
  }
  print(ans);
}


Measured memory_bytes: 3652
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
int n;
vector<vector<int>> g;
vector<int> res;
map<pair<int, int>, int> mp;
void dfs(int u, int p, int c) {
    int d = 1;
    for (int v : g[u]) {
        if (v == p) continue;
        if (d == c) ++d;
        res[mp[make_pair(u, v)]] = d;
        dfs(v, u, d);
        ++d;
    }
}
int main() {
    cin >> n;
    g.resize(n + 1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        mp[make_pair(a, b)] = i;
        mp[make_pair(b, a)] = i;
    }
    res.resize(n + 1);
    dfs(1, 0, 0);
    int k = 0;
    for (int u = 1; u <= n; ++u) {
        k = max(k, int(g[u].size()));
    }
    cout << k << endl;
    for (int i = 0; i < n - 1; ++i) {
        cout << res[i] << endl;
    }
    return 0;
}

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

int main()
{
  int n, k;
  int64_t ans;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (int i = 0; i < n; ++i)
    cin >> h[i];
  sort(h.begin(), h.end());

  ans = h[k - 1] - h[0];
  for (int i = 1; i < n - k + 1; ++i)
  {
    ans = min(h[i + k - 1] - h[i], ans);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	int i;
	for(i = 0; ans < n; i++){
		ans += i;
	}
	cout << i - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[] = {-1,0,1,0,-1,-1,1,1};
const int dy[] = {0,-1,0,1,1,-1,1,-1};
#define MAX 100000
#define MAX_E 100000

int par[MAX], friends[MAX];
//初期化
void init(int n){
  rep(i,n){
    par[i]=i;
    friends[i]=0;
  }
}
//親要素の取得
int find(int x){
  if(par[x]==x) return x;
  return par[x]=find(par[x]);
}
//要素同士の結合
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(friends[x]<friends[y]) par[x]=y;
  else {
    par[y]=x;
  }
  if(friends[x]==friends[y]) friends[x]++;
}
//同じ親要素を持つか判断する関数
bool same(int x,int y){
  return (find(x)==find(y));
}
//辺を定義
struct edge{int u, v, cost;};
//辺同士の比較
bool comp(const edge &e1, const edge &e2){
  return e1.cost<e2.cost;
}
int v,e;
edge es[MAX_E];
int kruskal(){
  sort(es,es+e,comp);
  init(v);
  int res=0;
  rep(i,e){
    edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}
int main(){
  int s,t,w;
  cin>>v>>e;
  rep(i,e){
    cin>>s>>t>>w;
    es[i]=(edge){s,t,w};
  }
  cout<<kruskal()<<endl;
  return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

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

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int X, Y;
	cin >> X >> Y;
	if (Y % 2 == 0 && 2*X <= Y && Y <= 4*X) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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


Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

template< typename T >
struct edge {
    int to;
    T cost;

    edge(int to, T cost) : to(to), cost(cost) {}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M,s,t; cin >> N >> M >> s >> t;
    s--; t--;
    vector<vector<edge<ll>>> A(N),B(N);
    rep(i,M) {
        int u,v,a,b; cin >> u >> v >> a >> b;
        u--; v--;
        A[u].emplace_back(v,a);
        A[v].emplace_back(u,a);
        B[u].emplace_back(v,b);
        B[v].emplace_back(u,b);
    }

    vector<ll> distA(N,1e18),distB(N,1e18);
    distA[s] = 0; distB[t] = 0;
    vector<bool> cA(N),cB(N);
    priority_queue<pll, vector<pll>, greater<pll>> pq;

    pq.emplace(0,s);
    while (!pq.empty()) {
        ll D,v;
        tie(D,v) = pq.top(); pq.pop();
        cA[v] = true;
        if (D > distA[v]) continue;
        for (auto e : A[v]) {
            if (cA[e.to]) continue;
            if (chmin(distA[e.to], distA[v]+e.cost)) pq.emplace(distA[e.to],e.to);
        } 
    }
    pq.emplace(0,t);
    while (!pq.empty()) {
        ll D,v;
        tie(D,v) = pq.top(); pq.pop();
        cB[v] = true;
        if (D > distB[v]) continue;
        for (auto e : B[v]) {
            if (cB[e.to]) continue;
            if (chmin(distB[e.to], distB[v]+e.cost)) pq.emplace(distB[e.to],e.to);
        } 
    }

    vector<ll> ans(N);
    ans[N-1] = distA[N-1] + distB[N-1];
    for (int i = N-2; i >= 0; i--) {
        ans[i] = min(ans[i+1],distA[i]+distB[i]);
    }

    rep(i,N) cout << 1000000000000000 - ans[i] << endl;
}


Measured memory_bytes: 19576
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;

ll dp[3005][6005], dp1[3005][6005];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    mod = 998244353;
    ll n; cin >> n;
    ll s; cin >> s;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    dp[0][0] = 1;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < 3002; j++) {
            (dp[i + 1][j + a[i]] += dp[i][j]) %= mod;            
        }
        for (ll j = 0; j < 3002; j++) {
            (dp[i + 1][j] += 2 * dp[i][j]) %= mod;
        }
    }

    cout << dp[n][s] << endl;

    return 0;
}

/*

*/

Measured memory_bytes: 116444
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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

  if(a==1)a=14;
  if(b==1)b=14;

  if(a>b){
    cout << "Alice";
  }else if(a==b){
    cout << "Draw";
  }else{
    cout << "Bob";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int i,n, data[10000],min,max;
    long long int sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &data[i]);
    }
    min = data[0];
    max = data[0];
    for (i = 0; i < n; i++){
        if (min>data[i]){
        min = data[i];
        }if (max < data[i]){
            max = data[i];
        }
        sum +=data[i];
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
} 

Measured memory_bytes: 1860
#include <iostream>
#include <cstdio>
using namespace std;
int n, x, t;
long long sum;
int main() {
	scanf("%d %d %d", &n, &x, &t);
	if(n % x != 0) {
		printf("%lld", (n / x + 1)* t); 
	}
	else{
		printf("%lld", (n / x)* t); 
	}
	return 0;
}

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

int main(){
    char a,b;cin >> a >> b;
    if (a == 'H'){
        cout << b << endl;
    }

    if (a == 'D'){
        if (b == 'H'){
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n+2,0);
  int sum=0;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n]);
  for(int i=1;i<=n;i++){
    int t=0;
    if((a[i]-a[i-1])*(a[i+1]-a[i])<0){
      t=min(abs(a[i]-a[i-1]),abs(a[i]-a[i+1]))*2;
    }
    cout << sum - t << endl;
  }
}

Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
ll answer, N, X;

void solve(int light_direction, ll x, ll y, ll limit_1, ll limit_2, ll limit_3, ll limit_4, ll limit_5){
	if(light_direction == 0){
		if(limit_3 - y < limit_2 - (x + y)){
			ll length = limit_3 - y, zigzag = min((limit_1 - x - 1)/length, (limit_2 - (x + y))/length);
			x += length*zigzag;
			limit_4 += length*zigzag;
			limit_5 += length*zigzag;
			answer += length*(zigzag*2 + 1);
			solve(2, x, limit_3, limit_1, limit_2, limit_3, x, limit_5);
		}else{
			answer += limit_2 - (x + y);
			solve(1, x, limit_2 - x, x, limit_2, limit_3, limit_4, limit_5);
		}
	}else if(light_direction == 1){
		answer += x - limit_4;
		solve(2, limit_4, y, limit_1, limit_2, y, limit_4, limit_5);
	}else{
		if(y <= limit_1 - x){
			answer += y;
			if(x + y == N - X){
				printf("%lld\n", answer);
				return;
			}else solve(0, x + y, 0, limit_1, limit_2, limit_3, limit_4, x + y);
		}else{
			ll length = (limit_1 - limit_4), zigzag = (y - 1)/length;
			answer += zigzag*2*length;
			solve(1, limit_4, y - zigzag*length, limit_1, x + y - (zigzag - 1)*length, y - zigzag*length, limit_4, limit_5);
		}
	}
}

int main(){
	scanf("%lld %lld", &N, &X);
	solve(0, N - X, 0, N, N, N, 0, 0);
	return 0;
}

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

int main()
{
    int xmin=0,ymin=0,xmax,ymax,n;
    cin>>xmax>>ymax>>n;
    for(int i=0;i<n;i++)
    {
        int a,x,y;
        cin>>x>>y>>a;
        if(a==1)    xmin=max(x,xmin);
        if(a==2)    xmax=min(x,xmax);
        if(a==3)    ymin=max(y,ymin);
        if(a==4)    ymax=min(ymax,y);

    }
    if(xmin<xmax && ymin<ymax)
        cout<<(xmax-xmin)*(ymax-ymin);
    else
        cout<<0;
    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif

bool cmp(pair<ll,ll> a,pair<ll,ll> b){
	return a.S<b.S;
}
//
int main()
{
	GO
	//fioe();
	ll n;
	cin>>n;
	VII v;
	for(ll i=0;i<n;i++){
		ll x,l;
		cin>>x>>l;
		v.pb(mp(x-l,x+l));
	}
	sort(v.begin(),v.end(),cmp);
	ll curr=v[0].S,ans=1;
	for(ll i=1;i<n;i++){
		if(curr<=v[i].F){
			ans++;
			curr=v[i].S;
		}
	}
	cout<<ans<<endl;
	time();
	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.141952
int main(){
  
  ll N,M,doing;
  cin >> N >> M;
  ll A[M];
  doing = 0;
  for(int i = 0;i < M; i++)  cin >> A[i],doing += A[i]; 
  
  ll ans = -1;
  if(N >= doing)  ans = N - doing;
  cout << ans << endl; 
  
  return 0;
}

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


int main (int argc, char const *argv[])
{
    int N,A,B;
    cin>>N>>A>>B;
    int num=N*A;

    cout<<min(num,B)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,v,a,b,c,d,e;
int main(){
    cin>>n;
    while(n--)
        cin>>v,a+=v,b=min(b+(v?v%2:2),a),c= min(c+!(v%2),b),d=min(d+(v?v%2:2),c),e=min(e+v,d);cout<<e;}


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

using namespace std;

typedef long long ll;
ll Min, N, K, Ans;

int main()
{
	scanf ("%lld", &N);
	while (N--)
	{
		scanf ("%lld", &K);
		if (K >= Min) Min = K;
		else Ans += Min - K;
	}
	printf ("%lld\n", Ans);
	//system("pause");
  return 0;
}

Measured memory_bytes: 3788
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    long n = Long.parseLong(sc.next());
    if (n < 2) {
      pw.println(0);
      return;
    }
    if (n % 2 == 1) {
      pw.println(0);
      return;
    }
    long ans = 0;
    long divider = 10;
    while (n >= divider) {
      ans += (n / divider);
      divider *= 5;
    }
    pw.println(ans);
  }
}


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

int a[101];
bool dp[100005][2];
int main(){
	int n, k;
	cin >> n >> k;
	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	sort(a, a + n);
	
	for(int i = 0; i < n; i++){
		dp[a[i]][0] = dp[a[i]][1] = 1;
	}
	
	for(int i = 0; i <= k; i++){
		for(int j = 0; j < n && i - a[j] >= 0; j++){
			for(int p = 0; p < 2; p++){
				dp[i][p] |= !dp[i - a[j]][!p];
			}
		}
	}
	
	cout << (dp[k][0] ? "First" : "Second");
}





Measured memory_bytes: 384
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int n;
	cin>>n;
	string s;
	cin>>s;
	int MOD=1000000007;
	int t=1;
	rep(i,n)(t*=i+1)%=MOD;
	int c=0;
	int w=1;
	rep(i,n*2){
		// cout<<w<<" "<<(s[i]=='B')<<" "<<c<<endl;
		if(w==(s[i]=='B'));
		else{
			w^=1;
		}
		w^=1;
		if(i%2!=w){
			if(c<0){
				cout<<0<<endl;
				return 0;
			}
			(t*=c)%=MOD;
			c--;
		}else c++;
	}
	if(c){
		t=0;
	}
	cout<<t<<endl;
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
#include <random>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;
 
 
void reader(int &a){scanf("%d",&a);}
void reader(double &a){scanf("%lf",&a);}
void reader(char a[]){scanf("%s",a);}
void reader(ll &a){scanf("%lld",&a);}
void reader(ull &a){scanf("%llu",&a);}
// void reader(string& a){cin >> a;};
template<class T,class U> void reader(T& t,U& u){reader(t); reader(u);}
template<class T,class U,class V> void reader(T& t,U& u,V& v){reader(t); reader(u); reader(v);}
 
void writer(int a,char c) {printf("%d",a); putchar(c);}
void writer(ll a,char c) {printf("%lld",a); putchar(c);}
void writer(double a,char c) {printf("%.20lf",a); putchar(c);}
void writer(char a[]) {printf("%s",a);};
void writer(char a[],char c) {printf("%s",a);putchar(c);};
void writer(char a,char c) {putchar(a); putchar(c);};
template<class T>void writerLn(T t){writer(t,'\n');}
template<class T,class U>void writerLn(T t,U u){writer(t,' ');writer(u,'\n');}
template<class T,class U,class V> void writerLn(T t,U u,V v){writer(t,' ');writer(u,' ');writer(v,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
template<class T> void writerVec(vector<T> x){int n=x.size();int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
 
vector<std::string> split(const std::string &str, char sep){std::vector<std::string> v;std::stringstream ss(str);std::string buffer;while(std::getline(ss,buffer,sep)){v.push_back(buffer);}return v;}
 
// #define int ll
bool test = false;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
ull mod = (int)1e9 + 7;
//..................
int H;
int a[10][6];
int cnt = 0;
void erace() {
  int i,j,k;
  rep(i,H) rep(j,3) {
	if(a[i][j] == -1) continue;
	if(a[i][j] == a[i][j+1] && a[i][j] == a[i][j+2]) {
	  int target = a[i][j];
	  REP(k,j,5) {
		if (a[i][k] == target) {
		  cnt += target; a[i][k] = -1;
		}
		else break;
	  }
	}
  }
  /*
  rep(i,H) {
	rep(j,5) {
	  printf("%d ",a[i][j]);
	}
	puts("");
  }
  */
}
signed main(){
  int i,j,k,l;
  while(1) {
	cnt = 0;
	cin >> H;
	if (H == 0) break;
	rep(i,H) rep(j,5) {
	  reader(a[i][j]);
	}
	bool is_continue = true;
	while(is_continue) {
	  erace();
	  is_continue = false;
	  rep(k,5) {
		for(i=H-1;i>-1;i--) {
		  if(a[i][k] != -1) continue;
		  for(j=i-1;j>-1;j--) {
			if(a[j][k] != -1) break;
		  }
		  if(j != -1) is_continue = true;
		  
		  a[i][k] = a[j][k];
		  a[j][k] = -1;
		}
	  }
	}
	cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3208
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iostream>
#include <limits>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cmath>


using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef stringstream ss;
const int mii = numeric_limits<int>::min();
const int mai = numeric_limits<int>::max();
const ll mil = numeric_limits<long long>::min();
const ll mal = numeric_limits<long long>::max();

#define REP(i, a, b) for(long long i=a; i<=b; ++i)
#define RREP(i, a, b) for(long long i=a; i>=b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

int main(int argc, char **argv) {
    string s;
    cin >> s;

    set<char> chars;
    for(auto c : s)
        chars.insert(c);

    if(chars.size() > 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M,K = MI()
mod = 10**9+7


def kaijou(n):
    res = 1
    for i in range(1,n+1):
        res *= i
        res %= mod
    return res

def nCr(n,r):
    return (kaijou(n)*pow(kaijou(r),mod-2,mod)*pow(kaijou(n-r),mod-2,mod)) % mod


a = N*(N+1)*(N-1)//6 * M**2 + M*(M+1)*(M-1)//6 * N**2
a %= mod
print((nCr(N*M-2,K-2) * a) % mod)


Measured memory_bytes: 62624
using System;
using static System.Console;


class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine().Split();
        if (str[0] == "H")
            WriteLine(str[1]);
        else if (str[1] == "H")
            WriteLine("D");
        else
            WriteLine("H");
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}


Measured memory_bytes: 2600
from collections import deque
 
 
walk = [(1, 0), (-1, 0), (0, 1), (0, -1)]
warp = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
        (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
        (0, -2), (0, -1), (0, 1), (0, 2),
        (1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
        (2, -2), (2, -1), (2, 0), (2, 1), (2, 2),]
 
 
def get_warped(walked, map_):
    warped = deque()
    while walked:
        h, w = walked.popleft()
        for i, j in warp:
            h2 = h + i
            w2 = w + j
            if -1 < h2 < H and -1 < w2 < W and map_[h2][w2] == '.':
                warped.append((h2, w2))
                map_[h2][w2] = map_[h][w] + 1
    return warped, map_
 
 
def get_walked(candidate, map_):
    walked = deque()
    while candidate:
        h, w = candidate.popleft()
        walked.append((h, w))
        for i, j in walk:
            h2 = h + i
            w2 = w + j
            if -1 < h2 < H and -1 < w2 < W and map_[h2][w2] == '.':
                candidate.append((h2, w2))
                map_[h2][w2] = map_[h][w]
    return walked, map_
 
H, W = map(int, input().split())
s_h, s_w = [i-1 for i in map(int, input().split())]
d_h, d_w = [i-1 for i in map(int, input().split())]
map_ = [list(input()) for i in range(H)]
 
candidate = deque([(s_h, s_w)])
map_[s_h][s_w] = 0
 
while candidate:
    walked, map_ = get_walked(candidate, map_)
    candidate, map_ = get_warped(walked, map_)
 
for h in range(H):
    for w in range(W):
        if map_[h][w] == '.':
            map_[h][w] = -1
 
print(map_[d_h][d_w])

Measured memory_bytes: 155764
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? (a=b,1) : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    i64 a, b, K;
    cin >> a >> b >> K;

    rep(i, K) {
        if (i % 2 == 0) {
            if (a & 1) --a;
            b += a / 2;
            a /= 2;
        } else {
            if (b & 1) --b;
            a += b / 2;
            b /= 2;
        }
    }

    cout << a << ' ' << b << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	if(x==1||x==n+n-1){
		puts("No");
	}
	else{
		puts("Yes");
		if(x==2){
			for(int i=n+2;i<n+n;i++){
				printf("%d\n",i);
			}
			for(int i=1;i<n+2;i++){
				printf("%d\n",i);
			}
		}
		else{
			int now=1;
			for(int i=0;i<n-3;i++){
				if(now==x-2) now=x+2;
				printf("%d\n",now++);
			}
			printf("%d\n%d\n%d\n%d\n",x-1,x,x+1,x-2);
			for(int i=0;i<n-2;i++){
				if(now==x-2) now=x+2;
				printf("%d\n",now++);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(x+r <= w && x-r >= 0 && y+r <= h && y-r >= 0)
			System.out.println("Yes");
		else System.out.println("No");

	}

}



Measured memory_bytes: 26356
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>S;
    N = S.size();
    cout<<S[0]<<N-2<<S[N-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b);
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int N,X;
int L[101];
int D[101];
int count = 1;

void D_i(int i){
	D[i] = D[i-1] + L[i-1];
	if(D[i] > X) return;
	else {
		count++;
		D_i(i+1);
	}
}

int main(){
	cin >> N >> X;
	for(int i = 1; i <= N; i++){
		cin >> L[i];
	}
	D[1] = 0;
	D_i(2);
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int A[110];
int main(){
	int a,b,c,x,y;
	cin >>  b >> c >> a >> x >> y;
	int ans1 = x * b + y * c;
	int ans2 = max(x,y) * 2 * a; 
	int ans3 = min(x,y) * 2 * a + b * (x - min(x,y)) + c * (y - min(x,y));
	int ans = min(ans1,ans2);
	ans = min(ans,ans3);
	//cout << ans1 << " " << ans2 << "  " << ans3 << endl;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint K;
llint A[100005];

int main(void)
{
	cin >> K;
	for(int i = 0; i < K; i++) cin >> A[i];
	reverse(A, A+K);
	
	llint m = 2, M = 2;
	for(int i = 0; i < K; i++){
		m = (m+A[i]-1)/A[i] * A[i];
		M = (M/A[i] + 1) * A[i] - 1;
		if(m > M){
			cout << -1 << endl;
			return 0;
		}
	}
	
	cout << m << " " << M << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  string s, t;
  cin >> s >> t;
  int sum = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != t[i]) sum++;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3912
#include<stdio.h>
int main(void)
{
	int a,s,d,f,i,g;
	scanf("%d",&a);
	while(a!=0){
	f=0;
	g=0;
	for(i=1;i<=a;i++){
		scanf("%d %d",&s,&d);
		if(s>d){
			f=f+s+d;
		}
		else if(d>s){
			g=g+s+d;
		}
		else if(d==s){
			g=g+d;
			f=f+s;
		}
	}
	printf("%d %d\n",f,g);
	scanf("%d",&a);
	}
	return 0;
}

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    string S;
    cin >> S;

    bool flag = true;
    for(int i=0; i<S.size(); i++){
        if(i%2){    // 偶数
            if(S[i]=='R')   flag = false;
        }else{      // 奇数
            if(S[i]=='L')   flag = false;
        }
    }

    if(flag)    show("Yes");
    else        show("No");
    
    return 0;
}


Measured memory_bytes: 256
a[2][101],n,m,i,j,c,p;main(s){for(;scanf(m="%d",&n),n;printf(m>210?"NA\n":"%d\n",m)){for(i=2;i--;)for(j=0;j-n;scanf(m,a[i]+j++));for(;++i-2;m>c?m=c:0)for(j=i,c=p=0;s=a[j][p],c<220&&s>1|n+~p;)p<n&s<2?s-1|a[j][p+1]-1?p+=2,j=1&~j,++c:++p:--p;}}

Measured memory_bytes: 0