akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string s, t; cin >> s >> t;

  if (s.size() != t.size()) {
    cout << (s.size() > t.size() ? "GREATER" : "LESS");
    return;
  }
  for (size_t i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      cout << (s[i] > t[i] ? "GREATER" : "LESS");
      return;
    }
  }

  cout << "EQUAL" << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
program ABC_072_B_OddString
   implicit none
   integer(8) i
   character(1000000) s
   read(*, *) s
   do i = 2, len_trim(s)
       s(i:i)= s(2*i-1:2*i-1)
   end do
   write(*, *) trim(s)
end program ABC_072_B_OddString

Measured memory_bytes: 1596
if __name__ == '__main__':
    #AB = [int(i) for i in input().split()]
    N = int(input())
    n = 0
    for i in range(3,N+1,2):
        k = 1
        for j in range(2,i+1):
            if i % j == 0:
                k += 1
            if k > 8:
                break
        if k == 8:
            n += 1
    print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
 int res=0;
  while(n>0){
  res+=(n%10);
    n/=10;
  }
  if(res==1) cout << "10" << endl;
  else cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,t,x,y;
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
  	scanf("%d%d%d",&t,&x,&y);
  	if(x+y>t||(t-x-y)%2!=0)
  	{
  	  printf("No");
	  return 0;	
	}
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
long A, B, C, D, index;
  
  scanf("%ld %ld %ld %ld", &A, &B, &C, &D);
  for (index = 0; index < 100; ++index) {
    if (index % 2 == 0) {
      // 高橋君
      C -= B;
    } else {
      // 青木君
      A -= D;
    }
    if (A <= 0 || C <= 0) break;
  }
  if (A <= 0) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
    
  return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int h, n, x;
int main() {
    DAU
    cin >> h >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        h -= x;
    }
    if (h <= 0)
        cout << "Yes";
    else cout << "No";
    PLEC
}


Measured memory_bytes: 256
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
/*
int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}
*/

int main(){
    int n,a[200000];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),asc);

    int cnt=1,sum=0,x;
    for(int i=0;i+1<n;i++){
        if(a[i]==a[i+1]){
            cnt++;
        }else{
            x=cnt-a[i];
            sum+=x<0?cnt:x;
            cnt=1;
        }
    }
    x=cnt-a[n-1];
    sum+=x<0?cnt:x;

    printf("%d\n",sum);

    return 0;
}

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

void trace(int n, int A[]){
    for(int k = 0; k < n; k++){
        if(k == n-1) cout << A[k];
        else cout << A[k] << " ";
    }
    cout << endl;
}

void insertion_sort(int A[], int n){
    for(int i = 0; i < n; i++){
        int val = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > val){ //?????´??? j > 0 ?????£???????????????????????????????????£???
            A[j+1] = A[j];
            j--;
            A[j+1] = val;
        }
        trace(n, A);
    }
}


