akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n;
	cin>>n;
	int A[n];
	int ans=0,sum=0,i;
	for(i=0;i<n;i++)
	{
		cin>>A[i];
		ans+=sum*A[i];
		ans%=MOD;
		sum+=A[i];
		sum%=MOD;
	}
	cout<<ans<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


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

int main()
{
	int n, m;
	cin>> n >> m;
	int s[m][n];
	for(int i=0;i<m;i++){
		int k;
		cin>> k;
		for(int j=0;j<n;j++){
			s[i][j] = 0;
		}
		for(int l=0;l<k;l++){
			int x;
			cin>> x;
			for(int o=0;o<n;o++){
				if(x-1 == o){
					s[i][o] = 1;
				}
			}
		}
	}
	
	vector<int> q(m);
	for(int i=0;i<m;i++){
		cin>>q[i];
	}
	
	int ans = 0;
	for(int bit=0;bit<(1<<n);bit++){
		vector<int> on(n);
		for(int i=0;i<n;i++){
			if(bit & (1<<i)){
				on[i] = 1;
			}
		}
		int cnt = 0;
		for(int j=0;j<m;j++){
			int mcnt = 0;
			for(int l=0;l<n;l++){
				if(on[l] == 1&&s[j][l] == 1){
					mcnt++;
				}
			}
			if(mcnt%2==q[j]){
				cnt++;
			}
		}
		if(cnt == m){
			ans++;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize
    };
    // arr = [2, 1]; 2.upto(90){|i| arr << (arr[i-1] + arr[i-2])}; print "[", arr.join("i64, "), "i64]"
    let arr = [
        2i64,
        1i64,
        3i64,
        4i64,
        7i64,
        11i64,
        18i64,
        29i64,
        47i64,
        76i64,
        123i64,
        199i64,
        322i64,
        521i64,
        843i64,
        1364i64,
        2207i64,
        3571i64,
        5778i64,
        9349i64,
        15127i64,
        24476i64,
        39603i64,
        64079i64,
        103682i64,
        167761i64,
        271443i64,
        439204i64,
        710647i64,
        1149851i64,
        1860498i64,
        3010349i64,
        4870847i64,
        7881196i64,
        12752043i64,
        20633239i64,
        33385282i64,
        54018521i64,
        87403803i64,
        141422324i64,
        228826127i64,
        370248451i64,
        599074578i64,
        969323029i64,
        1568397607i64,
        2537720636i64,
        4106118243i64,
        6643838879i64,
        10749957122i64,
        17393796001i64,
        28143753123i64,
        45537549124i64,
        73681302247i64,
        119218851371i64,
        192900153618i64,
        312119004989i64,
        505019158607i64,
        817138163596i64,
        1322157322203i64,
        2139295485799i64,
        3461452808002i64,
        5600748293801i64,
        9062201101803i64,
        14662949395604i64,
        23725150497407i64,
        38388099893011i64,
        62113250390418i64,
        100501350283429i64,
        162614600673847i64,
        263115950957276i64,
        425730551631123i64,
        688846502588399i64,
        1114577054219522i64,
        1803423556807921i64,
        2918000611027443i64,
        4721424167835364i64,
        7639424778862807i64,
        12360848946698171i64,
        20000273725560978i64,
        32361122672259149i64,
        52361396397820127i64,
        84722519070079276i64,
        137083915467899403i64,
        221806434537978679i64,
        358890350005878082i64,
        580696784543856761i64,
        939587134549734843i64,
        1520283919093591604i64,
        2459871053643326447i64,
        3980154972736918051i64,
        6440026026380244498i64,
    ];
    println!("{}", arr[n]);
}


Measured memory_bytes: 2124
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<(a==b && b==c?"Yes":"No")<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> arr(n+1,LLONG_MAX);
    arr[0] = 0;
    ll i = 6;
    set <ll> s;
    s.insert(1);
    while (i <= n){
        s.insert(i);
        i *= 6;
    }
    i = 9;
    while (i <= n){
        s.insert(i);
        i *= 9;
    }
    for (int z=0;z<=n;z++){
        for (ll i : s){
            if (z+i > n) break;
            arr[z+i] = min(arr[z+i],arr[z]+1);
        }
    }
    cout << arr[n] << endl;
}

