akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int flg2=0;
  while(1){
    int a,b,i,flg=0;
  scanf("%d %d",&a,&b);
  if(a==0&&b==0)break;
  if(flg2==1)printf("\n");
  flg2=1;
  for(i=a;b>=i;i++){
    if((i%400==0)||(i%4==0&&i%100!=0)){
      printf("%d\n",i);
      flg=1;
    }
  }

  if(flg==0){
    printf("NA\n");
  }
  }
  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MOD ((ll)(1e9+7))
#define HS1 ((ll)(137))
#define HS2 ((ll)(1e9+9))
#define ARRS ((ll)(6e5+900))
#define pb push_back
#define mid ((l+r)>>1)
#define PI 3.14159265358979323846

ll a[ARRS];


int main(){
	ll n;
	cin>>n;
	ll pas=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int t=1; t<(1<<n); t++){
		ll p=t;
		ll s=0,pk=1;
		for(int j=0; j<n; j++){
			ll x=p&1;
			if(x){
				s++;
				if(a[j]&1)pk*=2;
				else pk*=1;
			}
			else pk*=3;
			p>>=1;
		}
		if(s&1)pas+=pk;
		else pas-=pk;
	}
	cout<<pas;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	s := []rune(getString())

	now := 0
	for i := 1; i < n; i++ {
		if r := s[i]; r == 'E' {
			now++
		}
	}

	ans := now
	for i := 1; i < n; i++ {
		if s[i] == 'E' {
			now--
		}
		if s[i-1] == 'W' {
			now++
		}
		ans = min(ans, now)
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := 300001
	sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 2432
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[n-1-i];
	if(in[0]!=2){
		cout<<-1<<endl;
		return 0;
	}
	ll l=in[0],r=2*in[0]-1;
	bool h=true;
	loop(i,1,n){
		ll t=r/in[i]*in[i];
		r=t+in[i]-1;
		l=(l+in[i]-1)/in[i]*in[i];
		if(r<l)h=false;
	}
	if(h)cout<<l<<" "<<r<<endl;
	else cout<<-1<<endl;
}









Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    boolean flag = false;
    int n = Integer.parseInt(sc.next());
    for(int i = 1; i <= 9; i++) {
      for(int j = 0; j <= 9; j++) {
        if(i * j == n) flag = true;
      }
    }
    if(flag) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	ll x,y;
	scanf("%lld%lld",&x,&y);
	printf("%s\n",llabs(x-y)<=1?"Brown":"Alice");
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	lia := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		fmt.Scan(&lia[i])
	}
	lib := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&lib[i])
	}
	taosetyau := 0
	total := 0
	a := 0
	for i := 0; i < n; i++ {
		total += taosetyau
		a = lia[i] - taosetyau
		//正面のみの解決
		if a >= lib[i] {
			total += lib[i]
			taosetyau = 0
			// +1にも貢献
		} else if a < lib[i] {
			total += a
			taosetyau = lib[i] - a
			if taosetyau >= lia[i+1] {
				taosetyau = lia[i+1]
			}
		}
	}
	if taosetyau != 0 {
		total += taosetyau
	}
	fmt.Println(total)
}

Measured memory_bytes: 5504
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int n,x=0,a[10001]={0};
	cin>>n;
	long long int i,j,z;
	z=sqrt(n);
	j=0;
	for(i=1;i<=z;i++)
	{
		if(n%i==0)
		{
			j++;
			a[j]=i;
		}
	}
    x=n/a[j];
    x=x+a[j];
	cout<<x-2<<endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
flag = [None] * (N+1)
edges = [[] for j in range(N+1)]

for i in range(N-1):
  u, v, w = map(int, input().split())
  edges[u].append((v, w))
  edges[v].append((u, w))


def dfs(i, color):
  visited = set()
  distances = [float("inf")] * (N + 1)
  stack = [i]
  distances[i] = 0
  flag[i] = color

  while stack:
    u = stack.pop()
    visited.add(u)

    for (v, w) in edges[u]:
      if v not in visited:
        stack.append(v)
        distances[v] = distances[u] + w
        if distances[v] % 2 == 0:
          flag[v] = color

dfs(1, 0)
for u in range(1, N+1):
  if flag[u] == None:
    dfs(u, 1)
    break

for i in range(1, N+1):
  print(flag[i])


