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


using namespace std;

#define re return
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 0; i < int(n); i++)


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

const ll mod = 1000 * 1000 * 1000 + 7;
const ll ma = 128 * 1024;
ll n, a, b, mi[2 * ma], dp[2][ma];
vector<ll> s;

ll get_min(int l, int r) {
	if (l > r)
		re max(a, b) + 100LL;
	if (l % 2)
		re min(mi[l], get_min(l + 1, r));
	if (r % 2 == 0)
		re min(mi[r], get_min(l, r - 1));
	re get_min(l / 2, r / 2);
}

int main() {
	iostream::sync_with_stdio(0);
	//freopen("a.in", "r", stdin);
	cin >> n >> a >> b;
	//cout << mod << endl;
	s.resize(n);
	forn (i, n) {
		cin >> s[i];
	}
	forn (i, n - 1) {
		mi[i + ma] = s[i + 1] - s[i];
	}
	for (int j = ma - 1; j; j--) {
		mi[j] = min(mi[2 * j], mi[2 * j + 1]);
	}
	dp[0][0] = dp[1][0] = 1LL;
	for (int i = 1; i < n; i++) {
		int nu = upper_bound(s.begin(), s.end(), s[i] - a) - s.begin() - 1;
		if (get_min(ma + nu + 1, ma + i - 2) >= b) {
			if (nu == -1)
				dp[0][i] += 1LL;
			else {
				if (nu + 1 == i) {
					dp[0][i] += dp[0][nu];
				} else {
					int nu1 = upper_bound(s.begin(), s.end(), s[nu + 1] - b) - s.begin();
					if (get_min(ma + nu1, ma + nu - 1) >= a) {
						if (nu1 >= nu)
							dp[0][i] += dp[0][nu];
						else
							dp[0][i] += dp[0][nu1];
					}
				}
				if (nu + 1 == i || s[nu + 1] - s[nu] >= b)
					dp[0][i] += dp[1][nu];
			}
		}
		nu = upper_bound(s.begin(), s.end(), s[i] - b) - s.begin() - 1;
		if (get_min(ma + nu + 1, ma + i - 2) >= a) {
			if (nu == -1)
				dp[1][i] += 1LL;
			else {
				if (nu + 1 == i) {
					dp[1][i] += dp[1][nu];
				} else {
					int nu1 = upper_bound(s.begin(), s.end(), s[nu + 1] - a) - s.begin();
					if (get_min(ma + nu1, ma + nu - 1) >= b) {
						if (nu1 >= nu)
							dp[1][i] += dp[1][nu];
						else
							dp[1][i] += dp[1][nu1];
					}	
				}
				if (nu + 1 == i || s[nu + 1] - s[nu] >= a)
					dp[1][i] += dp[0][nu];
			}
		}
		dp[0][i] %= mod;
		dp[1][i] %= mod;
		if (dp[0][i] == 0 && dp[1][i] == 0) {
			cout << 0 << endl;
			re 0;
		}
		//cout << dp[0][i] << " " << dp[1][i] << endl;
	}
	cout << ((dp[0][n - 1] + dp[1][n - 1]) % mod + mod) % mod << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>>A(N);
    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        A[i-1] = {a, i};
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; ++i) {
        cout << A[i].second << " ";
    }
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int ans = 10000000;
		int [] [] in = new int [n][m+1];
       
        for(int i=0;i<n;i++){
                             for(int j=0;j<=m;j++){in[i][j] = sc.nextInt();}
                            }
        int max = 1;
        for(int i=0;i<n;i++){max*=2;}
        max--;
        int [] check = new int [n];  
        for(int i=0;i<=max;i++){int p = i; int cost = 0; int bool = 0;
                                for(int j=0;j<n;j++){check[j]=p%2;p/=2;}
                                for(int j=0;j<n;j++){cost+=in[j][0]*check[j];}
                                for(int j=1;j<=m;j++){int skill=0;
                                                      for(int k=0;k<n;k++){skill+=in[k][j]*check[k];}
                                                      if(skill<x){bool=1;}
                                                     }
                               if(bool==0){ans=Math.min(ans,cost);}
                               }        
        if(ans==10000000){ans=-1;}
		System.out.println(ans);
}
}