Measured memory_bytes: 1024
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._


  val Array(h, w, a, b) = readLine.trim.split(' ').map(_.toInt)
  val s = Array.tabulate(h){_ ⇒ readLine.trim}
  val start = (0 until h).flatMap(y ⇒ (0 until w).find(x ⇒ s(y)(x) == 's').map(x ⇒ Coordinate(x, y))).head
  val goal = (0 until h).flatMap(y ⇒ (0 until w).find(x ⇒ s(y)(x) == 'g').map(x ⇒ Coordinate(x, y))).head
  val state = s.map(_.map{
    case '#' ⇒ Wall
    case '*' ⇒ Bomb
    case _ ⇒ Road
  }.toArray)
  val minCost = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ Long.MaxValue}}
  val queue = mutable.PriorityQueue()(Ordering.by[(Long, Coordinate), Long](_._1).reverse)
  minCost(start.y)(start.x) = 0
  queue.enqueue((0L, start))
  while (queue.nonEmpty && queue.head._2 != goal){
    val (cost, current) = queue.dequeue()
    if (minCost(current.y)(current.x) == cost){
      for (n ← current.neighbor4.filter(_.contains(h, w)) if state(n.y)(n.x) != Wall){
        if (minCost(n.y)(n.x) > minCost(current.y)(current.x) + a){
          minCost(n.y)(n.x) = minCost(current.y)(current.x) + a
          queue.enqueue((minCost(n.y)(n.x), n))
        }
      }
      if (current.neighbor9.forall(c ⇒ !c.contains(h, w) || state(c.y)(c.x) != Bomb)) {
        for (n ← current.neighbor9.filter(_.contains(h, w))) {
          if (minCost(n.y)(n.x) > minCost(current.y)(current.x) + b + a * (math.abs(n.x - current.x) + math.abs(n.y - current.y))) {
            minCost(n.y)(n.x) = minCost(current.y)(current.x) + b + a * (math.abs(n.x - current.x) + math.abs(n.y - current.y))
            queue.enqueue((minCost(n.y)(n.x), n))
          }
        }
      }
    }
  }
  println(
    if (minCost(goal.y)(goal.x) == Long.MaxValue) "INF" else minCost(goal.y)(goal.x)
  )

  sealed trait State
  case object Road extends State
  case object Wall extends State
  case object Bomb extends State
  case class Coordinate(x: Int, y: Int) {
    def neighbor9 = (-1 to 1).flatMap(dx ⇒ (-1 to 1).map(dy ⇒ Coordinate(x + dx, y + dy)))
    def neighbor4 = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))
    def contains(h: Int, w: Int): Boolean = (0 until h).contains(y) && (0 until w).contains(x)
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


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

