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

const long double eps = 1e-9;

int A, B;

int main()
{
    cin >> A >> B;
    for (int i = 1; i <= 1000000; i++)
        if (int(i * 0.08l + eps) == A &&
            int(i * 0.1l + eps) == B) {
                printf("%d\n", i);
                return 0;
            }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,len,i=0,c=0;
    string s,n,d,f,g,h;
    cin >> s;
    reverse(s.begin(), s.end());
    n="maerd";
    d="remaerd";
    f="esare";
    g="resare";
    len=s.size();

    while(len>i)
    {
        if(s.substr(i,5)==n)
        {
             h=h+n;
             i+=5;
        }
        else if(s.substr(i,7)==d)
            {
                h=h+d;
                i+=7;
                
            }
        else if(s.substr(i,5)==f)
            {
                h=h+f;
                i+=5;
            
            }

            else if(s.substr(i,6)==g)
            {
                h=h+g;
                i+=6;
            }
            else
            {
                break;
            }
    }
    if(s==h)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    
    /*len=s.size();
    int c=0;
    if(len<5)
    {
        cout << "NO" << endl;
        return 0;
    }
        if(s.substr(i,8)=="dreamera")
        {
             n=n+d;
             i+=5;
            c++;
        }
            if(s.substr(i,6)==h && c==0)
            {
                n=n+h;
                i+=6;
                c++;
            }
        else if(s.substr(i,7)==f && c==0)
            {
                n=n+f;
                i+=7;
            c++;
            }

            else if(s.substr(i,5)==g && c==0)
            {
                n=n+g;
                i+=5;
            }
        
    while(i<=len)
    {
        if(s.substr(i,8)=="dreamera")
        {
             n=n+d;
             i+=6;
        }
        if(s.substr(i,6)==h)
            {
                n=n+h;
                i+=7;
            }
        if(s.substr(i,7)==f)
            {
                n=n+f;
                i+=8;
            }

            if(s.substr(i,5)==g)
            {
                n=n+g;
                i+=6;
            }
            if(s.substr(len-5,5)==d)
            {
                n=n+d;
                i+=6;
            }
    }
    if(s==n)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << n << endl;
    }*/     


    return 0;

}


Measured memory_bytes: 3984
while n = gets.to_i
  break if n == 0
  a = Array.new(10,0)
  for i in 1..n
    x = gets.to_i
    a[x] = a[x]+1
  end
  for i in 0..9
    if a[i] == 0 
      puts "-"
    else
      puts "*" * a[i]
    end
  end
end


Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	bool B=1;
	for(int i=0;i<n;i++) if(a[i]!=i){
		int l=i,r;
		while(i+2<n&&a[i+1]==i+1&&a[i+2]!=i+2) i+=2;
		r=i;
		if(l==r) B=0;
		vi b,c;
		for(int j=l;j<=r;j+=2){
			int A=a[j];
			if(A<j) b.push_back(A);
			if(A>j) c.push_back(A);
			if(A<l||r<A) B=0;
		}
		int N=b.size(),M=c.size();
		for(int j=1;j<N;j++) if(b[j-1]>b[j]) B=0;
		for(int j=1;j<M;j++) if(c[j-1]>c[j]) B=0;
	}
	cout<<(B?"Yes":"No")<<endl;
}

Measured memory_bytes: 2748
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let s = []
    let p = []
    let i = 0
    let r = {}
    while(hasNext()){
        i++
        let [s, p] = next().split(" ")
        if(!r[s]) r[s] = [[Number(p),i]]
        else r[s].push([Number(p), i])
    }
    let keys = Object.keys(r)
    keys.sort()
    let ans = ""
    for(let key of keys){
        let arr = r[key].sort((a,b) => b[0]-a[0])
        for(let el of arr) ans += String(el[1]) + "\n"
    }
    console.log(ans)
}
Main()


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

int main(void){
    while(true){
        int n=0, r=0, yama[55], tmp[55];
        cin >> n >> r;
        if(n==0 && r==0) break;
        for(int i=0;i<n;++i) yama[i] = n-i;
        for(int i=0;i<r;++i){
            int p, c;
            cin >> p >> c;
            for(int j=0;j<p-1;++j) tmp[j] = yama[j];
            for(int j=0;j<c;++j) yama[j] = yama[p-1+j];
            for(int j=0;j<p-1;++j) yama[c+j] = tmp[j];
        }
        cout << yama[0] << endl;
    }
}


Measured memory_bytes: 3008
n=int(input())
p=[int(i) for i in input().split()]

ans=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        ans+=1
    elif p[i+2]<p[i+1] and p[i+1]<p[i]:
        ans+=1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