int main(){
    int N;
    cin >> N;
    int array[N];
    for(int i = 0; i < N; i++){
        cin >> array[i];
    }
    insertion_sort(array,N);
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
using namespace std;
#include <algorithm>
long long int d[100001][3];
long long int maxhappy(long long int a[],long long int b[],long long int c[],long long int n, long long int i,long long int act ){
	if(i==n)
		return 0;
	long long int k;
       if(d[i][act]==0){
       	if(act==0){
                  k=a[i]+ maxhappy(a,b,c,n,i+1,1);
                  k=max(k, a[i]+maxhappy(a,b,c,n,i+1,2));
       	}

      else if(act==1){
      	  k=b[i]+ maxhappy(a,b,c,n,i+1,0);
                  k=max(k, b[i]+maxhappy(a,b,c,n,i+1,2));
      }
 else{
 	k=c[i]+ maxhappy(a,b,c,n,i+1,0);
                  k=max(k, c[i]+maxhappy(a,b,c,n,i+1,1));
 }

    d[i][act]=k;
       
       }


return d[i][act];
}
int main(){
  long long int i,j,k,l,m,n;
  cin>>n;
  long long int a[n+1],b[n+1],c[n+1];
  for(i=1;i<n+1;i++)
  {
  	cin>>a[i]>>b[i]>>c[i];
  }
  k=maxhappy(a,b,c,n+1,1,0);
  l=maxhappy(a,b,c,n+1,1,1);
  m=maxhappy(a,b,c,n+1,1,2);
 cout<<max(k,max(l,m));
}

Measured memory_bytes: 14336
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

ll H,W,N;
vector<vector<ll>> grid;

//dp
vector<vector<ll>> table;
ll dp(ll x,ll y){
  if(x<0||y<0) return 0;
  if(x==0&&y==0) return N-1;
  if(table.at(y).at(x)>-1) return table.at(y).at(x);
  
  table.at(y).at(x)=0;
  table.at(y).at(x)+=dp(x-1,y)/2;
  if(x>0&&dp(x-1,y)%2==1&&grid.at(y).at(x-1)==1) table.at(y).at(x)++;
  
  table.at(y).at(x)+=dp(x,y-1)/2;
  if(y>0&&dp(x,y-1)%2==1&&grid.at(y-1).at(x)==0) table.at(y).at(x)++;
  
  return table.at(y).at(x);
}
  

int main()
{
  while(true){
    cin>>H>>W>>N; if(H==0&&W==0&&N==0) break;
    grid=vector<vector<ll>>(H,vector<ll>(W)); rep(i,H) rep(j,W) cin>>grid.at(i).at(j);
    
    //dp
    table=vector<vector<ll>>(H,vector<ll>(W,-1));
    vector<vector<ll>> vec(H,vector<ll>(W));
    
    rep(y,H){
      rep(x,W){
        if(dp(x,y)%2==0) vec.at(y).at(x)=grid.at(y).at(x);
        else vec.at(y).at(x)=1-grid.at(y).at(x);
      }
    }
    
    //復元
    ll x=0,y=0;
    while(true){
      if(x>=W||y>=H) break;
      if(vec.at(y).at(x)==0) y+=1;
      else x+=1;
    }
    cout<<y+1<<" "<<x+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 26420
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
//abc120b
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int a =sc.nextInt();
		int b =sc.nextInt();
		int k=sc.nextInt();
		int smaller =Math.min(a, b);
		Integer[] divisors =new Integer[smaller+1];
		for (int i=0;i<=smaller;i++) {
			divisors[i] =0;
		}
		for (int i=1;i<=smaller;i++) {
			if (a%i==0&&b%i==0) {
				divisors [i] += i;
			}
		}
		Arrays.sort(divisors, Collections.reverseOrder());
		System.out.println(divisors[k-1]);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場
	
	//----------------------------------------
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

// Union Find {{{
class UnionFind {
 public:
     int n;
     std::vector<int> par;
     std::vector<int> num;

     explicit UnionFind(int n) {  // [0 n)のunion find
         this->n = n;
         this->par.resize(n);
         this->num.resize(n, 1);
         for (int i = 0; i < n; i++) {
             this->par[i] = i;
         }
     }

     int root(int i) {
         if (par[i] == i)
             return i;
         else
             return par[i] = root(par[i]);
     }

     bool same(int i, int j) {
         return root(i) == root(j);
     }

     bool unite(int i, int j) {
         int t = root(i);
         int k = root(j);

         if (t == k)
           return false;

         par[t] = k;
         num[k] += num[t];
         return true;
     }

     int size(int i) {
         return num[root(i)];
     }
};
// }}}

void solve() {
  ll n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b, a--, b--;
    uf.unite(a, b);
  }
  ll ans = -1;
  rep(i, n) {
    chmax(ans, (ll)uf.size(i));
  }
  cout << ans << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


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

int main(){
	int n,l;
	while(1){
		cin>>n>>l;	if(n==0)break;
		vector<pair<char,int>>A(n);
		for(int i=0;i<n;i++){
			cin>>A[i].first>>A[i].second;
		}

		int ans=0,num=0,time=0;;
		bool flag=true;
		while(flag){
			++time;	flag=false;
			for(int i=0;i<n;i++){
				if(A[i].second==-1)continue;
				// move
				flag=true;
				if(A[i].first=='R')A[i].second++;
				else A[i].second--;
			}

			for(int i=0;i<n;i++){
				// check
				if(0<A[i].second && A[i].second<l){
					for(int j=0;j<n;j++){
						if(i==j)continue;
						else if(A[i].second==A[j].second){
							//printf("%d: (%d,%d)\n",A[i].second,i+1,j+1);
							if(A[i].first=='R')A[i].first='L';
							else A[i].first='R';

							break;
						}
					}
				}else if(A[i].second==0){
					A[i].second=-1;
					ans=time;
					num=i+1;
				}else if(A[i].second==l){
					A[i].second=-1;
					if(ans!=time){
						ans=time;
						num=i+1;
					}
				}
			}
		}
		cout<<ans<<" "<<num<<endl;
	}

	return 0;
}



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

int number[10];
int count = 0;
int flag = 0;
int temp = 0;

int main(){

        for(count=0;count<10;count++){
                cin >> number[count];
                }
        count = 0;

        while(flag<10){
                for(count=0;count<9;count++){
                        if(number[count]<number[count+1]){
                                temp=number[count];
                                number[count]=number[count+1];
                                number[count+1]=temp;
                        }
                }
                flag++;
}
        for(count=0;count<3;count++){
                cout<<number[count]<<endl;
        }
}

Measured memory_bytes: 1160
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] -= 1

l = [-1]*n
now = 0
order = 0

while True:
    k -= 1
    order += 1
    now = a[now]
    if k == 0:
        break
    if l[now] == -1:
        l[now] = order
    else:
        cycle = order - l[now]
        k %= cycle

print(now + 1)

Measured memory_bytes: 32292
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    string s;
    cin >> s;
    bool flag=false;
    int a =count(all(s),'a');
    int b =count(all(s),'b');
    int c =count(all(s),'c');
    int x =a+1;
    int y =b+1;
    int z=c+1;
    if(a==b && b==c) flag=true;
    else if(x==b && b==c) flag=true;
    else if(a==y && y==c) flag=true;
    else if(a==b && b==z) flag=true;
    else if(x==y && y==c) flag=true;
    else if(x==b && b==z) flag=true;
    else if(a==y && y==z) flag=true;

    if(flag) cout << "YES" <<endl;
    else cout << "NO" <<endl;
    return 0;
}

Measured memory_bytes: 512
n=int(input())

#初期値が0の辞書
from collections import defaultdict
nn = defaultdict(lambda: 0) 

for i in range(1,n+1):
    if i%10!=0:
        nn[str(i)[0]+str(i)[-1]]+=1

result=0
#print(nn)
for i in range(1,10):
    for j in range(1,10):
        number=str(i)+str(j)
        numRev=str(j)+str(i)
        if i==j:
            result+=nn[number]*nn[number]
            #nn[number]=0
        else:
            result+=nn[number]*nn[numRev]
            #nn[number]=0
            #nn[numRev]=0

print(result)




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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << (a+b>=c ? "Yes" : "No") << endl;
}




Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, m;
		cin >> n >> m;
		if (n < 0) return 0;
		vector<LL> a(n);
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
		}
		LL l = a[0];
		for (int i = 1; i < n; ++i) {
			l = lcm(l, a[i]);
		}
		for (int i = 0; i < n; ++i) {
			LL b = l / a[i];
			if (b % 2) {

			} else {
				l *= 3;
			}
		}
		LL ans = (m + l / 2) / l;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 300 + 10;