int main(){
    int n,l,add;
    cin >> n >>l;
    int MIN=10000;
    int flag=0;
    int ans=0;

    //cout <<fixed<<setprecision(16)<< << endl;

    for (int i = 1; i <= n; i++){
        ans += l+i-1;
        if(MIN > abs(l+i-1)){
            MIN = abs(l+i-1);
            add= l+i-1;
        }

    }
    ans -= add;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
#define int long long

int memo[1000001]={0};


int fib(int x){
    if(memo[x]!=0)return memo[x];
    else if(x==1)return 2;
    else if(x==2)return 1;
    memo[x]=(fib(x-1)+fib(x-2));
    return memo[x];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    char ch[4];
    cin>>ch;

    int num;
    num=atoi(ch);

    // cout<<num<<endl;

    int sen=num/1000;
    int hya=(num-1000*sen)/100;
    int zyu=(num-(1000*sen+100*hya))/10;
    int iti=num-(1000*sen+100*hya+10*zyu);


    // cout<<sen<<" "<<hya<<" "<<zyu<<" "<<iti<<endl;

    if(sen+hya+zyu+iti==7){
        cout<<sen<<"+"<<hya<<"+"<<zyu<<"+"<<iti<<"=7"<<endl;
    }else if(sen+hya+zyu-iti==7){
        cout<<sen<<"+"<<hya<<"+"<<zyu<<"-"<<iti<<"=7"<<endl;
    }else if(sen+hya-zyu+iti==7){
        cout<<sen<<"+"<<hya<<"-"<<zyu<<"+"<<iti<<"=7"<<endl;
    }else if(sen+hya-zyu-iti==7){
        cout<<sen<<"+"<<hya<<"-"<<zyu<<"-"<<iti<<"=7"<<endl;
    }else if(sen-hya+zyu+iti==7){
        cout<<sen<<"-"<<hya<<"+"<<zyu<<"+"<<iti<<"=7"<<endl;
    }else if(sen-hya+zyu-iti==7){
        cout<<sen<<"-"<<hya<<"+"<<zyu<<"-"<<iti<<"=7"<<endl;
    }else if(sen-hya-zyu+iti==7){
        cout<<sen<<"-"<<hya<<"-"<<zyu<<"+"<<iti<<"=7"<<endl;
    }else if(sen-hya-zyu-iti==7){
        cout<<sen<<"-"<<hya<<"-"<<zyu<<"-"<<iti<<"=7"<<endl;
    }
}

Measured memory_bytes: 256
import collections
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
M = []
for i in range(H):
  M.append(list(input().strip()))

queue = collections.deque()
if M[0][0] == '#':
  queue.append((0, 0, 1))
else:
  queue.append((0, 0, 0))
visited = {}
while queue:
  i, j, level = queue.popleft()
  if (i,j) in visited:
    if visited[(i,j)] <= level:
      continue
  visited[(i,j)] = level
  for ni, nj in [(i+1, j), (i, j+1)]:
    if not (ni < H and nj < W):
      continue
    if M[ni][nj] != M[i][j] and M[ni][nj] == '#':
      queue.append((ni, nj, level+1))
    else:
      queue.append((ni, nj, level))
print(visited[(H-1,W-1)])

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - ABC/ARC
            var x = int.Parse(Console.ReadLine());

            if (x < 1200)
            {
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("ARC");
            }
        }
    }
}

Measured memory_bytes: 13140
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
use whiteread::parse_line;

