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

bool check(int n) {
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (n%i == 0) cnt++;
  }
  if (cnt == 8) return true;
  else return false;
}

int main() {
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (check(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
const int dg5 = 1e5;
int dp[dg5 + 1];

void solve()
{
    int N;
    cin >> N;
    vector<int> h(N);
    int K;
    cin >> K;
    REP0(i, N)
    {
        cin >> h[i];

        if (i == 0)
            continue;
        else if (i == 1)
            dp[1] = abs(h[0] - h[1]);
        else
            dp[i] = INTINF;
        for (int j = 1; j <= K and 0 <= i - j; j++)
        {
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
        }
    }
    cout << dp[N - 1] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"io"
	"os"
)

const Mod = 1000000007

func main() {
	r := NewScannerSize(os.Stdin, 1024)
	h, w := r.Int(), r.Int()

	grid := make([]string, h)
	for i := 0; i < h; i++ {
		grid[i] = r.Text()
	}

	var dp [1001][1001]int
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i][j] != '.' {
				continue
			}
			if i == 0 && j == 0 {
				dp[i][j] = 1
				continue
			}
			if i == 0 {
				dp[i][j] = dp[i][j-1]
				continue
			}
			if j == 0 {
				dp[i][j] = dp[i-1][j]
				continue
			}

			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % Mod
		}
	}

	fmt.Println(dp[h-1][w-1])
}

// generated by https://github.com/murosan/gollect

type Scanner struct {
	r     io.Reader
	buf   []byte
	delim byte
	size, eof,
	start, end int
}

func NewScannerSize(r io.Reader, size int) *Scanner {
	return &Scanner{
		r:     r,
		buf:   make([]byte, size),
		delim: ' ',
		size:  size, start: size, end: size,
	}
}

func (s *Scanner) Text() string { return string(s.bytes()) }

func (s *Scanner) Int() int { return ParseInt(s.bytes()) }

func (s *Scanner) bytes() []byte { b, _ := s.next(); return b }
func (s *Scanner) next() (b []byte, size int) {
	for n := 0; ; {
		for i := s.end; i < s.size; i++ {
			if s.buf[i] == s.delim || s.buf[i] == '\n' || i == s.eof {
				b, size = s.buf[s.start:i], i-s.start
				s.start, s.end = i+1, i+1
				return
			}
		}
		s.end = s.size
		if n++; n == 2 {
			panic("lack of buffer size")
		}
		s.read()
	}
}
func (s *Scanner) read() {
	copy(s.buf, s.buf[s.start:s.end])
	s.end -= s.start
	s.start = 0
	n, _ := s.r.Read(s.buf[s.end:])
	s.eof = s.end + n
}

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}


Measured memory_bytes: 9472
from collections import Counter


N = int(input())

str_list = []

ctr_list = Counter()

for i in range(N):
    ctr_list[input()] += 1

sort_list = []
max_value = 0
for each_str in ctr_list.most_common():
    if max_value <= each_str[1]:
        max_value = each_str[1]
        sort_list.append(each_str[0])

for each_str in sorted(sort_list):
    print(each_str)

