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

void makeVec(vector<long long> &vec, long long len){
    for(long long i = 0; i < len; i++){
        cin >> vec[i];
    }
    return;
}

int main(){
    long long x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<long long> p(a), q(b), r(c);
    makeVec(p, a);
    makeVec(q, b);
    makeVec(r, c);

    sort(p.begin(), p.end(), greater<long long>());
    sort(q.begin(), q.end(), greater<long long>());

    for(int i = 0; i < x; i++){
        r.push_back(p[i]);
    }
    for(int i = 0; i < y; i++){
        r.push_back(q[i]);
    }

    sort(r.begin(), r.end(), greater<long long>());

    long long ans = 0;
    for(int i = 0; i < x + y; i++){
        ans += r[i];
    }

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

Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n1,n2;
string s1,s2;
int lh[3005][3005];
int pv[3005][3005];
string lcs(3005,' ');
int main(){
	ll n,ss,ts;
	cin>>s1>>s2;	
	n1=s1.size(),n2=s2.size();
	s1.insert(0,"0");s2.insert(0,"0");
	for (int i=0; i<=n1; i++) lh[i][0] = 0;
    for (int j=0; j<=n2; j++) lh[0][j] = 0;
    
    for (int i=1; i<=n1; i++){
        for (int j=1; j<=n2; j++){
            if (s1[i] == s2[j])
            {
                lh[i][j] = lh[i-1][j-1] + 1;
                pv[i][j] = 0;
            }
            else
            {
                if (lh[i-1][j] < lh[i][j-1])
                {
                    lh[i][j] = lh[i][j-1];
                    pv[i][j] = 1;
                }
                else
                {
                    lh[i][j] = lh[i-1][j];
                    pv[i][j] = 2;
                }
            }
    	}
    }
	int l = lh[n1][n2];
    int x=n1,y=n2;
    while (l > 0)
        if (pv[x][y] == 0)
            l--, lcs[l] = s1[x],x--,y--;
        else if (pv[x][y] == 1)
            y--;
        else if (pv[x][y] == 2)
            x--;
    for (int k=0; k<lh[n1][n2]; ++k)
        cout << lcs[k];	
	return 0;
}


Measured memory_bytes: 70784
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Map<String, String> m1 = new HashMap<String, String>();
		m1.put(" ", "101");
		m1.put("'", "000000");
		m1.put(",", "000011");
		m1.put("-", "10010001");
		m1.put(".", "010001");
		m1.put("?", "000001");
		m1.put("A", "100101");
		m1.put("B", "10011010");
		m1.put("C", "0101");
		m1.put("D", "0001");
		m1.put("E", "110");
		m1.put("F", "01001");
		m1.put("G", "10011011");
		m1.put("H", "010000");
		m1.put("I", "0111");
		m1.put("J", "10011000");
		m1.put("K", "0110");
		m1.put("L", "00100");
		m1.put("M", "10011001");
		m1.put("N", "10011110");
		m1.put("O", "00101");
		m1.put("P", "111");
		m1.put("Q", "10011111");
		m1.put("R", "1000");
		m1.put("S", "00110");
		m1.put("T", "00111");
		m1.put("U", "10011100");
		m1.put("V", "10011101");
		m1.put("W", "000010");
		m1.put("X", "10010010");
		m1.put("Y", "10010011");
		m1.put("Z", "10010000");
		String[] s = new String[32];
		for(int i = 0; i < 26; i++) {
			s[i] = Character.toString((char)(i + 'A'));
		}
		s[26] = " ";
		s[27] = ".";
		s[28] = ",";
		s[29] = "-";
		s[30] = "'";
		s[31] = "?";
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String S = sc.nextLine();
			String t = "";
			for(int i = 0; i < S.length(); i++) {
				t += m1.get(S.substring(i, i + 1));
			}
			if(t.length() % 5 != 0) {
				int k = 5 - t.length() % 5;
				for(int i = 0; i < k; i++) {
					t += "0";
				}
			}
			String g = "";
			for(int i = 0; i + 5 <= t.length(); i += 5) {
				String sub = t.substring(i, i + 5);
				g += s[Integer.parseInt(sub, 2)];
			}
			System.out.println(g);
		}
		sc.close();
	}
}