const long long INF = 10000000000000000LL;

int N;
long long A[MAXN][MAXN];
pair < int, pair <int, int> > E[MAXN * MAXN];
int nE;
int Fa[MAXN];
long long B[MAXN][MAXN];

int GetRoot(int x)
{
	return (Fa[x] == x) ? x : (Fa[x] = GetRoot(Fa[x]));
}

void Work()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i ++)
		for (int j = 1; j <= N; j ++)
			scanf("%lld", &A[i][j]);

	for (int i = 1; i <= N; i ++)
		for (int j = 1; j <= N; j ++)
			for (int k = 1; k <= N; k ++)
				if (A[i][k] + A[k][j] < A[i][j])
				{
					printf("-1\n");
					return;
				}

	long long Ans = 0;
	for (int i = 1; i <= N; i ++)
		for (int j = i + 1; j <= N; j ++)
		{
			int red = 0;
			for (int k = 1; k <= N; k ++)
				if (i != k && j != k && A[i][k] + A[k][j] == A[i][j])
				{
					red = 1;
					break;
				}
			if (! red)
				Ans += A[i][j];
		}

	printf("%lld\n", Ans);
}

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

Measured memory_bytes: 896
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K, C;
    cin >> N >> C >> K;
    vector<ll> T(N);
    rep(i, N) cin >> T[i];
    sort(all(T));
    ll ans = 0;
    ll c = 0;
    ll fptime = 0;
    rep(i, N-1) {
        if (c == 0) {
            fptime = T[i];
        }
        c++;
        if (c == C) {
            c = 0;
            ans++;
        } else if (fptime + K < T[i+1]) {
            c = 0;
            ans++;
        }
    }
    print(ans+1);
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
 
