akhauriyash/Code-Regression huggingface dataset:
// AOJ ALDS1_15_A Change Making
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, ans;

	scanf("%d", &n);
	ans = n / 25, n %= 25;
	ans += n / 10, n %= 10;
	ans += n / 5, n %= 5;
	ans += n;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2092
from copy import deepcopy


n = int(input())
a_ = list(map(int, input().split()))
b = list(map(int, input().split()))

a = deepcopy(a_)
bef = 0
now = 0
ans = 0
for i in range(n):
    now = b[i]
    if bef >= a[i]:
        ans += a[i]
        bef = now
    else:
        ans += bef
        a[i] -= bef
        if now >= a[i]:
            ans += a[i]
            bef = now - a[i]
        else:
            ans += now
            bef = 0
if bef >= a[n]:
    ans += a[n]
else:
    ans += bef
ans1 = ans
a = deepcopy(a_)
a.reverse()
b.reverse()
bef = 0
now = 0
ans = 0
for i in range(n):
    now = b[i]
    if bef >= a[i]:
        ans += a[i]
        bef = now
    else:
        ans += bef
        a[i] -= bef
        if now >= a[i]:
            ans += a[i]
            bef = now - a[i]
        else:
            ans += now
            bef = 0
if bef >= a[n]:
    ans += a[n]
else:
    ans += bef
print(max(ans, ans1))


Measured memory_bytes: 18908
#include<iostream>
#include<vector>
#include<cinttypes>
#include<algorithm>

class union_find {
//	std::vector <T>;
	std::vector<std::int64_t> parent_, size_;

public:
	union_find()
		:parent_{}, size_{} {}

	union_find(std::int64_t n)
		: parent_{}, size_{}{
		
	/*
		data.resize(n);
		for (int i{}; i < data.size(); ++i)
			data[i] = i;
	*/
		parent_.resize(n, -1);
		size_.resize(n, 1);
	}

	auto root(std::int64_t x) {
		if (-1 == parent_[x])
			return x;
		else
			return
				parent_[x] = root(parent_[x]);
	}

	auto size(std::int64_t x) {
		return size_[root(x)];
	}

	auto unite(std::int64_t t, std::int64_t s) {
//		std::cout << "unite:";
		auto x = root(t);
		auto y = root(s);
//		std::cout << x << " " << y << " ";
		if ( x == y )
			return;

		auto sx = size(x);
		auto sy = size(y);
		if (sx > sy) 
			parent_[y] = x;
		else {
			if (sy == sy)
				++size_[ y ];

			parent_[x] = y;
		}

	}

	auto same(std::int64_t t, std::int64_t s){
		return 
			root(t) == root(s);
	}


};

