akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	if (n <= 6)
		ans = 1;
	else {
		ans=(n / 11)*2;
		n %= 11;
		if (n == 0)
			ans += 0;
		else if (n <= 6)
			ans++;
		else
			ans += 2;

	}
	cout << ans << endl;
}

Measured memory_bytes: 384
def main():
    n,k = list(map(int,input().split()))

    s, p ,r = list((map(int,input().split())))

    t = list(input())
    ans = 0
    for i in range(len(t)):
        if i < k:
            if t[i] == "r":

                ans += r
            if t[i] == "s":
                ans += s
            if t[i] == "p":
                ans += p
        else:
            if t[i] != t[i -k]:
                if t[i] == "r":
                    ans += r
                if t[i] == "s":
                    ans += s
                if t[i] == "p":
                    ans += p
            else:
                t[i] = "o"

    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 4084
#include<cstdio>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
static const int MAX_N = 10000;

int n;
vector<pair<int, int> > G[MAX_N];
vector<pair<int, int> > va[MAX_N];
int memo[MAX_N], memo2[MAX_N];

void dfs(int pv, int v){
	va[v].push_back(make_pair(0, v));
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].first == pv) continue;
		dfs(v, G[v][i].first);
		memo[v] = max(memo[v], memo[G[v][i].first] + G[v][i].second);
		va[v].push_back(make_pair(memo[G[v][i].first] + G[v][i].second, G[v][i].first));
	}
}
void dfs2(int pv, int v){
	sort(va[v].begin(), va[v].end(), greater<pair<int, int> >());
	memo2[v] = max(memo2[v], va[v][0].first);
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].first == pv) continue;
		if(va[v][0].second == G[v][i].first) va[G[v][i].first].push_back(make_pair(va[v][1].first + G[v][i].second, v));
		else va[G[v][i].first].push_back(make_pair(va[v][0].first + G[v][i].second, v));
		dfs2(v, G[v][i].first);
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n - 1; i++){
		int s, t, w;
		scanf("%d %d %d", &s, &t, &w);
		G[s].push_back(make_pair(t, w));
		G[t].push_back(make_pair(s, w));
	}
	dfs(-1, 0);
	dfs2(-1, 0);
	for(int i = 0; i < n; i++) printf("%d\n", memo2[i]);
	return 0;
}