fn main() {
    let x: i64 = parse_line().unwrap();
    let mut num: i64 = 100;
    let mut count: usize = 0;
    loop {
        num = (num / 100) + num;
        count = count + 1;
        if num >= x {
            break;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT","SUN"};
	string t;
	cin >> t;
	for(int i = 0;i < 7;i++){
		if(s[i] == t){
			cout << 7 - i << endl;
			return 0;
		}
	}
}


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

const ll p = 998244353;

string s;
ll n, ct[26], ans;

int main() {
	cin >> s;
	n = s.length();
	ans = n*(n-1)/2;
	for (int i = 0; i < n; ++i)
		ct[s[i]-'a']++;
	for (int i = 0; i < 26; ++i)
		ans -= ct[i]*(ct[i]-1)/2;
	cout << ans+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define MAX 2000000000
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li even(vector<li>& a){
  int n=a.size();
  li m=0;
  rep(i,n/2){
    m+=a[2*i+1]; // 1,3,5,...,n-1
  }
  li temp=m;
  rep(i,n/2){
    temp+=a[2*i]-a[2*i+1];
    chmax(m,temp);
  }
  return m;
}

li odd(vector<li>& a){
  int n=a.size();
  li m=-a[0],temp=-a[0];
  rep(i,n/2){
    int j=i*2+1;
    temp+=a[j]-a[j+1];
    chmax(temp,-a[j+1]);
    chmax(m,temp);
  }
  li s=0;
  rep(i,n/2+1){
    s+=a[i*2];
  }
  return s+m;
}

int main(){
  int n; cin >>n;
  vector<li> vec(n);
  rep(i,n) cin >>vec[i];
  if(n&1) print(odd(vec));
  else print(even(vec));
}


Measured memory_bytes: 4816
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		list[i] = nextInt();
	}
	var maxList = makeClone(list);
	maxList.sort(function(a,b){
		return b - a;
	});
	var max1 = maxList[0];
	var max2 = maxList[1];
	var output = new Array(N);
	if(max1 == max2){
		output.fill(max1);
	}else{
		for(var i = 0; i < N; i++){
			if(list[i] == max1){
				output[i] = max2;
			}else{
				output[i] = max1;
			}
		}
	}
	myout(myconv(output, 9));
}


Measured memory_bytes: 65308
card_num = int(input())
all_cards = {(st, num) for st in 'SHCD' for num in range(1, 14)}
your_cards = set()

for _ in range(card_num):
    st, num = input().split()
    your_cards.add((st, int(num)))

rest = all_cards - your_cards
for st, num in sorted(rest, key=lambda c: ('SHCD'.index(c[0]), c[1])):
    print(st, num)


Measured memory_bytes: 5620
#include<cstdio>
#include<algorithm>
int main() {
	int a[3];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	std::sort(a, a + 3);
	for (int i = 0; i < 3; i++)a[i] = a[2] - a[i];
	if ((a[0] + a[1]) % 2 == 0)printf("%d", (a[0] + a[1]) / 2);
	else printf("%d", (a[0] + a[1] + 3) / 2);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=105;

int n,k,fl[N],ans;

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{	
	n=read();k=read();
	Rf(i,1,k) {
		R int m=read();
		Rf(j,1,m) {
			R int a=read();
			fl[a]=1;
		}
	}
	Rf(i,1,n) if(!fl[i]) ans++;
	write(ans);
    return 0;
}


Measured memory_bytes: 3596
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e3 + 10, inf = 1e9 + 42;

int a[N], rev[N];
map<int, int> mp;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		mp[a[i]];
	}
	int nxt = 0;
	for (auto &i : mp) {
		i.second = nxt++;
		rev[i.second] = i.first;
	}
	for (int i = 1; i <= n; ++i) {
		a[i] = mp[a[i]];
	}
	int best = inf;
	for (int sm = 0; sm < nxt; ++sm) {
		int l = sm, r = nxt - 1;
		while (l <= r) {
			int lr = (l + r) / 2;
			int ctr = 0, cur = 0, good = 0;
			for (int i = 1; i <= n; ++i) {
				if (a[i] >= sm) {
					++cur;
					if (a[i] <= lr) {
						++good;
					}
				} else {
					ctr += max(0, min(good, cur - k + 1));
					cur = 0;
					good = 0;
				}
			}
			ctr += max(0, min(good, cur - k + 1));
			if (ctr >= q) {
				r = lr - 1;
			} else {
				l = lr + 1;
			}
		}
		if (r == nxt - 1) {
			break;
		} else {
			best = min(best, rev[r + 1] - rev[sm]);
		}
	}
	cout << best;
}

Measured memory_bytes: 384
n = int(input())
h = list(map(int,input().split()))
d = [0]*n
d[0] = 0
d[1] = abs(h[1]-h[0])
for i in range(2,n):
    d[i] = min( d[i-2]+abs(h[i]-h[i-2]), d[i-1]+abs(h[i]-h[i-1]) )
print(d[-1])

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

using namespace std;

const int MAX_N = 100, INDEX = 1;
const int MAX_VAL = 100, INF = MAX_N * MAX_VAL + 1;