Measured memory_bytes: 37696
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 1000000007
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      ll  power(ll  i,ll  j)
      {
        if(j==0)
        return 1 ;
        ll t=power(i,j/2)%maa ;
        if(j%2==0)
        return (t%maa*t%maa)%maa ;
        else
        return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
      }
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      ll n,k ;
      ll r[100001] ;
      ll dp[100001] ;
      ll fun(ll i)
      {
          if(i==n)
          return 0 ;
          else if(dp[i]!=-1)
          return dp[i] ;
          else
          {
              ll j=i+1 ;
              ll ans=LLONG_MAX ;
              for(ll j=i+1;j<=min(n,i+k);j++)
              {
                  ans=min(ans,fun(j)+abs(r[i]-r[j])) ;
              }
              return dp[i]=ans ;
          }
      }
      int main()
      {

        /// 50-4
        /// freopen("input.txt","r",stdin);
        /// freopen("output.txt","w",stdout);
        cin>>n>>k ;
        for(ll i=1;i<=n;i++)
        cin>>r[i] ;
         
        for(ll i=0;i<=n;i++)
        {
            dp[i]=-1 ;
        }
        cout<<fun(1)<<endl ;
        
        
        
        
        
      }








Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

long long modpow(long long a, long long n, long long mod) {//a^n(mod)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;//次の準備
        n >>= 1;
    }
    return res;
}

signed main(){
  ll n,m,ans=1,xsum=0,ysum=0;cin>>n>>m;
  vector<ll> x(n),y(m);
  for(int i=0;i < n;i++)
  {
    cin>>x[i];
    if(i){
      xsum+=((x[i]-x[i-1])*i %mod)*(n-i) %mod;
    }
  }
  xsum%=mod;

  for(int i=0;i < m;i++)
  {
    cin>>y[i];
    if(i){
      ysum+=((y[i]-y[i-1])*i %mod)*(m-i) %mod;
    }
  }
  ysum%=mod;

  ans*=xsum;ans%=mod;
  
  ans*=ysum;ans%=mod;

  cout<<ans<<endl;
}





Measured memory_bytes: 1792
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
//	   cin>>t;

	      while(t--)
{
/*
3
1 2 3*/
ll n,m,i;
cin>>n;
ll a[n],c=0;
fo(i,n)
{
	cin>>a[i];
	if(a[i]%2==1)
	c++;
}
if(c%2==1)
NN;
else
YY;
ee;
}
return 0;
}














Measured memory_bytes: 4356
import sys

a, b, c, d = map(int, input())

if a+b+c+d==7:
    print ("%d+%d+%d+%d=7" % (a,b,c,d))
elif a+b+c-d==7:
    print ("%d+%d+%d-%d=7" % (a,b,c,d))
elif a+b-c+d==7:
    print ("%d+%d-%d+%d=7" % (a,b,c,d))
elif a+b-c-d==7:
    print ("%d+%d-%d-%d=7" % (a,b,c,d))
elif a-b+c+d==7:
    print ("%d-%d+%d+%d=7" % (a,b,c,d))
elif a-b+c-d==7:
    print ("%d-%d+%d-%d=7" % (a,b,c,d))
elif a-b-c+d==7:
    print ("%d-%d-%d+%d=7" % (a,b,c,d))
elif a-b-c-d==7:
    print ("%d-%d-%d-%d=7" % (a,b,c,d))

