akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> Int -> [Int] -> Int
solve n a b ps = minimum [s1, s2, s3]
  where
    s1 = length [ p | p <- ps, p <= a ]
    s2 = length [ p | p <- ps, a+1 <= p, p <= b ]
    s3 = length [ p | p <- ps, b+1 <= p ]

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      [bs_a,bs_b]:remLines2 = remLines1
      a = readBInt bs_a
      b = readBInt bs_b
      line3:remLines3 = remLines2
      ps = map readBInt line3
  in solve n a b ps

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

inp1 = "7\n5 15\n1 10 16 2 7 20 12\n"
inp2 = "8\n3 8\n5 5 5 10 10 10 15 20\n"
inp3 = "3\n5 6\n5 6 10\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 2
test2 = tv2 == 0
test3 = tv3 == 1
alltest = test1 && test2 && test3


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    int a=1;
    ll ans=0;
    rep(i,n){
        ans+=(A[i]-1)/a;
        if(A[i]==a) a++;
        if(a==1) a++;
    }
    cout<<ans<<"\n";
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


int n, k;
vi arr;
vi b;

signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> k;
    rep(i,0,n) arr.push_back(input());
    b = arr;

    int ans = sum(arr);

    rep(i,1,n){
        int cnt = k * i;
        rep(j,0,n){
            int p = (j - i + n) % n;
            chmin(b[j], arr[p]);
            cnt += b[j];
        }
        chmin(ans, cnt);
    }

    print(ans);




    



	








    



    





    


    

}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

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

    int64_t ans = 0x7fffffffffffffffLL;

    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }

    ans = min(ans, a * b);
    ans = min(ans, b * c);
    ans = min(ans, c * a);

    cout << ans << endl;

    return 0;
}

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

int main(){
	int n, m, l;
	int i, j, k;
	int A[100][100], B[100][100];
	long  C[100][100] = {0};
	
	cin >> n >> m >> l;
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}

	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}

	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			for(k = 0; k < m; k++){
			C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
		cout << C[i][j];
		if(j != l - 1){
			cout << " ";
		}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3216
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int c=0;
    for(int i=1;i<=n;i++){
      if(i%2==0) continue;
      int cnt=0;
      for(int j=i;j>=1;j--){
        if(i%j==0){
          cnt++;
        }
      }
      if(cnt==8){
        c++;
      }
    }
    System.out.println(c);
  }
}

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

inline void makeSet(vector<int>* set, int size);
inline int find(vector<int> *v, int x);
inline void unite(vector<int> *v, int root1, int root2);
inline void printV(vector<int>* v);

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

    vector<int> set;
    makeSet(&set, n);

    int com, x, y;
    for(int i=0; i<q; i++){
        cin >> com >> x >> y;

        switch(com){
        case 0 :
            unite(&set, find(&set, x), find(&set, y));
            break; 
        case 1 :
            find(&set, x) == find(&set, y) ? cout << "1" : cout << "0";
            cout << endl;
            break;
        }
        // printV(&set);
    }
    
    return 0;
}

void makeSet(vector<int>* set, int size)
{
    for(int i=0; i<size; i++) set->push_back(i);
}

int find(vector<int> *v, int x)
{
    if( !(x >= 0 && x < v->size()) ) exit(1);

    while( v->at(x) != x ){
        x = v->at(x);
    }
    return x;
}

void unite(vector<int> *v, int root1, int root2)
{
    if( find(v, root1) == find(v, root2) ) return;
    if( !( (root1>=0 && root1<v->size()) && (root2>=0 && root2<v->size()) ) ) return;

    v->at(root1) = root2;
}