Measured memory_bytes: 52852
n = int(input())
s = list(map(int, input().split()))
MINUS_INF = -float("inf")
ans = 0
for c in range(1, n):
    k = 1
    tmp_ans = 0
    while k * c < n - 1:
        a = (n - 1) - k * c
        b = a - c
        if a <= b or b <= 0:
            tmp_ans = MINUS_INF
        if a % c == 0 and a // c <= k:
            tmp_ans = MINUS_INF
        tmp_ans += s[n-1-k*c] + s[k*c]
        ans = max(ans, tmp_ans)    
        k += 1    
print(ans)

Measured memory_bytes: 14988
#include <iostream>

#define GOAL 2019
#define MAX 100

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  int X[MAX+1];
  int P[GOAL+2] = {0};
  for(int i = 1; i <= N; i++) {
    cin >> X[i];
    P[X[i]] = 1;
  }
  int M;
  cin >> M;
  int A[MAX];
  for(int i = 0; i < M; i++) cin >> A[i];

  for(int i = 0; i < M; i++) {
    if(P[X[A[i]]+1] == 0 && X[A[i]] != GOAL) {
      P[X[A[i]]+1] = 1;
      P[X[A[i]]] = 0;
      X[A[i]]++;
    }
  }

  for(int i = 1; i <= N; i++) cout << X[i] << endl;

  return 0;
}


Measured memory_bytes: 3116
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/cmplx"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	cx := getNextFloat64(scanner)
	cy := getNextFloat64(scanner)
	r := getNextFloat64(scanner)

	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		x1 := getNextFloat64(scanner)
		y1 := getNextFloat64(scanner)
		x2 := getNextFloat64(scanner)
		y2 := getNextFloat64(scanner)
		s := complex(x2-x1, y2-y1)
		_, th := cmplx.Polar(s)
		v := rotate(complex(cx-x1, cy-y1), -th)
		l := 0.0
		if compare(cmplx.Abs(complex(0, imag(v))), r) != 0 {
			l = math.Sqrt(math.Max(0, (r+imag(v))*(r-imag(v))))
		}
		v1 := rotate(complex(real(v)+l, 0), th)
		v2 := rotate(complex(real(v)-l, 0), th)
		switch compare(real(v1), real(v2)) {
		case 0:
			if compare(imag(v1), imag(v2)) == 1 {
				v1, v2 = v2, v1
			}
		case 1:
			v1, v2 = v2, v1
		}
		fmt.Fprintln(writer, fmt.Sprintf("%.8f %.8f %.8f %.8f", real(v1)+x1, imag(v1)+y1, real(v2)+x1, imag(v2)+y1))
	}
}
func compare(a, b float64) int {
	eps := 1e-10
	if a-b > eps {
		return 1
	}
	if b-a > eps {
		return -1
	}
	return 0
}
func rotate(v complex128, theta float64) complex128 {
	r, th := cmplx.Polar(v)
	th += theta
	return cmplx.Rect(r, th)
}
func degToRad(deg float64) float64 {
	return deg * math.Pi / 180.0
}
func radTodeg(rad float64) float64 {
	return rad * 180.0 / math.Pi
}



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

using namespace std;
typedef long long ll;