int n, s[MAX_N + INDEX];

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }

    int ans = accumulate(s + INDEX, s + INDEX + n, 0, plus<int>());

    if (ans % 10 == 0) {
        int minNotDivisible = INF;
        for (int i = 1; i <= n; i++) {
            if (s[i] % 10 != 0) {
                minNotDivisible = min(minNotDivisible, s[i]);
            }
        }

        ans -= minNotDivisible;

        ans = max(ans, 0);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import deque
import heapq

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    A = NLI()
    A = [a * (-1) for a in A]
    A.sort()
    C = []
    heapq.heapify(C)
    ans = 0
    for i, a in enumerate(A):
        if i == 0:
            heapq.heappush(C, a)
            continue

        ans -= heapq.heappop(C)
        heapq.heappush(C, a)
        heapq.heappush(C, a)
    print(ans)


if __name__ == "__main__":
    main()

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

const int MAX_N = 5100*5100;

//個数無制限knapsack

int dp[MAX_N]; //容量がiのもとでの最大の価値をdp[i]とおく

void chmax( int &a, int b ){ if( a < b ){ swap(a,b); } return;}

signed main(void){ 
  
  int N; cin >> N;
  vector<int> g(2),s(2),b(2);
  for(int i = 0; i < 2; i++){ cin >> g[i] >> s[i] >> b[i];}
  
  for(int i = 0; i < MAX_N; i++){ dp[i] = -1;} //未更新
  
  dp[0] = 0;
  
  for(int i = 0; i < MAX_N; i++){
    if( dp[i] != -1 ){ 
      if( g[1] > g[0] && i+g[0] < MAX_N ){ 
        chmax( dp[i+g[0]], dp[i]+(g[1]-g[0]) );
      }
      if( s[1] > s[0] && i+s[0] < MAX_N ){ 
        chmax( dp[i+s[0]], dp[i]+(s[1]-s[0]) );
      }
      if( b[1] > b[0] && i+b[0] < MAX_N ){ 
        chmax( dp[i+b[0]], dp[i]+(b[1]-b[0]) );
      }
    }// if - dp
  }//for-i
    
    int m = 0; // 一度もドングリを交換しなかった場合も含めて、N-m >= 0である
    
    for(int i = 0; i <= N; i++){ 
      chmax(m,dp[i]);
    }
    
   m += N; //これが現在のドングリの個数
   // ここがミスっていないか一度確認
   // 多分　OK
 
  //もう一度同じことをする
  
  N = m;
  
  
  for(int i = 0; i < MAX_N; i++){ dp[i] = -1;} //未更新
  
  dp[0] = 0;
  
  swap(g[0],g[1]); swap(s[0],s[1]); swap(b[0],b[1]);
  
  for(int i = 0; i < MAX_N; i++){
    if( dp[i] != -1 ){ 
      if( g[1] > g[0] && i+g[0] < MAX_N ){ 
        chmax( dp[i+g[0]], dp[i]+(g[1]-g[0]) );
      }
      if( s[1] > s[0] && i+s[0] < MAX_N ){ 
        chmax( dp[i+s[0]], dp[i]+(s[1]-s[0]) );
      }
      if( b[1] > b[0] && i+b[0] < MAX_N ){ 
        chmax( dp[i+b[0]], dp[i]+(b[1]-b[0]) );
      }
    }// if - dp
  }//for-i
  
  m = 0; 
  
  for(int i = 0; i <= N; i++){ 
    chmax(m,dp[i]);
  }
  
  m += N;
  
  N = m;
  
  cout << N << endl;
     
  
  return 0;
} 
  
    
    
    
      
  
  

Measured memory_bytes: 203520
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for(ll i = 0;i < n; i++)
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>h(n);
    int s=0;
    REP(i,n){
        cin >> h[i];
        if(h[i]>=k) s++; 
    }   
    cout << s << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N, K;
    cin >> N >> K;
    set<int> div_set;
    unordered_map<int, int> cnt_map, idx_map;
    REP(i, 1, int(sqrt(N)) + 1) {
        div_set.insert(N / i);
        div_set.insert(i);
        //cout << i << ":" << N / i << endl;
    }
    vint div_vec(div_set.begin(), div_set.end());
    sort(div_vec.begin(), div_vec.end());
    cnt_map[div_vec[0]] = 1;
    idx_map[div_vec[0]] = 1;
    REP(i, 1, div_vec.size()) {
        cnt_map[div_vec[i]] = div_vec[i] - div_vec[i - 1];
        idx_map[div_vec[i]] = i + 1;
    }
    int M = idx_map.size();
    v2ll dp(K + 1, vll(M + 1, 0));
    ll p = 1000000007;
    rep(i, M) {
        dp[1][idx_map[div_vec[i]]] = dp[1][idx_map[div_vec[i]] - 1] + cnt_map[div_vec[i]];
        dp[1][idx_map[div_vec[i]]] %= p;
    }

    REP(i, 2, K + 1) {
        rep(j, M) {
            dp[i][idx_map[div_vec[j]]] = dp[i][idx_map[div_vec[j]] - 1] + cnt_map[div_vec[j]] * dp[i - 1][idx_map[N / div_vec[j]]];
            dp[i][idx_map[div_vec[j]]] %= p;
        }
    }

    cout << dp[K][idx_map[N]] << endl;

    return 0;
}

