akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K;
        cin >> N >> K;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        ll ans;
        N -= 1;
        if (N % (K-1) == 0) ans = N / (K-1);
        else ans = N / (K-1) + 1;
        cout << ans << endl;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
ll a[105000];

int ans[105000];
set<int> inv[105000];
int cnt[105000];
set<int> Rest;

void f(int val) {
    //cerr << "f: " << val << endl;
    int tmp = a[val];
    if(Rest.find(tmp) != Rest.end()) {
        auto itr = inv[cnt[tmp]].lower_bound(tmp);
        inv[cnt[tmp]].erase(itr);
        cnt[tmp]--;
        inv[cnt[tmp]].insert(tmp);
    }
    auto itr = Rest.lower_bound(val);
    Rest.erase(itr);
    itr = inv[cnt[val]].lower_bound(val);
    inv[cnt[val]].erase(itr);
}

bool ok() {
    for(int i = 2; i <= N; i++) {
        if(a[ans[i-1]] == ans[i]) return false;
    }
    return true;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    if(N == 2) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1; i <= N; i++) Rest.insert(i);
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i = 1; i <= N; i++) {
        inv[cnt[i]].insert(i);
        //cerr << i << " " << cnt[i] << endl;
    }
    for(int i = 1; i <= N - 3; i++) {
        //cerr << i << " " << Rest.size() << endl;
        if(!inv[N-i].empty()) {
            int val = *inv[N-i].begin();
            //cerr << i << " " << val << endl;
            f(val);
            ans[i] = val;
        } else {
            auto itr = Rest.begin();
            int val = *Rest.begin();
            if(i >= 2 and i < N) {
                if(a[ans[i-1]] == val) {
                    itr++;
                    val = *itr;
                }
            }
            //cerr << val << endl;
            f(val);
            ans[i] = val;
        }
    }
    for(int i = N - 2; i <= N; i++) {
        auto itr = Rest.begin();
        ans[i] = *itr;
        Rest.erase(itr);
    }
    do {
        //for(int i = 1; i <= N; i++) cerr << ans[i] << " ";
        //cerr << endl;
        if(ok()) break;
    } while(next_permutation(ans + N - 2, ans + N + 1));
    for(int i = 1; i <= N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 16896
MOD = 10 ** 9 + 7
n = int(input())

# 素数
primes = [True] * (n + 1)
p = 2
while p * p <= n:
    if primes[p]:
        for i in range(p * p, n + 1, p):
            primes[i] = False
    p += 1
primes[0], primes[1] = False, False

# counter
cnt = [0] * (n + 1)
for k in range(2, n + 1):
    now = k
    # 素因数分解
    for i in range(2, k + 1):
        while k % i == 0:
            cnt[i] += 1
            k //= i
    if k != 1:
        cnt[k] += 1

res = 1
for k in range(1, n + 1):
    if primes[k]:
        res *= cnt[k] + 1
        res %= MOD

print(res)

Measured memory_bytes: 68024
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef pair< pair<string, int>, int> psi;
bool cmp(psi a, psi b) {
  if (a.first.first == b.first.first) {
    return a.first.second > b.first.second;
  }
  return a.first.first < b.first.first;
}

int n;
psi ar[105];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i].first.first >> ar[i].first.second;
    ar[i].second = i+1;
  }
  sort(ar, ar+n, cmp);
  for (int i = 0; i < n; i++) {
    cout << ar[i].second << el;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC121
{
    class D
    {
        static void Main(string[] args)
        {
            long[] h = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long A = h[0], B = h[1];

            long[] la = Get(A-1); long[] lb = Get(B);

            long c = 0;
            for(int i = 0; i < 40; i++)
            {
                long z = lb[i] - la[i];
                if (z % 2 == 1)
                {
                    c += (long)Math.Pow(2, i);
                }
            }

            Console.WriteLine(c);
        }

        static long[] Get(long x)
        {
            long[] d = new long[40];

            for (int i = 0; i < d.Length; i++)
            {
                long k = (long)Math.Pow(2, i);
                long p = k * 2;
                long m = x % p;
                long s = k * (x / p) + Math.Max(0,(m - k + 1));
                d[i] = s;
            }

            return d;
        }

    }

    class Bit
    {
        public int[] digit;

        public Bit(long x)
        {
            List<int> list = new List<int>();
            long z = x;
            for(int i = 0; i < 13; i++)
            {
                list.Add((int)(z % 2));
                z /= 2;
            }
            digit = list.ToArray();
        }
    }
}


Measured memory_bytes: 13396
from itertools import product
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**16
    n,*abc=MI()
    ll=[II() for _ in range(n)]

    ans=inf
    for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

    print(ans)

main()

Measured memory_bytes: 43372
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	while(cin>>str){
        int flag=0;
        for(int i=0;i<str.length();i++){
            if(str[i]=='7'){
                flag=1;
                break;
            }
        }
        if(flag)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
	}
  return 0;
}


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