using namespace std;
 
int N;
int X[200000];
int Y[200000];
int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        scanf("%d", X+i);
    }
    for(int i = 0; i < N; ++i) {
        Y[i] = X[i];
    }
    sort(Y, Y+N);
    int mean = Y[N/2];
    for(int i = 0; i < N; ++i) {
        if(X[i] >= mean) {
            printf("%d\n", Y[N/2-1]);
        }
        else {
            printf("%d\n", mean);
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    string s;
    cin>>s;
    REP(i,s.size()-1){
        if(s[i] == s[i+1]){
            cout<<"Bad"<<endl; return 0;
        }
    }
    cout<<"Good"<<endl;

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

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
const long long mx =1e15;

int main()

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1;//>>s2;
    l(i,0,s1.size())
    {
        cout<<"x";
    }
    cout<<endl;

}


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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);


	map<int, int> M;
	vector<bool> B(10, 0);
	for (int i = 1; i <= 9; ++i) {
		int a;
		cin >> a;
		M[a] = i;
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		if (M[b])
			B[M[b]] = true;
	}

	bool found = false;
	found |= (B[1] && B[2] && B[3]);
	found |= (B[4] && B[5] && B[6]);
	found |= (B[7] && B[8] && B[9]);
	found |= (B[1] && B[4] && B[7]);
	found |= (B[2] && B[5] && B[8]);
	found |= (B[3] && B[6] && B[9]);
	found |= (B[1] && B[5] && B[9]);
	found |= (B[3] && B[5] && B[7]);
	
	cout << (found ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,i;
	i=0;
	while(i<10000){
		scanf("%d",&x);
		if(x==0){
			break;
		}
		printf("Case %d: %d\n",i+1,x);
		i++;
	}
	return 0;
}
	

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int N, K;
	int place[100];
	int i;
	int sum = 0;
	scanf("%d", &N);
	scanf("%d", &K);
	for (i = 0; i < N; i++)
	{
		scanf("%d", &place[i]);
		if (abs(place[i]) <= abs(place[i] - K))
			sum += abs(place[i]);
		else
			sum += abs(place[i] - K);
	}
	printf("%d", sum*2);
	return 0;
	
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(C, L, R, up) for (ll C = L; C < R; C += up)
#define rev(C, R, L, down) for (ll C = R - 1; C >= L; C -= down)

string solve1(string str)
{
    if (str[2] == str[3] && str[4] == str[5])
    {
        return "Yes";
    }
    else
    {
        return "No";
    }
}

int main(void)
{
    string s;
    cin >> s;
    cout << solve1(s) << endl;
}

Measured memory_bytes: 256
use proconio::input;

const MOD: i64 = 1000000007;

fn mpow(a: i64, b: i64) -> i64 {
  let tmp = if b % 2 == 1 { a } else { 1 };
  match b {
    0 => 1,
    _ => tmp * mpow(a * a % MOD, b / 2) % MOD
  }
}

fn main() {
  input! {
    n: i64,
    k: usize
  }
  let mut dp = vec![0; k + 1];
  
  for i in (1..=k).rev() {
    dp[i] = mpow((k / i) as i64, n);
    for j in (i*2..=k).step_by(i) {
      dp[i] = (dp[i] + MOD - dp[j]) % MOD;
    }
  }
  
  println!("{}", (1..=k).map(|t| dp[t] * t as i64 % MOD).fold(0, |v, t| (v + t) % MOD));
}



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