Measured memory_bytes: 59976
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	ll A, B, C, K, p;

	cin >> A >> B >> C >> K;

	if (K <= A)
	{
		cout << K << endl;
	}
	else if (K <= (A + B))
	{
		cout << A << endl;
	}
	else 
	{
		p = K - A - B;
		cout << A - p << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1e9;
int n;
int heights[100000];
int memo[100000];

int dp(int i)
{
	if (i < 0)
		return INF;
	if (i == 0)
		return 0;
	if (memo[i] > -1)
		return memo[i];

	int cur = heights[i];
	int res1 = dp(i - 1) + abs(cur - heights[i - 1]);
	int res2 = dp(i - 2) + abs(cur - heights[i - 2]);
	int res = min(res1, res2);
	memo[i] = res;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> heights[i];
	}
	memset(memo, -1, sizeof(memo));
	cout << dp(n - 1);
}

Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
int main() 
{ 
  fastio();
ll int T;//cin>>T;
T=1;while(T--)
{
ll int n,m,i,x;double pi=3.14159265358979323846;
cin>>n;map<ll int,ll int> mp;
for(i=0;i<n-1;i++)
{cin>>x;mp[x]++;
}

  for(i=1;i<=n;i++)
    cout<<mp[i]<<endl;





}

       
    return 0; 
} 


Measured memory_bytes: 16144
#include <iostream>
#include <chrono>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int m, k;
	cin >> k >> m;
	vector<pair<int, int>> n(m);
	vector<int> mm(k, 0);
	for (int i = 0; i < m; i++) {
		cin >> n[i].first >> n[i].second;
		mm[n[i].first - 1]++;
		mm[n[i].second - 1]++;
	}

	for (auto xx : mm) cout << xx << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll dist(ll x,ll y)
{
    if(x<=0 && y<=0)
        return abs(abs(x)-abs(y));
    else if(x<=0 && y>=0)
        return abs(x)+y;
    else
        return y-x;
}
ll sum(int n,ll ARR[])
{
    ll res=0;
    for(int i=0; i<n; i++)
    {
        res+=(((ARR[i]*(i+1))%MOD)*(n-i))%MOD;
        res%=MOD;
    }
    return res;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,m;
    cin>>n>>m;
    ll x[n+5],y[m+5];
    for(int i=0; i<n; i++)
    {
        cin>>x[i];
        if(i)
            x[i-1]=dist(x[i-1],x[i]);
    }
    for(int i=0; i<m; i++)
    {
        cin>>y[i];
        if(i)
            y[i-1]=dist(y[i-1],y[i]);
    }
    cout<<(sum(n-1,x)*sum(m-1,y))%MOD<<endl;





    return 0;
}


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


int main()
{
    int a, b, c, d;
	cin >> a >> b >> c;
	
	for(int i = a; i <= b; i++)
		if (c%i < 1)
			d++;

	cout << d << endl;
	return 0;
}



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

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

    int cnt = 0;
    for(int i=0; i<=a; i++){
        int sum = 0;
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                sum = 500*i + 100*j + 50*k;
                if(sum == x) cnt++;
                if(sum > x) break;
            }
        }
    }
    cout << cnt << '\n';
}

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