Measured memory_bytes: 117920
#include<bits/stdc++.h>
using namespace std;
long long n,m,u,v,a[100001],b[100001],c[100001],s[100001],f[100001],sr[100001],d[100001];
vector<long long>x[100001],y[100001];
bool bo[100001];
inline long long read()
{
    long long sum=0,x=1;
    char ch=getchar();
    while (ch<'0'||ch>'9')
	{
        if (ch=='-')
          x=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9')
	{
        sum=sum*10+ch-'0';
        ch=getchar();
    }
    return sum*x;
}
inline void write(long long x)    
{
    if (x<0)
    {
    	putchar('-');
    	x=-x;
	}
	if (x>9)
      write(x/10);
    putchar(x%10+'0');
}
inline bool cmp(long long x,long long y)
{
	return c[x]<c[y];
}
inline long long find(long long x)
{
	if (x==f[x])
	  return x;
	return f[x]=find(f[x]);
}
inline void dfs(long long u)
{
	s[u]=b[u];
	sr[u]=1e18;
	for (register long long i=0;i<y[u].size();++i)
	{
		dfs(y[u][i]);
		s[u]+=s[y[u][i]];
	}
	for (register long long i=0;i<y[u].size();++i)
	  sr[u]=min(sr[u],s[u]-s[y[u][i]]+max(c[u],sr[y[u][i]]));
	if (sr[u]==1e18)
	  sr[u]=b[u]+c[u];
}
int main()
{
	n=read();m=read();
	for (register long long i=1;i<=n;++i)
	{
		a[i]=read();b[i]=read();
		if (a[i]-b[i]>0)
		  c[i]=a[i]-b[i];
		d[i]=f[i]=i;
	}
	sort(d+1,d+1+n,cmp);
	for (register long long i=1;i<=m;++i)
	{
		u=read();v=read();
		x[u].push_back(v);
		x[v].push_back(u);
	}
	for (register long long i=1;i<=n;++i)
	{
		long long u=d[i];
		for (register long long j=0;j<x[u].size();++j)
		{
			long long v=x[u][j],vv=find(v);
			if (bo[v]&&vv!=u)
			{
				y[u].push_back(vv);
				f[vv]=u;
			}
		}
		bo[u]=1;
	}
	dfs(d[n]);
	write(sr[d[n]]);
	return 0;
}

Measured memory_bytes: 23860
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

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

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("out.out","w",stdout);
#define RE cout<<233<<endl;
#define Tone(x) cout<<x<<endl;
#define Tall(x,n) for(int i=0;i<n;i++)cout<<x[i]<<(i==n-1?"\n":" ");
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n;
int a[111111];
ll sum[111111];

int I_Love_Hashimoto_Kanna() {
  fastio;
  cin>>n;
	a[0]=0;
	FOR(i,1,n+1)cin>>a[i];
	a[n+1]=0;
	sum[0]=0;
	ll tot=0;
	FOR(i,1,n+2)sum[i]=sum[i-1]+abs(a[i]-a[i-1]),tot+=abs(a[i]-a[i-1]);
	FOR(i,1,n+1){
		cout<<sum[i-1]+abs(a[i-1]-a[i+1])+(tot-sum[i+1])<<endl;
	}
  
  return 0;
}


Measured memory_bytes: 2432
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <iomanip>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
//#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    string S;cin >> S;
    if(S.back() != 's'){
         cout << S+"s" << endl;
    }
    else{
        cout << S+"es" << endl;
    }
}


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

int hs(int n){
  int tmp=0;
  while(n>0){
    tmp+=n%10;
    n/=10;
  }
  return tmp;
}

int main()
{
  int n ;  
  cin >> n;
  int a = hs(n);
  if(n%a==0)
    cout << "Yes" << "\n";    
  else
    cout << "No" << "\n";        
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll c1,c5,c10,c50,c100,c500;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
  ll ans = 0;
  ans += c500*500 + c100*100 + c50 * 50 + c10 * 10 + c5 * 5 + c1;
  cout << (ans >= 1000) << endl;
  return 0;
}

Measured memory_bytes: 3140
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	index := make([][]int, 26)
	n := len(s)
	for i := 0; i < n; i++ {
		j := int(s[i] - 'a')
		index[j] = append(index[j], i)
	}
	odd := 0
	for i := 0; i < 26; i++ {
		if len(index[i])&1 == 1 {
			odd++
		}
	}
	if odd > 1 {
		fmt.Fprintln(writer, -1)
		return
	}
	pairs := make([]int, n)
	for i := 0; i < 26; i++ {
		l := 0
		r := len(index[i]) - 1
		for l <= r {
			pairs[index[i][l]] = index[i][r]
			pairs[index[i][r]] = index[i][l]
			l++
			r--
		}
	}
	replace := make([]int, n)
	r := 0
	for i := 0; i < n; i++ {
		if pairs[i] < i {
			continue
		}
		if pairs[i] == i {
			replace[n/2] = i
			continue
		}
		replace[r] = i
		replace[n-1-r] = pairs[i]
		r++
	}
	seg := newSegment(n)
	var ans int
	for i := 0; i < n; i++ {
		seg.update(i, 1, seg.add)
	}
	for i := 0; i < n; i++ {
		ans += seg.query(0, replace[i], 0, seg.add)
		seg.update(replace[i], 0, seg.add)
	}
	fmt.Fprintln(writer, ans)
}