Measured memory_bytes: 5124
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, q;
int main() {
	cin >> n >> q;
	vector<ll> s(n);
	REP(i, n)cin >> s[i];
	REP(i, q) {
		ll k, x, m;
		cin >> k >> x >> m;
		vector<ll> v(n);
		REP(i, n)v[i] = s[i] % m;
		ll sum = 0, cnt = 0;
		REP(i, n)if (v[i] != 0)cnt++;
		REP(i, n)sum += v[i];
		sum *= (k - 1) / n;
		cnt *= (k - 1) / n;
		REP(i, (k - 1) % n)sum += v[i];
		REP(i, (k - 1) % n)if (v[i] != 0)cnt++;
		sum += x;
		cout << cnt - (sum / m - x / m) <<endl;


	}
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
//#include <queue>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

using namespace std;

typedef long long int llint;

const long long int INF = 1 << 30; //10^10
const llint MOD = 998244353;

inline void maxch(int& a, int b) {if (a < b) a = b;}

int main() {
llint n, w;
cin >> n >> w;
vector<pair<int,int>> wv(n);
rep(i,n) cin >> wv[i].first >> wv[i].second;

sort(wv.begin(), wv.end(), greater<pair<int, int>>());

llint w1 = wv[n-1].first;

vector<vector<int>> wv4(4,vector<int>());
rep(i, n) {
  rep(j,4) if (wv[i].first == w1 + j) wv4[j].push_back(wv[i].second);
}
vector<int> k(4,-1);
llint ans = 0, k0 = k[0], k1 = k[1], k2 = k[2], k3 = k[3]; 

for (k[0] = k0; k[0] < (int)wv4[0].size(); k[0]++) {
	for (k[1] = k1; k[1] < (int)wv4[1].size(); k[1]++) {
		for (k[2] = k2; k[2] < (int)wv4[2].size(); k[2]++) {
			for (k[3] = k3; k[3] < (int)wv4[3].size(); k[3]++) {
				if ((llint)(1+k[0]) * w1 + (1+ k[1]) * (w1 + 1) + (1+k[2]) * (w1 + 2) + (1+ k[3]) * (w1 + 3) <= w) {
				  llint tmp = 0;
					rep(j,4) rep(i, k[j]+1) tmp += wv4[j][i];
					//cout << tmp << endl;
					ans = max(ans, tmp);
				}
			}
		}
	}
}

cout << ans << endl;
}

// vector<vector<pair<int,int>>> edge = { {{1,1},{2,2},{3,10}}, {{3,3}}, {{3,4}}, {} }; //(0,1),(0,2),(0,3),(1,3),(2,3)


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
typedef long long LL;

LL fastpow(LL a, LL b) {
    if (!b) return 1;
    LL t = fastpow(a, b / 2);
    if (b & 1) return t * t % mod * a % mod;
    else return t * t % mod;
}

LL fact[N * N], invf[N * N];
void prework(int n) {
    fact[0] = 1ll;
    for (int i = 1; i <= n; i++)
        fact[i] = fact[i - 1] * i % mod;
    invf[n] = fastpow(fact[n], mod - 2ll);
    for (int i = n - 1; ~i; i--)
        invf[i] = invf[i + 1] * (i + 1) % mod;
}

LL comb(int n, int m) {
    return fact[n]
         * invf[m] % mod
         * invf[n - m] % mod;
}

int k, n;
LL f[N][N];

signed main() {
    prework(4e6);
    cin >> n >> k;

    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 0; i <= n; i++)
        f[i][0] = 1ll;
    
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= i; j++) {
            f[i][j] += (f[i][j - 1] * (n - j + 1) % mod
                     * comb(n - i + (n - j + 1) * (k - 1) - 1, k - 2) % mod
                     + f[i - 1][j]) % mod;
        }
    
    cout << f[n][n] << endl;
    return 0;
}

Measured memory_bytes: 88268
import collections

N=int(input())
li=[]
for i in range(N):
    s=input()
    li.append(s)



c = collections.Counter(li)




print('AC x '+str(c['AC']))
print('WA x '+str(c['WA']))
print('TLE x '+str(c['TLE']))
print('RE x '+str(c['RE']))

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

int main() {
    string S;
    cin >> S;

    if(S[0] == 'R'){
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout << 3 << endl;
            }else{
                cout << 2 << endl;
            }
        }else{
            cout << 1 << endl;
        }
    }else if(S[1] == 'R'){
        if(S[2] == 'R'){
            cout << 2 << endl;
        }else{
            cout << 1 << endl;
        }
    }else if(S[2] == 'R'){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3620
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(m)]
for i,j in a:
    dis=10**9
    point=0
    for k in range(m):
        if abs(i-b[k][0])+abs(j-b[k][1])<dis:
            dis=abs(i-b[k][0])+abs(j-b[k][1])
            point=k
    print(point+1)

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

using namespace std;

//static const long long MOD = 1000000007;