Measured memory_bytes: 3064
import java.util.*;

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

        long val1 = sc.nextLong();

        long count = ("" + val1).length();
        for (long i = 1; (i * i) <= val1; i++) {
            if ((val1 % i) != 0) {
                continue;
            }
            long n = val1 / i;
            String a = "" + i;
            String b = "" + n;
            long val = Math.max(a.length(), b.length());
            if (count > val) {
                count = val;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,m;
  string s;
  cin>>s>>N;
  rep(i,(ll)s.size()){
    if(s[i]=='a')continue;
    m='z'-s[i]+1;
    if(m<=N){
      s[i]='a';
      N-=m;
    }
  }
  s[s.size()-1]='a'+(s[s.size()-1]-'a'+N)%26;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 592
#include<iostream>

int main(void) {
	int n, m, l;
	std::cin >> n >> m >> l;
	unsigned long A[101][101] = {};
	unsigned long B[101][101] = {};
	for (int ROW = 0; ROW < n; ++ROW) {
		for (int COLOUM = 0; COLOUM < m; ++COLOUM) {
			std::cin >> A[ROW][COLOUM];
		}
	}
	for (int ROW = 0; ROW < m; ++ROW) {
		for (int COLOUM = 0; COLOUM < l; ++COLOUM) {
			std::cin >> B[ROW][COLOUM];
		}
	}
	for (int ROW = 0; ROW < n; ++ROW) {
		for (int COLOUM=0; COLOUM < l; ++COLOUM) {
			unsigned long ELEMENT = 0;
			for (int ElementSum = 0; ElementSum < m; ++ElementSum) {
				ELEMENT += A[ROW][ElementSum] * B[ElementSum][COLOUM];
			}
			if (COLOUM == l - 1) {
				std::cout << ELEMENT << std::endl;
				break;
			}
			std::cout << ELEMENT << " ";
		}
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 3244
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
		string s,t;
		int a,b;
		string u;
		cin >> s >> t >> a >> b >> u;
		if (u==s) a--;
		else b--;
		cout << a <<  " " << b << endl;
		return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    bool visited[n];
    memset(visited , false , sizeof(visited));
    int c = 0;
    int k = 0;
    while(!visited[1]){
        if(!visited[k]){
            visited[k] = true;
            k = a[k] -1;
            c++;
        }else break;
    }
    if(visited[1]){
        cout<<c -1<<endl;
    }else cout<<-1<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {

            var N = Sarray()[0];
            if (N < 1000)
                WriteLine("ABC");
            else
                WriteLine("ABD");
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

void to_lower(string &s){
    int dif = 'a'-'A';
    for(auto &c : s){
        if(c >= 'A' && c <= 'Z'){
            c += dif;
        }
    }
}

int main() {
    string s = "", w;
    int cnt;
    cin >> w;
    to_lower(w);
    while(1){
        cin >> s;
        if(s == "END_OF_TEXT") break;
        to_lower(s);
        if(s==w)cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3176
import sys, os
from queue import PriorityQueue

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    if a+b>=10:
        print('error')
    else:
        print(a+b)

solve()


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int k,a,b;
  cin >> k >> a >> b;
  
  for(int i=a;i<=b;i++){
    if(i%k==0){
     cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG" << endl;
}




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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cll ll t;cin>>t;while(t--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<ll,ll>
typedef vector<ll> vll;
#define fi first
#define se second

ll mod=1e9+7;

int main(){
    faster;

    ll n,d,a;
    cin>>n>>d>>a;

    vector<pii> cor(n);
    rep(i,n){
        cin>>cor[i].first;
        cin>>cor[i].second;
    }

    set<pii> ans;
    sort(cor.begin(),cor.end());
    ll tmp1=0;
    ll count=0;

    rep(i,n){
        ll tmp=cor[i].second;
        vector<pii> tmp2;
        
        for(auto j:ans){
            if(j.first<cor[i].first) {tmp1-=j.second; tmp2.push_back({j.first,j.second});}
            else break;
        }
        for(auto l:tmp2){
            ans.erase({l.first,l.second});
        }
        
        tmp-=tmp1;
        if(tmp<=0) continue;
        count+=tmp/a+(tmp%a!=0);
        tmp1+=a*(tmp/a+(tmp%a!=0));
        ans.insert({cor[i].first+2*d,a*(tmp/a+(tmp%a!=0))});
    }

    cout<<count<<endl;
}

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


/*
 * N=3,M=3
 * H=2,4,3
 * 1-2
 * 2-3
 * 1-3
 * 1->2,3 2->1,3 3->1,2
*/
int main()
{
	int N,M;
	cin>>N>>M;
	vector<ll> H(N);
	rep(i,N) cin>>H[i];
	//一本の道を辿っていける展望台のうち最も高いも高さ
	vector<ll> height(N,-1);
	rep(i,M)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		height[a]=max(height[a],H[b]);
		height[b]=max(height[b],H[a]);
	}
	int ans=0;
	rep(i,N)
	{
		if(H[i]>height[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4844
import sys
input = sys.stdin.readline

def binary_search_int(ok, ng, solve):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    return ok, ng

##############################################################

def solve(x):
    """ ある点 x を境にして True と False が二分されるような関数"""
    return N - K*x >= 0

N, K = map(int, input().split())

a, b = binary_search_int(0, 10**18, solve)
print(min(abs(N-a*K), abs(N-b*K)))


Measured memory_bytes: 62036
#include <bits/stdc++.h>
using namespace std; 
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    map<pair<int, int>, int> store ;
    for (int i=0; i<n; i++){
        double no;
        long long lno;
        cin >> no;
        lno = llround(no*1e9);
        int two = 0, five = 0;
        while(lno%2==0)
            two++, lno >>= 1;
        while(lno%5==0)
            five++, lno /= 5;
        store[{two, five}]++;
    }
    long long ans = 0;
    for (auto i: store)
        for (auto j: store)
            if (i.first.first+j.first.first>=18 && i.first.second+j.first.second>=18){
                if (i<j)
                    ans += 1ll*i.second*j.second;
                else if (i==j)
                    ans += 1ll*i.second*(i.second-1)/2;
            }
    cout << ans <<"\n";
}


Measured memory_bytes: 3716
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
int main() {
	int N;
	cin >> N;
  long int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += i;
  }
  cout << sum << endl;
  return 0;
}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

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



int main(){
    int a;
    cin >> a;

    cout << a + a*a + a*a*a << endl;

}


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

using namespace std; 

int main() {
    int n,m,i,j,k,x,a;
    cin>>n>>m;
    i=a=0;
    int arr[m]={0};
    while(i<n){
      j=0;
      cin>>k;
      while(j<k){
        cin>>x;
        arr[x-1]++;
        j++;
      }
      i++;
    }
    i=0;
    while(i<m){
      if(arr[i]>=n)
        a++;
      i++;
    }
    cout<<a<<endl;
    return 0;
}


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

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

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

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) { for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i]; }
	CuSum(int N) : cusum(N + 1) {}

	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()) - 1; i++) cusum[i + 1] += cusum[i]; }

	T query(int l, int r /*[l, r) */) { return cusum[r] - cusum[l]; }
};

int main() {

	cin.tie(0);

	int N;
	string S;
	cin >> N >> S;

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

		if (S[i] == '#') cul.add(i,1);

	}
	cul.init();

	int ans = INF, changes;
	for (int i = 0; i < N; i++) {

		changes = cul.query(0, i) + (N - 1 - i - cul.query(i + 1, N));
		ans = ans > changes ? changes : ans;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1412
#include <iostream>

int main(void){
    int n, a, b, cnt=0, cnt_f=0;
    std::string s, ans="";
    std::cin >> n >> a >> b >> s;

    for(char c: s){
        if (c == 'c'){
            ans = "No";
        } else if (c == 'a'){
            if (a + b > cnt){
                ans = "Yes";
                ++cnt;
            } else {
                ans = "No";
            }
        } else {
            if (a + b > cnt && b > cnt_f){
                ans = "Yes";
                ++cnt;
                ++cnt_f;
            } else {
                ans = "No";
            }
        }
        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3732
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k, n %= k;
    cout << min(n, abs(n - k));
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  map<int, int> mp;
  for(int i = 1; i <= 100; ++i) {
    for(int j = 1; j <= 100; ++j) {
      if(i*i + j*j + i*j > n) break;
      for(int k = 1; k <= 100; ++k) {
        if(i*i+j*j+k*k+i*j+j*k+k*i > n) break;
        ++mp[i*i+j*j+k*k+i*j+j*k+k*i];
      }
    }
  }
  for(int i = 1; i <= n; ++i) cout << mp[i] << endl;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    ll m=n;
    ll res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    if(m%res==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long X;
        X = sc.nextLong();
        solve(X);
    }

    static void solve(long X){
        long a = X % 500;
        long ans = X / 500 * 1000;
        ans += a /5 * 5;
        System.out.println(ans);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 24532
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int arr[]=new int[26];

		for(int i=0;i<arr.length;i++) {
			arr[i]=0;
		}

		int a='a';
		for(int i=0;i<s.length();i++) {
			int num = s.charAt(i)-a;
			arr[num]=1;
		}
		for(int i=0;i<26;i++) {
			if(arr[i]==0) {
				char ans=(char)(a+i);
				System.out.println(ans);
				break;
			}
			else if(i==25)System.out.println("None");
		}

	}

}


Measured memory_bytes: 23932
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        System.out.println(process(readAll(System.in)));
    }

    protected static String process(String data) {
        StringBuilder sb = new StringBuilder();

        final String[] lines = splitForLines(data);
        final int[] input = split(lines[1]);

        for (int i = 0; i < input.length; i++) {
            if (i > 0) {
                sb.append(' ');
            }
            sb.append(input[input.length - 1 - i]);
        }

        return sb.toString();
    }

    private static String readAll(InputStream is) {
        InputStreamReader r = null;
        BufferedReader br = null;

        try {
            r = new InputStreamReader(is);
            br = new BufferedReader(r);
            StringBuilder sb = new StringBuilder();
            String s;

            while ((s = br.readLine()) != null) {
                sb.append(s).append('\n');
            }

            return sb.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                }
            }
            if (r != null) {
                try {
                    r.close();
                } catch (IOException e) {
                }
            }
        }
    }

    private static int[] split(String s) {
        final String[] s0 = s.split(" ");
        int[] ia = new int[s0.length];

        for (int i = 0; i < s0.length; i++) {
            ia[i] = Integer.parseInt(s0[i]);
        }

        return ia;
    }

    private static String[] splitForLines(String lines) {
        return lines.split("\\n");
    }

}

Measured memory_bytes: 16964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    int n = Integer.parseInt(s);

    String w[] = new String[555];
    HashSet<String> set = new HashSet<>();
    
    for(int i = 0; i < n; i++)
    {
      String e = r.readLine();
      w[i] = e;
      set.add(e);
    }
    
    if(set.size() != n)
    {
      System.out.println("No");
      System.exit(0);
    }
    
    for(int i = 0; i < n - 1; i++)
    {
      if(w[i].charAt(w[i].length() - 1) != w[i + 1].charAt(0))
      {
        System.out.println("No");
        System.exit(0);
      }
    }
    
    System.out.println("Yes");
  }

}


