akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    int k;
    std::cin >> k;

    long long sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += gcd(gcd(i, j), l);
            }
        }
    }

    std::cout << sum << std::endl;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	vector<string> vs={"hi", "hihi", "hihihi", "hihihihi", "hihihihihi"};
	rep(i, 5){
		if(s==vs[i]){
			puts("Yes"); return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>vec;
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,T,c,t;
    cin>>n>>T;
    for(int i=0;i<n;i++){
        cin>>c>>t;
        if(t<=T){
            vec.push_back(c);
        }
    }
    int sz=vec.size();
    if(sz==0){
        cout<<"TLE"<<endl;
    }
    else{
        sort(vec.begin(),vec.end());
        cout<<vec[0]<<endl;
    }

}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
int sum=0, ans = 0;
signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			sum++;
			if (sum > ans) {
				ans = sum;
			}
		}
		else {
			sum = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio Watubi elai
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define MX 10000008
#define cs int t;cin>>t;while(t--)
int i,j,k;
int r,s;
main()
{
 int a,b;
 cin>>a>>b;
 int k=a-(b*2);
 if(k>=0)cout<<k<<endl;else cout<<0<<endl;
}


Measured memory_bytes: 3632
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
MIN = []
MAX = []
MIN.append(t[0])
MAX.append(t[0])

for i in range(1,n):
  if t[i] == t[i-1]:
    MIN.append(1)
    MAX.append(t[i])
  else:
    MIN.append(t[i])
    MAX.append(t[i])
MIN[-1] = max(MIN[-1],a[-1])
MAX[-1] = min(MAX[-1],a[-1])
for i in range(n-1,0,-1):
  if a[i-1] == a[i]:
    MAX[i-1] = min(MAX[i-1],a[i-1])
  else:
    MIN[i-1] = max(MIN[i-1],a[i-1])
    MAX[i-1] = min(MAX[i-1],a[i-1])
ans = 1
for i,j in zip(MIN,MAX):
  diff = j-i+1
  if diff <= 0:
    print(0)
    exit()
  ans *= diff
  ans %= mod
print(ans)

Measured memory_bytes: 92772
import numpy as np
N, M = map(int, input().split())
A = np.array(input().split(), dtype=np.int32)

x = np.bincount(A)
fft_size = 1 << (2 * x.size + 10).bit_length()

fx = np.fft.rfft(x, fft_size)
conv = np.fft.irfft(fx * fx, fft_size)
conv = (conv + 0.5).astype(int)

tmp = np.arange(conv.size, dtype=int)
happy = tmp[np.nonzero(conv)].tolist()
cnt = conv[np.nonzero(conv)].tolist()


ans = 0
while M > 0:
    h = happy.pop()
    num = cnt.pop()
    num = min(M, num)

    M -= num
    ans += num * h

print(ans)


Measured memory_bytes: 41704
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) 
#define all(x) (x).begin(),(x).end()