type segment [][]int

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]int, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]int, 1))
	return seg
}
func (seg segment) update(i int, v int, f func(x, y int) int) {
	seg[0][i] = v
	for h := 1; h < len(seg); h++ {
		i >>= 1
		if i<<1+1 < len(seg[h-1]) {
			seg[h][i] = f(seg[h-1][i<<1], seg[h-1][i<<1+1])
		} else {
			seg[h][i] = seg[h-1][i<<1]
		}
	}
}
func (seg segment) query(l, r int, s int, f func(x, y int) int) int {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			s = f(s, seg[h][l])
			l++
		}
		l >>= 1
		if r&1 == 1 {
			s = f(s, seg[h][r-1])
		}
		r >>= 1
	}
	return s
}
func (seg segment) add(x, y int) int {
	return x + y
}


Measured memory_bytes: 11216
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;

namespace msolutions2020
{
    class SolverA
    {
        static void Main()
        {
            Solve();
        }

        public static void Solve()
        {
            var grade = 0;
            var x = int.Parse(ReadLine());
            if(x <= 599) grade = 8;
            else if(x <= 799) grade = 7;
            else if(x <= 999) grade = 6;
            else if(x <= 1199) grade = 5;
            else if(x <= 1399) grade = 4;
            else if(x <= 1599) grade = 3;
            else if(x <= 1799) grade = 2;
            else grade = 1;
            WriteLine(grade);
        }
    }
}


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