int main() {
    long long N;
    vector<pair<long long, long long> > BA;
    long long sum = 0;

    // input
    cin >> N;
    for (long long i = 0; i < N; i++) {
        long long temp_A, temp_B;
        cin >> temp_A >> temp_B;
        BA.emplace_back(temp_B, temp_A);
    }

    // process
    sort(BA.begin(), BA.end());

    for (auto v : BA) {
        sum += v.second;
        if (sum > v.first) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}

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

int main(void)
{
    ios_base::sync_with_stdio(0);   cin.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n - 1; ++i)
        ans += (s[i] == 'L' && s[i + 1] == 'L') + (s[i] == 'R' && s[i + 1] == 'R');
    cout << min(n - 1, ans + k * 2);
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
	ll N, X;
	cin >> N >> X;
	vector<ll> b(N), l(N), u(N);
	for (int i = 0; i < N; ++i) {
		cin >> b[i] >> l[i] >> u[i];
	}

	vector<P> v(N);
	ll sumB = 0;
	for (int i = 0; i < N; ++i) {
		v[i] = P(u[i]*(X - b[i]) + l[i]*b[i], i);
		sumB += l[i]*b[i];
	}
	sort(v.rbegin(), v.rend());
	
	vector<ll> d(N + 1, 0);
	for (int i = 1; i <= N; ++i) {
		d[i] = d[i - 1] + v[i - 1].first;
	}

	ll low = -1, high = N * X;
	while (high - low > 1) {
		ll mid = (low + high) / 2;
		int p = min(mid / X, N);
		ll q = mid % X;
		bool ok = false;
		for (int i = 0; i < N; ++i) {
			int idx = v[i].second;
			ll sumA = (i + 1 <= p ? d[p + 1] - v[i].first : d[p]);
			if (q >= b[idx]) { sumA += u[idx]*(q - b[idx]) + l[idx]*b[idx]; }
			else { sumA += l[idx] * q; }

			if (sumA - sumB >= 0) { ok = true; }
		}
		if (ok) { high = mid; }
		else { low = mid; }
	}
	cout << high << endl;

	return 0;
}

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

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        x: i32,
        n: i32,
        mut p: [i32; n],
    }

    p.sort();
    match p.binary_search(&x) {
        Ok(n) => {
            let mut lower = p[n];
            let mut i = 1;
            loop {
                if !p.contains(&(p[n] - i)) {
                    lower = p[n] - i;
                    break;
                }
                i += 1;
            }

            let mut greater = p[n];
            let mut i = 1;
            loop {
                if !p.contains(&(p[n] + i)) {
                    greater = p[n] + i;
                    break;
                }
                i += 1;
            }

            if (lower - x).abs() > (greater - x).abs() {
                println!("{}", greater);
            } else {
                println!("{}", lower);
            }
        },
        Err(n) => {
            println!("{}", x);
        }
    }
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
#define mp make_pair
using namespace std;

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

string s; cin>>s;

string t=s.substr(0,n/2);
if(n==s.size()){

if(t+t==s)
cout<<"Yes\n";
else
cout<<"No\n";
}

else
cout<<"No\n";
    return 0;
}

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

int sumOfDigits(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main()
{
    int N;
    cin >> N;
    int sum = sumOfDigits(N);
    if (sum == 1)
    {
        cout << 10 << endl;
    }
    else
    {
        cout << sum << endl;
    }
}

Measured memory_bytes: 3556
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// NextPermutation generates the next permutation of the
// sortable collection x in lexical order.  It returns false
// if the permutations are exhausted.
//
// Knuth, Donald (2011), "Section 7.2.1.2: Generating All Permutations",
// The Art of Computer Programming, volume 4A.
// ※NextPermutationは辞書順で次を返す
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

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

	N := getInt()
	p := make([]int, N)
	q := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = getInt()
	}
	for i := 0; i < N; i++ {
		q[i] = getInt()
	}

	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = i + 1
	}

	flg := true
	ppos := -1
	qpos := -1
	idx := 0
	for flg {
		// out(a)
		ok := true
		for j := 0; j < N; j++ {
			if a[j] != p[j] {
				ok = false
			}
		}
		if ok {
			ppos = idx
		}
		ok = true
		for j := 0; j < N; j++ {
			if a[j] != q[j] {
				ok = false
			}
		}
		if ok {
			qpos = idx
		}
		idx++
		flg = NextPermutation(sort.IntSlice(a))
	}

	out(abs(ppos - qpos))
}


Measured memory_bytes: 1920
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int mod2 = 998244353;
  const int N = 20005;
  const int INF = 1e16;
  const double PI = acos(-1);

int32_t main()
{
       

    IOS


    int n,a,b;
    cin >> n >> a >> b;

    cout << min(a*n,b);


  return 0;
} 

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

#define pi pair<int,pair<int,int>>

void __print(int32_t x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...)