Measured memory_bytes: 22740
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  printf("%d %d %d\n", z, x, y);
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    fast_io;
    int t, f=0;
    cin>>t;
    while(t!=0)
    {
        int r=t%10;
        if(r==7)
        {
            f=1;
            break;
        }
        t/=10;
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  int sum = 0;
  rep(i, n) {
    cin >> a[i];
    int cnt = 0;
    while(a[i]%2 == 0) {
      a[i] >>= 1;
      ++cnt;
    }
    sum += cnt;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 384
n,k=map(int,input().split())
x=sorted(list(map(int,input().split())))
a=[]
for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))
print(min(a))

Measured memory_bytes: 14224
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A <= 9 && B <= 9)
			System.out.println(A*B);
		else
			System.out.println(-1);

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;


int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
	return 0;
}

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

using namespace std;

void solve() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> l(Q), r(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> l[i] >> r[i];
    }
    
    vector<int> ac(N+1);
    ac[0] = 0;
    for (int i = 1; i < N; i++)
    {
        ac[i] = ac[i-1];
        if (S[i-1] == 'A' && S[i] == 'C')
        {
            ac[i]++;
        }
    }
    for (int i = 0; i < Q; i++)
    {
        cout << ac[r[i]-1] -ac[l[i]-1] << endl; 
    }
    
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4580
//ΔAGC024D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111;
int n,d[N],s[N],g[N],f;
vector<int> v[N],b;
LL ans;
void dfs(int u,int fa){
	int i,x;
	for(i=v[u].size();i--;){
		x=v[u][i];
		if(x!=fa){
			d[x]=d[u]+1;
			dfs(x,u);
		}
	}
}
void solve(LL t){
	int i;
	for(i=1;i<=n;i=i+1)
		g[i]=0;
	for(i=1;i<=n;i=i+1)
		g[d[i]]=max(g[d[i]],s[i]-1);
	for(i=1;g[i];i=i+1)
		t*=g[i];
	if(i<f||(i==f&&t<ans))
		f=i,ans=t;
}
int main()
{
	int i,x,y;
	cin>>n;
	for(i=1;i<n;i=i+1){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
		s[x]++,s[y]++;
	}
	f=n;
	for(i=1;i<=n;i=i+1){
		d[i]=1;
		dfs(i,0);
		s[i]++;
		solve(1);
		s[i]--;
		for(x=v[i].size();x--;){
			y=v[i][x];
			d[i]=1,d[y]=1;
			dfs(i,y),dfs(y,i);
			solve(2);
		}
	}
	cout<<f<<' '<<ans;
	return 0;
}

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

