akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 1e5 + 2;
int n, k;
ll arr[N], dp[N];

int main(){
	speed
	cin>>n >> k;
	f(i, 0, n)cin >> arr[i];
	dp[n - 1] = 0;
	dp[n - 2] = abs(arr[n - 1] - arr[n - 2]);
	for (int i = n - 3; i >= 0; i--){
		ll mn = 1e18;
		for (int j = 1; j <= k && i + j < n; j++){
			mn = min(mn ,abs(arr[i] - arr[i + j]) + dp[i + j]);
		}
		dp[i] = mn;
	}
	cout << dp[0] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main (void)
{
    int gr1[100][100],gr2[100][100],a1,a2,a3;
    int a,b,c,o,gou;
    long long  int an[100][100];
 
    for(a=0;a<100;a++)
    {
        for(b=0;b<100;b++)
        {
            gr1[a][b]=0;
            gr2[a][b]=0;
            an[a][b]=0;
        }
    }
    scanf("%d%d%d",&a1,&a2,&a3);
 
    for(a=0;a<a1;a++)
    {
        for(b=0;b<a2;b++)
        {
            scanf("%d",&gr1[a][b]);
        }
    }
    for(a=0;a<a2;a++)
    {
        for(b=0;b<a3;b++)
        {
            scanf("%d",&gr2[a][b]);
        }
    }
 
    for(a=0;a<a1;a++)
    {
        for(b=0;b<a3;b++)
        {   
            for(c=0;c<a2;c++)
            {
                an[a][b]+=(gr1[a][c]*gr2[c][b]);
            }
        }
    }
 
    for(a=0;a<a1;a++)
    {
        for(b=0;b<a3-1;b++)
        {
            printf("%lld ",an[a][b]);
        }
        printf("%lld\n",an[a][a3-1]);
    }
    return 0;
}

Measured memory_bytes: 756
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  ll n,a,b,c;
  cin>>n>>a>>b>>c;
  string s[n];
  int f=1;
  char d[n];
  rep(i,n){
    cin>>s[i];
  }
  rep(i,n){
    if(s[i]=="AB"){
      if(a<b){
        a++; b--; d[i]='A';
      }else if(a>b){
        a--; b++; d[i]='B';
      }else{
        if(i<n-1 && s[i+1]=="AC"){
          a++;b--;d[i]='A';
        }else{
          a--;b++;d[i]='B';
        }
      }
    }else if(s[i]=="AC"){
      if(a<c){
        a++;c--;d[i]='A';
      }else if(a>c){
        a--; c++;d[i]='C';
      }else{
         if(i<n-1 && s[i+1]=="AB"){
           a++;c--;d[i]='A';
         }else{
           a--;c++;d[i]='C';
         }
      }
    }else{
      if(b<c){
        b++;c--;d[i]='B';
      }else if(b>c){
        b--;c++;d[i]='C';
      }else{
        if(i<n-1 && s[i+1]=="AB"){
          b++;c--;d[i]='B';
        }else{
          b--;c++;d[i]='C';
        }
      }
    }
    if(a==-1 || b==-1 || c==-1){
      f=0;
      break;
    }
  }
  if(f==1){
    cout<<"Yes"<<"\n";
    rep(i,n){
      cout<<d[i]<<"\n";
    }
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 6844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] x = new int[4];
		int[] y = new int[4];
		x[0] = sc.nextInt();
		y[0] = sc.nextInt();
		x[1] = sc.nextInt();
		y[1] = sc.nextInt();
		
		int dx = x[1] - x[0];
		int dy = y[1] - y[0];
		dy = -dy;
		
		x[2] = x[1] + dy;
		y[2] = y[1] + dx;
		x[3] = x[0] + dy;
		y[3] = y[0] + dx;
		System.out.println(x[2]+" "+y[2]+" "+x[3]+" "+y[3]);
	}
}


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

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

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

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 a, b, c;
    cin >> a >> b >> c;
    i64 k;
    cin >> k;

    for (i64 i = 0; i <= k; i++) {
        for (i64 j = 0; i + j <= k; j++) {
            i64 na = a << i;
            i64 nb = b << j;
            i64 nc = c << (k - i - j);
            if (na < nb && nb < nc) {
                cout << "Yes" << endl;
                return;
            }
        }
    }

    cout << "No" << endl;
}

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