int main(void){
    int N;
    cin >> N;
    set<int> s;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        if(s.count(a) == 0){
            s.insert(a);
            ans++;
        }
        else{
            s.erase(a);
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	string ans;
	for (int i = 0; i < s.size(); i++)
	{
		ans += (char)('A' + (int)((s[i] - 'A' + n) % 26));
	}
	cout << ans;
}


Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[110];

    float sum;

    cin >> n;

    sum = 0;
    REP(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    sum /= 1.0 * n;

    int b = 0;
    FOR(i, 1, n)
    {
        if (abs(sum - a[i]) < abs(sum - a[b]))
        {
            b = i;
        }
    }

    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX(a, b) ((a > b) ? (a) : (b))

int main(void){
	int N;
	int m;
	int a, b, c;
	int judge;
	int i;

	scanf("%d\n", &N);

	for(i=0; i<N; i++){
		m=0;
		scanf("%d %d %d", &a, &b, &c);

		m = MAX(MAX(a, b), c);
		if(a == m){
			judge = (a*a - b*b - c*c == 0);
		}else if(b == m){
			judge = (b*b - a*a -c*c == 0);
		}else if(c == m){
			judge = (c*c - a*a -b*b == 0);
		}

		if(judge == 1){
			puts("YES");
		}else{
			puts("NO");
		}
	}

	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

"""

9 3
8 3
4 2
2 1
ans 4

7 2
4 4
2 3
ans 8

100 6
1 1
2 3
3 9
4 27
5 81
6 243
ans 100

9999 10
540 7550
691 9680
700 9790
510 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461
ans 139815
"""; test = """
"""
import builtins
test = list(reversed(test.strip().splitlines()))
input = test.pop if test else builtins.input


import numpy as np
h, n = map(int, input().split())    
ab = np.array([tuple(map(int, input().split())) for _ in range(n)])


dp = np.zeros(h + 1, dtype="int")
for i in range(1, h+1):
    dp[i] = np.min(dp[np.maximum(i - ab[:, 0], 0)] + ab[:, 1])
    ### dp[i] = min(dp[max(i-c[0], 0)] + c[1] for c in ab) ###
print(dp[-1])







Measured memory_bytes: 14564
#include <algorithm>
#include <cstdio>
const int N=205,mo=998244353;
int pw[N],s;
struct P{
	int x,y;
	P(const int xx=0,const int yy=0):x(xx),y(yy){}
}p[N];
P operator -(P a,P b){return P(a.x-b.x,a.y-b.y);}
int operator *(P a,P b){return a.x*b.y-a.y*b.x;}
bool operator <(P a,P b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool cmp(P a,P b){return (a-p[s])*(b-p[s])<0;}
int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
	pw[0]=1;
	for (int i=1;i<=n;i++) pw[i]=pw[i-1]*2%mo;
	int ans=pw[n]-n-1;
	for (int i=1;i<=n;i++){
		s=i;
		for (int j=i+1;j<=n;j++)
			if (p[j]<p[s]) s=j;
		std::swap(p[i],p[s]);s=i;
		std::sort(p+i+1,p+n+1,cmp);
		for (int j=i+1,k=i+1;j<=n;j=k){
			for (;k<=n && (p[j]-p[i])*(p[k]-p[i])==0;k++);
			(ans-=pw[k-j]-1)%=mo;
		}
	}
	printf("%d\n",(ans+mo)%mo);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  vector<ll> v = {A, B, C, D, E};
  sort(v.begin(), v.end());
  ll ans = ceil((double)N / (double)v[0]) + 4LL;
  cout << ans << endl;
}


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

int main(){
    int N,M,r=1,t;
    cin >> N >> M;

    t = M/N+1;
    for (int i=t;1<=i;i--){
        if (M%i==0 && M/i>=N) {r=i;break;}
    }
    cout << r << endl;
    }

Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}

int A, B;
int main()
{
	cin >> A >> B;
	rep(value, 10005) {
		int a = value * 0.08, b = value * 0.1;
		if (a == A && b == B) {
			cout << value << endl;
			return 0;
		}
		
	}
	cout << -1 << endl;

	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin>>n;
  int pp;
  int p;
  int now;
  int ans = 0;
  /*
  rep(i,n){
    cout << i<<endl;
    if(i==0) cin >> pp;
    else if(i==1) cin >> p;
    else{
      cin >> now;
      cout<<pp<<p<<now<<endl;
      if((pp<p&&p<now)||(now<p&&p<pp)) count++;
      pp = p;
      p = now;
    }
    
  }
  */
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  for(int i=2;i<n;i++){
    int pp = a[i-2];
    int p  = a[i-1];
    int now= a[i];
    if( (pp<p&&p<now) || (pp>p&&p>now)) ans++;
    //cout <<i <<endl;
    //cout<<pp<<p<<now<<endl;
  }
  cout << ans <<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
//--GLOBAL------------------------------------
ll x;
ll y;
void divisors(ll n) {
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i != 0) continue;
        x=i;
        y=n/i;
    }
}

//--MAIN------------------------------------
void Main(){
    
    ll N; cin>>N;

    divisors(N);

    cout<< x+y-2 <<"\n";

}

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


Measured memory_bytes: 384
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws IOException {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int count = 1;
        while(!str.equals("0")) {
            System.out.println( "Case " + count + ": " + str );
            count++;
            str = br.readLine();
        }
    }
}

