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

class Test
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int count = 0;
        for (int i = 0; i < n; i++)
        {
            int num = int.Parse(Console.ReadLine());
            bool flag;
            if (num <= 1) flag = false;
            else flag = true;
            
            for (int j = 2; j < (int)Math.Sqrt(num) + 1 ; j++)
            {
                if (num % j == 0) { flag = false; break; }
            }
            if (flag == true) count++;
        }
        Console.WriteLine(count);
    }
}


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

void solve() {
  string s; int w; cin >> s >> w;
  for(int i=0; i<s.size(); i+=w) {
    cout << s[i];
  }
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

#define lp(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define ff first
#define ss second

using namespace std;

void strRot(){
    string s, t;
    cin >> s >> t;
    int x = s.size();
    bool found = false;
    for (int i = 0; i < x; i++){
        s = s.at(x - 1) + s.substr(0, x - 1);
        if (s.compare(t) == 0){
            found = true;
            break;
        }
    }
    if (found)
        cout << "Yes";
    else
        cout << "No";
}

int main() {
    strRot();
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    A, B = input().split()
    a = int(A)
    b = int(B[0] + B[2] + B[3])
    print(a * b // 100)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10344
#include <bits/stdc++.h>
using namespace std;
int q;
string x, y;
int m, n;
int a[1000][1000];
int main()
{
	cin >> q;
	for(int i=0; i<q; i++)
	{
		cin >> x >> y;
		m=x.size();
		n=y.size();
		if(x[0]==y[0])
		{
			a[0][0]=1;
		}
		else
		{
			a[0][0]=0;
		}
		for(int j=1; j<m+n-1; j++)
		{
			if((j<n)&&((x[0]!=y[j])&&(a[0][j-1]==0)))
			{
				a[0][j]=0;
			}
			else if(j<n)
			{
				a[0][j]=1;
			}
			if((j<m)&&((x[j]!=y[0])&&(a[j-1][0]==0)))
			{
				a[j][0]=0;
			}
			else if(j<m)
			{
				a[j][0]=1;
			}
			for(int k=max(1, j-n+1); k<min(j, m); k++)
			{
				if(x[k]==y[j-k])
				{
					a[k][j-k]=a[k-1][j-k-1]+1;
				}
				else
				{
					a[k][j-k]=max(a[k-1][j-k], a[k][j-k-1]);
				}
			}
		}
		cout << a[m-1][n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5108
using System;
using System.Collections.Generic;

class Program {

    static int Main(string[] args) {
        List<decimal[]> list = new List<decimal[]>();

        int n = InputN();

        for (int i = 0; i < n; i++) {
            decimal[] v = InputDecimal();
            list.Add(v);
        }

        for (int i = 0; i < list.Count; i++) {
            Console.WriteLine(Check(list[i]));
        }

        return 0;
    }

    static int InputN() {
        string v = Console.ReadLine();
        return int.Parse(v);
    }

    static decimal[] InputDecimal() {
        string v = Console.ReadLine();
        string[] vs = v.Split(' ');

        decimal[] vd = new decimal[vs.Length];
        for (int i = 0; i < vs.Length; i++) {
            vd[i] = decimal.Parse(vs[i]);
        }

        return vd;
    }

    static string Check(decimal[] v) {
        decimal xt1 = v[0] - v[2];
        decimal yt1 = v[1] - v[3];
        decimal xt2 = v[4] - v[6];
        decimal yt2 = v[5] - v[7];

        if ((xt1 == 0) && (xt2 == 0)) { return "YES"; }
        if ((xt1 == 0) || (xt2 == 0)) { return "NO"; }

        if ((yt1 / xt1) == (yt2 / xt2)) { return "YES"; }

        return "NO";
    }
}

Measured memory_bytes: 9452
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    int i;
    set<string> z;
    char save;
    for(i=0; i<n; i++) {
        char str[105]={0};
        scanf("%s", str);
        if(!z.insert(string(str)).second) {
            break;
        }
        if(i>0) {
            if(str[0]!=save) {
                break;
            }
        }
        save=str[strlen(str)-1];
    }
    if(i<n) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    cout << fixed << setprecision(10) << double(N * N * N / 27.0) << endl;
}

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

struct dat{
  int cost, ay, ax, by, bx, cy, cx; 
};

int w, h, n;
int d[N][N][N][N][N][N];
string s[16];
int ay, ax, by, bx, cy, cx;
int dy[5]={-1,0,1,0,0};
int dx[5]={0,1,0,-1,0};

queue<dat> q;

bool check(int nay, int nax){
  if(nay<0||nax<0||h<=nay||w<=nax) return false;
  if(s[nay][nax]=='#') return false;
  return true;
}

bool check2(int Ay,int Ax,int By,int Bx,int ai,int bi){
  
  if(Ay==By){
    if(Ax+1==Bx&&ai==1&&bi==3) return false;
    if(Bx+1==Ax&&bi==1&&ai==3) return false;
  }
  
  if(Ax==Bx){
    if(Ay+1==By&&ai==2&&bi==0) return false;
    if(By+1==Ay&&bi==2&&ai==0) return false;
  }
  
  return true;
}

int bnf(){
  
  rep(i,N) rep(j,N)
    rep(k,N) rep(l,N)
    rep(m,N) rep(o,N)
    d[i][j][k][l][m][o]=INF;
  
  d[ay][ax][by][bx][cy][cx]=0;
  q.push(dat{0,ay,ax,by,bx,cy,cx});
  
  int res;
  
  while(!q.empty()){
    
    dat t=q.front(); q.pop();
    
    if(n==1&&s[t.ay][t.ax]=='A'+s[ay][ax]-'a'){
      res=t.cost;
      break;
    }
    
    if(n==2&&s[t.ay][t.ax]=='A'+s[ay][ax]-'a'&&
       s[t.by][t.bx]=='A'+s[by][bx]-'a'){
      res=t.cost;
      break;
    }
    
    if(n==3&&s[t.ay][t.ax]=='A'+s[ay][ax]-'a'&&
       s[t.by][t.bx]=='A'+s[by][bx]-'a'&&
       s[t.cy][t.cx]=='A'+s[cy][cx]-'a'){
      res=t.cost;
      break;
    }
    
    rep(i,5){
      int nay=dy[i]+t.ay, nax=dx[i]+t.ax;
      if(!check(nay,nax)) continue;
      
      rep(j,5){
	int nby=dy[j]+t.by, nbx=dx[j]+t.bx;
	if(n==1) nby=0, nbx=0;
	if(n>=2&&!check(nby,nbx)) continue;
	
	rep(k,5){
	  
	  int ncy=dy[k]+t.cy, ncx=dx[k]+t.cx;
	  if(n<=2) ncy=0, ncx=0;
      	  if(n==3&&!check(ncy,ncx)) continue;
      
	  if(n>=2&&!check2(t.ay,t.ax,t.by,t.bx,i,j)) continue;
	  if(n==3&&!check2(t.ay,t.ax,t.cy,t.cx,i,k)) continue;
	  if(n==3&&!check2(t.by,t.bx,t.cy,t.cx,j,k)) continue;
	  
	  if(n>=2&&nay==nby&&nax==nbx) continue;
	  if(n==3&&nay==ncy&&nax==ncx) continue;
	  if(n==3&&nby==ncy&&nbx==ncx) continue;

	  if(d[nay][nax][nby][nbx][ncy][ncx]>d[t.ay][t.ax][t.by][t.bx][t.cy][t.cx]+1){
	    d[nay][nax][nby][nbx][ncy][ncx]=d[t.ay][t.ax][t.by][t.bx][t.cy][t.cx]+1;
	    q.push(dat{d[nay][nax][nby][nbx][ncy][ncx],nay,nax,nby,nbx,ncy,ncx});
	  }
      
	}
      }
    }
  }
  
  return res;  
}

int main(){
  
  while(1){
    
    cin>>w>>h>>n;
    if(!w&&!h&&!n) break;
    
    unordered_set<char> memo;

    ay=ax=by=bx=cy=cx=0;
    
    getline(cin,s[0]);
    rep(i,h) getline(cin,s[i]);
    
    for(int i=0;i<h-2;i++){
      s[i]=s[i+1];
      s[i]=s[i].substr(1,w-2);
      rep(j,w-2){
	char c=s[i][j];
	if('a'<=c&&c<='z'&&!memo.count(c)){
	  if(memo.size()==0) ay=i, ax=j;
	  if(memo.size()==1) by=i, bx=j;
	  if(memo.size()==2) cy=i, cx=j;
	  memo.insert(c);
	}
      }
    }
    
    h-=2;
    w-=2;
    
    cout<<bnf()<<endl;
      
  }
  
  return 0;
}

Measured memory_bytes: 38724
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  string s;
  cin>>s;
  int ans = 0;
  REP(i,4){
    if(s[i]=='+'){
      ans++;
    }else{
      ans--;
    }
  }
cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
typedef long long LL;
int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	if (a + b == c + d) { std::cout << "Balanced" << std::endl; }
	else if (a + b < c + d) {
		std::cout << "Right" << std::endl;
	}
	else {
		std::cout << "Left" << std::endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final int num = Integer.parseInt(input.readLine());

      System.out.println(solver(num));
    }

  }

  private static String solver(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    StringBuffer ret = new StringBuffer();

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        ret.append((int) Math.pow(2, count));
        ret.append(" ");
      }
      count++;
    }
    return ret.toString().trim();
  }

}

Measured memory_bytes: 24272
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif   

	int n, k; cin >> n >> k; 
	vl h(n); repa(i, n) cin >> h[i];
	vl dp(n); 

	dp[0] = 0, dp[1] = abs(h[1] - h[0]);
	rep(i, 2, n) {
		dp[i] = INF(int);
		rep(j, 1, k + 1) 
			if (j <= i) 
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
	}    

	cout << dp[n - 1] << endl;
    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 4828
li = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
      'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
n = int(input())
s = input()
re = ''
for c in s:
    re += li[(li.index(c) + n) % 26]
print(re)


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

int main() {

  int N;
  cin >> N;
  
  for (int i = 0;i < 1000;i++) {
    if (N % 111 == 0) {
      cout << N <<endl;
      break;
    }
    N++;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main () {

	int a,b;

	cin >> a >> b;

	if (a + b == 15) {
		cout << "+" << endl;
		return 0;
	}

	if (a * b == 15) {
		cout << "*" << endl;
		return 0;
	}

	cout << "x" << endl;


    return 0;
}

Measured memory_bytes: 764
using System;
 
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        
        int x=0;
        
        if (a < b) { x = a; a = b; b = x; }
        while (b != 0)
        {
           x = b;
           b = a % x;
           a = x;
        }
        
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 9180
int main()
{
  int no1,no2,no3;
  scanf("%d",&no1);
  scanf("%d",&no2);
  scanf("%d",&no3);
  if ((no1<no2) &&(no2<no3)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int X;
    cin >> X;
    ve<bool> E(200001,true);
    E[0] = false,E[1] = false;
    for (int i = 2; i <= 200000; i++) {
        if(E[i]){
            for (int j = i*2; j <= 200000; j+=i) {
                E[j] = false;
            }

        }
    }

    int ans = 0;
    reps(i,X,200001){
        if(E[i]){
            out(i);
            return 0;
        }
    }
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;

ll a,b,c,d;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
ll cnt(ll x){
    ll num=x;
    ll cnum = x/c;
    ll dnum = x/d;
    ll cdnum = x/lcm(c,d);
    //cout<<cnum<<dnum<<cdnum<<endl;
    return num = x-cnum-dnum+cdnum;
}

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

ll ans = cnt(b)-cnt(a-1);
cout<< ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  vector<int> sum(k, 0);
  for(int i=0;i<n;i++)  cin >> v[i];

  int left = 0, right = 1000000000;
  while(left+1 < right){
    int mid = (left + right) / 2;
    int num = 0;
    for(int i=0;i<k;i++){
      int size = mid;
      while(1){
        if(num == n)break;
        if(size - v[num] < 0)break;
        size -= v[num++];
      }
      if(num == n)break;
    }
    if(num == n)
      right = mid;
    else 
      left = mid;
  } 
  cout << left + 1 << endl;
  return 0;
}

Measured memory_bytes: 1796
def pd(n):
    i = 2
    ans = []
    while i ** 2 <= n:
        while n % i == 0:
            n /= i
            ans.append(i)
        i += 1
    if n > 1:
        ans.append(n)
    return ans

def gcd(a, b):
    gcd = 1
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
            gcd *= i
    return int(gcd)

def lcm(a, b):
    lcm = a
    pd_a = pd(a)
    pd_b = pd(b)
    for i in pd_a:
        if i in pd_b:
            pd_b.remove(i)
    for j in pd_b:
        lcm *= j
    return int(lcm)

while True:
    try:
        s = input()
        a,b = [int(i) for i in s.split(' ')]
    except:
        break
    print(gcd(a, b), lcm(a, b))


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

using namespace std; 

int main(){ 
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(c<a){
    if(b<d){
     cout<<b-a;
    }
    else if(d<a) cout<<0;
    else cout<<d-a;
  }
  else if(b<c){
    cout<<0;
  }
  else{
    if(b<d) cout<<b-c;
    else cout<<d-c;
  }
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


const int MAX = 42;




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

  if(K % 2 == 0 || K % 5 == 0){
    cout << -1 << endl;
    return 0;
  }

  vector<ll> res(K, 0);
  ll cnt = 1;
  ll a = 7;
  while(true){
    if(a == 0){
      break;
    }else{
      while(a < K){
        a *= 10;
        a += 7;
        cnt++;
      }
      a %= K;
    }
  }

  cout << cnt << endl;

  // cout << setprecision(8) << ans << endl;  // For double
}



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

using namespace std;
typedef long long int lli;
lli n;
vector <double> p(3000);
double dp[3000][3000];
double solve(lli i,lli h);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin>>n;
	for (int i=0;i<n;i++) cin>>p[i];
	for (int i=0;i<n+1;i++){
		for (int j=0;j<n+1;j++){
			dp[i][j]=-10;
		}
	}
	solve(0,0);
	cout<<fixed<<setprecision(10)<<dp[0][0]<<endl;
	
}

double solve(lli i,lli h){
	if (i==n+1){
		if (h>(n-h)) return 1;
		else return 0;
	}
	if (dp[i][h]!=-10) return dp[i][h];
	dp[i][h]=solve(i+1,h+1)*p[i]+solve(i+1,h)*(1-p[i]);
	return dp[i][h];
}

Measured memory_bytes: 70784
//--------------------------------------------------
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
int n, total = 0;
vector<pair<int, int>> l, r;
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    forn(i, n){
        int mn = INT32_MAX, sum = 0;
        string str;
        cin >> str;
        forn(i, str.size())
            if(str[i] == '(') sum++, mn = min(mn, sum);
            else sum--, mn = min(mn, sum);
        total += sum;
        if(sum >= 0) l.pb({mn, sum});
        else r.pb({mn-sum, -sum});
    }
}

bool check(const vector<pair<int, int>> &v){
    int sum = 0;
    for(const auto &[mn, s]: v){
        if(sum + mn < 0) return false;
        sum += s;
    }
    return true;
}

int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    sort(all(l), greater<pair<int, int>>());
    sort(all(r), greater<pair<int, int>>());
    bool ex = (total == 0) && check(l) && check(r);
    cout << (ex ? "Yes" : "No") << endl;
}

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

int main(void)
{
    long long N, u, v, ans;

    cin >> N;

    //https://noimin.hatenablog.com/entry/2020/07/07/235034
    //ans = N*(N+1)*(N+2)/6;
    ans = (N*(N+1)*(2*N+1)/6 + N*(N+1)/2) / 2;
    
    //N-1本の辺を取得
    for(int i = 0; i < N - 1; ++i)
    {
        cin >> u >> v;
        if(u < v) ans -= u*(N-v+1);
        else ans -= v*(N-u+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c=0,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN(s);
  REP(i,s.size()) if(s[i]=='1') c++;
  OUT(c);
}

Measured memory_bytes: 256
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
long long h[205000];
int main()
{
    long long n,k,sum=0;
    cin >> n >>k;
    for(int i=1;i<=n;i++)
    {
        cin >> h[i];
    }
    sort(h+1,h+1+n);
    if(k>=n)
    {
        printf("0\n");
    }
    else
    {
        for(int i=1;i<=n-k;i++)
        {
            sum+=h[i];
        }
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
ll m[51];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//#ifndef ONLINE_JUDGE
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
 //#endif
int t=1;
	//cin>>t;
	while(t--)
	{
	    for(ll i=1;i<=50;i++)
            m[i]=(i*(i+1))/2;
	ll n;
	cin>>n;
	vector<ll >vec;
	for(ll i=2;i*i<=n;i++){
        if(n%i==0){
                ll c=0;
            while(n%i==0){
                n/=i;
                c++;
            }
            vec.pb(c);
        }
	}
	if(n>1)
        vec.pb(1);
        ll ans1=0;
    for(ll i=0;i<vec.size();i++){
        ll re=vec[i];
        ll ans=0;
        for(ll j=0;j<=50;j++){
            if(re>=m[j])
                ans=j;
            else break;
        }
        ans1+=ans;
    }
    cout<<ans1;
	}
return 0;
}


Measured memory_bytes: 3640
# AOJ 0545: Party
# Python3 2018.7.1 bal4u

import sys
from sys import stdin
input = stdin.readline

while True:
	n, m = int(input()), int(input())
	if n == 0: break
	n += 1
	f, tbl = [0]*n, []
	for i in range(m):
		a, b = map(int, input().split())
		if a == 1 or b == 1: f[a] = f[b] = 1
		else: tbl.append((a, b))
	for a, b in tbl:
		if f[a] == 1 and f[b] == 1: continue
		if f[a] == 1: f[b] = 2
		elif f[b] == 1: f[a] = 2
	ans = 0
	for i in range(2, n):
		if f[i]: ans += 1
	print(ans)


Measured memory_bytes: 6504
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

float a,b,c,d,e,f,x,y;

int main(){
    while(cin>>a>>b>>c>>d>>e>>f){
        if(a==0){
            y=b/c;
            x=(f-e*y)/d;
        }
        else{
            y=(c*d/a-f)/(b*d/a-e);
            x=(c-b*y)/a;
        }
        printf("%.3f %.3f\n",x,y);
    }
}




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

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		long[] A = new long[N + 1];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt();
		A[N] = 0;
		Arrays.sort(A);
		int idx = Arrays.binarySearch(A, 0);
		// A[idx]から正の値をとる
		long ans = Long.MAX_VALUE;
		for(int i = 0; i + idx <= N; i++) {
			if(idx - K + i < 0) continue;
			// 正の方向にiだけろうそくに火をつけることを考える
			ans = Math.min(ans, A[i + idx] * (long)2 + Math.abs(A[idx - K + i]));
			ans = Math.min(ans, A[i + idx] + Math.abs(A[idx - K + i]) * (long)2);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 51704
S = str(input())
Q = int(input())

hanten = 0
front = ""
end = ""

for i in range(Q):
  query = list(map(str, input().split()))
  if query[0] == "1":
    hanten += 1
    hanten = hanten % 2
  else:
    if query[1] == "1":
      if hanten == 0:
        front = query[2] + front
      else:
        end = end + query[2]
    else:
      if hanten == 0:
        end = end + query[2]
      else:
        front = query[2] + front

ans = front + S + end
if hanten == 1:
  ans = ans[::-1]
print(ans)

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
#define dbg(x)                cerr <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	ll n, knapsack;
	scanf("%lld%lld",&n,&knapsack);
	// dp dimension will be dp[item][knapsack]
	// but we will do raw sawpping for saving memory...
	vector<vector<ll> > dp(2,vector<ll>(knapsack+1,0));
	bool next=1, prev=0;
	ll w, v;
	for(int i=0; i< n; ++i){
		scanf("%lld%lld",&w,&v);
		for(int j=0; j<= knapsack ; ++j){
			if(j<w){
				dp[next][j]=dp[prev][j];
			}else{
				dp[next][j]=max(dp[prev][j],v + dp[prev][j-w]);
			}
		}
		swap(prev,next);
	}
	printf("%lld\n",dp[prev][knapsack]);
	
    return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n;
    cin >> n;
    if(n > 999) cout << "ABD\n";
    else cout << "ABC\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int r,d,x,i;
	scanf("%d%d%d",&r,&d,&x);
	for (i=1;i<=10;i++)
	{
		x=r*x-d;
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, k; cin >> n >> k;
  if (k & 1) cout << (n / k) * (n / k) * (n / k) << '\n';
  else {
    lint m = (n + k / 2) / k;
    cout << (n / k) * (n / k) * (n / k) + m * m * m << '\n';
  }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL a, b, c, d;
    for(int i = 1; i <= 7; ++i) {
        int tmp;
        if(i == 1) cin >> a;
        else if(i == 2) cin >> b;
        else if(i == 4) cin >> c;
        else if(i == 5) cin >> d;
        else cin >> tmp;
    }

    LL res = b;
    LL t = min({a, c, d});
    res += t * 3;
    a -= t;
    c -= t;
    d -= t;
    int tmp = a % 2 + c % 2 + d % 2;
    if(tmp >= 2 && t > 0) {
        a++;
        c++;
        d++;
        res -= 3;
    }
    cout << res + (a / 2 * 2) + (c / 2 * 2) + (d / 2 * 2) << endl;

    return 0;
}


Measured memory_bytes: 3664
from sys import stdin
import numpy as np


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    x_arr = np.arange(1,K+1)
    cnt = np.gcd.outer(np.gcd.outer(x_arr,x_arr),x_arr).sum()
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 89560
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

int N,K;

void func(){

	int baseTable[N],baseValue = 0,work[N];
	for(int i = 0; i < N; i++){
		scanf("%d",&baseTable[i]);
	}

	int tmp = 1,pre;
	for(int p = 0; p < K; p++){
		tmp *= baseTable[p];
	}
	baseValue = tmp;
	pre = tmp;

	for(int i = 1; i <= N-K; i++){
		tmp = (pre/baseTable[i-1])*baseTable[i+K-1];
		baseValue = max(baseValue,tmp);
		pre = tmp;
	}

	int nextValue = 0,tmpValue;
	//???????????§??§??????????????§????????????????????£???????????§?????????????????¨?????????????????¨??¢?´¢
	for(int a = 0; a < N-1; a++){
		for(int b = a+1; b < N; b++){
			for(int p = 0; p < N; p++)work[p] = baseTable[p];
			swap(work[a],work[b]);

			tmp = 1;
			for(int p = 0; p < K; p++){
				tmp *= work[p];
			}
			tmpValue = tmp;
			pre = tmp;

			for(int i = 1; i <= N-K; i++){
				tmp = (pre/work[i-1])*work[i+K-1];
				tmpValue = max(tmpValue,tmp);
				pre = tmp;
			}

			nextValue = max(nextValue,tmpValue);
		}
	}

	if(nextValue < baseValue){
		printf("NO GAME\n");
	}else{
		printf("%d\n",nextValue - baseValue);
	}
}


int main(){

	while(true){
		scanf("%d %d",&N,&K);
		if(N == 0 && K == 0)break;

		func();
	}

    return 0;
}

Measured memory_bytes: 3140
X = int(input())

max_a = X // 100 + 1
max_n = max_a


def sum_X(n_list):
    x = sum([n * (100 + i) for i, n in enumerate(n_list)])
    return x


for a in range(max_a):
    if a > max_n:
        break
    for b in range(max_a):
        n = sum([a, b])
        if n > max_n:
            break
        for c in range(max_a):
            n = sum([a, b, c])
            if n > max_n:
                break
            for d in range(max_a):
                n = sum([a, b, c, d])
                if n > max_n:
                    break
                for e in range(max_a):
                    n = sum([a, b, c, d, e])
                    if n > max_n:
                        break
                    for f in range(max_a):
                        n = sum([a, b, c, d, e, f])
                        if n > max_n:
                            break
                        if X == sum_X([a, b, c, d, e, f]):
                            print(1)
                            exit()
print(0)

Measured memory_bytes: 3064
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int b[] = new int[m];
		for(int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		int a[][] = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			int val = 0;
			for(int j = 0; j < m; j++) {
				val += a[i][j]*b[j];	
			}
			if (val+c>0) ans++;
			else continue;
		}
		System.out.println(ans);
	 }
}

Measured memory_bytes: 22356
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 410,mod = 998244353;
int n,sa,sb;
int a[N],b[N];
int f[N][N][N],fac[N],inv[N];
int ksm(int x,int y)
{
	int res = 1; 
	for(;y;y >>= 1,x = 1ll * x * x % mod) 
		if(y & 1) res = 1ll * res * x % mod; 
	return res;
}
void add(int &x,int y){x = x + y; if(x >= mod) x -= mod;}
int main()
{
	n = read();
	for(int i = 1;i <= n;i ++) a[i] = read(),b[i] = read(),sa += a[i],sb += b[i];
	fac[0] = 1; for(int i = 1;i <= 400;i ++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[400] = ksm(fac[400],mod - 2);
	for(int i = 399;i >= 0;i --) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
	f[0][0][0] = mod - 1;
	for(int i = 1;i <= n;i ++)
		for(int j = 0;j <= sa;j ++)
			for(int k = 0;k <= sb;k ++)
			{
				if(!f[i - 1][j][k]) continue;
				add(f[i][j][k],f[i - 1][j][k]);
				int x = 1;
				for(int l = 0;l < b[i];l ++,x = 1ll * x * a[i] % mod) 
					add(f[i][j + a[i]][k + l],mod - 1ll * x * inv[l] % mod * f[i - 1][j][k] % mod);
			}
	int ans = 0;
	for(int i = 1,x,invi;i <= sa;i ++)
	{
		invi = ksm(i,mod - 2);
		x = 1ll * sa * invi % mod;
		for(int j = 0;j <= sb;j ++,x = 1ll * x * invi % mod) 
			add(ans,1ll * x * fac[j] % mod * f[n][i][j] % mod);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 262400
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    bool ans = true;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] != 'h') {
            ans = false;
            break;
        }
        i++;
        if (i >= s.size()) {
            ans = false;
            break;
        }
        if (s[i] != 'i') {
            ans = false;
            break;
        }
    }

    ATYN(ans)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
    }

    vi ans(N + 1);
    rep(i, 0, N) {
        queue<int> q;
        q.push(i);
        vector<bool> vis(N, false);
        vi from(N, -1);
        vis[i] = true;
        vi tmp;
        while (sz(q)) {
            int v = q.front(); q.pop();
            for (int w : G[v]) {
                if (w == i) {
                    int cur = v;
                    while (cur != -1) {
                        tmp.pb(cur);
                        cur = from[cur];
                    }
                    goto next;
                }
                if (vis[w]) continue;
                vis[w] = true;
                from[w] = v;
                q.push(w);
            }
        }
        goto skip;
        next:
        if (sz(ans) > sz(tmp)) {
            ans = tmp;
        }
        skip:;
    }
    if (sz(ans) == N + 1) {
        cout << -1 << endl;
    } else {
        cout << sz(ans) << endl;
        for (int x : ans) cout << x + 1 << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int dec[6]={0};
    int n,i,j;
    double a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf",&a);
        if(a<165){
            dec[0]++;
        }
        for(j=1;j<5;j++){
            if(165+5*(j-1)<=a&&165+5*j>a){
                dec[j]++;
            }
        }
        if(185<=a){
            dec[5]++;
        }
    }
    for(i=0;i<6;i++){
        printf("%d:",i+1);
        for(j=0;j<dec[i];j++){
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	ll n;
    cin >> n;
    ll dp[n+1];
    fill(dp,dp+n+1,100000);
  	dp[0]=0;
    dp[1]=1;
    vector<ll> kouho;
    for(int i=2;i<=n;i++){
        kouho.push_back(1);
        for(int j=1;pow(9,j)<=i;j++){
        	kouho.push_back(pow(9,j));
        }
        for(int j=1;pow(6,j)<=i;j++){
        	kouho.push_back(pow(6,j));
        }
    	for(auto& e:kouho){
        	dp[i] = min(dp[i],dp[i-e]+1);
        }
        kouho.clear();
    }
    cout <<dp[n];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int d, n;
  cin >> d >> n;
  int multiple = pow(100, d);
  int ans = multiple * n;

  if (n == 100)
    ans += multiple;
  cout << ans << endl;
}


Measured memory_bytes: 256
testc=int(input())
ac=0
wa=0
tle=0
re=0
i=0
while(i<testc):
	t=input()
	if(t=="AC"):
		ac+=1
	elif(t=="WA"):
		wa+=1
	elif(t=="TLE"):
		tle+=1
	else:
		re+=1
	i+=1
print("AC x" , ac)
print("WA x" , wa)
print("TLE x" , tle)
print("RE x" , re)

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

vector<pair<ll, int>> factorize (ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; i++) {
        if (n%i) continue;
        res.emplace_back(i,0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n, 1); // 素数の場合
    return res;
}

ll gcd (int x, int y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

	bool flag = true;

	if (s[0] != 'A') {
		flag = false;
	}

	bool f = false;
	ll c = 0;

	FOR(i, 2, s.size() - 1) {
		if (s[i] == 'C') {
			f = true;
			c = i;
		}
	}

	if (!f) {
		flag = false;
	}

	FOR(i, 1, s.size()) {
		if (i != c && (s[i] - 'a' < 0 || s[i] - 'a' > 25)) {
			flag = false;
		}
	}

	if (flag) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}

Measured memory_bytes: 256