Measured memory_bytes: 3632
#include <iostream>
#include <stdint.h>
#include <vector>
#include <limits.h>
#include <utility>

using namespace std;

inline int to_add(char i) {
  return (i=='1') ? 1:-1;
}

int main()
{
  int64_t N, K;
  cin >> N >> K;

  vector<int> S = {0};
  for (int n=0; n<N; ++n) {
    char i;
    cin >> i;
    if (i=='0' && S.back() < 0)
      --S.back();
    else if (i=='0' && S.back() >= 0)
      S.push_back(-1);
    else if (i=='1' && S.back() < 0)
      S.push_back(1);
    else if (i=='1' && S.back() >= 0)
      ++S.back();
  }
  if (S.back() < 0)
    S.push_back(0);

  // for (auto s : S)
  //   cerr << s << ' ';
  // cerr << endl;

  int ans=0, sum=0;
  for (int ii=0; ii<2*K+1 && ii<S.size(); ++ii)
    sum += abs(S[ii]);
  //cerr << sum << endl;
  
  ans = sum;

  for (int ii=1; 2*ii+2*K < S.size(); ++ii) {
    sum -= S[2*(ii-1)];
    sum -= (-S[2*(ii-1)+1]);
    sum += (-S[2*ii+2*K-1]);
    sum += S[2*ii+2*K];
    //cerr << sum << endl;
    ans = max(sum, ans);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 892
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}

function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let A = next();
    let V = next();
    let B = next();
    let W = next();
    let T = next();
    if (A == B) return 'YES';
    let kyori = Math.abs(A - B);
    let sokudo = V - W;
    if (sokudo <= 0) return 'NO'
    if (kyori <= sokudo * T) return 'YES'
    return 'NO'


}

Measured memory_bytes: 29488
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b < a) swap(a, b);
    if (c < b) swap(b, c);
    if (b < a) swap(a, b);
    int ans = 0;
    int n = (c - b) / 2;
    ans += n;
    b += n * 2;
    int m = (c - a) / 2;
    ans += m;
    a += m * 2;

    //cout << a << " " << b << " " << c << " " << ans << endl;
    if ((c - b + c - a) % 2 == 0) {
        ans += (c - b + c - a) / 2;
    } else {
        ans += 2;
    }
    cout << ans << endl;
}


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

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long 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;
    }
}

// 二項係数計算
ll 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;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 100000;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];

int main(){
    int h,n; cin >> h >> n;
    vector<int> v(n);
    int sum = 0;
    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        sum += v[i];
    }
    
    string ans;
    if (h <= sum) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: i64,
    }

    let mut map = HashMap::new();
    let mut i = 0;
    let mut a = s;
    while map.insert(a, i).is_none() {
        i += 1;
        a = if a % 2 == 0 { a / 2 } else { 3 * a + 1 };
    }
    println!("{}", i + 1);
}


Measured memory_bytes: 2200
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::slice::*;
use std::*;