void dijkstra(string str[],int h,int w,int sx,int sy,int dx,int dy)
{
    priority_queue<pi,vector<pi>,greater<pi>> pq;

    pq.push({0,{sx-1,sy-1}});

    vector<vector<int>> used(h,vector<int>(w,-1));
    debug(used);
    while(!pq.empty())
    {

        auto cur=pq.top();
        debug(cur);
        pq.pop();
        int xc=cur.second.first;
        int yc=cur.second.second;

        if(used[xc][yc]!=-1)
        {
            continue;
        }
        else
        {
            used[xc][yc]=cur.first;

            for(int i=-2;i<=2;i++)
            {
                for(int j=-2;j<=2;j++)
                {
                    //debug(xc+i,yc+j);
                    //debug(used[xc+i][yc+j]);
                    if(xc+i>=0&&xc+i<h&&yc+j>=0&&yc+j<w&&used[xc+i][yc+j]==-1&&str[xc+i][yc+j]=='.')
                    {
                        
                        int dist=1+cur.first;

                        if(abs(i)+abs(j)==1)
                        {
                            dist--;
                        }
                        pq.push({dist,{xc+i,yc+j}});
                        debug("PLO",dist,xc+i,yc+j);
                    }
                }
            }

        }
    }

    debug(used);

    cout<<used[dx-1][dy-1];
}
 
int main()
{
    int h,w,startH,startW,endH,endW;

    cin>>h>>w;

    cin>>startH>>startW>>endH>>endW;

    string str[h];

    for(int i=0;i<h;i++)
    {
        cin>>str[i];
    }


    dijkstra(str,h,w,startH,startW,endH,endW);

}

Measured memory_bytes: 10040
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
//#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vector<int> A(n+1);
    int d;
    for(int i=0;i<k;++i){
        cin >> d;
        for(int j=0;j<d;++j){
            int a;
            cin >> a;
            A.at(a)+=1;
        }
    }
    itn count=0;
    for(itn i=1;i<n+1;++i){
        if(A.at(i)==0)count++;
    }
    cout << count ENDL;
    
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
#define LL long long
#define INF (LL)(1LL<<60)
using namespace std;


void solve(long long N, long long A, long long B, std::vector<long long> h){
    sort(h.begin(), h.end(), greater<LL>());
    LL l=h[0],r=0,diff=A-B;
    while(l-r>1){
        LL H=(l+r)/2;
        LL nB = (H+B-1)/B;
        LL nA=0;
        int i=0;
        while(h[i]>H){
            nA+=((h[i]-H+diff-1)/diff);
            i++;
        }
        if(nB-nA >= 0)l=H;
        else r=H;
    }
    cout << (l+B-1)/B << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, A, B, std::move(h));
    return 0;
}


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

int main()
{
    int N, M;
    scanf("%d%d", &N, &M);

    printf(
        "%d\n",
        ((N * (N - 1)) >> 1)
        +
        ((M * (M - 1)) >> 1)
    );

    return 0;
}

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

set<int > s;

int main(){
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        s.insert(x);
    }
    if(s.size()!=n)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


Measured memory_bytes: 9600
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func solve(n int64, as []int64) int64 {
	ret := int64(0)
	for i, a := range as {
		if as[a - 1] - 1  == int64(i) {
			ret += 1
		}
	}
	return ret / 2
}

func main() {
	defer out.Flush()

	n := nextInt()
	as := nextInts(n)
	res := solve(n, as)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int z = stdIn.nextInt();
		int cont = 0;
        stdIn.close();
        for(int i = x; i <= y; i++){
        	if (z%i==0) cont++;
        }
        System.out.println(cont);
	}
}



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

