akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

template<typename T>
map<T, T> prime_factorize(T n) {
	map<T, T> ret;
	for(T i = 2; i * i <= n; ++i) {
		while( n % i == 0 ) {
			ret[i]++;
			n /= i;
		}
	}
	
	if( n != 1 ) ret[n] = 1;
	
	return ret;
}

int main(void) {
	ll n;
	cin >> n;
	
	ll ans = 1LL;
	map<ll, ll> cnt;
	
	for(ll i = 1; i <= n; ++i) {
		map<ll, ll> mp = prime_factorize(i);
	
		for(auto& x : mp) {
			cnt[x.first] += x.second;
		}
	}
	
	for(auto& b : cnt) {
		ans *= (b.second + 1LL);
		ans %= MOD_LL;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ll n,i;
	cin>>n;
	ll a[n+1],b[n+1],c[n+1];
	ll dp[n+1][4]={0};
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];
	for(i=2;i<=n;i++)
	{
		
			dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
				dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
					dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
			
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,M;
  cin >>N>>M;
  vector<int>S(M);
  vector<int>C(M);
  for(int i=0;i<M;i++){
    cin>>S.at(i)>>C.at(i);
  }
  if(N==1){
    if(M==0){
      cout<<0<<endl;
      return 0;
    }
    if(M==1){
      cout<<C.at(0)<<endl;
      return 0;
    }else{
      int sum=0;
      rep(i,M){
        sum+=C.at(i);
      }
      double heikin=(double)sum/(double)M;
      rep(i,M){
        if(C.at(i)!=heikin){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }else if(N==2){
    if(M==0){
      cout<<10<<endl;
      return 0;
    }
    int sum1=0;
    int sum2=0;
    int count1=0;
    int count2=0;
    double heikin1=0;
    double heikin2=0;
    bool hantei=false;
    rep(i,M){
      if(S.at(i)==1){
        sum1+=C.at(i);
        count1++;
      }
      if(S.at(i)==2){
        sum2+=C.at(i);
        count2++;
        hantei=true;
      }  
    }
    if(count1!=0)heikin1=(double)sum1/(double)count1;
    if(count2!=0)heikin2=(double)sum2/(double)count2;
    rep(i,M){
      if(S.at(i)==1){
        if((double)C.at(i)!=heikin1){
          cout<<-1<<endl;
          return 0;
        }
      }
      if(S.at(i)==2){
        if((double)C.at(i)!=heikin2){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
    if(heikin1+heikin2==0){
      if(hantei==true){
        cout<<10<<endl;
        return 0;
      }else{
        cout<<-1<<endl;
        return 0;
      }
    }
    if(heikin1==0)heikin1=1;
    int kotae=(int)heikin1*10+(int)heikin2;
    cout<<kotae<<endl;
    return 0;
  }else{
    if(M==0){
      cout<<100<<endl;
      return 0;
    }
    int sum1=0;
    int sum2=0;
    int sum3=0;
    int count1=0;
    int count2=0;
    int count3=0;
    double heikin1=0;
    double heikin2=0;
    double heikin3=0;
    bool hantei=false;
    rep(i,M){
      if(S.at(i)==1){
        sum1+=C.at(i);
        count1++;
      }
      if(S.at(i)==2){
        sum2+=C.at(i);
        count2++;
        hantei=true;
      }  
      if(S.at(i)==3){
        sum3+=C.at(i);
        count3++;
        hantei=true;
      }  
    }
    if(count1!=0)heikin1=(double)sum1/(double)count1;
    if(count2!=0)heikin2=(double)sum2/(double)count2;
    if(count3!=0)heikin3=(double)sum3/(double)count3;
    rep(i,M){
      if(S.at(i)==1){
        if((double)C.at(i)!=heikin1){
          cout<<-1<<endl;
          return 0;
        }
      }
      if(S.at(i)==2){
        if((double)C.at(i)!=heikin2){
          cout<<-1<<endl;
          return 0;
        }
      }
      if(S.at(i)==3){
        if((double)C.at(i)!=heikin3){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
    if(heikin1+heikin2+heikin3==0){
      if(hantei==true){
        cout<<100<<endl;
        return 0;
      }else{
        cout<<-1<<endl;
        return 0;
      }
    }
    if(heikin1==0)heikin1=1;
    int kotae=(int)heikin1*100+(int)heikin2*10+(int)heikin3;
    cout<<kotae<<endl;
    return 0;
  }
  return 0;
}

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

bool solve( std::vector<int>& A, int i, int m, int n ){
    //std::cout << m << " ";
    if( m == 0 ){
        return true;
    }else if( i >= n ){
        return false;
    }
    return ( solve( A, i + 1, m, n ) || solve( A, i + 1, m - A[i], n ) );   
}

int main(){
    std::cin.tie(0);

    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for( auto& a : A ){
        std::cin >> a;
    }

    int q;
    std::cin >> q;
    int m;
    bool flag = false;
    for( int i = 0; i < q; ++i ){
        std::cin >> m;
        for( int j = 0; j < n; ++j ){
            if( solve( A, j, m, n ) ){
                flag = true;
                break;
            }
        }
        std::cout << ( flag? "yes" : "no" ) << "\n";
        flag = false;
    }
}


Measured memory_bytes: 3088
import random
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
numans=0
s=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s.append(list(map(int,input().split())))
    for j in range(26):
        num5=s[i-1][j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    numans+=num2+s[i-1][num1-1]
    num[num1-1]=i
def sco(n1,n2,n3):
    n0=0
    n01=[0]*26
    old=ans[n1]
    ans[n1]=n2
    for k in range(n3):
        n0+=s[k][ans[k]-1]
        n01[ans[k]-1]=k+1
        for l in range(26):
            n0-=(k+1-n01[l])*c[l]
    return n0
for i in range(1540):
    num6=random.randint(1,26)
    num7=random.randint(1,365)
    num100=sco(num7-1,num6,d)
    if num100>numans:
        ans[num7-1]=num6
for i in range(d):
    print(ans[i])


Measured memory_bytes: 9844
// ABC_071_B

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

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

	vector<char> c(s.size());
	for(int i = 0; i < s.size(); ++i) {
		c[i] = s[i];
	}

	set<char> s_char(c.begin(), c.end());
	vector<char> v_char(s_char.begin(), s_char.end());
	sort(v_char.begin(), v_char.end());
	
	//for(int i = 0; i < v_char.size(); ++i) cout << v_char[i];
	//cout << "\n";

	char ans = ' ';

	if(s_char.size() == 26) cout << "None" << "\n";
	else if(s_char.size() == 1 && v_char[0] != 'z') cout << char(v_char[0] + 1) << "\n";
	else if(v_char[0] != 'a') cout << 'a' << "\n";
	else {
		for(int i = 0; i < v_char.size()-1; ++i) {
			if((int)v_char[i] + 1 == (int)v_char[i+1]) ans = v_char[v_char.size()-1];
			else {
				ans = v_char[i];
				break;
			}
		}

		//cout  << ans << "\n";
		cout << char(ans + 1) << "\n";

	}

	//cout  << ans << "\n";
	//cout << ans + 1 << "\n";

	return 0;
}                   

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=105;
char s[N][N];
int dp[N][N],n,m,a[N][N];
void chmin(int &a,int b){if(a>b)a=b;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='.');
	memset(dp,0x3f,sizeof(dp));
	dp[0][1]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			chmin(dp[i][j],dp[i-1][j]+(s[i][j]=='#'));
			chmin(dp[i][j],dp[i][j-1]+(s[i][j]=='#'));
			for(int k=1;k<=i;k++)
				for(int l=1;l<=j;l++)
					if(a[i][j]-a[i][l-1]-a[k-1][j]+a[k-1][l-1]==0)
						chmin(dp[i][j],dp[k][l]);
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
int mod=1e9+7;
int arr[22][22];
int dp[22][(1<<21)+1];
int n;
int fun(int pos,int mask)
{
    if(pos==n)
    {
        return 1;
    }
    if(dp[pos][mask]!=-1)
        return dp[pos][mask];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(arr[pos][i]==1 && (mask&(1<<i))==0)
        {
            ans+=fun(pos+1,mask|(1<<i));
            ans%=mod;
        }
    }
    return dp[pos][mask]=ans;
}
int main()
{
//    READ;
    sf(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            sf(arr[i][j]);
        }
    }
    mem(dp,-1);
    cout<<fun(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 180480
def main():
    import numpy as np
    a, b, h, m = map(int, input().split())
    x = h + m / 60
    p = x % 12
    s, t = p / 12 * 360, m / 60 * 360

    d = min(t + 360 - s, abs(s-t))
    ans = a ** 2 + b ** 2 - 2 * a * b * np.cos(np.pi * d / 180)
    print(ans ** 0.5)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27200
#include <iostream>

using namespace std;

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

    int n, k;
    unsigned int pattern = 1;
    cin >> n >> k;

    pattern *= k;
    for (int i = 1; i < n; i++)
    {
        pattern *= k - 1;
    }

    cout << pattern;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int N, ans=0;
	string s;
	stack<char> st;

	cin >> s;
	for(auto c: s){
		if( st.size() && c == 'T' && st.top() == 'S' ){
			st.pop();
		}else{
			st.push(c);
		}
	}

	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 644
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);

int a;
a= sc.nextInt();
int b;
b= sc.nextInt();

if(a<b){
System.out.println("a < b");
}

else if(a>b){
System.out.println("a > b");
}

else{
System.out.println("a == b");
}

}
}



Measured memory_bytes: 26248
#include<stdio.h>
int main(void)
{
	int n;
	int a[100];
	int i,j,s;
	int c=0;
	int f=1;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	while(f==1)
	{
		f=0;
		for(j=n-1;j>0;j--)
		{
			if(a[j]<a[j-1])
			{
				s=a[j];
				a[j]=a[j-1];
				a[j-1]=s;
				c++;
				f=1;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d",a[i]);
		if(i!=n-1)
		{
			printf(" ");
		}
		else
		{
			printf("\n");
		}
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2132
#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;
const int MAX_HW = 1005;
char S[MAX_HW][MAX_HW];
int ans[MAX_HW][MAX_HW];
int H,W;
int dx[5] = {-2,-1,0,1,2}, dy[5] = {-2,-1,0,1,2};
int dx2[4] = {0,1,0,-1}, dy2[4] = {1,0,-1,0};

void init()
{
	rep(i,MAX_HW)
	{
		rep(j,MAX_HW)
		{
			ans[i][j] = 1e9;
		}
	}
}

int main()
{
	init();
	cin >> H >> W;
	int Ch,Cw,Dh,Dw;
	cin >> Ch >> Cw >> Dh >> Dw;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> S[i][j];
		}
	}

	/*
	dfs(Ch-1,Cw-1,0);
	int cnt = 1;
	while(true)
	{
		now++;
		while(!Q[now].empty())
		{
			P p = Q[now].front();
			Q[now].pop();
			//cout << "aa" << p.first << " " << p.second << " " << ans[p.first][p.second] << " " << cnt << endl;
			if (ans[p.first][p.second] == cnt)
			{
				//cout << "b" << endl;
				dfs(p.first,p.second,cnt);
			}
		}
		if (Q[now+1].empty()) break;
		cnt++;
	}
	*/

	deque<pair<P,int> > D;
	D.push_front(make_pair(P(Ch-1,Cw-1),0));	
	while(!D.empty())
	{
		pair<P,int> p = D.front();
		D.pop_front();
		int i = p.first.first, j = p.first.second, c = p.second;
		if (ans[i][j] < c) continue;
		rep(ii,4)
		{
			int newi = i+dx2[ii], newj = j+dy2[ii];
			//cout << newi << " " << newj << endl;
			if (newi >= 0 && newi < H && newj >= 0 && newj < W && S[newi][newj] == '.')
			{
				//cout << "b" << endl;
				if (ans[newi][newj] > c)
				{
					ans[newi][newj] = c;
					D.push_front(make_pair(P(newi,newj),c));
				}
			}
		}


		rep(ii,5)
		{
			rep(jj,5)
			{
				int newi = i+dx[ii], newj = j+dy[jj];
				if (newi >= 0 && newi < H && newj >= 0 && newj < W && S[newi][newj] == '.')
				{
					if (ans[newi][newj] > c+1)
					{
						ans[newi][newj] = c+1;
						D.push_back(make_pair(P(newi,newj),c+1));
					}
				}
			}
		}

	}

	/*
	rep(i,H)
	{
		rep(j,W)
		{
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	*/

	if (ans[Dh-1][Dw-1] != 1e9) cout << ans[Dh-1][Dw-1] << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 8608
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();}
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);}
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


signed main(){
    int k,q;
    cin>>k>>q;
    Vi d(k);
    REP(i,0,k){
        cin>>d[i];
    }

    REP(Q,0,q){
        int n,x,m;
        cin>>n>>x>>m;
        x %= m;
        Vi newd(k);
        REP(i,0,k){
            newd[i]=d[i]%m;
        }
        Vi num0(k+1);
        REP(i,1,k+1){
            if(newd[i-1]==0) num0[i]=num0[i-1]+1;
            else num0[i]=num0[i-1];
        }
        Vi sumd=accum(newd);

        int num0s=num0[k];
        int sum=sumd[k];

        int allsum=x+((n-1)/k)*sum+sumd[(n-1)%k];
        int count0 = ((n-1)/k)*num0s + num0[(n-1)%k];
        // vout(num0);
        // vout(sumd);
        // cout<<allsum<<" "<<num0s<<endl;
        cout<<(n-1)-allsum/m-count0<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

int main() {
    int n,m;
    cin>>n>>m;
    vector<int>x(m);
    for(int i=0;i<m;i++){
        cin>>x.at(i);
    }
    sort(x.begin(), x.end());
    vector<int>a(m-1);
    for(int i=0;i<m-1;i++){
        a.at(i)=x.at(i+1)-x.at(i);
    }
    sort(a.begin(), a.end());
    int ans=0;
    for(int i=0;i<m-n;i++){
        ans+=a.at(i);
    }
    cout<<ans<<endl;





    return 0;
}


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

int main() {
	int a[100];
	int N,M;
	int f = 1;
	int p;
	
	cin >> N >> M;

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


	while (f) {
		for (int i = 1; i <= N; i++) {
			if (a[i - 1] < a[i] && i != N) {
				p = a[i - 1];
				a[i - 1] = a[i];
				a[i] = p;
				break;
			}
			if (i == N) f = 0;
		}
	}

	int sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += a[i - 1];
	}

	if (a[M-1] * 4 * M >= sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;


int main()
{
    ciosup;
    int n;
    cin >> n;
    int now = n,keta=0;
    while(now > 0){
        now /= 10;
        ++keta;
    }
    int ans=0;
    while (keta > 0)
    {
        if (keta % 2 == 0){
            int hiku = pow(10, keta - 1);
            n = hiku - 1;
        }
        else
        {
            int hiku = pow(10, keta - 1);
            ans += n - hiku + 1;
            n = hiku - 1;
        }
        keta--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

class UnionFind{
  vi p,r;
public:
  UnionFind(int n):p(n,-1),r(n,0){ }
  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }
  bool same(int x,int y){return find(x)==find(y);}
  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }
};


int main(){
  int n;
  cin >> n;
  vector<pii> x(n), y(n);
  rep(i, n) {
    x[i].second = i;
    y[i].second = i;
    cin >> x[i].first >> y[i].first;
  }
  sort(all(x));
  sort(all(y));

  vector<pair<int, pii>> edges;
  rep(i,n-1) {
    edges.emplace_back(x[i+1].first-x[i].first, pii(x[i+1].second, x[i].second));
  }
  rep(i,n-1) {
    edges.emplace_back(y[i+1].first-y[i].first, pii(y[i+1].second, y[i].second));
  }

  sort(all(edges));
  ll ans = 0;
  UnionFind uf(n);
  for (auto edge : edges) {
    if(uf.same(edge.second.first, edge.second.second)) {
      continue;
    }
    ans += edge.first;
    uf.unite(edge.second.first, edge.second.second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll h,w;
	while(true){
		cin >> h >> w;
		if(h==0&&w==0)
			return 0;
		rep(i,h){
			rep(j,w){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int c = 0;
    REP(i, s.size() - 1) {
        if (s[i] == s[i + 1]) c++;
    }
    cout << min(c + k * 2, n - 1) << endl;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int sum = b+c;
    int cnt = 0;
    while (cnt <= a) {
        if (sum%a == 0) {
            cout << "YES" << endl;
            return 0;
        }
        sum += b;
        cnt++;
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
def resolve():
    from collections import Counter

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    n=int(input())
    fact = dict(Counter(prime_factorize(n)))
    cal={}
    ans=0
    for i in fact.values():
        if i not in cal.keys():
            cal[i]=int(((1+8*i)**(1/2)-1)//2)
        ans+=cal[i]
    print(ans)

if __name__ == '__main__':
    resolve()

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    int ans = 0;
    for(int i = 0; i < M; ++i) cin >> B[i];

    for(int i = 0; i < N; ++i) {
        int A;
        int tot = C;
        for(int j = 0; j < M; ++j) {
            int seki;
            cin >> A;
            seki = A*B[j];
            tot += seki;
        }
        if (tot > 0) ++ans;
    
    }
    cout << ans;

}


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
a += [0]
b = -1
ans = [0,0]
count = 0
for i in range(n+1):
    count += 1
    if b != a[i]:
        if count >= 4:
            if ans[0]:
                ans[1] = b
                break
            else:
                ans[0] = b
                ans[1] = b
                break
        elif count >= 2:
            if ans[0]:
                ans[1] = b
                break
            else:ans[0] = b
        b = a[i]
        count = 0
print(ans[0]*ans[1])

Measured memory_bytes: 14252
num = input()
a,b,c,d = int(num[0]),int(num[1]),int(num[2]),int(num[3])

finish = False
if not finish:
    for i in range(2):
        if not finish:
            for j in range(2):
                if not finish:
                    for k in range(2):
                        if a + b*(-1)**i + c*(-1)**j + d*(-1)**k == 7:
                            A = [i,j,k]
                            finish = True 

ans = []
for l in A:
    if l == 0:
        ans.append('+')
    else:
        ans.append('-')
print(str(a)+ans[0]+str(b)+ans[1]+str(c)+ans[2]+str(d)+'=7')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <queue>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  int V[H][W] = {0};
  queue<vector<int>> q;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      char tmp;
      cin >> tmp;
      if (tmp=='#'){
        V[i][j] = 1;
        vector<int> tmpp{i, j, 0};
        q.push(tmpp);
      }
    }
  }
  
  int max_n, i, j, n, ni, nj;
  while (!q.empty()){
    vector<int> v;
    v = q.front();
    
    i = v[0];
    j = v[1];
    n = v[2];
    max_n = n;
    for (int di=-1; di<2; (di = di+2)){
      ni = i + di;
      nj = j;
      if (ni>=0 && ni < H && nj>=0 && nj<W){
        if (V[ni][nj] == 0){
          V[ni][nj] = 1;
          vector<int> tmpp{ni, nj, n+1};
          q.push(tmpp);
        }
      }
    }
    for (int dj=-1; dj<2; (dj = dj+2)){
      ni = i;
      nj = j + dj;
      if (ni>=0 && ni < H && nj>=0 && nj<W){
        if (V[ni][nj] == 0){
          V[ni][nj] = 1;
          vector<int> tmpp{ni, nj, n+1};
          q.push(tmpp);
        }
      }
    }
    q.pop();
  }
  cout << max_n << endl;
}

Measured memory_bytes: 59572
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
typedef long long int I;
#define INF 2,147,483,646 //intの最大値-1

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}

/*
https://atcoder.jp/contests/abc153/tasks/abc153_e
*/

int main(){
    long long int n,h;
    bool flag=false;
    int m=0;
    int dp[100000];
    for(int i=0;i<100000;i++){
        dp[i]=pow(10,9);
    }
    dp[0]=0;

   
    cin>>h>>n;
    vector<int> A(n),B(n);
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i];
        m=max(m,B[i]);
    } //A->AT, B->MP

    for(int i=0;i<=h;i++){
        for(int j=0;j<n;j++){
            dp[i+A[j]] = min(B[j]+dp[i], dp[i+A[j]]);
        }
    }
    int ans=dp[h];
    for(int i=h;i<h+m;i++){
        ans=min(ans,dp[i]);
    }
    
    cout<<ans<<endl;
   
    return 0;
} //カモンAC

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

int main() {
  int m,n;
  cin>>n>>m;
  vector<int> a(m);
  int result=n;
  for(int i=0;i<m;i++){
    cin>>a.at(i);
    result-=a.at(i);
  }
  if(result>=0){
    cout<<result<<endl;
  }else{
    cout<<-1<<endl;
  }
  
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

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


int main(){
    string s;
    cin >> s;
    bool ans = true;
    Rep(i,3){
        if(s[i] == s[i+1]) ans = false;
    }
    if(ans) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast std::ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

void solve(){
    int c,y;
    cin>>c;
    
    int one=0,two=0,four=0;
    for(int i=0;i<c;i++){
        cin>>y;
        if(y%4==0)
             four++;
        else if (y%2==0)
             two++;
        else 
             one++;
    }
    int temp=min(one,four);
    one-=temp;
    four-=temp; 
    if(one==0||(one==1&&two==0))
       cout<<"Yes";
    else  
      cout<<"No";
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
int n,ans=1,sum=1,a[105];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)ans=ans*3;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(a[i]%2==0)sum*=2;
	}
	printf("%d",ans-sum);
	return 0;
}

Measured memory_bytes: 128
#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;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

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

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

	cin >> N >> M >> L >> R;
	L += M - 1;
	N += R - 1;
	if (N / R >= L / M)cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}

int a, b, pw[233];

inline int l2(int n) {
  for (int k = 60; k >= 0; k --) {
    if (n >> k & 1) return k;
  }        
}

main(void) {
  pw[0] = 1;
  for (int i = 1; i <= 60; i ++)
    pw[i] = pw[i - 1] * 2;
  read(a); read(b);
  if (a == b)
    return puts("1"), 0;
  for (int k = 60; k >= 0; k --) {
    if ((a >> k & 1) && (b >> k & 1))
      a ^= 1ll << k, b ^= 1ll << k;
    else if ((a >> k & 1) || (b >> k & 1))
      break;
  }
  // cout << a << " " << b << "\n";
  int s = l2(a);
  int t = l2(b);
  int tmp = b == pw[t] ? 0 : pw[(int) l2(b - pw[t]) + 1] - 1;
  int l = a;
  int r = pw[t] + tmp;
  int qr = pw[t + 1] - 1;
  int ql = pw[t + 1] - (pw[t] - a);
  // cout << l << " " << r << " " << ql << " " << qr << " " << s << " " << t << " " << a << " " << b  << "\n";
  if (ql <= r) {
    cout << qr - l + 1 << "\n";
  } else {
    cout << qr - ql + 1 + r - l + 1 << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,a,b,c;cin>>n>>a>>b>>c;
    string s[n];
    vector<char>ans;
    bool state=1;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        if(s[i]=="AB"){
            if(a>b){
                a--;b++;ans.pb('B');
            }else if(a<b){
                a++;b--;ans.pb('A');
            }else{
                if(i==n-1||s[i+1]=="AB"||s[i+1]=="AC"){
                    a++;b--;ans.pb('A');
                }else{
                    a--;b++;ans.pb('B');
                }
            }
        }
        if(s[i]=="AC"){
            if(a>c){
                a--;c++;ans.pb('C');
            }else if(a<c){
                a++;c--;ans.pb('A');
            }else{
                if(i==n-1||s[i+1]=="AB"||s[i+1]=="AC"){
                    a++;c--;ans.pb('A');
                }else{
                    a--;c++;ans.pb('C');
                }
            }
        }
        if(s[i]=="BC"){
            if(b>c){
                b--;c++;ans.pb('C');
            }else if(b<c){
                b++;c--;ans.pb('B');
            }else{
                if(i==n-1||s[i+1]=="AB"||s[i+1]=="BC"){
                    b++;c--;ans.pb('B');
                }else{
                    b--;c++;ans.pb('C');
                }
            }
        }
        if(a<0||b<0||c<0){
            state=0;break;
        }
    }
    if(state){
        cout<<"Yes\n";for(auto x:ans)cout<<x<<"\n";
    }else{
        cout<<"No\n";
    }
}


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

int main(){
int x; cin >> x;
rep(i,1000){
    x-=100;
    int z=5*(i+1);
   if(x<0){
        cout << "0" << endl;
        break;
    }
    if(x<=z){
        cout << "1" << endl;
        break;
    }
   
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;

int main()
{
	int i, j;
	int a, b;
	scanf("%d%d", &a, &b);
	if (a > b) swap(a, b);
	if (a == 1 && b == 2) printf("3");
	else if (a == 2 && b == 3) printf("1");
	else if (a == 1 && b == 3) printf("2");
}

Measured memory_bytes: 256
short t[9];double*p,s[99],v;main(){for(p=s+2;~scanf("%[^ \n]",t);getchar()-10||printf("%f\n",*--p))v=*--p,*t-43?*t-45?*t-42?*t-47?(sscanf(t,"%lf",&v,p++),*p++=v):(p[-1]/=v):(p[-1]*=v):(p[-1]-=v):(p[-1]+=v);}

Measured memory_bytes: 0
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt()
    call(n, 3)
  }
  def call(n:Int, i:Int){
    if(i % 3 == 0){
      print(" " + i)
    }else{
      def loop(x: Int){
        if(x % 10 == 3){
          print(" " + i)
        }else{
          if(x != 0){
            loop(x / 10)
          }
        }
      }
      loop(i)
    }
    if(i == n){
      println()
    }else{
      call(n, i+1)
    }
  }
}

Measured memory_bytes: 46892
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long action = sc.nextLong() + 1;
		long sell = sc.nextLong();
		long buy = sc.nextLong();
		long cookie = 0;
		for(int i = 0; i < action; i ++) {
			if(i < action - 1 && cookie >= sell && (sell + 2) < buy) {
				cookie += buy - sell;
				i ++;
			}else {
				cookie ++;
			}
		}
		System.out.println(cookie);
	}
}

Measured memory_bytes: 22484
def main():
    a, b, c = map(int, input().split())

    if a + b == c:
        print('Yes')
        return
    if a + c == b:
        print('Yes')
        return
    if a == b + c:
        print('Yes')
        return

    print('No')
    return


if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int 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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    vector<ll> Z(1000);
    REP(i,1000){
        Z[i] = pow(i,5);
    }

    REP(i,999){
        FOR(j,i+1,1000){
            if(Z[j]-Z[i] == X){
                cout << j << " " << i << endl;
                return 0;
            }
            if(Z[j]+Z[i] == X){
                cout << j << " " << -i << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4068
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define M 1000000007
using namespace std;
int n;
ll ans=0;
int num[300];
char c[4]={'A','C','G','T'};
ll f[200][400];
bool flag[200][400];

ll h(string S)
{
    int ans=0;
    for (int i=0; i<3; ++i)
    {
        ans=ans*4+num[S[i]];
    }
    return ans;
}

bool check3(string s)
{
    if (s=="AGC") return 0;
    return 1;
}

bool check2(string s)
{
    for (int i=0; i<=1; ++i)
    {
        if (check3(s.substr(i,3))==0) return 0;
    }
    return 1;
}

bool check(string s)
{
    for (int i=0; i<3; ++i)
    {
        if (check2(s)==0) return 0;
        char t=s[i];
        s[i]=s[i+1];
        s[i+1]=t;
        if (check2(s)==0) return 0;
        t=s[i];
        s[i]=s[i+1];
        s[i+1]=t;
    }

    return 1;
}

ll dp(int n,string S)
{
    if (n<=3)
    {
        if (S=="AGC" || S=="ACG" || S=="GAC") return 0;
        return 1;
    }
    if (flag[n][h(S)]==1)
        return f[n][h(S)];
    flag[n][h(S)]=1;
    f[n][h(S)]=0;

    for (int i=0; i<4; ++i)
    {
        if (check(c[i]+S))
        {
            f[n][h(S)]+=dp(n-1,c[i]+S.substr(0,2));
            f[n][h(S)]%=M;
        }
    }

    return f[n][h(S)];
}


void dfs(int now,string S)
{
    if (now==3)
    {
        //cout<<n<<' '<<S<<' '<<dp(n,S)<<endl;
        ans+=dp(n,S);
        ans%=M;
    }else
    {
        for (int i=0; i<4; ++i)
        {
            dfs(now+1,S+c[i]);
        }
    }
}
        


int main()
{
    num['A']=0;
    num['C']=1;
    num['G']=2;
    num['T']=3;
    cin>>n;

    dfs(0,"");

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



Measured memory_bytes: 640
N = int(input())
a = list(map(int, input().split()))
al = min(a)
ar = max(a)
ans = 1000000000000000
for i in range(al, ar+1):
    tmp = 0
    for j in a:
        tmp += (j-i) ** 2
    if ans > tmp:
        ans = tmp
print(ans)

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

vector< int > Q[30];

int main() {
	
	string s, t;
	char ch1[100005], ch2[100005];
	scanf("%s%s", ch1, ch2);
	s = ch1;
	t = ch2;
	
	int slen = s.length();
	int tlen = t.length();
	
	for(int i=0;i<slen;i++){
		int ch = s[i]-'a';
		Q[ch].push_back(i+1);
	}
	
	long long pre = 0, real = 0, cycle = 0;
	for(int i=0;i<tlen;i++){
		int ch = t[i]-'a';
		if(Q[ch].empty()){
			printf("-1\n");
			return 0;
		}
		int pos = lower_bound(Q[ch].begin(), Q[ch].end(), pre+1)-Q[ch].begin();
		
		if(pos==Q[ch].size()){
			real=(cycle+1)*slen + Q[ch][0];
			cycle++;
			pre = Q[ch][0];
		} else if(Q[ch][pos]>pre){
			real = cycle*slen + Q[ch][pos];
			pre = Q[ch][pos];
		}
	}
	printf("%lld\n", real);
	return 0;
}

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

int main() {
  string s;

  cin >> s;

  int flag = 1;

  rep(i,s.size()){
    if(i%2 == 0){
      if(s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D'){

      }

      else
      {
        flag = 0;
      }
      
    }

    else{
      if(s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D'){}
      else
      {
        flag = 0;
      }
      
    }
  }

  if(flag)
  cout << "Yes";
  else
  {
    cout << "No";
  }
  
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int M = 10;

int x[M], y[M];
int n = 3;
ld a[M], sum = 0;
ld b[M];

void read() {
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
}

ld sq(ld x) {
  return x * x;
}

void kill() {
  for (int i = 0; i < n; ++i) {
    int j = (i + 1) % n;
    int dx = x[i] - x[j];
    int dy = y[i] - y[j];
    a[i] = hypotl(dx, dy);
    sum += a[i];
  }

  ld ans = 0;

  for (int i = 0; i < n; ++i) {
    ld A = a[i];
    ld B = a[(i + 1) % n];
    ld C = a[(i + 2) % n];

    ld b = acosl((sq(A) + sq(C) - sq(B)) / (2 * A * C));
    ld c = acosl((sq(A) + sq(B) - sq(C)) / (2 * B * A));

    ld sum = 1.0 / tanl(b / 2) + 1.0 / tanl(c / 2) + 2;
    ld r = A / sum;

    ans = max(ans, r);
  }


  cout << ans << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  cout.precision(13);
  cout << fixed;

  read();
  kill();

}



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

int main() {
  int N; // 乗客
  int C; // バスの定員
  int K; // 飛行機の到着時刻からKの時間が経過するまでにバスに乗る必要がある
  cin >> N >> C >> K;

  vector<int> T_BEGIN(N);
  vector<int> T_END(N);
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    T_BEGIN.at(i) = n;
    T_END.at(i) = n + K;
  }

  sort(T_BEGIN.begin(), T_BEGIN.end());
  sort(T_END.begin(), T_END.end());

  int ans = 0;
  for (int i = 0; i < N;) {
    // バスに1名乗せる
    int current = i;
    i++;

    // バスに座席が余っている場合、
    // 一人目の搭乗者が待機可能な時間で相乗り可能な乗客を乗せる
    for (int j = 1; j <= (C - 1); j++) {
      // index を超える場合は終了
      if ((current + j) >= N) {
        break;
      }

      if (T_BEGIN.at(current + j) <= T_END.at(current)) {
        i++;
      }
    }
    ans++;
  }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int A , B;
    cin >> A >> B;
    if(A + B <= 23){
        cout << A + B << endl;
    }
    else{
        cout << A + B - 24 << endl;
    }
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int x,y;
bool A;

signed main(){
    cin>>x>>y;
    if(abs(x-y)<=1){
        cout<<"Brown"<<endl;
    }else cout<<"Alice"<<endl;
    return 0;
    
    
    
    
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
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 (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

ll gcd(ll a, ll b) {
	if (b > a) {
		swap(a, b);
	}
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {
	int t;
	cin >> t;
	while (t--) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a < b || d < b) {
			cout << "No" << endl;
			continue;
		}
		if (c >= b) {
			cout << "Yes" << endl;
			continue;
		}
		ll g = gcd(b, d);
		ll offset = a % g;
		ll ma = b - g + offset;
		if (ma > c) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const ll INF = 1e9;

int main() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(3));
    for (auto &a : A) {
        cin >> a[0] >> a[1] >> a[2];
    }
    vector<vector<ll>> DP(N, vector<ll>(3, INF));
    DP[0] = A[0];
    for (int i = 1; i < N; i++) {
        DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + A[i][0];
        DP[i][1] = max(DP[i - 1][2], DP[i - 1][0]) + A[i][1];
        DP[i][2] = max(DP[i - 1][0], DP[i - 1][1]) + A[i][2];
    }
    cout << *max_element(DP[N - 1].begin(), DP[N - 1].end()) << endl;
}


Measured memory_bytes: 11136
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;

#define io(F) string t_="";ifstream fin(t_+F+".in");ofstreamfout(t_+F+".out")
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define setm(A, B, C) if(C) A = min(A, B); else A = max(A, B)
#define graph unordered_map<int, unordered_set<int>>
typedef long long ll;

int main() {
	qio; int n; cin >> n;
	ll sm = 0;
	forl(i, 1, n+1) {
		if(!(i%3) or !(i%5)) continue;
		sm += i;
	}
	println(sm);
}


Measured memory_bytes: 3608