const MOD: isize = 1000000007;
fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();
    let mut b = vec![0usize; n + 1];

    for &i in a.iter() {
        b[i] += 1;
    }

    let mut sm: isize = 0;
    for &i in b.iter() {
        sm += i as isize * (i as isize - 1) / 2;
    }
    for &i in a.iter() {
        println!(
            "{}",
            if (b[i] > 1) {
                sm as usize - (b[i] * (b[i] - 1) / 2) + (b[i] - 1) * (b[i] - 2) / 2
            } else {
                sm as usize
            }
        );
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace() // iter
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 11504
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S =Number(inputs);
  var h=Math.floor(S/3600);
  var m=Math.floor(S%3600/60);
  var s=S%60;
  console.log([h,m,s].join(':'));
  // ????????????????????????

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

void solve(){
  int n; cin >> n;
  vector<string> v;
  string ans = "Yes";
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    int j;
    for(j = 0; j < v.size(); j++){
      if(v[j] == s) break;
    }
    if(j == v.size()){
      if(v.size() > 0 && v[v.size() - 1][v[v.size() - 1].length() - 1] == s[0]) v.push_back(s);
      else if(v.size() == 0) v.push_back(s);
      else{
        ans = "No";
        break;
      }
    }
    else{
      ans = "No";
      break;
    }

  }
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cn = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                cn = cn + 1

print(cn)

Measured memory_bytes: 67284
import java.util.EmptyStackException

import scala.io.StdIn.readLine

object Main extends App {

  val st1 = new Stack[Int]()
  val st2 = new Stack[(Int, Int)]()
  val arr = readLine.toCharArray

  arr.zipWithIndex.foreach { case (char, pos) => {
    char match {
      case '\\' => {
        st1.push(pos)
      }
      case '/' => {
        processUp(pos, st1, st2)
      }
      case _ => {}
    }
  }
  }

  var total = 0
  var resArr = Array[Int]()
  val itr: Iterator[(Int, Int)] = st2.iterator
  while (itr.hasNext) {
    val area = itr.next()
    resArr = resArr :+ area._2
    total += area._2
  }

  println(total)
  print(st2.count)
  if (st2.count > 0) {
    print(" " + resArr.reverse.mkString(" "))
  }
  println()

  def processUp(cur: Int, st1: Stack[Int], st2: Stack[(Int, Int)]): Unit = {

    if (st1.isEmpty) {
      return
    }

    val lastPos = st1.pop()
    var curArea = cur - lastPos
    if (st2.isEmpty) {
      st2.push(lastPos, curArea)
      return
    }

    var continue = true
    while (continue && !st2.isEmpty()) {
      val lastArea = st2.pop()
      if (lastArea._1 > lastPos) {
        curArea += lastArea._2
      } else {
        st2.push(lastArea)
        continue = false
      }
    }
    st2.push(lastPos, curArea)
  }

  class Node[T](v: T) {
    var value: T = v
    var next: Node[T] = null
    var prev: Node[T] = null
  }

  class Stack[T] extends Iterable[T] {

    var top: Node[T] = null
    var bottom: Node[T] = null
    var count = 0

    def push(value: T): Unit = {
      val newNode = new Node[T](value)
      if (count == 0) {
        bottom = newNode
      } else {
        top.prev = newNode
        newNode.next = top
      }
      top = newNode
      count += 1
    }

    def pop(): T = {
      if (count == 0) {
        throw new EmptyStackException()
      }
      val ret = top.value
      top = top.next
      count -= 1
      ret
    }

    def peek(): T = {
      if (count == 0) {
        throw new EmptyStackException()
      }
      top.value
    }

    override def isEmpty(): Boolean = {
      count == 0
    }

    override def iterator: Iterator[T] = {
      new StackIterator(top)
    }
  }

  class StackIterator[T](top: Node[T]) extends Iterator[T] {

    var current: Node[T] = top

    override def hasNext: Boolean = {
      current != null
    }

    override def next(): T = {
      val value = current.value
      current = current.next
      value
    }
  }

}



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

int main(){
	string s;
	int n;
	while(cin >> s >> n && !(s=="0" && n==0)){
			map<string,int> m;
			int sinit = s.size();
			for(int i=0;i<n-sinit;i++){
					s = "0" + s;
			}
			int cnt = 0;
			m[s] = cnt;
			cnt++;
			while(1){
					string t = s;
					sort(s.rbegin(), s.rend());
					sort(t.begin(), t.end());
					s = to_string( stoi(s) - stoi(t) );
					if(s.size()<n){
							for(int i=0;i<n-s.size();i++){
									s = "0" + s;
							}
					}
					if(m.count(s)){
							cout << m[s] << " " <<  stoi(s) << " " << cnt-m[s] << endl;
							break;
					}else{
							m[s] = cnt;
							cnt++;
					}

			}
	}
}


Measured memory_bytes: 3244
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    rep(i, s.size()) { cout << "x"; }
    cout << endl;

    return 0;
}


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