int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int N;
    cin>>N;
    int a,b;
    a = N/999;
    b = N%999;
    string ans = "AB";
    char ans2 = 'C';
    if(b==0&&N>0){
        a--;
        ans2+=a;
    }else{
        ans2+=a;
    }
    
    string ans3;



    cout << ans<<ans2<<endl;
    // if(b<10){//1けた
    //     cout<< "00"<< b<<endl;
    // }else if(b>9&&b<100){
    //     cout<< "0"<< b<<endl;
    // }else if(b>99){
    //     cout <<b<<endl;
    // }



    return 0;
}


//3 人は同時に、他の 2 人の持っている整数の和を求める。
//その後、自分の持っている整数を求めた整数で置き換える。

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N , D;
	int ans;

	cin >> N >> D;	


	ans = ceil(((double)N / ( D * 2 + 1)) );

	printf("%d",ans);


	//printf("No");


	return 0;
}



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

//   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
     String[] O=sc.nextLine().split(" ");
   //  String[] E=sc.nextLine().split("");

//int n=Integer.parseInt(nyuA);

int N=Integer.parseInt(O[0]);
int M=Integer.parseInt(O[1]);

int[] num=new int[N];

for(int i=0;i<M;i++){
O=sc.nextLine().split(" ");
int A=Integer.parseInt(O[0]);
int B=Integer.parseInt(O[1]);
num[A-1]++;num[B-1]++;
}

for(int i=0;i<N;i++)
System.out.println(num[i]);

//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

struct SegSum{
    //const ll INF=1e18;
    int n;
    vector<ll> dat;
    SegSum(int n_):n(),dat(n_*4,0){
        int x=1;
        while(n_>x){
            x*=2;
        }
        n=x;
    }

    void update(int i,ll x){//index iをxに更新する
        i+=n-1;
        dat[i]=x;
        while(i>0){
            i=(i-1)/2;
            dat[i]=dat[i*2+1]+dat[i*2+2];
        }
    }

    ll query(int a,int b){//a以上b未満の区間の和を求める
        return query_sub(a,b,0,0,n);
    }
    ll query_sub(int a,int b,int k,int l,int r){
        if(r<=a || b<=l){
            return 0;
        }
        else if(a<=l && r<=b){
            return dat[k];
        }
        else{
            ll vl=query_sub(a,b,k*2+1,l,(l+r)/2);
            ll vr=query_sub(a,b,k*2+2,(l+r)/2,r);
            return vl+vr;
        }
    }
};

int main() {
    int N,Q;
    cin>>N>>Q;
    vector<int> c(N);
    rep(i,N)cin>>c.at(i);
    vector<P> l(Q),r(Q);
    rep(i,Q){
        cin>>l.at(i).first>>r.at(i).first;
        l.at(i).second=i;
        r.at(i).second=i;
    }
    sort(r.begin(),r.end());
    int pointa=0;
    vector<int> ans(Q);
    //set<int> ma;
    vector<vector<int>> color(N+1,vector<int>(0));
    rep(i,N){
        color[c.at(i)].pb(i);
    }
    vector<int> bef(N,-1);
    rep(i,N+1){
        if(color[i].size()>1){
            rep(j,color[i].size()-1){
                bef[color[i][j+1]]=color[i][j];
            }
        }
    }
    SegSum ss(N+1);
    rep(i,Q){
        while(pointa<r.at(i).first){
            if(bef[pointa]>=0)ss.update(bef[pointa],0);
            ss.update(pointa,1);
            pointa++;
        }
        int query=r.at(i).second;
        int bor=l.at(query).first-1;//以上
        ans.at(query)=ss.query(bor,N+1);
    }
    rep(i,Q)cout<<ans.at(i)<<endl;
}