int main(){
	int n; cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}

	int ans = 0;

	for(int i = 0; i < n - 1; i++){
		for(int j = i+1; j < n; j++){
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
using namespace std;

int dp[100 + 1][100000 + 1];

void solve() {
  int N, W;
  cin >> N >> W;

  for (int i = 0; i <= N; i++) {
    fill(dp[i], dp[i] + 100000 + 1, INF);
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    int w, v;
    cin >> w >> v;
    for (int x = 0; x <= 100000; x++) {
      if (dp[i][x] == INF) {
        continue;
      }
      dp[i + 1][x] = min(dp[i + 1][x], dp[i][x]);
      if (dp[i][x] + w <= W) {
        dp[i + 1][x + v] = min(dp[i + 1][x + v], dp[i][x] + w);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i <= 100000; i++) {
    if (dp[N][i] != INF) {
      ans = i;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 79232
import java.io.PrintWriter

val br = System.`in`.bufferedReader()
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = br.readLine()!!
    val k = readInteger()
    // dpMax[上位桁からの桁数][0でない数の個数] 上位i桁がnと等しい場合の数
    val dpMax = Array(n.length + 1) { LongArray(k + 2) }
    // dpLess[上位桁からの桁数][0でない数の個数] 上位i桁がnより小さい 場合の数
    val dpLess = Array(n.length + 1) { LongArray(k + 2) }

    dpMax[0][0] = 1L // -1桁目が0である場合の数は1
    for ((i, c) in n.withIndex()) {
        // dpMax[i + 1][j]やdpLess[i + 1][j]をを最後まで更新するため、0からkまで考える
        for (j in 0..k) {
            val tmp = c - '0' // i番目の桁の数

            // dpMax[i][j]からの遷移
            if (tmp == 0) {
                dpMax[i + 1][j] += dpMax[i][j] // 0を選ぶしかない
            } else {
                dpMax[i + 1][j + 1] += dpMax[i][j] // tmpを選ぶ
                dpLess[i + 1][j] += dpMax[i][j] // 0を選ぶ
                dpLess[i + 1][j + 1] += dpMax[i][j] * (tmp - 1) // この行がよくわからない(´；ω；｀)
//              ↑dpLess[i + 1][j + 1]を更新しているので1からtmpまでを選ぶということ？？
//              tmpをつかうとdpMax[i + 1][j + 1]が更新されるのでtmpは除外するべきでは？
//              if (tmp >= 2) dpLess[i + 1][j + 1] += dpMax[i][j] * (tmp - 2) // 1から(tmp-1)までを選ぶ
//              ↑こっちのほうが正しい気がする
            }

            // dpLess[i][j]からの遷移
            dpLess[i + 1][j] += dpLess[i][j] // 0を選ぶ
            dpLess[i + 1][j + 1] += dpLess[i][j] * 9 // 0以外を選ぶ
        }
    }
    out.println(dpMax[n.length][k] + dpLess[n.length][k])
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 34452
#include <bits/stdc++.h>
#include <iostream>
#include <queue>

using namespace std;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

struct Edge {
    long long to;
};

using Graph = vector<vector<Edge>>;

int swaping(int i, int j) {
    if (i < j) swap(i, j);
    return i * (i - 1) / 2 + j + 1;
}

int abcd[2000000];  
int d[2000000];     
int a[1005][1005];

int dfs(const Graph &G, int n) {
  
    if (abcd[n] == 2) return d[n];
    abcd[n] = 1;
    for (auto e : G[n]) {
      
        if (abcd[e.to] == 1) {  
          
            cout << -1 << endl;
          
            exit(0);
        }
        chmax(d[n], dfs(G, e.to) + 1);
    }
    abcd[n] = 2;
  
    return d[n];
}
int main() {
    long long N;
  
    cin >> N;
    
    for(int i=0;i<N;i++){
     for(int j=0;j<N-1;j++)
     cin >> a[i][j];
     
    }
     
  
    Graph G(N * (N - 1) / 2 + 1);
  
    for(int i=0; i<N; i++) {
        int n = 0;
       for(int j=0;j<N-1;j++) {
       
           a[i][j]--;
                    
            int ne = swaping(i , a[i][j]);
          
            G[n].push_back({ne});
          
            n = ne;
        }
    }
  
    cout << dfs(G, 0) << endl;
  
    return 0;
}


Measured memory_bytes: 37888
# abc169_a.py
# https://atcoder.jp/contests/abc169/tasks/abc169_a

# A - Multiplication 1 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# A×Bを求めてください。

# 制約
#     1≤A≤100
#     1≤B≤100
#     入力は全て整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 値 A×Bを整数として出力せよ。

# 入力例 1
# 2 5

# 出力例 1
# 10

# 2×5=10です。

# 入力例 2
# 100 100

# 出力例 2
# 10000


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = A*B

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 5']
        lines_export = [10]
    if pattern == 2:
        lines_input = ['100 100']
        lines_export = [10000]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

struct edge { int to, rev; long long cap; };

bool vis[809]; vector<edge>g[809]; int V, inf = 1000000007;

void add_edge(int v1, int v2, long long cost) {
	g[v1].push_back(edge{ v2, (int)g[v2].size(), cost });
	g[v2].push_back(edge{ v1, (int)g[v1].size() - 1, 0LL });
}
long long find_augment(int pos, int tar, long long curflow) {
	if (pos == tar) return curflow;
	vis[pos] = true;
	for (edge &e : g[pos]) {
		if (!vis[e.to] && e.cap > 0) {
			long long newflow = find_augment(e.to, tar, min(e.cap, curflow));
			if (newflow > 0) {
				e.cap -= newflow;
				g[e.to][e.rev].cap += newflow;
				return newflow;
			}
		}
	}
	return 0;
}
long long max_flow(int src, int dst) {
	long long ret = 0;
	while (true) {
		fill(vis, vis + V, false);
		long long res = find_augment(src, dst, inf);
		if (res == 0) break;
		ret += res;
	}
	return ret;
}

int N, A, B, a[810], b[810], cnt; vector<int>X, Y;

int main() {
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i];
		if (abs(a[i] - b[i]) <= A || (B <= abs(a[i] - b[i]) && abs(a[i] - b[i]) <= 2 * A)) {
			cnt++;
			continue;
		}
		if (a[i] - b[i] >= 0) X.push_back(a[i] - b[i]);
		else Y.push_back(a[i] - b[i]);
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j < Y.size(); j++) {
			if (abs(X[i] + Y[j]) <= A || (B <= abs(X[i] + Y[j]) && abs(X[i] + Y[j]) <= 2 * A)) {
				add_edge(i, j + X.size(), 1);
			}
		}
	}
	for (int i = 0; i < X.size(); i++) add_edge(X.size() + Y.size(), i, 1);
	for (int i = 0; i < Y.size(); i++) add_edge(i + X.size(), X.size() + Y.size() + 1, 1);
	V = X.size() + Y.size() + 2;

	int cnt2 = max_flow(X.size() + Y.size(), X.size() + Y.size() + 1);

	cout << cnt + cnt2 << endl;
	return 0;
}


Measured memory_bytes: 4724
N, K = map(int, input().split())

ans = 0

if N == 1 and K != 1:
    print(0)
    exit()
if K % 2 == 0:
    # a, b, c が全て K の倍数
    cnt = N // K 
    ans = cnt ** 3
    K //= 2
    k = K
    # a, b, c が K//2 の奇数倍
    tmp = 1
    while 1:
        K += 2 * k
        if N < K:
            break
        tmp += 1
    ##print(cnt, tmp)
    ans += (tmp) ** 3
else:
    cnt = N // K
    ans = cnt ** 3

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;

    const int len = 3;
    bool cannot = false;
    for (int i = 'a'; i <= 'c'; ++i) {
        bool found = false;
        for (int j = 0; j < len; ++j) {
            if (s[j] == i) {
                found = true;
                break;
            }
        }
        if (!found) {
            cannot = true;
            break;
        }
    }

    if (cannot)
        cout << "No\n";
    else
        cout << "Yes\n";
}


Measured memory_bytes: 256
#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(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N, 2e9);
    rep(i, min(N, K + 1)) dp[i] = abs(h[0] - h[i]);

    rep(i, K + 1, N) {
        rep(k, 1, min(i + 2, K + 1)) {
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]));
        }
    }

    write(dp[N - 1]);
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n, t[100009], w[100009], L, T, J; vector<int>g;
int main() {
	cin >> n >> L >> T;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> w[i];
		if (w[i] == 1) { g.push_back((t[i] + (T%L)) % L); J += (t[i] + T) / L; }
		if (w[i] == 2) { int F = t[i] - (T%L); while (F < 0)F += L; g.push_back(F%L); J -= (T - t[i] - 1 + L) / L; }
	}
	sort(g.begin(), g.end());
	for (int i = 0; i < g.size(); i++)cout << g[(1LL * J + 1LL * n * 1000000007 + i) % n] << endl;
	return 0;
}