typedef long long ll;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define MOD 1000000007

int W,H;
int w,h,x,y;

int main(){
  cin>>W>>H;
  cin>>w>>h>>x>>y;
  int l = x - w/2;
  int r = x + w/2;
  int u = y - h/2;
  int d = y + h/2;
  CHMAX(l,-W/2);CHMIN(l, W/2);
  CHMAX(r,-W/2);CHMIN(r, W/2);
  CHMAX(u,-H/2);CHMIN(u, H/2);
  CHMAX(d,-H/2);CHMIN(d, H/2);
  double ans = (double)(u+d)/(l+r);
  printf("%.9f\n",ans);
  return 0;
}


Measured memory_bytes: 3240
#include<stdio.h>

int main()
{
 int n;
 long a; 
 long b; 
 long maxpos=0;
 long minval=1000000005;
 long players;
 int i;

 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
   scanf("%ld %ld",&a,&b);
   if(minval>b) minval=b;
   if(maxpos<a) maxpos=a;
 }
 players=maxpos+minval;
 printf("%ld\n",players);

 return 0;
}


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

int main(){

  int n, m, s;

  while(cin >> n >> m, n|m){
    vector<int> t_card;
    vector<int> h_card;
    int taro = 0, hanako = 0;
    for(int i = 0; i < n; i++){
      cin >> s;
      t_card.push_back(s);
      taro += s;
    }
    for(int i = 0; i < m; i++){
      cin >> s;
      h_card.push_back(s);
      hanako += s;
    }
    int flag = 0;
    int min_s = 10e7, t, h;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        if(taro - t_card[i] + h_card[j] == hanako - h_card[j] + t_card[i]){
          if(min_s > t_card[i] + h_card[j]){
            t = t_card[i];
            h = h_card[j];
            min_s = t + h;
          }
        }
      }
    }
    if(min_s == 10e7){
      cout << -1 << endl;
    }else{
      cout << t << " " << h << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

//繰り返し二乗法
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n;cin>>n;
	string s;cin>>s;
	vector<int> a(26,0);
	for(int i = 0; i < n; i++) {
		a[s[i] - 'a']++;
	}
	ll ans = 1;
	for(int i = 0; i < 26; i++) {
		ans *= (a[i] + 1);
		ans %= mod;
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    int N, A, B;  cin >> N >> A >> B;
    print(min(A * N, B));

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a[5],tmp;
    int i,j;
    for(i=0;i<5;i++)scanf("%d",&a[i]);
    for(i=0;i<5;i++){
        for(j=4;j>i;j--){
            if(a[i]<a[j]){
                tmp = a[j];
                a[j] = a[i];
                a[i] = tmp;
            }
        }
    }
    for(i=0;i<5;i++){
        printf("%d",a[i]);
        printf((i-4)? " " : "\n");
    }
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

 
int main() {
   
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans = "No";
    if(abs(a - c) <= d){
        ans = "Yes";
    }else if(abs(a - b) <= d && abs(b - c) <= d){
        ans = "Yes";
    }
    cout << ans << endl;

}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define modd               1e9+7
#define ff                 first
#define ss                 second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define rep(i,l,r)         for(int i=l;i<r;i++)
#define rer(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
using namespace std;
int32_t main(){

	
     int n;
     cin >> n;
     vi v(n);
     FOR(i,n)
     cin >> v[i];
     set<int>s;
     int ans = -1,st=1;
     FOR(i,n){
     	if(v[i]==st){
     		ans=max(ans,st);
     		st++;
     	}
     	s.insert(v[i]);
     }
     if(ans==-1)
     	ans=n+1;
     cout << n-ans << endl;
    return 0;

}

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


int main(){


    long long n, t, i;

    vector<long long> a;

    deque<long long> b;

 
    cin >> n;


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

         cin >> t;

         a.push_back(t);

         }


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

         if( n % 2 == 0 ){

             if( i % 2 == 0 ) b.push_back( a.at(i) );

             else b.push_front( a.at(i) );
   
             }

         else{
               
               if( i % 2 == 0 ) b.push_front( a.at(i) );

               else b.push_back( a.at(i) );

               }

         }


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

         cout << b.at(i);

         if( i < n - 1 ) cout << " " ;

         else cout << endl;

         }


    return 0;


    }