int main() {
	int n, q;
	std::cin >> n >> q;
	union_find uf{ n };

	for (int i{}; i < q; ++i) {
		int c, x, y;
		std::cin >> c >> x >> y;

		if (c == 0)
			uf.unite(x, y);
		else
			std::cout << uf.same(x, y) << "\n";

	}

}


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

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

  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  int succ = true;
  for (int i = 0; i < n - m; ++i) {
    for (int j = 0; j < n - m; ++j) {
      succ = true;
      for (int k = 0; k < m; ++k) {
        for (int l = 0; l < m; ++l) {
          if (b[k][l] != a[i + k][j + l]) {
            succ = false;
            break;
          }
        }
        if (!succ) break;
      }
      if (succ) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  if (succ) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
main = do
  _ <- getLine
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = length $ filter (isValid s) candidates

isValid :: String -> String -> Bool
isValid _ "" = True
isValid s (p:ps) =
  case (dropWhile (/= p) s) of
    [] -> False
    (_:s') -> isValid s' ps

candidates = map (padding.show) [0..999]
  where
    padding s = replicate (3 - (length s)) '0' ++ s

Measured memory_bytes: 2428
N = int(input())
A = list(map(int,input().split()))
T = [-1]*(N+1)
for i in range(N+1):
    if T[A[i]]>=0:
        P1 = T[A[i]]
        P2 = i
        break
    T[A[i]]=i

Q1 = P1
Q2 = P2-P1-1
Q3 = N-P2

MAXN = (N+1)+5
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


for K in range(1,N+2):
    if K==1:
        print(N)
        continue
    X = nCr(N+1,K,p)
    if Q1+Q3>=K-1:
        Y = nCr(Q1+Q3,K-1,p)
    else:
        Y = 0
    if X-Y<0:
        X+=p
    print((X-Y)%p)

Measured memory_bytes: 91060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int x; cin >> x;
    if (x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		
		 long a =scn.nextLong();
		 long b =scn.nextLong();
		 long c = scn.nextLong();
		  
		  if((a+b)>=c){
			  System.out.println("No");
			  return;
		  }
		  long val1 =4*(a*b);
		  long val2 = c-(a+b);
		  val2*=val2;
		  
		  
		  if(val1<val2){
			  System.out.println("Yes");
		  }else{
			  System.out.println("No");
		  }
		  
		  

	}

}

Measured memory_bytes: 21844
_10to2' :: Int -> String
_10to2' 0 = "0"
_10to2' 1 = "1"
_10to2' n 
 | digit == 0  = _10to2' rem ++ "0"
 | otherwise   = init (_10to2' (n-1)) ++ "1"
 where (rem, digit) = divMod n (-2)
 
main = putStrLn =<< _10to2'.read <$> getLine

Measured memory_bytes: 508
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

void DpFunc(long long dp[110000][3],int n,int a[],int b[],int c[]){
    for(int i=0;i<3;i++){
        if(i==0){
            if(dp[n-1][1]>dp[n-1][2]){
                dp[n][0]=dp[n-1][1]+a[n];
            }else{
                dp[n][0]=dp[n-1][2]+a[n];
            }
        }
        if(i==1){
            if(dp[n-1][0]>dp[n-1][2]){
                dp[n][1]=dp[n-1][0]+b[n];
            }else{
                dp[n][1]=dp[n-1][2]+b[n];
            }
        }
        if(i==2){
            if(dp[n-1][0]>dp[n-1][1]){
                dp[n][2]=dp[n-1][0]+c[n];
            }else{
                dp[n][2]=dp[n-1][1]+c[n];
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    int a[110000],b[110000],c[110000];
    
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    
    /*  dp[x][y]:=x日目にy(a,b or c)を取った場合の幸福度の最大値　*/
    long long dp[110000][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    
    for(int i=0;i<n;i++){
        DpFunc(dp,i,a,b,c);
    }
    long long ans = max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <list>
#include <algorithm>
#include <stack>
#include <vector>
#include <string>
using namespace std;

int main(){
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for(int i=0; cin>>ch; i++){
        if(ch == '\\') S1.push(i);
        else if(ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            sum += i - j;
            int a = i - j;
            while((S2.size() > 0) && (S2.top().first > j)){
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }
    
    vector<int> ans;
    while(S2.size() > 0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i=0; i<ans.size(); i++){
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    
    return 0;
}


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

using namespace std;

stack<int> stk;

int main()
{
  string s;
  while(cin >> s) {

    if (s == "+") {
      int b = stk.top();
      stk.pop();
      int a = stk.top();
      stk.pop();
      stk.push(a + b);
    }
    else if (s == "-") {
      int b = stk.top();
      stk.pop();
      int a = stk.top();
      stk.pop();
      stk.push(a - b);
    }
    else if (s == "*") {
      int b = stk.top();
      stk.pop();
      int a = stk.top();
      stk.pop();
      stk.push(a * b);
    }
    else {
      stk.push(atoi(s.c_str()));
    }
  }
  cout << stk.top() << endl;
  return 0;
}



Measured memory_bytes: 3160
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

import itertools
plist = list(itertools.permutations([i+1 for i in range(n)]))

count = 1

resultp = 0
resultq = 0

for pp in plist:
    if(list(pp) == p):
        resultp = count
    if (list(pp) == q):
        resultq = count
    count += 1

print(abs(resultp - resultq))

Measured memory_bytes: 8052
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n+1]
    }

    if n == 0 && a[0] != 1 {
        println!("-1");
        std::process::exit(0)
    }

    let s = a.iter().sum::<usize>();
    let mut node = 1usize;
    let mut leave = 0usize;
    let mut ans = 0usize;

    for (i, j) in a.windows(2).map(|x| (x[0], x[1])) {
        // dbg!(node, leave, i, j, ans, "\n");
        ans += node;
        if i > node {
            println!("-1");
            std::process::exit(0)
        }
        node -= i;
        leave += i;
        if j > node * 2 {
            println!("-1");
            std::process::exit(0)
        } else {
            node = min(s - leave, node * 2);
        }
    }
    ans += node;

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


Measured memory_bytes: 3756
import numpy as np
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

#めぐる式二分探索
def is_ok(i):
    su = 0
    for a in A:
        su += (a-1) // i
    if su <= K:
        return True
    else:
        return False

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(meguru_bisect(0, max(A) + 1))

Measured memory_bytes: 49556
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] lineKNQ = sc.nextLine().split(" ");
    	int intPersons = Integer.parseInt(lineKNQ[0]);
    	int initScore = Integer.parseInt(lineKNQ[1]);
    	int countMatch = Integer.parseInt(lineKNQ[2]);
    	
    	int Scores[] = new int[intPersons];
    	for(int i = 0;i<intPersons;i++) {
    		Scores[i] = 0;
    	}
    	for(int i =1;i<=countMatch;i++) {
    		int winner = Integer.parseInt(sc.nextLine());
    		Scores[winner -1]++;
    	}
    	for(int i = 0;i<intPersons;i++) {
    		int tmp = Scores[i] - countMatch + initScore;
    		if(tmp > 0) {
    			System.out.println("Yes");
    		}else {
    			System.out.println("No");
    		}
    	}
    }
}

Measured memory_bytes: 99004
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  for(int i = 0;i < s.size();i++) {
    s[i] -= 3;
    if(s[i] < 'A') {
      s[i] += 26;
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3168
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
LL ans;
int n,f[20][20];
char s[40],a[20],b[20];
int main()
{
	re(n);
	scanf("%s",s);
	for(int i=0;i<(1<<n);++i)
	{
		int aa=0,bb=0;
		for(int j=0;j<n;++j)
			if(i>>j&1)a[++aa]=s[j];
			else b[++bb]=s[j];
/*		for(int j=1;j<=aa;++j)putchar(a[j]);
		puts("");
		for(int j=1;j<=bb;++j)putchar(b[j]);
		cerr<<aa<<" "<<bb<<endl;*/
		memset(f,0,sizeof f);
		f[0][0]=1;
		for(int j=0;j<=aa;++j)
			for(int k=0;k<=bb;++k)if(j<aa || k<bb)
			{
//				putchar(s[n+n-j-k-1]);
//				printf(" %d %d\n",j,k);
				if(s[n+n-j-k-1]==a[j+1])f[j+1][k]+=f[j][k];
				if(s[n+n-j-k-1]==b[k+1])f[j][k+1]+=f[j][k];
			}
/*		for(int j=0;j<=aa;++j,puts(""))
			for(int k=0;k<=bb;++k)
				printf("%d ",f[j][k]);*/
		ans+=f[aa][bb];
//		return 0;
	}
	printf("%lld\n",ans);
}

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

  val Array(h, w, n) = readLine.trim.split(' ').map(_.toInt)
  val Array(sy, sx) = readLine.trim.split(' ').map(_.toInt)
  val s = readLine.trim
  val t = readLine.trim
  var left = 1
  var right = h
  println(if (canDrop(s, t)) "YES" else "NO")
  def canDrop(s: String, t: String): Boolean = {
    @tailrec def canDropRow(s: List[Char], t: List[Char], safeLeft: Int, safeRight: Int): Boolean = {
      if (safeLeft > safeRight) return true
      val (newLeft, newRight, tx) = t match {
        case 'R'::ts ⇒ (math.max(1, safeLeft - 1), safeRight, ts)
        case 'L'::ts ⇒ (safeLeft, math.min(safeRight + 1, w), ts)
        case _::ts ⇒ (safeLeft, safeRight, ts)
        case Nil ⇒ return sx < safeLeft || safeRight < sx
      }
      s match {
        case 'R'::ss ⇒ canDropRow(ss, tx, newLeft, newRight - 1)
        case 'L'::ss ⇒ canDropRow(ss, tx, newLeft + 1, newRight)
        case _::ss ⇒ canDropRow(ss, tx, newLeft, newRight)
        case Nil ⇒ ???
      }
    }
    @tailrec def canDropColumn(s: List[Char], t: List[Char], safeUp: Int, safeBottom: Int): Boolean = {
      if (safeUp > safeBottom) return true
      val (newUp, newBottom, tx) = t match {
        case 'D'::ts ⇒ (math.max(1, safeUp - 1), safeBottom, ts)
        case 'U'::ts ⇒ (safeUp, math.min(safeBottom + 1, h), ts)
        case _::ts ⇒ (safeUp, safeBottom, ts)
        case Nil ⇒ return sy < safeUp || safeBottom < sy
      }
      s match {
        case 'D'::ss ⇒ canDropColumn(ss, tx, newUp, newBottom - 1)
        case 'U'::ss ⇒ canDropColumn(ss, tx, newUp + 1, newBottom)
        case _::ss ⇒ canDropColumn(ss, tx, newUp, newBottom)
        case Nil ⇒ ???
      }
    }
    val revs = s.reverseIterator.toList
    val revt = t.reverseIterator.toList
    !canDropRow(revs, revt, 1, w) && !canDropColumn(revs, revt, 1, h)
  }
}

Measured memory_bytes: 54860
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int h, w; cin >> h >> w; std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];
	
	std::vector<bool> A(h, true), B(w, true);
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++) if(s[i][j] == '#') A[i] = false;
		
	for(int i = 0; i < w; i++)
		for(int j = 0; j < h; j++) if(s[j][i] == '#') B[i] = false;
		
	for(int i = 0; i < h; i++) {
		if(A[i]) continue;
		for(int j = 0; j < w; j++) {
			if(B[j]) continue;
			cout << s[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int n,i,j,f;
double x[1<<10],y[1<<10],X,Y,d,e,P=0.1;

int main() {
  auto dist=[](double a,double b){return a*a+b*b;};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf%lf",&x[i],&y[i]);
		X+=x[i];Y+=y[i];
	}
	X/=n;Y/=n;
	for(i=0;i<30000;i++){
		f=0;
		d=dist(X-x[0],Y-y[0]);
		for(j=1;j<n;j++){
			e=dist(X-x[j],Y-y[j]);
			if(d<e)d=e,f=j;
		}
		X+=(x[f]-X)*P;
		Y+=(y[f]-Y)*P;
		P*=0.999;
	}
	printf("%.10lf",sqrt(d));
}

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

int N,inf = 1e9;
bool row[510] = {},col[510] = {};
int cnt_row[510] = {},cnt_col[510] = {};//列，行'.'の数
char F[510][510];
int main(){
    cin >> N;
    int cnt = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cin >> F[i][j];
            if(F[i][j]=='#'){
                col[j] = true;
                row[i] = true;
                cnt++;
            }else{
                cnt_row[i]++;
                cnt_col[j]++;
            }
        }
    }
    if(cnt==0){
        cout << -1 << endl;
        return 0;
    }
    int mi = inf;
    for(int i=1;i<=N;i++){
        int p = 0;
        for(int j=1;j<=N;j++){
            if(F[i][j]=='.' && !col[i]) p = 1;
        }
        mi = min(mi,cnt_row[i]+p);
    }
    int ans = mi;
    for(int j=1;j<=N;j++) if(cnt_col[j]!=0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <stdlib.h>
 
int main() {
    int X;
    cin >>X;
    int A=400,B=599;
    for(int i=8;0<i;i--){
    if(A+200*(8-i)<=X&&X<=B+200*(8-i)){
        cout << i <<endl;
    }
    }

}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
c = 1000
dp = [0] * n
for i in range(n):
    if i == 0:
        dp[0] = 1000
        continue
    m = dp[i - 1]
    for j in range(i):
        x = dp[j] // a[j]
        y = dp[j] % a[j]
        z = a[i] * x
        #print(x, y, z)
        m = max(m, y + z)
    dp[i] = m
    #print(dp)
print(dp[n - 1])

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

using namespace std;

int n, m, sol;
int height[100005];
vector<int> graph[100005];

int main()
{

    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> height[i];
    sol = n;

    while(m--){
        int x, y;
        cin >> x >> y;

        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    for(int i = 1; i <= n; ++i){
        for(auto it:graph[i]){
            if(height[i] <= height[it]){
                --sol;
                break;
            }
        }
    }

    cout << sol;

    return 0;
}


Measured memory_bytes: 9176
<?php
// https://atcoder.jp/contests/abc144/tasks/abc144_b
// 入力された値が9*9の範囲で表現できるかどうかを判定する

//整数Nの入力を受け付ける
$N = intval(fgets(STDIN));

//99の範囲を指定
$Numset = array(1,2,3,4,5,6,7,8,9);

//答えを準備
$ans = "No";

//変数Numsetをforeachで分解
foreach ($Numset as $num) {
  //変数Nに対して1~9の割り算を行う
  $data = $N / $num;

  //変数Nの割り算した結果が整数かつ、1以上、9以下である時、変数ansにYesを代入する
  if(is_int($data) && $data >= 1 && $data <= 9){
    $ans = "Yes";
  }
}

// 答えを出力する
echo $ans."\n";

Measured memory_bytes: 4728
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e18+7;
const ll N = 5e5+5, inf = 1e18+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/all>
using namespace atcoder;

ll get_k(ll x, ll y) {
  auto res = crt({0, y-1}, {x, y});
  return (res.first != 0) ? res.first : inf;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll n; cin >> n;
  n *= 2;
  ll best_k = inf;

  for (ll x = 1; x*x <= n; x++) {
    if (n % x == 0) {
      best_k = min(best_k, get_k(x, n/x));
      if (n/x != x) {
        best_k = min(best_k, get_k(n/x, x));
      }
    }
  }

  cout << best_k << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdint>
#include <unordered_map>

int main() {
  const std::unordered_map<std::int_fast64_t, std::int_fast64_t> power = {
    {2, 0},
    {3, 1},
    {4, 2},
    {5, 3},
    {6, 4},
    {7, 5},
    {8, 6},
    {9, 7},
    {10, 8},
    {11, 9},
    {12, 10},
    {13, 11},
    {1, 12},
  };

  std::int_fast64_t a, b;
  std::cin >> a >> b;
  const std::int_fast64_t a_power = power.at(a);
  const std::int_fast64_t b_power = power.at(b);
  std::cout << (a_power > b_power ? "Alice" : a_power < b_power ? "Bob" : "Draw") << std::endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
road = [[] for _ in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    road[A].append(B)
    road[B].append(A)
# print(road)


ans = [-1] * (N + 1)
ans[1] = 0
ans[0] = 0
stack = deque([1])
def dfs():
    while len(stack) > 0:
        now = stack.popleft()
        for r in road[now]:
            if ans[r] == -1:
                ans[r] = now
                stack.append(r)
dfs()

temp = set(ans)
# 更新されていないもの(部屋に行けないもの)が一つでもあれば，"No"
if ((-1) in temp):
    print("No")
else:
    print("Yes")
    for a in ans[2:]:
        print(a)


Measured memory_bytes: 36296
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
struct Edge
{
	int to;
	int nxt;
}e[205];
int n,edgenum,head[105],pa[105],dep[105],maxd;
ll f[105],d[105];
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
void dfs(int node)
{
	d[node]=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		pa[to]=node;
		dep[to]=dep[node]+1;
		dfs(to);
		d[node]++;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	int ans1=n;
	ll ans2=1e18;
	for(int i=1;i<=n;i++)
	{
		pa[i]=0;
		dep[i]=0;
		dfs(i);
		memset(f,0,sizeof(f));
		maxd=0;
		for(int j=1;j<=n;j++)
		{
			maxd=max(maxd,dep[j]);
			f[dep[j]]=max(f[dep[j]],d[j]);
		}
		ll s=1;
		for(int j=0;j<maxd;j++)s*=f[j];
		if(maxd<ans1)
		{
			ans1=maxd;
			ans2=s;
		}
		else if(maxd==ans1&&s<ans2)ans2=s;
	}
	for(int i=1;i<=edgenum;i+=2)
	{
		int u=e[i].to;
		int v=e[i+1].to;
		pa[u]=v,pa[v]=u;
		dep[u]=dep[v]=0;
		dfs(u);
		dfs(v);
		memset(f,0,sizeof(f));
		maxd=0;
		for(int j=1;j<=n;j++)
		{
			maxd=max(maxd,dep[j]);
			f[dep[j]]=max(f[dep[j]],d[j]);
		}
		ll s=2;
		for(int j=0;j<maxd;j++)s*=f[j];
		if(maxd<ans1)
		{
			ans1=maxd;
			ans2=s;
		}
		else if(maxd==ans1&&s<ans2)ans2=s;
	}
	printf("%d %lld\n",ans1+1,ans2);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
#define compress(a) \
    do{ sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }while(0);
// }}}

struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

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

    vector<int> a(N);
    vector<int> d;

    auto comp = [](int v) {
        return (v == 0) ? 0 : (v < 0) ? -1 : 1;
    };

    cin >> a[0];
    rep(i, 1, N) {
        cin >> a[i];
        int c = comp(a[i] - a[i-1]);
        if (c != 0) d.push_back(c);
    }

    if (d.empty()) {
        cout << 1 << endl;
    } else {
        int ans = 1;
        for (int i = 1; i < d.size(); ++i) {
            if (d[i] != d[i-1]) ++ans, ++i;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1276
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
#[allow(dead_code)]
const INF: u64 = 1000000007;


fn main() {
    input!{
        v: [usize; 3]
    }
    let mut v = v;
    v.sort();

    println!("{}", if v[0]==5 && v[1]==5 && v[2]==7 {
        "YES"
    } else {
        "NO"
    });
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
typedef long long ll;
typedef long double ld;
const int MINI INT_MIN;
const ll MINL LLONG_MIN;
int n,m,a,b,g,hello;
int h[maxn],ans=0,dd[maxn];
vector<int> ct[maxn];
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    for (int i=1;i<=n;i++){
        cin>>h[i];
    }
    for (int i=1;i<=m;i++){
        cin>>a>>b;
        ct[a].push_back(b);
        ct[b].push_back(a);
    }
    for (int i=1;i<=n;i++){
        int l=ct[i].size();
        if (l==0) ans++;
        else{
            bool ck=true;
            for (int j=0;j<l;j++){
                if (h[ct[i][j]]<h[i]){
                    a=hello;
                }
                else{
                    ck=false;
                    break;
                }
            }
            if (ck) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=703;
 
inline int Get(int x){ return x*(x-1)>>1;}
 
int num[3],n,m,ans=1<<30,uu,vv,col[N],now;
bool f[N][N],g[N][N];
 
bool dfs(int x,int c){
	col[x]=c,num[c]++;
	
	for(int i=1;i<=n;i++) if(!g[x][i])
	    if(!col[i]){ if(!dfs(i,3-c)) return 0;}
	    else if(col[i]==c) return 0;
	
	return 1;
}
 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	    scanf("%d%d",&uu,&vv),g[uu][vv]=g[vv][uu]=1;
	
	f[0][0]=1;
	for(int i=1;i<=n;i++) g[i][i]=1;
	
	for(int i=1;i<=n;i++) if(!col[i]){
		num[1]=num[2]=0;
		if(!dfs(i,1)){ puts("-1"); return 0;}
		
		now++;
		for(int j=0;j<=n;j++) if(f[now-1][j]) f[now][j+num[1]]=f[now][j+num[2]]=1;
	}
	
	for(int i=0;i<=n;i++) if(f[now][i]) ans=min(ans,Get(i)+Get(n-i));
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using lint = long long;
using ld = long double;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(lint i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n;
	cin >> h >> w >> n;
	pint sp;
	cin >> sp.first >> sp.second;
	sp.first--; sp.second--;
	string s, t;
	cin >> s >> t;

	pint cp = sp;
	REP(i, n) {
		if(s[i] == 'L') {
			cp.second--;
			if(cp.second < 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
		if(t[i] == 'R') {
			if(cp.second < w - 1) {
				cp.second++;
			}
		}
	}

	cp = sp;
	REP(i, n) {
		if(s[i] == 'R') {
			cp.second++;
			if(cp.second >= w) {
				cout << "NO" << endl;
				return 0;
			}
		}
		if(t[i] == 'L') {
			if(cp.second > 0) {
				cp.second--;
			}
		}
	}

	cp = sp;
	REP(i, n) {
		if(s[i] == 'U') {
			cp.first--;
			if(cp.first < 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
		if(t[i] == 'D') {
			if(cp.first< h - 1) {
				cp.first++;
			}
		}
	}

	cp = sp;
	REP(i, n) {
		if(s[i] == 'D') {
			cp.first++;
			if(cp.first >= h) {
				cout << "NO" << endl;
				return 0;
			}
		}
		if(t[i] == 'U') {
			if(cp.first > 0) {
				cp.first--;
			}
		}
	}

	cout << "YES" << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
vector<int>G[maxn];
int in[maxn],out[maxn],tol;
int sz[maxn],S[maxn],is[maxn],son[maxn];
void get_cal(int v,int fa,int limit)
{
	son[v]=0;
	if(v>=limit)
		return;
	son[v]=1;
	for(int i=G[v].size()-1;i>=0;i--)
	{
		int u=G[v][i];
		if(u==fa)
			continue;
		get_cal(u,v,limit);
		son[v]+=son[u];
	}
}
void get_order(int v,int fa,int mx)
{
	is[v]=mx;
	for(int i=G[v].size()-1;i>=0;i--)
	{
		int u=G[v][i];
		if(u==fa)
			continue;
		if(is[v]>is[fa]||v>is[v])
			get_cal(u,v,is[v]);
		sz[u]=son[u];
	}
	for(int i=G[v].size()-1;i>=0;i--)
	{
		int u=G[v][i];
		if(u==fa)
			continue;
		get_order(u,v,max(mx,v));
	}
}
void dfs(int v,int fa)
{
	S[v]++;
	for(int i=G[v].size()-1;i>=0;i--)
	{
		int u=G[v][i];
		if(u==fa)
			continue;
		S[v]+=sz[u];
	}
	for(int i=G[v].size()-1;i>=0;i--)
	{
		int u=G[v][i];
		if(u==fa)
			continue;
		S[u]=S[v]-sz[u];
		dfs(u,v);
	}
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	get_order(1,0,0);
	dfs(1,0);
	for(int i=2;i<=n;i++)
		printf("%d ",S[i]-1);
	return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 2000000007;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,n)cin >> h[i];
	sort(ALL(h));
	int ans = h[k-1]-h[0];
	rep(i,n-k+1)
	{
		ans = min(ans,h[k-1+i]-h[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A_lst = list(map(int,input().split()))
S = Counter(A_lst)
sums = 0
for i in S.keys():
    if S[i] > 1:
        sums += combinations_count(S[i], 2)

for j in range(1, N + 1):
    if S[A_lst[j-1]] == 2:
        print(sums - 1)
    elif S[A_lst[j-1]] > 2:
        print(int(sums - S[A_lst[j-1]] * (S[A_lst[j-1]]-1) * 0.5 + (S[A_lst[j-1]] - 1) * (S[A_lst[j-1]] - 2) * 0.5))
    else:
        print(sums)

Measured memory_bytes: 117156
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

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


using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}

int32_t main(){
    fast;
    int n;    cin>>n;
    int tot=0;
    vector<int> v1(n),v2(n),v3(n-1);
    for(int i=0;i<n;++i){
        cin>>v1[i];
    }
    for(int i=0;i<n;++i){
        cin>>v2[i];
        tot+=v2[i];
    }
    for(int i=0;i<n-1;++i){
        cin>>v3[i];
    }
    for(int i=1;i<n;++i){
        if(v1[i]==(v1[i-1]+1)){
            tot+=v3[v1[i-1]-1];
        }
    }
    cout<<tot;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n, m, k=map(int,input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

j = m
ans = 0

a_acum = [0] + list(accumulate(a_list))
b_acum = [0] + list(accumulate(b_list))

for i in range(n+1):
    if a_acum[i] > k:
        break
    while b_acum[j] > k - a_acum[i] and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)
        

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

long long n, k, suf = 0, pre = 0, mid = 0;
vector<long long> a;

int main() {
  cin >> n >> k;
  a.resize(n);
  for (auto &p : a) cin >> p;
  for (int i = k; i < n; ++i)
    if (a[i] > 0) suf += a[i];
  for (int i = 0; i < k; ++i) mid += a[i];
  long long res = 0;
  for (int i = k; i <= n; ++i) {
    res = max({res, pre + mid + suf, pre + suf});
    if (a[i - k] > 0) pre += a[i - k];
    mid -= a[i - k];
    if (i != n) {
      mid += a[i];
      if (a[i] > 0) suf -= a[i];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
const int mo=1e9+7;
int n,k,a[2000],xb,f[2000],i,j,l,ans;
inline int poww(int x,int y){int ans=1;for(;y;y>>=1,x=1ll*x*x%mo)if(y&1)ans=1ll*ans*x%mo;return ans;}
int main(){
	scanf("%d%d",&n,&k);
	for(i=1;i*i<=n;++i)if(n%i==0){a[++xb]=i;if(i*i<n)a[++xb]=n/i;}
	std::sort(a+1,a+xb+1);
	for(j=1;j<=xb;ans=(ans+1ll*f[j]*(a[j]&1?a[j]:a[j]/2))%mo,++j)
		for(f[j]=poww(k,a[j]+1>>1),l=1;l<j;++l)if(a[j]%a[l]==0)f[j]=(f[j]+mo-f[l])%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  string N;
  cin >> N;
  if (N.at(N.length() - 1) == '3')
  {
    cout << "bon" << endl;
  }
  else if (N.at(N.length() - 1) == '0' || N.at(N.length() - 1) == '1' || N.at(N.length() - 1) == '6' || N.at(N.length() - 1) == '8')
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "hon" << endl;
  }

  return 0;
}


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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            v.push_back(i);
        }
    }
    cout << v.at(k-1) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    sort(all(a));
    sort(all(b));

    int ans=0;
    if(n%2==0){
        int ax=a[n/2]+a[n/2-1];
        int bx=b[n/2]+b[n/2-1];
        ans=bx-ax+1;
    }
    else{
        int ax=a[n/2];
        int bx=b[n/2];
        ans=bx-ax+1;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4828
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,k;
int cf[200000+20],a[200000+20];
void process(){
	rb(i,1,n)
	cf[i]=0;
	rb(i,1,n){
		cf[max(i-a[i],1)]++;
		cf[min(n+1,i+a[i]+1)]--;
	}
	rb(i,1,n)
		cf[i]+=cf[i-1];
	rb(i,1,n){
		a[i]=cf[i];
	}
}
int main(){
	fastio;
	cin>>n>>k;
	rb(i,1,n) cin>>a[i];
	rb(i,1,k){
		bool ok=1;
		rb(j,1,n){
			if(a[j]!=n){
				ok=0;
			}
		}
		if(ok) break;
		process();
	}
	rb(i,1,n)
	cout<<a[i]<<" ";
	return 0;
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
/*vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
int modInverse(int n){ 
return p(n, MOD-2); 
}  
int nCrModPFermat(int n, int r){   
    if(r == 0)  return 1; 
    return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
} 
*/
signed main(){
    fast();
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n  == 4 || n == 5 || n ==7 || n == 9){
        puts("hon");
        return 0;
    }
    if(n == 3){
        puts("bon");
        return 0;
    }
    puts("pon");
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll W,H,x,y;
	double ans;
	cin >> W >> H >> x >> y;
	if((2*x==W)&&(H==2*y)){
		ans = H/2*W;
		out(11) << ans << " " << 1 << endl;
		return 0;
	}else{
		ans = (long double)H/2.00*W;
		out(11) << ans << " " << 0 << endl;
	}
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int n,m,s=0,x,i;
	vector<int>a(105);
	scanf("%d%d",&n,&m);
	for(i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	double d=1.0*s/4/m;
	sort(a.begin(),a.end(),cmp);
	if(a[m-1]<d)
	{
		printf("%s","No");
	}
	else
	{
		printf("%s","Yes");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, m,sum=0,ans=0,i=0,k=0;
	cin >> n ;
	while(i<n){
		cin>>m;
		ans+=m*m;
		sum+=m;
		i++;
	}
	i=0;
	while(1){
		if(n*i*i-2*sum*i>k) break;
		k=n*i*i-2*sum*i;
		i++;
	}
	cout << ans+k << endl;
	return 0;
}

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

int main()
{
  int w, h, n;
  cin >> w >> h >> n;
  int x1, x2, y1, y2;
  x1 = x2 = y1 = y2 = 0;

  for (int i = 0; i < n; i++){
    int a, b, c;
    cin >> a >> b >> c;
    if (c == 1){
      x1 = max(x1, a);
    }
    else if (c == 2){
      x2 = max(x2, w - a);
    }
    else if (c == 3){
      y1 = max(y1, b);
    }
    else {
      y2 = max(y2, h - b);
    }
  }

  if (w < x1 + x2 || h < y1 + y2) cout << 0 << "\n";
  else cout << (w - (x1 + x2)) * (h - (y1 + y2)) << "\n";
}


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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
}






Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n;
	long long int a, b;
	cin >> n >> a >> b;
	int c = 0;
	long long int d;
	for (int i = 0; i < n; i++) {
		cin >> d;
		if (a <= d && d < b) {
		} else {
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans = min(N%K, K-N%K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

input = stdin.readline
import math

def solve():
    n = int(input())
    a = list(input().strip())
    left = 0
    rpos = [i for i in range(n) if a[i] == 'R']
    if not rpos:
        print(0)
        return
    right = len(rpos) - 1
    cnt = 0
    while right >= 0 and left < rpos[right]:
        if a[left] == 'W':
            cnt += 1
            right -= 1
        left += 1
    print(cnt)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 95824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    ll count = 0;
    for (int a = 1; a <= n; ++a) {
        for (int b = 1; b <= (n / a); ++b) {
            int c = n - a * b;
            if (c > 0) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632