akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;

namespace AtCoder0913
{
    class Program
    {
        static void Main(string[] args)
        {
      //      int Na = int.Parse(Console.ReadLine());
            long[] N = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray() ;

            long a = N[0];
            long b = N[1];
            long c = N[2];
            long d = N[3];

            List<long> list = new List<long>{ a * c, a*d, b*c, b*d};

            long max = list.Max();

            Console.WriteLine(max);

        }
    }
}


Measured memory_bytes: 28368
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

int main() {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);

  printf("%d\n", std::min(A*N, B));
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i % 2 == 1 && j % 2 == 1) {
                        System.out.print("#");
                    }
                    if (i % 2 == 0 && j % 2 == 1) {
                        System.out.print(".");
                    }
                    if (i % 2 == 1 && j % 2 == 0) {
                        System.out.print(".");
                    }
                    if (i % 2 == 0 && j % 2 == 0) {
                        System.out.print("#");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 37612
#include <stdio.h>

#define MAX 100

int main(){
    int n;
    int i;
    char z[MAX];
    if(scanf("%d",&n)!=1) return 1;
    if(scanf("%s",z)==0) return -1;
    if(n%2==1){
        printf("No\n");
        return 0;
    }
    else {
        for(i=0;i<n/2;i++){
            if(z[i]==z[n/2+i]) continue;
            printf("No\n");
            return 0;
        }
        printf("Yes\n");
        return 0;
    }
}


Measured memory_bytes: 128
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    k = II()
    print((-(-k//2))*(k//2))
    # if k%2==0:
        # print((k//2)**2)
    # else:
        # print(((k+1)//2)*(k//2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
#include <cctype>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5+10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int M, W;
int MB[16], WB[16];
int memo[16][1 << 13];

int calc(int m, int w){
	return abs(MB[m] - WB[w]) * (int)pow(abs(MB[m] - WB[w]) - 30, 2);
}

int rec(int m, int w){
	if(memo[m][w] != -1)
		return memo[m][w];
	if(m >= M)
		return 0;
	int res = 0;
	REP(i,W){
		if(!(w >> i & 1)){
			res = max(res, rec(m + 1, w | 1 << i) + calc(m, i));
		}
	}
	return memo[m][w] = res;
}

int main() {
	while(cin >> M >> W && (M || W)){
		memset(memo, -1, sizeof(memo));
		REP(i,M){
			cin >> MB[i];
		}
		REP(i,W){
			cin >> WB[i];
		}
		if(M > W){
			REP(i,M){
				if(i < W){
					swap(MB[i], WB[i]);
				}
				else{
					WB[i] = MB[i];
				}
			}
			swap(M, W);
		}
		cout << rec(0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1680
#include <iostream>
#include <string>
using namespace std;
int main(){
    int H, W, K, cnt, ans;
    ans = 0;
    string s[6];
    cin >> H >> W >> K;
    for(int i=0;i<H;i++){
        cin >> s[i];
    }
    for(int i=0;i<(1<<H);i++){
        for(int j=0;j<(1<<W);j++){
            cnt = 0;
            for(int a=0;a<H;a++){
                for(int b=0;b<W;b++){
                    if(s[a][b]=='#'){
                        if(!(i & (1<<a))){
                            if(!(j & (1<<b))){
                                cnt++;
                            }
                        }
                    }
                }
            }
            if(cnt == K){
                ans++;
            }
        }
    }
    cout << ans;
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n,m;
ll a[100001],b[100001],c[100001];
l_l cb[100001];

ll ans;

int main() {
    cin >> n >> m;
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    for (int i=0;i<m;i++) {
        cin >> b[i] >> c[i];
        cb[i] = make_pair(c[i],b[i]);
    }
    sort(a,a+n);
    sort(cb,cb+m,greater<l_l>());

    ll it = -1;
    for (int i=0;i<m;i++) {
        ll B = cb[i].second;
        ll C = cb[i].first;
        it += B;
        if(it>=n) {
            it -= B;
            for (int j=it+1;j<n;j++){
                ans += max(C,a[j]);
            }
            it = n-1;
            break;
        }
        if (a[it] > C) {
            ll mem = it - B +1;
            for (int j=mem;j<mem+B;j++) {
                ans += max(C,a[j]);
            }
            break;
        }

        ans += C*B;
    }

    for (int i=it+1;i<n;i++) {
        ans += a[i];
        // cout << ans << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>

int main(){
	int k, a, b;
	bool flg = false;
	std::cin >> k >> a >> b;
	for(int i = a; i <= b; ++i){
		if(i % k == 0){
			flg = true;
			break;
		}
	}

	if(flg){
		std::cout << "OK" << std::endl;
	}
	else{
		std::cout << "NG" << std::endl;
	}

	return 0;	
}


Measured memory_bytes: 3632
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

A,B=map(int,input().split())
A-=1
B-=1
lst=[["#" if m<50 else "." for i in range(100)] for m in range(100)]
for h in range(0,100,2):
    for w in range(0,100,2):
        if A==0:
            break
        lst[h][w]="."
        A-=1

    if A==0:
        break
for h in range(99,-1,-2):
    for w in range(0,100,2):
        if B==0:
            break
        lst[h][w]="#"
        B-=1

    if B==0:
        break
print(100,100)
for i in range(100):
    print("".join(lst[i]))


Measured memory_bytes: 38640
import itertools
K = int(input())
Q = [[int(i) for i in input().split()] for _ in range(K)]
li = list(range(8))
P = itertools.permutations(li, 8)

for p in P:
    is_ok = True
    for row, col in Q:
        if(p[row]!=col):
            is_ok = False
            break
    else:
        for ind,i in enumerate(p):
            for x in range(8):
                if(ind==x):
                    continue
                if(p[x]==i+x-ind or p[x]==i-(x-ind)):
                    is_ok = False
    if(is_ok):
        break
ans = [['.']*8 for _ in range(8)]
for ind, i in enumerate(p):
    ans[ind][i] = 'Q'
    print(*ans[ind], sep='')
     


Measured memory_bytes: 5660
#include <iostream>
#include <algorithm>
#include <cstdlib>
#define MAXN 100005
#define ll long long
using namespace std;
ll a[MAXN], b[MAXN], c[MAXN];
ll n;
template <typename T> inline void read(T &x) {
    char c; bool flag = 0; x = 0;
    c=getchar();
    while(c > '9' || c < '0') {if(c=='-') flag = 1; c = getchar();}
    while(c <= '9' && c >= '0'){x = x*10+c-48; c = getchar();}
    if(flag) x = x*(-1);    
}

inline void init() {
    read(n);
    for(int i = 1; i <= n; i++) read(a[i]);
    for(int i = 1; i <= n; i++) read(b[i]);
    for(int i = 1; i <= n; i++) read(c[i]);
}

inline ll searcha(ll x) {
    if(x <= a[1]) return 0;
    ll l = 1, r = n, mid;
    while(l <= r) {
        mid = (l+r) >> 1;
        if(a[mid] > x) r = mid - 1;
        else l = mid + 1;
    }
    l --;
    while(a[l] == x && l >= 0) l --;
    if(l < 0) l = 0;
    return l;
}
inline ll searchc(ll x) {
    if(x >= c[n]) return 0;
    ll l = 1, r = n, mid;
    while(l <= r) {
        mid = (l+r) >> 1;
        if(c[mid] > x) r = mid - 1;
        else l = mid + 1;
    }
    l --;
    return n-l;
}

int main() {
    long long ans = 0;
    ll loc1, loc2;
    init();
    sort(a+1, a+1+n);
    sort(c+1, c+1+n);
    for(int i = 1; i <= n; i++) {
        loc1 = searcha(b[i]);
        loc2 = searchc(b[i]);
        ans += loc1*loc2;
    }
    cout << ans << "\n";
    // system("pause");
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef struct {
  int y, x;
}pos;


char mp[55][55];
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int d[55][55];
int h, w;
queue<pos> que;

int bfs(int sy, int sx) {
  que.push((pos){sy, sx});
  d[sy][sx] = 1;

  while(!que.empty()){
    pos now = que.front();
    que.pop();

    int y = now.y;
    int x = now.x;

    if ( y == h-1 && x == w-1) {
      break;
    }
    for ( int i = 0; i < 4; i++) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if ( ny >= 0 && ny < h && nx >= 0 && nx < w && d[ny][nx] == -1 && mp[ny][nx] == '.') {
        d[ny][nx] = d[y][x] + 1;
        que.push((pos){ny, nx});
      }
      
    }
    
  }

  return d[h-1][w-1];
}

int main() {
  int p = -1;
  int kuro = 0, shiro = 0;

  cin >> h >> w;
  for ( int i = 0; i < h; i++) {
    for ( int j = 0; j < w; j++) {
      cin >> mp[i][j];
      d[i][j] = -1;
      if ( mp[i][j] == '#' ){
        kuro++;
      } else if ( mp[i][j] == '.' ){
        shiro++;
      }
    }
  }

  int sub = bfs(0,0);
  if ( sub != -1 ) {
    p = shiro - sub;
  } 
  cout << p << endl;

  return (0);
  
}

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

using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        v.push_back(x);
        ans += x;
    }
    sort(v.begin(), v.end(), greater<int>());
    ans -= v[0]/2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

import sys

def main():
    ans_list=[0]*26
    for line in sys.stdin:
        for s in line:
            if s.isupper()==True:
                s=s.lower()
            if ord(s)<97 or ord(s)>122:
                continue
            else:
                ans_list[ord(s)-97]+=1
    for idx,ans in enumerate(ans_list):
        print("{} : {}".format(chr(97+idx),ans))

if __name__=="__main__":
    main()


Measured memory_bytes: 5576
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def popcount(i):
    return bin(i).count('1')

N = INT()
S = list(map(int, input()))[::-1]

pcnt1 = S.count(1) - 1
pcnt2 = S.count(1) + 1
base1 = base2 = 0
for i in range(N):
    if S[i]:
        if pcnt1 != 0:
            base1 += pow(2, i, pcnt1)
        base2 += pow(2, i, pcnt2)

ans = [0] * N
for i in range(N):
    if S[i] and pcnt1 == 0:
        ans[i] = 0
        continue
    cur = 0
    if S[i]:
        cur += (base1 - pow(2, i, pcnt1)) % pcnt1
    else:
        cur += (base2 + pow(2, i, pcnt2)) % pcnt2
    cnt = 1
    while cur:
        cur %= popcount(cur)
        cnt += 1
    ans[i] = cnt
for a in ans[::-1]:
    print(a)


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

int main(){
    string s;
    for(int i=0;i<3;i++) cin >> s[i];
    if(s[0] == s[1] && s[1] == s[2] && s[2] == s[0]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
H, N = tuple(map(int, input().split(" ")))
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split(" "))))

minpower = 10 ** 8 + 1

# dp[n][h] = 0 ~ n - 1 番目の魔法を使えた時、残り体力がhのモンスターを倒すために必要な魔力
dp = [[minpower for _ in range(H + 1)] for __ in range(N)]
for h in range(H):
    dp[0][h] = math.ceil(h / AB[0][0]) * AB[0][1]

for n in range(N):
    dp[n][0] = 0

for h in range(H + 1):
    for n in range(N):
        a, b = AB[n]

        if h - a < 0:
            dp[n][h] = min(
                dp[n-1][h],
                b
            )
        else:
            dp[n][h] = min(
                dp[n-1][h],
                dp[n][h-a] + b)
print(dp[-1][H])

Measured memory_bytes: 125788
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	string ans = "|";
	for(int i = 0;i<=int(s.size())-int(t.size()); i++)
	{
		bool f = 1;
		string t2=s;
		for(int j = 0; j<t.size(); j++)
		{
			if(s[i+j]!=t[j] && s[i+j]!='?') f = 0;
			t2[i+j] = t[j];
		}
		if(f)
		{
			// t2 = s;
			replace(t2.begin(),t2.end(),'?','a');
			// t2 = t2.substr(0,i)+t+t2.substr(i+t.length());
			ans = min(ans,t2);
		}
	}
	if(ans=="|")
		cout<<"UNRESTORABLE"<<endl;
	else
		cout<<ans<<endl;
	return 0;
}


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

int main() {
  int N; cin >> N;
  int kaijouN =1;
  for (int i =1; i<= N; i++) {
    kaijouN *= i;
  }
  vector<int> P(N);
  vector<int> Q(N);
  for (int i =0; i<N; i++) cin >> P.at(i);
  for (int i =0; i<N; i++) cin >> Q.at(i);
  
  vector<int> asceP(N);
  for (int i =0; i<N; i++) asceP.at(i) = P.at(i);
  sort(asceP.begin(),asceP.end());
  
  int numP,numQ, countP, countQ;
  int j =0;
  while (j < kaijouN) {
    int i =0;
    while (i < N) {
      if (asceP.at(i) == P.at(i)) countP++;
      if (asceP.at(i) == Q.at(i)) countQ++;
      i++;
    }
    if (countP == N) numP = j;
    if (countQ == N) numQ = j;
    countP =0; countQ =0; j++;
    next_permutation(asceP.begin(),asceP.end());
  }
  cout << abs(numP - numQ) << endl; 
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int ans=101;
    for(int i=0;i<26;i++){
        int maxi=0,count=0;
        for(int j=0;j<s.length();j++){
            count++;
            if(s[j]==u[i]){
                maxi=max(maxi,count-1);
                count=0;
            }
            else if(j==s.length()-1){
                maxi=max(maxi,count);
            }
        }
        ans=min(maxi,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll dp[101][100001];
main(){
    int N,W;
    cin >> N >> W;
    rep(i,0,N){
        int w,v;
        cin >> w >> v;
        rep(j,0,W+1){
            dp[i+1][j] = dp[i][j];
            if(j - w < 0)continue;
            dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v);
        }
    }
    ll maxi = 0;
    rep(i,0,W+1)maxi = max(maxi, dp[N][i]);
    cout << maxi << endl;
}

Measured memory_bytes: 78336
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;


int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int ans = n/x;
  if(n%x != 0){
    ans++;
  }
  cout << ans*t << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  string s;
  cin>>s;
  int c=0;
  rep(i,0,s.size()){
    if(s[i]=='x') c++;
  }
  if(c>=8) co("NO");
  else co("YES");
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int mid(int a,int b,int c){
  return a+b+c-max(max(a,b),c)-min(min(a,b),c);
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0;i < N;i++){
    cin >> A.at(i);
  }
  int count = 0;
  for(int k = 0;k < N-2;k++){
    if(A.at(k + 1) == mid(A.at(k),A.at(k+1),A.at(k+2))){
      count++;
    }
  }
    cout << count  << endl;
  
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int a,b;cin>>a>>b;
  cout<<max3(a+b,a+a-1,b+b-1)<<endl;

  return 0;
}



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

int main() {
    int s[10];
    rep(i,10) cin >> s[i];
    int ans = 0;
    rep(i,10) ans += s[i];
    cout << ans << endl;

}


Measured memory_bytes: 3080
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    input! {
        n: usize,
        m: usize,
        a: [usize; m]
    }

    let d = 1000000007;
    let mut dp = vec![0; n+1];

    dp[0] = 1;
    dp[1] = 1;
    for e in &a {
        dp[*e] = -1;
    }

    for i in 2..n+1 {
        if dp[i] != -1 {
            dp[i] = if dp[i-1] != -1 { dp[i-1] } else { 0 }
                    + if dp[i-2] != -1 { dp[i-2] } else { 0 };
            dp[i] = dp[i] % d;
        }
    }

    println!("{}", dp[n]);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,m;
        cin>>n>>m;
        bool vis[N];
        ll arr[N];
        memset(arr,0,sizeof(arr));
        rep(i,0,m)
        {
             ll x;
             cin>>x;
             string s;
             cin>>s;
             if(s=="AC")
             {
                vis[x]=1;
             }
             else
             {
                if(vis[x]==0)
                    arr[x]++;
             }
        }
        ll ans=0,ans2=0;
        rep(i,1,n+1)
        {
            if(vis[i])
                ans++,ans2+=arr[i];
        }
        
        cout<<ans<<" "<<ans2<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;
const int N = 1e5 + 123 , mod = 1e9 + 7;
int n , k , dp[2][N] , a[101] , pr[2][N];
int get(int x , int l , int r){
	if(l <= 0)
		return pr[x][r];
	return (pr[x][r] - pr[x][l - 1] + mod) % mod;
}
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++)
		cin >> a[i];
	dp[0][0] = 1;
	for(int i = 0 ; i <= k ; i++)
		pr[0][i] = 1;
	
	for(int i = 1 ; i <= n; i++){
		for(int j = 0 ; j <= k ; j++)
			dp[i % 2][j] = get((i + 1) % 2 , j - a[i] , j) % mod;
		pr[i % 2][0] = dp[i % 2][0];
		for(int j = 1 ; j <= k ; j++){
			pr[i % 2][j] = (pr[i % 2][j - 1] + dp[i % 2][j]) % mod;
		}
	}
	
	cout << dp[n % 2][k];
	
}

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

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

using namespace std;

int main(){
	int n,d; cin>>n>>d;
	int x[10][10];
	rep(i,n) rep(j,d) cin>>x[i][j];

	int ans=0;
	rep(i,n) rep(j,i) {
		int a=0;
		rep(k,d) a+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
		int b=(int)(sqrt(a)+0.5);
		if(b*b==a) ans++;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    long long a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    // long long prod = 1;
    // for (int i = 0; i < k; i++)
    //     prod *= a[i];

    // long long prev = prod;

    // for (int i = k; i < n; i++)
    // {
    //     prod = (prod * a[i]) / a[i - k];
    //     if (prod > prev)
    //         cout << "Yes\n";
    //     else
    //         cout << "No\n";
    //     prev = prod;
    // }

    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i - k])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

int main(void){

    int h, w, m;
    cin >> h >> w >> m;

    set<P> s; // setのfindの計算量はlog
    mp x, y;
    int hmval = 0, wmval = 0;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        s.insert(P{a, b});
        x[a]++;
        y[b]++;
        chmax(hmval, x[a]);
        chmax(wmval, y[b]);
    }

    int ans = hmval + wmval - 1; // 爆弾が重複しているとしてマイナス1
    // 各行列ごとに、最大値と一致するhとwを答えの候補とする
    vector<int> hmax, wmax;
    for(auto q : x){
        if(hmval == q.second){
            hmax.push_back(q.first);
        }
    }
    for(auto q : y){
        if(wmval == q.second){
            wmax.push_back(q.first);
        }
    }

    // 答えの候補の中に重複しない（爆弾が存在しない）座標があれば、それが最大値となるからans+1をする
    for(auto q : hmax){
        for(auto p : wmax){
            if(s.find(P{q, p}) == s.end()){
                cout << ans + 1 << "\n";
                return 0;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

using ull = unsigned long long;

// レベルnのx層目までに何枚パティがあるか
ull solve(int n, ull x, vector<ull> &len, vector<ull> &cnts) {
  if (x == 0) {
    return 0;
  }

  if (n == 0) {
    return 1;
  }

  if (x <= len[n - 1] + 1) {
    return solve(n - 1, x - 1, len, cnts);
  } else if (x == len[n - 1] + 2) {
    return cnts[n - 1] + 1;
  } else {
    x -= len[n - 1] + 2;
    ull ans = cnts[n - 1] + 1 + solve(n - 1, x, len, cnts);
    return ans;
  }
}

int main(int argc, const char *argv[]) {
  int n;
  ull x;
  cin >> n >> x;

  vector<ull> len(n + 1);
  len[0] = 1;
  for (int i = 1; i <= n; ++i) {
    len[i] = len[i - 1] * 2 + 3;
  }

  // cnts[i]: レベルiにパティが何枚あるか
  vector<ull> cnts(n + 1);
  cnts[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cnts[i] = cnts[i - 1] * 2 + 1;
  }

  cout << solve(n, x, len, cnts) << '\n';

  return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

int main(){
    ll x;
    cin >> x;
    x = lcm(x, 360) / x;
    cout << (x) << endl;
    return 0;
}


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

using namespace std;

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

  for(int i = 0; i <= n; i++) {
    if((n-4*i) >= 0 & (n-4*i)%7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

// Segment Tree
// セグメント木
// 区間個数
// i = 0～
#define SEGT_N ((1<<17)) // > 10^5
#define SEGT_INVALID (INT_MIN)
int segt[SEGT_N*2];

void SEGTupdate(int i, int val)
{
    i = SEGT_N-1+i;
    segt[i]++;
    while(i)
    {
        i = (i-1)/2;
        segt[i] = segt[i*2+1]+segt[i*2+2];
    }
}

int SEGTget_sub(int l, int r, int i, int il, int ir)
{
    if((ir < l) || (r < il) ) return 0; // 被らない
    if((l <= il) && (ir<=r) )
    {
        return segt[i]; // 完全にかぶっている
    }else
    {
        int lv = SEGTget_sub(l,r,i*2+1,il, (il+ir+1)/2-1);
        int rv = SEGTget_sub(l,r,i*2+2, (il+ir+1)/2,ir);
        return lv+rv;
    }
}

int SEGTget(int l, int r)
{
    return SEGTget_sub(l,r,0,0,SEGT_N-1);
}

ll l[MAXN];

int main(void)
{
    ll n;
    scanf("%ld",&n);
    for(int i=0;i<n;i++)scanf("%ld",&l[i]);

    for(int i=0;i<n;i++) SEGTupdate(l[i],0);

    ll ans = 0;
    for(int i=0;i<n;i++) for(int j=i+1;j<n;j++)
    {
        ll n = SEGTget(abs(l[j]-l[i])+1,l[j]+l[i]-1);
        if(abs(l[j]-l[i])+1 <= l[i] && l[i] <= l[j]+l[i]-1 ) n--;
        if(abs(l[j]-l[i])+1 <= l[j] && l[j] <= l[j]+l[i]-1 ) n--;
        ans += n;
    }
    
    printf("%ld\n", ans/3);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        long long int n,k;
        long long int a[200010];
        int ans=0, check=0,chnum[200010],count=0;

        cin >> n >>k;
        for(int i=0; i<n; i++) cin >> a[i];

        sort(a,a+n);

        check=a[0];

        for(int i=0;i<n;i++){

                if(a[i]==check) chnum[count]++;
                else{
                        count++;
                        check=a[i];
                        chnum[count]=1;
                }
        }

        count++;

        sort(chnum,chnum+count);

        for(int i=0; i<count-k; i++) ans+=chnum[i];

        cout << ans << endl;

        return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e5+3;
const int INF = 1e9;


int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    LL ans = 0;
    fore(i,1,n) {
        if(i%3 && i%5) ans+=i;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n; ll k;
	cin >> n >> k;
	int a[n];
	rep(i,n) cin >> a[i];

	vector<int> s;
	vector<int> ord(n+1,-1);//-1なら訪れてない
	int c= 1,l = 0;
	{
		int v = 1;
		while(ord[v] == -1){
			ord[v] =s.size();
			s.push_back(v);
			v = a[v-1];
		}
		c = s.size()-ord[v];
		l = ord[v];
	}

	if (k < l) cout << s[k] << endl;
	else {
		k -= l;
		k %= c;
		cout << s[l+k] << endl;
	}
	return 0;

}

Measured memory_bytes: 5824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

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

int find_order(vi a){
	int n = a.size();
	int ans = 0;
	vi temp(n);
	forn(i, n) temp[i] = i + 1;
	do{
		ans++;
		if(temp == a) break;
	}while(next_permutation(temp.begin(), temp.end()));
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vi a(n), b(n);
	forn(i, n) cin >> a[i];
	forn(i, n) cin >> b[i];
	cout << abs(find_order(a) - find_order(b)) << endl;
}		


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        int[] L, R;
        Check(A, out L, out R);
        long ans = 0;
        for (int i = 0; i < N; i++)
            ans += (long)A[i] * (i - L[i] + 1) * (R[i] - i);
        Console.WriteLine(ans);
    }

    // [L, R)
    void Check(int[] H, out int[] L, out int[] R)
    {
        int N = H.Length;
        L = new int[N];
        R = new int[N];
        int[] stack = new int[N];

        for (int i = 0, si = 0; i < N; i++)
        {
            while (si > 0 && H[stack[si - 1]] >= H[i]) si--;
            L[i] = si == 0 ? 0 : stack[si - 1] + 1;
            stack[si++] = i;
        }
        for (int i = N - 1, si = 0; i >= 0; i--)
        {
            while (si > 0 && H[stack[si - 1]] >= H[i]) si--;
            R[i] = si == 0 ? N : stack[si - 1];
            stack[si++] = i;
        }
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 22224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> vp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    vp.at(i) = make_pair(a, b);
  }
  sort(vp.begin(), vp.end());
  double sum = 0;
  int co = 0;
  do{
    rep2(i, 1, n){
      double add = (vp.at(i).first - vp.at(i-1).first) * (vp.at(i).first - vp.at(i-1).first) + (vp.at(i).second - vp.at(i-1).second) * (vp.at(i).second - vp.at(i-1).second);
      sum += sqrt(add);
    }
    co++;
  }while(next_permutation(vp.begin(), vp.end()));
  // cerr << co << endl;
  sum /= co;
  printf("%.10f\n", sum);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		String strN = sc.next();

		//"7が含まれているかの判定"
		if(strN.contains("7")) {
			System.out.println("Yes");

		}
		//含まれていない
		else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

vector<int> unique(vector<int> v) {
	vector<int> u;
	if (!v.empty()) {
		u.push_back(v[0]);
		FOR(i, 1, v.size()) if (v[i] != v[i-1]) u.push_back(v[i]);
	}

	return u;
}

int main() {
	int n, m;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;

		vector<vector<int> > v(n);
		REP(i, m) {
			int a, b;
			cin >> a >> b;
			v[a-1].push_back(b-1);
			v[b-1].push_back(a-1);
		}

		vector<int> u;
		REP(i, v[0].size()) {
			u.push_back(v[0][i]);
			REP(j, v[v[0][i] ].size()) {
				u.push_back(v[v[0][i] ][j]);
			}
		}

		sort(u.begin(), u.end());
		u = unique(u);
		u.erase(u.begin());

		cout << u.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1384
#include <algorithm>
#include <iostream>
#include <vector>

#include <cmath>

using namespace std;

typedef long long ll;

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

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

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

    // {x. y}
    vector<pair<int, int>> town(N);
    for (int i = 0; i < N; i++) {
        cin >> town[i].first >> town[i].second;
    }

    double sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            double d_x = (town[i].first - town[j].first) * (town[i].first - town[j].first);
            double d_y = (town[i].second - town[j].second) * (town[i].second - town[j].second);
            // printf("i: %d, j: %d, d_x: %f, d_y: %f\n", i, j, d_x, d_y);
            sum += sqrt(d_x + d_y);
        }
    }

    printf("%.7f\n", sum / N);

    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

const double pi = 3.141592653589793;

#define xx          first
#define yy          second
#define mp          make_pair
#define intl        long long
#define filein      freopen("input.txt", "r", stdin)
#define fileout     freopen("output.txt", "w", stdout)
#define debug       cout << "YES" << endl
#define what_is(x)  cout << #x << " is " << x << endl
#define pb          push_back
#define pii         pair<int, int>
const intl mod = 1e9 + 7;

//find_by_order(int) and order_of_key(int)
//typedef tree < intl , null_type ,less<intl>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
const int M = 200008;

intl fact[M], inv[M];

long long exponentiation( long long a, long long b, long long mod )
{
    long long ans = 1;
    while( b > 0 )
    {
        if( b&1 )
            ans = (a*ans)%mod;
        a = (a*a)%mod;
        b /= 2;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //filein;
    fact[0] = 1;
    inv[0] = 1;
    for( int i = 1; i < M; i++ )
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = exponentiation( fact[i], mod-2, mod );
    }
    intl n, m, a, b;
    cin >> n >> m >> a >> b;
    intl ans = (((fact[n+m-2]*inv[n-1])%mod)*inv[m-1])%mod;
    intl y = b;
    //what_is(ans);
    for( intl x = n-a+1; x <= n; x++ )
    {
        ans = (ans - (((((fact[x+y-2]*inv[x-1])%mod)*inv[y-1])%mod)*((((fact[m-y-1+n-x]*inv[m-y-1])%mod)*inv[n-x])%mod))%mod)%mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		List<List<Integer>> g = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			g.add(new ArrayList<>());

			int u = sc.nextInt() - 1;
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				g.get(u).add(sc.nextInt() - 1);
			}
		}

		sc.close();

		Deque<Integer> q = new ArrayDeque<>();
		int[] d = new int[n];
		Arrays.fill(d, -1);

		q.add(0);
		d[0] = 0;

		while (!q.isEmpty()) {
			int c = q.poll();

			for (int x : g.get(c)) {
				if (d[x] == -1 || d[x] > d[c] + 1) {
					d[x] = d[c] + 1;
					q.add(x);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			out.println((i + 1) + " " + d[i]);
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}



Measured memory_bytes: 28368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll n=s.size();
  if(n==1){
    cout << k/2 << endl;
    return 0;    
  }
  if(k==1){
    ll ttans=0;
    rep(i,n-1){
      if(s[i]==s[i+1]){
	ttans++;
	i++;
      }
    }
    cout << ttans << endl;
    return 0;    
  }
  ll tans=0;
  ll ans=0;
  bool nxt=false;
  s += s[0];
  rep(i,n){
    if(i+1<=n && s[i]==s[i+1]){
      tans++;
      if(i+1==n){
	nxt=true;
      }
      i++;
    }
  }
  if(!nxt){
    ans = tans*k;
    cout << ans << endl;
    return 0;
  }
  ll tans2=0;
  nxt=false;
  rep1(i,n-1){
    if(i+1<=n && s[i]==s[i+1]){
      tans2++;
      if(i+1==n){
	nxt=true;
      }
      i++;
    }
  }
  
  if(nxt){
    ans=tans2*(k-1)+tans-1;
    cout << max(ans,0LL) << endl;
  }
  else{
    
    ans=(tans+tans2)*(k/2) + (k%2)*(tans-1);
    cout << max(ans,0LL) << endl;
  }
  
  
  return 0;
    

}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int n;

  scanf("%d",&n);

  int a;
  int odd = 0;

  REP (i, n) {
    scanf("%d",&a);
    if (a % 2 == 1) odd++;
  }
  if (odd % 2 == 0) printf("YES\n");
  else printf("NO\n");
}


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

using namespace std;

int main() {
	int banyak, angka, ganjil[100010], genap[100010];
	scanf("%d", &banyak);
	memset(ganjil, 0, sizeof ganjil);
	memset(genap, 0, sizeof genap);
	vector<pair<int, int> > daftar;
	pair<int, int> pganjil1, pganjil2, pgenap1, pgenap2;
	for (int i = 0; i < banyak; i++) {
		scanf("%d", &angka);
		if (i % 2 == 0)
			genap[angka]++;
		else
			ganjil[angka]++;
	}
	for (int i = 1; i < 100001; i++)
		daftar.push_back(make_pair(ganjil[i], i));
	sort(daftar.rbegin(), daftar.rend());
	pganjil1 = daftar[0];
	pganjil2 = daftar[1];
	daftar.clear();
	for (int i = 1; i < 100001; i++)
		daftar.push_back(make_pair(genap[i], i));
	sort(daftar.rbegin(), daftar.rend());
	pgenap1 = daftar[0];
	pgenap2 = daftar[1];
	angka = pganjil1.first + pgenap1.first;
	if (pganjil1.second == pgenap1.second)
		angka = max(pganjil1.first + pgenap2.first, pganjil2.first + pgenap1.first);
	banyak -= angka;
	printf("%d\n", banyak);
	return 0;
}

Measured memory_bytes: 2168