akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string code;
  string output = "Good";
  cin >> code;
  int last = 11;

  for(int i = 0; i < 4; i++){
    int now = int(code.at(i)) - 48;
    if(now == last){
    	output = "Bad";
    }
    last = now;
  }
  
  cout << output << endl;  
}

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


int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int res = g * 10 + b;
	if (res % 4 == 0) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;// 1e9 + 7;

ll a[100001];
ll aq[100001];
ll c[100001];
ll cq[100001];

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
string s;
int main() {
	cin >> s;

	rep(i, 0, s.size()) {
		if (s[i] == 'A') {
			a[i]++;
			if (i > 0) {
				a[i] += a[i - 1];
				aq[i] = aq[i - 1];
			}
		}
		else if (s[i] == '?') {
			aq[i]++;
			if (i > 0) {
				aq[i] += aq[i - 1];
				a[i] = a[i - 1];
			}
		}
		else {
			a[i] = a[i - 1];
			aq[i] = aq[i - 1];
		}
	}

	rep_r(i, 0, s.size()) {
		if (s[i] == 'C') {
			c[i]++;
			if (i < s.size() - 1) {
				c[i] += c[i + 1];
				cq[i] = cq[i + 1];
			}
		}
		else if (s[i] == '?') {
			cq[i]++;
			if (i < s.size() - 1) {
				cq[i] += cq[i + 1];
				c[i] = c[i + 1];
			}
		}
		else {
			c[i] = c[i + 1];
			cq[i] = cq[i + 1];
		}
	}

	ll ans = 0;
	rep(i, 1, s.size() - 1) {
		ll A,C;

		if (s[i] == 'B' || s[i] == '?') {
			A = a[i - 1] * Pow(3,aq[i-1]) % MOD; // select A on l
			if (aq[i - 1] > 0) {
				A += aq[i - 1] * Pow(3, aq[i - 1] - 1) % MOD; // select ? on l
			}

			C = c[i + 1] * Pow(3, cq[i + 1]) % MOD; // select C on r
			if (cq[i + 1] > 0) {
				C += cq[i+1] * Pow(3, cq[i + 1] - 1) % MOD;
			}

			ans += A * C % MOD;
		}
	}
	cout << ans % MOD << endl;

	return 0;
}

