akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

void ans(bool flag){
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int cnt=0,m=0,G[100];
void insertionsort(int a[],int n,int g){
    int i,j,v;
    for(i=g;i<n;i++){
        v=a[i];
        j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j=j-g;
            cnt++;
        }
        a[j+g]=v;
    }
}
void makeg(int n){
    int i;
    G[0]=1;
    for(i=0;G[i]<=n;i++){
        G[i+1]=G[i]*3+1;
        m++;
    }
}
void shellsort(int a[],int n){
  int i;
  makeg(n);
  for(i=m-1;i>=0;i--)insertionsort(a,n,G[i]);
}
int main(){
    int n,i,a[1000000];
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    shellsort(a,n);
    printf("%d\n",m);
    for(i=m-1;i>0;i--)printf("%d ",G[i]);
    printf("%d\n%d\n",G[0],cnt);
    for(i=0;i<n;i++)printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n, k;
cin >> n >> k;
ll ans = k;
for(ll i =0; i<n-1; i++){
	ans *= (k-1);
}

cout << ans; 

return 0;
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MIN 100000000000000

int main()
{
  int n;cin>>n;
  vector<ll> w(n);
  int i,j;
  rep(i,n)cin>>w[i];
  vector<vector<ll>> dp(n,vector<ll>(n,MIN));
  rep(i,n)
  {
    dp[i][i]=w[i];
  }
  for(i=1;i<=n-1;i++)
  {
    rep(j,n-i)
    {
      dp[j][j+i]=max(w[j]-dp[j+1][j+i],w[j+i]-dp[j][j+i-1]);
    }
  }
  cout<<dp[0][n-1]<<endl;
}


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

string s[600];
int main(){
	int n;cin>>n;
	rep(i,n)cin>>s[i];
	int cnt=0;
	rep(j,n){
		int ok=true;
		rep(i,n){
			if(s[i][j]=='.')ok=false;
		}
		if(!ok)cnt++;
	}
	bool ok=false;
	rep(i,n)rep(j,n){
		if(s[i][j]=='#')ok=true;
	}
	if(!ok){
		puts("-1");return 0;
	}
	int Min=INT_MAX;
	rep(i,n){
		bool b=false;
		int c=0;
		rep(j,n){
			if(s[j][i]=='#')b=true;
		}
		rep(j,n){
			if(s[i][j]=='.')c++;
		}
		Min=min(Min,c+!b);
	}
	cout<<cnt+Min<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
const long long Maxn=100;
long long f[Maxn],a[Maxn];
long long n;
inline long long read()
{
	long long s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i)
	a[i]=read();
	f[1]=1000;
	for(long long i=2;i<=n;++i)
	f[i]=max(f[i-1],f[i-1]/a[i-1]*a[i]+f[i-1]%a[i-1]);
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);

    while( 1 ) {
        long len=strlen(str);
        if(len>=5 && strcmp(&(str[len-5]), "dream") == 0) {
            str[len-5]='\0'; continue;
        }
        if(len>=5 && strcmp(&(str[len-5]), "erase") == 0) {
            str[len-5]='\0'; continue;
        }
        if(len>=7 && strcmp(&(str[len-7]), "dreamer") == 0) {
            str[len-7]='\0'; continue;
        }
        if(len>=6 && strcmp(&(str[len-6]), "eraser") == 0) {
            str[len-6]='\0'; continue;
        }
        break;
    }
    if(strlen(str)==0) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


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

int s,n,k,a,b,c,A,B,C;
    string  str;

    cin >> n >> k;
    cin >> str;

    if (str.at(k-1) == 'A'){

        str.at(k-1) = 'a';

    }else if (str.at(k-1) == 'B'){

        str.at(k-1) = 'b';

    }else{

        str.at(k-1) = 'c';

}



cout << str << endl;



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>

int mod = 1000000007;

int myfunc(long n){
	if (n == 1) {
		return 1;
	}
	else {
		return ((n % mod) * (myfunc(n-1) % mod)) % mod;
	}
}

int main(int argc, char const *argv[]) {
	long dog,mon,temp,ardog,armon;
	std::cin >> dog >> mon;
	//　簡単のため、犬の方を多くしとく
	if (dog < mon) {
		temp = mon;
		mon = dog;
		dog = temp;
	}
	if (dog - mon > 1) {
		std::cout << "0" << '\n';
		return 0;
	}
	ardog = myfunc(dog);
	armon = myfunc(mon);
	if (dog - mon == 1) {
		temp = ((ardog % mod) * (armon % mod)) % mod;
	}
	if (dog - mon == 0) {
		temp = ((ardog % mod) * (armon % mod)) % mod;
		temp = (temp * 2) % mod;
	}
	std::cout << temp << '\n';
	return 0;
}


Measured memory_bytes: 3328
package main
     
    import "fmt"
    import "math"
     
    func main() {
    	var sin, tin string
    	fmt.Scanf("%s\n%s", &sin, &tin)
     
    	s := []byte(sin)
    	t := []byte(tin)
    	ans, tmp := math.MaxInt64, 0
    	//fmt.Println(s)
    	//fmt.Println(t)
    	for i := 0; i <= len(s)-len(t); i++ {
    		tmp = 0
    		for j := 0; j < len(t); j++ {
    			if t[j] != s[j+i] {
    				tmp++
    			}
    		}
    		//fmt.Println(tmp)
    		if ans > tmp {
    			ans = tmp
    		}
    	}
    	fmt.Println(ans)
    }

Measured memory_bytes: 1860
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
	int p,r,l;
};