int main() {
  int r,d,x2000;
  cin >> r >> d >> x2000;
  
  vector<int> x(11);
  x.at(0) = x2000;
  
  for(int i = 1; i < 11; i++){
    x.at(i) = r*x.at(i-1)-d;
    cout << x.at(i) << endl;
  }
  
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a > b)
		swap(a, b);
	if(b > c)
		swap(b, c);
	if(a > b)
		swap(a, b);
	cout << c-a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll x, y;
	cin >> x >> y;
	if(abs(x-y) <= 1) {
		cout << "Brown" << '\n';
	} else {
		cout << "Alice" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

VVI edge(214514, VI(0));
VI ans(214514);
int n;
int c[2]={0,0};
int pn[3]={3,1,2};
bool f;
void check(int v, int p, int d) {
	c[d]++;
	for (int i = 0; i < edge[v].size(); i++) {
		if (edge[v][i] != p) {
			check(edge[v][i], v, !d);
		}
	}
}
void dfs(int v, int p, int d) {
	int num;
	if(d)
		num=1;
	else
		num=2;
	if(pn[num]<=n){
		ans[v]=pn[num];
		pn[num]+=3;
	}
	else{
		ans[v]=pn[0];
		pn[0]+=3;
	}
	for (int i = 0; i < edge[v].size(); i++) {
		if (edge[v][i] != p) {
			dfs(edge[v][i], v, !d);
		}
	}
}

void dfs2(int v, int p, int d, int f){
	if(d==f){
		ans[v]=pn[0];
		pn[0]+=3;
	}
	else{
		REP(i,3){
			if(pn[(i+1)%3]<=n){
				ans[v]=pn[(i+1)%3];
				pn[(i+1)%3]+=3;
				break;
			}
		}
	}
	for (int i = 0; i < edge[v].size(); i++) {
		if (edge[v][i] != p) {
			dfs2(edge[v][i], v, !d, f);
		}
	}
}

int main() {
	cin >> n;
	int a, b;
	REP(i,n-1){
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	check(0,-1,0);
	if(c[0]>n/3&&c[1]>n/3){
		dfs(0,-1,0);
	}
	else{
		if(c[0]>n/3){
			dfs2(0,-1,0,1);
		}
		else{
			dfs2(0,-1,0,0);
		}
	}
	REP(i,n)cout << ans[i] << (i==n-1?'\n':' ');
	return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int x;
    vector<int> v(N + 1);
    for (int i = 0; i < 2 * M; i++)
    {
        cin >> x;
        v.at(x) += 1;
    }
    for (int i = 1; i <= N; i++)
    {
        cout << v.at(i) << endl;
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	VE s(n), t(n);
	rep(i, n) {
		int a, b; cin >> a >> b;
		s[i] = a - b; t[i] = a + b;
	}
	vector<P>itv(n);
	rep(i, n) {
		itv[i].first = t[i];
		itv[i].second = s[i];
	}
	sort(ALL(itv));
	int ans = 0;
	int lastwork = -INF;
	rep(i, n) {
		if (lastwork <= itv[i].second) {
			ans++;
			lastwork = itv[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N>>M>>K;
    cout<<(M * K >= N ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3632
def solve():
    if k==n: return A
    if len(M) == n: return sorted(M, reverse=k%2)[:k]

    P.sort(reverse=True)
    M.sort()
    P.append(-1)
    M.append(1) # add endpoint
    pa, ma = [], []
    while len(pa) + len(ma) < k:
        if P[len(pa)] < -M[len(ma)]:
            ma.append(M[len(ma)])
        else:
            pa.append(P[len(pa)])

    if len(ma)%2 == 0: return pa + ma

    exist_pa = len(pa) > 0
    exist_ma = len(ma) > 0
    remain_p = len(P) - 1 > len(pa)
    remain_m = len(M) - 1 > len(ma)
    if exist_pa & exist_ma & remain_p & remain_m:
        if abs(pa[-1] * P[len(pa)]) < abs(ma[-1] * M[len(ma)]):
            pa.pop()
            ma.append(M[len(ma)])
        else:
            ma.pop()
            pa.append(P[len(pa)])
    elif exist_ma & remain_p:
        ma.pop()
        pa.append(P[len(pa)])
    elif exist_pa & remain_m:
        pa.pop()
        ma.append(M[len(ma)])
    return pa + ma

n, k = map(int, input().split())
A = [*map(int, input().split())]
P, M = [], [] # plus, minus
for a in A:
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 31732
#include <stdio.h>

int main()
{
  int a, b;

  scanf("%d %d", &a ,&b);

  if (a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }

  return 0;
}


Measured memory_bytes: 2040
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for(int i = 0;i < n;i++) s[i]=sc.next();
      int[][] a = new int[n][26];
      int x = 0;
      for(int i = 0;i < n;i++){
        for(int j = 0;j < s[i].length();j++){
      		for(char c = 'a';c <= 'z';c++){
        		if(s[i].substring(j,j+1).equals(String.valueOf(c)))a[i][x]++;
            	x++;
        	}
            x = 0;
        }
      }
      StringBuilder ans = new StringBuilder();
      int[] min = new int[26];
      for(int i = 0;i < 26;i++)min[i]=100;
      for(int j = 0;j < 26;j++){
      	for(int i = 0;i < n;i++){
        	min[j] = Math.min(min[j],a[i][j]);
        }
      }
      int y = 0;
      for(char c = 'a';c <= 'z';c++){
        for(int i = 0;i < min[y];i++){
      		ans.append(String.valueOf(c));
        }
        y++;
      }
      System.out.println(ans.toString());
    }
}

Measured memory_bytes: 30676
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     multimap<int,int> mp2;
     map<int,int> mp;
     int n;
     cin>>n;
     int j,arr[n];
     for(j=0;j<n;j++)
        cin>>arr[j];
     multiset<int> st;
     int ptr=1;
     mp[ptr]=arr[0];
     mp2.insert({arr[0],ptr});
     st.insert(arr[0]);
     for(j=1;j<n;j++)
     {
		 int val=*st.begin();
		 if(val>=arr[j])
		 {
			 ptr++;
			 mp[ptr]=arr[j];
			 mp2.insert({arr[j],ptr});
			 st.insert(arr[j]);
		 }
		 else
	     {
			 auto it=st.lower_bound(arr[j]);
			 it--;
			 val=*it;
			 auto it2=mp2.find(val);
			 int index=it2->second;
			 mp[index]=arr[j];
			 st.erase(it);
			 st.insert(arr[j]);
			 mp2.erase(it2);
			 mp2.insert({arr[j],index});
		 }
	 }
	 cout<<mp.size()<<endl;
}


Measured memory_bytes: 21084
S = input()
T = input()
s = len(S)
def hantei():
    for i in range(s):
        p = 0
        for j in range(s):
            if S[(j + i) % s] != T[j]:
                p = 1
        if p == 0:
            return("Yes")
    return("No")

print(hantei())

Measured memory_bytes: 3060
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
typedef struct{
	double x;
	double y;
}point;

void kock(int n,point p1,point p2){
	if(n==0) return;
	point s,t,u;
	s.x=(2*p1.x+1*p2.x)/3;
	s.y=(2*p1.y+1*p2.y)/3;
	t.x=(1*p1.x+2*p2.x)/3;
	t.y=(1*p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
	u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

	kock(n-1,p1,s);
	printf("%lf %lf\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%lf %lf\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%lf %lf\n",t.x,t.y);
	kock(n-1,t,p2);
}

int main(){
	int n;
	point p1={0,0},p2={100,0};
	
	scanf("%d",&n);
	printf("%lf %lf\n",p1.x,p1.y); 
	kock(n,p1,p2);
	printf("%lf %lf\n",p2.x,p2.y);
	return 0;
}



Measured memory_bytes: 1956
import java.io.*; 
import java.util.*; 
public class Main {
    static long dp[][],mod=1000000007L;
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int m=input.nextInt();
        dp=new long[n][m];
        for(int i=0;i<n;i++) {
            String str=input.next();
            for(int j=0;j<m;j++) {
                if(str.charAt(j)=='#') {
                    dp[i][j]=-1;
                }
            }
        }
        System.out.println(solve(n,m));
    }
    public static long solve(int n, int m) {
        for(int i=1;i<n;i++) {
            if(dp[i][0]==-1) {
                break;
            }
            else {
                dp[i][0]=1;
            }
        }
        for(int i=1;i<m;i++) {
            if(dp[0][i]==-1) {
                break;
            }
            else {
                dp[0][i]=1;
            }
        }
        for(int i=1;i<n;i++) {
            for(int j=1;j<m;j++) {
                if(dp[i][j]==-1) {
                    continue;
                }
                if(dp[i-1][j]==-1 && dp[i][j-1]==-1) {
                    dp[i][j]=0;
                }
                else if(dp[i-1][j]==-1) {
                    dp[i][j]=dp[i][j-1];
                }
                else if(dp[i][j-1]==-1) {
                    dp[i][j]=dp[i-1][j];
                }
                else {
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                }
            }
        }
        return dp[n-1][m-1];
    }
}


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

using namespace std;
using ll = long long;
int main()
{
	cin.sync_with_stdio(false);

	ll N;
	cin >> N;
	vector<ll>n;
	for (ll i = 1;i < N + 1;i++) {
		if (N%i == 0) {
			n.push_back(N/i);
		}
		if (i*i >= N) {
				break;
		}
	}
	ll x = n.back();
	int count=0;
	while (x > 0) {
		x = x / 10;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	// 書き換え可能なパターンの計算簡略化のため
	if b == 0 {
		return a
	}
	var r int
	for {
		r = a % b
		if r == 0 {
			return b
		}
		a = b
		b = r
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	l := make([]int, n+1)
	l[0] = 0
	for i := 0; i < n; i++ {
		l[i+1] = gcd(l[i], a[i])
	}
	r := make([]int, n+1)
	r[n] = 0
	for i := n - 1; i >= 0; i-- {
		r[i] = gcd(r[i+1], a[i])
	}

	max := 0
	for i := 0; i < n; i++ {
		if v := gcd(l[i], r[i+1]); v > max {
			max = v
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  vector<int> p(n),q(n);
  rep(i,n)cin>>p[i];
  rep(i,n)cin>>q[i];
  vector<int> a(n);
  rep(i,n)a[i]=i+1;
  map<vector<int>,int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(all(a)));
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
}

Measured memory_bytes: 8644
import copy
N=int(input())
An=[int(x) for x in input().split()]
Bn=[int(x) for x in input().split()]
maxMon=sum(An)
for i,B in enumerate(Bn):
  An[i+1]=max(0,An[i+1]-(max(0,B-An[i])))
  An[i]=max(0,An[i]-B)

print(maxMon-sum(An))

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

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:[isize;a],
    c:[isize;a],
    }
    let mut ans:isize=0;
    for i in 0..a {
        if ans<ans+b[i]-c[i] {ans+=b[i]-c[i]; }
    }
    println!("{}",ans);
}

Measured memory_bytes: 2168
#include<stdio.h>
#include<string.h>

void getChar(char*, int*);   //??????, ?????°

char key1[] = {'.', ',', '!', '?', ' '};
char key2[] = {'a', 'b', 'c'};
char key3[] = {'d', 'e', 'f'};
char key4[] = {'g', 'h', 'i'};
char key5[] = {'j', 'k', 'l'};
char key6[] = {'m', 'n', 'o'};
char key7[] = {'p', 'q', 'r', 's'};
char key8[] = {'t', 'u', 'v'};
char key9[] = {'w', 'x', 'y', 'z'};

int main(void) {
    int n, i, j, count;
    char str[1024], num, currentNum;
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%s", str);
        count = 0;
        for(j=0; j<strlen(str); j++) {
            num = str[j];
            if(str[j] == '0' ) {
                if(currentNum != '0') {
                    getChar(&currentNum, &count);
                    count = 0;
                    currentNum = '0';
                }
            } else {
                currentNum = str[j];
                count++;
            }
        }
        printf("\n");
    }
return 0;
}

void getChar(char *num, int *n) {
   // printf("%c %d\n", *num, *n);
    *n-=1;
    char out = 'a';
    switch (*num) {
        case '1':
            out = key1[*n%sizeof(key1)];
            break;
        case '2':
            out = key2[*n%sizeof(key2)];
            break;
        case '3':
            out = key3[*n%sizeof(key3)];
            break;
        case '4':
            out = key4[*n%sizeof(key4)];
            break;
        case '5':
            out = key5[*n%sizeof(key5)];
            break;
        case '6':
            out = key6[*n%sizeof(key6)];
            break;
        case '7':
            out = key7[*n%sizeof(key7)];
            break;
        case '8':
            out = key8[*n%sizeof(key8)];
            break;
        case '9':
            out = key9[*n%sizeof(key9)];
            break;
        default:
            break;
    }
    
    printf("%c", out);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();

    VI a;
    int cnt = 1;
    FOR(i, 1, n) {
        if (s[i - 1] == s[i])++cnt;
        else {
            a.push_back(cnt);
            cnt = 1;
        }
    }
    a.push_back(cnt);
    int m = a.size();

    function<bool(int)> check = [&](int x) {
        if (1 < x) {
            if (a[x - 2] >= a[x])return true;
        }
        if (x < m - 2) {
            if (a[x + 2] >= a[x])return true;
        }
        return false;
    };

    if (m <= 2)cout << *max_element(all(a)) << "\n";
    else {
        FOR(i, 1, m)a[i] += a[i - 1];
        int ans = INF;
        FOR(i, 0, m - 1)chmin(ans, max(a[i], n - a[i]));
        cout << ans << "\n";
    }
}

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


using namespace std;

#define ll long long

int main(){
   int n;
   cin >> n;
   ll ans=1;
   int mod=1e9 + 7;
   for(int i=1;i<=n;i++) {
		ans=(ll)(ans*i)%mod;
   }
   cout << ans;	
   return 0;
}




Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
  int x,a,b;

scanf("%d %d %d",&x,&a,&b);

  if(b-a<=0){
  printf("delicious\n");
  }
  else if(b-a<=x){
    printf("safe\n");
  }
  else
  {
    printf("dangerous\n");
  }

  return 0;
}


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

int main() {
  int N, sum = 0;
  cin >> N;
  vector<int> T(N);
  for(int i = 0; i < N; i++){
    cin >> T.at(i);
  }
  for(int j = 0; j < N; j++){
    sum += T.at(j);
  }
  int a = sum;
  int M;
  cin >> M;
  vector<int> P(M);
  vector<int> X(M);
  for(int i = 0; i < M; i++){
    cin >> P.at(i) >> X.at(i);
  }
  for(int i = 0; i < M; i++){
    sum = 0;
    sum = a;
    sum -= T.at(P.at(i)-1);
    sum += X.at(i);
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
s = 0.5 * (H*60+M)
l = 6 * M
c = max(s, l) - min(s, l)

ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(c)))
print(ans)

Measured memory_bytes: 9568
N = int(input())
S = input()
 
cumsum_b = [0] * (N+1)
 
for i in range(N):#累積和
  if S[i] == "#":
    cumsum_b[i+1] = cumsum_b[i] + 1
  else:
    cumsum_b[i+1] = cumsum_b[i]

ans = N
tmp = 0
for i in range(N+1):#境界を全探索
  tmp = cumsum_b[i] + ((N-i) - (cumsum_b[-1] - cumsum_b[i]))
  ans = min(ans,tmp)
else:
  print(ans)

Measured memory_bytes: 11144
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

}

Node treeSearch(Node u, int k){

}

Node treeSuccessor(Node x){

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL){
    root=z;
  }
  else if(z->key < y->key){
    y->left =z;
  }
  else y->right = z;
}

void inorder(Node u){
  if(u->left!=NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right!=NIL){
    inorder(u->right);
  }			
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL){
    preorder(u->left);
  }
  if(u->right!=NIL){
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25184
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    
    ll v,w;
    cin >> a >> v;
    cin >> b >> w;
    ll t;
    cin >> t;
    if(a>b) swap(a,b);
    if(a+v*t>=b+w*t){
        puts("YES");
    }else{
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	if(n >= 10)
		cout << k << endl;
	else
		cout << k + (100 * (10 - n)) << endl;

	return 0;
}



Measured memory_bytes: 256