Measured memory_bytes: 49492
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize
    }
    let zenbu = pow(ModP(10), n);
    let zeronai = pow(ModP(9), n);
    let kyuunai = pow(ModP(9), n);
    let zeromokyuumonai = pow(ModP(8), n);
    let ans = zenbu - zeronai - kyuunai + zeromokyuumonai;
    println!("{}", ans.0);
}

use num_traits::{pow, One};
use std::ops::{Add, Div, Mul, Sub};

const MODULUS: usize = 1000000007;

#[derive(Clone, Copy, PartialEq, Debug)]
struct ModP(usize);

impl One for ModP {
    fn one() -> Self {
        return ModP(1);
    }
}
impl Add for ModP {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {
        return ModP((self.0 + rhs.0) % MODULUS);
    }
}
impl Sub for ModP {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {
        return ModP((self.0 + MODULUS - rhs.0) % MODULUS);
    }
}
impl Mul for ModP {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        return ModP((self.0 * rhs.0) % MODULUS);
    }
}
impl Div for ModP {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {
        if rhs.0 == 0 {
            panic!("Tried to divide by ModP(0)!");
        }
        let rhs_inv = pow(rhs, MODULUS - 2);
        return self * rhs_inv;
    }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,c;
  cin >> a >> b >> c;
  int64_t d=c-a-b;
  if(4*a*b<d*d && d>0 )cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    int d = c * 3 - a - b;
    int e = a + b - c;
    int f = c * 2 - b;
    int g = c * 2 - a;
    printf("%d %d %d\n", a, b, d);
    printf("%d %d %d\n", c * 3 - a - e, c * 3 - b - f, c * 3 - d - g);
    printf("%d %d %d\n", e, f, g);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<pair<pair<int,int>,pair<int,int> > >pp;
int dp[51][10005];
pair<int,int>city[55];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n,m,s;
  cin>>n>>m>>s;
  fill_n(&dp[0][0],51*10005,1e17);
  s=min(s,9000LL);
  dp[1][s]=0;
  int x,y,a,b;
  for(int i=0;i<m;i++)
  {
    cin>>x>>y>>a>>b;
    pp.push_back({{x,y},{a,b}});
  }
  for(int i=1;i<=n;i++)
  {
    cin>>city[i].first>>city[i].second;
    city[i].first=min(city[i].first,9000LL);
  }
  for(int i=0;i<=10000;i++)
  {
    if(i+city[1].first<=10000)
    dp[1][i+city[1].first]=min(dp[1][i+city[1].first],dp[1][i]+city[1].second);
  }
  for(int ll=0;ll<=m+5;ll++)
  {
    for(auto j:pp)
    {
      for(int i=0;i<=10000;i++)
      {
        if(i+j.second.first<=10000)
        {
          dp[j.first.first][i]=min(dp[j.first.first][i],dp[j.first.second][i+j.second.first]+j.second.second);
          dp[j.first.first][min(10000LL,i+city[j.first.first].first)]=min(dp[j.first.first][min(10000LL,i+city[j.first.first].first)],dp[j.first.first][i]+city[j.first.first].second);
        }
        if(i+j.second.first<=10000)
        {
          dp[j.first.second][i]=min(dp[j.first.second][i],dp[j.first.first][i+j.second.first]+j.second.second);
          dp[j.first.second][min(10000LL,i+city[j.first.second].first)]=min(dp[j.first.second][min(10000LL,i+city[j.first.second].first)],dp[j.first.second][i]+city[j.first.second].second);
        }
      }
    }
  }
  for(int i=2;i<=n;i++)
  {
    int mn=1e18;
    for(int j=0;j<=10000;j++)
      mn=min(mn,dp[i][j]);
    cout<<mn<<'\n';
  }


// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 7768
A, B, C, D = map(int, input().split())


def start(num: int) -> int:
    if A % num == 0:
        num_start = A + (A % num)
    else:
        num_start = A + (num - A % num)
    return num_start


def count_in_range(num_start: int, num: int) -> int:
    r = B - num_start
    return r // num + 1


def calc(num: int) -> int:
    return count_in_range(start(num), num)


def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)


c = calc
print((B - A + 1) - (calc(C) + calc(D) - calc(lcm(C, D))))


Measured memory_bytes: 5076
while True:
    n = int(input())
    if n == 0:
        break
    m = n
    z = 0
    while z**3<=n:
        y = int((n-z**3)**0.5)
        x = n-z**3-y**2
        m = min(x+y+z,m)
        z +=1
    print(m)


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

