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

int main() {
    long double a, b, x;
    cin >> a >> b >> x;
    if (a * a * b / 2 < x) {
        cout << fixed << setprecision(10) << atan2(2 * b - 2 * x / (a * a), a) * 180 / 3.141592653589793238 << endl;
    }
    else {
        cout << fixed << setprecision(10) << atan2(b, 2 * x / (a * b)) * 180 / 3.141592653589793238 << endl;
    }
}

Measured memory_bytes: 256
#abc137d
import heapq

n,m=map(int,raw_input().split())
ab=[]
for i in xrange(n):
 l=map(int,raw_input().split())
 ab.append(l)
ab=sorted(ab,reverse=True)
q=[]
res=0
for i in xrange(1,m+1):
 while ab and ab[-1][0]==i:
  heapq.heappush(q,ab.pop()[1]*(-1))
 if q:
  res-=heapq.heappop(q)
print res


Measured memory_bytes: 19708
from sys import stdin


def main() -> None:
    a, b, k = [int(next_str()) for _ in range(3)]

    for i in range(k):
        if a + i <= b:
            print(a + i)

    for j in range(k - 1, -1, -1):
        if a + k - 1 < b - j:
            print(b - j)


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

H, W = I()

pad_s = ['.'*(W+2)]
for h in range(H):
  pad_s.append('.' + input() + '.')
pad_s.append('.'*(W+2))

for i,ss in enumerate(pad_s):
  for j,s in enumerate(ss):
    if s == '#'\
      and pad_s[i][j+1] == '.'\
      and pad_s[i][j-1] == '.'\
      and pad_s[i+1][j] == '.'\
      and pad_s[i-1][j] == '.':
      print('No')
      exit()

print('Yes')


Measured memory_bytes: 10292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
 
int main() {
  int N, L;
  cin >> N >> L;
  int ans = 100000;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= L) {
      ans = min(ans, c);
    }
  }
  if (ans == 100000) {
    cout << "TLE";
  } else {
    cout << ans;
  }
  return 0;
}

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

int main(){
  
  string S;
  cin >> S;
  
  bool isOK = true;
  int i = 1;
  for(char c:S) {
    if (i % 2 == 1) {
      if (c != 'R' && c != 'U' && c != 'D') {
        isOK = false;
        break;
      }
    } else {
      if (c != 'L' && c != 'U' && c != 'D') {
        isOK = false;
        break;
      }
    }
    i++;
  }
  if (isOK) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 25e3 + 5, K = 4e2 + 5;

int n, m, k, A[N], DP[N][K], PS[N][K], C[N][K], PC[N][K], CNT[K], F[K];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	F[0] = 1;
	for (int i = 1; i < K; i++) F[i] = 1LL * i * F[i - 1] % MOD;
	
	cin >> n >> k >> m;
	int ans = 1LL * (n - m + 1) * Power(k, n - m) % MOD;
	int inv = Power(F[k], MOD - 2);
	for (int i = 0; i < m; i++) cin >> A[i];

	for (int i = 0; i < m; i++) {
		memset(CNT, 0, sizeof CNT);
		int j = i;
		while (j < m && CNT[A[j]] == 0) CNT[A[j++]]++;
		if (j - i == k) die(ans);
	}
	memset(CNT, 0, sizeof CNT);
	int l = 0;
	while (l < m && CNT[A[l]] == 0) CNT[A[l++]]++;
	memset(CNT, 0, sizeof CNT);
	int r = 0;
	while (r < m && CNT[A[m - 1 - r]] == 0) CNT[A[m - 1 - r++]]++;
	bool dup = !(l == m && r == m);	

	PS[0][0] = DP[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < k && j <= i; j++) {
			DP[i][j] = (1LL * DP[i - 1][j - 1] * (k - j + 1) % MOD + PS[i - 1][j]) % MOD;
		}
		for (int j = k - 1; j >= 1; j--) PS[i][j] = (PS[i][j + 1] + DP[i][j]) % MOD;
	}
	if (dup) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < k && j <= i; j++) C[i][j] = (1LL * C[i - 1][j - 1] * (k - j + 1) % MOD + PC[i - 1][j]) % MOD;
			if (i >= m) C[i][r] = (C[i][r] + 1LL * PS[i - m + l][l] * (1LL * F[k - l] * inv % MOD) % MOD) % MOD;
			for (int j = k - 1; j >= 1; j--) PC[i][j] = (PC[i][j + 1] + C[i][j]) % MOD;
		}
	} else {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < k && j <= i; j++) {
				C[i][j] = (1LL * C[i - 1][j - 1] * (k - j + 1) % MOD + PC[i - 1][j]) % MOD;
				if (j >= m) C[i][j] = (C[i][j] + 1LL * DP[i][j] * (1LL * F[k - m] * inv % MOD) % MOD) % MOD;
			}
			for (int j = k - 1; j >= 1; j--) PC[i][j] = (PC[i][j + 1] + C[i][j]) % MOD;
		}
	}
	cout << (ans - PC[n][1] + MOD) % MOD << endl;

	return 0;
}


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