struct Node T[MAX];

int D[MAX];
int n;

void print(int u){
	int i,c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);
	
	if(T[u].p==NIL){printf("root, ");}
	else if(T[u].l==NIL){printf("leaf, ");}
	else{printf("internal node, ");}
	
	printf("[");
	
	for(i=0,c=T[u].l; c!=NIL; i++,c=T[c].r){
		if(i){
			printf(", ");
		}
		printf("%d",c);
	}
	printf("]\n");
}

int rec(int u, int p){
	D[u]=p;
	if(T[u].r !=NIL){
		rec(T[u].r,p);
	}
	if(T[u].l !=NIL){
		rec(T[u].l,p+1);
	}
}

int main(void){
	int i,j,d,v,c,l,r;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++) T[i].p=T[i].l=T[i].r=NIL;

	
	for(i=0; i<n;i++){
		scanf("%d %d",&v,&d);
		
		for(j=0; j<d;j++){
			scanf("%d",&c);
			if(j==0) T[v].l=c;
			else T[l].r=c;
			l=c;
			T[c].p=v;
		}
	}
	
	for(i=0; i<n;i++){
		if(T[i].p==NIL){
			r=i;
		}
	}	
	rec(r,0);
	
	for(i=0; i<n;i++){
		print(i);
	}

	return 0;
}