int main(){

	int n, a[100];
	cin >> n;

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

	for(int i = n-1; i>=0; i--){
		cout << a[i] << " \n"[i == 0];
	}


	return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define ls(x) (x << 1)
#define rs(x) (x<<1|1)
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2e9;
const double INF_d = 1e64;

template<class T>
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }
// head

const int N = 1e5 + 7;
int n, k, a[N], res, cnt, vis[N];

void solve(){
    res = INF;
    int l, r; 
    l = r = cnt = 0;
    memset(vis, 0, sizeof(vis));
    while (r < n){
        while (cnt < k && r < n){
            if (a[r] >= 1 && a[r] <= k){
                if (!vis[a[r]]) cnt++;
                vis[a[r]]++;
            }
            r++;
        }
        if (cnt < k) break;
        while (cnt >= k && l < r){
            res = min(res, r - l);
            if (a[l] >= 1 && a[l] <= k){
                vis[a[l]]--;
                if (!vis[a[l]]) cnt--;
            }
            l++;
        }
    }
    if (res == INF) res = 0;
    printf("%d\n", res);
}

int main(){
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    solve();
    return 0;
}


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

using ll=long long;
const ll MOD=1e9+7;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++) cin>>a[i];

    vector<vector<ll>> dp(h,vector<ll>(w,0));
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#') dp[i][j]=0;
            if(i+1<h) (dp[i+1][j]+=dp[i][j])%=MOD;
            if(j+1<w) (dp[i][j+1]+=dp[i][j])%=MOD;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 9216
A11,A12,A13 = map(int, input().split())

A21,A22,A23 = map(int, input().split())

A31,A32,A33 = map(int, input().split())

A1 = [A11, A12, A13]
A2 = [A21, A22, A23]
A3 = [A31, A32, A33]

B1 = [0, 0, 0]
B2 = [0, 0, 0]
B3 = [0, 0, 0]

N = input()
N = int(N)

b = list(range(N))

for l in b:
    b[l] = input()
    b[l] = int(b[l])

for i in range(N):
    if b[i] == A1[0]:
        B1[0] = 1
    elif b[i] == A1[1]:
        B1[1] = 1
    elif b[i] == A1[2]:
        B1[2] = 1
    elif b[i] == A2[0]:
        B2[0] = 1
    elif b[i] == A2[1]:
        B2[1] = 1
    elif b[i] == A2[2]:
        B2[2] = 1
    elif b[i] == A3[0]:
        B3[0] = 1
    elif b[i] == A3[1]:
        B3[1] = 1
    elif b[i] == A3[2]:
        B3[2] = 1

Bingo = 0

if B1[0] == 1 and B1[1] == 1 and B1[2] == 1:
    Bingo = 1
elif B2[0] == 1 and B2[1] == 1 and B2[2] == 1:
    Bingo = 1
elif B3[0] == 1 and B3[1] == 1 and B3[2] == 1:
    Bingo = 1
elif B1[0] == 1 and B2[0] == 1 and B3[0] == 1:
    Bingo = 1
elif B1[1] == 1 and B2[1] == 1 and B3[1] == 1:
    Bingo = 1
elif B1[2] == 1 and B2[2] == 1 and B3[2] == 1:
    Bingo = 1
elif B1[0] == 1 and B2[1] == 1 and B3[2] == 1:
    Bingo = 1
elif B1[2] == 1 and B2[1] == 1 and B3[0] == 1:
    Bingo = 1