using namespace std;

int main() {
  int N;
  while(cin >> N) {
    int v[N];
    for (int i = 0; i < N; i++) {
      cin >> v[i];
    }
    sort(v, v + N);
    int upper = v[N / 2];
    int lower = v[N / 2 - 1];
    cout << upper - lower << endl;
  }
}


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

int main(void)
{
	int i,n,ans;
	int a[102];
	long int sum = 0;
	double small = 101.0;
	double ave;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d ", &a[i]);
		sum += a[i];
	}
	
	ave = (float)sum/n;
	
	for (i = 0; i < n; i++){
		if (fabs(ave - a[i]) < small){
			ans = i;
			small = fabs(ave - a[i]);
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll int binomialCoeff(ll int n,ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        for (ll int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ll int n;
    cin>>n;
    map<string,int> mp1;
    while(n--)
    {
        string s;
        cin>>s;
        sort(s.begin(), s.end());
        mp1[s]++;
    }
    
    ll int cnt = 0;
    
    for(auto it = mp1.begin(); it != mp1.end(); it++)
    {
        if(it->second > 1)
            cnt += binomialCoeff(it->second, 2);
    }
    cout<<cnt;
}

Measured memory_bytes: 11136
n = int(input())
a = [int(input()) for _  in range(n)]


d = {}
for i in a:
    if i not in d:
        d[i] = 0
        d[i] +=1
    elif i in d:
        if d[i] == 0:
            d[i] +=1
        else:
            d[i] -=1
        
        
l =[]
for i in d.keys():
    if d[i] != 0:
        l.append(d[i])
print(len(l))

Measured memory_bytes: 16268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=200010;
ll f[N];
ll qpow(ll a,int b){
	ll ans=1;
	while(b){
		if(b&1ll) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1ll; 
	}
	return ans;
}
ll C(ll a,ll b){
	return f[a]*qpow(f[b]*f[a-b]%mod,mod-2)%mod;
}
int main(){
	int n,m,a,b;
	ll ans=0;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	if(n==a||b==m) {
		puts("0");return 0;
	}
	f[0]=1;
	for(int i=1;i<=n+m;i++) f[i]=f[i-1]*i%mod;
	ans=C(n+m-2,m-1);
	
	for(int i=1;i<=a;i++)
	ans=(ans-C(n-a+i+b-2,b-1)*C(a-i+1+m-b-2, m-b-1)%mod+mod)%mod;    //   -(...)*C(A-i+1+m-B-2, m-B-1) 
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n);
double absolute(double n);
void input(vector<int>& vec);
void print(vector<int> vec);
void print(vector<double> vec);
int sum(vector<int> vec);
ll sum(vector<ll> vec);
double sum(vector<double> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    ll n;
    cin >> n;
    ll sum=n*(n-1)/2;
    cout << sum << endl;
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

double absolute(double n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<double> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

ll sum(vector<ll> vec)
{
    ll s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

double sum(vector<double> vec)
{
    double s = accumulate(vec.begin(), vec.end(), 0.0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char c[100010];
int n;
int main(){
	scanf("%s",c+1);
	n=strlen(c+1);
	if(c[1]=='0'||c[n]=='1') return 0*puts("-1");
	for(int i=1;i<n;i++){
		if(c[i]!=c[n-i]) return 0*puts("-1");
	}
	int u=n;
	for(int i=n-1;i>=1;i--){
		if(c[i]=='1'){
			printf("%d %d\n",u,i);
			u=i;
		}
		else printf("%d %d\n",u,i);
	}
}

Measured memory_bytes: 1408
def solve(n, k, hs):
    gs = sorted(hs)
    return min(gs[i + k - 1] - gs[i] for i in range(n - k + 1)) 


def main():
    n, k = (int(z) for z in input().split())
    hs = [int(input()) for _ in range(n)]
    res = solve(n, k, hs)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  int c=0;
  rep(i,a){
    rep(j,b){
      if((j/10)>1&&(j%10)>1){
  if(i==(j/10)*(j%10))
    c++;
        }
    }
    }
  cout<<c;
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
s = str(input())
a_count,b_count = 0,0
for i in range(n):
  if s[i] == 'c':
    print('No')
  elif s[i] == 'a':
    if a_count+b_count < a+b:
      print('Yes')
      a_count += 1
    else:
      print('No')
  elif s[i] == 'b':
    if a_count+b_count < a+b and b_count < b:
      print('Yes')
      b_count += 1
    else:
      print('No')

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

int main(){
  int N, L;
  //string str[N];
  string str;
  vector<string> strlist;
  cin >> N >> L;
  for(int i=0;i<N;i++){
  	cin >> str;
	strlist.push_back(str);
  }
  sort(strlist.begin(), strlist.end());
  
  //sort(str, str+N);
  for(int i=0;i<N;i++) cout << strlist[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

// ll modexp(ll x, ll y, ll p)
// {
// 	ll res = 1;
// 	x = x % p;
// 	while (y > 0)
// 	{
// 		if (y & 1)
// 			res = (res * x) % p;
// 		y = y >> 1;
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll mulmod(ll a, ll b)
// {
// 	return ((a % mod) * (b % mod)) % mod;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b) 
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

// ll gcd(ll a, ll b)
// {
// 	if (a == 0)
// 		return b;
// 	else
// 		return gcd(b % a, a);
// }

// ll modInv(ll a) 
// { 
//     ll g = gcd(a, mod); 
//     if (g != 1) 
//         return -1; 
//     else
//         return modexp(a, mod-2, mod); 
// } 


int main()
{
	fastio;
//#ifndef ONLINE_JUDGE   
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	ll n = 0;
	cin >> n;
	vector<ll>v(n);
	for (ll i = 0; i < n; ++i)
		cin >> v[i];
	sort(v.begin(), v.end());
	cout << v[n - 1] - v[0];

	
}



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

public class Main {

	public static void main(String[] args)
			throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		int n[] = new int [101];

		int max=0;
		while (scan.hasNext())
			n[scan.nextInt()]++;

		for(int i=1;i<101;i++)
			max =Math.max(max,n[i]);
		for(int i=1;i<101;i++)
			if(n[i] == max)System.out.println(i);

		}


					}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    ll k;
    cin >> n >> k;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    vector<vector<ll>> dp(50 + 1, vector<ll>(2, -1));
    dp[50][0] = 0;
    for(int i = 49; i >= 0; i--){
        ll mask = 1LL << i;
        ll one = 0, zero = 0;
        for(int j = 0; j < n; j++){
            if(a[j] & mask) one++;
            else zero++;
        }
        if(dp[i + 1][1] != -1){
            dp[i][1] = max(dp[i][1], dp[i + 1][1] + mask * max(one, zero));
        }
        if(dp[i + 1][0] != -1){
            if(k & mask){
                dp[i][1] = max(dp[i][1], dp[i + 1][0] + mask * one);
                dp[i][0] = max(dp[i][0], dp[i + 1][0] + mask * zero);
            }else{
                dp[i][0] = max(dp[i][0], dp[i + 1][0] + mask * one);
            }
        }
    }
    cout << max(dp[0][0] ,dp[0][1]) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
int editDistance(string x,string y){
  int n=x.length(),m=y.length();
  int INF=1LL<<55LL;
  vector<vector<int> > dp(n+1,vector<int>(m+1,INF));
  for(int i=0;i<=n;i++) dp[i][0]=i;
  for(int i=0;i<=m;i++) dp[0][i]=i;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
      dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
      dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(x[i-1]!=y[j-1]));
    }
  }
  return dp[n][m];
}
signed main(){
  string s1,s2;
  cin>>s1>>s2;
  cout<<editDistance(s1,s2)<<endl;
  return 0;
}


Measured memory_bytes: 10840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
LL facctorialMethod(int k);
int main(){
    LL k,a,b;
    cin >> k;
    cin >> a >> b;
    bool err_flg;
    err_flg = true;
    for(int i = a; i <= b; i++) {
        if(i%k == 0){
            err_flg = false;
            cout << "OK" << endl;
            break;
        }
    }
    if(err_flg){
        cout << "NG" << endl;
    }

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n)  for(long long i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll n; cin >> n;
    vector<ll> v(n);
    map<ll,ll>mp;
    ll prefix = 0;
    rep(i,n){
        cin >> v[i]; ++mp[v[i]];
        prefix += v[i];
    }
    ll q; cin >> q;
    rep(i,q){
        ll b, c; cin >> b >> c;
        mp[c] += mp[b];
        //cerr << 1 << ' '; deb(prefix);
        prefix -= b * mp[b];
       // cerr << 2 << ' '; deb(prefix);
        prefix += c * mp[b];
       // cerr << 3 << ' '; deb(prefix);
        mp[b] = 0;
        cout << prefix << '\n';
    }
    return 0;
}


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


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
map<int,int> a1,a2;
ll fns = 1;
const ll mod = 998244353;
vi v[3];
int t[500009];
set<int> ss;
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	ss.insert('R');
	ss.insert('B');
	ss.insert('G');
	int n;cin>>n;
	string s;cin>>s;
	repA(i,0,3*n-1){
		if(s[i]=='R') v[0].pb(i);	
		if(s[i]=='G') v[1].pb(i);	
		if(s[i]=='B') v[2].pb(i);	
	}
	sort(all(v[0]));
	sort(all(v[1]));
	sort(all(v[2]));
	rep(i,n){
		t[max({v[0][i],v[1][i],v[2][i]})]=2;	
		t[min({v[0][i],v[1][i],v[2][i]})]=1;	
		fns = fns*(i+1)%mod;
	}
	rep(i,3*n){
		if(t[i]==1) {
			a1[s[i]]++;
		}
		if(t[i]==2){
			fns = fns*a2[s[i]]%mod;
			a2[s[i]]--;
		}
		if(t[i]==0){
			trav(j,a1) if(j.fst!=s[i]&&j.snd>0){
				fns=fns*j.snd%mod;
				j.snd--;
				trav(k,ss) if(k!=j.fst&&k!=s[i]) a2[k]++;
			}
		}
	}
	cout<<fns;
	return 0;
}



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

int main(){
	int a[3];
	for(int i = 0;i < 3;i++)scanf("%d", &a[i]);
	int x = a[0]*100+a[1]*10+a[2];
	if(x % 4 == 0)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

ll solve(const std::string& S)
{
    char p = '\0';
    return std::accumulate(S.begin(), S.end(), 0, [&](const int a, char c){
        if (p != c)
        {
            p = c;
            return a + 1;
        }
        return a;
    }) - 1;
}

int main(void)
{
    std::string S;
    std::cin >> S;
    std::cout << solve(S) << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc075/tasks/abc075_b

int main() {
    int H, W;
    cin >> H;
    cin >> W;
    string arr[H];
    REP(i, H) cin >> arr[i];

    REP(i, H) {
        REP(j, W) {
            int cnt = 0;
            if (arr[i][j] == '#') {
                cout << "#";
            } else {
                REP(k, 8) {
                    int nx = j+dx8[k];
                    int ny = i+dy8[k];
                    if (nx >= 0 && nx < W && ny >= 0 && ny < H) {
                        if (arr[ny][nx] == '#') cnt++;
                    }
                }
                cout << cnt;
            }
        }
        cout << "\n";
    }

    return 0;
}


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

int main()
{
	string s;
	string ans;
	int z,count=0;
	cin >> s;
	cin >> z;
	for (ans = 'a'; ans[0] <= 'z'; ans[0]++) {
		for (int a = 0; a < s.size(); a++) {
			if (s.substr(a, 1) == ans) {
				count++;
				if (z == count)goto breakpoint;
				if (s.size()-a >= 2) {
					for (ans += 'a'; ans[1] <= 'z'; ans[1]++) {
						for (int b = 0; b < s.size() - 1; b++) {
							if (s.substr(b, 2) == ans) {
								count++;
								if (z == count)goto breakpoint;
								if(s.size()-b>=3){
									for (ans += 'a'; ans[2] <= 'z'; ans[2]++) {
									for (int c = 0; c < s.size() - 2; c++) {
										if (s.substr(c, 3) == ans) {
											count++;
											if (z == count)goto breakpoint;
											if(s.size()-c>=4){
												for (ans += 'a'; ans[3] <= 'z'; ans[3]++) {
												for (int d = 0; d < s.size() - 3; d++) {
													if (s.substr(d, 4) == ans) {
														count++;
														if (z == count)goto breakpoint;
														if(s.size()-d>=5){
															for (ans += 'a'; ans[4] <= 'z'; ans[4]++) {
															for (int e = 0; e < s.size() - 4; e++) {
																if (s.substr(e, 5) == ans) {
																	count++;
																	if (z == count)goto breakpoint;
																	ans.pop_back();
																	break;
																}
															}
														}
													}
														ans.pop_back();
														break;
													}
												}
											}
										}
											ans.pop_back();
											break;
										}
									}
								}
							}
								ans.pop_back();
								break;
							}
						}
					}
				}
				break;
			}
		}
	}
breakpoint:;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define ppb pop_back
using namespace std;
int dp[3005][3005];
string ans="";
int main()
{
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	for (int i=0;i<3005;i++) dp[i][0]=dp[0][i]=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n,j=m;
	while(i>0 && j>0)
	{
		if (s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		} else
		if (dp[i][j]==dp[i-1][j]) i--; else j--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35456
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  long long x;
  std::cin >> x;

  long long q = x / 500;
  long long r = x % 500;
  long long p = r / 5;

  long long ans = 1000 * q + 5 * p;
  // std::cout << p << " " << q << " " << r << std::endl;
  std::cout << ans << std::endl;

  return 0;
}


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

void Main()
{
  string N;
  cin >> N;
  rep(i,N.size()) {
    if (N[i] == '7') {cout << "Yes" << endl;  return;}
  }
  cout << "No" << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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

int main() {
	int w,h,n,x,y,a;
	cin >> w >> h >> n;
	int x1 = 0,x2 = w,y1 = 0,y2 = h;
	for(int i = 0;i < n;i++)
	{
		cin >> x >> y >> a;
		if(a == 1 && x1 < x)
		{
			x1 = x;
		}
		if(a == 2 && x2 > x)
		{
			x2 = x;
		}
		if(a == 3 && y1 < y)
		{
			y1 = y;
		}
		if(a == 4 && y2 > y)
		{
			y2 = y;
		}
	}
	int ss = 0;
	if(x1 < x2 && y1 < y2)
	{
		ss = (x2 - x1) * (y2 - y1);
	}
    cout << ss << endl;
	return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int a[n][2],c[m][2];
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
    }
    for(int i=0;i<m;i++){
        cin>>c[i][0]>>c[i][1];
    }
    for(int i=0;i<n;i++){
        int tmp=2e9,ans,len;
        for(int j=0;j<m;j++){
            len=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]);
            if(len<tmp){
                tmp=len;
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 100000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N;
	cin >> N;

	cout << 800 * N - N / 15 * 200;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1);
    t[0] = x[0] = y[0] = 0;
    rep(i, n) cin >> t[i+1] >> x[i+1] >> y[i+1];
    auto dist = [&](int i) { return abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);};
    rep(i, n) {
        int d = dist(i);
        int dt = t[i+1] - t[i];
        if (d <= dt && (dt - d) % 2 == 0) continue;
        puts("No");
        return 0;
    }
    puts("Yes");
}


Measured memory_bytes: 4500
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;
double x[20], y[20];

int main() {
  int perm[8];

  cin >> N;

  rep(i, 0, N) { perm[i] = i; }
  rep(i, 0, N) { cin >> x[i] >> y[i]; }

  vector<double> dists;
  do {
    rep(i, 0, N - 1) {
      int ci = perm[i];
      int ni = perm[i + 1];

      double cx = x[ci];
      double nx = x[ni];
      double dx = cx - nx;
      double cy = y[ci];
      double ny = y[ni];
      double dy = cy - ny;

      dists.push_back(sqrt(dx * dx + dy * dy));
    }
  } while (next_permutation(perm, perm + N));

  double sum = 0.0;
  sort(dists.begin(), dists.end());
  for (auto e : dists) {
    sum += e;
  }

  ll patterns = 1;
  repe(i, 1, N) { patterns *= i; }

  cout << setprecision(20) << fixed << sum / patterns << endl;
}


Measured memory_bytes: 7568
S = input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
i = 0
ans = "Yes"

for s in S:
    if i % 2 == 0:
        if s not in odd:
            ans = "No"
            break
    else:
        if s not in even:
            ans = "No"
            break
    i += 1

print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int x[1000][10],n,a,c,d,e;
string T[3]={"root","internal node","leaf"};
void depth(int s,int r){
	if(s==-1){
		return;
	}x[s][4]=r;
	depth(x[s][0],r+1);
	depth(x[s][1],r+1);
}
int height(int s){
	int h1=0,h2=0;
	if(x[s][0]!=-1) h1=height(x[s][0])+1;
	if(x[s][1]!=-1){
		h2=height(x[s][1])+1;
	}return x[s][5]=max(h1,h2);
}

int main(){
	memset(x,-1,sizeof(x));
	cin>>n;
	for(int i=0;i<n;i++){
		x[i][5]=0;x[i][6]=0;cin>>a>>d>>e;
		x[a][0]=d;
		x[a][1]=e;x[d][2]=a;
		x[e][2]=a;x[d][3]=e;x[e][3]=d;
	}
	for(int i=0;i<n;i++){
		if(x[i][2]==-1){
			c=i;break;
		}
	}
	depth(c,0);height(c);
	for(int i=0;i<n;i++){
		if(x[i][0]>=0) x[i][6]++;
		if(x[i][1]>=0) x[i][6]++;
	}
	for(int i=0;i<n;i++){
		if(i==c) x[i][7]=0;
		else if(x[i][6]>=1) x[i][7]=1;
		else x[i][7]=2;
	}
	for(int i=0;i<n;i++){
		cout<<"node "<<i<<": parent = "<<x[i][2]<<", sibling = "<<x[i][3]<<", degree = "<<x[i][6]<<", depth = "<<x[i][4]<<", height = "<<x[i][5]<<", "<<T[x[i][7]]<<endl;
	}
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[87];
int main()
{
    cin>>n;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=n;i++)
        a[i]=a[i-1]+a[i-2];
    cout<<a[n];
    return 0;
}

Measured memory_bytes: 256
def abc046_d():
    s = str(input())
    n = len(s)
    if n == 1: return 0
    gc = [0] * n
    pc = [0] * n
    for i, c in enumerate(s):
        gc[i] = gc[i-1] + c.count('g')
        pc[i] = pc[i-1] + c.count('p')
    ans = (gc[-1] - pc[-1]) // 2
    return ans

if __name__ == '__main__':
    print(abc046_d())

Measured memory_bytes: 16876
N=int(input())
if N==1:
  print(0)
  exit()
# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

S = factorization(N)
ans=0
start=1
for i in S:
  U=0
  for j in range(1,i[1]+1):
    U+=j
    ans+=1
    if U>i[1]:
      ans-=1
      break
print(ans)


Measured memory_bytes: 9488
class Game
  def initialize
    @cups = {A: true, B: false, C: false}
  end

  attr_accessor :cups

  def switch(one, another)
    tmp            = @cups[one]
    @cups[one]     = @cups[another]
    @cups[another] = tmp
  end

  def answer
    @cups.rassoc(true)[0]
  end
end

game = Game.new

while line = gets
  one, another = line.chomp.split(",").map(&:to_sym)
  game.switch(one, another)
end

puts game.answer

Measured memory_bytes: 8604
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  bool loop = true;
  int ans = 0;
  while (loop)
  {
    for (int i = 0; i < n; i++)
    {
      if (a[i] % 2 != 0)
      {
        loop = false;
        break;
      }
      a[i] = a[i] / 2;
    }
    if (loop) ans++;
  }
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  V<string> s(n);
  REP(i, n) cin >> s.at(i);
  ll ans = 0, ea = 0, sb = 0, ab = 0;
  REP(i, n) {
    rep(si, 1, s.at(i).size()) {
      if (s.at(i).at(si-1) == 'A' && s.at(i).at(si) == 'B') ans++;
    }
    if (s.at(i).at(0) == 'B' && s.at(i).at(s.at(i).size()-1) == 'A') ab++;
    else if (s.at(i).at(0) == 'B') sb++;
    else if (s.at(i).at(s.at(i).size()-1) == 'A') ea++;
  }
  if (ab > 0) {
    ans += ab - 1;
    if (sb > 0) {ans++; sb--;}
    if (ea > 0) {ans++; ea--;}
  }
  cout << ans + min(sb, ea) << endl;
  return 0;
}


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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int N;
	cin >> N;
	vector <int> v(N);
	for(int i = 0; i < N; i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	int ans = 0;
	for(int i = 0; i <= 1e5; i++){
		int pos = lower_bound(v.begin(),v.end(),i) - v.begin();
		if(N - pos == N / 2)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer num = Integer.parseInt(br.readLine());
		ArrayList<Integer> numArrays = new ArrayList<Integer>();
		for (int i = 1; i <= num; i++) {
			int x = i;
			if (x % 3 == 0) {
				numArrays.add(i);
			} else {
				while (x != 0) {
					if (x % 10 == 3) {
						numArrays.add(i);
						break;
					}
					x /= 10;
				}
			}
		}
		String out = "";
		for (int i = 0; i < numArrays.size(); i++) {
			out += " " + numArrays.get(i);
		}
		System.out.println(out);
	}

}

Measured memory_bytes: 174408
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans_odd = 0;
    int ans_even = 0;
    int nagasa = s.length();    
  
     for(int i=0;i<nagasa;i++){
        if(i % 2 == 0){
          if(s[i] == 'L'){ 
            cout << "No" << endl; 
            return 0;
          }
        }else{ 
          if(s[i] == 'R'){ 
            cout << "No" << endl; 
            return 0;
          }
        }  
     }
 

      cout << "Yes" << endl; 
} 


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, M;
    cin >> N >> M;
    string S, T;
    bool ok = true;
    cin >> S >> T;
    ll L = N / __gcd(N, M) * M;
    ll n = L / N, m = L / M;
    if (N < M)
    {
        swap(n, m);
        swap(S, T);
    }
    for (int i = 0; i * n < T.size() and i * m < S.size(); i++)
    {
        if (T[i * n] != S[i * m])
            ok = false;
    }

    cout << (ok ? L : -1);
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <bitset>
#include <limits>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
// all_of

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
template<class T>
struct IsIterable {
private:
	template<class Iterable>
	static auto Is_iterable(Iterable subject) -> decltype(std::begin(subject), std::end(subject), std::true_type()) {}
	static auto Is_iterable(...) -> decltype(std::false_type()) {}
public:
	typedef decltype(Is_iterable(std::declval<T>())) type;
	static bool const value = type::value;
};
template <class Container>
typename std::conditional<true, std::ostream&, typename std::enable_if<IsIterable<Container>::value>::type>::type
operator<<(ostream& ost, const Container& container) {
	for (auto it = begin(container); it != end(container); ++it) {
		if (it != begin(container)) ost << ' ';
		ost << *it;
	}
	return ost;
}
#endif

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#endif
int H, W;
LL N;
string S;
int main() {
	cin >> N;
	REP(a, 1, 3501) {
		REP(b, 1, 3501) {
			LL t = N * a * b;
			LL u = 4 * a * b - N * (a + b);
			if (u <= 0)continue;
			if (t % u == 0) {
				LL c = t / u;
				cout << a <<' '<< b << ' ' << c;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
const int INF=1000000000;

long long n,a,b,ng=0,ok=INF;

bool chk(int x,vector<long long> hp)
{
    long long tm=0;
    for(int i=0;i<n;i++){
        hp.at(i)-=b*x;
        hp.at(i)=max(0LL,hp.at(i));
        tm+=hp.at(i)/(a-b);
        if(hp.at(i)%(a-b)!=0)tm++;
    }
    return tm<=x;
}

int main()
{
    cin >> n >> a >> b;
    vector<long long > h(n);
    for(int i=0;i<n;i++)cin >> h.at(i);
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(chk(mid,h)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define OO 2e18
#define oo 1e9
#define yalla ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define sz  100005
#define re return
#define mod  1000000007
#define pi acos(-1)
using namespace std;
int n,h[sz],k;
int main()
{yalla;
 cin>>n>>k;
for(int i=0;i<n;i++)
    cin>>h[i];
///
int ans[sz]={};
for(int i=1;i<n;i++)
{ans[i]=oo;
 for(int y=i-1;y>=max(0,i-k ) ;y--)
 {
  ans[i]=min(ans[i],ans[y]+abs(h[i]-h[y]) );
 }
}
cout<<ans[n-1]<<endl;
 re 0;
}




Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int x,i;
	double m,n;
	
	scanf("%lf",&m);
	
	//m = (double)x;
	
	
	
	n=100;i=0;
	
	while(1){
		if(n>=m)
			break;
		n*=1.01;
		//x=(int)n;
		//n=(double)x;
		n = floor(n);

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

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

int main(){
  int a[5][3],m;

  while(1){
    cin >> a[0][0] >> a[0][1];
    if(!a[0][0] && !a[0][1])break;

    for(int i=1;i<5;i++)cin >> a[i][0] >> a[i][1];

    m = 0;
    for(int i=0;i<5;i++){
      a[i][2] = a[i][0] + a[i][1];
      m = max(m,a[i][2]);
    }

    for(int i=0;i<5;i++){
      if(a[i][2] == m)printf("%c %d\n",'A'+i,m);
    }
  }
}

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

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

    sort(A, A + 3);
    int c = 0;
    for(int i = 0; i < 3; i++)
    {
        if(i == 0) continue;

        c += A[i] - A[i-1];
    }
    cout << c << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, X;
    cin >> K >> X;
    if(X <= 500*K) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int cnt(int n, int x)
{   
    int count = 0;
    for (int i = 1; i <= n-2; i++) {
        for (int j = i + 1; j <= n-1; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (i + j + k == x) count++;
            }
        }
    }
    return count;
}

int main()
{
    int n, x;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0)   break;
        cout << cnt(n, x) << '\n';
    }
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
// const long double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n,k;
	cin>>n>>k;
	set<int> s;
	for(int i=0;i<k;i++)
	{
		int l;
		cin>>l;
		for(int i=0;i<l;i++)
		{
			int p;
			cin>>p;
			s.insert(p);
		}
	}
	cout<<n-int(s.size)<<endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    if (N < 10) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        int i, j;
        for (i = 9; i >= 1; --i) {
            if (N % i == 0) {
                N = N / i;
                break;
            }
        }
        for (j = 9; j >= 1; --j) {
            if (N == j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256