Measured memory_bytes: 5360
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define endl "\n"



void solve(){
    ll x;
    cin>>x;
    
    if(x>=400&&x<=599){cout<<"8"<<endl;}
     if(x>=600&&x<=799){cout<<"7"<<endl;}
      if(x>=800&&x<=999){cout<<"6"<<endl;}
       if(x>=1000&&x<=1199){cout<<"5"<<endl;}
        if(x>=1200&&x<=1399){cout<<"4"<<endl;}
         if(x>=1400&&x<=1599){cout<<"3"<<endl;}
          if(x>=1600&&x<=1799){cout<<"2"<<endl;}
           if(x>=1800&&x<=1999){cout<<"1"<<endl;}
           return;
        
}


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

   solve();
}


Measured memory_bytes: 3648
// OURL: https://atcoder.jp/contests/abc104/tasks/abc104_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll D,G;
  cin >> D >> G;
  auto ps = make_v<pair<ll,ll>>(D);
  REP(i,D) {
    ll p, c;
    cin >> p >> c;
    ps[i] = make_pair(p, c);
  }
  auto v = make_v<int>(D);
  iota(v.begin(), v.end(), 1);
  ll ans = LONG_LONG_MAX;
  do {
    ll sum = 0, c = 0;
    for(auto x: v) {
      ll m = x * 100 * ps[x-1].first;
      if (sum + m + ps[x-1].second < G) {
        c += ps[x-1].first;
        sum += m + ps[x-1].second;
        continue;
      } else if (sum + m < G) {
        c += ps[x-1].first;
        break;
      } else {
        c += ll(ceil(double(G-sum) / double(x*100)));
        break;
      }
    }
    ans = min(ans, c);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(H[b-1])
    adj[b-1].append(H[a-1])
cnt = 0
for idx in range(N):
    if len(adj[idx]) == 0:
        cnt += 1
    elif max(adj[idx]) < H[idx]:
        cnt += 1

print(cnt)


Measured memory_bytes: 92844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,m; cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    int left = 1;
    int right = n;
    bool res = true;
    rep(i,m) {
        cin >> l[i] >> r[i];
        chmax(left,l[i]);
        chmin(right,r[i]);
        if (left > right) {
            res = false;
            break;
        }
    }
    if(res) cout << right - left + 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 1024
N, M, *A = $<.read.split.map &:to_i
(x, y, z), a = A.partition &:odd?
if z
  puts :Impossible
  exit
end
a = *x, *a, *y
b = []
a.each do |x|
  if x % 2 == 0
    b[0] ||= 1
    b << x
  else
    b[0] ||= 2
    b += [2] * (x / 2)
  end
end
b[-1] -= 1 unless y
puts a, b.size, b


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

int main()
{
    MOAE;
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            cout << "OK" << endl;
            ok;
        }
    }
    cout << "NG" << endl;
    ok;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>v(n + 5), cum(n + 5);
    long long dp[n + 5][n + 5];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            dp[i][j] = 1e18;
        }
    }
    cum[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        cum[i] = cum[i - 1] + v[i];
        dp[i][i] = 0;
    }
    for(int i = 2; i <= n; i++){
        for(int l = 1; l + i - 1 <= n; l++){
            int r = l + i - 1;
            for(int j = l; j < r; j++){
                dp[l][r] = min(dp[l][r], dp[l][j] + dp[j + 1][r] + cum[r] - cum[l - 1]);
            }
        }
    }
    cout << dp[1][n];
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int cnt[200000];
int main(){
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    cnt[a-1]++;
  }
  sort(cnt,cnt+N);
  int ans=0;
  for(int i=0;i<N-K;i++)ans+=cnt[i];
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(100009),B(100009);
  vector<pair<int, pair<int, int> > > vec(N);
  for(int i=0;i<N;i++){cin >> A[i] >> B[i];}
  for(int i=0;i<N;i++){vec[i] = make_pair(A[i]+B[i], make_pair(A[i],B[i]));}
  long long a=0,b=0;
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    if(i%2==0){a+=vec[N-1-i].second.first;}
    else{b+=vec[N-1-i].second.second;}
  }
  cout << a-b << endl;
}