Measured memory_bytes: 6388
#include<iostream>
using namespace std;
int main()
{int s,a=0;
cin>>s;
for(int i=0,m=100;i<3;i++,m=m/10)
   { 
   if((s/m)%10==1)
   a++;
   else continue;}
   cout<<a<<endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long
const int INT=100000000;
int dist[100005];
int par[100005];
bool vis[100005];
vector<int> adj[100005];

void bfs(int node) {
    
    dist[node] = 0;
    
    par[node] = -1;
    
    queue<pair<int,int> > q;
    q.push(make_pair(node,dist[node]));
    
    while(!q.empty()) {
        pair<int,int> p = q.front();
        q.pop();
        int u = p.first;
        int d = p.second;
        
        if(vis[u]) continue;
        vis[u] = true;
        
        for(int v:adj[u]) {
            if(dist[u]+1 < dist[v]) {
                dist[v] = dist[u]+1;
                par[v] = u;
                q.push(make_pair(v,dist[v]));
            }
        }
    }
    
}

int main() 
{
    int n,m;
    cin >> n >> m;
    int x,y;
    
    for(int i=1;i<=n;i++) {
        dist[i] = INT;
        par[i] = -1;
    }
    
    for(int i=1;i<=m;i++){
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    bfs(1);
    
    for(int i=2;i<=n;i++){
        if(dist[i]>=INT || par[i]==-1) {
            cout<<"No\n";
            return 0;
        }
    }
    
    cout<<"Yes\n";
    
    for(int i=2;i<=n;i++) cout<<par[i]<<endl;
    
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while(first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if(last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}

string S;

int main() {
    cin >> S;
    auto s = split(S, '/');
    int sum = stoi(s[0] + s[1] + s[2]);
    if(sum > 20190430) {
        cout << "TBD"
             << "\n";
    } else {
        cout << "Heisei"
             << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define LL long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

#define MAX_NUM 1000000007
int main(){
	LL n, m;
	cin >> n >> m;

	if(abs(n - m) > 1){
		cout << 0 << endl;
		return 0;
	}
	LL inu = 1;
	LL saru = 1;
	LL ans;
	REP(i, n){
		inu = (inu * (i + 1)) % MAX_NUM; 
	}
	REP(i, m){
		saru = (saru * (i + 1)) % MAX_NUM;
	}
//	cout << inu << " " << saru << endl;
	if(abs(n - m) == 1){
		ans = inu * saru % MAX_NUM;
	}else{
		ans = inu * saru % MAX_NUM;
		ans = ans * 2 % MAX_NUM;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    int k;
    cin>>k;
    string s;
    cin>>s;
    int happy=0;
    rep(i,0,n-1)if(s[i]==s[i+1])happy++;

    cout<<min(n-1,2*k+happy)<<endl;
    return 0;
}




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

#define MOD 1000000007

vector< pair<int, int> > X;

long long dp[3003];
long long fact[200005], mmi[200005];

long long power(long long N, long long expo)
{
    long long ans = 1;
    
    while(expo)
    {
        if(expo % 2)
            ans = ans * N % MOD;
        
        N = N * N % MOD;
        expo /= 2;
    }
    
    return ans;
}

long long nCr(int N, int r)
{
    if(N < r)
        return 0;
    
    return fact[N] * mmi[r] % MOD * mmi[N-r] % MOD;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int H, W, N;
    cin >> H >> W >> N;
    
    for(int i=0; i<N; i++)
    {
        int x, y;
        cin >> x >> y;
        
        X.push_back({x, y});
    }
    
    X.push_back({H, W});
    sort(X.begin(), X.end());
    
    fact[0] = mmi[0] = 1;
    
    for(int i=1; i<=200000; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
        mmi[i] = power(fact[i], MOD-2);
    }
    
    for(int i=0; i<X.size(); i++)
    {
        int x = X[i].first;
        int y = X[i].second;
        
        dp[i] = nCr((x-1) + (y-1), x-1);
        
        for(int j=0; j<i; j++)
        {
            if(X[j].second > y)
                continue;
            
            int p = X[j].first;
            int q = X[j].second;
            
            dp[i] -= dp[j] * nCr((x-p) + (y-q), x-p) % MOD;
            dp[i] += MOD;
        }
        
        dp[i] %= MOD;
    }
    
    cout << dp[X.size()-1] << "\n";
    return 0;
}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	string s, t;
	cin >> s >> t;
	int a = 0;
	rep(i, 3){
		a += (s[i] == t[i]);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep (i, n) cin >> a[i];
  rep (i, n - 1) a[0] = __gcd(a[0], a[i + 1]);
  rep (i, a[0] + 1) if (i > 0 && a[0] % i == 0) cout << i << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

// メイン関数
int main() {

	int N;
	cin >> N;

	int M;
	cin >> M;

	vector<vector<int>> num(N, vector<int>());

	size_t s = 0;
	int c = 0;
	for (int i = 0; i < M; i++) {
		cin >> s;
		cin >> c;
		if (num[s - 1].end() == find(num[s - 1].begin(), num[s - 1].end(), c)) {
			num[s - 1].push_back(c);
		}
	}

	if (num[0].size() == 0) {
		if (N > 1) {
			num[0].push_back(1);
		}
		else {
			num[0].push_back(0);
		}
	}

	int ans = 0;
	for (size_t i = 0; i < N; i++) {
		if (num[i].size() == 1) {
			ans += num[i][0] * pow(10, (N - 1 - i));
		}
		else if (num[i].size() == 0) {
			continue;
		}
		else {
			ans = -1;
			break;
		}
	}

	int minval = pow(10, (N - 1));
	if (minval == 1) {
		minval = 0;
	}
	if (ans < minval) {
		ans = -1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//AtCoder ABC082 A - Round Up the Mean
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    double a,b;
    cin>>a>>b;
    double x=(a+b)/2.0;
    cout<<(ll)(x+0.5)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define ll         	long long int
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,n)   	for(ll i =0;i<n;i++)
#define inf 		INT_MAX
#define pll 		pair<ll, pair<ll,ll>>
const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
void solve(){
	
	ll N;
	cin>>N;
	ll ans = 0;

	for(ll i = 2;i<=1000010; i++){
		ll cur = 0;
		while(N%i == 0){
			cur++;
			N /= i;
		}

		for(ll j = 1;j<=10000 ;j++){
			if(cur < j)
				break;
			ans++;
			cur -=j;
		}
	}
	if(N > 1){		// If N = is already prime number
		//cout<<"N = "<<N<<endl;
		ans++;
	}
	cout<<ans<<endl;

	
}
int main(){
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}


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

int main() {
	int N, C, X, D[30][39], t[3][30] = { 0 };
	cin >> N >> C;
	int i, j, k, l;
	for (i = 0;i < C;i++) {
		for (j = 0;j < C;j++) cin >> D[i][j];
	}
	for (i = 0;i < N;i++) {
		for (j = 0;j < N;j++) {
			cin >> X;
			t[(i + j) % 3][X - 1]++;
		}
	}
	int iwamin = 1 << 30;
	for (i = 0;i < C;i++) {
		for (j = 0;j < C;j++) {
			if (i != j) {
				for (k = 0;k < C;k++) {
					if (k != i && k != j) {
						int iwa = 0;
						for (l = 0;l < C;l++) iwa += D[l][i] * t[0][l];
						for (l = 0;l < C;l++) iwa += D[l][j] * t[1][l];
						for (l = 0;l < C;l++) iwa += D[l][k] * t[2][l];
						if (iwamin > iwa) iwamin = iwa;
					}
				}
			}
		}
	}
	cout << iwamin << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    double sum=0;
    for(uint i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(float(v[i])>=sum/(4*m))
        {
            count++;
            if(count>=m)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        
    }
   cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3612
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m>>k;
	if(n==0 && m==0){
		cout<<1;
		return 0;
	}
	if(n == 0){
		cout<<m/k+1<<"\n";
		return 0;
	}
	cout<<((m/k - (n-1)/k));
    return 0;
}
//.........

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

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

  bool flag;
  for(int i=0;i<26;i++){
    flag=false;
    for(int j=0;j<S.size();j++){
      if(i==S.at(j)-97) flag=true;
    }
    if(!flag){
      char ans=97+i;
      cout << ans << endl;
      return 0;
    }
  }
  cout << "None" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> d(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    // reverse(ALL(d));
    vector<ll> imos(n + 1, 0);
    imos[0] = 1;
    imos[1] = -1;
    for (ll i = 0; i < n; i++)
    {
        if (d[i] / 10 == 0)
        {
            continue;
        }
        ll end = min(i + d[i] / 10 + 1, n);
        imos[i + 1]++;
        imos[end]--;
    }
    for (ll i = 1; i <= n; i++)
    {
        imos[i] += imos[i - 1];
    }
    for (ll i = 0; i < n; i++)
    {
        if (imos[i] == 0)
        {
            cout << "no" << endl;
            return 0;
        }
    }
    // for (ll i = 0; i < n; i++)
    // {
    //     cout << imos[i] << ' ';
    // }
    // cout << endl;
    reverse(ALL(d));
    vector<ll> imos2(n + 1, 0);
    imos2[0] = 1;
    imos2[1] = -1;
    for (ll i = 0; i < n; i++)
    {
        if (d[i] / 10 == 0)
        {
            continue;
        }
        ll end = min(i + d[i] / 10 + 1, n);
        imos2[i + 1]++;
        imos2[end]--;
    }
    for (ll i = 1; i <= n; i++)
    {
        imos2[i] += imos2[i - 1];
    }
    // for (ll i = 0; i < n; i++)
    // {
    //     cout << imos2[i] << ' ';
    // }
    // cout << endl;
    for (ll i = 0; i < n; i++)
    {
        if (imos2[i] == 0)
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 9864
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(dead_code)]

use std::fmt::Debug;
use std::io::BufRead;
use std::io::Stdin;
use std::io::StdinLock;
use std::str::FromStr;

pub struct Scanner<'a> {
    // stdin: Stdin,
    buf_read: Box<BufRead + 'a>,
    tokens: Vec<String>,
}

impl<'a> Scanner<'a> {
    pub fn new(buf_read: StdinLock<'a>) -> Self {
        Scanner {
            buf_read: Box::new(buf_read),
            tokens: Vec::new(),
        }
    }

    // pub fn from_stdin() -> Self {
    //     let stdin = Box::leak(Box::new(std::io::stdin()));
    //     Self {
    //         buf_read: Box::new(stdin.lock()),
    //         tokens: Vec::new(),
    //     }
    // }

    pub fn next(&mut self) -> String {
        while self.tokens.is_empty() {
            let mut s = String::new();
            if self.buf_read.read_line(&mut s).is_err() {
                panic!()
            }
            self.tokens = s
                .split_whitespace()
                .filter(|s| !s.is_empty())
                .rev()
                .map(str::to_string)
                .collect();
        }
        self.tokens.pop().unwrap()
    }

    pub fn next_g<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn usize(&mut self) -> usize {
        self.next_g()
    }

    pub fn i64(&mut self) -> i64 {
        self.next_g()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let a = sc.i64();
    let b = sc.i64();
    println!("{}", if a * b % 2 == 1 { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,c,k=map(int,input().split())
    ans=0
    person=0
    wait=-10**9
    T=[int(input())for _ in range(n)]
    T.sort()
    for i in range(n):
        if T[i]-wait<=k and person+1<=c:
            person+=1
        else:
            ans+=1
            person=1
            wait=T[i]
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 44380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int MAX = 200010;

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;
}
//main関数にCOMinit();を忘れない


int main(){
    COMinit();

    ll N,M,K; cin>>N>>M>>K;
    ll ans=0ll;
    for(int i=0;i<N;++i){
        for (int j = 0; j < M; ++j) {
            ll tmp=((N-i)*(M-j)%MOD)*(i+j)%MOD;
            if(i>0&&j>0) tmp*=2ll;
            (ans+=tmp)%=MOD;
        }
    }

    (ans*=COM(N*M-2,K-2))%=MOD;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))
s = 1
for i in range(N):
    if A[i] == 0:
        s = 0
        i += 1
if s == 0:
    print(0)
else:
    for i in range(N):
        s = s * A[i]
        if s > 10**18:
            break
        i += 1
    if s > 10**18:
        print(-1)
    else:
        print(s)

Measured memory_bytes: 84628
N=int(input())
A=list(map(int,input().split()))
B=sorted(A)
a=B[N//2-1]
b=B[N//2]
if a==b:
  for i in range(N):
    print(a)
else:
  for i in A:
    if i>((a+b)/2):
      print(a)
    else:
      print(b)

Measured memory_bytes: 26352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL x; cin >> x;
	bitset<32> b = x;
	cout << b << endl;
	cout << ~b << endl;
	cout << (b << 1) << endl;
	cout << (b >> 1) << endl;
}


Measured memory_bytes: 3168
import java.io.*;
import java.util.*;
import java.util.Map.*;

public class Main {
	static final int MOD = (int)1e9+7;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			map.put(a, map.containsKey(a) ? map.get(a) + 1 : 1);
		}
		
		int res = 0;
		
		for(Entry<Integer,Integer> ent : map.entrySet()) {
			if(ent.getKey() < ent.getValue()) {
				res += ent.getValue() - ent.getKey();
			}else if(ent.getKey() > ent.getValue()){
				res += ent.getValue();
			}
		}
		
		out.println(res);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
	
	public static long factorial(int n) {
		long a;
		
		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}
		
		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 45488
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  if(min(B,D)-max(A,C)<0) printf("0\n");
  else printf("%d\n",min(B,D)-max(A,C));
  return 0;
}


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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	int n;
	cin >> n;
	int k = 0;
	int koft = 0;
	long long ans = 0;

	int a[n * 3];
	for (int i = 0; i < n * 3; ++i) 
		cin >> a[i];

	sort(a, a + n * 3, greater<int>());

	while (k < n) {
		ans += a[koft * 2 + 1];
		k++;
		koft++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        var sb = new StringBuilder();
        for (int l = 1; l <= n; l++) {
            int cnt = 0;
            for (int i = 1; i < 100; i++) {
                for (int j = 1; j < 100; j++) {
                    for (int k = 1; k < 100; k++) {
                        if (i * i + j * j + k * k + i * j + j * k + k * i > l) {
                            break;
                        }
                        if (i * i + j * j + k * k + i * j + j * k + k * i == l) {
                            cnt++;
                        }
                    }
                }
            }
            sb.append(cnt);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 35908
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long s,s1,ans,s2;
    cin>>s;
    s1=s;
    if(s1%500==0)
    {
        ans=(s1/500)*1000;
        cout<<ans<<endl;
    }
    else
    {
        s2=s1%500;
        s1=s1-s2;
        ans=(s1/500)*1000;
        s2=s2/5;
        ans+=(s2*5);
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

int mm[4][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };

int main(int argc, char *argv[])
{
  int H, W;
  string ss[54];
  cin >> H >> W;
  for (int i = 0; i < H; i++) cin >> ss[i];

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ss[i][j] == '.') continue;

      for (int k = 0; k < 4; k++) {
        int yy = i + mm[k][0];
        int xx = j + mm[k][1];
        if ((yy >= 0) && (yy < H) && (xx >= 0) && (xx < W)) {
          if (ss[yy][xx] == '#' || ss[yy][xx] == 'x') {
            ss[yy][xx] = 'x';
            ss[i][j] = 'x';
          }
        }
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ss[i][j] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import math

kosuu = int(input())
arr = list(map(int, input().split()))

hoge =1

if 0 in arr:
    print(0)

else:
    for num in arr:
        hoge = hoge*num
        if hoge>1000000000000000000:
            print(-1)
            kosuu=0
            break
    if kosuu>0:
        print(hoge)


Measured memory_bytes: 22708
n_paper = int(input())
vote_data = {}
for _ in range(n_paper):
    votename = input()
    if votename in vote_data:
        vote_data[votename] += 1
    else:
        vote_data[votename] = 1

max_n_vote = max(vote_data.values())
winners = [x for x in vote_data.keys() if vote_data[x] == max_n_vote]
winners.sort()
for winner in winners:
    print(winner)

Measured memory_bytes: 32096
package main

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

func main() {
	n := readInt()
	l := make([]int, n)
	for i := range l {
		l[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(l)))

	ans := 0
	for i := range l {
		for j := i + 1; j < n-1; j++ {
			if l[j+1] <= l[i]-l[j] {
				break
			}
			s := j + 1
			e := upperBound(l, s, len(l)-1, l[i]-l[j])
			ans += e - s + 1
		}
	}

	fmt.Println(ans)
}

func upperBound(a []int, l, r, v int) int {
	for l < r {
		if a[r] > v {
			return r
		}
		m := (l + r) / 2
		if a[m] > v {
			if l == m {
				return l
			}
			l = m
		} else {
			r = m - 1
		}
	}
	return l
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
a,b,c = map(int,input().split())
tmp = 0
flag = 0
for i in range(100):
    tmp += a
    if tmp % b == c:
        flag = 1
        break

if flag == 1:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 2940
def cmb(s, t, r):
    x = 1
    y = 1
    for i in range(t):
        x = (x*(s-i))%r
        y = (y*(i+1))%r
 
    y_inverse = pow(y, r-2, r)
    return (x*y_inverse)%r


# inputを高速化する。
import sys
input = sys.stdin.readline

rid = 10 ** 9 + 7

n, a, b = map(int, input().split())

ans = pow(2, n, rid) - 1

ans -= cmb(n, a, rid) + cmb(n, b, rid)

print(ans % rid)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
int main() {

	int N, A, B, C, D, E, F;

	std::cin >> N >> A >> B >> C >> D;

	if (N % A == 0) {
		E = N / A * B;
	}
	else {
		E = (N / A + 1)*B;
	}
	if (N % C == 0) {
		F = N / C * D;
	}
	else {
		F = (N / C + 1)* D;
	}
	std::cout << std::min({ E, F }) << std::endl;

	return 0;

}


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

#define ntest 0

using namespace std;
int n;
long long a[200005], f[201000], res;
const int mod = 1e9 + 7;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        f[i] = f[i-1] + a[i];
    }
    res = 0;
    for (int i = 2; i <= n; ++i) {
        res = (res + (a[i] * (f[i-1]%mod) % mod)) % mod;
    }
    cout << res << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 6768
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U =sc.next();

		if(S.equals(U)) {
			System.out.println((A-1) + " " + B);
		} else {
			System.out.println(A + " " + (B-1));
		}
	}
}




Measured memory_bytes: 23892
k = input()
k = int(k)
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(arr[k-1])

Measured memory_bytes: 3060
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=sum([p[i] for i in range(k)])
if n==k:
  ans=l
else:
  ans=0
for i in range(n-k):
  l-=p[i]
  l+=p[i+k]
  ans=max(l,ans)
print('{:.12f}'.format((ans+k)/2))

Measured memory_bytes: 24804
# xをseedとしてどんどんlunlun数を作成する関数. 
# uppe lim = 3234566667
K = int(input())
lunlun_arr = []

#dfs(x)はxを格納して, 次のnodeのdfsを実行する関数.
def dfs(x):
    if x<= 3234566667:
        lunlun_arr.append(x)
        for i in range(10):
            if abs(x%10-i)<=1:
                dfs(10*x + i)
    return lunlun_arr

for seed in range(1,10):
    dfs(seed)

lunlun_arr.sort()
print(lunlun_arr[K-1])

Measured memory_bytes: 7708
import bisect
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0

for i in range(1, K + 1):#i個以下取り出し、K - i個以下戻す＃１００
  nownow = 0
  for p in range(i + 1):#[0:i] から [N - i:N]まで取り出さないところを選べる#100
    #[p:p + N - i]を取り出さない
    if i < N:
      now = sorted(V[:p] + V[p + N - i:])
    else:
      now = V
    #print(now, i, p)
    index = bisect.bisect_right(now, 0)
    #index個の負の数がある。
    if K - i >= index:
      nownow = sum(now[index:])
    else:
      nownow = sum(now[K - i:])
    ans = max(ans, nownow)
    #print(now, nownow, ans)

print(ans)      
      

Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

typedef long long int ll;
const int INF =1e11;


int N;
int h[100005];

int dp[100005];

int main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>h[i];
    for(int i=0;i<N;++i)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<N;++i){
        dp[i+1]=min(dp[i]+abs(h[i+1]-h[i]),dp[i+1]);
        dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+2]);
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <complex>
#define print(a) cout << a << endl;
using namespace std;
typedef complex<double> P;

//三角形の内部にあるか
bool is_in_triangle(double cross1, double cross2, double cross3) {
    return((cross1 > 0 && cross2 > 0 && cross3 > 0) || (cross1 < 0 && cross2 < 0 && cross3 < 0));
}
//ベクトルの引き算
P subVector(P a, P b) {
    return(P(a.real() - b.real(), a.imag() - b.imag()));
}

int main(void) {
    double x1, y1, x2, y2, x3, y3, px, py;
    
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &px, &py) != EOF) {
        P a(x1, y1), b(x2, y2), c(x3, y3), p(px, py);
        //辺ベクトル、頂点と辺とのベクトル
        P ab = subVector(b, a), bc = subVector(c, b), ca = subVector(a, c);
        P bp = subVector(p, b), cp = subVector(p, c), ap = subVector(p, a);
        //外積(z成分のみ)
        double cross1 = ab.real() * bp.imag() - ab.imag() * bp.real(),
               cross2 = bc.real() * cp.imag() - bc.imag() * cp.real(),
               cross3 = ca.real() * ap.imag() - ca.imag() * ap.real();
        //判定
        if(is_in_triangle(cross1, cross2, cross3)) cout << "YES" << endl;
        else                                       cout << "NO"  << endl;
    }
    return(0);
}

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

using namespace std;

int main() {
	int N;
	while (cin >> N, N) {
		vector<int> data(N, 0);

		int ba = 0;
		int turn = 0;
		string str; cin >> str;
		for (int t = 0; t < str.size(); ++t) {
			switch (str[t]) {
				case 'M': // テ」ツつェテ」ツδ暗」ツつウ
					++data[turn];
					break;

				case 'S': // テ・ツ敖甘、ツクツサ
					++data[turn];
					ba += data[turn];
					data[turn] = 0;
					break;

				case 'L': // テ・ツァツォ
					++data[turn];
					data[turn] += ba; ba = 0;
					break;
			}
			turn = (turn + 1) % N;
		}

		sort( data.begin(), data.end() );
		for (int i = 0; i < data.size(); ++i) {
			cout << data[i] << " ";
		}
		cout << ba << endl;
	}
}

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

int main(){
   int64_t h;
   cin >> h;
   int64_t m = 1;
   int64_t ans = 1;
   while(h>1){
      h /= 2;
      m *= 2;
      ans += m;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
import sys
n=int(input())
data={}
for i in range(1,5):
	for j in range(1,4):
		for k in range(1,11):
			data[(i,j,k)]=0
			

for i in range(1,n+1):
	b,r,f,v=map(int,input().split())
	data[(b,r,f)]+=v

for i in range(1,5):
	for j in range(1,4):
		for k in range(1,11):
			sys.stdout.write(' '+str(data[(i,j,k)]))
		print('')
	if i<4:
		print('#'*20)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,i,b[6];
	while(cin>>n,n){
		int a[86400]={0},ans=0,s=0;
		while(n--){
			scanf("%d:%d:%d %d:%d:%d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5]);
			a[b[0]*3600+b[1]*60+b[2]]++;
			a[b[3]*3600+b[4]*60+b[5]]--;
		}
		for(i=0;i<86400;i++){
			s+=a[i];
			ans=max(ans,s);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3468
use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

use std::collections::VecDeque;
use std::cmp::Ordering;

#[macro_use]
extern crate lazy_static;

lazy_static! {
    static ref DIR:Vec<(isize, isize)> = vec![
        (-1, 0),
        (1, 0),
        (0, -1),
        (0, 1),
    ];
}

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: isize,
        x1: Usize1,
        y1: Usize1,
        x2: Usize1,
        y2: Usize1,
        c: [Chars; h]
    }

    let mut costs = vec![vec![None; w]; h];
    let mut queue = VecDeque::new();
    costs[x1][y1] = Some(0);
    queue.push_back((0, (x1 as isize, y1 as isize)));

    while let Some((cost, pos)) = queue.pop_front() {
        let cost = cost + 1;
        for d in DIR.iter() {
            for i in 1isize..=k {
                let pos = (pos.0 + d.0 * i, pos.1 + d.1 * i);
                if pos.0 == x2 as isize && pos.1 == y2 as isize {
                    println!("{}", cost);
                    return;
                }
                if pos.0 < 0 || pos.1 < 0 || pos.0 as usize >= h || pos.1 as usize >= w {
                    break;
                }
                let pos = (pos.0 as usize, pos.1 as usize);
                if c[pos.0][pos.1] == '@' {
                    break;
                }
                if let Some(c) = costs[pos.0][pos.1] {
                    match c.cmp(&cost) {
                        Ordering::Less => { break; },
                        Ordering::Equal => { continue; },
                        Ordering::Greater => {},
                    }
                }

                costs[pos.0][pos.1] = Some(cost);
                queue.push_back((cost, (pos.0 as isize, pos.1 as isize)));
            }
        }
    }

    println!("-1");
}

Measured memory_bytes: 17768