int main()
{
    string s;
    cin >> s;
    vector<int> a(3);
    rep(i, s.size())
    {
        switch (s[i])
        {
        case 'a':a[0]++; break;
        case 'b':a[1]++; break;
        case 'c':a[2]++; break;
        }
    }
    sort(all(a),greater<int>());
    if ((a[0] - a[1] <= 1 && a[1] - a[2] == 0) || (a[0] - a[1] == 0 && a[1] - a[2] <= 1))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
vector<pair<int,int>> g[1010];

const ll INF=1e15;

pair<ll,ll> dfs(int now,int par){
    ll sum=0;
    ll ma=0;
    for(int i=0;i<g[now].size();i++){
        int nex=g[now][i].first;
        if(nex==par) continue;
        if(g[nex].size()==1) continue;
        ll x,y;
        tie(x,y)=dfs(nex,now);

        x+=g[now][i].second;
        y+=2*g[now][i].second;

        sum+=y;
        ma=max(ma,y-x);
    }

    return mkp(sum-ma,sum);
}

void solve(){
    for(int i=0;i<=N;i++) g[i].clear();
    vector<int> p(N),d(N);
    for(int i=1;i<N;i++) cin>>p[i];
    for(int i=1;i<N;i++) cin>>d[i];

    ll res=0;
    for(int i=1;i<N;i++){
        p[i]--;
        g[p[i]].push_back(mkp(i,d[i]));
        g[i].push_back(mkp(p[i],d[i]));
        res+=d[i];
    }

    ll ans=INF;
    for(int i=0;i<N;i++){
        ans=min(ans,dfs(i,-1).first);
    }
    cout<<ans+res<<endl;
}

int main(){
  while(1){
      cin>>N;
      if(N==0) break;
      solve();
  }

  return 0;
}



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


int main() {
  int n, l; cin >> n >> l;
  vector<string> vec(n);
  rep(i,n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  rep(i,n) cout << vec[i];
  cout << endl;
  
  return 0;
  
}

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

int main(){
  int N;
  int64_t K,Q;
  cin>>N>>K>>Q;
  vector<int> A(Q);
  vector<int> score(N);
  
  for(int i=0;i<Q;++i){
    cin>>A.at(i);
    score.at(A.at(i)-1)=score.at(A.at(i)-1)+1;
  }

  for(int i=0;i<N;++i){
    if(score.at(i)>Q-K){
      cout<<"Yes"<<endl;
    }
    else{
    cout<<"No"<<endl;
    }
  }
}

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

int main(){
	string s;
	cin >> s;
	if((int)s.length()>=4 && s.substr(0,4) == "YAKI"){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,d,a[222222],ps,ans;
struct node
{
	long long mn,pos;
	pair<long long,long long> x,y;//ai+id,ai-id
	pair<long long,long long> xx,yy;
}tree[888888];
long long Min(long long a,long long b,long long c,long long d)
{
	return min(a,min(b,min(c,d)));
}
void pushup(long long node)
{
	tree[node].x=min(tree[node<<1].x,tree[(node<<1)|1].x);
	tree[node].y=min(tree[node<<1].y,tree[(node<<1)|1].y);
	tree[node].xx=min(tree[node<<1].xx,tree[(node<<1)|1].xx);
	tree[node].yy=min(tree[node<<1].yy,tree[(node<<1)|1].yy);
	tree[node].mn=Min(tree[node<<1].mn,tree[(node<<1)|1].mn,tree[node<<1].y.first+tree[(node<<1)|1].xx.first,tree[(node<<1)|1].x.first+tree[node<<1].yy.first);
	if (tree[node].mn==tree[node<<1].mn) tree[node].pos=tree[node<<1].pos;
	else if (tree[node].mn==tree[(node<<1)|1].mn) tree[node].pos=tree[(node<<1)|1].pos;
	else if (tree[node].mn==tree[node<<1].y.first+tree[(node<<1)|1].xx.first) tree[node].pos=tree[(node<<1)|1].xx.second;
	else tree[node].pos=tree[node<<1].yy.second;
}
void build(long long l,long long r,long long node)
{
	if (l==r)
	{
		tree[node].mn=1e18;
		if (l==1) 
		{
			tree[node].x=make_pair(a[l]+l*d,l);
			tree[node].y=make_pair(a[l]-l*d,l);
			tree[node].xx=make_pair(1e18,1e18);
			tree[node].yy=make_pair(1e18,1e18);
		} 
		else
		{
			tree[node].xx=make_pair(a[l]+l*d,l);
			tree[node].yy=make_pair(a[l]-l*d,l);
			tree[node].x=make_pair(1e18,1e18);
			tree[node].y=make_pair(1e18,1e18);
		}
		return;
	}
	long long mid=(l+r)>>1;
	build(l,mid,node<<1);
	build(mid+1,r,(node<<1)|1);
	pushup(node);
}
void upd(long long x,long long l,long long r,long long node) 
{
	if (l==r)
	{
		swap(tree[node].x,tree[node].xx);
		swap(tree[node].y,tree[node].yy);
		return;
	}
	long long mid=(l+r)>>1;
	if (x>mid) upd(x,mid+1,r,(node<<1)|1);
	else upd(x,l,mid,node<<1);
	pushup(node);
}
int main()
{
	scanf("%lld%lld",&n,&d);
	for (long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	build(1,n,1);
	for (long long i=1;i<n;i++)
	{
		ans+=tree[1].mn;
		ps=tree[1].pos;
		upd(ps,1,n,1);
	}
	printf("%lld\n",ans);
	return 0;
} 

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

ll N,P;
string S;

ll solve(){
	vl s(N);
	rep(i,N) s[i] = S[i]-'0';

	if(P==2 || P==5){
		ll ret = 0;
		rep(i,N){
			ll lsd = s[N-1-i];
			if(lsd % P == 0) ret += N - i;
		}
		return ret;
	}

	ll ten = 1;
	vl cnt(P, 0);
	ll r = 0;
	cnt[r]++;
	rep(i,N){
		ll msd = s[N-1-i];
		r = (msd*ten + r) % P;
		ten = ten*10 % P;
		cnt[r]++;
	}

	ll ret = 0;
	rep(r,P) ret += cnt[r] * (cnt[r]-1) / 2;
	return ret;
}

int main(){
	cin>>N>>P>>S;
	cout<< solve() <<endl;
}


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

int main() {
  int N;
  int r[100000];
  int l[100000];
  cin >> N;
  int p[100000];
  int sum = 0;
  int i;
  for (i = 0; i < N; i++) {
    cin >> l[i] >> r[i] ;
    p[i] = 0;
    p[i] = r[i] - l[i]+1;
    sum += p[i];
  }
  cout << sum << endl;
}

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

using namespace std;

static const int N=100;

int main(){
int n,A[N+1],B[N+1][N+1];
cin>>n;
for(int i=1;i<=n;i++){
    cin>>A[i-1]>>A[i];
}
for(int i=1;i<=n;i++)B[i][i]=0;
for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
        int j=i+l-1;
        B[i][j]=(1<<21);
        for(int k=i;k<=j-1;k++){
            B[i][j]=min(B[i][j],B[i][k]+B[k+1][j]+A[i-1]*A[k]*A[j]);
        }
    }
}
cout<<B[1][n]<<endl;

return 0;
}


Measured memory_bytes: 3160
def warshall_floyd(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

H, W = map(int,input().split())
N = H * W

d = [[float("inf") for i in range(N)] for i in range(N)] 

M = [[1 for i in range(W+1)] for i in range(H+1)]
for i in range(H):
    m = input().strip()
    for j in range(W):
        if m[j] == '.':
            M[i][j] = 0

for i in range(H):
    for j in range(W):
        if M[i][j] == 0:
            d[W*i+j][W*i+j] = 0
            if M[i][j+1] == 0:
                d[W*i+j][W*i+j+1] = 1
                d[W*i+j+1][W*i+j] = 1
            if M[i+1][j] == 0:
                d[W*i+j][W*(i+1)+j] = 1
                d[W*(i+1)+j][W*i+j] = 1

o = warshall_floyd(d, N)
ans = 0
for i in range(N):
    for j in range(N):
        if o[i][j] != float('inf'):
            ans = max(ans, o[i][j])
print(ans)

Measured memory_bytes: 135176
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    long int a, b, c, d, e, f, g, h;
    scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
    e = a * c;
    f = a * d;
    g = b * c;
    h = b * d;
    if (e > f && e > g && e > h) printf("%ld\n", e);
    else if (f > g && f > h) printf("%ld\n", f);
    else if (g > h) printf("%ld\n", g);
    else printf("%ld\n", h);
    return 0;
}

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

int main(void)
{
  char child, mum;
  while (cin >> child >> mum)
  {
    if (child == '0' && mum == 'U')
    {
      cout << "nn";
    }
    else
    {
      switch (child)
      {
        case '1':
          break;
        case '2':
          cout << 'k';
          break;
        case '3':
          cout << 's';
          break;
        case '4':
          cout << 't';
          break;
        case '5':
          cout << 'n';
          break;
        case '6':
          cout << 'h';
          break;
        case '7':
          cout << 'm';
          break;
        case '8':
          cout << 'y';
          break;
        case '9':
          cout << 'r';
          break;
        case '0':
          cout << 'w';
          break;
      }
      switch (mum)
      {
        case 'T':
          cout << 'a';
          break;
        case 'L':
          cout << 'i';
          break;
        case 'U':
          cout << 'u';
          break;
        case 'R':
          cout << 'e';
          break;
        case 'D':
          cout << 'o';
          break;
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

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

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

void Main() {
  int N; cin >> N;
  vector<ll> A(3 * N);
  rep(i, 0, 3 * N) cin >> A[i];
  sort(all(A), greater<ll>());

  ll res = 0;
  rep(i, 0, N){
    res += A[2 * i + 1];
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


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

ll mod = 1000000007;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<int> A(2 * N);
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = a;
    A[i + N] = a;
  }

  ll c1 = 0;
  rep(i, N - 1) {
    for (int j = i + 1; j < N; j++) {
      if (A[i] > A[j])
        c1++;
    }
  }
  ll c2 = 0;
  rep(i, 2 * N - 1) {
    for (int j = i + 1; j < 2 * N; j++) {
      if (A[i] > A[j])
        c2++;
    }
  }
  c2 = max(ll(0), c2 - 2 * c1);

  ll ans = 0;
  ans += K * c1 % mod;
  ans += (K * (K - 1) / 2 % mod) * c2 % mod;
  ans %= mod;
  cout << ans << endl;
}

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

int main(){
    int a,b,c,count;
    count = 0;
    cin >> a >> b >> c;
    
    for (int i = a; i < b+1; i++){
        if (c % i == 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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


int main()
{
    string o,e;cin>>o>>e;
    int n = o.size() + e.size();
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) cout << o[i / 2];
        else cout << e[i/2];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

string S[2100];
int X[4][2100][2100];
int main(){
    int H, W;
    cin >> H >> W;
    REP(i,H){
        string s;
        cin >> s;
        S[i] = s;
    }

    REP(i,H){
        int num = 0;
        REP(j,W){
            char c = S[i][j];
            bool block = c == '#';
            if(!block){
                X[0][i][j] = num;
                num++;
            }
            else
                num = 0;
        }
    }

    REP(i,H){
        int num = 0;
        for(int j = W-1; j >= 0; j--){
            char c = S[i][j];
            bool block = c == '#';
            if(!block){
                X[1][i][j] = num;
                num++;
            }
            else
                num = 0;
        }
    }

    //for(int i = H-1; i >= 0; i--){
    //    int num = 0;
    //    for(int j = W-1; j >= 0; j--){
    //        char c = S[i][j];
    //        bool block = c == '#';
    //        if(!block){
    //            X[2][i][j] = num;
    //            num++;
    //        }
    //        else
    //            num = 0;
    //    }
    //}

    for(int j = 0; j < W; j++){
        int num = 0;
        for(int i = 0; i < H; i++){
            char c = S[i][j];
            bool block = c == '#';
            if(!block){
                X[2][i][j] = num;
                num++;
            }
            else
                num = 0;
        }
    }

    for(int j = 0; j < W; j++){
        int num = 0;
        for(int i = H-1; i >= 0; i--){
            char c = S[i][j];
            bool block = c == '#';
            if(!block){
                X[3][i][j] = num;
                num++;
            }
            else
                num = 0;
        }
    }

    int ans = 0;
    REP(i,H){
        REP(j,W){
            int num = 0;
            char c = S[i][j];
            bool block = c == '#';
            if(block) continue;
            REP(k,4){
                num += X[k][i][j]; 
            }
            chmax(ans, num+1);
        }
    }


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


Measured memory_bytes: 72448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
int n,m;
int p[80],cnt;
int pd(int x){
	for(int i=2;i*i<=x;i++)
		if(x%i==0)return 0;
	return 1;
}
int main(){
	for(int i=2;i<=10005;i++){
		if(pd(i) && i%10==1){
		//	cout<<i<<endl;
			p[cnt++]=i;
		}
		if(cnt>=70)break;
	}
	cin>>n;
	for(int i=0;i<n;i++){
		if(i!=0)cout<<" ";
		 cout<<p[i];
	}
	return 0;
}
/*
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
void con(string &s){
	int l=s.length();
	for(int i=0;i<(l+1)/2;i++){
		char t=s[i];s[i]=s[l-i-1];s[l-i-1]=t;
	}
}
int main(){
	string S,start,end;
	char str;
	int Q;
	int t,f,times=0;
	cin>>S>>Q;
	while(Q--){
		cin>>t;
		if(t==1) times++;
		else{
			cin>>f>>str;
			if(f==1){
				if(times%2==0) start=str+start;
				else end+=str;
			} else{
				if(times%2==0) end+=str;
				else start=str+start;
			}
		}
	}
	if(times%2==0) cout<<start<<S<<end<<endl;
	else{
		con(start);con(S);con(end);
		cout<<end<<S<<start<<endl;
	}
}

Measured memory_bytes: 1104
from collections import defaultdict
N = int(input())
H = defaultdict(int)
for _ in range(N):
  S = input()
  C = [0] * 26
  for s in S:
    C[ord(s) - 97] += 1
  H[str(C)] += 1
cnt = 0
for v in H.values():
  cnt += v * (v - 1) // 2
print(cnt)

Measured memory_bytes: 23908
N, P = map(int, input().split()) # 横に2個
A = [0 if a % 2 == 0 else 1 for a in list(map(int, input().split()))]
odd = A.count(1)
even = A.count(0)

if (P == 1 and odd == 0 ):
    ans = 0
elif odd == 0:
    ans = 2**(len(A))
else:
    ans = 2**(len(A)-1)

print(ans)

Measured memory_bytes: 3064
N = int(input())
bun_lis = [input() for _ in range(N)]
for n in range(N):
    bun_lis[n] = ''.join(sorted(list(bun_lis[n])))

bun_lis.sort()

total = 0
cnt = 1
bun_lis.append('XXX') #タグ

def pea(n):
    return int(n*(n-1)/2)

for n in range(N):
    if bun_lis[n] != bun_lis[n+1]:
        total += pea(cnt)
        cnt = 1
        continue
    cnt += 1

print(total)

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

using namespace std;

int main()
{
    int N,K,h,i,c;

    cin>>N>>K;

    c = 0;
    for(i=0;i!=N;i++)
    {
        cin>>h;

        if(h >= K)
            c++;
    }

    cout<<c;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define Num 100
#define INF 200000000

int main(void)
{
    int n , i;
    int w , x , y , z;
    int P[Num + 1] , M[Num + 1][Num + 1];
    
    scanf("%d" , &n);
    
    for(i = 1 ; i <= n ; i++)
        scanf("%d %d" , &P[i - 1] , &P[i]);
    
    for(i = 1 ; i <= n ; i++)
        M[i][i] = 0;
    
    for(z = 2 ; z <= n ; z++) {
        for(w = 1 ; w <= n - z + 1 ; w++){
            x = w + z - 1;
            M[w][x] = INF;
            
            for(y = w ; y <= x - 1 ; y++)
                M[w][x] = (M[w][x] < (M[w][y] + M[y + 1][x] + P[w - 1] * P[y] * P[x])) ?  M[w][x] : (M[w][y] + M[y + 1][x] + P[w - 1] * P[y] * P[x]);
        }
    }
    
    printf("%d\n" , M[1][n]);
    
    return 0;
}



Measured memory_bytes: 1924
import java.util.*
import kotlin.math.floor
import kotlin.math.min


fun main() {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextLong()
    val n = sc.nextLong()

    val x = min(b-1, n)
    
    println((floor(a * x / b.toDouble()) - a * floor(x / b.toDouble())).toInt())

}

/*


floor(x * a / b) - a * floor(x / b) の最大値

 */


Measured memory_bytes: 36180
#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;
typedef long long ll;

void vecprint(vector<ll> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

void qprint(priority_queue<ll> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

int main(void) {
    int n;
    cin >> n;
    
    vector<ll> va, vb, vc;
    for(int i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp;
        va.push_back(tmp);
    }
    for(int i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp;
        vb.push_back(tmp);
    }
    for(int i = 0; i < n-1; i++) {
        ll tmp;
        cin >> tmp;
        vc.push_back(tmp);
    }
    //cout << n << endl;
    //vecprint(va);
    //vecprint(vb);
    //vecprint(vc);
    
    int ans = 0;
    ans += vb[va[0]-1];
    //cout << ans << endl;
    for(int i = 1; i < n; i++) {
        ans += vb[va[i]-1];
        if(va[i] == va[i-1] + 1) ans += vc[va[i-1]-1];
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int a;
		scanf("%d",&a);
	for(int i=0,j=100;i<3;i++,j/=10){
		int c=a/j;a%=j;
			printf("%d",(c==1?9:1));
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define gcd __gcd
#define nl cout<<"\n"
#define endl "\n"
#define rep(i,n) for(ll i = 0 ; i < n ; i++)
#define fo(i,a,b) for(ll i = a ; i <= b ; i++)
#define foi(i,a,b) for(ll i = a ; i >= b ; i--)
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
//sorting in reverse order
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_factors_less_than(ll n){
    vector<ll> factor;
    vector<ll> prime(n,1);
    prime[0]=0,prime[1]=0;
    for(ll i = 2 ; i <= n ; i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returns x^y in order logn 
ll power(ll x, ll y) { 
    if (y == 0) return 1; 
    ll a = power(x,y/2);
    if (y % 2 == 0) return a * a; 
    else return x * a * a; 
} 
const float a =6.2831853071;
int main(){
    IOS;
    ll test,i;
    test = 1;
   // cin>>test;
    while(test--){
        float r;
        cin>>r;
        cout<<setprecision(10)<<a*r<<endl;   
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3824
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    if (a == b && b == c) { cout << 1 << endl; }
    else if (a == b && a != c) { cout << 2 << endl; }
    else if (b == c && c != a) { cout << 2 << endl; }
    else if (c == a && a != b) { cout << 2 << endl; }
    else { cout << 3 << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    ll n; cin >> n;
    vll a(n);
    ll s = 0;
    rep(i,n){
        cin >> a[i];
        s = s^a[i];
    }
    rep(i,n){
        ll ans = s^a[i];
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}  

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

int main(){
    int ans = 0;
    int num1 = 0;
    vector <int> v1;
    int num2 = 0;
    vector <int> v2;
    cin >> num1;

    for(int i = 0; i < num1 ; i++ ){
        int tmp;
        cin >> tmp;
        v1.push_back(tmp);
    }

    cin >> num2;

    for(int i = 0; i < num2; i++){
        int tmp;
        cin >> tmp;
        v2.push_back(tmp);
    }

    for(int i = 0; i< num2; i++){
        
        if(lower_bound(v1.begin(), v1.end(), v2[i]) != v1.end() && *lower_bound(v1.begin(), v1.end(), v2[i]) == v2[i]){
            ans++;
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
def agc_003_a
    n = 0
    w = 0
    s = 0
    e = 0
    gets.chomp.each_char do |c|
        case c
        when 'N'; n += 1
        when 'W'; w += 1
        when 'S'; s += 1
        when 'E'; e += 1
        end
    end

    ok = true
    ok = false if ok and n > 0 and s == 0
    ok = false if ok and w > 0 and e == 0
    ok = false if ok and s > 0 and n == 0
    ok = false if ok and e > 0 and w == 0

    puts ok ? 'Yes' : 'No'
end

agc_003_a

Measured memory_bytes: 1788
N = int(input())
S = []
for i in range(N):
    S.append(input())
AC = S.count("AC")
WA = S.count("WA")
TLE = S.count("TLE")
RE = S.count("RE")
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

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

using namespace std;

vector<int> Group;
vector<vector<int>> G(100001);
vector<pair<int, int>> blo,fri;

void dfs(int now,int parent){
    Group[now] = parent;
    for(int &x:G[now]){
        if(Group[x]==-1){
            dfs(x, parent);
        }
    }
    return;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    blo.resize(k);
    fri.resize(m);
    Group.resize(n, -1);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[--a].push_back(--b);
        G[b].push_back(a);
        fri[i] = {a, b};
    }
    for(int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        blo[i] = {--a, --b};
    }
    for (int i = 0; i < n; i++){
        if(Group[i]==-1)dfs(i,i);
    }
    vector<int> cnt(n, 0);
    for(int& x:Group){
        cnt[x]++;
    }
    vector<int> ret(n, 0);
    for(int i = 0; i < n; i++) {
        ret[i] = cnt[Group[i]]-1;
    }
    for(auto& x:fri){
        ret[x.first]--;
        ret[x.second]--;
    }
    for(auto& x:blo){
        if(Group[x.first]==Group[x.second]){
            ret[x.first]--;
            ret[x.second]--;
        }
    }
    for(auto& x:ret){
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

using ll = long long;
using namespace std;

int main() {
    ll N, M;
    cin >> N >> M;
    if (N * 2 <= M) {
        cout << N + (M - (2 * N)) / 4 << endl;
    }
    else {
        cout << M / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[0]*n
for i in range(n):
    a[i]=int(input())

b=sorted(a)
if(b[n-1]==b[n-2]):
    for i in range(n):
        print(b[n-1])
else:
    for i in range(n):
        if(a[i]==b[n-1]):
            print(b[n-2])
        else:
            print(b[n-1])

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int valid[3][3][2010] = {};
int cnt[3][3][2010] = {};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S[3];
    vec<int> si(3);
    int sum = 0;
    for(int i=0;i<3;i++){
        cin >> S[i];
        si[i] = S[i].size();
        sum += si[i];
    }
    for(int a=0;a<3;a++) for(int b=0;b<3;b++) if(a!=b){
        for(int i=0;i<=si[a];i++){
            bool ok = true;
            for(int j=i;j<si[a];j++) if(j-i<si[b]){
                ok &= (S[a][j]==S[b][j-i] || S[a][j]=='?' || S[b][j-i]=='?');
                cnt[a][b][i]++;
            }
            valid[a][b][i] = ok;
        }
    }
    vec<int> P = {0,1,2};
    int ans = 1e9;
    do{
        for(int i=0;i<=si[P[0]];i++){
            for(int j=0;j<=si[P[1]];j++){
                bool ok = valid[P[0]][P[1]][i];
                if(i+j<si[P[0]]){
                    ok &= valid[P[0]][P[2]][i+j];
                }
                ok &= valid[P[1]][P[2]][j];
                if(ok){
    //                cerr << S[P[0]] << " " << S[P[1]] << " " << S[P[2]] << "\n";
    //                cerr << i << " " << j << "\n";
                    ans = min(ans,sum-cnt[P[0]][P[1]][i]-(i+si[P[1]]<=si[P[0]]? cnt[P[0]][P[2]][i+j]:cnt[P[1]][P[2]][j]));
                }
            }
            if(i+si[P[1]]<=si[P[0]] && valid[P[0]][P[1]][i]){
                for(int j=i+si[P[1]];j<=si[P[0]];j++){
                    if(valid[P[0]][P[2]][j]) ans = min(ans,sum-cnt[P[0]][P[1]][i]-cnt[P[0]][P[2]][j]);
                }
            }
        }
    }while(next_permutation(P.begin(),P.end()));
    cout << ans << "\n";
}

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

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

  int A = 1, B;
  while (A * 10 < N) A *= 10;
  B = N - A;

  int A_sum = 0, B_sum = 0;
  while (A > 0) {
    A_sum += A % 10;
    A /= 10;
  }
  while (B > 0) {
    B_sum += B % 10;
    B /= 10;
  }

  cout << A_sum + B_sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll k,cnt=1;
  cin>>k;
  ll x=7, rem=7%k;
  while(rem!=0){
    x = (x*(10%k))%k;
    rem = (rem+x)%k;
    cnt++;
    if(cnt>1e7){
      cnt=-1;
      break;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3688
var
  f:array[0..111,0..111111] of int64;
  w,v,a:array[1..111] of int64;
  n,m,j,i:longint;
BEGIN
 /// assign(input,'a.in'); reset(input);
  readln(n,m);
  for i:=1 to n do readln(w[i],v[i]);
  fillchar(f,sizeof(f),0);
  for i:=1 to n do
    for j:=1 to m do
      if (w[i]>j) then f[i,j]:=f[i-1,j] else
      if f[i-1,j]>=f[i-1,j-w[i]]+v[i] then f[i,j]:=f[i-1,j] else f[i,j]:=f[i-1,j-w[i]]+v[i];
  writeln(f[n,m]);
  Readln;
END.


Measured memory_bytes: 97280
while True:
    n = int(input())
    if n == 0:
        break
    h = list(map(int,input().split()))
    for i in range(n+1):
        s = 0
        if i == 0:
            s = 1
        d = None
        k = 1
        cnt = 0
        for j in range(s+1,n+1):
            if j == i:
                continue
            if d == None:
                d = h[j]-h[s]
            elif h[j]-h[s] != d*k:
                cnt += 1
            k += 1
        if cnt == 0:
            print(h[i])
            break



Measured memory_bytes: 5608
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
int f[N2];
int space;
string path;

bool operator < (const Puzzle &p)const{
for(int i=0;i<N2;i++){
if(f[i]==p.f[i])continue;
return f[i]>p.f[i];
}
return false;
}
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p){
for(int i=0;i<N2;i++)
if(p.f[i]!=(i+1))return false;
return true;
}

string bfs(Puzzle s){
queue<Puzzle>Q;
map<Puzzle,bool>V;
Puzzle u,v;
s.path="";
Q.push(s);
V[s]=true;
while(!Q.empty()){
  u=Q.front();
  Q.pop();
  if(isTarget(u))return u.path;
  int sx=u.space/N;
  int sy=u.space%N;
  for(int r=0 ; r<4 ; r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0 || ty<0 || tx>=N || ty>=N)continue;
    v=u;
    swap(v.f[u.space], v.f[tx*N+ty]);
    v.space=tx*N+ty;
    if(!V[v]){
      V[v]=true;
      v.path+=dir[r];
      Q.push(v);
    }
  }
}

return "unsolvable";

}

int main(){
  Puzzle in;
  for(int i=0 ; i<N2 ; i++){
    cin >> in.f[i];
    if(in.f[i]==0){
    in.f[i]=N2;
    in.space=i;
    }
  }
  
  string ans=bfs(in);
  cout << ans.size() << endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

ll a[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < 3 * n; i++)
        cin >> a[i];
    sort(a, a + 3 * n, greater<ll>());
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += a[2 * i + 1];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2688
#include "bits/stdc++.h"
 
using namespace std;
 
using ll = long long;
 
#define all(x) begin(x), end(x)
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); 
 
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
ll n; cin >> n;
cout << fixed << (long double)n/3*(long double)n/3*(long double)n/3 << "\n";

 
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  N++;

  int ans = 0;
  while (N > 9)
  {
    ans += 9;
    N /= 10;
  }
  ans += N - 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())


dp = [0]*(n+1)
dp[0] = 1

for i in range(m):
	dp[int(input())] = -1

if dp[1] != -1:
	dp[1] = 1

for i in range(n-1):
	if dp[i+2] != -1:
		if dp[i+1] != -1:
			dp[i+2] += dp[i+1]
		if dp[i] != -1:
			dp[i+2] += dp[i]

print(dp[n]%1000000007)


Measured memory_bytes: 469112
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int s=a*b;
		int l=2*(a+b);
		
		System.out.println(s+" "+l);
	}
}


Measured memory_bytes: 26172
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define int long long
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool ok = false;
    while(1){
      if(a>0 && c<=0){
        cout <<"Yes";
        return 0;
      }
      else if(a<=0 && c>0){
        cout << "No";
        return 0;
      }
      if(ok==false){
        c = c-b;
        ok = true;
      }
      else{
        a = a -d;
        ok = false;
      }
    }
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    } 
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		FastReader sc = new FastReader();
		double d = sc.nextDouble();
		double t = sc.nextDouble();
		double s = sc.nextInt();
		
		if(s!=0)
		{
		if(d/s <= t )
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
		}
		else
		{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 33100
# D - 2017-like Number (hint)
import math
Q = int(input())
lr = []
for _ in range(Q):
    l,r = map(int,input().split())
    lr.append((l,r))

# iが素数なら Primes[i] = 1
Primes = [1]*((10**5)+1)
Primes[0],Primes[1] = 0,0

for i in range(2,10**5+1):
    if Primes[i] == 0:
        continue
    M = int(math.sqrt(i))+1 
    for j in range(2,M):
        if i%j == 0:
            Primes[i] = 0
            break
    else:
        for k in range(i*2,(10**5)+1,i):
            Primes[k] = 0

like2017 = [0]*(10**5+1)
for x in range(10**5+1):
    if Primes[x] == 1 and Primes[(x+1)//2] == 1:
        like2017[x] = 1

# 累積和
s = [0]*(len(like2017)+1)
for a in range(len(like2017)):
    s[a+1] = s[a] + like2017[a]

for l,r in lr:
    ans = s[r+1] - s[l]
    print(ans)

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

using namespace std;
typedef  long long ll;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sdo(a) scanf("%lf",&a)
#define sdo2(a,b) scanf("%lf %lf",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+10;
const int mod=1e9+7;

struct xx{
int x,d,l,r;
};
xx a[maxn];
bool cmp(xx a,xx b)
{
    if(a.l==b.l)
        return a.r<b.r;
    return a.l<b.l;
}
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            int d;
            sint2(a[i].x,d);
            a[i].l=a[i].x-d;
            a[i].r=a[i].x+d;
        }
        sort(a,a+n,cmp);
        stack<int> st;
        int wz=-1e9+7;
        st.push(0);
        wz=a[0].l;
        for(int i=1;i<n;i++)
        {
            int t=st.top();
            if(wz<=a[i].l&&a[i].r<=a[t].r)
            {
                st.pop();
                if(!st.empty())
                    wz=a[st.top()].r;
                else
                {
                    wz=-1e9+7;
                }
                st.push(i);
            }
            else if(a[i].l>=a[t].r)
            {
                wz=a[st.top()].r;
                st.push(i);
            }
            else
            {
                continue;
            }
        }
        printf("%d\n",st.size());
    }
    return 0;
}


Measured memory_bytes: 2176
N = int(input())

if N % 2 == 0 :
    n_even = int(N / 2)
    n_odd = n_even
    chance = n_odd / N
    print(chance)
    
else :
    n_even = int(N / 2)
    n_odd = n_even + 1
    chance = n_odd / N
    print(chance)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
int main(){
    int N;
    std::cin >> N;
    std::vector<int> A(N),count(N),u;
    
    for(int i=0;i<N;i++){
        std::cin >> A[i];
    }
    std::sort(A.begin(),A.end());
    int k=0;
    for(int i=0;i<N;i++){
        count[k]++;
        if(A[i+1]!=A[i]){
            k++;
            u.push_back(A[i]);
        }

    }
    int sum=0;
    for(int i=0;i<k;i++){
        if(count[i]!=u[i]){
            if(count[i]>u[i]){
                sum+=count[i]-u[i];
            }else{
                sum+=count[i];
            }
        }
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int n; cin >> n;
    int a[n][26];
    memset(a, 0, sizeof(a));

    rep(i,n) {
        string s; cin >> s;
        rep(j,s.length()) {
            a[i][s[j]-'a']++;
        }
    }

    vector<int> count(26, INF);
    rep(j,26) {
        rep(i,n) {
            count[j] = min(count[j], a[i][j]);
        }
    }
    rep(i,26) {
        if (count[i] == INF) continue;
        rep(j,count[i]) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 3608