stack<int> temp;
struct Node {
    int parent;
    int left;
    int right;
};
Node tree[25];

void preorder(int node) {
    printf(" %d", node);
    if(tree[node].left != -1) {
        preorder(tree[node].left);
    }
    if(tree[node].right != -1) {
        preorder(tree[node].right);
    }
}

void inorder(int node) {
    temp.push(node);
    if(tree[node].left != -1) {
        inorder(tree[node].left);
    }
    printf(" %d", temp.top());
    temp.pop();
    if(tree[node].right != -1) {
        inorder(tree[node].right);
    }
}

void postorder(int node){
    temp.push(node);
    if(tree[node].left != -1){
        postorder(tree[node].left);
    }
    if(tree[node].right != -1){
        postorder(tree[node].right);
    }
    printf(" %d", temp.top());
    temp.pop();
}
int findRoot(int node){
    while(tree[node].parent != -1){
        node = tree[node].parent;
    }
    return node; 
}

int main() {
    int n, it, left, right,parentNode;
    cin >> n;
    for(int i = 0; i < n; i++) {
        tree[i].parent = tree[i].right = tree[i].left = -1;
    }
    for(int i = 0; i < n; i++) {
        scanf("%d %d %d", &it, &left, &right);
        tree[it].left = left;
        tree[it].right = right;
        if(left != -1) {
            tree[left].parent = it;
        }
        if(right != -1) {
            tree[right].parent = it;
        }
    }
    parentNode = findRoot(0);
    cout << "Preorder" << endl;
    preorder(parentNode);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(parentNode);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(parentNode);
    cout << endl;
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 111;

int n, a[N];
int dp[N][5][5][5];

int mapping(char c){
   if(c == 'A')return 0;
   if(c == 'G')return 1;
   if(c == 'C')return 2;
   return 3;
}

vector<char> v;
int solve(int idx, int P3, int P2, int P1){
   if(idx >= n){
      return 1;
   }

   int &ans = dp[idx][P3+1][P2+1][P1+1];
   if(ans != -1)
      return ans;

   ans = 0;
   for(auto it: v){
      if(it == 'G' and P2 == 0 and P1 == 2){
         continue;
      }
      if(it == 'C' and P2 == 0 and P1 == 1){
         continue;
      }
      if(it == 'C' and P2 == 1 and P1 == 0){
         continue;
      }
      if(it == 'C' and P3 == 0 and P1 == 1 and (P2 >= 1)){
         continue;
      }
      if(it == 'C' and P3 == 0 and P2 == 1 and (P1 != 2)){
         continue;
      }
      ans += solve(idx+1, P2, P1, mapping(it));
      if(ans >= mod)ans -= mod;
   }

   return ans;
}

int32_t main(){_

   cin>>n;
   v = {'A', 'G', 'C', 'T'};
   
   int ans = 0;
   memset(dp, -1, sizeof dp);
   for (int i = 0; i < sz(v); ++i)
   {
      for (int j = 0; j < sz(v); ++j)
      {
         for (int k = 0; k < sz(v); ++k)
         {
            string str(1, v[i]);
            str += v[j];
            str += v[k];
            if(str == "ACG" or str == "GAC" or str == "AGC")continue;
            ans += solve(3, mapping(str[0]), mapping(str[1]), mapping(str[2]));
            ans %= mod;
         }
      }
   }
   // cout<<solve(0, -1, -1, -1);
   cout<<ans;
   #warning make sure N size is correct!
   return 0;
}

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

#define endl '\n'

using namespace std;

struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int maxn = 1e5 + 3;
const int mod = 1e9 + 7;

long long fast_pow(long long x, int deg)
{
	long long ans = 1, y = x;
	while (deg)
	{
		if (deg & 1)
			ans = ans * y % mod;

		deg >>= 1;

		y = y * y % mod;
	}

	return ans;
}

long long add(long long a, long long b)
{
	a += b;
	if (a >= mod)
		a -= mod;

	if (a < 0)
		a += mod;

	return a; 
}

int n, k; 
void read()
{
	cin >> n >> k; 
}

long long f[maxn];
void solve()
{
	long long ans = 0; 
	for (int i = k; i >= 1; i--)
	{
		f[i] = fast_pow(k / i, n);
		for (int j = i * 2; j <= k; j += i)
			f[i] = add(f[i], -f[j]);

        ans = add(ans, f[i] * i % mod);
	}

	cout << ans << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}

Measured memory_bytes: 4380
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) ll(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 1e5 + 5;

int a[105];

signed main(){
    fastio;
    int i,n;
    cin>>n;
    for(i=0;i<n;++i){
        cin>>a[i];
    }
    for(i=0;i<n;++i){
        if(!(a[i] & 1)){
            if(!(a[i]%3==0 || a[i]%5==0)){
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, j, k, c = 0;
    int K, S;
    scanf("%d %d", &K, &S);
    for ( i = 0; i <= K; i++ ){
        for ( j = 0; j <= K; j++ ){
            k = S - (i+j);
            if ( k >= 0 && k <= K ){
                c++;
            }
        }
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define FOR(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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
const ll MOD = 1000000007;
 
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 MAX = 510000;

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

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

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




int main() {
   ll ans = 1;

       // 前処理
    COMinit();


   ll N,M;
   int a = -1;
   cin >> N >> M;
   rep(i,M+1)
   {
      ll b = N+1;
      if(i<M) cin >> b;
      ll c = b-a-2;
      if (b != 1 && c == -1) {ans = 0; break;}
      ll com = 0;
      rep (j,c/2+1) //COMの処理
      {
         com += COM(c-j,j)% MOD ;
         com = com %MOD;
      }
      ans *= com % MOD;
      ans = ans % MOD;
      a = b;
   }
   cout << ans << endl;
}

Measured memory_bytes: 12160