//long long
long long n,ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(long long i=1;i<=n;i++)
	{
		long long xiang=(n-n%i-i)/i+1;
		long long sum=(i+n-n%i)*xiang/2;
		ans+=sum*1;
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<long long int> A(N), B(N), C(N);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    for(int n=0; n<N; n++) {
        cin >> B[n];
    }
    for(int n=0; n<N; n++) {
        cin >> C[n];
    }
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    vector<long long int> na(N), nb(N), snb(N+1, 0);
    for(int n=0; n<N; n++) {
        na[n] = upper_bound(B.begin(), B.end(), A[n]) - B.begin();
        nb[n] = C.end() - upper_bound(C.begin(), C.end(), B[n]);
        snb[n+1] = snb[n]+nb[n];
    }

    // for(int n=0; n<N; n++) {
    //     cout << A[n] << " ";
    // }
    // cout << endl;
    // for(int n=0; n<N; n++) {
    //     cout << B[n] << " ";
    // }
    // cout << endl;
    // for(int n=0; n<N; n++) {
    //     cout << C[n] << " ";
    // }
    // cout << endl;
    // cout << endl;
    
    // for(int n=0; n<N; n++) {
    //     cout << na[n] << " ";
    // }
    // cout << endl;
    // for(int n=0; n<N; n++) {
    //     cout << nb[n] << " ";
    // }
    // cout << endl;
    // for(int n=1; n<=N; n++) {
    //     cout << snb[n] << " ";
    // }
    // cout << endl;
    
    
    long long int ans=0;
    for(int n=0; n<N; n++) {
        ans += snb[snb.size()-1]-snb[na[n]];
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 4992
fun main(args: Array<String>) {
    val (a, b, q) = readLine()!!.split(" ").map { it.toInt() }
    val ss = (1..a).map { readLine()!!.toLong() }.sorted().toMutableList()
    val ts = (1..b).map { readLine()!!.toLong() }.sorted().toMutableList()
    val qs = (1..q).map { readLine()!!.toLong() }

    val inf = 1L shl 50

    ss.add(0, -inf)
    ss.add(inf)
    ts.add(0, -inf)
    ts.add(inf)

    for (q in qs) {
        var ans = Long.MAX_VALUE

        // 寺->神社のルート
        for (i in 0..1) {   // 0:東方向 1:西方向
            // 一番近い寺
            var temple = ts[if (i == 0) east(ts, q) else west(ts, q)]

            // 寺から東または西に行ったときに一番近い神社
            for (j in 0..1) {   // 0:東方向 1:西方向
                var shrine = ss[if (j == 0) east(ss, temple) else west(ss, temple)]

                val dist = Math.abs(q - temple) + Math.abs(temple - shrine)
                ans = Math.min(ans, dist)
            }
        }

        // 神社->寺のルート
        for (i in 0..1) {   // 0:東方向 1:西方向
            // 一番近い神社
            var shrine = ss[if (i == 0) east(ss, q) else west(ss, q)]

            // 神社から東または西に行ったときに一番近い寺
            for (j in 0..1) {   // 0:東方向 1:西方向
                var temple = ts[if (j == 0) east(ts, shrine) else west(ts, shrine)]

                val dist = Math.abs(q - shrine) + Math.abs(shrine - temple)
                ans = Math.min(ans, dist)
            }
        }

        println(ans)
    }
}

private fun <T: Comparable<T>> east(list: List<T>, q: T): Int {
    var i = list.binarySearch(q)
    if (i < 0) {
        i = -(i + 1)
    }

    return i
}

private fun <T: Comparable<T>> west(list: List<T>, q: T): Int {
    var i = list.binarySearch(q)
    if (i < 0) {
        i = -(i + 1)
        return i - 1
    }

    return i
}

Measured memory_bytes: 70048
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
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);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % 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 * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    long long X;cin >> X;
    for(int i = 0;i<=5000;i++){
        for(int j = -10000;j<=10000;j++){
            long long A = ((i*i)*(i*i)*i) - ((j*j)*(j*j)*j);
            if(A == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 3628
n,m,c = map(int,input().split())

x = list(map(int,input().split()))

def test(l,c,m):
    case = list(map(int,input().split()))
    k = 0
    for i in range(m):
        k += l[i]*case[i]
    if k+c>0:
        return 1
    else:
        return 0
        
cnt = 0

for i in range(n):
    cnt += test(x,c,m)
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> vec(5);
	vector<int> amari(5);
	vector<int> zyuu(5);
	int sum=0;
	for(int i=0; i<5; i++){
		cin>>vec[i];
		amari[i]=(vec[i]%10);
		if((vec[i]%10)!=0){
			zyuu[i]=vec[i]-vec[i]%10+10;
		}
		else{
			zyuu[i]=vec[i];
		}
		sum+=zyuu[i];
	}
	sort(amari.begin(), amari.end());
	for(int i=0; i<5; i++){
	    if(amari[i]!=0){
	        sum+=amari[i]-10;
	        break;
	}
	}
	cout<<sum<<endl;
}

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


int main(){
    
    int num = 0;
    cin >> num;
    string str1, str2;
    int taro=0;
    int hana=0;
    
    for(int i=0;i<num;i++){
        cin>>str1>>str2;
        if(str1==str2){
            taro++;
            hana++;
        }
        if(str1<str2){
            hana+=3;
        }
        if(str1>str2){
            taro+=3;
        }
    }
    cout<<taro<<" "<<hana<<endl;
    
   
    
  return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll N; // max <= 1e16 + 1
    cin >> N;

    ll N_temp = N;
    string ans = "";

    if (N <= 26)
    {
        ans += 'a' + (N - 1);
        cout << ans << endl;
        return (0);
    }

    vector<ll> remain;
    int num;
    while (N > 26)
    {
        num = (N - 1) / 26;
        remain.push_back(num);
        N = (N - 1) / 26;
    }
    reverse(remain.begin(), remain.end());
    //debug
    ll last = remain[remain.size() - 1];
    // for (int i = 0; i < remain.size(); i++)
    // {
    //     // remain[i]--;
    //     cout << remain[i] << " ";
    // }
    // printf("\n");
    ans += remain[0] - 1 + 'a';
    ll before = remain[0];
    ll calc;
    for (int i = 1; i < remain.size(); i++)
    {
        calc = remain[i] - (before * 26);
        if (calc == 0)
        {
            calc = 26;
        }
        ans += calc - 1 + 'a';
        before = remain[i];
    }
    ll final = N_temp - (last * 26);
    // printf("final = %lld\n", final);
    if (final != 0)
    {
        ans += final - 1 + 'a';
    }
    else
    {
        final = 26;
        ans += final - 1 + 'a';
    }

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

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

int main() {
  int N; cin >> N;
  bool ret = false;

  int c = 0;
  for (int i = 0; i < N; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {c++; if (c==3) ret = true;}
    else {c=0;}
  }

  cout << (ret ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,K = map(int,input().split())
A = [int(x) for x in input().split()]

dp = [False] * (K+K+1)
for i in range(K):
    if not dp[i]:
        for a in A:
            dp[i+a] = True

answer = 'First' if dp[K] else 'Second'
print(answer)

Measured memory_bytes: 4596
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Fri Jun  1 21:57:47 2018
//
package main

import (
	"fmt"
	"strings"
)

var s string

func isPalidrome(s string) bool {
	for i := range s {
		if s[i] != s[len(s)-1-i] {
			return false
		}
	}
	return true
}

func main() {
	fmt.Scan(&s)

	t := strings.Replace(s, "x", "", -1)
	if !isPalidrome(t) {
		fmt.Println(-1)
		return
	}
	ans := 0
	left := 0
	right := len(s) - 1
	for left < len(s) || 0 <= right {
		if left < len(s) && 0 <= right && s[left] == s[right] {
			left++
			right--
		} else if left < len(s) && s[left] == 'x' {
			ans++
			left++
		} else if 0 <= right && s[right] == 'x' {
			ans++
			right--
		}
	}

	fmt.Println(ans / 2)
}

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

int n;
int a[2][100];
int maxx = -1;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);   
        }
    }
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += a[0][j];
        }
        for (int j = i; j < n; j++) {
            sum += a[1][j];
        }
        if (sum > maxx) {
            maxx = sum;
        }
    }
    printf("%d", maxx);
    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mood 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,C,K;
	cin>>N>>C>>K;
	VI T(N);
	REP(i,N)cin>>T[i];
	SORT(T);
	int cnt=0,bus=T[0]-1,ans=0;
	REP(i,N){
		cnt++;
		if(cnt==C && i!=N-1 && T[i]-bus<=K){
			bus=T[i+1];
			cnt=0;
			ans++;
			//cout<<i<<endl;
		}
		if(T[i]-bus>K){
			bus=T[i];
			cnt=1;
			ans++;
			//cout<<i<<"K"<<endl;
		}
		
		if(i==N-1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}




















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

int main(){
  int n,i,k=1,a=0,count=0;
  int *raw;

  scanf("%d",&n);

  if(1>n || n > 100 ) exit(8);

  raw = (int *)malloc(sizeof(int)*n);

  for(i=0;i<n;i++){
    scanf("%d",raw+i);
    if(0 > raw[i] ||100 <  raw[i]) exit(8);
  }

  while(k==1){

    k = 0;
    for(i=n-1;i>=1;i--){

      if(raw[i]<raw[i-1]){
	a=raw[i];
	raw[i]=raw[i-1];
	raw[i-1]=a;
	count++;
	k = 1;
      }
    }
  }

  for(i = 0; i < n; i++){
    if(i)printf(" ");
    printf("%d",raw[i]);
  }
  printf("\n%d\n",count);
  free(raw);
  return 0;
}
  



Measured memory_bytes: 2144
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int q;
  cin >> q;
  bool prime[100005] = {false};
  prime[1] = true;
  for(int i = 2;i * i <= 100000;i ++){
    if(!prime[i]){
      for(int j = i * 2;j <= 100000;j += i){
	prime[j] = true;
      }
    }
  }
  int ans[100005] = {};
  reps(i, 100000){
    if(!prime[i] && !prime[(i + 1) / 2]){
      ans[i] ++;
    }
    ans[i + 1] += ans[i];
  }
  int l, r;
  reps(i, q){
    cin >> l >> r;
    cout << ans[r] - ans[l - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
                        
#define endl '\n'
#define int long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
 
using namespace std;
const int mod = 1e9 + 7;
int dp[10005][105][2];
string K;   
int D;
int solve(int i, int sum, int f){
    if(i > K.size())
        return 0;
    if(i == K.size() && sum % D == 0)
        return 1;
    if(i == K.size() && sum % D != 0)
        return 0;
    int &ans = dp[i][sum % D][f];
    if(ans != -1)
        return ans;
    ans = 0;
    if(f == 0){
        for(int j = 0; j < 10; j++){
            ans += solve(i + 1, (sum + j) % D, f);
            ans %= mod;
        }
    }
    else{
        for(int j = 0; j <= (K[i] - '0'); j++){
            ans += solve(i + 1, (sum + j) % D, j == (K[i] - '0'));
            ans %= mod;
        }
    }
    return ans;
}        
int32_t main()
{
    IOS  //FRE

    cin >> K >> D;
    memset(dp, -1, sizeof(dp));
    int temp = solve(0, 0, 1);
    
    cout << (temp - 1 + mod) % mod;
 
   return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    string S;
    cin >> S;
    ll c = 0;
    if(S == "RRR"){
        cout << 3 << endl;
    }
    else if(S == "RRS" || S == "SRR"){
        cout << 2 << endl;
    }
    else if(S == "RSR" || S == "RSS" || S == "SRS" || S == "SSR"){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    for (int i=0;i<=3000;i++){
        cin>>x>>y;
        if (x==0 && y==0){
            break;
        }
        else if (x>=y){
            cout<<y<<" "<<x<<endl;
        }
        else if (x<y){
            cout<<x<<" "<<y<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3096
#79 素数の数

import math

while(1):
    try:
        n = int(input())
    except:
        break
    
    m = int(math.sqrt(n))
    keys = [n // i for i in range(1, m+1)] #1からm+1の間のみn//iを行う
    keys += range(keys[-1]-1, 0, -1) #range(始まりの数値,最後の数値,増加量)
    h = {i: i-1 for i in keys}
    
    for i in range(2, m+1):
        if h [i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j // i] - hp
    print(h[n])


Measured memory_bytes: 6076
//Tanka1 pbc
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[3];
    cin>>a;
    if(a[2]!=0)
    {
        cout<<a[2]<<a[1]<<a[0]<<endl;
    }
    else
    {
        cout<<a<<endl;
    }
    return 0;
}

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

//Optimizations
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//save time
#define endl '\n'
#define db(x) cerr << "> " << #x << ": " << x << endl
typedef long long ll;

//for sorting
#define all(a) a.begin(),a.end()

//Constants
#define PI   3.141592653593
#define MOD  1000000007LL
#define EPS  0.000000001
#define INF  0X3f3f3f3f

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

//vectors
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int>>
#define vlll vector<pair<ll,ll>>
#define pb  push_back
#define vb vector<bool>

//pairs
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define F first
#define S second

//fast I/O
#ifndef _WIN32
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
#define gc getchar
#define pc putchar

//If using cin and cout
#define IOS ios::sync_with_stdio(false)
#define TIE cin.tie(NULL);cout.tie(NULL)

//queue
#define di deque<int>
#define dll deque<ll>
#define qi queue<int>
#define PQ priority_queue

//general
#define E empty()

const int MAXN=405;
vector<vll> dp(MAXN, vll(MAXN, 0));


int main(){
    int n ;cin >> n ;
    vi ar(n);
    REP(i,n)
        cin>>ar[i];
    auto cost = [&ar](int l, int r){
        ll res = 0;
        FOR(i, l, r+1){
           res+=ar[i];
        }
        return res;
    };
    for(int l = n-1; l >=0; --l){
        for(int r = l; r <  n; ++r){
            if(r == l)
                dp[l][r]=0;
            else{
                dp[l][r]=LONG_MAX;
                ll c = cost(l, r);
                for(int k = l ; k < r; ++k){
                    dp[l][r]=min(dp[l][r], dp[l][k]+dp[k+1][r]+c);
                }
                // dp[l][r] = min(dp[l][r], dp[l])
            }
        }
    }
    cout << dp[0][n-1] << endl;

}


Measured memory_bytes: 4932
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(0, N):
    ans+=B[A[i]-1]
    if i>0 and A[i]-A[i-1]==1:
        ans+=C[A[i-1]-1]
print(ans)

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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25460
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

#define MAXN 15
vector<map<int, bool>> A(MAXN);

int main() {
    int N;
    cin >> N;
    rep(i,N) {
        int j; cin >> j;
        auto&& AI = A[i];
        rep(k, j) {
            int x,y; cin >> x >> y;
            AI.insert({x-1, (y == 1)});
        }
    }

    int ma = 0; 
    for (int b = 0; b < 1 << N; b++) {
        bool ok = true;
        for (int i = 0; i < N; i++) {
            if (b & 1<<i) {
                for (auto x : A.at(i)) {
                    int k,v; k = x.first; v = x.second;
                    if ((b >> k & 1) ^ v) {
                        ok = false;
                        goto FALSE;
                    }
                }
            }
        }
FALSE:
        if (ok) ma = max(ma, __builtin_popcount(b));
    }
    cout << ma << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

bool my_compare(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.first != b.first) {
    return a.first > b.first;
  }
  if (a.second != b.second) {
    return a.second > b.second;
  } else {
    return false;
  }
}
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  vector<pair<ll, ll> > CB(M);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) {
    cin >> CB[i].second >> CB[i].first;
  }
  sort(A.begin(), A.end());
  sort(CB.begin(), CB.end(), my_compare);
  ll cur_min = A[0], cur_min_idx = 0, replace_size, replace_num;
  for (int i = 0; i < M; i++) {
    replace_size = CB[i].second;
    replace_num = CB[i].first;
    if (cur_min < replace_num) {
      ll upper =
          (cur_min_idx + replace_size < N) ? cur_min_idx + replace_size : N;
      for (int j = cur_min_idx; j < upper && A[j] < replace_num; j++) {
        A[j] = replace_num;
      }
      if (upper == N) break;
      cur_min_idx = upper;
      cur_min = A[cur_min_idx];
    } else {
      break;
    }
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
def f(t,a,n,hist):
    if t != n:
        return max(f(t+1,a,n,hist+[0]),f(t+1,a,n,hist+[1]))
    for i in range(n):
        if hist[i] == 1:
            for j in range(n):
                if a[i][j] == -1:
                    continue
                if a[i][j] != hist[j]:
                    return 0
    return hist.count(1)

n = int(input())
a = [[-1 for i in range(n)] for j in range(n)]
for i in range(n):
    an = int(input())
    for j in range(an):
        x,y = map(int,input().split())
        a[i][x-1] = y
print(f(0,a,n,[]))

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

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

    int n, m;
    cin >> n >> m;

    long long A[n][3];
    REP(i, n) REP(j, 3) cin >> A[i][j];

    long long maxi = -1e18;
    REP(i, 1 << 3){
        vector<long long> B(n);
        REP(j, n){
            long long tmp = 0;
            REP(k, 3){
                tmp += A[j][k] * ((i >> k) & 1 ? 1 : -1);
            }
            B[j] = tmp;
        }
        sort(B.begin(), B.end(), greater<long long>());
        long long tmpp = 0;
        REP(j, m) tmpp += B[j];
        maxi = max(maxi, tmpp);
    }
    cout << maxi << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        for(int i=1;i<=n;i++){
            int x=i;
            if(x%3==0){
                System.out.print(" " + i);
                continue;
            }
            do{
                if(x%10==3){
                    System.out.print(" " + i);
                    break;
                }
                x /= 10;
            } while (x>0);
        }
        System.out.println();
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)

using namespace std;
typedef long long ll;

vector<ll> ss, ts, xs;

void solve() {
  for(const ll& x : xs) {
    decltype(ss)::iterator sitr = upper_bound(ss.begin(), ss.end(), x);
    ll rs = *sitr;
    ll ls = *(--sitr);
    decltype(ts)::iterator titr = upper_bound(ts.begin(), ts.end(), x);
    ll rt = *titr;
    ll lt = *(--titr);
    ll minv = 20000000020;
    minv = min(minv, max(rs, rt)-x);
    minv = min(minv, x-min(ls, lt));
    minv = min(minv, (x-ls)+(rt-ls));
    minv = min(minv, (x-lt)+(rs-lt));
    minv = min(minv, (rs-x)+(rs-lt));
    minv = min(minv, (rt-x)+(rt-ls));
    cout << minv << endl;
  }
}

int main() {
  int A, B, Q;
  scanf("%d %d %d", &A, &B, &Q);
  ll s, t, x;
  rep(i, A) {
    scanf("%lld", &s);
    ss.push_back(s);
  }
  ss.push_back(-50000000000-1);
  ss.push_back(50000000000+1);
  sort(ss.begin(), ss.end());
  rep(i, B) {
    scanf("%lld", &t);
    ts.push_back(t);
  }
  ts.push_back(-50000000000-2);
  ts.push_back(50000000000+2);
  sort(ts.begin(), ts.end());
  rep(i, Q) {
    scanf("%lld", &x);
    xs.push_back(x);
  }
  solve();
  return 0;
}


Measured memory_bytes: 3828
a,b,c,k = (int(x) for x in input().split())
count = 0
if a >= k:
    count += k;
    k = 0
else:
    count += a
    k -= a
# print(count)
if b >= k:
    count += 0;
    k = 0
else:
    count += 0
    k -= b
# print(count)

if c >= k:
    count -= k;
    k = 0
else:
    count -= a
    k -= a
print(count)

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

int64_t mod = 1000000007;

int64_t mypow(int64_t x, int64_t y)
{
    if (y == 1)
        return x;
    else if (y % 2 == 1)
        return mypow(x, y - 1) * x % mod;
    else
    {
        int64_t tmp = mypow(x, y / 2);
        return tmp * tmp % mod;
    }
}

int64_t soujo(int64_t x, int64_t y) //x~y
{
    if (y < x)
        swap(x, y);
    if (x == y)
        return y;
    else
        return x * soujo(x + 1, y) % mod;
}

int64_t combi(int64_t x, int64_t y) //y C x,y < x
{
    int64_t X = soujo(x - y + 1, x);
    int64_t Y = soujo(1, y);
    return X * mypow(Y, mod - 2) % mod;
}

int main()
{
    int X, Y;
    cin >> X >> Y;

    if ((X + Y) % 3 != 0 || -X + 2 * Y < 0 || 2 * X - Y < 0)
        cout << 0;
    else
    {
        double p = -X / 3 + Y * 2 / 3;
        double q = 2 * X / 3 - Y / 3;
        cout << combi(p + q, max(p, q));
    }
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
	ll a;
	cin>>a;
	if(a%10 == 2 || a%10 == 4 ||a%10 == 5 ||a%10 == 7 || a%10 == 9)
	{
		cout<<"hon"<<endl;
	}
	else if(a%10 == 0 || a%10 == 1 ||a%10 == 6 ||a%10 == 8)
	{
		cout<<"pon"<<endl;
	}
	else
	{
		cout<<"bon"<<endl;
	}
	return 0;
}

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

int main(void)
{
  int n, m;
  long long sum = 0;
  cin >> n >> m;
  vector<int> a(n);
  
  for (int i=0;i<n;i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  double line = (double)sum / 4.0;
  line = line / (double)m;
  //double line = (double)(sum / (4*m));
  int cnt = 0;
  
  for (int i=0;i<n;i++){
    if ((double)a.at(i) >= line) cnt++;
  }
  
  if (cnt >= m){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;

ll i,j,k;


int main(){
   string S;
   cin>>S;
   if(S=="ABC")cout<<"ARC"<<endl;
   else cout<<"ABC"<<endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>
#include <string.h>

#define PI  3.1415
#define BUF_MAX 101    

int main(void)
{
    int     rect = 0;
    float   ans = 0.0f;
    char    buf[BUF_MAX];
    
    memset(buf, 0x00, sizeof(buf));
    
    fgets(buf, sizeof(buf), stdin);
    sscanf(buf, "%d", &rect);
    
    ans = 2 * (float)rect * PI;
    
    printf("%lf", ans);
    
    return 0;
}


Measured memory_bytes: 1772
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<vector>
#include<functional>
#include<queue>
using namespace std;

const double INF = 1e9;
typedef double Weight;

struct Edge{
  int src,dst;
  Weight weight;
  Edge(int src,int dst,Weight weight) : src(src), dst(dst), weight(weight) {;}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void dijkstra(const Graph &g,const int s, vector<Weight> &dist, vector<int> &prev) {
  const int n = g.size();
  dist.assign(n, INF);
  dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;

  for(Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top();
    Q.pop();
    if(prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(Edges::const_iterator it = g[e.dst].begin(); it != g[e.dst].end(); ++it) {
      if(dist[it->dst] > e.weight + it->weight) {
	dist[it->dst] = e.weight + it->weight;
	Q.push(Edge(it->src, it->dst, e.weight + it->weight));
      }
    }
  }
}

int main() {
  int n,m,p,a,b,ts,t,x,y,z;
  vector<int> tickets(8);
  vector<int> prev((1<<8)*30);
  vector<Weight> dist((1<<8)*30);

  while(scanf("%d %d %d %d %d", &n, &m, &p, &a, &b)) {
    if(n==0 && m==0 && p==0 && a==0 && b==0) break;
    ts = 1<<n;
    Graph g(ts*m);
    a--,b--;

    tickets.clear();
    for(int i=0; i<n; ++i) {
      scanf("%d", &t);
      tickets.push_back(t);
    }

    for(int i=0; i<p; ++i) {
      scanf("%d %d %d", &x, &y, &z);
      x--,y--;
      for(int j=0; j<ts; ++j) {
	for(int k=0; k<n; ++k) {
	  if((j&(1<<k)) == 0) {
	    g[x*ts+j].push_back( Edge(x*ts+j, y*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	    g[y*ts+j].push_back( Edge(y*ts+j, x*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	  }
	}
      }
    }

    dist.clear();
    prev.clear();
    dijkstra(g, a*ts, dist, prev);

    double minw = INF;
    for(int i=0; i<ts; ++i)
      minw = min(dist[b*ts+i], minw);

    if(minw == INF)
      printf("Impossible\n");
    else
      printf("%f\n", minw);
  }
}

Measured memory_bytes: 27000
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var maxv = -2000000000;
            var minv = int.Parse(Console.ReadLine());

            for (int i = 1; i < n; i++)
            {
                var value = int.Parse(Console.ReadLine());
                maxv = Math.Max(maxv, value - minv);
                minv = Math.Min(minv, value);
            }

            Console.WriteLine(maxv);
        }
    }
}


Measured memory_bytes: 19864
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs            v.size()
#define ss            s.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii            pair<int, int>
#define int           long long
#define ull           unsigned long long
#define pb            push_back
#define mpp           make_pair
#define Okay          0
#define pi            3.14159

const int inf = 1e6;
const int cont = 1e18;
using namespace std;

vector<int>Graph[100005];
bool vis[100005];

void dfs(int u){
    vis[u] = true;
    for(int i =0; i<Graph[u].size(); i++){
        int v = Graph[u][i];
        if(!vis[v]){
            dfs(v);
        }
    }
}

void solve(){
    int n, m;
    cin>>n>>m;
    for(int i = 0; i<m; i++){
        int a, b;
        cin>>a>>b;
        Graph[a].pb(b);
        Graph[b].pb(a);
    }
    memset(vis, 0, sizeof vis);
    int cnt = 0;
    for(int i=1; i<=n; i++){
        if(!vis[i]){
                dfs(i);
                cnt++;
        }
    }
    cout<<cnt-1<<endl;
}

int32_t main() {
   Fast;
   int tst;

   solve();
    return Okay;
}



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

typedef long long ll;

// dp[i][j][k] := i 桁目まで見たとき、0 以外の数字がちょうど j 個使われていている数字の個数
// k は、N 未満(:=0)か N と同じ(:=1)かを表すフラグ
ll dp[105][5][2];

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

    string s;   // N を文字列で受け取る
    int k;
    cin >> s >> k;
    int n = s.length();
    
    dp[0][0][1] = 1;    // 0 桁目で、入力 N と一致している個数を 1 とする
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';   // 入力 N の i+1 桁目の数

        for(int j = 0; j <= k; ++j){
            for(int x = 0; x < 10; ++x){    // i+1 桁目にどの数字を入れる場合を考えるか
                int next = (x == 0) ? 0 : 1;    // j の遷移先を考えるときに必要
                
                // フラグの遷移は、未満 → 未満, 同じ → 未満
                if(x < num){
                    dp[i+1][j+next][0] += dp[i][j][0];
                    dp[i+1][j+next][0] += dp[i][j][1];
                }
                // フラグの遷移は、未満 → 未満, 同じ → 同じ
                else if(x == num){
                    dp[i+1][j+next][0] += dp[i][j][0];
                    dp[i+1][j+next][1] += dp[i][j][1];
                }
                // フラグの遷移は、未満 → 未満
                else{   // x > num
                    dp[i+1][j+next][0] += dp[i][j][0];
                }
            }
        }
    }

    cout << dp[n][k][0] + dp[n][k][1] << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

count = 0
prev = len(C)
for i in range(N):
  count += B[A[i]-1]
  if prev < len(C) and prev + 1 == A[i]-1:
    count += C[prev]
  prev = A[i] - 1
print(count)

Measured memory_bytes: 3064
N, K = map(int, input().split())
l = []
for i in range(N):
  h = int(input())
  l.append(h)
l.sort()
m = []
for i in range(N - K + 1):
  d = l[i + K - 1] - l[i]
  m.append(d)
m.sort()
print(m[0])
  

Measured memory_bytes: 11288
/*input
31 -41 -59 26
*/

// Nihesh Anderson - knandy

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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::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...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

#define fast_cin() ios_base::sync_with_stdio(false)
#define pb push_back
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug1(x) cerr << x << endl;
#define debug2(x,y) cerr << x << " " << y << endl;
#define debug3(x,y,z) cerr << x << " " << y << " " << z << endl;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define FORR(i, a, b) for (int i=a; i>=(b); i--)
ll INF = 2000000000000000001;
double EPS = 1e-9;
ll nextInt(){ll inp; cin>>inp; return inp;}
string nextStr(){string inp; cin>>inp; return inp;}
double nextDouble(){double inp; cin>>inp; return inp;}
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int x1,y1,x2,y2;
	int len,sign;
	cin>>x1>>y1>>x2>>y2;
	int x_shift = x2-x1;
	int y_shift = y2-y1;
	cout<<x2-y_shift<<" "<<y2+x_shift<<" "<<x1-y_shift<<" "<<y1+x_shift<<endl;
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> X(N);
	for(auto &i:X)cin >> i;
	int ans=999999999;
	for(int i=1;i<=100;i++){
		int tmp=0;
		for(auto x:X)tmp+=(x-i)*(x-i);
		ans=min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m, x = nm()
    A = nl()
    cost = [0] * 101
    for a in A:
        cost[a] = 1
    ans_1 = 0
    ans_2 = 0
    for i in range(x):
        ans_1 += cost[i]
    for i in range(x, n + 1):
        ans_2 += cost[i]
    print(min(ans_1, ans_2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin>>n;
    vector<int> p(n); rep(i,n)cin>>p[i];
    int ans = 0;
    REP(i,n-1)if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1]))ans++;
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
 
signed main() {
    quickie
    int n ;
    cin >> n ;
    string s = to_string(n) ;
    rep(i, 0, 3) {
        if(s[i] == '7')
        {
            cout << "Yes" << endl ;
            return 0 ;
        }
    }
    cout << "No" << endl ;
}
 
int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a, b;

  rep(i,N){
    int x;
    cin >> x;
    if(x<0) a.push_back(x);
    else b.push_back(x);
  }

  reverse(ALLOF(a));
  
  ll ret = 1e15;
  rep(i,a.size()){
    int xi = K-(i+1);
    if(xi <= b.size()){
      if(xi > 0) ret = min(ret, 2LL*abs(a[i]) + abs(b[xi-1]));
      else ret = min(ret, (ll)abs(a[i]));
    }
    if(i>=K) break;
  }
  rep(i,b.size()){
    int xi = K-(i+1);
    if(xi <= a.size()){
      if(xi > 0) ret = min(ret, 2LL*abs(b[i]) + abs(a[xi-1]));
      else ret = min(ret, (ll)abs(b[i]));
    }
    if(i>=K) break;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef struct{
    int x;
    int y;
} ax;
int main(){
    int n;
    cin >> n;
    vector<ax> r(n),b(n);
    for(int i = 0; i < n; i++)
        cin >> r[i].x >> r[i].y;
    for(int i = 0; i < n; i++)
        cin >> b[i].x >> b[i].y;
    sort(b.begin(),b.end(),[](auto c,auto d){return c.x < d.x;});
    int count = 0;
    for(int i = 0; i < n; i++){
        int j,max=-1,ab;
        for(j = 0; j < r.size(); j++){
            if(r[j].x < b[i].x && r[j].y < b[i].y){
                if(r[j].y > max){
                    max = r[j].y;
                    ab = j;
                }
            }
        }
        if(max != -1){
            r.erase(ab+r.begin());
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;
int n, k, frecv[10000];

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        int cate;
        cin >> cate;
        for (int j = 1; j <= cate; j++) {
            int a;
            cin >> a;
            frecv[a] = 1;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
        if (frecv[i] == 0)
            cnt++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3656