typedef long long ll;

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

const ll INF = 1LL << 60;

int N;
ll W, weight[110], value[110];

ll dp[110][100100] = { 0 };

int main() {
	cin >> N >> W;
	for(int i=0; i<N; i++) cin >> weight[i] >> value[i];

	for (int i = 0; i < N; i++) {
		for (int sum_w = 0; sum_w <= W; sum_w++) {
			// i番目の品物を選ぶ場合
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}
			// i番目の品物を選ばない場合
			chmax(dp[i+1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
#include <cstdio>
#include <iostream>
using namespace std;
int a[100005];
int main() {
  int n, least = 2;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  ans += a[0] - 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] < least) { continue; }
    if (a[i] == least) {
      ++least; continue;
    }
    ans += (a[i] - 1) / least;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
S = list((input()))
a = int(S[0] + S[1])
b = int(S[2] + S[3])
 
if a > 12 or a < 1:
	if b > 12 or b < 1:
		print('NA')
	else:
		print('YYMM')
else:
	if b > 12 or b < 1:
		print('MMYY')
	else:
		print('AMBIGUOUS')

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, a, b;
    cin >> n >> a >> b;
    cout << ((b - a) % 2 ? "Borys" : "Alice") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
/* created   : 2019-09-23 23:52:16
 * accepted  : 2019-09-24 00:10:02
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  // 1101 1000 0010
  // 0110 0100 0010
  int n, m; cin >> n >> m;
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    q.push(x);
  }
  // 1001 0101 0011 0001
  // 0100 0101 0011 0001
  while (m > 0) {
    int mx = q.top(); q.pop();
    bool ok = 0;
    for (int i = 31; i >= 0; i--) {
      if (mx & (1 << i)) {
        ok = 1;
        mx >>= 1;
        m--;
        q.push(mx);
        break;
      }
    }
    if (!ok) {
      break;
    }
  }
  ll ans = 0;
  while (!q.empty()) {
    ans += q.top(); q.pop();
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define sqrt sqrtl
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;

void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl c;
    cin >> c;
    ld e =  1.0e-14;
    fp((sqrt(a) + sqrt(b) + e < sqrt(c)));
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
p = list(map(int,input().split()))
#print(p[0])
flag = 0

for i in range(N):	
	if p[i] != i + 1 : #iは０からはじまるから＋１する
		flag = flag + 1

if flag <= 2:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 2940
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = (dp[s][j][0][0] + dp[s][j][1][0]) % 100000;
			int sum1 = (dp[s][j][0][1] + dp[s][j][1][1]) % 100000;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][conv[nxt]][0][0] += sum0;
				dp[t][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][conv[nxt + 1]][1][0] += dp[s][j][0][0];
					dp[t][conv[nxt + 1]][1][1] += dp[s][j][0][1];

					dp[t][conv[nxt + 1]][1][0] %= 100000;
					dp[t][conv[nxt + 1]][1][1] %= 100000;

					dp[t][conv[nxt]][1][0] += dp[s][j][1][0];
					dp[t][conv[nxt]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
					dp[t][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[t][conv[nxt]][1][0] += sum0;
				}

				dp[t][conv[nxt]][1][1] += sum1;
			}

			dp[t][conv[nxt]][1][0] %= 100000;
			dp[t][conv[nxt]][1][1] %= 100000;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= 100000;
	}

	printf("%d\n", ret);

	return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  sort(rbegin(a), rend(a));
  long long res = 0;
  for (int i = 0; i < n - 1; ++i) {
    res += a[(i + 1) / 2];
  }
  cout << res << '\n';
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  vector<string> v;
  map<string, ll> m;

  ll n;
  scanf("%lld", &n);

  ll max_count = 0;
  for (ll i = 0; i < n; i++) {
    string s;
    cin >> s;

    m[s] += 1;

    max_count = max(max_count, m[s]);

    if (m[s] == 1) {
      v.emplace_back(s);
    }
  }

  sort(v.begin(), v.end());

  for (auto e : v) {
    if (m[e] == max_count) {
      cout << e << endl;
    }
  }
}


Measured memory_bytes: 25700
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int a, b, c;
   cin >> a >> b >> c;
   bool ok = false;
   for(int i = 1; i < 10001; i++){
	   if ((a * i) % b == c) {
		    ok = true;
		    break;  
		 } 
	 }
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
 }

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  int cnt = 0;
  long long res = 0;
  for (int i=1; i<=9; i++){
      for (int j=i; j<=9; j++){
          long long cnt1 = 0;
          long long cnt2 = 0;
          
          for (int k=1; k<=n; k++){
              string s = to_string(k);
              int frst = s[0]-'0';
              int scnd = s[s.size()-1]-'0';
              if (frst == i && scnd == j){
                  cnt1++;
              }
              if (frst == j && scnd == i){
                  cnt2++;
              }
          }
          if (i == j){
             res += cnt1*cnt2; 
          }else{
              res += 2*cnt1*cnt2;
          }
          
      }
  }
  cout << res;
  return 0; 
}


Measured memory_bytes: 256
n,m = map(int,input().split())
N = [list(list(input())) for _ in range(n)]
#N =[input().split() for _ in range(n)]
M = [list(list(input())) for _ in range(m)]
#M =[input().split() for __ in range(m)]
#print(n,m)
#print(N)
#print(M)

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            #print(N[i+k][j:j+m])
            #print(M[k])
            if N[i+k][j:j+m] != M[k]:
                break
        else:
            print('Yes')
            exit()
    #break
else:
    print('No')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int N;
int F[100][10];
int P[100][11];
int main () {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }
    int ans = INT_MIN;
    for (int k = 1; k < (1 << 10); k++) {
        int r = 0;
        for (int i = 0; i < N; i++) {
            int c = 0;
            for (int j = 0; j < 10; j++) {
                if (F[i][j] && (k & (1 << j))) {
                    c++;
                }
            }
            r += P[i][c];
        }
        ans = max(ans, r);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

conbi = 0

strings = {}
for i in range(n):
  
  notinstr = 1
  s = input()
  l = 0
  for c in s:
    l += 10**(ord(c)-ord('a'))
  #print(l)
  
  if l in strings:
    conbi += strings[l]
    strings[l] += 1
    
  else:
    strings[l] = 1
  
print(conbi)

Measured memory_bytes: 15816
import java.util.*;
import java.io.*;

class Main {
    public static void main( String args[] ) throws IOException {
		long n = 0;
		long a = 0;
		long b = 0;
		long xb = 0;
		long xc = 0;
		long xp = 0;
		long result = 0;

		Scanner scan = new Scanner( System.in );

		n = scan.nextInt();
		a = scan.nextInt();
		b = scan.nextInt();

		xb = scan.nextInt();

		for( int i = 1 ; i < n ; i++ ){
			xc = scan.nextInt();

			xp = (xc - xb);
			if( xp * a < b ){
				result += xp * a;
			}
			else{
				result += b;
			}

			xb = xc;
		}

        System.out.println( result );
    }
}


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

using namespace std;

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, l;
	while (cin >> n >> l, n || l)
	{
		vector<int> ant(n);
		vector<int> direction(n);
		for (int i = 0; i < n; ++i)
		{
			char d;
			int p;
			cin >> d >> p;
			if (d == 'R')
			{
				direction[i] = 1;
			}
			else
			{
				direction[i] = -1;
			}
			ant[i] = p;
		}
		int step = 0;
		int goal = 0;
		while (goal < n)
		{
			for (int i = 0; i < n; ++i)
			{
				if (ant[i] == 0 || ant[i] == l)
				{
					++goal;
				}
			}
			for (int i = 0; i < l; ++i)
			{
				int cnt = 0;
				for (int j = 0; j < n; ++j)
				{
					if (ant[j] == i)
					{
						++cnt;
					}
				}
				if (cnt == 2)
				{
					for (int j = 0; j < n; ++j)
					{
						if (ant[j] == i)
						{
							direction[j] = -direction[j];
						}
					}
				}
			}
			for (int i = 0; i < n; ++i)
			{
				ant[i] += direction[i];
			}
			++step;
		}
		cout << --step << " ";
		for (int i = 0; i < n; ++i)
		{
			if (ant[i] == -1)
			{
				cout << i + 1 << endl;
				goto END;
			}
		}	
		for (int i = 0; i < n; ++i)
		{
			if (ant[i] == l + 1)
			{
				cout << i + 1 << endl;
				goto END;
			}
		}
	END:
		;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1204
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

class Add_Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	long long int ret;
	int num;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		v[place] = Update(place * 2) + Update(place * 2 + 1);
		return v[place];
	}
	void Sum(int a, int b, int place) {
		if (l[place] >= a && r[place] <= b) {
			ret += v[place];
			return;
		}
		if (l[place] > b || r[place] < a) return;
		Sum(a, b, place * 2);
		Sum(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Add_Segment_Tree(int n) {
		n++;
		num = 1;
		while (num < n * 2)num *= 2;
		l.resize(num);
		r.resize(num);
		v.resize(num, 0);
		Left(1);
		Right(1);
	}
	void Add(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] += num;
		if (!update)return;
		place /= 2;
		while (place) {
			v[place] = v[place * 2] + v[place * 2 + 1];
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int Sum(int a, int b) {
		ret = 0;
		Sum(a, b, 1);
		return ret;
	}
};

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

	cin >> N >> M >> K;
	if (M < K)swap(M, K);
	vector<long long int>v(N + 1);
	for (int i = 1; i <= N; i++)cin >> v[i];
	v[0] = -MOD * MOD;
	v.push_back(LLONG_MAX);
	vector<long long int>use(N + 2);
	use[0] = 1;
	use[1] = 1;
	int box = 0;
	Add_Segment_Tree asg(N + 2);
	asg.Add(0, 1, true);
	asg.Add(1, 1, true);
	for (int i = 2; i <= N + 1; i++) {
		if (v[i - 1] - v[i - 2] < K)box = i - 2;
		L = 0;
		R = i;
		while (R - L > 1) {
			int mid = (R + L + 1) / 2;
			if (v[i] - v[mid] < M)R = mid;
			else L = mid;
		}
	//	cout << i << " " << L << " " << box << endl;
		use[i] = asg.Sum(box, L);
		use[i] %= MOD;
		asg.Add(i, use[i], true);
	}
	for (int i = 0; i < N - 1; i++) {
		if (v[i + 2] - v[i] < K) {
			cout << 0 << endl;
			return 0;
		}
	}
	//for (int i = 0; i <= N + 1; i++)cout << i << " " << use[i] << endl;
	cout << use.back() << endl;
	return 0;
}


Measured memory_bytes: 6000
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = INT()

dic = defaultdict(int)
dic[s] = 1
for i in range(2, 10000000):
	if s%2 == 0:
		s = s//2
	else:
		s = 3*s + 1
	if dic[s]:
		break
	dic[s] = i+1
print(i)


Measured memory_bytes: 3952
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
ll calc(ll n){
    for(ll i = 2; ;i++)
        if(i*(i+1)/2 > n)
            return i-1;
}
void solve(){
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i = 2; i*i <= n; i++){
        int cnt = 0;
        while(n%i == 0){
            n /= i;
            ++cnt;
        }
        if(cnt == 0)
            continue;
        ans += calc(cnt);
    }
    if(n != 1)
        ++ans;
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3636
def main():
    H, W = (int(i) for i in input().split())
    A = [input() for i in range(H)]
    dhw = ((0, -1), (0, 1), (-1, 0), (1, 0))
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                for dh, dw in dhw:
                    if h + dh < 0 or H <= h + dh or \
                            w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        break
                else:
                    return print("No")
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
h, w, k = gets.chomp.split.map(&:to_i)
c = Array.new(h) { gets.chomp.chars }

res = 0
0.step(2 ** h - 1) do |ib|
  0.step(2 ** w - 1) do |jb|
    cnt = 0
    0.step(h - 1) do |i|
      0.step(w - 1) do |j|
        if ib & (1 << i) == 0 && jb & (1 << j) == 0 && c[i][j] == "#"
          cnt += 1
        end
      end
    end
    if cnt == k
      res += 1
    end
  end
end
puts res

Measured memory_bytes: 14372
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>
#include <algorithm>

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

inline int min(int a, int b) {
	if (a > b) swap(a, b);
	return a;
}


int main() {
	int a, p, sum;
	
	cin >> a >> p;

	sum = a * 3 + p;

	cout << sum / 2 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cmath>

using namespace std;

int gcd(int a, int b);

int main(void){
    int N, X;
    vector <int> x, y;
    int sub;
    int ans;
    
    cin >> N >> X;
    for(int i = 0; i < N; i++){
        cin >> sub;
        x.push_back(sub);
        y.push_back(abs(X - sub));
    }
    
    sort(y.begin(), y.end());
    
    bool judge = true;
    
    ans = gcd(y[0], y[1]);
    
    for(int i = 2; i < N; i++){
        ans = gcd(ans, y[i]);
    }
    
    cout << ans << "\n";
}

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

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
const double EPS = 1e-10;

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

struct Point{
	double x, y;
	Point(){}
	Point(double x,double y) :x(x), y(y){}
	Point operator+(Point p) {return Point(x+p.x,y+p.y);}
	Point operator-(Point p) {return Point(x-p.x,y-p.y);}
	Point operator*(double k){return Point(x*k,y*k);}
	Point operator/(double k){return Point(x/k,y/k);}
	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}

	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};

typedef Point Vector;
typedef vector<Point> Polygon;

double dot(Vector a,Vector b){
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a,Vector b){
	return a.x * b.y - a.y * b.x;
}

int contains(Polygon g,Point p){
	int n = g.size();
	bool x = false;
	for(int i = 0; i < n; i++){
		Point a = g[i] - p, b = g[(i + 1) % n] - p;
		if(fabs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1;
		if(a.y > b.y) swap(a, b);
		if(a.y < EPS && EPS < b.y && cross(a,b) > EPS ) x = !x;
	}

	return (x ? 2 : 0);
}

int main() {
	Point a, r;
	Polygon v;

	while (cin >> a.x >> a.y) {
		v.clear();
		v.pb(a);
		rep(i, 2) { 
			cin >> a.x >> a.y;
			v.pb(a);
		}
		cin >> r.x >> r.y;

		cout << (contains(v, r) == 2 ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3040
N = int(input())
cnt = [0] * (N+1)
for x in range(1, int(N**0.5)+1):
    for y in range(1, int(N**0.5)+1):
        fxy = x**2 + y**2 + x*y
        if N < fxy: break
        for z in range(1, int(N**0.5)+1):
            f = fxy + z**2 + y*z + z*x
            if N < f: break
            cnt[f] += 1
print(*cnt[1:], sep='\n')

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

int main(){
  int H,W,K;
  cin>>H>>W>>K;
    char C[H][W];
    char T[H][W];
  int cnt=0;
  int ans=0;
  
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            T[i][j]='*';
        }
    }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>T[i][j];
      }
  }

  //cout<<(1<<(H+W))<<endl;
  for(int i=0;i<(1 << (H+W));i++){
    
      for(int l=0;l<H;l++){
        for(int m=0;m<W;m++){
          C[l][m]=T[l][m];
        }
      }    
    
    for(int j=0;j<H+W;j++){
      if(i & (1<<j)){
        //cout<<i<<" "<<j<<endl;
        if(j<H){
          for(int k=0;k<W;k++){
            C[j][k]='*';
          }
        }
        else{
          for(int k=0;k<H;k++){
            C[k][j-H]='*';
          }
        }
      }
    }
    //count black==K? ans++;
    cnt=0;
      for(int l=0;l<H;l++){
        for(int m=0;m<W;m++){
          if(C[l][m]=='#') cnt++;
        }
      } 
    if(cnt==K){
      //cout<<i<<"#"<<endl;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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


static const int N = 100;

int m[N+1][N+1];
int main()
{
    int n,p[N+1];
    cin >> n;

    for(int i=1;i<=n;i++)
    {
        cin >> p[i-1] >> p[i];
    }

    for(int i=1;i<=n;i++)m[i][i]=0;
    int i;
    for(int l=2;l<=n;l++)
    {
        for(int i=1;i<=n-l+1;i++)
        {
            int j=i+l-1;
            m[i][j]=(9999999);
            for(int k=i;k<=j-1;k++)
            {
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
                //cout << "l i j k m[i][j]:" <<l<<" " << i << " " << j << " "<<k<<" "<<m[i][j]<<endl;
            }
        }
    }
    cout <<m[1][n] << endl;

    return 0;
}



Measured memory_bytes: 3136
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n,k,r,s,p;
    map<char,int> point;
    map<char,char> win;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    point['r']=p;point['s']=r;point['p']=s;
    win['r']='p';win['s']='r';win['p']='s';
    int ans=0;
    queue<char> q;
   
    rep(i,n){
        if(i<k){
            ans+=point[t[i]];
            q.push(win[t[i]]);
        }else{
            char preK = q.front(); q.pop();
            if(win[t[i]] != preK|| preK=='a'){
                ans += point[t[i]];
                q.push(win[t[i]]);
            }else {
                q.push('a');
            }
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

struct point {
  double x, y;
};

struct Vector2D {
  double x, y;
};

double dot(Vector2D a, Vector2D b) {
  return a.x * b.x + a.y * b.y;
}

double norm(Vector2D a) {
  return sqrt(a.x*a.x + a.y*a.y);
}

//??´???a = p1->p2 ???????????????p????°???±???c??¨????????¨?????? p1->c ??????????????? b = p1 -> p
//??§?¨??????´?????¨??????p1????¶????
Vector2D project(Vector2D a, Vector2D b) {
  return Vector2D{dot(a, b)/dot(a, a) * a.x, dot(a, b)/dot(a, a) * a.y};
}

signed main(void)
{
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Vector2D v1 = {x2-x1, y2-y1};
  int q;
  cin >> q;
  REP(i, q) {
    double x, y;
    cin >> x >> y;
    Vector2D v2 = {x-x1, y-y1};
    Vector2D ret = project(v1, v2);
    //???????????§?????´?????????
    cout << fixed << setprecision(15) << ret.x + x1 + 0 << " " << ret.y + y1 +  0 << endl;
  }

  return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int input;
    int index = 1;
    unordered_map<int, int> mp;
    while (cin >> input){
        mp[index++] = input;
    }
    
    int count(0);
    for (auto itr = mp.begin(); itr != mp.end(); ++itr){
        if (mp[itr->second] == itr->first){
            count++;
        }
    }
    cout << count/2 << endl;
               
}
       
      


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

LL a, b, c, d;
map<LL, LL> memo;

LL solve(LL n) {
    if (n == 0) return 0;
    if (n == 1) return d;
    if (memo.count(n)) return memo[n];
    LL res = 1e18;
    if (n < res / d) res = n * d;

    LL l2 = (n / 2) * 2;
    res = min(res, llabs(l2 - n) * d + a + solve(l2/2));
    LL r2 = ((n + 1) / 2) * 2;
    res = min(res, llabs(r2 - n) * d + a + solve(r2/2));

    LL l3 = (n / 3) * 3;
    res = min(res, llabs(l3 - n) * d + b + solve(l3/3));
    LL r3 = ((n + 2) / 3) * 3;
    res = min(res, llabs(r3 - n) * d + b + solve(r3/3));

    LL l5 = (n / 5) * 5;
    res = min(res, llabs(l5 - n) * d + c + solve(l5/5));
    LL r5 = ((n + 4) / 5) * 5;
    res = min(res, llabs(r5 - n) * d + c + solve(r5/5));

    memo[n] = res;

    return res;
}

int main() {
    int t; cin >> t;
    for (int i = 0; i < t; i++) {
        memo.clear();
        LL n;
        cin >> n >> a >> b >> c >> d;
        cout << solve(n) << endl;
    }
    return 0;
}


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

int main(){

  int n,count=0;

  while(cin >> n){

    count=0;

    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	for(int s=0;s<10;s++){
	  for(int t=0;t<10;t++){
	    if(i+j+s+t==n) count++;
	  }
	}
      }
    }

    cout << count << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
#define int int64

int gcd(int a,int b){
  return (a%b==0?b:gcd(b,a%b));
}

int lcm(int a,int b){
  return a/gcd(a,b)*b;
}

signed main() {
  int n;cin>>n;
  int ans=1;
  for(int i=0;i<n;++i){
	int t;cin>>t;
    ans=lcm(ans,t);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n;cin>>n;
    vector<vector<double>> v(n*2,vector<double>(3,400));
    rep(i,n)cin>>v[i][1]>>v[i][2];
    rep(i,n){
        if(v[i][1]!=0){
            v[i][0]=atan(v[i][2]/v[i][1])/pi*180;
            if(v[i][2]/v[i][1]<0)v[i][0]+=180;
        }
        else v[i][0]=90;
        if(v[i][2]<0||v[i][2]==0&&v[i][1]<0)v[i][0]+=180;
    }
    sort(all(v));
    rep(i,n){
        v[i+n][0]=v[i][0]+360;
        rep(j,2)v[i+n][j+1]=v[i][j+1];
    }
    vector<double> x(2*n+1),y(2*n+1);
    rep(i,n*2){
        x[i+1]=x[i]+v[i][1];
        y[i+1]=y[i]+v[i][2];
    }
    double ans=0;
    rep(i,n){
        rep(j,n)chmax(ans,(x[i+j+1]-x[i])*(x[i+j+1]-x[i])+(y[i+j+1]-y[i])*(y[i+j+1]-y[i]));
    }
    cout<<fixed<<setprecision(15);
    out(sqrt(ans));
}

Measured memory_bytes: 512
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0 for _ in range(n+2)]
dp[0]=1
for t in a:
	dp[t]=-1
for i in range(n):
	if dp[i]==-1:
		continue
	if dp[i+1]!=-1:
		dp[i+1]=dp[i+1]+dp[i]
	if dp[i+2]!=-1:
		dp[i+2]=dp[i+2]+dp[i]
print(dp[n]%(10**9+7))

Measured memory_bytes: 468916
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
template <typename T>
pair<T, T>& operator+=(pair<T, T>& a, const T& b) {
	a.first += b;
	a.second += b;
	return a;
}
int main() {
	int n;
	scanf("%d", &n);
	vector<vector<int>> ch(n);
	vector<int> V(n);
	for (int i = 1; i < n; ++i) {
		int a;
		scanf("%d%d", &a, &V[i]);
		--a;
		ch[a].push_back(i);
	}
	ll lo = 0, hi = 1LL << 35;
	while (lo < hi) {
		ll M = (lo + hi) >> 1;
		vector<vector<pair<ll, ll>>> L(n);
		for (int i = n - 1; i >= 0; --i) {
			if (ch[i].empty()) {
				L[i] = {{0, 0}};
			} else {
				int x = ch[i][0], y = ch[i][1];
				if (L[x].size() > L[y].size()) swap(x, y);
				for (auto& z : L[x]) z += (ll)V[x];
				for (auto& z : L[y]) z += (ll)V[y];
				int xn = L[x].size(), yn = L[y].size();
				vector<pair<ll, ll>> A, B, C;
				for (int j = 0, k = yn - 1, l = 0; j < xn; ++j) {
					while (k >= 0 && L[x][j].first + L[y][k].first > M) --k;
					while (l < yn && L[x][j].first + L[y][l].second > M) ++l;
					ll mn = LLONG_MAX;
					if (k >= 0) mn = min(mn, L[y][k].second);
					if (l < yn) mn = min(mn, L[y][l].first);
					if (mn != LLONG_MAX) A.emplace_back(L[x][j].second, mn);
				}
				for (int j = xn - 1, k = yn - 1, l = 0; j >= 0; --j) {
					while (k >= 0 && L[x][j].second + L[y][k].first > M) --k;
					while (l < yn && L[x][j].second + L[y][l].second > M) ++l;
					ll mn = LLONG_MAX;
					if (k >= 0) mn = min(mn, L[y][k].second);
					if (l < yn) mn = min(mn, L[y][l].first);
					if (mn != LLONG_MAX) B.emplace_back(L[x][j].first, mn);
				}
				reverse(A.begin(), A.end());
				reverse(B.begin(), B.end());
				C.resize(A.size() + B.size());
				merge(A.begin(), A.end(), B.begin(), B.end(), C.begin());
				for (auto& c : C) {
					if (!L[i].empty() && L[i].back().first <= c.first && L[i].back().second <= c.second) continue;
					L[i].push_back(c);
				}
			}
		}
		if (L[0].empty()) lo = M + 1;
		else hi = M;
	}
	printf("%lld\n", lo);
}


Measured memory_bytes: 25156
import sys
from bisect import bisect_right

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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 not arr:
        arr.append([n, 1])
    
    return arr


def solve():
    N = int(rl())
    
    if N == 1:
        print(0)
        return
    
    acc = [1]
    for i in range(2, 100):
        acc.append(acc[-1] + i)
    
    facts = factorization(N)
    ans = 0
    for fact, exp in facts:
        ans += bisect_right(acc, exp)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 63572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define Max(a,b) max({a,b})
#define Min(a,b) min({a,b})
#define rep(i,m,n) for(int (i)=(m);(i)<(int)(n);(i)++)
#define len(n) n.size()
#define print(n); cout << n << endl;

// s.substr(i,n)

using namespace std;

//char a = 65;

int n,m,a,b,c,cou,co;
double d,k;
char num = 65;
string s,t;

int main(){
    
    cin >> n;
    int ans = 1;

    for(int i = 2;i*i <= n;i++){
        cou = i;
        while(cou <= n){
            ans = max({ans,cou});
            cou *= i;
        }
    }
    print(ans)

    return 0;
}

Measured memory_bytes: 256