void printV(vector<int>* v)
{
    for(int i=0; i<v->size(); i++) cout << v->at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 1320
#include"stdio.h"

int p[1000000];
int i,j,f;
int n;
int ans;

int main(){
	while(scanf("%d",&n)!=EOF){
		ans=0;
		for(i=2;i<=n;i++)p[i]=1;
		for(i=2;i<=n;i++)if(p[i]==1){
			ans++;
			for(j=2;i*j<=n;j++)p[i*j]=0;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 4928
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter
G = []
H = []
color = []


def dfs(G, i, fr, c):
    global color
    color[i] = c
    # print('lp')
    for node in G[i]:
        if color[node] == -1:
            dfs(G, node, i, c)


def main():
    global G, H, color
    n, m, k = list(map(int, input().strip().split()))
    G = [[] for _ in range(n)]
    H = [[] for _ in range(n)]
    color = [-1] * n
    for i in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        G[a].append(b)
        G[b].append(a)
    for i in range(k):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        H[a].append(b)
        H[b].append(a)
    c = 0
    # print(G)
    for i in range(n):
        # print('before dfs')
        if color[i] == -1:
            dfs(G, i, -1, c)
            c += 1
        # print('af dfs')
    counter = dict(Counter(color))
    # print(counter)
    # print(color)
    # print(H)
    for i in range(n):
        block = 0
        for b in H[i]:
            if color[i] == color[b]:
                block += 1
        # print('block, ', block)
        print(counter[color[i]] - 1 - len(G[i]) - block)

if __name__ == '__main__':
    main()


Measured memory_bytes: 335440
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

type Items [][]int
func (I Items) Len() int { return len(I) }
func (I Items) Less(i, j int) bool {
  if I[i][0] == I[j][0] { return I[i][1] < I[j][1] }
  return I[i][0] < I[j][0]
}
func (I Items) Swap(i, j int) { I[i], I[j] = I[j], I[i] }

func Unique(A *[][]int) {
  N := len((*A))
  for i := N - 1; 0 < i; i-- {
    if (*A)[i][0] == (*A)[i - 1][0] && (*A)[i][1] == (*A)[i - 1][1] {
      (*A) = append((*A)[:i - 1], (*A)[i:]...)
    }
  }
}

func Max(x, y int) int {
  if x < y { return y }
  return x
}

func main() {
  N := NextInt()
  A := NextIntVec()
  B := make([][][]int, len(A))
  for i, a := range A {
    B[i] = make([][]int, 2)
    B[i][0] = []int{a, i}
    B[i][1] = []int{0, -1}
  }
  for i, b := range B {
    for j := 0; j < N; j++ {
      k := i | (1 << uint(j))
      if B[k][0][0] < b[0][0] && B[k][0][1] != b[0][1] {
        B[k][1] = B[k][0]
        B[k][0] = b[0]
      } else if B[k][1][0] < b[0][0] && B[k][0][1] != b[0][1] {
        B[k][1] = b[0]
      }
      if B[k][1][0] < b[1][0] && B[k][0][1] != b[1][1] {
        B[k][1] = b[1]
      }
    }
  }
  ans := 0
  for _, b := range B[1:] {
    ans = Max(b[0][0] + b[1][0], ans)
    Write(ans)
  }
  Output()
}

Measured memory_bytes: 37248
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let n: usize = input();
    let a: Vec<i64> = input_vec();

    let mut accum = vec![0; n+1];
    for i in 1..n+1 {
        accum[i] = accum[i-1] + a[i-1];
    }

    let mut count = HashMap::new();
    let mut ans = 0usize;
    for i in accum.iter() {
        let h = count.entry(*i).or_insert(0);
        ans += *h;
        *h += 1;
    }

    println!("{}", ans);
}



pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 20496
a = [int(i) for i in input().split()]
 
if a[1]%2 == 1:
	print ((a[0]//a[1])**3)
else:
	if a[0]%a[1] < a[1] // 2:
		print ((a[0]//a[1])**3 + ((a[0]//a[1])**3))
	else:
		print ((1 + a[0]//a[1])**3 + ((a[0]//a[1])**3))

Measured memory_bytes: 38428
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

bool charge[100][200000];
bool wait[100];
int sz[100];
int state[100];
int use;
queue<int> que;

int doit(int n){
	int res = 0;
	bool used = false;
	use = -1;
	
	while(!que.empty()){
		int p = que.front();
		if(!charge[p][state[p]]){
			que.pop();
			wait[p] = false;
		}else{
			
			state[p] = (state[p] + 1) % sz[p];
			if(!charge[p][state[p]]){
				que.pop();
				wait[p] = false;
			}
			used = true;
			use = p;
			break;
		}
	}

	rep(i, n){
		if(i == use){
	//		cout << 'a';
		}else if(wait[i]){
	//		cout << '-';
			res++;
		}else{

			if(charge[i][state[i]]){
				if(used){
					res++;
					que.push(i);
					wait[i] = true;
	//				cout << 'b';
				}else{
	//				cout << '.';
					used = true;
					state[i] = (state[i] + 1) % sz[i];
					wait[i] = true;
					if(charge[i][state[i]])que.push(i);
					else wait[i] = false;
				}
			}else{
	//			cout << '*';
				state[i] = (state[i] + 1) % sz[i];
			}
		}
	}
	//cout << endl;
	return res;
}

int main(){
	int n, d; // n <= 100 d <= 10800
	int a, b;
	while(cin >> n >> d && (n || d)){
		int res = 0;
		memset(sz, 0, sizeof(sz));
		memset(state, 0, sizeof(state));
		memset(wait, false, sizeof(wait));
		while(!que.empty()) que.pop();

		use = -1;
		rep(i, n){
		
			while(cin >> a && a){
				cin >> b;
				rep(j, a) charge[i][sz[i]++] = false;
				rep(j, b) charge[i][sz[i]++] = true;
			}

		}

		rep(i, d){
			res += doit(n);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input().strip())
A = sorted(map(int, input().strip().split()), reverse=True)

ans = A[-1]

l = A[0]
for r in A[1:]:
  if r < l:
    tmp = r
    r = l
    l = tmp
  mod = -1
  while mod != 0:
    div, mod = divmod(l, r)
    l = r
    r = mod

print(l)


Measured memory_bytes: 14252
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		Map<Long, Integer> map = new HashMap<>();
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			long l = sc.nextLong();
			if(map.containsKey(l)) {
				map.put(l, map.get(l)+1);
			} else {
				map.put(l, 1);
			}
		}
		long l1 = 0;
		long l2 = 0;
		for(long lo : map.keySet()) {
			int a = map.get(lo);
			if(a >= 4) {
				l1 = Math.max(l1, lo);
				l2 = Math.max(l2, lo);
			} else if(a >= 2) {
				if(l1 > l2) {
					l2 = Math.max(l2, lo);
				} else {
					l1 = Math.max(l1, lo);
				}
			}
		}
		System.out.println(l1*l2);
	}
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;

int a[N];

int main()
{
      int n, cnt = 0, ans = 0;
      cin >> n;
      for (int i = 1; i <= n; i ++) {
            cin >> a[i];
      }
      sort(a + 1, a + n + 1);
      if (n & 1) cout << 0 << endl;
      else {
            cnt = n / 2 + 1;
            cout << a[cnt] - a[n / 2] << endl;
      }
      return 0;
}











Measured memory_bytes: 640
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

struct Node {
	Node * l;
	Node * r;
	Node () {l = r = NULL;}
};

Node * build(char s[], int l, int r) {
	if (r < l) return NULL;
	Node * p = new Node();
	int cnt = 0;
	for (int i = l + 1; i < r; ++i) {
		if (s[i] == '(') {cnt ++; continue;}
		if (s[i] == ')') {cnt --; continue;}
		if (s[i] == ',' && cnt == 0) {
			p->l = build(s, l + 1, i - 1);
			p->r = build(s, i + 1, r - 1);
			break;
		}
	}
	return p;
}

Node * getInter(Node * a, Node * b) {
	Node * p = new Node();
	if (a->l != NULL && b->l != NULL) {
		p->l = getInter(a->l, b->l);
	}
	else p->l = NULL;
	if (a->r != NULL && b->r != NULL) {
		p->r = getInter(a->r, b->r);
	}
	else p->r = NULL;
	return p;
}

Node * getUnion(Node * a, Node * b) {
	Node * p = new Node();
	if (a != NULL && b != NULL) {
		if (a->l != NULL || b->l != NULL) {
			p->l = getUnion(a->l, b->l);
		}
		else p->l = NULL;
		if (a->r != NULL || b->r != NULL) {
			p->r = getUnion(a->r, b->r);
		}
		else p->r = NULL;
	} else if (a == NULL) {
		if (b->l != NULL) p->l = getUnion(NULL, b->l);
		else p->l = NULL;
		if (b->r != NULL) p->r = getUnion(NULL, b->r);
		else p->r = NULL;
	} else {
		if (a->l != NULL) p->l = getUnion(a->l, NULL);
		else p->l = NULL;
		if (a->r != NULL) p->r = getUnion(a->r, NULL);
		else p->r = NULL;
	}
	return p;
}

string getStr(Node * p) {
	if (p == NULL) {
		return "";
	}
	else return "(" + getStr(p->l) + "," + getStr(p->r) + ")";
}

char a[3000], b[3000];

int main() {
	char op;
	while (scanf("%c %s %s", &op, a, b) != EOF) {
		getchar();
		int la = strlen(a), lb = strlen(b);
		Node * ra = build(a, 0, la - 1);
		Node * rb = build(b, 0, lb - 1);
		Node * root = NULL;
		if (op == 'i') root = getInter(ra, rb);
		else root = getUnion(ra, rb);
		string res = getStr(root);
		printf("%s\n", res.c_str());
	}
	return 0;
}

/*
i ((,),(,)) ((,(,)),)
u ((,),(,)) ((,(,)),)
i (((,),),) (,(,(,)))
u (((,),),) (,(,(,)))
*/

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	ll n,s;
	ll ans=-1;
	cin>>n>>s;
	ll r=(ll)sqrt(n)+1LL;
	for(ll i=2;i<r;i++)
	{
		ll cp=n;
		ll temp=0;
		while(cp!=0)
		{
			temp+=cp%i;
			cp/=i;
		}
		if(temp==s)
		{
			ans=i;
			break;
		}
		//cerr<<i<<" "<<temp<<endl;
	}
	if(ans==-1)
	{
		ll mm=1e15-1;
		//2ケタの探索
		for(ll p=1;p<r;p++)
		{
			ll q=s-p;
			ll i=(n-q)/p;
			if(i<r)
				continue;
			ll cp=n;
			ll temp=0;
			while(cp!=0)
			{
				temp+=cp%i;
				cp/=i;
			}
			if(temp==s)
			{
				mm=min(i,mm);
			}
		}
		if(mm<1e15-1)
			ans=mm;
	}
	
	if(s==n && ans==-1)
		ans=n+1;
	if(s==1 && ans==-1)
		ans=n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    cout<<(a+b)%24<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

R = [0] * N
L = [0] * N

for i in range(N):
  L[i] = max(A[i], L[i-1])

for i in range(N-1, 0-1, -1):
  R[i] = max(A[i], R[(i+1)%N])

for i in range(N):
  print(max( 0<i and L[i-1], i<N-1 and R[i+1] ))


Measured memory_bytes: 15636
#include <iostream>
#include <cmath>

using namespace std;

#define equals(a, b) (a == b)

class Point {
    public:
        Point() = default;
        Point(double x = 0, double y = 0): x(x), y(y) {}
        Point operator + (Point p) { return Point(x + p.get_x(), y + p.get_y()); }
        Point operator - (Point p) { return Point(x - p.get_x(), y - p.get_y()); }
        Point operator * (double k) { return Point(k * x, k * y); }
        Point operator / (double k) { return Point(x / k, y / k); }
        double abs() { return sqrt(norm()); }
        double norm() { return x * x + y * y; }
        bool operator < (const Point &p) const {
            return x != p.get_x() ? x < p.get_x() : y < p.get_y();
        }
        bool operator == (const Point &p) const {
            return x == p.get_x() && y == p.get_y();
        }
        const double get_x() const { return x; }
        const double get_y() const { return y; }
    private:
        double x = 0;
        double y = 0;
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.get_x() * b.get_x() + a.get_y() * b.get_y();
}

double cross(Vector a, Vector b) {
    return a.get_x() * b.get_y() - a.get_y() * b.get_x();
}

struct Segment {
    Point p1;
    Point p2;
};
typedef Segment Line;

bool is_orthogonal(Vector a, Vector b) {
    return equals(dot(a, b), 0);
}

bool is_orthogonal(Point a1, Point a2, Point b1, Point b2) {
    return is_orthogonal(a1 - a2, b1 - b2);
}

bool is_orthogonal(Segment s1, Segment s2) {
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0);
}

bool is_parallel(Vector a, Vector b) {
    return equals(cross(a, b), 0);
}

bool is_parallel(Point a1, Point a2, Point b1, Point b2) {
    return is_parallel(a1 - a2, b1 - b2);
}

bool is_parallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * r;
}

int
main(int argc, const char *argv[])
{
    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int q;
    cin >> q;
    while (q--) {
        double p0, q0;
        cin >> p0 >> q0;
        Point p{p0, q0};
        Point sp1{x0, y0}, sp2{x1, y1};
        Segment s{sp1, sp2};
        Point r = project(s, p);
        printf("%.10f %.10f\n", r.get_x(), r.get_y());
    }

    return 0;
}

Measured memory_bytes: 3284
#!/usr/bin/python

# AtCoder Beginner Contest 075
# A - One out of Three

from sys import stdin

def solve(A, B, C):
  if A == B: return C
  if A == C: return B
  if B == C: return A
  raise

def splitToInt(line):
  words = line.strip().split()
  return [int(w) for w in words]

A, B, C = splitToInt(stdin.readline())
print(solve(A, B, C))

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, m; cin >> n >> m;
	map<long long, long long> modM;
	long long sum = 0;
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		sum += a;
		modM[sum % m]++;
	}
	modM[0]++;
	long long ans = 0;
	for(auto i = modM.begin(); i != modM.end(); i++){
		ans += i->second * (i->second - 1) / 2;
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 4224
from fractions import gcd
a,b = map(int,input().split())
gcdab = gcd(a, b)
d = {}
j = 2
while j*j<=gcdab:
  while gcdab%j==0:
    gcdab //= j
    if j in d:
      d[j] += 1
    else:
      d[j] = 1
  j += 1
if gcdab>1:
  d[gcdab] = 1
print(len(d)+1)

Measured memory_bytes: 5816
#include<bits/stdc++.h>
using namespace std;
const int N=6005;
char s[N],s1[N],s2[N],ans[N];
int flag[N],n,la[N];
int check(char s1[],int len1,char s2[],int len2){
	for (int i=1;i<=len1&&i<=len2;i++)
		if (s1[i]!=s2[i])return s1[i]>s2[i];
	return len1>=len2;
}
int check2(char s1[],int len1,char s2[],int len2){
	for (int i=1;i<=len1&&i<=len2;i++)
		if (s1[i]!=s2[i])return s1[i]>s2[i];
	return 1;
}
int main(){
	scanf("%d",&n);
	n*=2;
	scanf("%s",s+1);
	int len=0;
	for (int i=1,j=1;i<=n;i=j){
		int cnt=0;
		while (j==i||cnt!=0){
			if (s[j]=='a')cnt++;
			else cnt--;
			j++;
		}
		la[j-1]=i-1;
	}
	for (int i=n,j=n;i;i=j){
		int cnt=0;
		j=la[i];
		int len1=0;
		memset(s1,0,sizeof s1);
		if (s[j+1]=='a'){
			vector<int> p1,p2;
			for (int l=j+1;l<=i;l++)
				if (s[l]=='a')p1.push_back(l);
				else p2.push_back(l);
			int now=0;
			while (now<p1.size()){
				s1[++len1]='a';s1[++len1]='b';
				int k=p2[now];
				while (now<p1.size()&&p1[now]<k)now++;
			}
		}
		else {
			for (int k=1;k<=(i-j)/2;k++){
				memset(flag,0,sizeof flag);
				int cnta=0,cntb=0;
				for (int l=i;l>j;l--)
					if (s[l]=='a'){
						if (cnta<k)flag[l]=1,cnta++;
					}
					else {
						if (cntb<k)flag[l]=1,cntb++;
					}
				int len2=0;
				for (int l=j+1;l<=i;l++)
					if (flag[l])s2[++len2]=s[l];
				if (check(s2,len2,s1,len1)){
					for (int l=1;l<=len2;l++)s1[l]=s2[l];
					len1=len2;
				}
			}
		}
		if (check2(s1,len1,ans,len)){
			for (int l=len;l;l--)ans[l+len1]=ans[l];
			for (int l=1;l<=len1;l++)ans[l]=s1[l];
			len+=len1;
		}
	}
	puts(ans+1);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    println(getPrimeList.filter(_ % 5 == 3).take(sc.nextInt).force.mkString(" "))
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def getPermutation(now: Long = 0): Stream[Long] = {
    Stream.cons(now, getPermutation(now + 1))
  }

  def getPrimeList(): Stream[Long] = {
    getPrimeListRecursive(getPermutation(2))
  }

  def getPrimeListRecursive(A: Stream[Long]): Stream[Long] = {
    Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))
  }

  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 32336
N = int(input())
a = input().split()

int_a = []
for i in range(N):
    int_a.append(int(a[i]))

cnt = 0
for i in range(N):
    if (int_a[i] % 2) == 0:
        t = int_a[i]
        while t > 1:
            if (t % 2) == 0:
                cnt += 1
            t /= 2

print(cnt)

Measured memory_bytes: 4148
mod = 10**9+7
N = int(input())
li = [list(map(int, input().split())) for i in range(N)]
lc = [0] * (1<<N)
dp = [0]*(1<<N)
dp[0] = 1
for S in range(1, 1<<N):
    lc[S] = lc[S>>1]+S%2
    for i in range(N):
        if S>>i&li[lc[S]-1][i] == 1:
            dp[S] = (dp[S]+dp[S-(1<<i)]) %mod
print(dp[(1<<N)-1])

Measured memory_bytes: 75100
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n, m; cin >> n >> m;
  if (n == 1 and m == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  if (n == 1 or m == 1) {
    cout << max(n, m) - 2 << endl;
    return 0;
  }
  
  if (m == 2 or n == 2) {
    cout << 0 << endl;
    return 0;
  }
  
  cout << (n-2) * (m-2) << endl;
  return 0;
}


Measured memory_bytes: 3548
using System;
using System.Linq;

public class Hello{
    public static void Main(){
        // 自分の得意な言語で
        // Let's チャレンジ！！

        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((n[0] * n[1]) + " " +  (2 * n[0] + 2 * n [1]));
    }
}


Measured memory_bytes: 16324
#include <iostream>
#include <cmath>

using namespace std;


int main()
{
    //string S, T;
    int a1, a2, a3;
//    int count = 0;

    //double K, S;
    //double x, y, z;


    cin >> a1 >> a2 >> a3;

   if(a1 + a2 + a3 >= 22){
       cout << "bust" << endl;
   }else {
       cout << "win" << endl;

   }


     return 0;

}



Measured memory_bytes: 256
import std.stdio;
import std.parallelism : parallel;
import std.range : iota;

void main() {
    int n, m, q;
    readf(" %s %s %s", &n, &m, &q);

    auto ans = new int[][](n, n);
    foreach (_; 0..m) {
        int l, r;
        readf(" %s %s", &l, &r);
        foreach (i; parallel(iota(--r, n)))
            ans[l - 1][i]++;
    }
    foreach_reverse (i; 0..n - 1)
        foreach (j; parallel(iota(i, n)))
            ans[i][j] += ans[i + 1][j];

    foreach (_; 0..q) {
        int pi, qi;
        readf(" %s %s", &pi, &qi);
        ans[--pi][--qi].writeln;
    }
}


Measured memory_bytes: 2428
use std::io;
use std::collections::HashSet;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut set = HashSet::new();
	let s:Vec<char> = buf.trim().chars().collect();
	let mut flag = true;
	for i in s {
		if !set.insert(i) {
			flag = false;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
#include<iostream>
#include<math.h>

using namespace std;

int main(void)

{
    long long int a, b, c = 1, i, flag = 0, j;
    cin>>a>>b;
    while(c != 1000000){
        i = c * 0.08;
        j = c * 0.1;
        if(i == a && j == b){
            cout<<c<<endl;
            flag = 1;
            break;
        }
        c++;
    }
    if(flag == 0)
        cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int dp[200005];
signed main() {
    int N,K;
    cin >> N >> K;
    vector<P>cnt(K);
    for(int i = 0; i < K; i++) {
        int L,R;
        cin >> L >> R;
        cnt[i] = {2-R,2-L};
        L++;R++;
        for(int j = L; j <= R; j++) {
            dp[j]++;
        }
    }
    dp[1] = 1;
    int sum = dp[2];
    /*dp[2] = 0;*/
    for(int i = 2; i <= N; i++) {
        dp[i] += sum;
        dp[i] %= mod;
        for(int j = 0; j < K; j++) {
            cnt[j].first++;
            cnt[j].second++;
            if(cnt[j].first-1 >= 1) {
                sum = (sum+mod-dp[cnt[j].first-1])%mod;
            }
            if(cnt[j].second >= 1) {
                sum += dp[cnt[j].second];
                sum %= mod;
            }
        }
    }
    cout << dp[N]*mod_pow(2,mod-2)%mod << endl;
}


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

int Selection(vector<int> a,int N) {
  	int cnt=0;
  	bool flag=false;
    for(int i=0; i<N; i++) {
        int minj = i;
        for(int j=i; j<N; j++) {
            if(a.at(j)<a.at(minj)) {
              minj = j;
              flag=true;
            }
        }
      	if(flag==true) {
          swap(a.at(i), a.at(minj));
          cnt++;
          flag=false;
        }
    }

    for(int i=0; i<N; i++) {
        cout << a.at(i);
        i==N-1? cout<<endl: cout<<' ';
    }
  
  	return cnt;
}

int main() {
    int N;  cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin>>a.at(i);
    cout << Selection(a, N) << endl;
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;
 
ld pot(ld b, ll e){
	ld res = 1;
	while (e){
		if(e&1){
			res *= b;
		}
		b *= b;
		e >>= 1;
	}
	return res;
}

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

	ll n, m, res = 0;
	cin >> n >> m;
	vl vet(n, -1);
	vector<vl> lista(n);
	for(int i = 0; i < m; ++ i){
		ll u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		lista[u].push_back(v);
		lista[v].push_back(u);
	}
	for(int i = 0; i < n; ++i){
		if(vet[i] == -1){
			W(i, "\n")
			res ++;
			queue<ll> fila;
			fila.push(i);
			vet[i] = 0;
			while (!fila.empty()){
				auto a = fila.front();
				fila.pop();
				for(auto&p: lista[a]){
					if(vet[p] == -1){
						fila.push(p);
						vet[p] = vet[a];
					}
				}
			}
		}
	}
	
	cout << res << "\n";

	return 0;
}

// 2^x >= k/i

// s 		= 		p^1 + p^2 + p^3 + p^4 + ... + p^(n-1) + p^n
// s/p 		= p^0 + p^1 + p^2 + p^3 + p^4 + ... + p^(n-1)
// _____________________________________________________________
// s - s/p	= p^n - p^0
// s 		= (p^n - p^0)*p/(p - 1)


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

int n;
int p[100000];
int nx[100000];
bool vis[100000];

int dfs(int v)
{
	vis[v] = true;
	if (p[v] == 0) return nx[v] = v;
	if (vis[v + p[v]]) return nx[v] = nx[v + p[v]];
	return nx[v] = dfs(v + p[v]);
}

int bfs(int v)
{
	static int dist[100000];
	memset(dist, -1, sizeof(dist));
	
	queue<int> q;
	auto push = [&](int t, int c){
		if (~dist[t]) return;
		dist[t] = c;
		q.push(t);
	};
	for (push(0, 0); q.size(); q.pop()){
		int pos = q.front();
		for (int i = pos + 1; i < min(n, pos + 7); i++){
			if (~nx[i]) push(nx[i], dist[pos] + 1);
		}
	}
	return dist[n - 1];
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", p + i);
	
	memset(nx, -1, sizeof(nx));
	for (int i = 0; i < n; i++){
		if (!vis[i]) dfs(i);
	}
	
	printf("%d\n", bfs(0));
}

Measured memory_bytes: 3764
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(A[i] % 2 == 1) {
				cnt++;
			}
		}
		if(cnt % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}


Measured memory_bytes: 51100
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  vector<int> cnt(256);
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]]++;
  }
  for (int i = 0; i < 256; i++) {
    if (cnt[i] % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll X,A;
    cin >>X>> A;

    if (X <A){
        cout << 0 <<endl;
    }else{
        cout << 10 <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l;
  cin >> n >> m >> l;
  long long int a[101][101], b[101][101], c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> b[i][j];
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      c = 0;
      for (int k = 0; k < m; k++) {
        c += a[i][k] * b[k][j];
      }
      if (j != 0) cout << " ";
      cout << c;
    }
    cout << endl;
  }

}


Measured memory_bytes: 3180
s = str(input())
li = list(s)
sum_ = 0
# 2こうえんざんのアルゴリズム。
for i in range(1 << len(s) -1):
    r =''
    for j in range(len(s) ):
        r += li[j]
        if i & (1 << j):
            r += '+'

    sum_ += eval(r)
print(sum_)

Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

N, P = map(int, input().split())

p = factorization(P)
ans = 1

for a, b in p:
    ans *= a ** (b//N)

print(ans)

Measured memory_bytes: 3064
/*input
5
IIDID
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn];
int main()
{
	IOS;
	int x=0;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	REP(i,n){
		if(s[i]=='I') x++;
		else x--;
		ans=max(ans,x);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
# ABC053C - X: Yet Another Die Game (ARC068C)
def main():
    x = int(input())
    ans, r = x // 11 * 2, x % 11  # r: remainder
    if r != 0:
        ans += 1 if x % 11 <= 6 else 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
<?php
  list($n,$m) = explode(" ", trim(fgets(STDIN)));

  $uf = new UnionFind($n);

  for($i=0;$i<$m;$i++){
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    $uf->unite($a,$b);
  }

  $ans=0;
  for($i=1;$i<=$n;$i++){
    $ans=max($ans, $uf->size($i));
  }
  echo $ans;
  
  class UnionFind {
    public $d = [];
    function __construct($n){
      for($i=1;$i<=$n;$i++){
        $this->d[$i] = -1;
      }
    }
    function unite($x, $y){
      $rx = $this->root($x);
      $ry = $this->root($y);
      if($rx == $ry) return;
      //echo $rx." ".$ry." ";
      if($this->size($rx) > $this->size($ry)){
        $this->d[$rx]+= $this->d[$ry];
        $this->d[$ry] = $rx;
        //echo $this->d[$rx].PHP_EOL;
      }else{
        $this->d[$ry]+= $this->d[$rx];
        $this->d[$rx] = $ry;        
        //echo $this->d[$ry].PHP_EOL;
      }
    }
    function root($x){
      //echo $x.PHP_EOL;
      if($this->d[$x] < 0){
        return $x;
      }
      return $this->d[$x] = $this->root($this->d[$x]);
    }
    function size($x){
      return $this->d[$this->root($x)]*-1;
    }
    function isSame($x, $y){
      return $this->root($x) == $this->root($y);        
    }
  }

Measured memory_bytes: 24276
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
// #define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m,k; cin >> n >> m >> k;
    COMinit();
    ll ans = 0;
    reps(i,0,k){
        ll tmp = modpow(m-1, n-1-i, MOD);
        ans += (COM(n-1,i)*m % MOD)* tmp % MOD;
    }
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15600
#include <iostream>
#include <vector>
#include <math.h>
#include <map>

using namespace std;



int main() {
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    for(auto &i: l){
        cin >> i;
    }
    int D = 1;
    int k = 0;
    for(int i = 1; i  <= n;i++){
       k += l[i-1];
       if(k <= x){
           D++;
       }
    }
    cout << D << endl;

}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,al=0,bob=0;
	cin>>n;
	vi a(n);
	REP(i,0,n-1)cin>>a[i];
	sort(a.begin(),a.end(),greater<int>());
	REP(i,0,n-1){
		if(i%2==0){
			al+=a[i];
		}
		else bob+=a[i];
	}
	cout<<al-bob;
	
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

sys.setrecursionlimit(10**8)

#メモ化再帰
def rec(x):
    global dp
    if dp[x]!=-1:
        return dp[x]
    num = 0
    for a in adj[x]:
        num = max(num, rec(a)+1)
    dp[x] = num
    return num

#入力受け取り
N, M = mi()
x = li2(M)

#隣接リスト作成
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])

#メモ化再帰を実行
dp = [-1]*N
for i in range(N):
    rec(i)

print(max(dp))

Measured memory_bytes: 143752
x = int(input())
count = 0

if x <= 6:
    count = 1
else:
    x -= 11
    count += 2
    if x > 0:
        count += (x // 11) * 2
        x %= 11
        if x == 0:
            count += 0
        elif x > 6:
            count += 2
        else:
            count += 1
print(count)

Measured memory_bytes: 3188
X, N = map(int, input().split())
p = list(map(int, input().split()))
small = X
big = X
while True:
    if p.count(X) == 0:
        print(X)
        break
    small -= 1
    big += 1
    if p.count(small) == 0:
        print(small)
        break
    elif p.count(big) == 0:
        print(big)
        break

Measured memory_bytes: 9128