Measured memory_bytes: 2176
n=int(input())
A=list(map(int,input().split()))
A=[0]+A+[0]
ans=0
LC=[0]*(n+2)
for i in range(1,n+1):
    ans+= abs(A[i]-A[i-1])
    if A[i-1]<A[i] and A[i]>A[i+1]:
        LC[i]= 2*( A[i]- max(A[i-1],A[i+1]) )
    if A[i-1]>A[i] and A[i]<A[i+1]:
        LC[i]= -2*(A[i]- min(A[i-1],A[i+1])) 
ans+= abs(A[n])
for i in range(n):
    print(ans-LC[i+1])
#print(ans,LC)

Measured memory_bytes: 86780
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

//Nは奇数
//互いに異なればよいので、要素の種類が大事
//要らない要素が奇数個あったら、余計に1枚食われる

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

	map<int, int> mp;

	for (int i = 0; i < n; i++) {
		mp[a[i]] += 1;
	}
	int tmp = 0;
	int ans = 0;
	for (pair<int, int> x : mp) {
		if (x.second % 2 == 0) { tmp++; }
		ans++;
	}

	if (tmp % 2 == 1) {
		ans--;
	}

	cout << ans << endl;





}


Measured memory_bytes: 5376
#!/usr/bin/env python3
from functools import reduce

mod = 10**9 + 7
n, k, *a = map(int, open(0).read().split())
a.sort(key=lambda x: abs(x))
ans = reduce(lambda a, b: (a * b) % mod, a[-k:])

c = a[-k:]
j = sum(i < 0 for i in c) % 2
if j:
    c = a[-k:]
    neg = [i for i in c if i < 0]
    pos = [i for i in c if i > 0]
    b = sorted(a[:n - k])
    if b == []:
        print(ans)
        exit()
    if neg == []:
        if pos[0] * b[0] < 0:
            ans = ans * pow(pos[0], mod - 2, mod) * b[0] % mod
        else:
            ans = reduce(lambda a, b: (a * b) % mod, a[:k])
    elif pos == []:
        if neg[0] * b[-1] < 0:
            ans = ans * pow(neg[0], mod - 2, mod) * b[-1] % mod
        else:
            ans = reduce(lambda a, b: (a * b) % mod, a[:k])
    elif pos[0] * b[-1] < neg[0] * b[0] and pos[0] * b[0] < 0:
        ans = ans * pow(pos[0], mod - 2, mod) * b[0] % mod
    elif 0 > b[-1] * neg[0]:
        ans = ans * pow(neg[0], mod - 2, mod) * b[-1] % mod
    else:
        ans = reduce(lambda a, b: (a * b) % mod, a[:k])
print(ans)


Measured memory_bytes: 32088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int a,b,c;
	cin >> a>>b>>c;
	if(a==b) cout << c;
	else if (a==c) cout << b;
	else if (c==b) cout << a;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string a, s, c; cin >> a >> s >> c;
  cout << 'A' << s.front() << 'C' << '\n';
  return 0;
}


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