Measured memory_bytes: 3584
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	map<char, int>mp;
	for (int i = 0; i < N; i++) {
		char c;
		cin >> c;
		mp[c] = 1;
	}
	int ans = mp.size();
	if (ans == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
int main() {
    string s;
    cin>>s;
    if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba") cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3612
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	char b;
	cin>>b;

	if(b=='A'){
		b='T';
	}
	else if(b=='T'){
		b='A';
	}
	else if(b=='G'){
		b='C';
	}
	else{
		b='G';
	}

	cout<<b<<endl;
	
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s, t;
    cin >> s >> t;
    ll ans = 1000;
    rep(0, i, s.size() - t.size() + 1)
    {
        string ss = s.substr(i, t.size());
        ll tmp = 0;
        rep(0, j, t.size())
        {
            if (ss.at(j) != t.at(j))
            {
                tmp++;
            }
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextInt();
        }

        final Solver solver = new Solver();
        solver.solve(K, N, A);
    }
}

class Solver {
    public void solve(int K, int N, int[] A) {
        long min = Long.MAX_VALUE;

        for (int i = 0; i < N; i++) {

            long backward = i == N - 1?
                    A[i] - A[0] :
                    A[i] + (K - A[i + 1]);

            long forward = i == 0 ?
                    A[N - 1] - A[i] :
                    (K - A[i]) + A[i - 1];

            long shorter = Math.min(backward, forward);
            min = Math.min(min, shorter);
        }

        System.out.println(min);
    }
}


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

int main() {
  string s;
  cin >> s;
  int x=0;
  for(int i=2;i<s.size()-1;i++){
    if(s.at(i)=='C'){
      x++;
    }
  }
  int y=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)>='A'&&s.at(i)<='Z'){
      y++;
    }
  }
  if(s.at(0)=='A'&&x==1&&y==2){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<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(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    char diff = 'A' - 'a';
    printf("%c%c%c",sa[0]+diff,sb[0]+diff,sc[0]+diff);
    return 0;
}



Measured memory_bytes: 256
H,W,N = map(int,input().split())
sr,sc = [int(e)-1 for e in input().split()]
S = input()
T = input()

r = 0
l = 0
u = 0
d = 0
ans = "YES"

for j in range(N):
    for i in range(2):

        if i == 0:
            mark = S[j]
            if mark == "R":
                r += 1
            elif mark == "L":
                l += 1
            elif mark == "U":
                u += 1
            elif mark == "D":
                d += 1
            
        if i == 1:
            mark = T[j]
            if mark == "R":
                l = max(l-1,-(W-1-sc))
            elif mark == "L":
                r = max(r-1,-sc)
            elif mark == "U":
                d = max(d-1,-sr)
            elif mark == "D":
                u = max(u-1,-(H-1-sr))
    
        if r > W-1-sc or l > sc or u > sr or d > H-1-sr:
            ans = "NO"

print(ans)

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, q;
int ad[200200];
vector<int> edge[200200];
bool f[200200];

void dfs(int u, int pl) {
    ad[u] += pl;
    f[u] = true;
    for(auto&&v:edge[u]) {
        if(!f[v])
            dfs(v, ad[u]);
    }
}

signed main() {

    cin >> n >> q;
    for(int i = 0; i < n-1; i++) {
        int x, y;
        cin >> x >> y;
        edge[x].bash(y);
        edge[y].bash(x);
    }

    for(int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        ad[a] += b;
    }

    dfs(1, 0);

    for(int i = 1; i <= n; i++) cout << ad[i] << " \n"[i==n];
    
    return 0;
}



Measured memory_bytes: 20608
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define rep(i,n) for(i=0;i<n;i++)
int in(void){
	int i;
	scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;
	scanf("%lld",&i);
	return i;
}
int cmp(const void *a,const void *b){
	return *(long long *)a-*(long long *)b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long max(long long a,long long b){
	return a>b?a:b;
}

long long a[300000];

int main(void){
	int i,n;
	long long ans=0;
	n=in();
	rep(i,3*n){
		a[i]=llin();
	}
	qsort(a,3*n,sizeof(long long),cmp);
	for(i=n;i<3*n;i+=2){
		ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4860
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q;
ll parent[200001]={0};
ll find(ll x){
  if(parent[x]==x)
    return x;
    return parent[x]=find(parent[x]);
}
void unian(ll x,ll y){
  ll xset=find(parent[x]);
  ll yset=find(parent[y]);
  if(yset!=xset)
  parent[xset]=yset;
}
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n>>m;
      map<ll,ll>ma;
      for(int i=0;i<n+1;i++){
        parent[i]=i;
      }
      for(int i=0;i<m;i++){
        cin>>x>>y;
        unian(x,y);
      }
      ll ans=0;
      for(int i=1;i<=n;i++){
        ma[find(i)]++;
        ans=max(ans,ma[find(i)]);
      }
      cout<<ans;
}

Measured memory_bytes: 17628
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from math import ceil
def resolve():
    n,h=map(int,input().split())
    AB=[tuple(map(int,input().split())) for _ in range(n)]

    # a が最大のうち、bが最小のものを取りだす
    AB.sort(lambda x:(x[0],-x[1]))
    ma,mb=AB.pop()

    # 残りのうち b が大きい順に投げ続ける
    AB.sort(lambda x:-x[1])
    ans=0
    for i in range(n-1):
        a,b=AB[i]
        if(b<=ma): break
        h-=b
        ans+=1
        if(h<=0):
            print(ans)
            return
    ans+=min(ceil(h/ma),ceil((h-mb)/ma)+1)
    print(ans)
resolve()

Measured memory_bytes: 63580
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    a = int(input())
    print(a + a **2 + a ** 3)



if __name__ == "__main__":
    run()

Measured memory_bytes: 9096
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 305
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int f[N][N][N];
int n, m, L[N][4], R[N][4];

void add(int &x, int y){ x += y; if(x >= mod) x -= mod; }

bool check(int x, int r, int g, int b){
	for(int i = 1; i < 4; i++)
		if(L[x][i] <= R[x][i] && ((r >= R[x][i]) + (g >= R[x][i]) + (b >= R[x][i]) != i || (r >= L[x][i]) + (g >= L[x][i]) + (b >= L[x][i]) != i))
			return false;
	return true;
}

int main(){
	n = read(), m = read();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < 4; j++)
			L[i][j] = inf, R[i][j] = 0;
	for(int i = 1; i <= m; i++){
		int l = read(), r = read(), x = read();
		L[r][x] = min(L[r][x], l);
		R[r][x] = max(R[r][x], l);
	}
	f[0][0][0] = 1;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= (!i ? i : i - 1); j++)
			for(int k = 0; k <= (!j ? j : j - 1); k++) if(f[i][j][k]){
				if(check(i + 1, i + 1, j, k))
					add(f[i + 1][j][k], f[i][j][k]);
				if(check(i + 1, i, i + 1, k))
					add(f[i + 1][i][k], f[i][j][k]);
				if(check(i + 1, i, j, i + 1))
					add(f[i + 1][i][j], f[i][j][k]);
			}
	int ans = 0;
	for(int i = 0; i < n; i++)
		for(int j = 0; j <= (!i ? i : i - 1); j++)
			add(ans, f[n][i][j]);
	printf("%d\n", ans);
}


Measured memory_bytes: 108800
import scala.io.StdIn._

object Main extends App {
  val Array(a, b, c, k) = readLine.split(" ").map(_.toInt)

  val (aCount, k1) = if (k >= a) (a, k - a) else (k, 0)
  val (_, k2) = if (k1 >= b) (b, k1 - b) else (k1, 0)
  val cCount = if (k2 >= c) c else k2

  println(aCount - cCount)
}



Measured memory_bytes: 54740
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()

int main(void){
    string s1,s2;
    cin>>s1>>s2;
    reverse(all(s2));
    cout<<(s1==s2 ? "YES" : "NO")<<endl;
    return 0;
}


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

int main()
{
    unsigned long long n, rem;
    string s;
    cin >> n;

    while(n){
        rem = (n%26);
        n /= 26;
        if(!rem) rem = 26, n--;
        s.push_back(96+rem);
    }
    reverse(s.begin(),s.end());
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3588
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc174/tasks/abc174_f
ll ans[1000001];
tl3 query[1000001];
ll n,q;
ll a[1000001];
ll sz;
bool cmp(tl3 a, tl3 b) {
	if (get<0>(a) / sz != get<0>(b) / sz)
		return get<0>(a) / sz < get<0>(b) / sz;
	return get<1>(a) < get<1>(b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,q;
    cin >> n >> q;
    for(int i = 1;i<=n;i++){
        cin >> a[i];
    }
    sz = sqrt(n);
    for(int i = 0;i<q;i++){
        cin >> get<0>(query[i]) >> get<1>(query[i]);
        get<2>(query[i]) = i;
    }
    sort(query, query+q ,cmp);
    vector<ll> state(1000001);
    ll val = 0;
    ll s = get<0>(query[0]);
    ll e = get<1>(query[0]);
    for(int i = s;i<=e;i++){
        if(state[a[i]] == 0) val++;
        state[a[i]]++;
    }
    ans[get<2>(query[0])] = val;
    for(int i = 1;i<q;i++){
        ll next_s = get<0>(query[i]);
        ll next_e = get<1>(query[i]);
        if(s > next_s){
            for(;s != next_s;s--){
                if(state[a[s-1]] == 0) val++;
                state[a[s-1]]++;
            }
        }
        else if(s < next_s){
            for(;s != next_s;s++){
                if(state[a[s]] == 1) val--;
                state[a[s]]--;
            }
        }
        if(e > next_e){
            for(;e != next_e;e--){
                if(state[a[e]] == 1) val--;
                state[a[e]]--;
            }
        }
        else if(e < next_e){
            for(;e != next_e;e++){
                if(state[a[e+1]] == 0) val++;
                state[a[e+1]]++;
            }
        }
        ans[get<2>(query[i])] = val;
    }
    for(int i = 0;i<q;i++){
        cout << ans[i] << "\n";
    }
    return 0; 
}

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

#define SIZE 1000010
vector<bool> prime(SIZE,true);
void init(){
    prime[0] = prime[1] = false;
    rep(i,SIZE){
        if(!prime[i])continue;
        for(int j=i*2;j<SIZE;j+=i){
            prime[j] = false;
        }
    }
}


int main(void){
    ll n, p;
    cin >> n >> p;
    init();
    map<ll,int> cnt;
    for (int d = 2; d < SIZE; d++) {
        if (!prime[d]) continue;
        while (p%d == 0) {
            p /= d;
            cnt[d]++;
        }
        if (p == 1) break;
    }
    if (p > 1) {
        cnt[p]++;
    }
    ll res = 1;
    for (auto itr : cnt) {
        if (itr.second >= n) {
            res *= pow(itr.first, (itr.second / n));
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
//#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int n;
	double p[8];
	double k1, k2;
	bool ans = false;

	cin >> n;

	while (n--){
		ans = false;
		for (int i = 0; i < 8; i++){
			cin >> p[i];
		}

		if (p[0] == p[2] || p[4] == p[6]){
			if (p[0] == p[2] && p[4] == p[6])ans = true;
		}
		else{
			k1 = (p[3] - p[1]) / (p[2] - p[0]);
			k2 = (p[7] - p[5]) / (p[6] - p[4]);
			if (k1 == k2)ans = true;
			if (k1 > k2 && (k1 -k2 ) < 0.000000001) ans = true;
			if (k2 > k1 && (k2 - k1) < 0.000000001) ans = true;
		}

		cout << (ans ? "YES" : "NO") << endl;
	}


	return 0;
}

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

using namespace std;


int main() {
	long long int N, A, B;
	cin >> N >> A >> B;
	long long int ansmax = 1e9 + 1, ansmin = -1;
	vector<long long int>h( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> h[i];
	}
	for( size_t index = 0; index < 100; index++ ) {
		long long int ansmid = ( ansmax + ansmin ) / 2;
		auto H = h;
		long long int count = 0;
		for( size_t i = 0; i < N; i++ ) {
			H[i] -= ansmid*B;
			if( H[i] > 0 ) {
				count += ( H[i] + ( A - B ) - 1 ) / ( A - B );
			}
		}
		if( count <= ansmid ) {
			ansmax = ansmid;
		} else {
			ansmin = ansmid;
		}
	}
	cout << ansmax << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

const ll DICE_SIZE = 6;

const map<pair<ll, ll>, ll> tf2r = {
    {{0, 1}, 2},
    {{0, 2}, 4},
    {{0, 3}, 1},
    {{0, 4}, 3},

    {{1, 2}, 0},
    {{1, 3}, 5},
    {{1, 5}, 2},

    {{2, 4}, 0},
    {{2, 5}, 4},

    {{3, 4}, 5},
    {{3, 5}, 1},

    {{4, 5}, 3}
};

ll get_right(ll top, ll front){
    if(front < top){
        return 5 - get_right(front, top);
    }
    return tf2r.at({top, front});
}

struct Dice{
    array<ll, DICE_SIZE> i2v;
    ll top, front, right;
    map<ll, ll> v2i;
    Dice(const array<ll, DICE_SIZE>& num) : i2v(num), top(0), front(1), right(2) {
        REP(i, DICE_SIZE){
            v2i[i2v.at(i)] = i;
        }
    }

    void move(char c){
        if(c == 'N'){
            const ll old_top = top;
            top = front;
            front = 5 - old_top;
        }else if(c == 'S'){
            const ll old_front = front;
            front = top;
            top = 5 - old_front;
        }else if(c == 'W'){
            const ll right = get_right(top, front);
            top = right;
        }else{
            assert(c == 'E');
            const ll right = get_right(top, front);
            top = 5 - right;
        }
    }

    ll get_top() const { return i2v.at(top); }

    bool operator==(const Dice& other) const {
        REP(t, DICE_SIZE){
            REP(f, DICE_SIZE){
                if(t == f || t == 5 - f){ continue; }
                const ll r = get_right(t, f);
                array<ll, DICE_SIZE> tmp = {
                    i2v.at(t),
                    i2v.at(f),
                    i2v.at(r),
                    i2v.at(5 - r),
                    i2v.at(5 - f),
                    i2v.at(5 - t)
                };
                if(tmp == other.i2v){
                    return true;
                }
            }
        }
        return false;
    }
};


int main(){
    array<ll, DICE_SIZE> num1, num2;
    REP(i, DICE_SIZE){
        cin >> num1.at(i);
    }
    REP(i, DICE_SIZE){
        cin >> num2.at(i);
    }

    Dice d1(num1), d2(num2);

    if(d1 == d2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

using ll = long long;
using P = pair<int, int>;
#define reps(i,n) for (int i=1; i<=n; i++)
#define zarray(x,n) x[n+1]; reps(i,n) {x[i]=0;} 
#define zarray2(x,n,m) x[n+1][m+1]; reps(i,n) { reps(j,m) {x[i][j]=0;}}

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

    ll ans = 0;
    for (ll i=100; i<x; i += (i / 100)) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int answer = 1;
        for(int i = 0;i<n;i++){   
            if(answer <k){
                answer *= 2;
            }else{
                answer += k;
            }
        }
        System.out.println(answer);
    }
}

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

using namespace std;

//Shortcut
#define long long long
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define sz size
#define ft(i , a , b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i , a , b) for (long i = (long)a ; i >= (long)b ; i--)
#define lt(i , a , b , c) for (long i = (long)a ; i <= (long)b ; i += (long)c)
#define ld(i , a , b , c) for (long i = (long)a ; i >= (long)b ; i -= (long)c)
#define pll pair <long , long>
#define pls pair <long , string>
#define vtl vector <long>
#define vts vector <string>
#define mll map <long , long>

//Variable
const long mxN = 1e5 + 5;
const long base = 311;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const long d4i[4] = {-1 , 0 , 1 , 0} , d4j[4] = {0 , 1 , 0 , -1};
const long d8i[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1} , d8j[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1};

long TestCase;
long n , ans;
long a[mxN];

void Solve() {
    cin >> n;
    ft(i , 1 , n) cin >> a[i];
    lt(i , 1 , n , 2) if (a[i] & 1) ans++;
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //cin >> TestCase;
    TestCase = 1;
    while(TestCase--)
        Solve();
    return 0;
}

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

#define int long long

signed main() {
	int n, ans = 0;
	cin >> n;
	vector <int> adj[n + 1];
	for(int i = 0; i < n - 1; i++){
	    int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 1; i <= n; i++){
		int maxi = 0, c = 0;
		sort(adj[i].begin(), adj[i].end());
		for(int j:adj[i]){
			if(j < i){
				maxi = j;
				ans -= (maxi) * (n - i + 1);
			}
			else
			    break;
		}
		ans += (i) * (n - i + 1);
	}
	cout << ans;
}


Measured memory_bytes: 15792
#include <stdio.h>

char solve(int mid, int fin, int re){
    if(mid == -1 || fin == -1)return 'F';

    int sum = mid + fin;
    if(sum >= 80)return 'A';
    else if(sum >= 65) return 'B';
    else if(sum >= 50) return 'C';
    else if(sum >= 30){
        if(re >= 50) return 'C';
        else return 'D';
    }
    else return 'F';
}

int main(){
    int mid, fin, re;
    while(1){
        scanf("%d %d %d", &mid, &fin, &re);
        getchar();

        if(mid == -1 && fin == -1 && re == -1)break;

        printf("%c\n", solve(mid, fin, re));
    }
}


Measured memory_bytes: 2116
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>

using namespace std;
// const long long int MOD = 1e9 + 7;

const int MAX = 1000000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int x,y;
    cin >> x >> y;
    if((x+y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    int m = (x - 2*y)*(-1)/3;
    int n = (-2*x + y)*(-1)/3;
    
    // 前処理
    COMinit();
    // cout << m << " " << n << endl;
    cout << COM(m+n, min(m,n)) << endl;
    return 0;
}

Measured memory_bytes: 23680
import sys, time
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = [list(map(int, input().split()))[::-1] for _ in range(n)]
#print(*a, sep="\n")
opponent = [-1 for _ in range(n)]
match = 0
day = 0
start_time = time.time()
while match < n*(n-1)//2:
	approved = False
	for i in range(n):
		if a[i] != [] and opponent[i] == -1:
			opponent[i] = a[i].pop()-1
	#print(opponent)
	for i in range(n):
		if opponent[i] != -1 and opponent[opponent[i]] == i:
			approved = True
			match += 1
			opponent[opponent[i]] = -1
			opponent[i] = -1
	#print(opponent)
	if not approved:
		print(-1)
		sys.exit()
	now = time.time()
	#print(start_time, now, now - start_time)
	if now-start_time > 1.6:
		print(n*(n-1)//2)
		sys.exit()
	day += 1
print(day)


Measured memory_bytes: 36612
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    cout << 1-x;
}


Measured memory_bytes: 3636
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 100010
using namespace std;

int fa[N<<1],val[N<<1][2],n;
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
struct poi{int x,y,ax,ay;}a[N];
bool cmp1(poi x,poi y){return x.x<y.x;}
bool cmp2(poi x,poi y){return x.y<y.y;}
void merge(int x,int y)
{
	int fx=find(x),fy=find(y); if(fx==fy)	return;
	val[fx][0]+=val[fy][0]; val[fx][1]+=val[fy][1];
	fa[fy]=fx; 
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	int xx=0,yy=0;
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=n;i++)
	{
		if(a[i].x!=a[i-1].x)	++xx;
		a[i].ax=xx; 
	}
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<=n;i++)
	{
		if(a[i].y!=a[i-1].y)	++yy;
		a[i].ay=yy;
	}
	for(int i=1;i<=xx;i++)	fa[i]=i,val[i][0]=1;
	for(int i=1;i<=yy;i++)	fa[i+xx]=i+xx,val[i+xx][1]=1;
	for(int i=1;i<=n;i++)	merge(a[i].ax,a[i].ay+xx);
	ll ans=0;
	for(int i=1;i<=xx+yy;i++)
		if(fa[i]==i)	ans+=1ll*val[i][0]*val[i][1];
	printf("%lld\n",ans-n);
	return 0;
}


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

int main(){
    int N;
 	double ans;
    cin>>N;

    if(N%2==0){
        cout<<"0.5\n";
    }
    else{
        if(N==1)cout<<"1\n";
        else{
          	ans=((N/2)+1)/(double)N;
            cout<<ans<<endl;
        }
    }
 return 0; 
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int dp[64][3];
constexpr int MOD = 1'000'000'007;
void solve(std::istream &in, std::ostream &out) {
  uint64_t n;
  in >> n;
  dp[60][0] = 1;
  for (int bit = 59; bit >= 0; --bit) {
    for (int diff = 0; diff < 3; ++diff) {
      int ndiff = 2 * diff + (n >> bit & 1);
      if (ndiff >= 2) {
        (dp[bit][min(2, ndiff - 2)] += dp[bit + 1][diff]) %= MOD;
      }
      if (ndiff >= 1) {
        (dp[bit][min(2, ndiff - 1)] += dp[bit + 1][diff]) %= MOD;
      }
      (dp[bit][min(2, ndiff)] += dp[bit + 1][diff]) %= MOD;
    }
  }
  out << ((dp[0][0] + dp[0][1]) % MOD + dp[0][2]) % MOD << '\n';
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<pii,int> edge;

#define MAX_N 100
#define MAX_M 1000

int d[MAX_N][MAX_N];
edge es[MAX_M];

int main(){
	int n,m;
	cin>>n>>m;
	const int inf=1000000001;
	for(int v=0;v<n;++v) fill(d[v],d[v]+n,inf);
	for(int v=0;v<n;++v) d[v][v]=0;
	for(int e=0;e<m;++e){
		int a,b,c;
		cin>>a>>b>>c;
		es[e]=mp(mp(--a,--b),c);
		d[a][b]=c;
		d[b][a]=c;
	}
	for(int v=0;v<n;++v) for(int u=0;u<n;++u) for(int w=0;w<n;++w){
		if(d[u][w]>d[u][v]+d[v][w]) d[u][w]=d[u][v]+d[v][w];
	}
	int ans=0;
	for(int e=0;e<m;++e){
		int v=es[e].fi.fi,w=es[e].fi.sc,c=es[e].sc;
		bool f=false;
		for(int u=0;u<n;++u) if(abs(d[u][v]-d[u][w])==c){
			f=true;
			break;
		}
		if(!f) ++ans;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int read(){
    register int x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 

#define int long long
const int maxn = 210000;
int n, m, k;
int a[maxn], b[maxn], Suma[maxn], Sumb[maxn];
int solve(int rest) {
	if (b[1] > rest) return 0;
	int l = 1, r = m, ans;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (Sumb[mid] <= rest) {
			ans = mid;  l = mid + 1;
		}
		else r = mid - 1;
	}
	return ans;
}
signed main() {
	n = read(), m = read(), k = read();
	for (int i = 1; i <= n; i++) {
		a[i] = read(); Suma[i] = Suma[i - 1] + a[i];
	}
	for (int i = 1; i <= m; i++) {
		b[i] = read(); Sumb[i] = Sumb[i - 1] + b[i];
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (Suma[i] > k) break;
		ans = max(ans, i + solve(k - Suma[i]));
	}
	cout << ans;
}


Measured memory_bytes: 9840
import java.util.Scanner;

public class Main {
    public static int maximum_poison(int a,int b)
    {
        if(a>=(b-1))
            return b;
        return a+1;

    }
    public static void main(String args[])
    {
        Scanner input = new Scanner(System.in);
        int a,b,c;
        a = input.nextInt();
        b = input.nextInt();
        c = input.nextInt();

        System.out.println(b+maximum_poison(a+b,c));


    }
}


Measured memory_bytes: 23764
// SeeAlso: https://atcoder.jp/contests/abc060/tasks/abc060_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string a, b, c;

int main() {
    cin >> a >> b >> c;
    bool flag1 = a[a.size()-1] == b[0];
    bool flag2 = b[b.size()-1] == c[0];
    print((flag1&&flag2)?"YES": "NO");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
int main(){
    int n,t;
    scanf("%d%d",&n,&t);
    int res=0;
    int remain=0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        res+=(x+t);
        res-=max(x,remain);
        remain=x+t;
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 3776
n=[int(i) for i in input()]
a = [int(i) for i in input().split()]
a.sort()
#print(n,a)
def f(y,x):
    if x==0:
        return y
    else:
        return f(x,y%x)

ans=f(a[1],a[0])

for i in range(2,len(a)):
    ans=f(a[i],ans)
    
print(ans)

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

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

    for(int i = 0; i < 1<<n; i++){
        vector<int> bit;
        for(int j = 0; j < n; j++)  if(i & 1<<j)    bit.push_back(j);
        if(bit.size() != k) continue;
        cout << i << ":";
        for(int j : bit)    cout << " " << j;
        cout << endl;
    }
    
    return 0;
}


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

int A, B, C, X, Y;

main()
{
    int total = 0;
    cin >> A >> B >> C >> X >> Y;
    if (A + B > 2 * C) {
        total += min(X, Y) * 2 * C;
        if (X > Y) {
            total += (X - Y) * A;
        } else {
            total += (Y - X) * B;
        }
        if (total > max(X, Y) * 2 * C) {
            total = max(X, Y) * 2 * C;
        }
    } else {
        total += X * A + Y * B;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
import numpy as np  

n, k = map(int, input().split())
h = np.array([int(i) for i in input().split()])

dp = np.array([0] * n)

for i in range(1, n):
    j = max(i-k, 0)
    dp[i] = np.min(np.abs(h[i] - h[j:i]) + dp[j:i])

print(dp[-1])

Measured memory_bytes: 23092
#include<bits/stdc++.h>
/*   -- AUTHOR -- 
  ---- cervotrex ---- 
*/
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
// ordered_set <int> s  ;
// auto x=s.find_by_order(k);
// s.order_of_key(val);

// Atcoder String formation

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
      string s; cin>>s;
      int q, f=1; cin>>q;
      string front="", back="";
      while(q--){
        int p; cin>>p;
        if(p==1)
          f^=1;
        else{
          int pos; char ch;
          cin>>pos>>ch; pos--;
          if(f)
            pos^=1;
          if(pos)
            front+=ch;
          else
            back+=ch;
        }
      }
      reverse(all(front));
      s=front+s+back;
      if(!f)
        reverse(all(s));
      cout<<s<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

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


//////////////////////////////////////////////////

ll dp[10010][2][110];

int main() {
    string K; cin >> K;
    int d; cin >> d;
    int len = K.size();

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    ll mod = 1e9+7;

    for (int i = 0; i < len; i++) {
        int p = K[i] - '0';
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < d; k++) {
                for (int l = 0; l <= (j ? 9 : p); l++) {
                    int nextk = (k+l)%d;
                    dp[i+1][j || (l<p)][nextk] += dp[i][j][k];
                    dp[i+1][j || (l<p)][nextk] %= mod;
                }
            }
        }
    }

    ll ans = (dp[len][1][0] + dp[len][0][0])%mod - 1;
    if (ans < 0) ans += mod;

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 17536
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    int N;
    string S;
    
    cin >> N >> S;
    int minc = N;
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0) { 
            for (int j = 0; j < N; j++) {
                if (j < i) {
                    if (S[j] == 'W') count++;
                } else if (i < j) {
                    if (S[j] == 'E') count++;
                }
            }
        } else {
            if (S[i-1] == 'W') count++;
            if (S[i] == 'E') count--;  
        }
        if (minc > count) minc = count;
    }
    cout << minc << "\n";
    return 0;
}

Measured memory_bytes: 900
int main(void){
  int n,i,x;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    x=i;
    if ( x % 3 == 0 ){
      printf(" %d",i);
    }else{
      do{
        if ( x % 10 == 3 ){
          printf(" %d",i);
          x=0;
        }
        x /= 10;
      }while( x );
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int r = Integer.parseInt(in.next());
            double ans = 0;

            ans = 2 * Math.PI * r;

            // 出力
            out.printf("%.8f%n", ans);


        }

    }
}



Measured memory_bytes: 36056
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
int main()
{
	string ans;
	int n,k;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	int op=0;
	for(int i=0;i<t.length();i++)
	{
		char tar;
		if(t[i]=='r') tar='p';
		else if(t[i]=='p') tar='s';
		else tar='r';
		if(i<k)
		{
			ans+=tar;
			if(tar=='p') op+=p;
			else if(tar=='s') op+=s;
			else op+=r;
		}
		else{
			char org=ans[i-k];
			if(org==tar)
				ans+='-';
			else {
				ans+=tar;
				if(tar=='p') op+=p;
				else if(tar=='s') op+=s;
				else op+=r;
			}
		}
	}
	cout<<op<<'\n';
}


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

int main() {
	vector<vector<int>> A(3,vector<int>(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> A.at(i).at(j);
		}
	}

	int N;
	cin >> N;

	vector<int> B(N);
	for(int i=0;i<N;i++){
		cin >> B.at(i);
	}

	vector<pair<int,int>> bingo;
	vector<vector<bool>> correct(3, vector<bool>(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			correct.at(i).at(j) = false;
		}
	}

	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<N;k++){
				if(A.at(i).at(j) == B.at(k)){
					correct.at(i).at(j) = true;
				}
			}
		}
	}

	for(int i=0;i<3;i++){
		if(correct.at(i).at(0) && correct.at(i).at(1) && correct.at(i).at(2)){
			cout << "Yes" << endl;
			return 0;
		}else if(correct.at(0).at(i) && correct.at(1).at(i) && correct.at(2).at(i)){
			cout << "Yes" << endl;
			return 0;
		}else if(correct.at(0).at(0) && correct.at(1).at(1) && correct.at(2).at(2)){
			cout << "Yes" << endl;
			return 0;
		}else if(correct.at(0).at(2) && correct.at(1).at(1) && correct.at(2).at(0)){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
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 dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}



using namespace std;
int main(){
    bool fl[5];
    ll n,ans=0, x;
    cin  >> n;
    string S;
    map<char, int> mp;

    char X[5] = {'M', 'A', 'C', 'R', 'H'};
    REP(i,n){
        cin  >> S;
        mp[S[0]] ++;
    }


    for(int i=0;i<=3;i++){
        for(int j = i+1;j<=4;j++){
            REP(k, 5) fl[k] = 1;
            fl[i] = false;
            fl[j] = false;
            x = 1;
            REP(k,5){
                if(fl[k]) x *= mp[X[k]];
            }
            ans += x;
        }
    }

    cout << ans <<endl;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき

int main()
{
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) cin >> a[i];
    int idx = 0;
    int ans = 0;
    rep(i, n - 1) //全ボタン繰り返すためだけに使ってる。どこからもiは参照してない。
    {
        if (a[idx] == 2)
        {
            ans = i + 1;
            printf("%d\n", ans);
            return 0;
        }
        idx = a[idx] - 1;
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 640