akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

constexpr i64 MOD = 1 ? 1'000'000'007 : 998'244'353;
using m64 = modint<MOD>;
constexpr m64 operator"" _m(unsigned long long n) { return m64(n); }

template<typename T>
struct combinatorics {
    vector<T> fac;

    combinatorics(i64 n): fac(2*n+1) {
        fac[0] = 1;
        for (i64 i = 1; i <= 2*n; i++) fac[i] = fac[i-1] * i;
    }

    T p(i64 n, i64 k) const {
        if (k < 0 || n < k) return 0;
        return fac[n] / fac[n-k];
    }

    T c(i64 n, i64 k) const {
        if (k < 0 || n < k) return 0;
        return fac[n] / (fac[k] * fac[n-k]);
    }

    T h(i64 n, i64 k) const {
        return c(n+k-1, k);
    }
};

void solve() {
    i64 n, m;
    cin >> n >> m;

    combinatorics<m64> c(m);
    m64 ans = 0;
    for (i64 i = 0; i <= n; i++) {
        ans += c.c(n, i) * (i % 2 ? -1 : 1) * c.p(m, i) * c.p(m - i, n - i) * c.p(m - i, n - i);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 11100
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main(){
    int n,x;
    cin>>n>>x;
    int a[114514];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=abs(a[0]-x);
    for(int i=1;i<n;i++){
        ans=gcd(ans,abs(a[i]-x));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int n,to[maxn],vis[maxn],st[maxn],ring[maxn],inring[maxn],top=0;
long long m;
int getring()
{
	vis[1]=1;
	int p=1;
	st[++top]=1;
	for(;;)
	{
		if(vis[to[p]]){
			int i,len=0;
			for(i=1;i<=top;++i)if(st[i]==to[p]) break;
			for(;i<=top;++i) ring[len++]=st[i],inring[st[i]]=1;
			return len;
		} else {
			vis[to[p]]=1;
			st[++top]=to[p];
			p=to[p];
		}
	}
}
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&to[i]);
	int len=getring(),rem=0,i=1;
	while(!inring[i]) i=to[i],rem++;
	if(m<rem){
		printf("%d",st[m+1]);
		return 0;
	}
	int j=0;
	for(;ring[j]!=i;++j);
	printf("%d",ring[(m-rem+j+len)%len]);
	return 0;
}

Measured memory_bytes: 7604
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

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


Measured memory_bytes: 3832
from collections import Counter
from itertools import product

H, W, K = map(int, input().split())
lists = [list(input()) for _ in range(H)]


def cnt_black(lists):
    cnt = 0
    for lis in lists:
        cnt += Counter(lis).get('#', 0)
    return cnt


def to_red(lists, row_ops, col_ops):
    lists = lists.copy()
    for idx in range(H):
        if row_ops[idx] == '1':
            lists[idx] = ['r'] * W
    for idx in range(W):
        if col_ops[idx] == '1':
            lists = [lis[:idx] + ['r'] + lis[idx + 1:] for lis in lists]
    return lists

row_patterns = [format(n, f'0{H}b') for n in range(2 ** H)]
col_patterns = [format(n, f'0{W}b') for n in range(2 ** W)]

cnt = 0
for row_ops, col_ops in product(row_patterns, col_patterns):
    red_lists = to_red(lists, row_ops, col_ops)
    if cnt_black(red_lists) == K:
        cnt += 1
print(cnt)


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

count = 0
r=0
g=0
b=0
for i in range(0,n):
  if s[i] == 'R':
    r = r + 1
  if s[i]=='G':
    g = g+1
  if s[i]=='B':
    b = b+1
    
for i in range(0,n):
  ii = s[i]
  for j in range(i+1, n):
    jj = s[j]
    if ii==jj:
      continue
    if (2*j-i)<=(n-1):
      if ii!=s[2*j-i] and jj!=s[2*j-i]:
        count = count + 1
print(r*g*b-count)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main(){
int r,d;
int x[11];

cin>>r>>d>>x[0];

int i;
for(i=1;i<=10;i++){
x[i]=x[i-1]*r - d;
}
for(i=1;i<=10;i++){
cout<<x[i]<<endl;
}

}


Measured memory_bytes: 3572
#include <iostream>
#include <math.h>
#include <strings.h>
using namespace std;

int main()
{
    long long N,A,B,M,r,l;
    cin>>N>>A>>B;
    if(N<A){
        cout<<N;
    }else if(N<=(A+B)){
        cout<<A;
    }else
    {
      r=N/(A+B);
      l=N%(A+B);
      if(l>A){
          l=A;
      }
      M=l+(r*A);
    cout<<M;
    }
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
	int i;
	while (1) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) {
			return 0;
		}
		if (a <= b) {
			printf("%d %d\n", a, b);
		} else {
			printf("%d %d\n", b, a);
		}
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main()
{
	ll n;
	cin>>n;
	ll c = 0;
	ll arr[n+1];
	REP(i,1,n+1){
		cin>>arr[i];
		if(i % 2 && arr[i] % 2) c++;
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

template<typename T>
constexpr T _gcd(T m, T n) noexcept {
	T g = 1;

	while (m != 0) {
		if (m < n) std::swap(m, n);
		
		if (m & 1) {
			if (n & 1) m = (m - n) >> 1;
			else n = n >> 1;
		}
		else {
			if (n & 1) {
				m = m >> 1;
			}
			else {
				n = n >> 1;
				m = m >> 1;
				g = g << 1;
			}
		}
	}

	return g * n;
}

int main(){
  int x;
  cin >> x;
  cout << 360 / _gcd(x, 360) << "\n";
  
  return 0;
}

Measured memory_bytes: 3608
from collections import deque
n, m = map(int, raw_input().split())
graph = {_: set() for _ in xrange(n + 1)}
in_deg, dist = [0] * (n + 1), [-1] * (n + 1)
for _ in xrange(m):
    l, r, d = map(int, raw_input().split())
    graph[l].add((r, d))
    in_deg[r] += 1
que = deque([i for i in xrange(n + 1) if not in_deg[i]])
cst = 1
while que:
    stp = que.popleft()  # start_point
    if in_deg[stp] < 0:
        in_deg[stp] = cst
    for v, d in graph[stp]:
        if dist[v] < 0:
            dist[v] = dist[stp] + d
        else:
            if dist[v] != dist[stp] + d:
                print 'No'
                exit()
        in_deg[v] -= 1
        if not in_deg[v]:
            que.append(v)
print 'No' if [_ for _ in in_deg[1:] if _ > 0] else 'Yes'


Measured memory_bytes: 62892
#include <stdio.h>

int main(void){
	int N, i;
	scanf("%d", &N);
	int A[N], cnt[N];
	for (i = 0; i <= N; i++){
		cnt[i] = 0;
	}
	for (i = 2; i <= N; i++){
		scanf("%d", &A[i]);
	}
	for (i = 2; i <= N; i++){
		cnt[A[i]]++;
	}
	for (i = 1; i <= N; i++){
		printf("%d\n", cnt[i]);
	}
}

Measured memory_bytes: 3292
#include <iostream>
#include <stdlib.h>
#include <string>
#include <sstream>

using namespace std;
int pow_10(int n)
{
	int ans = 1;
	for (int i = 0; i < n; i++) 
		ans *= 10;
	return ans;
}

int reverse_int(int n)
{
	int num[5];
	int ans = 0;
	for (int i=0; i< 5; i++){
		num[i] = n %10; // num[i]はnを10で割った余り
		n /= 10; // nを10で割ることで更新
		num[i] *= pow_10(4-i);
		// cout << "num[" << i << "] = " << num[i] << '\n';
		ans += num[i];
	}
	return ans;
}

int main()
{
	int A, B;
	cin >> A >> B;
	int count = 0;

	for (int i = A; i <= B; i++) {
		if (i == reverse_int(i)) {
			count++;
			// cout << "i = " << i << '\n';
		}	
	}
	cout << count << '\n';
}

Measured memory_bytes: 3580
#include <iostream>

using namespace std;

int main(void)
{
    int X, A, B;
    cin >> X >> A >> B;

    if(A >= B) cout << "delicious" << endl;
    else if((B - A) <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 384
import math

a, b, x = map(int, input().split())

if x/(a*a*b) <= 0.5: #水が水筒の半分以下の場合
    h = x/a/b*2
    hy2 = (h*h + b*b)
    cosa = (hy2 + b*b - h*h )/(2*(hy2**0.5)*b)
    d = 180 - math.degrees(math.acos(cosa)) - 90
else:
    rest = (a*a*b - x)/a
    tan = rest*2/(a*a) #空の部分の面積は、a*atanθ/2 = a*a*b - x
    d = math.degrees(math.atan(tan))

print(d)

Measured memory_bytes: 3188
a, b = input().split()

a = int(a)
b = int(b)

count = 0

if b == 1:
    print('0')
else:
    while True:
        if b <= a:
            count += 1
            break
        elif b <= 0:
            break
        else:
            b = b - a + 1
            count = count + 1

    print(count)

Measured memory_bytes: 3060
while line = gets
  formula = line.chomp
  o, p, q = formula.split(/(\+|=)/).select { |x| x !~ /\+/ && x !~ /=/ }
  l, r = formula.split('=')

  range = 0..9
  [o, p, q].each do |value|
    if value.gsub('X', '0') != value.gsub('X', '0').to_i.to_s
      range = 1..9
      break
    end
  end

  answer = :NA
  for i in range
    if eval(l.gsub('X', i.to_s)).to_i == r.gsub('X', i.to_s).to_i
      answer = i
      break
    end
  end

  puts answer
end

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

const int L = 32;
int n, x, ans, a, cnt[L];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		cnt[__builtin_ctz(a)]++;
		x ^= a;
	}
	
	bool t = 1;
	for (int i = L - 1; i >= 0; i--){
		if((x >> i) % 2 == t){
			if(cnt[i] == 0)
				return cout << -1, 0;
			t = 1 - t;
			ans++;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 384
import sys

while(1):
    n, x = map(int, input().split())
    if n+x == 0:
        sys.exit()
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if x-i-j > j and x-i-j <= n:
                ans += 1
    print(ans)


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

int main(){
  int n , k;
  cin >> n >> k;
  int ret = 0;
  for(int i = 1; i <= n; ++i){
    int x;
    cin >> x;
    ret += (x >= k);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long ans = (long) Math.pow(n / k, 3);
		if(k % 2 == 0) {
			n -= k / 2;
			if(n >= 0)
				ans += (long) Math.pow(n / k + 1, 3);
		}
		System.out.println(ans);
	}

}


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

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var v = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);

            Array.Sort(v);

            for (int i = 1; i < N; i++)
            {
                v[i] = (v[i] + v[i - 1]) / 2;
            }

            Console.WriteLine(v[N-1]);
        }

    }
}

Measured memory_bytes: 11348
/// 12-03-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)

using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<pii> vpll;
typedef pair<ll,ll> Pll;
typedef map<string,int>msi;
typedef set<ll>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}


int main(){

    string s,ss,sss;
    r(s,ss,sss);
    cout<<s[0]<<ss[1]<<sss[2]<<endl;
    return 0;

}


Measured memory_bytes: 256
S = input()
T = input()

b = 1000

for i in range(len(S) - len(T) + 1):
  a = 0
  for j in range(len(T)):
    if list(S[i + j]) == list(T[j]):
      a = a
    elif list(S[i + j]) != list(T[j]):
      a += 1
  if a < b:
    b = a
  else:
    b = b

print(b)

Measured memory_bytes: 9024
#include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

int lm,bud,an,cn,um;
pair<int,int> dp[1000005];

int main(){
	while(1){
		bool used=false;
		cin>>lm;
		if(lm==0) break;
		cin>>bud>>an>>cn>>um;
		for(int i=um;i>0;i--){
			int tmp=(bud-i*an)/cn;
			if(i+tmp>=lm&&tmp>=0&&i*an<=bud){
				cout<<i<<' '<<tmp<<endl;
				used=true;
				break;
			}
		}
		if(!used) cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 8972
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    way = [[] for i in range(n+1)]
    for i in range(n-1):
        a,b = map(int,ipt().split())
        way[a].append((b,i))
        way[b].append((a,i))

    q = queue.Queue()
    q.put((1,-1,-1)) #nowplace,pastplace,hen
    col = [-1]*(n-1)
    while not q.empty():
        np,pp,hen = q.get()
        nc = 1
        for i,wn in way[np]:
            if i == pp:
                continue
            if nc == hen:
                nc += 1
            col[wn] = nc
            q.put((i,np,nc))
            nc += 1
    print(max(col))
    for i in col:
        print(i)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 100228
#include <iostream>
#include <cstdio>

using namespace std;

int L, R, d;

int main() {
  cin >> L >> R >> d;
  int ans = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int even = 0;
        int odd = 0;
        for (int i = 0 ; i < n ; i++) {
            int a = sc.nextInt();
            if (a % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }
        if (p == 0) {
            if (odd == 0) {
                System.out.println((long) Math.pow(2, n));
            } else {
                System.out.println((long) Math.pow(2, n - 1));
            }
        } else {
            if (odd == 0) {
                System.out.println(0);
            } else {
                System.out.println((long) Math.pow(2, n - 1));
            }
        }

    }

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, res[100000];

int main() {
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> A;
		res[A - 1] = i;
	}
	for (int i = 0; i < N; ++i) {
		cout << res[i];
		if (i != N - 1)cout << sp;
	}
	cout << endl;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    lint ans=0;
    char pre = 0;
    int mode = 2;

    REP(i,SZ(s)){
        if(mode==0){
            mode = 2;
            ans++;
            continue;
        }
        if(mode==2){//前が2文字
            pre = s[i];
            ans++;
            mode = 1;
            continue;
        }
        //前が1文字
        if(pre==s[i]){
            mode = 0;
        }else{
            pre = s[i];
            ans++;
        }
    }

    cout << ans <<"\n";

    return 0;
}

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

int main()
{
   string x,y;
   cin >> x >> y;
   if (x > y){
       cout << '>' << endl;
   }else if(x < y)
   {
       cout <<'<'<< endl;
   }else{
       cout <<'='<< endl;
   }
   
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int INF = 100000000;

int main()
{
    int n, p;
    cin >> n;
    int w[n+1][n+1];
    for(int i = 1; i <= n; i++) 
        for(int j = 1; j <= n; j++) 
            w[i][j] = (i==j) ? 0 : INF;

    int r,k,t;
    for(int i = 1; i <= n; i++) {
        cin >> r >> k;
        for(int j = 0; j < k; j++) {
            cin >> t;
            w[r][t] = 1;
        }
    }

    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
            }
        }
    }
    
    cin >> p;
    int s,d,v;
    for(int i = 0; i < p; i++) {
        cin >> s >> d >> v;
        if(w[s][d] + 1 <= v) {
            cout << w[s][d] + 1 << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<P>> g(n);
  rep(i, m) {
    ll p, y;
    cin >> p >> y;
    p--;
    g[p].push_back({y, i});
  }
  vector<P> ans(m);
  rep(i, n) {
    sort(all(g[i]));
    rep(x, g[i].size()) {
      ll in = g[i][x].second;
      ans[in] = {i, x};
    }
  }
  rep(i, m) printf("%06d%06d\n", ans[i].first + 1, ans[i].second + 1);
}

Measured memory_bytes: 10212
#include <iostream>
#include <string>
#include <iterator>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <array>

struct pair_hash {
	template <class T1, class T2>
	std::size_t operator() (const std::pair<T1, T2> &pair) const {
		return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
	}
};

typedef std::vector<long> Vec_t;

void merge(Vec_t &A, Vec_t &B, Vec_t &C, int max)
{
  for (auto ita : A) {
    for (auto itb : B) {
      C.push_back(ita + itb);
    }
  }
  /*
  std::cout << "bc" << "\n";
  for (auto it : C) {
    std::cout << it << ' ';
  }
  std::cout << std::endl;
  */

  std::sort(C.begin(), C.end(), std::greater<long>());
  if (C.size() > max) {
    C.erase(C.begin()+max, C.end());
  }

}

/*
void merge(Vec_t &A, Vec_t &B, Vec_t &C, int max)
{
  int i = 0, j = 0;
  C.push_back(A[i]+B[j]);
  for (int _=0; _<max-1; _++) {
    if (i<A.size()-1 && j<B.size()-1) {
      long tmp1 = A[i+1] + B[j];
      long tmp2 = A[i] + B[j+1];
      if (tmp1 > tmp2) {
        C.push_back(tmp1);
        i++;
      }
      else {
        C.push_back(tmp2);
        j++;
      }
    }
    else if (i>=A.size()-1 && j>=B.size()-1) {
      C.push_back(A[i] + B[j]);
      break;
    }
    else if (i>=A.size()-1) {
      C.push_back(A[i] + B[++j]);
    }
    else {
      C.push_back(A[++i] + B[j]);
    }
  }

}
*/

int main()
{
  int x, y, z;
  long k;
  std::cin >> x >> y >> z >> k;
  //long a[x], b[y], c[z];
  /*
  std::array<long, 1000> a;
  std::array<long, 1000> b;
  std::array<long, 1000> c;
  */
  /*
  std::vector<long> a(1, 0);
  std::vector<long> b(1, 0);
  std::vector<long> c(1, 0);
  */
  std::vector<long> a;
  std::vector<long> b;
  std::vector<long> c;
  int sizes[3] = {x,y,z};

  /*
  for (int i=0; i<x; i++) std::cin >> a[i];
  for (int i=0; i<y; i++) std::cin >> b[i];
  for (int i=0; i<z; i++) std::cin >> c[i];
  */
  for (int i=0; i<x; i++) {
    long l;
    std::cin >> l;
    a.push_back(l);
  }
  for (int i=0; i<y; i++) {
    long l;
    std::cin >> l;
    b.push_back(l);
  }
  for (int i=0; i<z; i++) {
    long l;
    std::cin >> l;
    c.push_back(l);
  }

  std::sort(a.begin(), a.end(), std::greater<long>());
  std::sort(b.begin(), b.end(), std::greater<long>());
  std::sort(c.begin(), c.end(), std::greater<long>());
/*
  a.pop_back();
  b.pop_back();
  c.pop_back();
*/
  /*
  std::cout << "\n\n";
  for (auto it : a) {
    std::cout << it << ' ';
  }
  std::cout << std::endl;
  std::cout << "\n\n";
  for (auto it : b) {
    std::cout << it << ' ';
  }
  std::cout << std::endl;
  std::cout << "\n\n";
  for (auto it : c) {
    std::cout << it << ' ';
  }
  std::cout << std::endl;
  */

  std::vector<long> bc;
  std::vector<long> res;

  merge(b, c, bc, k);
  /*
  std::cout << "\n\n";
  for (auto it : bc) {
    std::cout << it << ' ';
  }
  std::cout << std::endl;
  */
  /*
  for (int i=0; i<k; i++) {
    std::cout << bc[i] << std::endl;
  }
  std::cout << "\n\n";
  */
  merge(a, bc, res, k);

  for (int i=0; i<k; i++) {
    std::cout << res[i] << std::endl;
  }
  /*
  for (auto it : a) {
    std::cout << it << ' ';
  }
  std::cout << std::endl;
  */


  return 0;
}


Measured memory_bytes: 43128
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val a = sc.intList()

        val map = mutableMapOf<Int, Int>()
        for (i in 0 until n) {
            map[a[i]] = (map[a[i]] ?: 0) + 1
        }

        // 4
        val t = mutableListOf<Int>()
        val f = mutableListOf<Int>()
        map.forEach {
            if (it.value >= 4) f.add(it.key)
            if (it.value >= 2) t.add(it.key)
        }

        t.sortBy { -it }
        f.sortBy { -it }

        var ans = 0L
        if (t.size >= 2) {
            ans = Math.max(ans, t[0].toLong() * t[1])
        }
        if (f.size >= 1) {
            ans = Math.max(ans, f[0].toLong() * f[0])
        }
        println(ans)

    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

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

#define mt make_tuple
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())

#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  int g = 0;
  vi a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  bool ok = K % g == 0 && K >= *min_element(ALL(a)) && K <= *max_element(ALL(a));
  cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;
const double pi = 3.14159265358979;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問状況

int a, b; // 変数
double h, m;

int main() {
// input
    cin >> a >> b;
    cin >> h >> m;
// solve
    double longer = h * pi / 6 + m * pi / 360;
    double shorter = m * pi / 30;
    double x = longer - shorter;
    double c = sqrt(a * a + b * b - 2 * a * b * cos(x));
// output
    printf("%.10f\n", c);
}

Measured memory_bytes: 4228
#include <iostream>
#include <vector>

using namespace std;

#define MOD 1000000007
#define N_MAX 100002

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

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

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


ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

vector<int> G[100000];
bool used[100000];
int N, K;
int ch[100000];
ll ans = 1;

ll dfs(int v, int d){
    used[v] = true;
    ll cnt = 0;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            dfs(G[v][i], d+1);
            if(d == 0) {
                ans *= (K-1-cnt);
                ans %= MOD;
            }else{
                ans *= (K-2-cnt);
                ans %= MOD;
            }
            cnt++;
        }
    }
    
    ch[v] = cnt;
    return ans;
}

int main(){
    init();
    cin >> N >> K;
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans = K;
    cout << dfs(0,0) << endl;
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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(){
    int n,k;cin>>n>>k;
    vector<int> p(n);rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    ll sum= 0;
    rep(i,k)sum+=p[i];
    cout<<sum<<endl;

}

Measured memory_bytes: 3620
#include<stdio.h>
int d[10000][1500]={0};
int main(){
  int n,m,i,j,s,t,k,a;
  while(scanf("%*d %d",&n),n){
    for(i=0;i<n;i++){
      for(j=500;j<=1270;j++)d[i][j]=0;
    }
    scanf("%d",&k);
    while(k--){
      scanf("%d %*d %d %d",&m,&i,&j);
      d[i][m]+=(j%2)*2-1;
    }
    scanf("%d",&k);
    while(k--){
      scanf("%d %d %d",&s,&t,&m);
      for(i=a=j=0;i<1300;i++){
	j+=d[m][i];//printf("%d ",j); 
	if(s<=i&&i<t&&j>0)a++;
      }
      printf("%d\n",a);
    }
  }
  return 0;
}

Measured memory_bytes: 57936
#include<iostream>
#include<cstring>
#include<algorithm>
#define maxn 100010
using namespace std;
int n,k,s;
int main(){
	scanf("%d%d%d",&n,&k,&s);
	if(s<1e9){
	for(int i=1;i<=k;i++){
		printf("%d ",s);
	}
	for(int i=k+1;i<=n;i++){
		printf("%d ",s+1);
	}	
	}
	else if(s==1e9){
	for(int i=1;i<=k;i++){
		printf("%d ",s);
	}
	for(int i=k+1;i<=n;i++){
		printf("%d ",s-1);
	}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include<sstream>
#include <cmath>
using namespace std;
#define pb push_back
#define PB pop_back
#define bk back()
#define fs first
#define se second
#define INF 1e9*2+10
#define sq(x) (x)*(x)
#define eps (1e-7)
#define clr(x) memset((x),0,sizeof (x))
#define cp(a,b) memcpy((a),(b),sizeof (b))

const int maxn=1005;
int W,H,N;
int x1[maxn],x2[maxn],Y1[maxn],Y2[maxn];
int fld[maxn*3][maxn*3];
int dir[4][2]={1,0,0,1,0,-1,-1,0};

int compress(int *x1,int *x2,int w)
{
    vector<int> v;
    for(int i=1;i<=N;i++)
    {
        int tx1,tx2;
        for(int d=-1;d<=1;d++)
        {
            tx1=x1[i]+d;
            tx2=x2[i]+d;
            if(tx1>=0&&tx1<w) v.pb(tx1);
            if(tx2>=0&&tx2<w) v.pb(tx2);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=1;i<=N;i++)
    {
        x1[i]=lower_bound(v.begin(),v.end(),x1[i])-v.begin();
        x2[i]=lower_bound(v.begin(),v.end(),x2[i])-v.begin();
    }
    return v.size();
}

void solve()
{
    W=compress(x1,x2,W);
    H=compress(Y1,Y2,H);
    clr(fld);
    for(int i=1;i<=N;i++)
    for(int y=Y1[i];y<=Y2[i];y++)
    for(int x=x1[i];x<=x2[i];x++)  fld[y][x]=1;
    int ans=0;
    /*
    for(int x=0;x<W;x++)
    {
        for(int y=0;y<H-1;y++) cout<<fld[x][y]<<" ";
        cout<<fld[x][H-1]<<endl;
    }
    */
    for(int y=0;y<H;y++)
    for(int x=0;x<W;x++)
    {
        if(fld[y][x]) continue;
        fld[y][x]=1;
        ans++;
        queue<pair<int,int> > q;
        q.push(make_pair(x,y));
        while(!q.empty())
        {
            int xx,yy,nx,ny;
            xx=q.front().fs,yy=q.front().se;
            q.pop();
            for(int i=0;i<4;i++)
            {
                nx=xx+dir[i][0];
                ny=yy+dir[i][1];
                if(nx<0||nx>=W||ny<0||ny>=H||fld[ny][nx]) continue;
                fld[ny][nx]=1;
                q.push(make_pair(nx,ny));
            }
        }
    }
    printf("%d\n",ans);
}

int main()
{
    while(~scanf("%d%d",&W,&H)&&W&&H)
    {
        scanf("%d",&N);
        for(int i=1;i<=N;i++)//注意?里，把?个坐?当成?上面的一个一个格子。。。。。然后照着做就行了.......
        {
            scanf("%d%d%d%d",&x1[i],&Y1[i],&x2[i],&Y2[i]);
            x2[i]-=1;
            Y2[i]-=1;
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 36756
#include<stdio.h>

int main(){
int a,b,c,f,s,t,i;
scanf("%d %d %d",&a,&b,&c);
f=a;
s=b;
t=c;
if(f>s){
i=f;
f=s;
s=i;
}
if(s>t){
i=s;
s=t;
t=i;
}
if(f>s){
i=f;
f=s;
s=i;
}
printf("%d %d %d\n",f,s,t);
return 0;
}

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

using namespace std;
long long fa[2000000], a[1010];
long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

double eps = 0.0000001;
const long long mod = 1e9+7;


int fn;

long long bp(long long a, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return bp((a*a) % m, n / 2, m);
	else
		return (a%m) * bp(a%m, n - 1, m) % m;
}

int cnk(int a, int b) {
	return (fa[a + b] * bp(fa[a], mod - 2, mod)) % mod * bp(fa[b], mod - 2, mod) % mod;
}

long long lcm(long long a, long long b) {
	return (a / gcd(a, b)) * b;
}



signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x, y;
	cin >> x >> y ;
	long long ans = 1;
	fa[0] = 1;
	for (int i = 1; i <= 2000000; i++) {
		fa[i] = (fa[i - 1] * i) % mod;
		fa[i] %= mod;
	}
	//cout << cnk(x, y) << endl;
	if (x > y)
		swap(x, y);
	int c = y - x;
	x -= c;
	if (x < 0 || x % 3 != 0) {
		cout << 0;
	}
	else {
		cout << cnk(x / 3, x / 3 + c);
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}

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

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

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

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

int main(){
	while(1){
		char a[5], b[5];
		cin>>a>>b;
		if(a[1]==0) break;
		int cnt[10];
		REP(i, 10) cnt[i]=0;
		int hit = 0;
		REP(i, 4){
			if(a[i]==b[i]) hit++;
			else{
				cnt[a[i]-'0']++;
				cnt[b[i]-'0']++;
			}
		}
		int blow = 0;
		REP(i, 10){
			if(cnt[i]==2) blow++;
		}
		printf("%d %d\n", hit, blow);
	}
}

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

int main(){

	int n, m, l;
	cin >> n >> m >> l;
	int A[n][m], B[m][l];
	long C[n][l];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			C[i][j] = 0;
		}
	}

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

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

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			for(int k = 0; k < m ; k++){
				C[i][j] += A[i][k] * B [k][j];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			if(j) cout << " ";
			cout << C[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

string fillc(string s, char c)
{
    string ret = "";
    rep(i, s.size())
    {
        if (s[i] == '?')
        {
            ret += c;
        }
        else
        {
            ret += s[i];
        }
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<string> v(n);
    rep(i, n) cin >> v[i];
    string s;
    cin >> s;
    int lownum = 0, highnum = 0;
    rep(i, n)
    {
        if (fillc(v[i], 'z') < s)
        {
            highnum++;
        }
        if (fillc(v[i], 'a') > s)
        {
            lownum++;
        }
    }
    for (int i = highnum; i < n - lownum + 1; i++)
    {
        cout << i + 1;
        if (i < n - lownum)
            cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  ld a, b, h, m; cin >> a >> b >> h >> m;

  ld lhand = h * 30 + m * 0.5;
  ld shand = m * 6;

  ld angle = min({abs(lhand - shand), (360 - lhand) + shand, lhand + (360 - shand)});

  angle = angle / 180 * M_PI;
  
  cout << sqrt(a*a + b*b - 2*a*b*cos(angle)) << endl;

  return (0);
}


Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

constexpr int     MAX =       500'005;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int64_t N, M;
    cin >> N >> M;
    COMinit();

    int64_t tmp = fac[M] * finv[M-N] % MOD;
    cerr << "tmp: " << tmp << endl;

    vector<int64_t> v(N+1);
    v[0] = 1;
    // v[1] = M-N+1;
    for(int i=1; i<=N; i++) {
        v[i] = v[i-1] * (M-N+i) % MOD;
    }

    int64_t ans = tmp;
    for(int k=1; k<=N; k++) {
        if(k%2) {
            ans -= COM(N, k) * v[N-k];
            ans %= MOD;
        } else {
            ans += COM(N, k) * v[N-k];
            ans %= MOD;
        }
    }

    ans *= tmp;
    ans %= MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;

    // vector<int64_t> v(N+1);
    // v[0] = 1;
    // v[1] = M-1;
    // for(int64_t i=2; i<=N; i++) {
    //     v[i] = (i-1) * (v[i-1] + v[i-2]);
    //     v[i] %= MOD;
    // }

    // ans *= v.back();
    // ans %= MOD;

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


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int b,c;
	c=0;
	cin>>a;
	for(b=0;b<6;b++){
		if(a[b]=='1'){
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    S = int(input())
    mod = (10 ** 9 + 7)

    if S < 3:
        print(0)
        exit()

    inf = S // 3 +3 # 最大桁数
    sup = (S-1)//9



    ans =0

    dp= [0]*(S+1)
    dp[0] =1


    for i in range(inf):
        for j in range(S,-1,-1):
            if j ==S:
                dp[j] = sum(dp[0:max(j - 2, 0)])
            else:
                if j>=3:
                    dp[j] = dp[j+1] - dp[j-2]
                else:
                    dp[j]=0
            dp[j] %=mod

        ans +=dp[S]
        ans %=mod


    print(ans)






if __name__ == "__main__":
    main()


Measured memory_bytes: 68216
#include <stdio.h>

int main(void)
{
	int H, W, i, j;

	while (1)
	{
		scanf("%d %d", &H, &W);

		if ((H == 0) && (W == 0)) break;
		
		for (i = 1; i <= H; i++)
			if ((i == 1) || (i == H))
			{
				for (j = 1; j <= W; j++)
				{
					printf("#");
				}
				printf("\n");
			}
			else
			{
				printf("#");
				for (j = 1; j <= W - 2; j++)
				{
					printf(".");
				}
				printf("#\n");
			}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=998244353;
const ll INF=1000000000;
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,-1,0,1,-1,0};
ll digitsum(ll n){
    ll sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    ll n;cin>>n;
    if(n%digitsum(n)==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

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

long long max(long long a,long long b){
	return (a>b)? a:b;
}
int j_k_bit_1or0(int j,int k){

}

int main (){
	long long NNN,MMM,maxx=0,p=0,sum=0;
	cin >> NNN >> MMM;
	long long a[3][NNN];
	rep(i,NNN)rep(j,3)cin >> a[j][i];
	vector <long long> temp[8];
	rep(i,8){
		rep(j,NNN){
			rep(k,3)(i & (1 << k))? p += a[k][j]:p -= a[k][j];
			temp[i].push_back(p);
			p=0;
		}
		sort(temp[i].rbegin(),temp[i].rend());
		sum=0;
		rep(k,MMM)sum += temp[i][k];
		maxx = max(sum,maxx);
	}
	cout << maxx << endl;

	return 0;
}


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

int main() {
int a,i,j;
int mod=2019,mod3=673;
cin>>i>>j;
if(i==j-1){
   i%=mod;
   j%=mod;
   cout<<i*j%mod; 
}else if(j-i>=mod3||i%mod3>j%mod3 ||i%mod3==0){
   cout<<0; 
}else{
   i%=mod;
   j%=mod;
   if((j-1)*j<mod){
      cout<<i*(i+1); 
   }else{
       a=mod-1;
       for(int k=i;k<j&&a>0;k++)
           for(int l=k+1;l<=j&&a>0;l++)
               if(a>k*l%mod)a=k*l%mod;
       cout<<a;
   }
}
    return 0;
}

Measured memory_bytes: 256
#python3

INF = int(1e9)

def main():

    n, k = map(int, input().split()) 
    h = [int(i) for i in input().split()] + [0]* 110


    dp = [INF] * 100001
    dp[0] = 0
    for i in range(n):
        for j in range(1, k+1):
            if i >= j:
                dp[i] = min(dp[i] , dp[i-j] + abs(h[i-j]- h[i])) 

    print(dp[n-1])

main() 

Measured memory_bytes: 53216
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool check(int x, string a, string b){
	rep(i,b.size()){
		if(x+i>=a.size()) return false;
		if(a[x+i]!='?' && a[x+i] != b[i]) return false;
	}
	return true;
}

string func(int x, string a, string b){
	rep(i,b.size()){
		a[x+i] = b[i];
	}
	rep(i,a.size()){
		if(a[i]=='?') a[i]='a';
	}
	return a;
}

string mainmain(){
	string a,b;
	cin>>a>>b;
	if(a.size()<b.size()) return "UNRESTORABLE";
	string ans = "{{{";
	rep(i,a.size()){
		if(check(i,a,b)){
			string tmp = func(i,a,b);
			mins(ans, tmp);
		}
	}
	if(ans=="{{{") return "UNRESTORABLE";
	return ans;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<mainmain()<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n - 1);
  rep(i, n - 1) cin >> b[i];

  if (n == 2) {
    cout << b[0] * 2 << endl;
    return 0;
  }

  vector<int> a(n);
  rep(i, n) {
    if (i == 0) {
      a[i] = b[i];
      continue;
    }

    if (i == n - 1) {
      a[i] = b[i - 1];
      break;
    }

    a[i] = min(b[i], b[i - 1]);
  }

  ll ans = 0;
  rep(i, n) ans += a[i];

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

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  
  vector <int> H(N);
  
  double min = 10000000;
  int best;
  
  for (int i=0; i<N; i++){
    cin >> H[i];
    double Ti = T - H[i]*0.006;
    
    if( Ti-A >= 0 && Ti-A < min){
      min = Ti-A;
      best = i+1;
    }
    if( Ti-A < 0 && A-Ti < min){
      min = A-Ti;
      best = i+1;
    }
  }
  cout << best << endl;
    

   
}

Measured memory_bytes: 256