Measured memory_bytes: 2552
#!/usr/bin/env python3
import sys


def solve(N: int, R: int):
    return R + 100 * (10 - min(10, N))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    print(solve(N, R)) 

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn min_index(vs: Vec<usize>) -> (usize, usize) {
    let mut min = (std::usize::MAX, 0);
    for (i, v) in vs.iter().enumerate() {
        if v < &min.1 {
            min = (i, *v);
        }
    }
    min
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut from_w = vec![0; n];
    let mut from_e = vec![0; n];
    let mut sum=0;
    for i in 0..n {
        from_w[i] = sum;
        if s[i] == 'W' {
            sum+=1;
        }
    }
    sum=0;
    for i in (0..n).rev() {
        from_e[i] = sum;
        if s[i] == 'E' {
            sum+=1;
        }
    }
    let mut ss = vec![0; n];
    for i in 0..n {
        ss[i] = from_e[i] + from_w[i];
    }
    println!("{}", ss.iter().min().unwrap());
}

Measured memory_bytes: 12540
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

mod = 998244353
N = int(input())
XD = [tuple(map(int, input().split())) for _ in range(N)]
XD.sort(key=lambda x : x[0])
children = [[] for _ in range(N)]
pq = []
for i, (x, d) in list(enumerate(XD))[::-1]:
    while pq and pq[0][0] < x + d:
        y, j = heappop(pq)
        children[i].append(j)
    heappush(pq, (x, i))