Measured memory_bytes: 60508
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N;
	size_t L[10];
	size_t maxPos = 0;
	size_t sum = 0;

	scanf("%zu\n", &N);

	for (size_t i = 0; i < N; i++) {
		scanf("%zu", &(L[i]));
		if (i < N - 1) {
			scanf(" ");
		}

		if (0 < i) {
			if (L[maxPos] < L[i]) {
				sum += L[maxPos];
				maxPos = i;
			}
			else {
				sum += L[i];
			}
		}
	}

	puts((L[maxPos] < sum ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    string S;
    cin >> N >> K >> S;
    char c = '1';
    int cnt = 0;
    vector<int> vec;
    rep(i,0,N){
        if(S[i] != c){
            vec.push_back(cnt);
            c = S[i];
            cnt = 0;
        }
        cnt++;
    }
    vec.push_back(cnt);
    //for(auto i:vec)cout << i << " ";

    int M = vec.size();
    vector<int> accum(M+1);
    rep(i,0,M){
        accum[i+1] = accum[i] + vec[i];
    }
    /*
    cout << endl;
    for(auto i:accum)cout << i << " ";
    cout << endl;
    */
    int maxi = 0;
    rep(i,0,N){
        int l = i * 2;
        int r = i * 2 + K * 2 + 1;
        if(l >= M)l = M;
        if(r >= M)r = M;
        int dif = accum[r] - accum[l];
        maxi = max(maxi, dif);
    }
    cout << maxi << endl;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    int n,m;
    cin>>n>>m;
    //n+=2;
    //m+=2;
    for(int i=0;i<n+2;++i){
    	for(int j=0;j<m+2;++j){
    		if(i==0 || i==(n+2)-1 || j==0 || j==(m+2)-1) cout<<"#";
    		else{
    			char c;
    			cin>>c;
    			cout<<c;
    		}
    	}
    	cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

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

using ll = long long int;

constexpr ll mod = 998244353;

ll pow(ll x, int n)
{

    ll res = 1;
    rep(bit, 30)
    {
        //std::cerr << "DE" << bit << std::endl;

        if (n & (1 << bit))
            res = res * x % mod;
        x = x * x % mod;
    }

    return res;
}

ll inv(ll x)
{

    return pow(x, mod - 2);
}

ll fac[2 * (int)1e5];

ll cmb(int x, int y)
{

    return fac[x] * (inv(fac[y]) * inv(fac[x - y]) % mod) % mod;
}

int main()
{
    int n, k;
    ll m;

    std::cin >> n >> m >> k;

    fac[0] = 1;

    rep(i, n - 1)
    {
        fac[i + 1] = fac[i] * (i + 1) % mod;
    }

    ll ans = 0;

    rep(i, k + 1)
    {
        ans = (ans + cmb(n - 1, i) * (m * pow(m - 1, n - i - 1) % mod)) % mod;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 5088
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

signed main() {
  ll N, M;
  cin >> N >> M;

  vector<ll> numbers(N);
  rep(i, M) {
    ll s, c;
    cin >> s >> c;
    s--;
    if (numbers[s] == 0 || numbers[s] == c) {
      if (N != 1 && s == 0 && c == 0) {
        COUT(-1);
        return 0;
      }
      numbers[s] = c;
    } else {
      COUT(-1);
      return 0;
    }
  }

  if (N == 1 && numbers[0] == 0) {
    COUT(0);
    return 0;
  }

  if (numbers[0] == 0) {
    numbers[0] = 1;
  }
  rep(i, N) {
    cout << numbers[i];
  }
  ENDL;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		
		for (int i=1;i<=N;i++) {
		    if (i %2 != 0) {
		        count+=1;
		    }
		}
		
		double ans = (double) count/N;
		System.out.println(ans);
    
    }
}

Measured memory_bytes: 23892
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize, k: usize,
    }
    let mut sum = 0;
    for i in k..n + 2 {
        let l = (1 + i) * i / 2;
        let u = (n + 1 - i + 1 + n + 1) * i / 2;
        sum += u - l + 1;
        sum %= M;
    }
    println!("{}", sum);
}


Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 2007;
const int MAXX = 1000000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);
    
    
    int n;
    cin >> n;
    VI A;
    FOR(i,0,n)
    {
        int x;
        scanf("%d" , &x);
        A.push_back(x);
    }
    Int L = 2;
    Int R = 2;
    RFOR(i,n,0)
    {
        Int x = A[i];
        
        L = (L + x - 1) / x * x;
        R = R / x * x + x - 1;
        
        if (L > R)
        {
            cout << "-1" << endl;
            return 0;
        }
        
    }
    cout << L << ' ' << R << endl;
    
    return 0;
}