Measured memory_bytes: 31496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
 
 
const long long INF = 1e18;
 
bool f(long long x, long long y, vector<long long> &A, int n) {//越小越好
    long long s = 0;//小于x的数有几个
    for (int i = 0; i < n; i++) {
        int l = 0, r = n-1;
        if (A[i] >= 0) {
            while (l <= r) {
                int m = (l+r) / 2;
                if (A[i]*A[m] < x) l = m+1;
                else r = m-1;
            }
            s += r+1;
        } else {
           while (l <= r) {
                int m = (l+r) / 2;
                if (A[i]*A[m] < x) r = m-1;
                else l = m+1;
            }
            s += n-l;
        }
        if (A[i]*A[i] < x) s--;
    }
    s /= 2;
    return s < y;
}
 
int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    long long l = -INF-5, r = INF+5;
    while(l<= r) {
        long long m = (l+r) / 2;
        if (f(m, K, A, N)) l = m+1;
        else r = m-1;
    }
    cout << r << endl;
    return 0;
}
/* 
4 3
-4 -2 3 3
 
10 40
5 4 3 2 -1 0 0 0 0 0
 */

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n,w;
    cin>>n>>w;
    vector<pii> v(n);
    for(pii &p : v)
      cin >> p.first >> p.second;
    vector<ll> dp(w + 1);
    for(pii &p : v){
        for(int j = w; j>=p.first; j--){
            dp[j]=max(dp[j],dp[j-p.first]+p.second);
        }
    }
    cout<<dp[w]<<endl; 
}

Measured memory_bytes: 1024
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    x, y = gets.chomp.split.map(&:to_i)

    g0 = [1, 3, 5, 7, 8, 10, 12]
    g1 = [4, 6, 9, 11]
    g2 = [2]

    if g0.include?(x) && g0.include?(y) ||
        g1.include?(x) && g1.include?(y) ||
        g2.include?(x) && g2.include?(y)
      puts "Yes"
    else
      puts "No"
    end

  end
end

if __FILE__ == $0
  Solver.new.main
end


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

int main() {
  int A,B,C;
  cin>> A >> B >> C;
  bool can = false;
  if(A == 7 && B == 5 && C ==5){
    can = true;
  }
  if(A == 5 && B == 7 && C ==5){
    can = true;
  }
  if(A == 5 && B == 5 && C ==7){
    can = true;
  }
  if(can){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N], b[N];
vector<int> u;

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a+i, b+i);
    u.push_back(i);
  }
  sort(u.begin(), u.end(), [](int x, int y) {
			     return a[x]+b[x] > a[y]+b[y];
			   });
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i%2) {
      ans -= b[u[i]];
    } else {
      ans += a[u[i]];
    }
  }
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4620
#include<stdio.h>

int Max(int a,int b){
    if(a>b) return a;
    return b;
}


int main(void){
    int N=0,sum=0,max=0;
    scanf("%d",&N);
    int L[N];
    for(int i=0;i<N;i++){
        scanf("%d",&L[i]);
        sum+=L[i];
        max=Max(max,L[i]);
    }

    if(max<sum-max) printf("Yes");
    else printf("No");
    
    
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	 ll k;
	 int ans=0;
	 cin >> n >> k;
	 Vi a(n);
	 input(a);
	 VVi dis(n, Vi(70));
	 rep(i, n) { dis[i][0] = a[i] - 1; }
	 for (int i = 1; i < 70; i++) {
		 rep(j, n) { dis[j][i] = dis[dis[j][i-1]][i-1]; }
	}
	for (int cnt = 0LL; k >= (1LL << cnt); cnt++) {
		if (k & (1LL << cnt)) {
			ans = dis[ans][cnt];
		}
	}
	cout << ans +1<< endl;
}

Measured memory_bytes: 64964