akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <cmath>
#include <numeric>
#include <stack>
#include <iomanip>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a >= b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}

int main() {

    int n = inp1;
    vector<int> a = inp(n);

    map<int, int> mp;

    // a[i] + a[j] == j - i となる数
    // a[j] - j == -a[i] - i

    ll ans = 0LL;
    rep(i, n) {
        ans += mp[a[i] - i];
        ++mp[-a[i] - i];
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 21012
import sys
N=int(input())
B=list(map(int,input().split()))
if(N==2):
    print(B[0]*2)
    sys.exit()
before=B.pop(0)
ans=before
for b in B:
    ans+=min(before,b)
    before=b
ans+=B[-1]
print(ans)

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String s = sc.next();
        for (int i = 0; i < n; i++) {
            String t1 = s.substring(0, i);
            String t2 = s.substring(i, n);
            if (t1.equals(t2)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


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

int main(){
    int a,b;
    char ch; 
    while(cin>>a>>ch>>b){
        if(ch=='+')cout<<(a+b)<<"\n";
        else if(ch=='-')cout<<(a-b)<<"\n";
        else if(ch=='/')cout<<(a/b)<<"\n";
        else if(ch=='*')cout<<(a*b)<<"\n";
        else if(ch=='?')break;
    }   
    return 0;                                              
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e5 + 5)], sum[int(2e5+5)];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    sum[i] = sum[i-1] + A[i];
    sum[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++){
    ans += A[i] * (sum[N] - sum[i]) % MOD;
    ans %= MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6708
#include <stdio.h>

int main(void)
{

char c;
int i,count[26]={0};

while(scanf("%c",&c)!=EOF)
{
	if(c>='a'&&c<='z')
	{
		count[c-'a']++;
	}
	else if(c>='A'&&c<='Z')
	{
		count[c-'A']++;
	}
	
}

for(i=0;i<26;i++)
{
	printf("%c : %d\n",'a'+i,count[i]);
}
return 0; 





}

Measured memory_bytes: 540
#include <stdio.h>
#include <bits/stdc++.h>
#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int
     
     
using namespace std;
     
int a, b, c;
     
void init()
{
    si3(a, b, c);
    if(c >= a and c <= b) {
			//System.out.println("Yes");
    	printf("Yes\n");
		}
		else {
			printf("No\n");
			//System.out.println("No");
		} 
}
int main()
{
  
    init();
    return 0;
}



Measured memory_bytes: 256
import copy
n = int(input())
k = int(input())
b = [[]]
for i in range(n):
    tmp = len(b)
    for j in range(tmp):
        b.append(copy.copy(b[j]))
        '''
        b.append([])
        for l in range(len(b[j])):
            b[j+tmp].append(b[j][l])
        '''
    for j in range(tmp):
        b[j].append(0)
        b[j+tmp].append(1)
#0: x2, 1: +k
#print(b)
m = 2 ** 11
for i in range(len(b)):
    num = 1
    #print(b[i])
    for j in range(n):
        if b[i][j] == 0:
            num *= 2
        else:
            num += k
        #print(i, j, num, n, k)
    m = min(m, num)
    #print(i, num)
print(m)

Measured memory_bytes: 3700
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()


a = l()


a.sort()


for i in range(1,n):
    if a[i] == a[i-1]:
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 26060
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 1005;
const int MAXM = 5005;
const int INF = 0x3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

int n, X[MAXN];
int dp[MAXN], tmp[2][MAXM];

struct Edge {
	int v, nxt;
}e[MAXN];
int first[MAXN], eCnt;

inline void AddEdge(int u, int v) {
	e[++eCnt].v = v;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

void DFS(int u) {
	for (int i=first[u];i;i=e[i].nxt) {
		DFS(e[i].v);
	}
	mset(tmp[0], 0x3f);
	tmp[0][0] = 0;
	int pre = 0, cur = 1;
	for (int i=first[u];i;i=e[i].nxt) {
		int v = e[i].v;
		mset(tmp[cur], 0x3f);
		for (int j=min(X[v], dp[v]);j<=X[u];++j) {
			if (j >= X[v]) cmin(tmp[cur][j], tmp[pre][j-X[v]] + dp[v]);
			if (j >= dp[v]) cmin(tmp[cur][j], tmp[pre][j-dp[v]] + X[v]);
		}
		pre = cur; cur = pre ^ 1;
	}
	for (int j=0;j<=X[u];++j) {
		cmin(dp[u], tmp[pre][j]);
	}
}

void init() {
	read(n);
	for (int i=2,fa;i<=n;++i) {
		read(fa);
		AddEdge(fa, i);
	}
	for (int i=1;i<=n;++i) {
		read(X[i]);
	}
}

void solve() {
	mset(dp, 0x3f);
	DFS(1);
	puts((dp[1] < INF)? "POSSIBLE" : "IMPOSSIBLE");
}

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


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

#define MAX 160000

typedef pair<llong, llong> pii;

bool visited[400][400];

llong h, w;
string s[400];

pii solve(int x, int y){
  pii res;
  visited[y][x] = true;
  if(s[y][x] == '.'){
    res.first++;
  }else{
    res.second++;
  }

  REP(k,4){
    if(y + dy[k] >= 0 && y + dy[k] < h && x + dx[k] >= 0 && x + dx[k] < w && !visited[y+dy[k]][x+dx[k]] ){
      if((s[y][x] == '.' && s[y+dy[k]][x+dx[k]] == '#') || (s[y][x] == '#' && s[y+dy[k]][x+dx[k]] == '.')){
        pii tmp = solve(x+dx[k], y+dy[k]);
        res.first += tmp.first;
        res.second += tmp.second;
      }
    }
  }
  //cout << res.first << res.second << endl;
  return res;
}

int main(){

  cin >> h >> w;

  REP(i,h){
    cin >> s[i];
  }

  llong ans = 0;
  REP(i,h){
    REP(j,w){
      if(!visited[i][j]){
        pii tmp = solve(j,i);
        ans += tmp.first * tmp.second;
      }
    }
  }

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



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

int main() {
	int N, A, B; cin >> N >> A >> B;
	string S; cin >> S;
	for(int i=0; i<N; ++i){
	    if(S[i]=='c') cout << "No" << endl;
	    else if(S[i]=='b'){
	        if(B){
	            --B;
	            cout << "Yes" << endl;
	        }
	        else cout << "No" << endl;
	    }
	    else if(A+B){
	        cout << "Yes" << endl;
	        if(A) --A;
	        else --B;
	    }
	    else cout << "No" << endl;
	}
	return 0;
}


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

int main(){
    int n, m;
    while(cin >> n >> m){
        if(n == 0 && m == 0)break;
        if(n <= 23){
            vector<vector<int>> b(n, vector<int>(m));
            for(int i = 0; i < n; ++i){
                for(int j = 0; j < m; ++j){
                    char c;
                    cin >> c;
                    b[i][j] = c == '1';
                }
            }
            int ans = 0;
            vector<int> tmp(m, 0);
            for(int i = 1; i < 1 << n; ++i){
                int def = __builtin_ctz(i ^ (i - 1) ^ (i / 2) ^ ((i - 1) / 2));
                bool ok(1);
                for(int j = 0; j < m; ++j){
                    tmp[j] ^= b[def][j];
                    ok &= !tmp[j];
                }
                if(ok)ans = max(ans, __builtin_popcount(i ^ (i / 2)));
            }
            cout << ans << endl;
        }else{
            vector<int> b(n);
            for(int i = 0; i < n; ++i){
                char c;
                for(int j = 0; j < m; ++j){
                    cin >> c;
                    b[i] *= 2;
                    b[i] += c == '1';
                }
            }
            vector<vector<int>> dp(n + 1, vector<int>(1 << m, -1));
            dp[0][0] = 0;
            for(int i = 1; i <= n; ++i){
                for(int j = 0; j < 1 << m; ++j){
                    if(dp[i - 1][j] >= 0)dp[i][j] = max(dp[i - 1][j], dp[i][j]);
                    if(dp[i - 1][j ^ b[i - 1]] >= 0)dp[i][j] = max(dp[i][j], dp[i - 1][j ^ b[i - 1]] + 1);
                }
            }
            cout << dp[n][0] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 114188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtof ...
func Sliceconvtof() []float64 {
	strs := strings.Split(sc.Text(), " ")

	var flts []float64
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		xf := float64(x)
		flts = append(flts, xf)
	}

	return flts
}

func main() {

	for sc.Scan() {
		i := Sliceconvtof()
		fmt.Printf("%6f", i[0]*i[1]/3.305785)
	}

}



Measured memory_bytes: 1144
N=int(input())
for i in range(1,3501):
   for j in range(1,3501):
         a=N*i*j
         b=4*i*j-N*j-N*i
         if b>0:
            if (a/b).is_integer() == True:
               print(i,j,int((N*i*j)/(4*i*j-N*j-N*i)))
               exit()

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
    int A,B,C;
    cin >>A >> B >>C;
    int m=max(A,B);
        m=max(m,C);
    while((m*3-A-B-C)%2!=0){
        m++;
    }
    int answer=(m*3-A-B-C)/2;
    cout <<answer<<endl;

 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
	char s[1001],cmd[8],p[1001];
	char t;
	int q,a,b;
	int i,j,k;

	
	scanf( "%s", s );
	scanf( "%d", &q );
	for( i=0; i<q; i++ ) {
		scanf( "%s", cmd );
		if( strcmp( "print" , cmd ) == 0 ) {
			scanf( "%d %d", &a, &b );
			for( j=a; j<=b; j++ ) {
				printf( "%c", s[j] );
			}
			printf( "\n" );
		} else if( strcmp( "reverse" , cmd ) == 0 ) {
			scanf( "%d %d", &a, &b );
			for( j=0; a+j<b-j; j++ ) {
				t = s[a+j];
				s[a+j] = s[b-j];
				s[b-j] = t;
			}
		} else if( strcmp( "replace" , cmd ) == 0 ) {
			scanf( "%d %d %s", &a, &b, p );
			k = 0;
			for( j=a; j<=b; j++ ) {
				s[j] = p[k++];
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2092
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e6+100;
const int MAXM = 1e5;
int n,x;
double dp[307][307][307];//dp[i][j][k]代表当前1块的个数为i,两块的个数为j,三块的个数为k的期望 
double dfs(int n1,int n2,int n3){
	if(dp[n1][n2][n3]!=-1.0) return dp[n1][n2][n3];
	int n0=n-n1-n2-n3;
	if(n0==n) return 0.0;
	double res=0;
	if(n1>0) res+=(dfs(n1-1,n2,n3)+1.0)*((double)n1/(double)n);//拿1的情况 
	if(n2>0) res+=(dfs(n1+1,n2-1,n3)+1.0)*((double)n2/(double)n);//拿2的情况
	if(n3>0) res+=(dfs(n1,n2+1,n3-1)+1.0)*((double)n3/(double)n);
	res+=(double)n0/(double)n;
	res*=(double)n/(double)(n-n0);
//	cout<<res<<endl;
	return dp[n1][n2][n3]=res;
}
int re[4];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;re[x]++;
	}
	for(int i=0;i<=301;i++){
		for(int j=0;j<=301;j++){
			for(int k=0;k<=301;k++) dp[i][j][k]=-1.0;
		}
	}
	printf("%.14lf\n",dfs(re[1],re[2],re[3]));
	return 0;
}



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

int main() {
    ll x,a,b,seki;
    cin >> x;
    for(ll i=-500;i<500;i++){
        for(ll j = -500; j < 500; j++){
            seki = pow(i,5)-pow(j,5);
            if(seki == x){
                a=i;b=j;
                break;
            }
        }
    }
  cout << a << " "<< b << endl;
    return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int a, b, c; cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())

    l = H + W - 1
    sharp = 0
    i = 0
    while i < H:
        A = str(input())
        sharp += A.count('#')
        i += 1

    if l == sharp:
        print('Possible')
    else:
        print('Impossible')

main()


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

int a, d, n;
bool Era[1000001];
int main() {
    Era[0] = Era[1] = false;
    for(int i=2; i<=1000001; ++i) Era[i]=true;
    
    for(int i=2; i*i < 1000001; ++i){
        if(Era[i]){
            for(int j=0; i*(j+2)< 1000001; j++){
                Era[i*(j+2)]= false;
            }
        }
    }   
    while(cin >> a >> d >> n, a||d||n){
        int num = a, cnt=0;
        
        while(cnt!=n){
            if(Era[num]) cnt++;
            num += d;
        }
        cout << num-d << endl;
    }
        
    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
// #define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N;cin>>N;
	ote(N*N*N);
}


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

// n の i ビット目と j ビット目を swap する
void swp(int &n, int i, int j) {
    if ((n >> i & 1) ^ (n >> j & 1) == 0) return;
    n ^= (1 << i);
    n ^= (1 << j);
}

// [0, n) ビット目を使って a を b にする
vector<int> dfs(int n, int a, int b) {
    if (n == 1) return {a, b};

    b ^= a;
    int highest = n - 1;
    for (int i = 0; i < n - 1; i++) {
        if (b >> i & 1) highest = i;
    }
    swp(b, n - 1, highest);

    int onehot = 1 << (n - 1);
    int mask = onehot - 1;
    auto first = dfs(n - 1, 0, 1);
    auto second = dfs(n - 1, 1, b & mask);

    vector<int> res;
    for (auto x : first) res.push_back(x);
    for (auto x : second) res.push_back(x | onehot);

    for (auto& x : res) swp(x, n - 1, highest);
    for (auto& x : res) x ^= a;
    return res;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int g = a ^ b;
    if (__builtin_popcount(g) % 2 == 0) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    auto res = dfs(n, a, b);
    for (int i = 0; i < res.size(); i++) {
        cout << res[i] << ((i == res.size() - 1) ? "\n" : " ");
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  string s;
  cin >> s;
  ll n = s.size();

  vector<ll> nextL(n, -1);
  vector<ll> nextR(n, -1);
  ll r = 0;
  rep(i, n){
    if(s[i] == 'R'){
      r = i;
      continue;
    }
    nextR[i] = r;
  }

  ll l = n-1;
  for(ll i = n-1; 0 <= i; i--){
    if(s[i] == 'L'){
      l = i;
      continue;
    }
    nextL[i] = l;
  }

  vector<ll> memo(n, 0);
  rep(i, n){
    ll idx = i;
    ll dir = -1;
    if(s[idx] == 'R') dir = 1;

    ll dist = 0;
    if(s[idx] == 'R') dist = nextL[i] - idx;
    else              dist = idx - nextR[i];

    if(dist%2 == 0) memo[idx + dir*dist]++;
    else            memo[idx + dir*dist - dir]++;
  }

  string pt = "";
  rep(i, n) cout << pt << memo[i], pt = " ";
  cout << endl;

  return 0;
}



Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	int counts[4] = {};
	FOR_LT(i, 0, n) {
		string s; cin >> s;
		if (s == "AC") counts[0]++;
		if (s == "WA") counts[1]++;
		if (s == "TLE") counts[2]++;
		if (s == "RE") counts[3]++;
	}

	cout << "AC x " << counts[0] << endl;
	cout << "WA x " << counts[1] << endl;
	cout << "TLE x " << counts[2] << endl;
	cout << "RE x " << counts[3] << endl;

	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong();
		
		double n = (Math.sqrt(N+(1/4)));
		
		long count = 0;
		
		for(int m =1; m <= n; m++){
			if((N % m == 0)){
				if(N / m > m + 1) {
				count += (N/m - 1);
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    string s;
    cin >> n;
    vector<string> adj;
    for(int i = 0; i < n; i++) {
        cin >> s;
        adj.push_back(s);
    }
    // bipartite-graph check
    vector<int> color(n, 0);
    vector<int> dq = {0};
    color[0] = 1;
    while(!dq.empty()) {
        vector<int> new_dq;
        for(int node: dq) {
            for(int i = 0; i < n; i++) {
                if (adj[node][i] == '1') {
                    if (color[i] == 0) {
                        color[i] = color[node] * -1;
                        new_dq.push_back(i);
                    } else {
                        if (color[node]*color[i] != -1) {
                            cout << -1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
        dq = new_dq;
    }

    // floyd-warshall
    vector<vector<int>> dist(n, vector<int>(n, 1e5));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            if (adj[i][j] == '1')
                dist[i][j] = 1;
    for(int k = 0; k <n; k++) {
        for(int i = 0; i < n; i++) {
            if (i == k) continue;
            for(int j = 0; j < n; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j])
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++)
            ans = max(ans, dist[i][j]);
    cout << ans+1 << endl;
    return 0;
}




Measured memory_bytes: 512
import java.util.*;
import java.util.stream.LongStream;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        List<List<List<Integer>>> n = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int A = Integer.parseInt(scanner.nextLine());
            List<List<Integer>> list = new ArrayList<>();
            for (int j = 0; j < A; j++) {
                int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
                List<Integer> l = new ArrayList<>();
                l.add(a[0] - 1);
                l.add(a[1]);
                list.add(l);
            }
            n.add(list);
        }

        int ans = 0;
        loop:
        for (int i = 0; i < (1 << N); i++) {
            for (int j = 0; j < N; j++) {
                boolean t = ((1 << j) & i) > 0;
                if (t) {
                    for (List<Integer> l: n.get(j)) {
                        if (l.get(1) == 1) {
                            if (((1 << l.get(0)) & i) == 0) {
                                continue loop;
                            }
                        } else {
                            if (((1 << l.get(0)) & i) > 0) {
                                continue loop;
                            }
                        }
                    }
                }
            }
            ans = Math.max(ans, Integer.bitCount(i));
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 30032
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main() {
  string s, c;
  cin >> s;
  c = s;
  reverse(c.begin(), c.end());
  int cnt;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != c[i]) cnt++;
  }

  cout << cnt / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int SUM = 0;
  cin >> N;
  vector<int> l(N),r(N);  
  for(int i=0;i<N;i++){
    int x;
  	cin >> l.at(i) >> r.at(i);
    x = r.at(i) - l.at(i)+1;
    SUM += x;
  }
  cout << SUM;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
      string x=to_string(i);
      if(x.length()%2!=0)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

signed main() {
    ll n, m; 
    cin >> n >> m;
    
    ll r = 0;
    
    vvll s(m);
    
    rep(i, m) {
        ll k; 
        cin >> k;
        rep(j, k) {
            ll a; 
            cin >> a; --a;
            s[i].push_back(a);
        }
    }
    vll p(m);
    rep(i, m) {
        cin >> p[i];
    }
    
    
    for (int bit = 0; bit < (1<<n); ++bit) {
        bool ok = true;
        for (int i = 0; i < m; ++i) {
            int con = 0;
            for (auto v : s[i]) {
                if (bit & (1<<v)) ++con;
            }
            if (con % 2 != p[i]) ok = false;
        }
        if (ok) r++;
    }
    mes(r);
    
    
    
}

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

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

    string s;
    int x;
    while (n > 0)
    {
        x = n % 26;
        n /= 26;
        if (x == 0)
        {
            s.push_back('z');
            n--;
        }
        else
            s.push_back('a' + x - 1);
    }
    reverse(s.begin(), s.end());

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int N, a[50];
	int maxabs, maxsgn, maxi, m;
	int op1[100], op2[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	maxabs = 0;
	maxsgn = +1;
	for (int i = 0; i < N; i++) {
		if (a[i] > 0) {
			if (maxabs < a[i]) {
				maxabs = a[i];
				maxi = i;
				maxsgn = +1;
			}
		}
		if (a[i] < 0) {
			if (maxabs < -a[i]) {
				maxabs = -a[i];
				maxi = i;
				maxsgn = -1;
			}
		}
	}
	if (maxabs == 0) { printf("0\n"); return 0; }
	
	if (maxsgn == 1) {
		m = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] < 0) {
				op1[m] = maxi + 1;
				op2[m] = i + 1;
				m++;
			}
		}

		for (int i = 0; i < N - 1; i++) {
			op1[m] = i + 1;
			op2[m] = i + 2;
			m++;
		}
	}
	if (maxsgn == -1) {
		m = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] > 0) {
				op1[m] = maxi + 1;
				op2[m] = i + 1;
				m++;
			}
		}

		for (int i = N-1; i >0 ; i--) {
			op1[m] = i + 1;
			op2[m] = i;
			m++;
		}
	}

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

	for (int i = 0; i < m; i++) {
		printf("%d %d\n", op1[i], op2[i]);
	}
}

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

using namespace std;

typedef pair<int, int> edge;
typedef vector<vector<edge>> graph;

graph g;
vector<int> color;


void dfs(int v, int parent, int c) {
    color[v] = c;
    for (auto e : g[v]) {
        if (e.first == parent) continue;
        if (e.second % 2 == 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

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

    g.assign(n, vector<edge>());

    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        g[u].push_back(edge(v, w));
        g[v].push_back(edge(u, w));
    }
    
    color.assign(n, 0);
    dfs(0, -1, 0);
    
    for (int i = 0; i < n; i++)
    {
        cout << color[i] << endl;
    }

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	vector<int> tmp = a;
	if (prev_permutation(tmp.begin(), tmp.end())) {
		cout << tmp[0];
		for (int i = 1; i < n; ++i) cout << ' ' << tmp[i];
		cout << endl;
	}
	cout << a[0];
	for (int i = 1; i < n; ++i) cout << ' ' << a[i];
	cout << endl;
	tmp = a;
	if (next_permutation(tmp.begin(), tmp.end())) {
		cout << tmp[0];
		for (int i = 1; i < n; ++i) cout << ' ' << tmp[i];
		cout << endl;
	}
}


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

int main() {
  
  char m1, m2, m3;
  cin >> m1 >> m2 >>m3; 
  int c;
  
  if ( m1 == '1' ) c++;
  if ( m2 == '1' ) c++;
  if ( m3 == '1' ) c++;
  
  cout << c << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


double dp[3000][3000];

int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++){
        double p; cin >> p;
        dp[0][0] = 1;
        dp[i+1][0] = dp[i][0] * (1-p);

        for(int j=0; j<N; j++){
            dp[i+1][j+1] = dp[i][j] * p + dp[i][j+1] * (1-p);
        }
    }
    
    double ans = 0;
    for(int j=N/2+1; j<=N; j++){
        ans += dp[N][j];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
int r,c,n,sx,sy,tx,ty,cnt,x,y,tp,st[100005];
struct note{
	int x,id,type;
}a[200005];
int cal(int x,int y){
	if (x==0) return y;
	if (x==c) return r+c+r-y;
	if (y==0) return r+c+r+c-x;
	if (y==r) return r+x;
	return -1;
}
bool cmp(note x,note y){
	return x.x<y.x;
}
int main(){
	scanf("%d%d%d",&c,&r,&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
		x=cal(sx,sy);
		y=cal(tx,ty);
		if (x==-1 || y==-1) continue;
		if (x>y) std::swap(x,y);
		a[++cnt]={x,i,1};
		a[++cnt]={y,i,2};
	}
	std::sort(a+1,a+cnt+1,cmp);
	for (int i=1;i<=cnt;i++){
		if (a[i].type==1) st[++tp]=a[i].id;
		else{
			if (st[tp]!=a[i].id){
				puts("NO");
				return 0;
			}
			tp--;
		}
	}
	puts("YES");
	return 0;
} 

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;

using namespace std;

int main()
{
    // 整数の入力
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> ans(N, -1);
    map<ll, ll> a_counts;
    map<ll, ll> b_counts;
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        a_counts[A[i]]++;
    }
    for (size_t i = 0; i < N; i++)
    {
        cin >> B[i];
        b_counts[B[i]]++;
    }

    vector<bool> can_move(N, true);
    ll from = -1;
    ll to = -1;
    ll last_b = -1;
    for (int i = 0; i < N; i++)
    {
        if (last_b != B[i])
        {
            from = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
            to = upper_bound(A.begin(), A.end(), B[i]) - A.begin();
            // cout << from << "~" << to - 1<< endl;
            for (int j = from; j < to; j++)
            {
                can_move[(N + j - i) % N] = false;
            }
        }
        else if(from != -1 && to != -1 && from < to)
        {
            // cout << "111" << endl;
            can_move[(N + to - 1 - i) % N] = false;
            can_move[(N + from - i) % N] = false;
        }
        last_b = B[i];
    }

    // for (int i = 0; i < N; i++)
    // {
    //     cout << can_move[i] << ",";
    // }
    // cout << endl;

    ll diff = -1;
    for (int i = 0; i < N; i++)
    {
        if (can_move[i])
        {
            diff = i;
            break;
        }
    }
    // cout << diff << endl;
    if (diff == -1)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        for (size_t i = 0; i < N; i++)
        {
            if (i != 0)
            {
                cout << " ";
            }
            cout << B[(N + i - diff) % N];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 32988
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n: String = sc.nextLine()

    if (n.toInt % n.foldLeft(0)((acc, i) => acc + i.toString.toInt) == 0) println("Yes")
    else println("No")
  }

}


Measured memory_bytes: 27312
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
const int inf=1e9+7;
const int mod=1e9+7;
using namespace std;
//
int main(){
	string S;
	cin>>S;
	int N=S.size();
	if(S[0]=='0'||S[N-1]=='1'){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<=N/2;i++){
		if(S[i]!=S[N-i-2]){
			cout<<-1<<endl;
			return 0;
		}
	}
	queue<int> par;
	for(int i=0;i<N;i++){
		if(S[i]=='1'){
			par.push(i+1);
		}
	}
	par.push(N);
	for(int i=1;i<N;i++){
		if(i==par.front()){
			par.pop();
		}
		cout<<i<<" "<<par.front()<<endl;
	}
	return 0;
}


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


const ll mod = 998244353;

ll power(ll b, ll x) {
    ll ans = 1;
    for (int i = 0; i < x; i++) {
        ans *= b;
        ans %= mod;
    }

    return ans;
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n) cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return;
    }
    for (int i = 1; i < n; i++) {
        if (d[i] == 0) {
            cout << 0 << endl;
            return;
        }
    }

    map<ll, ll> num_dist;
    for (int i = 1; i < n; i++) {
        num_dist[d[i]]++;
    }

    int ok = 1;
    for (int i = 1; i < n; i++) {
        if (num_dist[i] == 0) {
            ok = 0;
        }
        if (ok == 0 && num_dist[i] != 0) {
            cout << 0 << endl;
            return;
        }
    }

    ll ans = 1;
    for (int i = 2; i < n; i++) {
        ans *= power(num_dist[i-1], num_dist[i]);
        ans %= mod;
    }

    cout << ans << endl;

}

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


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

int main() {

  string N;
  cin >> N;

  for(int i=0; i<N.size(); i++ ){
    if(N.at(i)=='7'){
      cout << "Yes" << endl;
      break;
    }
    if(i==2){
      if(N.at(i)!='7'){
        cout << "No" << endl;
        break;
      }
    }
  }

}


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

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

typedef long long  ll;

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

int main() {
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    if(s.at(c-1)=='#' || s.at(d-1)=='#'){
        cout<<"No"<<endl;
        return 0;
    }
    if(s.at(a-1)=='#' || s.at(b-1)=='#'){
        cout<<"No"<<endl;
        return 0;
    }
    if(c<d){
        for(int i=a-1;i<d-1;i++){
            if(s.at(i)=='#' && s.at(i+1)=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        for(int i=a-1;i<c-1;i++){
            if(s.at(i)=='#' && s.at(i+1)=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        for(int i=b-2;i<d-1;i++){
            if(s.at(i)=='.' && s.at(i+1)=='.' && s.at(i+2)=='.'){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
    }





    return 0;
}


Measured memory_bytes: 640
function main()
  
  S = split(chomp(readline()),"")
  
  S1 = parse(Int,join(S[1:2]))
  S2 = parse(Int,join(S[3:4]))
  
  check1 = true
  check2 = true

  if S1 == 0 || S1 > 12
    check1 = false
  end

  if S2 == 0 || S2 > 12
    check2 = false
  end
  
  if check1 == check2 == true
    println("AMBIGUOUS")
  elseif check1 ==  true && check2 == false
    println("MMYY")
  elseif check2 ==  true && check1 == false
    println("YYMM")
  else
    println("NA")
  end
  
end

main()

Measured memory_bytes: 113708
<?php

class Answer
{
    private $sequence_len;
    private $sequence;

    public function __construct()
    {
        while (1) {
            $line = FGETS(STDIN);
            if ($line == false) {
                break;
            }
            $line = trim($line);
            $lines[] = $line;
        }
        
        $this->sequence_len = $lines[0];
        $this->sequence = explode(' ', $lines[1]);
    }

    public function bubbleSort()
    {
        $seq_len = $this->sequence_len;
        $seq = $this->sequence;
        $count = 0;

        for ($i = 0; $i < $seq_len; $i++) {
            for ($j = 1; $j < $seq_len; $j++) {
                if ($seq[$j-1] > $seq[$j]) {
                    list($seq[$j], $seq[$j-1]) = array($seq[$j-1], $seq[$j]);
                    $count++;
                }
            }
        }
        echo implode(" ", $seq), PHP_EOL;
        echo $count, PHP_EOL;
    }
}
    $answer = new Answer;
    $answer -> bubbleSort();


Measured memory_bytes: 9424
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

#INF = float("inf")
route_list=[[10**8]*N for _ in range(N)]

for i in range(M):
    a,b,c=[int(x) for x in input().split()]
    route_list[a-1][b-1]=c
    route_list[b-1][a-1]=c

wa_list=warshall_floyd(route_list)
ans=30**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)


Measured memory_bytes: 4656
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		double N = sc.nextInt();
		boolean f = false;
		for(int i=0; i<50000;i++) {
			if((int)(i*1.08)==N) {
				System.out.println(i);
				f = true;
				break;
			}
		}
		if(!f) {
			System.out.println(":(");
		}
		
				
		
		
		
		
	}
}




Measured memory_bytes: 21716
r, c = map(int, input().split())
mask = 10**9 + 7
grid = []
for _ in range(r):
  grid.append(input())
dp = [[0 for _ in range(c)] for _ in range(r)]
dp[0][0] = 1
for i in range(1, r):
  dp[i][0] = dp[i-1][0] if grid[i][0] != '#' else 0
for j in range(1, c):
  dp[0][j] = dp[0][j-1] if grid[0][j] != '#' else 0

for i in range(1, r):
  for j in range(1, c):
    if grid[i][j] != '#':
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mask
print(dp[-1][-1] % mask)

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

using namespace std;

int dp[10001];

int solve(int, int, int*, int*);

int main() {
  int H, N;
  cin >> H >> N;
  int A[N], B[N];
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

  memset(dp, -1, sizeof(dp));
  cout << solve(H, N, A, B) << endl;

  return 0;
}

int solve(int H, int N, int* A, int* B) {
  if (H < 0) H = 0;

  if (dp[H] >= 0) {
    return dp[H];
  }

  int res;
  if (H <= 0) {
    res = 0;
  } else {
    res = solve(H - A[0], N, A, B) + B[0];
    for (int i = 1; i < N; i++) {
      res = min(res, solve(H - A[i], N, A, B) + B[i]);
    }
  }
  return dp[H] = res;
}

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

int N, W;
int V[101][10001];

void init(void) {
	for (int i = 0; i < 101; i++)
		for (int j = 0; j < 10001; j++)
			V[i][j] = 0;
}

int main() {
	init();
	cin >> N >> W;
	int value, weight;
	for (int i = 1; i <= N; i++) {
		cin >> value >> weight;
		for (int c = 0; c <= W; c++) {
			if (c - weight >= 0)
				V[i][c] = max(value + V[i - 1][c - weight], V[i - 1][c]);
			else
				V[i][c] = V[i - 1][c];
//			cout << V[i][c] << " ";
		}
//		cout << endl;
	}
	cout << V[N][W] << endl;
}

Measured memory_bytes: 5104