akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    vector<string> a;
    vector<string> b;
    int n, m; cin >> n >> m;
    REP(i, n) {
        string tmp; cin >> tmp;
        a.push_back(tmp);
    }
    REP(i, m) {
        string tmp; cin >> tmp;
        b.push_back(tmp);
    }
    int a_width = a[0].size();
    int b_width = b[0].size();
    FOR(i, 0, n - m) {
        FOR(j, 0, a_width - b_width) {
            bool f = true;
            FOR(di, 0, m-1) {
                FOR(dj, 0, b_width-1) {
                    if (a[i+di][j+dj] != b[di][dj]) {
                        f = false;
                    }
                }
            }
            if (f) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int n, x, t;

int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a%b);
}

int main() {
	cin >> n >> t; n--;
	while (n--) {
		cin >> x;
		t = gcd(t, x);
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }
fn main() {
    input!(_s: String);

    let s: Vec<char> = _s.chars().collect();

    if s[1] == 'R' {
        println!("{}", s.iter().filter(|&&c| c == 'R').count());
    }
    else {
        if (s[0] == 'R') || (s[2] == 'R') {
            println!("1");
        }
        else {
            println!("0");
        }
    }
}


Measured memory_bytes: 2116
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int ans[1000];
    int i = 0;
    if (n == 0)
    {
        printf("0\n");
        return 0;
    }
    while (n != 0)
    {
        if (n % 2 == 0)
            ans[i] = 0;
        else
        {
            ans[i] = 1;
            n--;
        }
        n /= -2;
        i++;
    }
    i--;
    for (; i >= 0; i--)
        printf("%d", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n, k; cin >> n >> k;
  vector<int> a(n); rep(i, n) cin >> a[i];
  outl(ceil(n - k, k - 1) + 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

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

    int a, b;
    cin >> a >> b;

    map<int, int> mp;
    int idx = 1, r = 3, j = 2;
    while(r <= 499500){
        mp[idx] = r;
        idx += j;
        j++;
        r += j;
    }

    REP(i, 500500){
        int aa = a + i;
        int bb = b + i;
        if(mp[aa] == bb){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 23680
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan =  null;
		try{
			scan = new Scanner(System.in);
			int n,m;
			while(scan.hasNext()){
				n = scan.nextInt();
				m = scan.nextInt();
				System.out.println(n + m);
			}
		}finally{
			if(scan !=null)scan.close();
		}
	}
}

Measured memory_bytes: 20528
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long H, long long W, long long M, std::vector<long long> h,
           std::vector<long long> w) {
  vector<pair<int, int>> CountH(H), CountW(W);
  map<int, map<int, bool>> m;
  rep(i, H) CountH[i].second = i;
  rep(i, W) CountW[i].second = i;
  rep(i, M) {
    h[i]--,w[i]--;
    CountH[h[i]].first++;
    CountW[w[i]].first++;
    m[h[i]][w[i]] = true;
  }
  sort(CountH.rbegin(), CountH.rend());
  sort(CountW.rbegin(), CountW.rend());
  lli ans =
      CountH[0].first + CountW[0].first - (int)m[CountH[0].second][CountW[0].second];
  if (!m[CountH[0].second][CountW[0].second]) {
    cout << ans << endl;
    return;
  } else {
    set<int> HS, WS;
    rep(i, W) {
      if (CountW[i].first != CountW[0].first) {
        break;
      }
      WS.insert(CountW[i].second);
    }
    rep(i, H) {
      if (CountH[i].first != CountH[0].first) {
        break;
      }
      HS.insert(CountH[i].second);
    }
    for (auto i : HS)
      for (auto j : WS) {
        if(!m[i][j]){
          cout << ans + 1 <<endl;
          return;
        }
      }
    cout << ans <<endl;
  }
}

signed main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> h(M);
  std::vector<long long> w(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &h[i]);
    scanf("%lld", &w[i]);
  }
  solve(H, W, M, std::move(h), std::move(w));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 64268
const ten2n = base => num => {
	const ary = [];
	let _num,sho,am;
	_num = num;
	while (_num > 0) {
		sho = Math.floor(_num/base);
		am = _num - sho * base;
		_num = sho;
		ary.unshift(am);
	}
	return ary;
}
const fillZoro = n => ary => {
	const ret = [];
	const len = ary.length;
	for(let i = 0; i < n; i++) ret[i] = 0;
	for(let i=n-len, j=0; i < n; i++,j++) ret[i] = ary[j];
	return ret;
	
}
const logJoinChar = d => ary => console.log(ary.join(d));
const func = obj => (n,keta,ch) => num => {
	const jump = obj.f1(n);
	const step = obj.f2(keta);
	const hop = obj.f3(ch);
	hop(step(jump(num)));
}

const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const funcs = {
	f1:ten2n,
	f2:fillZoro,
	f3:logJoinChar
};
const params = func(funcs);
const action = params(60,3,':');

action(Number(input));


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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if (a==b&&b!=c) cout<<"Yes";
  else if (b==c&&c!=a) cout<<"Yes";
  else if (c==a&&a!=b) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    P = LIST()
    count = 0
    for i in range(N):
        if P[i] != i + 1:
            count += 1
    if count == 2 or count < 2:
        YES()
    else:
        NO()

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i<n; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int mini = 1001001001;
  for(int i = 0; i < n - k + 1; i++) {
    mini = min(mini, h[i + k - 1] - h[i]);
  }
  cout << mini << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  n++;
  vector<int> t(n), x(n), y(n);
  t[0], x[0], y[0] = 0, 0, 0;
  for (int i = 1; i < n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool can = true;
  for (int i = 0; i < n - 1; i++) {
    if (t[i] % 2 != (x[i] + y[i]) % 2) {
      can = false;
      break;
    }
    if (t[i + 1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) {
      can = false;
      break;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main(){

	int n, x;
	int i;
	int a, b, c;
	while (true){
		cin >> n >> x;
		if (n == 0 && x == 0){
			break;
		}
		i = 0;
		for (a = 1; a <= n; a++){
			for (b = 1; b <= n; b++){
				for (c = 1; c <= n; c++){
					if (a + b + c == x){
						if (a != b&&b != c&&a != c){
							i++;
						}
					}
				}
			}
		}
		cout << i / 6 << endl;
	}
	return 0;

}


Measured memory_bytes: 3100
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Control.Applicative
import Text.Printf

readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as


data Mark = S | H | C | D deriving (Eq, Ord, Show, Read, Enum)

main = do
    n <- readInt
    mns <- replicateM n getPair
    let res = go mns
    forM_ [0..3] $ \m -> do
        let mark = toEnum m :: Mark
        forM_ [1..13] $ \n -> do
            when (not $ res ! (m,n)) $ putStrLn (printf "%s %d" (show mark) n)

getPair = do
    m <- getChar
    _ <- getChar
    n <- readInt
    return (fromEnum $ (read [m] :: Mark), n)

go :: [(Int, Int)] -> UArray (Int, Int) Bool
go mns = runSTUArray $ do
    cards <- newArray ((0, 1), (3, 13)) False
    forM_ mns $ \(m,n) -> writeArray cards (m,n) True
    return cards



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



int main(){
  string str;
  char ans[100];
  int cnt=0;

  cin>>str;
  for(int i=0;i<(int)str.size();i++){
    if(str[i]=='A'){
      if(cnt%2==0){
	ans[cnt]='A';
	cnt++;
      }
    }else if(str[i]=='Z'){
      if(cnt%2==1){
	ans[cnt]='Z';
	cnt++;
      }
    }
  }
  if(cnt%2==1)cnt--;
  if(cnt==0)cout<<-1<<endl;
  else {
    for(int i=0;i<cnt;i++)cout<<ans[i];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val a = new Array[Int](N+1)
  for(i <- 1 to N)
    a(i) = in.next().toInt

  //
  import Math.{max, min}
  val memo = Array.ofDim[Long](N+1, N+1)
  val init = Long.MaxValue
  for (a <- 0 to N; b <- 0 to N)
    memo(a)(b) = init

  def solve(bg: Int, ed: Int, turn: Boolean): Long = {
    if(memo(bg)(ed) != init)
      memo(bg)(ed)
    else{
      if(bg == ed) {
        memo(bg)(ed) = a(bg) * (if(turn) 1 else -1)
        memo(bg)(ed)
      }
      else {
        val left = solve(bg+1, ed, !turn)
        val right = solve(bg, ed-1, !turn)
        if(turn)
          memo(bg)(ed) = max(left + a(bg), right + a(ed))
        else
          memo(bg)(ed) = min(left - a(bg), right - a(ed))
        memo(bg)(ed)
      }
    }
  }

  println(solve(1, N, true))
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



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

int main()
{
  std::ios::sync_with_stdio(false);
  int n, a, b;
  while (std::cin >> n >> a >> b) {
    int result = n;
    for (int i = 0, x; i < n; ++ i) {
      std::cin >> x;
      result -= a <= x && x < b;
    }
    std::cout << result << std::endl;
  }
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new FastScanner(System.in)
  val k = sc.nextInt()
  val s = sc.next().length

  val mod = 1000000007

  def plus(a: Long, b: Long): Long = (a + b) % mod
  def times(a: Long, b: Long): Long = (a * b) % mod

  def pow(a: Long, n: Int, res: Long = 1): Long = {
    if (n == 0) {
      res
    } else if ((n&1) == 0) {
      pow(times(a,a), n >> 1, res)
    } else {
      pow(times(a,a), n >> 1, times(res,a))
    }
  }

  def inv(a: Long): Long = pow(a, mod-2)

  def initFactTable(n: Int): Array[Long] = {
    (1 to n).scanLeft(1L)(times(_,_)).toArray
  }

  val fact = initFactTable(s+k)

  def initInvFactTable(n: Int): Array[Long] = {
    (1 to n).scanRight(inv(fact(n)))(times(_,_)).toArray
  }

  val invFact = initInvFactTable(s+k)

  def comb(n: Int, k: Int): Long = {
    times(times(fact(n), invFact(k)), invFact(n-k))
  }

  val pow25 = (0 until k).scanLeft(1L){ case (res, _) => times(res, 25)}.toArray
  val pow26 = (0 until k).scanLeft(1L){ case (res, _) => times(res, 26)}.toArray

  val ans = (s to s+k).map{ i =>
    times(times(comb(i-1, s-1), pow25(i-s)), pow26(s+k-i))
  }.reduceLeft(plus)

  println(ans)
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


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

priority_queue<int> q;

int main(){
	int n;
	while(cin>>n) q.push(n);
	cout<<q.top()<<endl;
	q.pop();
	cout<<q.top()<<endl;
	q.pop();
	cout<<q.top()<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a+b>=c){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())

path = [list(map(int, input().split())) for _ in range(n)]

path_before_t = list(filter(lambda x: x[1] <= t, path))
if len(path_before_t) == 0:
    print('TLE')
else:
    print(min(path_before_t)[0])

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"strconv"
)

func solve(nums []int) int {
	minDiff := 753
	tn := 753
	for i := 0; i < len(nums)-2; i++ {
		n := 0
		for j := 0; j < 3; j++ {
			n = 10*n + nums[i+j]
		}
		diff := tn - n
		if diff < 0 {
			diff = -diff
		}

		if diff < minDiff {
			minDiff = diff
		}
	}

	return minDiff
}

func main() {
	var str string
	fmt.Scanln(&str)

	nums := make([]int, len(str))
	for i, c := range str {
		nums[i], _ = strconv.Atoi(string(c))
	}

	fmt.Println(solve(nums))
}

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

typedef long long ll;
typedef long double ld;

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

    int N, M;
    cin >> N >> M;

    vector<int> v;
    for(int i = 1; i < N; i++) {
        v.push_back(i);
    }

    vector<vector<bool> > c(N, vector<bool>(N));

    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        c[a][b] = true;
        c[b][a] = true;
    }

    int ans = 0;

    do {
        int pos = 0;
        bool checker = false;
        for(int i = 0; i < N - 1; i++) {
            if(!c[pos][v[i]]) {
                checker = true;
                break;
            }
            pos = v[i];
        }
        if(checker) continue;
        ans++;
    } while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _[2<<17]
n,i;B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){R[i]=i?s(u,T[i],p),(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[n-u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?T[i-1]=F[u],T[i]=F[v],B[F[u]=i-1]=v,B[F[v]=i++]=u:(n=u,M=v);s(1,F[1]);for(S(1,1);n--;)printf("%d ",P[n]);}

Measured memory_bytes: 12032
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine();
        var num = ToInt32(input);
        var sum = 0;
        for(var i = 0; i < input.Length; i++)
        {
            sum += ToInt32(input.Substring(i,1));
        }
        var result = num % sum==0 ? "Yes" : "No";
        WriteLine(result);
    }
}



Measured memory_bytes: 13268
#include <stdio.h>
  
int main(){
    int n,m,c;scanf("%d %d %d",&n,&m,&c);
    int b[m];for (int i=0;i<m;i++) scanf("%d",&b[i]);
    int a[n][m];
    int sum;
    int count=0;
    for(int i=0;i<n;i++){
        sum=c;
        for (int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
            sum+=a[i][j]*b[j];
        }
        if(sum>0)count++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }

  int temp = INF;
  int ans = 0;
  rep(i, N) {
    if (P[i] <= temp) {
      ans++;
      temp = P[i];
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(a);
  cout << a[0]+a[1] << endl;
}

Measured memory_bytes: 256
import copy
h, w, k = map(int, input().split())
chiz_m = [[] for _ in range(w)]
for _ in range(h):
    tmp_list = input()
    for i in range(w):
        chiz_m[i].append(tmp_list[i])
chiz = copy.deepcopy(chiz_m)
n=12
perms=[]
for i in range(2**n):
    list2 = []
    for j in range(n):
        if (i >> j) &1 == 1:
            list2.append(1)
        else:
            list2.append(0)
    perms.append(list2)

def draw(rc):
    if rc < 6:
        for i in range(w):
            chiz[i][rc] = '='
    else:
        for i in range(h):
            chiz[rc-6][i] = '='
res = 0
for perm in perms:
    for idx,x in enumerate(reversed(perm[:6])):
        if x == 1:
            break
    if 6-idx > h:
        continue
    for idx,x in enumerate(reversed(perm[-6:])):
        if x == 1:
            break
    if 6-idx > w:
        continue
    for b in range(12):
        if b < 6:
            if b < h:
                if perm[b] == 1:
                    draw(b)
            else:
                continue
        else:
            if b-6 < w:
                if perm[b] == 1:
                    draw(b)
            else:
                continue
    cnt = 0
    for i in range(w):
        for j in range(h):
            if chiz[i][j] == "#":
                cnt += 1
    #print(perm)
    #print(cnt)
    if cnt == k:
        res += 1
    chiz = copy.deepcopy(chiz_m)
print(res)

Measured memory_bytes: 72668
n = int(input());
p = input().split(" ");
ans = 0;
for i in range(1,n-1) :
	if int(p[i]) < int(p[i+1]) and int(p[i]) >= int(p[i-1]) :
		ans += 1;
	elif int(p[i]) < int(p[i-1]) and int(p[i]) >= int(p[i+1]) :
		ans += 1;
print(ans);

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

int n, m;
int s, t;
vector<vector<int>> g;
vector<int> dis;
set<pair<int, int>> used;

void dfs(int cur, int step, set<int>& to) {
	if (used.count(make_pair(cur, step))) return;
	used.emplace(cur, step);

	if (step == 0) {
		to.emplace(cur);
		return;
	}

	for (auto t : g[cur]) { dfs(t, step - 1, to); }
}

void bfs() {
	queue<int> q;
	q.emplace(s);

	dis = vector<int>(n, 1e9);
	dis[s] = 0;

	while (not q.empty()) {
		int cur = q.front();
		q.pop();
		if (cur == t) {
			cout << dis[t] << endl;
			return;
		}
		set<int> to;
		dfs(cur, 3, to);
		for (auto i : to) {
			if (dis[i] != 1e9) continue;
			dis[i] = dis[cur] + 1;
			q.emplace(i);
		}
		// cout << dis << endl;
	}
	cout << -1 << endl;
}

signed main() {
	cin >> n >> m;
	g = vector<vector<int>>(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
	}
	cin >> s >> t;
	s--;
	t--;
	bfs();
}


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

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

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

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

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

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

void Main() {
	ll N; cin >> N;
	string S; cin >> S;
	vll A(N);

	bool f = false;
	for (int i = 0; i < N; i++) {
		A[i] = S[i]-'1';
		f |= (A[i]==1);
	}

	if (f) {
		for (auto &v : A) v &= 1;
	}

	int ans = 0;
	
	for (int i = 0; i < N; i++) {
		if ((i|(N-1)) == N-1) ans ^= A[i];
	}
	
	cout << ans << endl;
}

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


Measured memory_bytes: 9244
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>


using namespace std;

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

    string S;
    int K;
    cin >> S;

    vector<string> V;

    for (int i = 0; i < S.size(); ++i) {
        for (int j = i; j < S.size(); ++j) {
            if(j - i + 1 > 5){
                break;
            }
            V.push_back(S.substr(i, j-i+1));
        }
    }

    cin >> K;
    sort(V.begin(), V.end());
    unique(V.begin(), V.end());

    cout << V[K - 1] <<endl;

    return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
#define INF 999999999

int l[250002] = {};
int r[250002] = {};
int c ;

 int s[500000];

void merge(int left,int mid,int right){

  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i = 0;i < n1;i++) l[i] = s[left + i];
  for(i = 0;i < n2;i++) r[i] = s[mid + i];

  l[n1] = INF;
  r[n2] = INF;

  i = j = 0;
  
  for(k = left;k < right;k++){
    c++;
    if(l[i] <= r[j]){
      s[k] = l[i];
      i++;
    }
    else{
      s[k] = r[j];
      j++;
    }
  }
}

void mergesort(int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}
    
int main(){
  
  int n,i,left,right;
 
  c = 0;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&s[i]);

  
  left = 0;right = n;

  mergesort(left,right);

  for(i = 0;i < n;i++){
    if(i != n - 1) printf("%d ",s[i]);
    else printf("%d\n",s[i]);
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 6624
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			String str = cin.next();
			int ans=-1;
			String s1 = str.substring(0, str.indexOf('+'));
			String s2 = str.substring(str.indexOf('+')+1, str.indexOf('='));
			String s3 = str.substring(str.indexOf('=')+1);
			for(int i = 0; i < 10; i++){
				String a1=X(s1,i);
				String a2=X(s2,i);
				String a3=X(s3,i);
				if(a1.length()!=1&&a1.charAt(0)=='0'){
					continue;
				}
				if(a2.length()!=1&&a2.charAt(0)=='0'){
					continue;
				}
				if(a3.length()!=1&&a3.charAt(0)=='0'){
					continue;
				}
				BigInteger a = new BigInteger(a1);
				BigInteger b = new BigInteger(a2);
				BigInteger c = new BigInteger(a3);
				if(a.add(b).equals(c)){
					ans=i;
					break;
				}
			}
			if(ans==-1){
				System.out.println("NA");
			}
			else{
				System.out.println(ans);
			}
		}
	}
	static String X(String str, int a){
		char[] s = new char[str.length()];
		for(int i = 0; i < s.length; i++){
			if(str.charAt(i) >= '0' && str.charAt(i) <= '9'){
				s[i]=str.charAt(i);
			}
			else{
				s[i]=(char)('0'+a);
			}
		}
		return String.valueOf(s);
	}
}

Measured memory_bytes: 12000
N = int(input())
A = list(map(int, input().split()))

X_tot = 0
A_odd = [0]
A_even = [0]
for i in range(N):
    X_tot += A[i]
    if i % 2 != 0:
        A_even.append(A_even[-1] + A[i])
    else:
        A_odd.append(A_odd[-1] + A[i])
X_tot /= 2

for i in range(1, N+1):
    if i % 2 == 0:
        print(int(X_tot - A_even[i // 2 - 1] - (A_odd[-1] - A_odd[i // 2])) * 2)
    else:
        print(int(X_tot - A_odd[(i - 1) // 2] - (A_even[-1] - A_even[(i - 1) // 2])) * 2)


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

int main(){
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    int max1=0,max2=0;
    int x,y;
    rep(i,n){
        if(max1<v[i]){
            max2=max1;
            y=x;
            max1=v[i];
            x=i;
        }
        else if(max2<v[i]){
            max2=v[i];
            y=i;
        }
    }
    rep(i,n){
        if(i==x){
            cout<<max2<<endl;
        }
        else{
            cout<<max1<<endl;
        }
    }
}

Measured memory_bytes: 3944
N = int(input())
H = list(map(int,input().split()))
gap = [1]
for _ in range(N - 1):
    gap.append(H[_ + 1] - H[_])
for _ in range(1,N):
    if gap[-_] < 0:
        gap[-_] += 1
        gap[-_ - 1] -= 1
if min(gap) >= 0:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<ll> a(N), acc(N + 1);
  FOR(i, N) cin >> a[i];
  FOR(i, N) acc[i + 1] = acc[i] + a[i];
  vector<ll> b;
  for (int i = 0; i < N; ++i)
    for (int j = i; j < N; ++j) b.push_back(acc[j + 1] - acc[i]);
  ll ans = 0;
  for (int i = 40; i >= 0; --i) {
    int cnt = 0;
    vector<ll> ok, ng;
    for (ll x : b)
      if ((x >> i) & 1LL) {
        cnt++;
        ok.push_back(x);
      }
    if (cnt >= K) {
      b = ok;
      ans |= (1LL << i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6260
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <sstream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
// ll binaryNum[64];
// void decToBinary(ll n, ll k) 
// { 
//     // binaryNum[64]={0};
//     rep(i,64){
//         binaryNum[i]=0;
//     }
//     int i = 0; 
//     while (n > 0) { 
//         binaryNum[i] = n % k; 
//         n = n / k; 
//         i++; 
//     } 
// }

void solve(){
    ll n;
    cin>>n;
    ll a1=power(10,n)%(mod);
    ll a2=((power(9,n))%mod+(power(9,n))%mod - power(8,n)%mod)%mod;
    ll ans = (a1 - a2)%(mod);
    if(ans<0){
        ans+=mod;
    }
    cout<<ans;
}


int main()
{

    // cout<<1<<endl;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> height(n);
    for (int i = 0; i < n; i++) cin >> height[i];

    int dp[n];
    fill(dp, dp + n, 0);

    int result = 0;
    for (int i = n - 2; i >= 0; i--) {
        if (height[i] >= height[i + 1]) {
            dp[i] = dp[i + 1] + 1;
            result = max(result, dp[i]);
        } else {
            dp[i] = 0;
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int dp[100010];

int main(void) {
	int n, j = 1;
	cin >> n;
	dp[0] = 0;
	for (int i = 1;i <= 100009;i++)dp[i] = INF;
	for (int i = 1;i <= n;i++) {
		dp[i] = i;
		j = 1;
		while (i - j >= 0) {
			dp[i] = min(dp[i], dp[i - j] + 1);
			j *= 6;
		}
		j = 1;
		while (i - j >= 0) {
			dp[i] = min(dp[i], dp[i - j] + 1);
			j *= 9;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c: u32 = read();

    if (a - b) > c {
        println!("0");
    } else {
        println!("{}", c - (a - b));
    }
}


Measured memory_bytes: 4352
fn solve(s: String) -> bool{
    let n = s.len();

    let s = s.chars().collect::<Vec<char>>();

    for i in 0..n {
        if i % 2 == 0 && s[i] == 'L' {
            return false;
        }
        if i % 2 == 1 && s[i] == 'R'{
            return false;
        }
    }

    return true;
}


fn main(){
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.pop();


    let ans = solve(s);
    match ans {
        true => println!("Yes"),
        false => println!("No")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

bool time_check(int N,ll K, vector<ll> A, vector<ll> F, ll T){
    ll needs = 0;
    rep(i,N){
        ll cost = T/F[i];
        needs += max(A[N-1-i]-cost,0ll);
    }
    if(needs <= K) return true;
    else return false; 
}

void solve(int N,ll K,vector<ll>A,vector<ll> F,ll start,ll end){
    // start : impossible, end : possible
    if(end == start + 1){
        cout<<end<<endl;
        return ;
    }
    ll t = (end+start)/2;
    if(time_check(N,K,A,F,t)) solve(N,K,A,F,start,t);
    else solve(N,K,A,F,t,end);
}

int main(){
    int N;
    ll K;
    vector<ll>A,F;
    ll a,f;
    cin>>N>>K;
    ll sum = 0;
    rep(i,N){
        cin>>a;
        A.push_back(a);
        sum+=a;
    }
    if(sum<=K){
        cout<<0<<endl;
        return 0;
    }
    rep(i,N) {
        cin>>f;
        F.push_back(f);
    }
    sort(A.begin(),A.end());
    sort(F.begin(),F.end());
    // rep(i,N) cout<<A[i]<<" ";
    // cout<<endl;
    // rep(i,N) cout<<F[i]<<" ";
    // cout<<endl;
    solve(N,K,A,F,0ll,(ll)10000000000000);
    return 0;
}

Measured memory_bytes: 144008
import sys
input = sys.stdin.readline

def main():
  n, m, p = map(int, input().split())
  edge = []
  for _ in range(m):
    a, b, c = map(int, input().split())
    edge.append((a, b, p-c))
  dist = [float("inf")]*(n+1)
  dist[1] = 0
  for i in range(n):
    for a, b, c in edge:
      if dist[b] > dist[a] + c:
        dist[b] = dist[a] + c
  ans = min(dist[n], 0)
  for i in range(n):
    for a, b, c in edge:
      if dist[b] != -float("inf") and dist[b] > dist[a] + c:
        dist[b] = -float("inf")
  if dist[n] == -float("inf"):
    ans = 1
  print(-ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 75288
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

const int MAX=1e6;
vector<pll>g[MAX];
bool vis[MAX];
int ans[MAX];
void dfs(pll u){
    vis[u.ft]=true;
    for(auto &x:g[u.ft]){
        if(!vis[x.ft]){
            if(x.sd%2==0){
                ans[x.ft]=ans[u.ft];
            }else{
                ans[x.ft]=!ans[u.ft];
            }
          dfs(x);
        }
    }
}
int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif
int r,d,x;
cin>>r>>d>>x;
forn(i,0,10){
    x=x*r-d;
    cout<<x<<endl;
}
}


Measured memory_bytes: 27040
#include<stdio.h>

int main(){
int j, n, t, R[200000], max, min;
scanf("%d", &n);
for (t=0;t<n;t++){
  scanf("%d", &R[t]);
 }

min=R[0];
max=R[1]-R[0];

for(j=1;j<n;j++){
  if(max < R[j]-min){
    max = R[j] - min;
  }
  else if(max > R[j]-min){
    max = max;
  }
  if(min > R[j]){
    min = R[j];
  }
  else if(min < R[j]){
    min = min;
  }
 }

printf("%d\n", max);

return 0;
}

Measured memory_bytes: 1376
import java.util.*;
public class Main {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		if(s.contains("7"))
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35604
;; B - Digits

(let ((n (read))
      (k (read)))
  ; nをk進数で表したときの桁数
  ; (log n k) は n がfloatで正確に表せないと不正確
  (princ (loop for i from 1 to 31
               while (<= (expt k i) n)
               finally (return i))))


Measured memory_bytes: 3560
//The_one_Solver
#include<bits/stdc++.h>
using namespace std;
long long n,arr[1000001],war[1000001],c;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        war[i]+=abs(arr[i]-arr[i-1]);
        c+=war[i];

        if(i!=1)
        {
            war[i-1]+=abs(arr[i]-arr[i-1]);

        }
        if(i==n)
        {
          c+=abs(arr[i]-arr[i+1]);
          war[i]+=abs(arr[i]-arr[i+1]);

        }
    }

    for(int i=1;i<=n;i++)
    {
        if(i==1)
        {
            cout<<(c-war[i])+abs(arr[0]-arr[2])<<endl;
        }
       else if(i==n)
        {
            cout<<(c-war[i])+abs(arr[i-1])<<endl;
        }
        else
        {
            cout<<(c-war[i])+abs(arr[i-1]-arr[i+1])<<endl;
        }

    }

   
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<ll>
#define pb push_back
using namespace std;
const ll mod = 998244353;
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	vector<vi> dp(c+1, vi(d+1));
	dp[a][b] = 1;
	for(int i=a; i<=c; ++i) {
		for(int j=b; j<=d; ++j) {
			dp[i][j] += dp[i-1][j] * (ll)j % mod;
			dp[i][j] %= mod;
			dp[i][j] += dp[i][j-1] * (ll)i  % mod;
			dp[i][j] %= mod;
			dp[i][j] -= dp[i-1][j-1] * (i-1) * (j-1) % mod;
			dp[i][j] += mod;
			dp[i][j] %= mod;
		}
	}
	cout<<dp[c][d];
}


Measured memory_bytes: 73616
#
# 10d
#
import math


def main():
    n = int(input())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    d1 = 0
    d2 = 0
    d3 = 0
    dn = 0
    for i in range(n):
        d1 += abs(x[i] - y[i])
        d2 += (x[i] - y[i])**2
        d3 += abs(x[i] - y[i])**3
        dn = max(dn, abs(x[i] - y[i]))

    d2 = math.sqrt(d2)
    d3 = math.pow(d3, 1/3)
    print(f"{d1:.5f}")
    print(f"{d2:.5f}")
    print(f"{d3:.5f}")
    print(f"{dn:.5f}")


if __name__ == '__main__':
    main()


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

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (int)
N = list(input().rstrip())

if N[-1] in ("2", "4", "5", "7", "9"):
    print("hon")
elif N[-1] in "3":
    print("bon")
else:
    print("pon")


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	string s;
	ll d;
	cin>>s>>d;

	ll n=s.size();
	vec<vvec<ll>> dp(d, vvec<ll>(n + 1, vec<ll>(2, 0)));
	dp[0][0][tight] = 1;
	
	REP(i, n) {
		ll num = s[i] - '0';
		ll ni = i + 1;
		REP(t, 2) {
			REP(j, 10) {
				if (t == tight && num < j) break;
				ll nt = ((t == tight) && (j == num))?tight:loose;
				REP(l,d){
					(dp[(l+j)%d][ni][nt] += dp[l][i][t])%=MOD;
				}
			}
		}
	}

	cout<<(dp[0][n][loose] + dp[0][n][tight] + MOD - 1)%MOD<<en;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 55680