val = [0] * N
for i in range(N)[::-1]:
    res = 1
    for j in children[i]:
        res = res * val[j] % mod
    val[i] = res + 1
ans = 1
while pq:
    x, i = heappop(pq)
    ans = ans * val[i] % mod
print(ans)

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int M = nextInt();
		Pair[] p = new Pair[M];
		ArrayList<Pair> list = new ArrayList<>();
		for(int i =0;i<M;i++){

			p[i]=new Pair(nextInt(),nextInt(),i);
			list.add(p[i]);
		}
		Collections.sort(list,Pair.getComparator());

		int cnt=0;
		int bef=-1;
		for(Pair x:list){
			if(bef!=x.N){
				cnt=0;
				bef=x.N;
			}
			cnt++;
			x.cnt=cnt;
		}

		for(Pair x:p){
			System.out.printf("%06d%06d\n",x.N,x.cnt);
		}
	}

	public static class Pair {
		int N;
		int V;
		int idx;
		int cnt;

		Pair(int N, int V,int idx) {
			this.N = N;
			this.V = V;
			this.idx=idx;
		}

		public int getN() {
			return N;
		}

		public int getV() {
			return V;
		}


		public int getIdx() {
			return idx;
		}

		public void setIdx(int idx) {
			this.idx = idx;
		}

		public static Comparator<Pair> getComparator() {
			return Comparator.comparing(Pair::getN).thenComparing(Pair::getV);
		}
		public static Comparator<Pair> getComparator2() {
			return Comparator.comparing(Pair::getIdx);
		}
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 133120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int X = Integer.parseInt(strArr[0]);
		int Y = Integer.parseInt(strArr[1]);
		int ans = 0;
		if (X == 1)
			ans += 300000;
		else if (X == 2)
			ans += 200000;
		else if (X == 3)
			ans += 100000;
		if (Y == 1)
			ans += 300000;
		else if (Y == 2)
			ans += 200000;
		else if (Y == 3)
			ans += 100000;
		if (X == 1 && Y == 1)
			ans += 400000;
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22484
n, m = gets.split.map(&:to_i)
abs = n.times.map { gets.split.map(&:to_i) }.sort_by! { |a, b| a }

ans = 0

abs.each do |a, b|
  if b >= m
    ans += a * m
    m = 0
  else
    ans += a * b
    m -= b
  end

  break if b == 0
end

puts ans


Measured memory_bytes: 12664
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a));

    vint b(N);
    REP(i,N){
        b[i]=abs(i-(N-(i+1)));
    }
    sort(ALL(b));

    if(a!=b) cout<<0<<endl;
    else{
        int ans=1;
        REP(i,N/2) ans=ans*2%mod;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	ll a,b;
	cin>>a>>b;
	ll k;
	cin>>k;

	ll ans=0;
	vector<ll> num;
	for(ll i=1;i<=min(a,b);i++){
		if(a%i==0 && b%i==0){
			num.push_back(i);
		}
	}

	cout<<num[num.size()-k]<<endl;
}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val fact = Array(200001) { ModInt(1) }
    for (n in 1 until 200000) fact[n] = fact[n - 1] * n
    fun Combi(n: Int, m: Int) = if (n >= m) fact[n] / (fact[m] * fact[n - m]) else ModInt(0)

    val N = nextInt()
    val A = listOfInt()
    var L = -1; var R = -1
    val index = IntArray(N + 1) { -1 }
    for (n in A.indices) {
        if (index[A[n]] != -1) {
            L = index[A[n]] + 1
            R = n + 1
            break
        }
        index[A[n]] = n
    }
    val ans = StringBuilder()
    for (k in 1 .. N + 1) {
        ans.appendln(Combi(N + 1, k) - Combi(L + N - R, k - 1))
    }
    println(ans.toString())
}

