akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N,K;
    cin >> N >> K;
    long double act=0;
    double num=(double) 1/N;
    int res=1;
    double tmp=0;
    double limit=sqrt(K);
    for(int res=1;res<=N;++res){
        num=(double) 1/N;
        tmp=(double) res;
        while(tmp<K){
            tmp=tmp*2;
            num=num/2;
        }
        act+=num;
    }

    cout << fixed <<setprecision(10) <<  act;
}

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

int main()
{
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)!=s.at(i+1)){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma region template 1.2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    ll K;
    cin >> K;

    ll ans = 0;
    REP1(a, K)
    {
        REP1(b, K)
        {
            REP1(c, K)
            {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

    OUT(ans);
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
#include<iomanip>
#include<cctype>
using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

int main(){
    int n, m; cin >> n >> m;
    vector<int> coins(m);
    vector<vector<int>> dp(m+1,vector<int>(n+1,inf));
    dp[0][0] = 0;
    for (int i = 0; i < m; i++) cin >> coins[i];
    for (int i = 0; i < m; i++){
        for (int j = 0; j <= n; j++){
            if (j >= coins[i]){
                dp[i+1][j] = min(dp[i+1][j-coins[i]]+1,dp[i][j]);
            } else dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[m][n] << endl;

    return 0;
}


Measured memory_bytes: 7128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,z,ans1,ans2,ans3,ans4,ans5;
	cin>>x>>y>>z;
	ans1=x+y;
	ans2=x+z;
	ans3=y+z;
	
	cout<<min(ans1,min(ans2,ans3))<<endl;
	return 0;
	
}


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

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		solve(s);
		s.close();
	}

	public static void solve(Scanner s) {
		int n = s.nextInt();
		int[] an = new int[n];

		for (int i = 0; i < n; i++) {
			an[i] = s.nextInt();
		}

		long ans = Long.MAX_VALUE;

		for (int i = -100; i <= 100; i++) {
			long tmp = 0;
			for (int j = 0; j < n; j++) {
				tmp += Math.pow(i - an[j], 2);
			}
			ans = Long.min(ans, tmp);
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 9676
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, i;
    cin>>n>>m;
    vector<ll> v, ans(n+1, 0), f, p(n+1, 0);
 	v.pb(0);
 	string s;
 	cin>>s;
 	for(i=1; i<s.length(); i++) {
 		if(s[i] == '1') {
 			continue;
 		}
 		ll mini = lower_bound(all(v), max(i - m, (ll)0)) - v.begin();
 		if(mini == v.size()) {
 			cout<<-1<<"\n";
 			return 0;
 		}
 		v.pb(i);
 		p[i] = v[mini];
 		ans[i] = i - v[mini];
 	}
 	// for(i=0; i<=n; i++) {
 	// 	cout<<p[i]<<" ";
 	// }

 	i = n;
 	while(1) {
 		f.pb(ans[i]);
 		i = p[i];
 		if(i == 0)
 			break;
 	}
 	reverse(all(f));
 	for(auto u: f)
 		cout<<u<<" ";
 	cout<<"\n";
}

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

int main() {
  int n, c = 0;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v.at(i);
  rep(i, n){
    if(v.at(i) != i + 1 - c) ++c;
  }
  if(c == n) cout << -1 << endl;
  else cout << c << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
int w,h,x,y,r;
 scanf("%5d",&w);
 scanf("%5d",&h);
 scanf("%5d",&x);
 scanf("%5d",&y);
 scanf("%5d",&r);
 if(w>=x+r&&h>=y+r&&x+r>0&&y+r>0){
  printf("Yes\n");
 }
  else {
  printf("No\n");
 }
}


Measured memory_bytes: 2680
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] time = new long[n];
		for(int i=0;i<n;i++){
			time[i] = sc.nextLong();
		}
		for(int i=0;i<n-1;i++){
			long a = time[i];
			long b = time[i+1];
			if(a>=b){
				time[i+1] = a/gcd(a,b)*b;
			}
			else{
				time[i+1] = a/gcd(b,a)*b;
			}
		}
		System.out.println(time[n-1]);
	}

	public static long gcd(long a,long b){
		if(a%b==0){
			return b;
		}
		else{
			return gcd(b,a%b);
		}
	}
}

Measured memory_bytes: 21844
n=int(input())
a = set()
pi = ""
no = 0
for i in range(n):
    x = input()
    a.add(x)
    if i > 0 and pi[-1] != x[0]:
        no = 1
    pi = x
if n != len(a):
    no = 1
print(('Yes','No')[no])

Measured memory_bytes: 3064
using System;



class Program
{
    static void Main(string[] args)
    {
        Input CInput = new Input();
        int[] input = new int[(int)Input.Define.MAX_ArraySize];
        //int[,] input = new int[(int) Input.Define.MAX_ArraySize, (int) Input.Define.ArraySize2d];
        //int num = 0;
        input = CInput.Line1_int(' ', 3);
        //input = CInput.Multiline_int(' ' ,2, ref num);

        int count = 0;
        for (int i = input[0]; i <= input[1]; i++)
        {
            if (input[2] % i == 0) count++;
        }

        Console.WriteLine("{0}",count);

    }








    class Input
{
    public enum Define
    {
        MAX_ArraySize = 1000000,
        ArraySize2d = 2,                // 2?¬?????????????[][?] ???????
    }

    public string Line1_string()
    {
        return Console.ReadLine();
    }

    public int Line1_int()
    {
        var input = Console.ReadLine();
        return int.Parse(input);
    }

    public int[] Line1_int(int chr, int num)
    {
        var input = Console.ReadLine();
        var split = input.Split(' ');
        int[] spliti = new int[100];
        for (int i = 0; i < num; i++)
        {
            spliti[i] = int.Parse(split[i]);
        }
        return spliti;
    }

    public int[] Multiline_int(ref int datanum)
    {
        int i = 0;
        int[] data = new int[(int)Input.Define.MAX_ArraySize];
        while (true)
        {
            var input = Console.ReadLine();
            var value = int.Parse(input);
            if (value == 0) break;
            data[i] = value;
            i++;
        }
        datanum = i;
        return data;
    }
    /// <summary>
    /// ?????°??????int??????????????????????????????
    /// </summary>
    /// <param name="chr">???????????????</param>
    /// <param name="num">?????????????????????????????°</param>
    /// <param name="datanum">??????????????????????????°</param>
    /// <returns></returns>
    public int[,] Multiline_int(int chr, int num, ref int datanum)
    {
        int i = 0;
        int[,] data = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
        while (true)
        {
            var input = Console.ReadLine();
            var split = input.Split(' ');
            int[] spliti = new int[100];
            for (int j = 0; j < num; j++)
            {
                spliti[j] = int.Parse(split[j]);
            }
            if (spliti[0] == 0 && spliti[1] == 0) break;
            data[i, 0] = spliti[0];
            data[i, 1] = spliti[1];
            i++;
        }
        datanum = i;
        return data;
    }

}
}

Measured memory_bytes: 13120
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

fn main(){
    let mut line: Vec<u32> = read_as_vec();
    let (a, b, c) = (line[0], line[1], line[2]);

    if a == b && b == c{
        println!("Yes");
    }else{
        println!("No");
    }

}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()

	for i := n; ; i++ {
		isPrime := true
		for j := 2; j < i; j++ {
			if i%j == 0 {
				isPrime = false
			}
		}
		if isPrime {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BPalindromePhobia {
public:
    void solve(std::istream &in, std::ostream &out) {
        string str;
        in >> str;
        vi counter(3);
        trav(c, str) {
            counter[c - 'a']++;
        }
        sort(all(counter));
        bool res = counter[2] - counter[0] <= 1;
        out << (res ? "YES" : "NO") << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BPalindromePhobia solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int biggest = 1;
    int second_biggest = 1;

    for(int i=0; i < N; i++){
        if(A[i] > biggest){
            second_biggest = biggest;
            biggest = A[i];
        }
        else if(second_biggest < A[i]){
            second_biggest = A[i];
        }
    }
    for(int i=0; i < N; i++){
        if(A[i] == biggest) cout << second_biggest << endl;
        else  cout << biggest << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>

typedef long long int64;

static int getLower8(int x) {
  int q = 100 * x % 8;
  if (q == 0) {
    return 100 * x / 8;
  }
  else {
    return (100 * x / 8) + 1;
  }
}

static int getMin(int al, int au, int bl, int bu) {
  if (au < bl || bu < al) {
    return -1;
  }
  else {
    return std::max(al, bl);
  }
}

int main(void) {
  int a, b;
  std::cin >> a >> b;
  int l8 = getLower8(a);
  int u8 = getLower8(a + 1) - 1;
  int l10 = b * 10;
  int u10 = l10 + 9;

  std::cout << getMin(l8, u8, l10, u10) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::cmp::Reverse;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        mut As: [i64; N],
    }

    let mut alice: i64 = 0;
    let mut bob: i64 = 0;

    As.sort_by_key(|&num| Reverse(num));

    for mut chunk in &As.into_iter().chunks(2) {
        alice += chunk.next().unwrap_or(0);
        bob += chunk.next().unwrap_or(0);
    }

    let ans = alice - bob;
    println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    string a;
    cin >> a;
    if (a == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1)
      cout << "Three" << endl;
  }
}


Measured memory_bytes: 764
#include <iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<list>
#include<deque>
#include<ctime>
#include<map>
#include<set>
using namespace std;
int main()
{
	string s;
	cin >> s;
	for (int x = 0; x < s.size(); x++)
	{if (s[x]=='R'&&x%2!=0)
	{
		cout << "No";
		return 0;
	}
	if (s[x]=='L'&&x%2==0)
	{
		cout << "No";
		return 0;
	}

	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = ' ';
        for(char cc : s.toCharArray()) {
            if(c != cc) {
                c = cc;
            } else {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 23892
card = [ input() for i in range(3) ]
count = [0, 0, 0]
curr = 0
while count[curr] != len(card[curr]):
    if card[curr][count[curr]] == "a":
        tmp = 0
    if card[curr][count[curr]] == "b":
        tmp = 1
    if card[curr][count[curr]] == "c":
        tmp = 2
    count[curr] += 1
    curr = tmp
print("ABC"[curr])

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
const int N=2e5+50;
const int INF=0x3f3f3f3f;
typedef long long ll;
int main()
{
    int n;
    ll a,b;
    ll x,y;
    scanf("%d",&n);
    a=1;
    b=1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld %lld",&x,&y);
        ll sum,s1,s2;
        s1=1;
        s2=1;
        sum=1;
        if(x<a)
        {
            s1=a/x;
            if(a%x!=0)
                s1++;
        }
        if(y<b)
        {
            s2=b/y;
            if(b%y!=0)
                s2++;
        }
        sum=max(s1,s2);
        a=x*sum;
        b=y*sum;
    }
    ll ans=a+b;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import sys
from pprint import pprint

import math

a, b, x = map(int, sys.stdin.readline().strip().split(" "))

threshold = math.atan(b/a)
# print(threshold / math.pi * 180)

theta = math.atan(2*(a**2 * b - x) / a**3)
# print("theta", theta / math.pi * 180)
if theta <= threshold:
    print(theta / math.pi * 180)
else:
    theta = math.atan(2*x / (a * b**2))
    print(90 - theta / math.pi * 180)

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

int main()
{
    int N;
    cin >> N;
    set<int> s;
    int A;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        s.insert(A);
    }
    if (s.size() == N)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
A=int(input())
Sum= A*(A+1)/2
B=(A//3)
C=(A//5)
D=(A//15)

E=B*(6+(B-1)*3)/2
F=C*(10+(C-1)*5)/2
G=D*(30+(D-1)*15)/2

print(int(Sum-E-F+G))

Measured memory_bytes: 9216
N = int(input())
H = list(map(int, input().split()))
cnt = 0
mx = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        mx = max(cnt, mx)
        cnt = 0
mx = max(cnt, mx)
print(mx)

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

int n;
string s;

int get_pos(int i, int pos) {
  while (pos < n) {
    // cerr << i << " " << pos << " " << n << endl;
    if ((s[pos]-'0') == i) {
      // cout << i << " " << s[pos] << endl;
      break;
    }
    ++pos;
  }
  return pos;
}

int main() {
  cin >> n;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 10; ++i) {
    int p1 = get_pos(i, 0);
    if (p1 == n) continue;
    // cout << i << " " << p1 << endl;
    for (int j = 0; j < 10; ++j) {
      int p2 = get_pos(j, p1+1);
      if (p2 == n) continue;
      // cout << i << " " << j << " " << p1 << " " << p2 << endl;
      for (int k = 0; k < 10; ++k) {
        int p3 = get_pos(k, p2+1);
        if (p3 == n) continue;
        // cout << i << " " << j << " " << k << " " << p1 << " " << p2 << endl;
        ++ans;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M; cin >> N >> M;
	vector<int> a(N, 0);
	rep (i, N) cin >> a[i];

	int g = __gcd(N, M);
	int L = N * M / g;
	int numGroup = L / M; 

	vector<int> Group[numGroup];
	rep (i, numGroup) Group[i].clear();
	rep (i, L){
		Group[i/M].push_back(a[i%N]);
	} // end rep
	
	rep (i, numGroup){
		sort(ALL(Group[i]));
//		cerr << "max: " << Group[i][Group[i].size() - 1] << " min: " << Group[i][0] << endl; 
	} // end rep


	int res = 0;
	rep (i, numGroup){
		int range = Group[i][Group[i].size() - 1] - Group[i][0];
		res += range;
	} // end rep

	cout << res << endl;

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int b = n;
    int wa;
    for (int i = 0; i < 10; i++)
    {
        int a = n % 10;
        wa += a;
        n = n / 10;
        if (n == 0)
        {
            break;
        }
    }
    if (b % wa == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

A=int(A)
B=int(B)
C=int(C)
X=int(X)

count=0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x=X-(500*a+100*b+50*c)
            
            if x==0:
                count=count+1

print(count)

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

int main(){
  vector<int> cook(5);
  for(int i=0;i<5;i++) cin>>cook.at(i);
  vector<vector<int>> A;
  vector<int> ans={0,1,2,3,4};
  do{ A.push_back(ans); }while(next_permutation(ans.begin(),ans.end()));
  priority_queue<int,vector<int>,greater<int>> time;
  for(int i=0;i<120;i++){
    int X=0;
    for(int j=0;j<4;j++){
      if(cook.at(A.at(i).at(j))%10==0) X+=cook.at(A.at(i).at(j));
      else X+= (cook.at(A.at(i).at(j))/10+1)*10;
    }
    X+=cook.at(A.at(i).at(4));
    time.push(X);
  }
  cout<<time.top()<<endl;
}


Measured memory_bytes: 3616
function Main(input) {
  input = input.split("\n");
  var M = input[0].split(" ").map(Number);
  var N = input[1].split(" ").map(Number);
  N.sort(function(a,b){return a-b;});
  var sum = 0;
  for(var i=0;i<M[1];i++){
  sum += N[N.length-1-i];
  }
  if(sum>=M[0]) console.log("Yes");
  else console.log("No")
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define tt template<typename T> ostream& operator <<(ostream& os, const
#define tuv template<typename U, typename V> ostream& operator<<(ostream& os, const
tt vector<T>& v)            { os << "["; for(auto & x : v) os << " " << x; os << " ]"; return os; }
tt vector<vector<T> >& m)   { for(auto & x : m) { for(auto & y : x) os << y << " "; os << "\n"; } return os; }
tt set<T>& s)               { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt unordered_set<T>& s)     { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt queue<T>& q)             { queue<T> q2(q); while(!q2.empty()) { os << q2.front() << " "; q2.pop(); } return os; }
tt stack<T>& s)             { stack<T> s2(s); while(!s2.empty()) { os << s2.top() << " "; s2.pop(); } return os; }
tuv pair<U,V>& p)           { os << "(" << p.first << "," << p.second << ")"; return os; }
tuv map<U,V>& m)            { os << "{ "; for(auto & x : m) os << x.first << ":" << x.second << " "; os << "}"; return os; }
tuv unordered_map<U,V>& um) { os << "{ "; for(auto & x : um) os << x.first << ":" << x.second << " "; os << "}"; return os; }


void incr(vector<int>& v, const std::set<int>& Dset)
{
    for(int i = v.size()-1; i >= 0; --i)
    {
	if(v[i] == 9)
	{
	    if(i != 0)
		v[i] = 0;
	    else
	    {
		v[i] = 0;
		v.insert(v.begin(), 1);
	    }
	}
	else
	{
	    v[i]++;
	    break;
	}
    }
}


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    int N, K;
    std::cin >> N >> K;

    std::vector<int> D(K);
    for(int i = 0; i < K; ++i) std::cin >> D[i];
    std::set<int> Dset(D.begin(), D.end());
    
    int temp = N;
    bool ok = true;
    vector<int> v;
    while(temp)
    {
	if(Dset.find(temp % 10) != Dset.end()) ok = false;
	v.push_back(temp % 10);
	temp /= 10;
    }
    reverse(v.begin(), v.end());

    if(ok)
    {
	std::cout << N << std::endl;
	return 0;
    }

    for(int i = N; i <= 100000; ++i)
    {
	incr(v, Dset);
	bool done = true;
	for(int j = 0; j < v.size(); ++j)
	{
	    if(Dset.find(v[j]) != Dset.end())
	    {
		done = false;
		break;
	    }
	}
	if(done == true)
	{
	    bool zero_part = true;
	    for(auto x : v)
	    {
		if(x != 0) zero_part = false;
		if(!zero_part) cout << x;
	    }
	    std::cout << std::endl;
	    return 0;
	}
    }


    return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input!{
        n: usize
    }
    let m: i64 = 1000000007;
    let mut dp = vec![0; n+1];
    for i in 3..=n {
        dp[i] = 1;
        for j in 3..=i-3 {
            dp[i] = (dp[i] + dp[j]) % m;
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mpp make_pair
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    ll n,j=0,cnt=0;
    map<ll,char>mp;
    char ch=96;
    for(ch=97; ch<=122; ch++)
    {
        mp[j]=ch;
        j++;

    }

    cin>>n;
    string s,ans,ans1;
    while(n!=0)
    {
        n-=1;
        ll rem=n%26;
        ans+=mp[rem];
        // cout<<rem<<" "<<n<<endl;;
        n=n/26;


    }
    //cout<<ans.size()<<endl;
    reverse(ans.begin(),ans.end());
 ll    sz=ans.size();
    for(ll i=0; i<sz; i++)
    {
        if(ans[i]>='a' && ans[i]<='z')
        {
            ans1+=ans[i];
        }
    }
    cout<<ans1<<endl;
}


Measured memory_bytes: 3628
n=input()
for i in range(n):
    dt=map(int, raw_input().split())
    a1=0
    a2=0
    for e in dt:
        if e>a1: a1=e
        elif e>a2: a2=e
        else:
            print "NO"
            break
    else:
        print "YES"

Measured memory_bytes: 4200
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      String str = br.readLine();
      int numR = 0;
      for(int i = 0; i < n; i++)
        	if(str.charAt(i) == 'R')
              numR++;
     int ans = 0;
     for(int i = 0; i < numR; i++)
       if(str.charAt(i) == 'W')
         ans++;
     out.println(ans);
      out.close();
   }
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    string s;
    cin>>s;
    int n=s.size();
    vin ama(n+1,0);
    vll cnt(2019,0);
    vin ten(n+1,1);
    rep(i,n){
        ten[i+1]=ten[i]*10;
        ten[i+1]%=2019;
    }
    rep(i,n){
        ama[i+1]=ama[i]+(s[n-i-1]-'0')*ten[i+1];
        ama[i+1]%=2019;
        cnt[ama[i+1]]++;
    }
    cnt[0]++;
    ll ans=0;
    rep(i,2019){
        ans+=(cnt[i]-1)*cnt[i]/2;
    }
    cout<<ans<<endl;
    
    
    
    
  

}


Measured memory_bytes: 5084
#include<iostream>
using namespace std;
int main(){
  long long n, a, b, x, y, i=0;
  cin >> n >> a >> b >> x;
  long long ans=0;
  for(int i=1;i<n;i++){
    cin >> y;
    ans+=min(b,a*(y-x));
    x=y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
gets
xs = gets.split(' ').map(&:to_i).map{ |v| v / 400 }.group_by{|v| v}
ranks = xs.select{|k,v| k < 8}
wc = xs.select{|k,v| k >= 8}.values.flatten

min = ranks.keys.length
min = 1 if min == 0 && wc.length > 0

max = ranks.keys.length
max = [max, max + wc.length].max
puts min.to_s + ' ' + max.to_s


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<list>
using namespace std;
static string s;
int main() {
	int k;
	/*cin >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] += 1;
	}
	cout << s << endl;*/
	cin >> s >> k;
	for (int i = 0; i < s.size()&&0<k; i++) {
		//if (s[i] == 'a')continue;
		if ('z'+1 - s[i] <= k&&s[i]!='a') {
			k -= ('z'+1 - s[i]);
			s[i] ='a';
			//cout << s[i] << "→ a   k =" << k << endl;
		}
		if (i == s.size() - 1) {
			s[i] += (k%26);
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0; 
	for(int i = 0; i < n - 2; ++i) {
		if( s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(ll factor[],ll n){
    ll a = 2;
    bool flag = false;
    for(int p = 2;p*p <= n;p++){
        while(n%p == 0){
            n/=p;
            factor[p]++;
        }
    }
    if(n!=1)  factor[n]++; //prime num
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
   ll n;
   cin >> n;
   ll d[5] = {0};
   int a[10] = {0,0,0,0,0,0,1,1,1,2};
   int b[10] = {1,1,1,2,2,3,2,2,3,3};
   int c[10] = {2,3,4,3,4,4,3,4,4,4};

   rep(i,0,n){
       string s;
       cin >> s;
       if(s[0] == 'M') d[0]++;
       if(s[0] == 'A') d[1]++;
       if(s[0] == 'R') d[2]++;
       if(s[0] == 'C') d[3]++;
       if(s[0] == 'H') d[4]++;
   }
   ll ans = 0;
   rep(i,0,10){
       ans += d[a[i]]*d[b[i]]*d[c[i]]; 
   }
   
   cout << ans <<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

m,k = li()

if k >= pow(2, m):
    print(-1)

elif k == 0:
    ans = []
    for i in range(pow(2,m)):
        ans.append(i)
        ans.append(i)
    print(*ans)

else:
    xor = 0
    cur = []
    for i in range(pow(2,m)):
        if i == k:
            continue

        else:
            xor ^= i
            cur.append(i)

    if xor == k:
        ans = [k] + cur[::-1] + [k] + cur
        print(*ans)

    else:
        print(-1)


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

int main(){
  int a, b;
  int x, y, s;

  while (1) {
    int beforea, beforeb;
    int aftera, afterb;
    int max = 0;
    scanf("%d%d%d", &x, &y, &s);
    if (x == y && y == s && x == 0) break;
    for (a = 1; a < s; a++) {
      for (b = a; b < s; b++) {
        beforea = a*(100+x)/100;
        beforeb = b*(100+x)/100;
        aftera = a*(100+y)/100;
        afterb = b*(100+y)/100;
        if (beforea + beforeb == s) {
          if (max < aftera + afterb) {
            max = aftera+afterb;
            // printf("a = %d  b = %d\n",a,b);
            // printf("beforea = %d  beforeb = %d\n", beforea, beforeb);
            // printf("aftera = %d  afterb = %d\n", aftera, afterb);
          }
        }

      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

#define rep(i, n) for(i = 0;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define pb push_back

struct edge{
  int to;
};
vector<edge> G[10000];

int v, e;
#define maxV 10000
vector<edge> sccrG[maxV];
bool sccused[maxV] = {false};
int sccr[maxV], sccrhd = 0;
int scctopo[maxV];

void sccdfs(int now){
  sccused[now] = true;
  for(int i = 0;i < G[now].size();++i)if(!sccused[G[now][i].to])sccdfs(G[now][i].to);
  sccr[sccrhd++] = now;
  return;
}
void sccrdfs(int now, int num){
  sccused[now] = true;
  scctopo[now] = num;
  for(int i = 0;i < sccrG[now].size();++i)if(!sccused[sccrG[now][i].to])sccrdfs(sccrG[now][i].to, num);
  return;
}
void scc(void){
  for(int i = 0;i < v;++i)for(int j = 0;j < G[i].size();++j)sccrG[G[i][j].to].push_back((edge){i});
  for(int i = 0;i < v;++i)if(!sccused[i])sccdfs(i);

  int num = 0;
  for(int i = 0;i < v;++i)sccused[i] = false;
  for(;sccrhd--;)if(!sccused[sccr[sccrhd]])sccrdfs(sccr[sccrhd], num++);
  return;
}

signed main(void){
  int i, j;
  scanf("%d%d", &v, &e);
  rep(i, e){
    int2(a, b);
    G[a].pb((edge){b});
  }
  scc();

  int(q);
  for(;q--;){
    int2(u, v);
    puts((scctopo[u] == scctopo[v]) ? "1" : "0");
  }

  return 0;
}

Measured memory_bytes: 4664
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (max( { a, b, c, d, e }) - min( { a, b, c, d, e }) > k) {
    cout << ":(";
  } else {
    cout << "Yay!";
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int H,W,i,j,k;
  while(1){
  scanf("%d %d",&H,&W);
  if(H==0 && W==0){
    break;
  }
  for(i=0;i<W-1;i++){
    printf("#");
      }
  printf("#\n");
  for(k=0;k<H-2;k++){
    printf("#");
  for(j=0;j<W-2;j++){
    printf(".");
  }
  printf("#\n");
  }
for(i=0;i<W-1;i++){
  printf("#");
      }
  printf("#\n\n");
  }
  return 0;
}

Measured memory_bytes: 588
from collections import deque

N = int(input())
tree = [[] for i in range(N)]
edges = []

for i in range(N - 1):
    edges.append(tuple(map(int, input().split())))
    tree[edges[-1][0] - 1].append(edges[-1][1] - 1)
    tree[edges[-1][1] - 1].append(edges[-1][0] - 1)

coloring = {}
c_max = 1

color_used = [0]*N
v_dist = [-1]*N

queue = deque([0])
v_dist[0] = 0

while queue:
    v = queue.popleft()
    
    c = 1
    for n_v in tree[v]:
        if v_dist[n_v] < 0:
            v_dist[n_v] = v_dist[v] + 1

            if color_used[v] == c:
                c += 1
            
            coloring[(v, n_v)] = c
            coloring[(n_v, v)] = c
            color_used[n_v] = c
            queue.append(n_v)

            c += 1
    
    c_max = max(c_max, c)

print(c_max - 1)

for edge in edges:
    print(coloring[(edge[0]-1, edge[1]-1)])

Measured memory_bytes: 157380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i,k) {
    int m;
    cin >> m;
    rep(j,m) {
      int a;
      cin >> a;
      d[a-1] = 1;
    }
  }
  int ans = 0;
  rep(i,n) if (d[i] == 0) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int Time[5],i,max=10,max_i,total=0;

  for (i = 0; i < 5; i++) {
    scanf("%d", &Time[i]);
  }

  for (i = 0; i < 5; i++) {
    if (max > Time[i] % 10 && Time[i] % 10 != 0) {
      max = Time[i] % 10;
      max_i = i;
    }
  }

  for (i = 0; i < 5; i++) {
    if (i == max_i) {
      total += Time[i];
    } else if (Time[i] % 10 != 0) {
      total += (Time[i] + (10 - (Time[i] % 10)));
    } else if (Time[i] % 10 == 0) {
      total += Time[i];
    }
  }

  printf("%d\n",total);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  ll ret = 1L;
  vector<int> cur = {0,0,0};
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    int pos = 0,cnt=0;
    for(int j=0;j<3;j++){
      if(cur[j]==x){
        cnt++;
        pos = j;
      }
    }
    ret=ret*cnt%mod;
    cur[pos]++;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int d;
    cin >> d;
    if (d == 25){
        cout << "Christmas" << endl;
    }
    else {
        cout << "Christmas";
        for (int i=25-d-1; i>0; i--){
            cout << " " << "Eve";
        }
        cout << " " << "Eve" << endl;
    }
    return 0;
 
 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
    Scanner cin = new Scanner();
	  string searchString = cin.next();
	  int n = cin.nextInt();
    string[] rings = new string[n];
	  int ans = 0;
    for (int i = 0; i < n; i++)
	  {
	    rings[i] = cin.next();
	    rings[i] += rings[i];
	    if (rings[i].IndexOf(searchString) != -1)
	    {
	      ++ans;
	    }
	  }
    Console.WriteLine(ans);
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 20580
#include<bits/stdc++.h>
#define LL long long
#define dl double
template <class T>
void rd(T &x){
  x=0;T f=1;char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  while(ch<='9' && ch>='0')x=x*10+ch-'0',ch=getchar();x*=f;
}

using namespace std;

const int N=20;

int n;
struct Point{
 int x,y,p,id;
 void read(int i){rd(x);rd(y);rd(p);id=i;}
}t1[N],t2[N];
int hs1[N],hs2[N];
bool cmp1(Point a,Point b){return a.x < b.x;}
bool cmp2(Point a,Point b){return a.y < b.y;}

bool flg1[N],flg2[N];

int q1[N],q2[N],tp1,tp2;

LL ans[N];

LL ghb[N];

void dfs(int x){
 if(x == n+1){
  tp1=tp2=0;
  for(int i=1;i<=n;i++){
   if(flg1[i])q1[++tp1]=t1[i].x;
   if(flg2[i])q2[++tp2]=t2[i].y;
   ghb[i]=0x7fffffffffffff;
  }
  for(int i=1,j1=1,j2=1;i<=n;i++){
   int tmp=abs(t1[i].x);
   if(tp1){
    while(j1 < tp1 && q1[j1] <= t1[i].x)j1++;
    tmp=min(tmp,abs(q1[j1]-t1[i].x));
    tmp=min(tmp,abs(q1[j1-1]-t1[i].x));
   }
   ghb[t1[i].id]=min(ghb[t1[i].id],1ll*t1[i].p*tmp);
   tmp=abs(t2[i].y);
   if(tp2){
    while(j2 < tp2 && q2[j2] <= t2[i].y)j2++;
    tmp=min(tmp,abs(q2[j2]-t2[i].y));
    tmp=min(tmp,abs(q2[j2-1]-t2[i].y));
   }
   ghb[t2[i].id]=min(ghb[t2[i].id],1ll*t2[i].p*tmp);
  }
  LL ttt=0;
  for(int i=1;i<=n;i++)ttt+=ghb[i];
  ans[tp1+tp2]=min(ans[tp1+tp2],ttt);
  return ;
 }
 dfs(x+1);
 flg1[hs1[x]]=1;dfs(x+1);flg1[hs1[x]]=0;
 flg2[hs2[x]]=1;dfs(x+1);flg2[hs2[x]]=0;
}

int main(){
 // freopen("in.txt","r",stdin);
 // freopen("o.txt","w",stdout);
 rd(n);
 memset(ans,0x7f,sizeof(ans));
 for(int i=1;i<=n;i++)t1[i].read(i),t2[i]=t1[i];
 sort(t1+1,t1+n+1,cmp1);
 for(int i=1;i<=n;i++)hs1[t1[i].id]=i;
 sort(t2+1,t2+n+1,cmp2);
 for(int i=1;i<=n;i++)hs2[t2[i].id]=i;
 dfs(1);
 for(int i=0;i<=n;i++)printf("%lld\n",ans[i]);
 return 0;
}
/**/

Measured memory_bytes: 3736
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  rep1(i,9){
    rep1(j,9){
      if(i*j == n){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}


Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "c"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

const l MOD = e9 + 7;

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  l s = accumulate(all(v), l(0));
  cout << s - n << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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

N = int(input())
A = list(map(int, input().split()))
cnt = [0]*(N+1)
B = [0]*(N+1)

for Ai in A:
    cnt[Ai] += 1
    B[cnt[Ai]] += 1

acc = [0]

for Bi in B:
    acc.append(acc[-1]+Bi)

x = N

for K in range(1, N+1):
    while x>0 and K*x>acc[x+1]:
        x -= 1
    
    print(x)

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

typedef long long ll;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll prev, curr_abs;

  if (!(N % K))
  {
    cout << 0 << "\n";
    return 0;
  }
  else
  {
    prev = N % K;
    curr_abs = abs(prev - K);
    if (prev < curr_abs)
    {
      cout << prev << "\n";
    }
    else
    {
      cout << curr_abs << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    abcd = list(map(int,list(S())))
    bits = itertools.product([0,1],repeat=3)

    for bit in bits:
        cnt = abcd[0]
        for i,op in zip(abcd[1:],bit):
            if op == 0:
                cnt += i
            else:
                cnt -= i
        if cnt == 7:
            ans = str(abcd[0])
            for i,op in zip(abcd[1:],bit):
                ans += "+" if op == 0 else "-"
                ans += str(i)
            break
    ans += "=7"
    print(ans)
main()            


Measured memory_bytes: 74620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{  // freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
    iso;
  	string s;
  	cin>>s; int c=0;
  	for(int i=0;i<s.length();i++)
  	  if(s[i]=='o')
  	    c++; 
  	 if(c+15-s.length()>=8)
	   cout<<"YES";
	 else
	   cout<<"NO"; 
 
}

Measured memory_bytes: 256