int a,b,c;
int rcount;
 
int ran(int x){
  return (a*x+b)%c;
}

int main(){
  int n,x,xf;
  int y[101];

  while(1){
    rcount=0;
    cin >> n >> a >> b >> c >> x;
    xf=x;
    if(n==0 && a==0 && b==0 && c==0 && n==0)break;
    for(int i=0;i<n;i++){
      cin >> y[i];
    }
    for(int i=0;i<n;i++){
      if(xf!=y[0]){
	while(rcount<=10001){
	    x=ran(x);
	    rcount++;
	  if(x==y[i]){
	    break;
	  }
	}
      }
      xf=-1;
    }
    if(rcount<=10000){
      cout << rcount << endl;
    }else{
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 1160
x=int(input())

import random

def is_prime3(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

for i in range(10**5):
    if is_prime3(x+i):
        print(x+i)
        break


Measured memory_bytes: 39280
def factorial(n, mod=10**9+7):
    a = 1
    for i in range(1,n+1):
        a = a * i % mod
    return a

def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod=10**9+7):
    if n < k or k < 0:
        result = 0
    else:
        a = factorial(n, mod=mod)
        b = factorial(k, mod=mod)
        c = factorial(n-k, mod=mod)
        result = (a * power(b, mod-2, mod=mod) * power(c, mod-2, mod=mod)) % mod
    return result

n, k = map(int, input().split())
k = min(n, k)
MOD = 10**9 + 7
fl = [-1]*(n+1)
fl[0] = 1
def f(i):
  global fl
  if fl[i] > 0: return fl[i]
  else:
    res = f(i-1)*(n-i+1)*(n-i)
    t = power(i, MOD-2)
    res *= t**2
    res %= MOD
    fl[i] = res
    return res

if k <= n//2:
  ans = 0
  for i in range(k+1):
    ans += f(i)
    ans %= MOD
else:
  fl[k] = comb(n, k) * comb(n-1, k) % MOD
  ans = 0
  for i in range(k+1, n+1):
    ans += f(i)
    ans %= MOD
  ans = comb(2*n-1, n) - ans
  ans %= MOD

print(ans % MOD)

Measured memory_bytes: 56924
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int x[55], y[55];

int f[55][55];

int subsum(int x_min, int y_min, int x_max, int y_max) {
    return f[x_max][y_max] - f[x_max][y_min-1] - f[x_min-1][y_max] + f[x_min-1][y_min-1];
}

ll solve() {
    map<int, int> mx, my;
    map<int, int> mxr, myr;
    for (int i = 0; i < n; i++) {
        mx[x[i]] = 0;
        my[y[i]] = 0;
    }

    int idx = 1;
    for (auto v : mx) {
        mx[v.first] = idx;
        mxr[idx] = v.first;
        idx++;
    }
    idx = 1;
    for (auto v : my) {
        my[v.first] = idx;
        myr[idx] = v.first;
        idx++;
    }

    for (int i = 0; i < n; i++) {
        f[mx[x[i]]][my[y[i]]]++;
    }
    for (int i = 1; i < 55; i++) {
        for (int j = 1; j < 55; j++) {
            f[i][j] += f[i-1][j] + f[i][j-1] - f[i-1][j-1];
        }
    }

    ll res = 9e18;
    for (int i0 = 0; i0 < n; i0++) {
        for (int i1 = 0; i1 < n; i1++) {
            for (int i2 = 0; i2 < n; i2++) {
                for (int i3 = 0; i3 < n; i3++) {
                    int x_min = min(min(mx[x[i0]], mx[x[i1]]), min(mx[x[i2]], mx[x[i3]]));
                    int x_max = max(max(mx[x[i0]], mx[x[i1]]), max(mx[x[i2]], mx[x[i3]]));
                    int y_min = min(min(my[y[i0]], my[y[i1]]), min(my[y[i2]], my[y[i3]]));
                    int y_max = max(max(my[y[i0]], my[y[i1]]), max(my[y[i2]], my[y[i3]]));
                    if (subsum(x_min, y_min, x_max, y_max) >= k) {
                        res = min(res, (ll)(mxr[x_max] - mxr[x_min]) * (ll)(myr[y_max] - myr[y_min]));
                    }
                }
            }
        }
    }
    return res;
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	int a,b,c;
  	int temp;
    cin >> a >> b >> c;
  	// 入れ替え処理
  	// aとbの値を入れ替える
  	temp = a;
  	a = b;
  	b = temp;
  	// aとcの値を入れ替える
  	temp = a;
  	a = c;
  	c = temp;
  
  	// 入れ替え結果を出力
  	cout << a  << " " << b << " " << c;
  	
}


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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 998244353;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll num_): num((num_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return num; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }

    template <typename T>
    modint operator+(const T &r) const { return modint(num + r); }
    template <typename T>
    modint operator-(const T &r) const { return modint(num - r); }
    template <typename T>
    modint operator*(const T &r) const { return modint(num * r); }
    template <typename T>
    modint operator/(const T &r) const { return num * pow(r, MOD-2); }

    template <typename T>
    modint operator+=(const T &r) { return *this = *this + r; }
    template <typename T>
    modint operator-=(const T &r) { return *this = *this - r; }
    template <typename T>
    modint operator*=(const T &r) { return *this = *this * r; }
    template <typename T>
    modint operator/=(const T &r) { return *this = *this / r; }

    static modint pow(const modint &x, const ll &r) {
        if(r == 0) return 1;
        return pow(x*x, r/2) * modint(r&1 ? x : modint(1));
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) {
            int size = factorial.size();
            factorial.resize(n+1);
            for (int k = size; k <= n; k++) {
                factorial[k] = factorial[k-1] * k;
            }
        }
        return factorial[n];
    }

    static modint C(int n, int r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial = {1};
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)


int main(void){
    int n;
    cin >> n;
    modint sum = 0;
    for (int i = n/2+1; i <= n; i++) {
        sum += C(n,i) * modint::pow(2,n-i) * 2;
    }
    cout << modint::pow(3,n) - sum << endl;
    return 0;
}


Measured memory_bytes: 117376
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

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

    READV(N);
    READV(K);
    READV(R);
    READV(S);
    READV(P);
    string T;
    READ(T);
    ll ans=0;
    for (ll i = 0; i < K; i++)
    {
        ll a=0,b=0,c=0;
        for (ll j = i; j < N; j+=K)
        {
            ll a1,b1,c1;
            if (T[j]=='r')
            {
                a1=max(b,c);
                b1=P+max(a,c);
                c1=max(a,b);
            }
            else if (T[j]=='p')
            {
                a1=max(b,c);
                b1=max(a,c);
                c1=S+max(a,b);
            }
            else
            {
                a1=R+max(b,c);
                b1=max(a,c);
                c1=max(a,b);
            }
            a=a1,b=b1,c=c1;
        }
        ans+=max({a,b,c});
    }
    cout<<ans<<endl;
    
    

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


   
    return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;  cin >> s;
    t += s[0];
    t += to_string(s.size() - 2);
    t += s[s.size() - 1];

    cout << t << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):A[i] -= 1
visited = [-1] * n
visited[0] = 0
now = 0
count = 0
while True:
  now = A[now]
  count += 1
  if count == k:
    print(now+1)
    exit()
  if visited[now] == -1:
    visited[now] = count
  else:
    rooplen = count-visited[now]
    k -= visited[now]
    k = k % rooplen
    break
  # print(visited)

visited = [-1] * n
count = 0
while True:
  # print(count,k,now)
  if count == k:
    print(now+1)
    exit()
  if visited[now] == -1:
    visited[now] = count
  now = A[now]
  count += 1

Measured memory_bytes: 92640