if Bingo == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve(std::string S){
    ll n = S.length();
    ll sum=0;
    ll cntr=0, cntl=0;
    for (ll i = 0; i < n; i++) {
        if(S[i]=='<') cntr++;
        if(S[i]=='>') cntl++;
        if(S[i]=='>' && S[i+1]=='<'){
            if(cntr>cntl){
                sum+=cntr*(cntr+1)/2;
                sum+=(cntl-1)*(cntl)/2;
            }else{
                sum+=(cntr-1)*(cntr)/2;
                sum+=cntl*(cntl+1)/2;
            }
            // debg(cntr);
            // debg(cntl);
            cntr=0;
            cntl=0;
        }
    }
    if(cntr!=0 || cntl!=0){
        if(cntr>cntl){
            sum+=cntr*(cntr+1)/2;
            sum+=(cntl-1)*(cntl)/2;
        }else{
            sum+=(cntr-1)*(cntr)/2;
            sum+=cntl*(cntl+1)/2;
        }
    }
    cout << sum << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int> st;
  for(int i=0;i<3;i++) {
    int a;
    cin>>a;
    st.insert(a);
  }
  cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX_V 1000
int V,cmp[MAX_V];
vector<int> G[MAX_V],rG[MAX_V],vs,a,xx;
int used[MAX_V];
void addedge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
} 
void dfs(int v){
  used[v]=1;
  for(int i=0;i<G[v].size();i++)
    if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v,int k){
  used[v]=1;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++){
    if(!used[rG[v][i]])rdfs(rG[v][i],k);
  }
}
void dfs2(int v,int k){
  used[v]=k;
  for(int i=0;i<G[v].size();i++)
    if(!used[G[v][i]])dfs2(G[v][i],k);
  xx.push_back(v);
}
int scc(){
  int pp=0;
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++)
    if(!used[v])dfs(v);
  memset(used,0,sizeof(used));
  int k=1;
  for(int i=vs.size()-1;i>=0;i--)
    if(!used[vs[i]]){
      rdfs(vs[i],k++);
    }
  k=1;
  map<int,int>m;
  memset(used,0,sizeof(used));
  for(int i=vs.size()-1;i>=0;i--){
    if(!used[vs[i]]){
      dfs2(vs[i],k);
      r(j,xx.size())if(used[xx[j]]!=k){
        m[used[xx[j]]]=0;
      }
      xx.clear();
      m[vs[i]]=cmp[vs[i]];
      k++;
    }
  }
  r(i,V)if(m[i])
    a.push_back(m[i]);
  return k;
}
int main(){
  int x,y;
  while(cin>>V,V){
    double d[V],ans=0;
    a.clear();
    r(i,1000)G[i].clear(),rG[i].clear();
    r(i,V){
      cin>>d[i]>>x;
      r(j,x){
        cin>>y;
        addedge(i,y-1);
      }
    }
    scc();
    int cnt=0;
    r(i,a.size()){
      double p=0;
      int c=0;
      r(j,V)if(cmp[j]==a[i]){
        if(!c++)p+=d[j];
        else p*=d[j];
      }
      if(!cnt++)ans+=(1.0-p);
      else ans*=(1.0-p);
    }
    printf("%.9f\n",ans);
  }
}

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