Measured memory_bytes: 892
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, m;
ll s[3010][3010], c[3010][3010];
ll modpow(ll a, ll n, ll mod) {
	ll r = 1, b = a;
	while(n > 0) {
		if(n & 1) r = r * b % mod;
		b = b * b % mod;
		n >>= 1;
	}
	return r;
}
int main() {
	scanf("%d%d", &n, &m);
	s[0][0] = 1, c[0][0] = 1;
	for(int i=1; i<=3000; i++) {
		s[i][0] = 1, c[i][0] = 1;
		for(int j=1; j<=i; j++) {
			s[i][j] = (1ll * (j + 1) * s[i-1][j] % m + s[i-1][j-1]) % m;
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % m;
		}
	}
	ll res = 0;
	for(int i=0; i<=n; i++) { // i : 합이 0 또는 1인 것의 개수
		ll loc = 0;
		for(int j=0; j<=i; j++) { // j : 1개 이상의 토핑이 있는 라면의 개수 (토핑이 중복될 수 없으므로 라면의 개수는 i개 이하임을 알 수 있다)
			ll v = s[i][j];
			v = v * modpow(modpow(2, n-i, m), j, m) % m;
			loc = (loc + v) % m;
		}
		loc = loc * c[n][i] % m * modpow(2, modpow(2, n-i, m-1), m) % m;
		ll f = i % 2 ? -1 : 1;
		res = (res + loc * f + m) % m;
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 140032
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define sii set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


 // void solution(ll a[],ll n)
 // {
 // 	ll sum=0;
 // 	rep(i,0,n)
 // 	sum=(sum%MOD+a[i]%MOD)%MOD;

 // 	ll square = ((sum%MOD)*(sum%MOD))%MOD;

 // 	ll sum2=0;

 // 	rep(i,0,n)
 // 	{
 // 		// sum2=(((sum2%MOD)+((a[i]%MOD)*(a[i]%MOD))%MOD)%MOD;
 // 		sum2=(sum2%MOD + (a[i]%MOD * a[i]%MOD)%MOD)%MOD;
 // 	}

 // 	// cout<<square<<"\n";
 // 	// cout<<sum2<<"\n";

 // 	ll ans= (square%MOD - sum2%MOD+MOD)%MOD;

 // 	cout<<(ans%MOD)/2;
 // }



ll findProductSum(ll A[], ll n)
{
	ll sum = 0,result=0;
	for (ll i = 0; i < n; i++)
	sum = (sum%MOD + A[i]%MOD)%MOD;
	for(ll i=0;i<n;i++)
	{
	    sum=(sum%MOD-A[i]%MOD + MOD)%MOD;
	    result=(result %MOD+ (A[i]%MOD*sum%MOD)%MOD)%MOD;
	}
	return result;
}


void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n) cin>>a[i];
	cout<<findProductSum(a,n);
}


int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 5176
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

poles = []
poles.append(a)
poles.append(b)
poles.append(c)
poles.append(d)
poles.append(e)

able_poles = 0
for i in range(4):  # あくまでここではindex番号での組み合わせを抽出する
    for j in range(i+1, 5):
        if abs(poles[i]-poles[j]) <= k:
            able_poles += 1