data class ModInt(private var v: Long) {
    companion object { private const val MOD = 1000000007L }
    init { this.v %= MOD }
    constructor(k: Int): this(k.toLong())
    operator fun plus(other: Int) = ModInt((this.v + other) % MOD)
    operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)
    operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)
    operator fun times(other: Int) = ModInt(this.v * other % MOD)
    operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)
    operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)
    private fun pow(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2 == 0L) {
            val d = pow(a, b / 2)
            return (d * d) % MOD
        }
        return a * pow(a, b - 1) % MOD
    }
    override fun toString() = this.v.toString()
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 81004
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define frfr  freopen("input.text","r",stdin); //freopen("output.txt","w",stdout)
#define LL long long int
#define wh int T;cin >> T;while(T--)
#define foro(i,n) for(int i=0;i<n;i++)
#define forn(i,k,n) for(int i=k;i<n;i++)
#define PB push_back
#define mod 1000000007 
#define UMP unordered_map<int,int>
int main()
{
	double d,t,s;
	cin >> d >> t >> s;
	double tt = d/s;
	if( t >=  tt){
	cout << "Yes" << endl;	
	}else{
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 3728
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();
        long W = sc.nextLong();
        long S = H * W;
       if(H==1||W==1){
		System.out.println(1);
	}else{
		 if(S%2==1){
		System.out.println((S-1)/2+1);
	        }else{
	        System.out.println(S/2);
	        }
	}
    }
}



Measured memory_bytes: 21588
s = input().strip()
a = int(s[:2])
b = int(s[2:])

if 1 <= a <= 12:
  if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 2940
N = gets.to_i
digits = N.to_s.size

def dfs(digits_size, digits = [])
  return [digits] if digits.size == digits_size
  [7, 5, 3].flat_map do |n|
    dfs(digits_size, digits + [n])
  end
end

ans = 0
(3..digits).each do |d|
  dfs(d).each do |list|
    is_ok = list.join('').to_i <= N &&
      list.count { |n| n == 7 } >= 1 &&
      list.count { |n| n == 5 } >= 1 &&
      list.count { |n| n == 3 } >= 1
    ans += 1 if is_ok
  end
end
puts ans