int main() {
    int n; cin >> n;
    if(n == 1) cout << "Hello World" << endl;
    else{
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

int main() {
  int n;
  string s;
  while(cin >>n >>s && n){
    int ans = -1;
    bool reject = false;
    vector<string> v;
    
    int lim = (1 << ((int)(s.length()) - 1));
    for(int cut = 0; cut < lim; ++cut){
      int last = 0;
      vector<string> tmp;
      for(int mask = 1, i = 0; mask < lim && i < (int)(s.length()); mask = (mask << 1), ++i){
        if((cut & mask) != 0){
          tmp.push_back(s.substr(last, i + 1 - last));
          last = i + 1;
        }
      }
      if(last != (int)(s.length())) tmp.push_back(s.substr(last, (int)(s.length()) - last));
      int sum = 0;
      REP(i, tmp.size()) sum += (atoi(tmp[i].c_str()));

      if(sum > n) continue;

      //debug
      //cout <<"=============" <<endl;
      //cout <<cut <<endl;
      //cout <<sum <<endl;
      //REP(i, tmp.size()) cout <<tmp[i] <<", ";
      //cout <<endl;

      if(sum > ans){
        ans = sum;
        reject = false;
        v = tmp;
      } else if(sum == ans){
        reject = true;
      }
    }

    if(ans == -1) cout <<"error" <<endl;
    else if(reject) cout <<"rejected" <<endl;
    else{
      cout <<ans;
      REP(i, v.size()) cout <<" " <<v[i];
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(void)
{
  char S[4], T[4];
  int i, count=0;

  scanf("%s",S);
  scanf("%s",T);

  for(i=0;i<3;i++){
    if(S[i]==T[i])count++;
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll d[100][100];

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

    // input
    ll N, M;
    cin >> N >> M;

    VI A(M);
    VI B(M);
    VI C(M);

    rep(i, N){
      rep(j, N){
        if(i!=j) d[i][j] = inf;
      }
    }

    rep(i, M){
      ll a, b, c;
      cin >> a >> b >> c;
      a--; b--;
      A[i] = a;
      B[i] = b;
      C[i] = c;

      d[a][b] = c;
      d[b][a] = c;
    }

    FOR(i, 0, N){ // 経由点
        FOR(j, 0, N){ // 始点
            FOR(k, 0, N){ // 終点
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    ll cnt = 0;
    rep(i, M){
      ll a = A[i];
      ll b = B[i];
      ll c = C[i];

      if(d[a][b]!=c){
        cnt++;
      }
    }

    p(cnt);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,m;
    cin >> n >> m;
    vi a(m), b(m);
    rep(i,m) cin >> a.at(i) >> b.at(i);
    UnionFind uf(n);
    rep(i,m){
        uf.unite(a.at(i), b.at(i));
    }
    vi fl(200007);
    rep(i,n){
        fl.at(uf.root(i))++;
    }
    ll res = 0;
    rep(i,n) res = std::max(res, fl.at(i));
    cout << res << endl;
}

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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N, K;
    cin >> N >> K;
    int h;
    int ans = 0;
    lpn(i, N)
    {
        cin >> h;
        if (h >= K) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a,b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if (op == '+') printf("%d\n",a+b);
        else if (op == '-') printf("%d\n",a-b);
        else if (op == '*') printf("%d\n",a*b);
        else if (op == '/') printf("%d\n",a/b);
        else if (op == '%') printf("%d\n",a%b);
        else break;
    }
}


Measured memory_bytes: 3212
#define ABC122_A
#ifdef ABC122_A
// ABC122-A 

#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int N, Q;
string S;
vi L, R;

int main() {
    cin >> N >> Q >> S;
    L.resize(Q); R.resize(Q);
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        L[i] = l;
        R[i] = r;
    }

    vi cnt;
    cnt.resize(N);
    rep(i, 1, N) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            cnt[i] = cnt[i - 1] + 1;
        }
        else {
            cnt[i] = cnt[i - 1];
        }
    }

    rep(i, Q) {
        int ans = cnt[R[i]] - cnt[L[i]];

        if (S[L[i]] == 'C') {
            //ans--;
        }

        write(ans);
    }
}

#endif

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

namespace _075c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] s = new int[N];
            
            for(int i = 0; i < N;i++){
                s[i] = int.Parse(Console.ReadLine());
            }
            int ans = 0;
            Array.Sort(s);
            int j = 0;
            if(s.Sum()%10!=0){
                ans = s.Sum();
            }else{
                while(j < N){
                    if(s[j]%10==0){
                        j++;
                        continue;
                    }else{
                        s[j] = 0;
                        ans = s.Sum();
                        break;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
class Proram
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[][] adj = new int[n][];
        for (int i = 0; i < n; i++)
        {
            adj[i] = new int[n];
            int[] adjs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            for (int j = 2; j < adjs.Length; j++)
                adj[i][adjs[j] - 1] = 1;
        }
        for (int i = 0; i < n; i++)
        {
            Console.Write(adj[i][0]);
            for (int j = 1; j < n; j++)
                Console.Write(" " + adj[i][j].ToString());
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 10000
#include<bits/stdc++.h>
int  main()
{
    char s[200];
    scanf("%s", s);

    int len = 0;
    for(int i=0;s[i] !=0 ; i++)
    len++;
    int cnt =0;
    for(int i=0,j=len-1; i<=j ;i++,j--)
    if(s[i] != s[j])
    {
       cnt++;
    }
    printf("%d",cnt);

    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head
int n, q;
const int nax = 5e5 + 5;
vector<int> t[4 * nax];
void mergeArr(vector<int>& a, vector<int>& b, vector<int>& c) {
    int i = 0;
    int j = 0;
    int n = sz(b);
    int m = sz(c);
    while(i < n || j < m) {
        if(i < n && j < m) {
            if(b[i] < c[j]) {
                a.pb(b[i]);
                i++;
            } else {
                a.pb(c[j]);
                j++;
            }
        } else if(i < n) {
            a.pb(b[i]);
            i++;
        } else {
            a.pb(c[j]);
            j++;
        }
    }
}
void build(vector<int>& a, int v, int tl, int tr) {
    if(tl == tr) {
        t[v] = vector<int>(1,a[tl]);
    } else {
        int tm = (tl + tr) / 2;
        build(a, v * 2, tl, tm);
        build(a, v * 2 + 1, tm + 1, tr);
        mergeArr(t[v], t[v * 2], t[v * 2 + 1]);
    }
}

int qry(int l, int r, int rightBound, int v = 1, int tl = 0, int tr = n - 1) {
    if(l > r) {
        return 0;
    } else if(tl == l && tr == r) {
        auto x = upper_bound(all(t[v]), rightBound);
        if(x == t[v].end()) return 0;
        else return sz(t[v]) - (x - t[v].begin());
    } else {
        int tm = (tl + tr) / 2;
        return qry(l, min(tm, r), rightBound, v * 2, tl, tm) + qry(max(l, tm + 1), r, rightBound, v * 2 + 1, tm + 1, tr);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> q;
    vector<int> a(n);
    vector<int> nxt(n);
    vector<int> occ(n + 1, - 1);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = n - 1; i >= 0; i--) {
        if(occ[a[i]] == -1) {
            nxt[i] = n;
        } else {
            nxt[i] = occ[a[i]];
        }
        occ[a[i]] = i;
    }
    build(nxt,1,0,n-1);
    rep(i,0,q) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << qry(l, r, r) << endl;
    }
    return 0;
}


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

int main()
{
	int a, b, n;
	int g = 0;

	cin >> a >> b >> n;

	for (int i = 0; i < n; i++) {
		int s, f;
		cin >> s >> f;
		if (!(s >= b || f <= a))
			g = 1;
	}

	cout << g << endl;
	
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef pair<int64_t,int64_t> pii;

const int64_t INF = 1e16;
struct edge{ int64_t to, d; };

 
int main(){ 
  int64_t V, E, r;
  cin >> V >> E >> r;

  vector<vector<edge>> G(100010);
  for(int i=0; i<E; i++){
    int64_t s, t, d; cin >> s >> t >> d;
    G[s].push_back(edge{t,d});
  }

  priority_queue<pii, vector<pii>, greater<pii>> Q;
  vector<int64_t> dist(100010, INF);
  dist[r] = 0; Q.push(pii(0,r));

  while(!Q.empty()){
    int64_t cur_d = Q.top().first;
    int64_t cur_v = Q.top().second;
    Q.pop();

    if(cur_d > dist[cur_v]) continue;
  
    for(int i=0; i<G[cur_v].size(); i++){
      edge e = G[cur_v][i];
      if(dist[e.to] > dist[cur_v] + e.d){
        dist[e.to] = dist[cur_v] + e.d;
       Q.push(pii(cur_d + e.d, e.to));
      }
    }

  }

  for(int i=0; i<V; i++){
    if(dist[i] == INF) cout << "INF" << endl;
    else cout << dist[i] << endl;
  }
  
}


Measured memory_bytes: 19420
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int cnt = 0, ans = 0;
for (int i = 0; i < (int)s.size(); ++i) {
if (s[i] == 'S') ++cnt;
else {
if (cnt) --cnt;
else ++ans;
}
}
ans += cnt;
cout << ans << "\n";
return 0;
}

Measured memory_bytes: 644
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static int maxAB = 100;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt(), Ma = in.nextInt(), Mb = in.nextInt();

			int[] a = new int[N], b = new int[N], c = new int[N];
			for (int i = 0; i < N; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
				c[i] = in.nextInt();
			}

			int[][][] dp = new int[N+1][maxAB+1][maxAB+1];
			for (int i = 0; i <= N; i++) {
				for (int j = 0; j <= maxAB; j++) {
					for (int k = 0; k <= maxAB; k++) {
						dp[i][j][k] = INF;
					}
				}
			}
			dp[0][0][0] = 0;

			for (int i = 0; i < N; i++) {
				for (int j = 0; j <= maxAB; j++) {
					for (int k = 0; k <= maxAB; k++) {
						if (j-a[i]>=0 && k-b[i]>=0) {
							dp[i+1][j][k] = min(dp[i][j-a[i]][k-b[i]] + c[i], dp[i][j][k]);
						} else {
							dp[i+1][j][k] = dp[i][j][k];
						}
					}
				}
			}

			int ans = INF;
			for (int j = 1; j <= maxAB; j++) {
				for (int k = 1; k <= maxAB; k++) {
					if (j*Mb==k*Ma) {
						ans = min(dp[N][j][k], ans);
					}
				}
			}

			out.println(ans == INF ? -1 : ans);



		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 24312
expression = gets.chomp.split(" ")

stack = []

expression.each do |elem|
  case elem
  when '+'
    a = stack.pop
    b = stack.pop
    stack.push(b + a)
  when '-'
    a = stack.pop
    b = stack.pop
    stack.push(b - a)
  when '*'
    a = stack.pop
    b = stack.pop
    stack.push(b * a)
  when '/'
    a = stack.pop
    break if a == 0

    b = stack.pop
    stack.push(b / a)
  else
    stack.push(elem.to_i)
  end
end

puts stack.pop

Measured memory_bytes: 8640
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

# define INF (int)10e9

int main()
{

    int n;cin >> n;

    int h[100];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }

    int res=0;
    while(1){
        bool s=false;
        bool e=false;
        for(int i=0;i<n;i++){
            if(h[i]>0){
                e=true;
            }

            if(h[i]>0){
               if(!s){
                res++;
                s=true;
               }
               h[i]--;
            } else {
                s=false;
            }
        }
        if(!e) break;
    }
    p(res)
}

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

int main(){
    int x,i,j,k=0,ans,max=0,a[500];
    scanf("%d",&x);
    for(i=1;i<=31;i++){
        for(j=2;j<=10;j++){
            ans=pow((double)i,(double)j);
            if(ans<=x){
                a[k]=ans;
                k++;
            }
        }
    }
    for(i=0;i<k;i++){
        if(max<a[i]){
            max=a[i];
        }
    }
    printf("%d\n",max);
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll MOD = 1e9 + 7;

int n, k;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	vector<ll> neg, pos;
	for (int i = 0; i < n; ++i) {
		ll a; cin >> a;
		if (a <= 0) neg.push_back(a);
		else pos.push_back(a);
	}
	
	ll ans = 1;
	// If you can't make pos number, is this all the cases?
	if ((k == n && sz(neg) % 2) || (k % 2 && !sz(pos))){
		sort(all(pos));
		sort(all(neg), greater<ll>());
		
		if (!sz(pos)) {
			for (int i = 0; i < k; ++i) {
				ans = ans * neg[i] % MOD;
			}
		} else {
			for (int i = 0; i < sz(pos); ++i) {
				ans = ans * pos[i] % MOD;
			}
			for (int i = 0; i < sz(neg); ++i) {
				ans = ans * neg[i] % MOD;
			}
		}
		if (ans < 0) ans += MOD;	
	} else {
		sort(all(pos), greater<ll>());
		sort(all(neg));
		
		int ni = 0, pi = 0, taken = 0;
		while (taken < k) {
			if (taken + 2 <= k) {
				ll np = -1, pp = -1;
				if (ni + 2 <= sz(neg)) {
					np = neg[ni] * neg[ni + 1];
				}
				if (pi + 2 <= sz(pos)) {
					pp = pos[pi] * pos[pi + 1];
				}
				
				
				if (np > pp) {
					ans *= np % MOD;
					ans %= MOD;
					ni += 2;
					taken += 2;
				} else {
					ans *= pos[pi] % MOD;
					ans %= MOD;
					++pi, ++taken;
				}
			} else {
				++taken;
				ans *= pos[pi];
				ans %= MOD;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 5572
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[M],mn,ans;
int main(){
	cin>>n;
	mn=99999999;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]<mn)
		{
			ans++;
			mn=a[i];
		}
	}
	cout<<ans;
	return 0;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int mod = 2019;
const int maxn = 200000+100;
i64 pref[maxn], cnt[maxn];
string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    ms(cnt, 0);
    cin >> s;
    int len = SZ(s);
    int ten = 1, now = 0;
    for (int i = len-1; i >= 0; --i) {
        int num = int(s[i] - '0');
        now = (ten*num+now)%mod;
        pref[i] = now;
        ++cnt[now];
     //   cerr << i << ' ' << now << endl;
        ten = (ten*10)%mod;
    }
    i64 ans = 0;
    ++cnt[0];
    for (int i = 0; i < 2019; ++i) {
        if (cnt[i] >= 2) {
            //cerr << "i : " << i << ' ' << cnt[i] << endl;
            ans += cnt[i]*(cnt[i]-1)/2;
        }
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int H, W;

char a[102][102];

bool t[102], y[102];

int main() {
  cin.tie(0);cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>H>>W;
  
  rep(i, H)rep(j, W) {
  	cin>>a[i][j];
  	if(a[i][j]=='#')y[i] = t[j] = true;
  }
  
  rep(i, H) {
  	if(!y[i])continue;
  	rep(j, W) {
  		if(!t[j])continue;
  		cout<<a[i][j];
  	}
  	cout<<endl;
  }
  return 0;
}


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

const int N=1e5+1e3+7;

int vis[N],n;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		vis[x+1]++,vis[x+2]++,vis[x]++;
	}
	int mx=0;
	for(int i=0;i<=(int)(1e5+1);i++)
		mx=max(mx,vis[i]);
	cout<<mx;
}

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

int main(void){
    int x,y;
    cin >> x >> y;
    bool check = false;
    for(int i = 0;i <= x;i++){
        if(i*2+(x-i)*4 == y)check = true;
    }
    
    if(check)cout << "Yes";
    else cout << "No";
    
    
}

Measured memory_bytes: 3588
N = int(input())
R = list(map(int, input().split()))
X = [0]*8
p = 0
for r in R:
  if r >= 3200:
    p += 1
  else:
    X[r//400] = 1

s = sum(X)
if s == 0:
  print(str(1) + " " + str(p))
else:
  print(str(s) + " " + str(s + p))


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int i,j,sum1=0,sum2=0;
  //dainyu-
  for(i=0;i<N;i++){cin >> a.at(i);}
  
  for(i=0;i<N;i++){
    int max=0,s;
    for(j=0;j<N;j++){
      if(max<a.at(j)){
        max=a.at(j);
        s=j;
      }
    }
    a.at(s)=0;
    if(i%2==0){sum1+=max;}
    else{sum2+=max;}
  }
	cout<<sum1-sum2<<endl;
}


Measured memory_bytes: 256
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
p=a+b
q=b+c
r=c+a
if p>=q:
  if r>=q:
    min=q
  else:
    min=r
else:
  p<=q
  if p<=r:
    min=p
  else:
    min=r
print(min)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int num (int n, int a[]) {
  int count=0;
  
  for (int i=0; i<n-1; i++) {
	for(int j=i; j<n; j++)
      if (a[i]>a[j])
		count++;
    count *= n-i-1;
  }
  return count;
}

int main(void)
{
	int n;
	int p[8],q[8], P,Q;
	
	scanf("%d", &n);
	for (int i=0; i<n; i++){
	scanf("%d", &p[i]);
	}
	for (int i=0; i<n; i++){
	scanf("%d", &q[i]);
	}
	
	P = num(n,p); Q = num(n, q);
	
	printf("%d", abs(P-Q));
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll S;
  cin >> S;
  /*
  (x1,y1)=(0,0)に固定すると、
    S/2 = |x2*y3-y2*x3|/2
    S = |x2*y3-y2*x3|
  ここで(x2,y2)=(10^9,1)に固定すると、1≦S≦10^18の全ての整数が表せる(y2=0ではy3を小数にしないといけなくなるので駄目)
    S = 10^9*y3-x3
  y3はSが10^9以下なら1、それ以上なら2でいいので
    y3 = ceil(S/10^9)
    x3 = 10^9*y3-S
  */
  const int M = 1e9;
  int y = (S+M-1)/M;
  int x = (ll)M*y-S;
  cout << "0 0 1000000000 1 " << x << ' ' << y << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)puts("bust");
	else puts("win");

	return 0;
}


Measured memory_bytes: 256
<?php
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b


list($N)=sscanf(trim(fgets(STDIN)),"%d");
$cnt = 0;
$max = 0;

$sc = new Scanner();
for ($i=0; $i < $N; $i++) {
    $n = $sc->nextInt();
    if($n > $max){
        $max = $n;
    }else{
        $cnt += $max - $n;
    }

}
print($cnt);

Measured memory_bytes: 31916
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int x;
  cin >> x;
  int sum = 0;
  sum = sum + (x/500) * 1000;
  x = x - (x/500)*500;
  sum = sum + (x/5) * 5;
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
            res.append(n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())

def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

ll rexe[64][(ll)1e5 + 10];

int main() {
    ll N;
    cin >> N;
    V<ll> X(N);
    for(ll &e : X) cin >> e;

    V<ll> dist(N - 1);
    for(ll i = 0; i < N - 1; i++) {
        dist[i] = X[i + 1] - X[i];
        rexe[0][i] = i;
    }

    ll M, K;
    cin >> M >> K;
    for(ll i = 0; i < M; i++) {
        ll a;
        cin >> a;
        a--;
        swap(rexe[0][a - 1], rexe[0][a]);
    }

    for(ll i = 1; i < 64; i++) {
        for(ll j = 0; j < N - 1; j++) {
            rexe[i][j] = rexe[i - 1][rexe[i - 1][j]];
        }
    }

    V<ll> idxv(N - 1);
    iota(ALL(idxv), 0);
    for(ll d = 62; d >= 0; d--) {
        if(!(K & (1ll << d))) continue;
        for(ll i = 0; i < N - 1; i++) {
            idxv[i] = rexe[d][idxv[i]];
        }
    }

    ll now = X[0];
    cout << now << endl;
    for(ll i = 0; i < N - 1; i++) {
        now += dist[idxv[i]];
        cout << now << endl;
    }

    return 0;
}


Measured memory_bytes: 53632
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	 string t;
	 cin >> t;
	 string s;
	 cin >> s;
	 t += t;
	 //cout << t << endl;
	 int n = (int)t.size();
	 int m = (int)s.size();
	 for (int i = 0; i + m < n; ++i) {
		 bool d = 1;
		 int p = 0;
		 for (int j = i; j < i + m; ++j) {
			 if (s[p] != t[j]) {
				 d = 0;
			 }
			 p++;
		 }
		 if (d) {
			 cout << "Yes";
			 return 0;
		 }
	 }
	 cout << "No";
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    cin >> N;

    if(N%1000==0) cout << 0 << endl;
    else cout << 1000 - N % 1000 << endl;

    

}

Measured memory_bytes: 3636
#include<cstdio>
#include<deque>
using namespace std;
typedef long long LL;
deque <int> q;
LL n;
int i,j,k,g,l;

void solve(LL n)
{
	if (n==1)
		q.push_front(++l);
	else
		if (n&1)
			solve(n>>1),
			q.push_back(++l);
		else
			solve(n-1),
			q.push_front(++l);
}

int main()
{
	scanf("%lld",&n);
	solve(n);
	printf("%d\n",l<<1);
	for (i=0;i<l;++i) printf("%d ",q[i]);
	for (i=1;i<=l;++i) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

ll modpow(ll m, ll n, ll mod)
{
	ll res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * m % mod;
		}
		m = m * m % mod;
		n>>=1;
	}
	return res;
}

int main()
{
	ll m, n;
	cin >> m >> n;
	cout << modpow(m, n, mod) << endl;
}


Measured memory_bytes: 3100