if able_poles == 10:  # もっとスマートな方法ない？
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3064
#include<stdio.h>
struct a
{
    char ch;
    int num;
} s[36];
int main()
{
    struct a s1[36],s2[36],s3[36];
    int n,i,j,k,l,t,min,book;
    char x;
    while(scanf("%d",&n)!=EOF)
    {
        getchar();
        for(i=0; i<n; i++)
        {
            scanf("%c%d",&s[i].ch,&s[i].num);
            getchar();
            s1[i].ch=s[i].ch;
            s2[i].ch=s[i].ch;
            s3[i].ch=s[i].ch;
            s1[i].num=s[i].num;
            s2[i].num=s[i].num;
            s3[i].num=s[i].num;
        }
        for(i=0; i<n-1; i++)
        {
            min=i;
            for(j=i+1; j<n; j++)
            {
                if(s1[j].num<s1[min].num)
                    min=j;
            }
            if(i!=min)
            {
                t=s1[i].num;
                s1[i].num=s1[min].num;
                s1[min].num=t;
                x=s1[i].ch;
                s1[i].ch=s1[min].ch;
                s1[min].ch=x;
            }
        }
        for(i=0; i<n; i++)
        {
            for(j=n-1; j>i; j--)
            {
                if(s2[j].num<s2[j-1].num)
                {
                    t=s2[j].num;
                    s2[j].num=s2[j-1].num;
                    s2[j-1].num=t;
                    x=s2[j].ch;
                    s2[j].ch=s2[j-1].ch;
                    s2[j-1].ch=x;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            printf("%c%d",s2[i].ch,s2[i].num);
            if(i!=n-1)
                printf(" ");
            else
                printf("\n");
        }
        book=0;
        for(i=0; i<n; i++)
        {
            if(book==1)
                break;
            for(j=0; j<n; j++)
            {
                if(s2[i].num==s[j].num)
                {
                    if(s2[i].ch!=s[j].ch)
                    {
                        book=1;
                        break;
                    }
                    else
                    {
                        s2[i].num=-1;
                        s[j].num=-2;
                        break;
                    }
                }
            }
        }
        if(book==0)
            printf("Stable\n");
        if(book==1)
            printf("Not stable\n");
        for(i=0; i<n; i++)
        {
            printf("%c%d",s1[i].ch,s1[i].num);
            if(i!=n-1)
                printf(" ");
            else
                printf("\n");
        }
        book=0;
        for(i=0; i<n; i++)
        {
            if(book==1)
                break;
            for(j=0; j<n; j++)
            {
                if(s1[i].num==s3[j].num)
                {
                    if(s1[i].ch!=s3[j].ch)
                    {
                        book=1;
                        break;
                    }
                    else
                    {
                        s1[i].num=-1;
                        s3[j].num=-2;
                        break;
                    }
                }
            }
        }
        if(book==0)
            printf("Stable\n");
        if(book==1)
            printf("Not stable\n");
    }
    return 0;
}



Measured memory_bytes: 2044
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

string s;
bool dfs(int p){
	if (p == s.size())
		return true;
	if (s.substr(p, 5) == "dream"){
		if (dfs(p + 5) == true) return true;
	}
	if (s.substr(p, 7) == "dreamer"){
		if (dfs(p + 7) == true) return true;
	}
	if (s.substr(p, 5) == "erase"){
		if (dfs(p + 5) == true) return true;
	}
	if (s.substr(p, 6) == "eraser"){
		if (dfs(p + 6) == true) return true;
	}
	return false;
}
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	cin >> s;
	if (dfs(0) == true) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	bool win = true;
	
	rep(i, 100) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int64_t N, M;
  cin >> N >> M;

  vector<int64_t> happy(N);
  for (int64_t n = 0; n < N; ++n) cin >> happy[n];
  sort(happy.begin(), happy.end());

  vector<int64_t> cum_sum(N + 1);
  for (int64_t n = N - 1; n >= 0; --n) {
    cum_sum[n] = cum_sum[n + 1] + happy[n];
  }

  int64_t ng = 0, ok = (happy.back() + 1) * 2;
  while (abs(ng - ok) > 1) {
    int64_t cnt = 0;
    int64_t mid = (ng + ok) >> 1;
    for (int64_t n = 0; n < N; ++n) {
      int64_t range = lower_bound(happy.begin(), happy.end(), mid - happy[n]) - happy.begin();
      cnt += N - range;
    }
    if (cnt >= M) {
      ng = mid;
    } else {
      ok = mid;
    }
  }

  int64_t sum = 0;
  for (int64_t n = 0; n < N; ++n) {
    int64_t pos = lower_bound(happy.begin(), happy.end(), ok - happy[n]) - happy.begin();
    int64_t cnt = N - pos;
    sum += cnt * happy[n] + cum_sum[pos];
    M -= cnt;
  }
  sum += ng * M;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792