Measured memory_bytes: 7036
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 100010
#define SZ 1010

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N,K;
int dp[SIZE];
int A[SIZE];
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen(fi, "r", stdin);
    #endif */
    //freopen("route.in","r",stdin);
    //freopen("route.out","w",stdout);
    //cin.ignore();
    //cin.clear();
    boost;
    //cin.tie(0);
    //cout<<"Case "<<tt<<": ";
    cin>>N>>K;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    dp[0] = 2;
    for(int i=1;i<=K;i++){
        bool is = false;
        for(int j=1;j<=N;j++){
            if(i >= A[j]){
                if(dp[i-A[j]] == 2){
                    is = true;
                }
            }
        }
        if(is)
        {
            dp[i] = 1;
        }
        else{
            dp[i] = 2;
        }
    }
    if(dp[K] == 1){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n ;
 cin >> n;
 vector<int> p(n);
   for(int i=0; i<n; i++){
     cin >> p.at(i);
   }
 int result = 0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      result +=  p.at(i) * p.at(j) ;
    }
  }
 cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };

           signed main(){
        
           	int x,a[100030],n,b;
           	cin>>n;
           	
           	cout<<"ABC"<<n<<endl;
           //	cout<<-1<<endl;
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int i,a,b,cnt=0;
  cin >> a >> b;
  for(i=a;i<=b;i++){
    if(i%10==i/10000 && (i/10)%10==(i/1000)%10)cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]
count = []

for i in range(N):
  c = 0
  for k in range(i+1):
    c += A[0][k]
  for k in range(i, N):
    c += A[1][k]
  count.append(c)
  c = 0
    
print(max(count))

Measured memory_bytes: 3064
def bubbleSort( cards )
    n = cards.length
    0.upto( n-1 ) { |i|
        ( n-1 ).downto( i+1 ) { |j|
            if cards[j][1].to_i < cards[ j-1 ][1].to_i
                cards[j], cards[ j-1 ] = cards[ j-1 ], cards[j]
            end
        }
    }
   puts( cards.join( " " ) )
end

def selectionSort( cards )
    n = cards.length
    0.upto( n-1 ) { |i|
        mini = i
        ( i+1 ).upto( n-1 ) { |j|
            if cards[j][1].to_i < cards[ mini ][1].to_i
                mini = j
            end
        }
        if mini != i
            cards[i], cards[ mini ] = cards[ mini ], cards[i]
        end
    }
    puts( cards.join( " " ) )
end


n = gets.to_i
cards = gets.split( " " )
cards2 = cards.clone
bubbleSort( cards )
puts( "Stable" )
selectionSort( cards2 )
if cards2 == cards
	puts( "Stable" )
else
	puts( "Not stable" )
end

Measured memory_bytes: 6116
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int a;
		String s;

		a = scan.nextInt();
		s = scan.next();

		if (a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


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

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static int[] ToInt(this string[] strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ToLong(this string[] strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SplToInt(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SplToLong(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static int[] ToFlat(this int[] array)
    {
        var min = array.Min();
        return array.Select(x => x - min).ToArray();
    }
    public static long[] ToFlat(this long[] array)
    {
        var min = array.Min();
        return array.Select(x => x - min).ToArray();
    }
    public static int Gcd(int a, int b)
    {
        if (b == 0)
        {
            return a;
        }

        return Gcd(b, a % b);
    }
    public static long Gcd(long a, long b)
    {
        if (b == 0)
        {
            return a;
        }

        return Gcd(b, a % b);
    }
    public static int Lcm(int a, int b)
    {
        var g = Gcd(a, b);
        return a / g * b;
    }
    public static long Lcm(long a, long b)
    {
        var g = Gcd(a, b);
        return a / g * b;
    }
    //テンプレここまで
}

public static partial class Program
{
    static void Main()
    {
        var n = CRL().ToInt();
        var times = new List<long>();
        long ans = 1;
        for (int i = 0; i < n; i++)
        {
            var input = CRL().ToLong();
            ans = Lcm(ans, input);
        }

        CWL(ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 5e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;

int n,k;
char a[maxN]; 
int main()
{
	scanf("%d%d%",&n,&k);
	scanf("%s",a+1);
	a[k] = a[k]-'A'+'a';
	for(int i=1;i<=n;i++)
	{
		printf("%c",a[i]);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

string S;

bool aMtrue, bMtrue;
bool aYtrue, bYtrue;

int main()
{
	cin >> S;

	int a = (S[0] - '0') * 10 + (S[1] - '0');
	int b = (S[2] - '0') * 10 + (S[3] - '0');

	//付きいけるかどうか調べる
	if (a != 0 && a <= 12) aMtrue = true;
	else aMtrue = false;

	if (b != 0 && b <= 12) bMtrue = true;
	else bMtrue = false;

	//歳いけるか調べる
	aYtrue = true;
	bYtrue = true;


	if (aMtrue && bYtrue && aYtrue && bMtrue)
	{
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	if (aMtrue && bYtrue)
	{
		cout << "MMYY" << endl;
		return 0;
	}
	if (aYtrue && bMtrue)
	{
		cout << "YYMM" << endl;
		return 0;
	}
	cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

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

/* -- template -- */

int main() {
    int N; cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = 1;
    if(A[0] != 0) {
        rep(i, N) {
            if(ans > ll(1e18) / A[i]) {
                ans = -1;
                break;
            } else {
                ans *= A[i];
            }
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4416
import java.util.Arrays;
import java.util.HashMap;
import java.util.Optional;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int P = sc.nextInt();
        String s = sc.next();

        HashMap<Integer, Integer> cnt = new HashMap<>();
        if (P == 2 || P == 5) {
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int x = s.charAt(i) - '0';
                if (x % P == 0) {
                    ans += i + 1;
                }
            }
            System.out.println(ans);
            return;
        }

        long ans = 0;
        int cur = 0;
        int pow = 1;
        for (int i = N - 1; i >= 0; i--) {
            int x = s.charAt(i) - '0';
            cur = (cur + x * pow) % P;
            int v = cnt.getOrDefault(cur, 0);
            cnt.put(cur, v + 1);
            ans += v;
            if (cur == 0) ans++;
            pow = (pow * 10) % P;
        }

        System.out.println(ans);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 32344
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
nkai=1
for i in range(1,n+1):
    nkai=nkai*i%mod
bunsu=[0]*(n+1)
for i in range(1,n+1):
    bunsu[i]=(pow(i,mod-2,mod)+bunsu[i-1])%mod
ans=0
for i in range(n):
    now=(bunsu[n-i]+bunsu[i+1]-bunsu[1])%mod
    now=now*a[i]%mod
    now=now*nkai%mod
    ans=(ans+now)%mod
print(ans)

Measured memory_bytes: 14480