int main(){
    int n;
    string w;
    vector<string> wo;
    int count = 1;

    cin >> n;
    for(int i = 0; i < n; i++){
        string w;
        cin >> w;
        auto itr = find(wo.begin(), wo.end(), w);
        
        if(itr != wo.end()){
            cout << "No" << endl;
            count = 0;
            break;
        }
    
        wo.push_back(w);
        
        if(i != 0){
            if(wo[i][0] != wo[i-1][wo[i-1].size()-1]){
                cout << "No" << endl;
                break;
            } else {
                count++;
            }
            
        }
    }
    
    if(count == n){
        cout << "Yes" << endl;
    }

    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


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

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


f64 N;

int main() {
  cin >> N;

  cout << 1 - (floor(N / 2) / N) << endl;

  return 0;
}

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

const int N = 100010;

int cnt[N << 2], a[3][N], inv[N];
bool rev[N];

void no(){
	puts("No");
	exit(0);
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < 3; ++ i){
		for (int j = 0; j < n; ++ j){
			scanf("%d", &a[i][j]);
			++ cnt[a[i][j]];
		}
	}
	for (int i = 1; i <= 3 * n; ++ i){
		if (cnt[i] != 1){
			no();
		}
	}
	for (int i = 0; i < n; ++ i){
		if (a[0][i] + a[2][i] != a[1][i] << 1) no();
		if (std::abs(a[0][i] - a[1][i]) != 1) no();
		if (((a[0][i] - 1) / 3 & 1) != (i & 1)) no();
		inv[(a[0][i] - 1) / 3] = i;
	}
	for (int i = 0; i < n; ++ i){
		if ((a[0][i] - 1) / 3 != i){
			inv[(a[0][i] - 1) / 3] = inv[i];
			for (int j = 0; j < 3; ++ j){
				std::swap(a[j][i], a[j][inv[i]]);
			}
			std::swap(a[0][i + 1], a[2][i + 1]);
			if ((inv[i] - i) >> 1 & 1){
				std::swap(a[0][i], a[2][i]);
				std::swap(a[0][inv[i]], a[2][inv[i]]);
			}
			inv[i] = i;
		}
	}
	for (int i = 0; i < n; ++ i){
		rev[i] = a[0][i] > a[2][i];
	}
	for (int i = 0; i <= n - 4; ++ i){
		if (rev[i]){
			for (int j = 0; j < 4; ++ j){
				rev[i + j] = !rev[i + j];
			}
		}
	}
	if (rev[n - 2] || rev[n - 3] != rev[n - 1]) no();
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3072
//
// Created by Myabu on 2020/01/18.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int N;
    double ans = 0;

    cin>>N;

    for (int i = 0; i < N; ++i) {
        double X;
        string U;
        cin>>X>>U;

        if(U == "JPY"){
            ans += X;
        }else{
            ans += X * 380000;
        }
    }

    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
 
  int main(){
        lint n;
        cin >>n; vector<lint> a(n);
        rep(i,n)cin >> a[i];
        map<lint,lint>mp;
        rep(i,n){
             lint count=0;
             lint b=a[i];
                repp(j,2,sqrt(a[i])+1){
                    if(b==1)break;
                    lint count=0;
              while(b%j==0){
                    count++;
                    b/=j;
              }
              mp[j]=max(mp[j],count);
                }
                if(b!=1)mp[b]=max(mp[b],(lint)1);
            }
        lint lc=1;
        for(auto x:mp){
            lc*=modpow(x.first,x.second,MOD);
            lc%=MOD;
        }
    lint ans=0;
    
    rep(i,n){
        ans+=lc*modpow(a[i],MOD-2,MOD);
        ans%=MOD;
    }
    cout<<ans<<endl;
  }
  
     


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
//#define int long long

#pragma GCC optimize ("O3")

signed main(){

  int N, M, Q; cin >> N >> M >> Q;
  vector<int16_t> L(M), R(M), p(Q), q(Q);
  for(int i = 0; i < M; i++){
    cin >> L[i] >> R[i];
  }

  vector<int> ans(Q);
  for(int i = 0; i < Q; i++){
    cin >> p[i] >> q[i];
  }

  const int Q1 = Q / 8 * 8;
  for(int i = 0; i < Q1; i+=8){
    for(int j = 0; j < M; j++){
      ans[i + 0] += (p[i + 0] <= L[j]) & (R[j] <= q[i + 0]);
      ans[i + 1] += (p[i + 1] <= L[j]) & (R[j] <= q[i + 1]);
      ans[i + 2] += (p[i + 2] <= L[j]) & (R[j] <= q[i + 2]);
      ans[i + 3] += (p[i + 3] <= L[j]) & (R[j] <= q[i + 3]);
      ans[i + 4] += (p[i + 4] <= L[j]) & (R[j] <= q[i + 4]);
      ans[i + 5] += (p[i + 5] <= L[j]) & (R[j] <= q[i + 5]);
      ans[i + 6] += (p[i + 6] <= L[j]) & (R[j] <= q[i + 6]);
      ans[i + 7] += (p[i + 7] <= L[j]) & (R[j] <= q[i + 7]);
    }
  }
  for(int i = Q1; i < Q; i++){
    for(int j = 0; j < M; j++){
      ans[i] += (p[i] <= L[j]) & (R[j] <= q[i]);
    }
  }

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

  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 305;
const int NIL = -1;
const ll LINF = 1LL << 50;
const int mod = 1e+9 + 7;
/* global variables */
/* funciton */
/* main */
int main() {
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> a[i][j];

    ll upper = 1 << N;
    // dp[m][s] = Male, m番目まで使った時
    // s : 使ったFemaleをbitで管理
    vector<vector<ll>> dp(N+1, vector<ll>(upper));

    dp[0][0] = 1;
    for (int m = 0; m < N; m++) {
        for (ll s = 0; s < upper; s++) {
            if (__builtin_popcount(s) != (m) || dp[m][s] == 0) continue;
            for (int f = 0; f < N; f++) {
                ll b = 1 << f;
                if (s & b || (a[m][f] == 0)) continue;
                ll nextS = s + b;
                dp[m+1][nextS] += dp[m][s];
                dp[m+1][nextS] %= mod;
            }
        }
    }
    cout << dp[N][upper-1] << '\n';
}

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

int main(){
  int n, m;
  map<string, int> cards{};

  cin >> n;
  string s;
  for( int i = 0; i < n; ++i ){
    cin >> s;
    cards[s]++;
  }
  
  cin >> m;
  for(int i = 0; i < m; ++i){
    cin >> s;
    cards[s]--;
  }

  int maxv = 0;
  for( auto x : cards ){
    maxv = max(maxv, x.second);
  }

  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 256
A = (1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692)
print(A[int(input())-1])

Measured memory_bytes: 62356
A_having = int(input())
B_having = int(input())
C_having = int(input())
X = int(input())

patterns = 0
for a in range(A_having + 1):
    for b in range(B_having + 1):
        for c in range(C_having + 1):
            total = a * 500 + b * 100 + c * 50
            if total == X:
                patterns += 1

print(patterns)


Measured memory_bytes: 3060
#include <iostream>

using namespace std ;

int main(void){
    int N;
    bool flag = false;

    cin >> N;
    // 4A+7B=N
    for(int i=0; i<=N/4; i++){
        for(int j=0; j<=N/7; j++){
            if(4*i + 7*j == N) flag = true;
        }
    }
    if (flag == false) cout << "No" << endl;
	else cout << "Yes" << endl;

    return 0;
}


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

int index(int numToFind, std::vector<int> vectorToFindIn) {int len = vectorToFindIn.size();for (int i = 0; i < len; i++){if (vectorToFindIn[i] == numToFind){return i;}}return -1;}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin>>n>>m;
	if (abs(n-m)%2==1)
	{
		cout<<"IMPOSSIBLE";
	}
	else
	{
		cout<<(n+m)/2;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,i,j,k;
    scanf("%d",&n);
    int A[n],rev[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
        rev[i]=A[i];
    }
    for(i=0;i<n;i++)
    {
        rev[A[i]-1]=i+1;
    }
    for(i=0;i<n;i++)
    {
        printf("%d ",rev[i]);
    }
    return 0;
}


Measured memory_bytes: 1536
n = input()
 
a = list( map( int, input().split()))
b = list( map( int, input().split()))
c = list( map( int, input().split()))
 
satisfaction = 0
for i in range( len( a )):
  a_i = a[ i ] - 1
  satisfaction += b[ a_i ]
  if i > 0:
    if a[ i ] == a[ i - 1 ] + 1:
      satisfaction += c[ a_i - 1 ]
print( satisfaction )

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t x;
  cin >> x;
  int64_t total = (x/500)*1000+((x % 500)/5)*5;
  cout << total << endl;
}

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

int ans[7];

int main() {
  for (int i = 0; i < 7; ++i) {
    int a, b;
    cin >> a >> b;
    ans[i] = a - b;
  }

  for (int i = 0; i < 7; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <set>
using namespace std;
int main()
{
    int N;
    cin>> N;
    set<string> kinds;
    for(int i = 0; i<N; i++){
        string k;
        cin>> k;
        kinds.insert(k);
    }
    cout<< kinds.size();
    return 0;
}


Measured memory_bytes: 19192
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pa pair<int,int>
#define pii pair<ll,ll>
#define st first
#define nd second
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

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

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

int main(){
  ll n,m;
  cin >> n >> m;
  string s,t; cin >> s >> t;
  ll l=lcm(n,m);
  ll dn=l/n;
  ll dm=l/m;
  ll dl=lcm(dn,dm);
  ll di=dl/dn;
  ll dj=dl/dm;
  int i=0,j=0;
  bool f=1;
  while(i<n&&j<m){
    if(s[i]!=t[j]) f=0;
    i+=di; j+=dj;
  }
  if(f) cout << l << endl;
  else cout << -1 << endl;
  
}

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

int main()
{
    string s;
    int n;
    int m;
    cin>>n;
    cin>>s;
    cin>>m;

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

        if(s[i]==s[m-1]){
          cout<<s[i];
        }else{
            cout<<'*';
        }
    }
    printf("\n");
    //cout << "Hello world!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

int a,b;

int main()
{
	cin >> a >> b;
	if (a <= 0 && b >= 0)
		cout << "Zero" << endl;
	else if (a > 0 || (a - b) & 1)
		cout << "Positive" << endl;
	else
		cout << "Negative" << endl;
	return 0;
}

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

using namespace std;

const int inf = (int) 1e9;
const int N = 1234567;

int save_x[N], save_y[N];

vector <int> g[N], g_blue[N];
int d[N], d_blue[N];
int pr[N], pr_blue[N];

void dfs(int v, int pv) {
  if (d[v] >= d_blue[v]) {
    return;
  }
  int sz = g[v].size();
  for (int j = 0; j < sz; j++) {
    int u = g[v][j];
    if (u == pv) {
      continue;
    }
    pr[u] = v;
    d[u] = d[v] + 1;
    dfs(u, v);
  }
}

int n;

void get_d(int start) {
  for (int i = 0; i < n; i++) {
    d[i] = inf;
    pr[i] = -1;
  }
  d[start] = 0;
  pr[start] = start;
  dfs(start, -1);
}

int main() {
  int x, y;
  scanf("%d %d %d", &n, &x, &y);
  x--; y--;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", save_x + i, save_y + i);
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int foo, bar;
    scanf("%d %d", &foo, &bar);
    foo--; bar--;
    g[foo].push_back(bar);
    g[bar].push_back(foo);
  }
  for (int i = 0; i < n; i++) {
    d_blue[i] = inf;
  }
  get_d(y);
  for (int i = 0; i < n; i++) {
    d_blue[i] = d[i];
    g_blue[i] = g[i];
    pr_blue[i] = pr[i];
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int foo, bar;
    foo = save_x[i];
    bar = save_y[i];
    foo--; bar--;
    g[foo].push_back(bar);
    g[bar].push_back(foo);
  }
  get_d(x);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] < d_blue[i]) {
      mx = max(mx, 2 * d_blue[i]);
      for (int j = 0; j < (int) g[i].size(); j++) {
        int to = g[i][j];
        if (pr_blue[to] == i || pr_blue[i] == to || pr_blue[pr_blue[to]] == i || pr_blue[pr_blue[i]] == to || pr_blue[i] == pr_blue[to]) {
          continue;
        }
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 86912
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
val = 1
ans = 1

while True:
    if val <= N:
        ans = val
    else:
        break
    val *= 2

print(ans)


Measured memory_bytes: 27288
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

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


int main(){
    ll ans,n;
    cin >>n;
    ll a[n];
    ll gl[n];
    ll gr[n];
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    gl[0]=a[0];
    gr[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        gl[i]=gcd(gl[i-1],a[i]);
        gr[n-1-i]=gcd(gr[n-i],a[n-1-i]);
    }
    ans=0;
    for(int i=0;i<n;i++){
        if(i==0)ans=max(ans,gr[i+1]);
        else if(i==n-1)ans=max(ans,gl[i-1]);
        else ans=max(ans,gcd(gl[i-1],gr[i+1]));
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 2688
n,w = map(int,input().split())
v = []
wt = []
for _ in range(n):
    x,y=map(int,input().split())
    wt.append(x)
    v.append(y)
a = [[0 for x in range(w+1)] for x in range(n+1)] 
for i in range(n+1):
    for j in range(w+1):
        if i == 0 or j==0:
            a[i][j]=0
        elif wt[i-1]<=j:
            a[i][j]=max(a[i-1][j],(v[i-1]+a[i-1][j-wt[i-1]]))
        else:
            a[i][j]=a[i-1][j]
print(a[n][w])

Measured memory_bytes: 171656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0;
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	
	if(s.length()<=k)cout<<s<<endl;
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}cout<<"..."<<endl;
	}
	
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
    rep(i, m)
    {
        cin >> k[i];
        rep(j, k[i])
        {
            int k_ij;
            cin >> k_ij;
            s[i].push_back(k_ij - 1);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    int sum = 0;
    for (int i = 0; i < (1 << n); ++i)
    {
        bool ok = true;

        rep(j, m)
        {
            int c = 0;
            for (int id : s[j])
            {
                if ((i >> id) & 1)
                    ++c;
            }
            c %= 2;
            if (c != p[j])
                ok = false;
        }

        if (ok)
            ++sum;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>


using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair

lint mod = 1e9+7;
lint mypow(lint a, lint n){
    lint res = 1;
    lint base = a;
    while(n > 0){
        if (n%2) res = res*base%mod;
        base = base*base%mod;
        n = n/2;
    }
    return res;
}

lint rev(lint a){
    return mypow(a, mod-2);
}

lint comb(lint n, lint m, vl &la, vl &rela){
    return (la[n] * rela[m] % mod) * rela[n-m] % mod;
}

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

    lint n, m; cin>>n>>m;

    vl la(m+1, 1);
    for (int i=1; i<=m; ++i) la[i] = la[i-1]*i%mod;

    vl rela(m+1);
    rela[m] = rev(la[m]);
    for (int i=m; i>=1; --i) rela[i-1] = rela[i] * i % mod;


    lint cnt = 0;
    for (int k = 0; k<= n; ++k){
        lint p = (comb(n, k, la, rela)* comb(m-k, n-k, la, rela) % mod) * la[n-k];
        p = p%mod;
        if (k % 2) p = mod - p;
        cnt = (cnt + p)%mod;
    }

    cout<< (cnt * comb(m, n, la, rela) % mod) * la[n] % mod;
}


Measured memory_bytes: 11068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin >> n >> k;
  string s;cin >> s;
  vector<int> v;
  v.push_back(0);
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
      v.push_back(i+1);
    }
  }
  v.push_back(n);
  int ans=0;
  int u=v.size();
  for(int i=0;i<v.size();i++){
    if(s[v[i]]=='1'){
      ans=max(ans,v[min(i+2*k+1,u-1)]-v[i]);
    }
    else{
      ans=max(ans,v[min(i+2*k,u-1)]-v[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1020
n = int(input())
A = [int(i) for i in input().split()]

p = 10 ** 9 + 7

def fact(n, p=10**9 + 7):
    f = 1
    for i in range(1, n+1):
        f *= i
        f %= p
    return f

def get_inv(n, p=10**9 + 7):
    inv = [0, 1]
    for i in range(2, n+1):
        inv.append(-(p//i * inv[p%i]) % p)
    return inv

f = fact(n)
inv = get_inv(n)

csum = [0]

for i in range(1, n+1):
    csum.append((csum[-1] + inv[i]) % p)

ans = 0
for i, a in enumerate(A):
    ans += (csum[i+1] + csum[n-i] - csum[1] + p) % p * a
    ans %= p

print(ans * f % p)

Measured memory_bytes: 15248
while True:
    n,m=map(int,input().split())
    if (n,m)==(0,0):
        break
    t=m//n
    a=list(map(int,input().split()))
    cnt=0
    for i in a:
        if t<=i:
            cnt+=t
        else:
            cnt+=i
    print(cnt)


Measured memory_bytes: 5608
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int r=Integer.parseInt(scan.next());
    int c=Integer.parseInt(scan.next());
    int[][] array1=new int[r][c];
    for(int i=0;i<array1.length;i++){
      for(int j=0;j<array1[i].length;j++){
        array1[i][j]=Integer.parseInt(scan.next());
      }
    }

    int[][] array2=new int[r+1][c+1];
    for(int i=0;i<array2.length-1;i++){
      for(int j=0;j<array2[i].length-1;j++){
        array2[i][j]=array1[i][j];
      }
    }
    for(int i=0;i<array2.length-1;i++){
      for(int j=0;j<array2[i].length-1;j++){
        array2[i][c]+=array2[i][j];
      }
    }
    for(int i=0;i<c+1;i++){
      for(int j=0;j<r;j++){
        array2[r][i]+=array2[j][i];
      }
    }

    for(int i=0;i<r+1;i++){
      for(int j=0;j<c+1;j++){
        if(j<c){
          System.out.print(array2[i][j]+" ");
        }else{
          System.out.println(array2[i][j]);
        }
      }
    }
  }
}


Measured memory_bytes: 39156
#include <bits/stdc++.h>
typedef long long ll; 

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N + 1, 0);
	vector<int> b(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> b[i];
	}

	for (int i = 1; i <= N; i++) {
		a[i] += a[i - 1];
		b[i] += b[i - 1];
	}

	int res = 0;
	for (int i = 1; i <= N; i++) {
		int tmp = a[i] + (b[N] - b[i - 1]);
		res = max(res, tmp);
	}

	cout << res << endl;
	return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 1000005;
int mul(int a, int b){
	return 1ll*a*b%mod;
}
int add(int a, int b){
	a += b;
	if(a >= mod)
		a -= mod;
	return a;
}
int sub(int a, int b){
	a -= b;
	if(a < 0)
		a += mod;
	return a;
}
int pwr(int a, int b){
	int r = 1;
	for(;b;b>>=1, a = mul(a,a))
		if(b & 1)
			r = mul(r, a);
	return r;
}
int main(){
	fastio;
	int n;
	cin >> n;
	cout << sub(add(pwr(10,n), pwr(8,n)), add(pwr(9,n), pwr(9,n))) << '\n';
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
ll n,m,k;
vector<ll> arrange(vector<ll> prev, vector<ll> com){
	vector<ll> res(n+1);
	for(ll i=1;i<=n;i++){
		res[i] = prev[ com[i] ];
	}
	return res;
}
int main(){
	cin>>n;
	vector<ll> x(n+1),d(n+1),bas[63],st(n+1);
	bas[0].pb(0);
	for(ll i=1;i<=n;i++){
		cin>>x[i];
		bas[0].pb(i);
		st[i]=i;
	}
	cin>>m>>k;
	vector<ll> a(m+1);
	for(ll i=1;i<=m;i++){
		cin>>a[i];
	}
	d[0]=0;
	for(ll i=1;i<=n-1;i++){
		d[i]=x[i+1]-x[i];
	}
	for(ll i=1;i<=m;i++){
		swap(bas[0][a[i]-1],bas[0][a[i]]);
	}
	for(ll i=1;i<=60;i++){
		bas[i] = arrange(bas[i-1],bas[i-1]);
	}
	for(ll i=0;i<=60;i++){
		if(k%2==1){
			st = arrange(st,bas[i]);
		}
		k = k/2;
	}
	d = arrange(d, st);
	ll pos = x[1];
	for(ll i=0;i<n;i++){
		pos+=d[i];
		cout<<pos<<endl;
	}
	return 0;
}

Measured memory_bytes: 53676
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int a[200010];
ll dp[200010];
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=1;
	ll sum=a[0];
	int l=0;
	for(int i=1;i<n;i++){
		while((sum^a[i])!=sum+a[i]&&l<=i){
			sum-=a[l];
			l++;
		}
		sum+=a[i];
		ans+=i-l+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    string n;
    cin >> n;
    int ans = 0;
    for (int i=0;i<n.length();i++){
        if(n[i] == '2'){
            ans++;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int unsigned long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ; 
    cin >> n ; 
    int x = n ; 
    n = 100 ;
    for(int day = 1; ; day++){
        n += n * 1 / 100 ; 
        if ( n >= x ) {
            cout << day << endl;
            return 0 ;
        }
    }
    return 0; 
}

Measured memory_bytes: 3652