akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
ll llgcd(ll x,ll y){
	if (x<y) return llgcd(y,x);
	if (y==0) return x;
	ll r = x % y;
	return llgcd(y,r);
}

int main(){
    int H,W;
    SCD2(H,W);
    static int a[502][502] = {};
    FORq(i,1,H){
        FORq(j,1,W){
            SCD(a[i][j]);
        }
    }

    vector<PII> M;

    FORq(i,1,H){
        FORq(j,1,W-1){
            if (a[i][j] % 2 == 0) continue;
            a[i][j]--; a[i][j+1]++;
            M.PB(MP(i,j));
            M.PB(MP(i,j+1));
        }
    }

    FORq(i,1,H-1){
        if (a[i][W] % 2 == 0) continue;
        a[i][W]--; a[i+1][W]++;
        M.PB(MP(i,W));
        M.PB(MP(i+1,W));
    }

    //output
    int N = M.size() / 2;
    PRINTD(N);

    REP(i,N){
        printf("%d %d %d %d\n",M[2*i].fst,M[2*i].snd,M[2*i+1].fst,M[2*i+1].snd);
    }
    printf("\n");

}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
using graph=vector<vector<int>>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n; cin>>n;
    vector<int> tri;

    rep(i,n){
        int a;
        cin>>a;
        tri.push_back(a);
    }

    sort(tri.begin(),tri.end());

    int ansnum=tri.size();
    int ans=0;
    if(ansnum==1||ansnum==2) ans=0;
    else
    {
        rep(i,ansnum-2){
            for(int j=i+1;j<ansnum-1; j++){
            for (int k=j+1; k<ansnum; k++){ 
                if(tri[i]==tri[j]||tri[k]==tri[j]) continue;
                if(tri[i]+tri[j]>tri[k]) ans++;               
            }
            }
        }
    }
    cout<<ans<<endl;
    
}

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

int main(int argc, char **argv)
{
    int N, K;
    std::cin >> N >> K;

    std::vector<int> kinds(N); // max N kinds

    int num_kinds = 0;

    for(int i = 0; i < N; i++){
        int a;
        std::cin >> a;
        if(kinds.at(a-1) == 0) num_kinds++; // new kind
        kinds.at(a-1)++;
    }
    /*
    for(int i = 0; i < N; i++){
        std::cout << " " << kinds.at(i);
    }
    std::cout << std::endl;
    std::cout << "kinds=" << num_kinds << std::endl;
    */
    std::sort(kinds.begin(), kinds.end());
    int rest = num_kinds - K;
    int i = 0;
    int ans = 0;
    while(rest > 0){
        if(kinds.at(i) > 0){
            ans += kinds.at(i);
            rest--;
        }
        i++;
    }

    std::cout << ans << std::endl;    
}


Measured memory_bytes: 1024
/*************************
author : coldbeer
2019-06-08 1:20:57 PM
*************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

typedef long long ll;
const ll inf = 1e18;
ll n, W;
vector<pair<ll, ll>> arr;
vector<vector<ll>> cache;

ll solve(int i, int j)
{
    if (j < 0)
        return -inf;
    if(j == 0)
        return 0;
    if(i > n - 1)
        return 0;
    if(cache[i][j] != -1)
        return cache[i][j];
    ll ans = 0;
    ll val = arr[i].second;
    ll w = arr[i].first;
    ans = max({ans, val + solve(i + 1, j - w), solve(i + 1, j)});
    cache[i][j] = ans;
    return cache[i][j];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> W;
    arr.resize(n);
    ll w, v;
    for (int i = 0; i < n; i++)
    {
        cin >> w >> v;
        arr[i] = {w, v};
    }
    cache.assign(n + 1,vector<ll>(W + 1,-1));
    cout << solve(0,W) << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <map>
using namespace std;

template <typename T>
struct UnionFind {
  vector<T> data;
  UnionFind(size_t size) {
    data.resize(size);
    for (size_t i = 0; i < size; i++) {
      data[i] = i;
    }
  }
  T root(T x) {
  	return data[x] == x ? x : (data[x] = root(data[x]));
  }
  bool same(T x, T y) {
    return root(x) == root(y);
  }
  void unite(T x, T y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    data[x] = y;
  }
};

int n, m;
int main(void) {
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  UnionFind<int> un(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    un.unite(x, y);
  }
  int counter = 0;
  for (int i = 0; i < n; i++) {
    if (un.root(p[i]) == un.root(p[p[i]])) {
      counter++;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define N 100010
#define INF 1e15+7
struct SegmentTree {
private:
    int nn; vector<ll> node;
public:
    SegmentTree(int sz) {
        nn = 1; while(nn < sz) nn *= 2;
        node.resize(2*nn-1, INF);
    }
    void update(int x, ll val) {
        x += (nn - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = nn;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
    ll rmq(int a,int b){
        return getmin(a,b,0,0,-1);
    }
};
main(){
    ll n=lin(),e=lin(),t=lin();
    ll x[N]={};
    rep2(i,1,n)x[i]=lin();
    ll dp[N]={};
    SegmentTree seg1(n+2),seg2(n+2);
    seg1.update(0,-x[1]*2);
    seg2.update(0,0);
    rep2(i,1,n){
        int l=-1,r=i-1;
        while(l<r-1){
            int mid=(l+r)/2;
            if(t-x[i]*2+x[mid+1]*2>0){
                r=mid;
            }
            else l=mid;
        }
        ll m1=seg1.rmq(0,r);
        ll m2=seg2.rmq(r,i)+t-x[i]*2;
        dp[i]=3*x[i]+min(m1,m2);
        seg1.update(i,dp[i]-(x[i]+2*x[i+1]));
        seg2.update(i,dp[i]-x[i]);
    }
    cout<<dp[n]+(e-x[n]);
}


Measured memory_bytes: 5888
x1, y1, x2, y2 = map(int, input().split())

x3,y3,x4,y4 = 0, 0, 0, 0

x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)
x4 = x1 + (y1 - y2)
y4 = y1 - (x1 - x2)

print(x3,y3,x4,y4)

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

int main(){
  int N, M;
  cin >> N >> M;
  int x = 0;
  
  if(1 < N){
   for(int i = 1; i < N; i++){
     x += N - i;
   }
 }
  if(1 < M){
   for(int i = 1; i < M; i++){
     x += M - i;
    }
   }
  
  cout << x << endl;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

turn = 0
while True:
    if turn % 2 == 0:
        c -= b
    else:
        a -= d
    if a <= 0 or c <= 0:
        break
    else:
        turn += 1

print("Yes" if turn % 2 == 0 else "No")

Measured memory_bytes: 61784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll 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<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
ll t,n,a,b,c,d;
map<ll,ll> Map;
ll solve(ll n){
	if(n==0) return 0;
	if(n==1) return d;
	if(Map.count(n)) return Map[n];
	ll l2=n/2*2,r2=(n+1)/2*2;
	ll l3=n/3*3,r3=(n+2)/3*3;
	ll l5=n/5*5,r5=(n+4)/5*5;
	ll res=1e18;
	if(n<res/d) res=n*d;
	res=min(res,abs(l2-n)*d+a+solve(l2/2));
	res=min(res,abs(r2-n)*d+a+solve(r2/2));
	
	res=min(res,abs(l3-n)*d+b+solve(l3/3));
	res=min(res,abs(r3-n)*d+b+solve(r3/3));
	
	res=min(res,abs(l5-n)*d+c+solve(l5/5));
	res=min(res,abs(r5-n)*d+c+solve(r5/5));
	Map[n]=res;
	return res;
}
int main(){
	t=read();
	while(t--){
		n=read(),a=read(),b=read(),c=read(),d=read();
		Map.clear();
		printf("%lld\n",solve(n));
	}
	return 0;
}

Measured memory_bytes: 4512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.math.*;

public class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }

    private void solve() {
        try {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a * b);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println();
    }

}


Measured memory_bytes: 32488
#include <stdio.h>

int digit_sum(int x) {
    int sum=0;
    while(x>0) {
        sum += x%10;
        x /= 10;
    }
    return sum;
}

int main(void) {
    int n, i, j, min=45;
    scanf("%d", &n);
    
    for(i=n-1; i>0; i--) {
        j = n-i;
        if(digit_sum(i)+digit_sum(j)<min)
            min = digit_sum(i)+digit_sum(j);
    }
    printf("%d\n", min);
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    REP (i, N - 2) if (S.substr (i, 3) == "ABC") ans += 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
    // Here your code !
    string a,b,c;
    cin >>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;

class Main {

    private static Scanner sc = new Scanner(System.in);
    //ソート系
    /*
    *ソート(配列) Arrays.sort(配列名);
    *ソート(リスト)Collections.sort(foo);
    *逆順ソート(配列) Arrays.sort(配列名,  Collections.reverseOrder());
    *逆順ソート(リスト) Collections.reverse(リスト名);
    */

    //変換系
    /*
    *String to int : Integer.parseInt();
    *
    */
    public static double distance(double[] a,double[] b){
        double dis = 0;
        for(int i = 0;i< a.length; i++){
            dis+=Math.pow(a[i] - b[i],2);
        }
        return Math.sqrt(dis);
    }
    public static void main(String[] args) {
        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());

        double x[][] = new double[n][d];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < d; j++){
                x[i][j]=Double.parseDouble(sc.next());
            }        
        }
        int ans = 0;

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i==j)continue;
                double dis = distance(x[i],x[j]);
                if(dis == (int)dis){
                    ans++;
                }
            }
        }
        System.out.println(ans/2);

        
    }
}


Measured memory_bytes: 23636
import java.util.Scanner;


public class Main {
    static   Scanner scan = new Scanner(System.in);
 
    public static void main(String[] args) {
       int x,y;
        while(true){
            x=scan.nextInt(); y=scan.nextInt();
            if(x==0 && y==0){
                break;
            }
           
            for(int i=0; i<x;i++){
                for(int j=0; j<y; j++){
                    if(i==0 || i==x-1){
                        System.out.print("#");
                    }else if (i>0 || i<x-1) {
                        if (j>0&&j<y-1) {
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        }
}


Measured memory_bytes: 34560
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  int a[n][2];
  for(int i =0;i<n;i++){
    for(int j=0;j<2;j++){
      cin >> a[i][j];
    }
  }
  int m;
  cin >>m;
  int b[m][2];
  for(int i =0;i<m;i++){
    for(int j=0;j<2;j++){
      cin >> b[i][j];
    }
  }
  int a1[n];
  int b1[m];
  int ans[n+m];
  int acount=0,bcount=0;
  for(int i=0;i<n;i++){
    a1[i]=a[i][0]*60+a[i][1];
 }
  for(int i=0;i<m;i++){
   b1[i]=b[i][0]*60+b[i][1];
 }
 int kaburi = 0;
 for(int i =0;i+kaburi<n+m;i++){
   if(a1[acount]>b1[bcount]){
     ans[i]=b1[bcount];
     bcount++;
   }else if(a1[acount]<b1[bcount]){
     ans[i]=a1[acount];
     acount++;
   }else{
     ans[i]=a1[acount];
     acount++;
     bcount++;
     kaburi++;
   }
   if(acount==n){
     for(int j=1;j<=m+n-i;j++){
       ans[i+j]=b1[bcount+j-1];
     }
     break;
   }
   if(bcount==m){
     for(int j=1;j<=m+n-i;j++){
       ans[i+j]=a1[acount+j-1];
     }
     break;
   }
 }
 for(int i=0;i<n+m-kaburi-1;i++){
   int h,m;
   h = ans[i]/60;
   m = ans[i]%60;
   if(m>=10){
    cout <<h <<":"<<m<<' ';
  }else{
    cout <<h<<":0"<<m<<' ';
  }
}

cout <<ans[n+m-kaburi-1]/60;
if(ans[n+m-kaburi-1]%60<10){
  cout <<":0"<< ans[n+m-kaburi-1]%60<<endl;
}else{
  cout <<":"<< ans[n+m-kaburi-1]%60<<endl;
}
return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int a[100001],f[100001]={0};
int main()
{
	int i,j,k,n;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=2;i<=n;i++)
	{
		f[i]=INT_MAX;
		for(j=1;j<=min(k,i-1);j++)
			f[i]=min(f[i-j]+abs(a[i]-a[i-j]),f[i]);
	}
	printf("%d",f[n]);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
public static void main(String[]args) {
	Scanner tc = new Scanner (System.in);
	int N, S=0;
	N= tc.nextInt();
	if(N>=3&& N<=100) {
		S= (N-2)*180;
		System.out.println(S);
	}
	
}
}


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


int main(void){
  string s;
  
  cin >> s;
  
  if (s[5]=='1' || s[6]>='5'){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	cout << 180 * (N - 2) << endl;
}


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

using namespace std;

int main() {
    int s_days, n, sum{0}, answer;

    cin >> s_days >> n;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        sum += tmp;
    }

    answer = s_days - sum;
    cout << std::max(answer, -1) << endl; 
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
  int a[5],k;
  for(int i=0;i<5;i++) cin>>a[i];
  cin>>k;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(a[i]-a[j]>k){
        cout<<":(\n";
        return 0;
      }
    }
  }
  cout<<"Yay!\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2333,mo=998244353;
int n,k,f[N][N],g[N][N];
int main() {
	read(k);read(n);int m=max(k,n);
	f[0][0]=g[0][0]=1;
	rep(i,1,m){
		int sf=0,sg=0;
		rep(j,0,m){
			f[i][j]=(sf+f[i-1][j])%mo;g[i][j]=(sg*2LL+g[i-1][j])%mo;
			sf=(sf+f[i-1][j])%mo;sg=(sg+g[i-1][j])%mo;
		}
	}
	rep(i,2,k*2){
		ll res=0;int a=0;rep(j,1,(i-1)/2)a+=j!=i-j&&i-j<=k;
		int b=k-2*a;if(i%2==0)b--;
		rep(j,0,n)res+=1LL*f[b][j]*g[a][n-j]%mo;
		if(i%2==0)rep(j,0,n-1)res+=1LL*f[b][j]*g[a][n-1-j]%mo;
		printf("%lld\n",res%mo);
	}
	return 0;
}

Measured memory_bytes: 39168
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a,b)     (a*b)/__gcd(a,b)
#define tr(s) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";
#define pv(a) for(ll i=0;i<a.size();i++) cout<<a[i]<<" ";
#define flu(i,a,b) for(ll i=a;i<b;i++)
#define blu(i,a,b) for(ll i=a;i>=b;i--)
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e='\n';
ll i,j,le;
int main()
{IOS;
   int t;
   t=1;
    while (t--)
    {
       ll n,c=0,x;
       cin>>n;
       flu(i,1,n+1)
       { cin>>x;
           if(i%2!=0 && x%2!=0)
           c++;
       }
       cout<<c<<e;
    }
    return 0;
}



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

namespace ARC66_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).ToList();


            var count = a
                .GroupBy(i => i)
                .Select(g => new { n = g.Key, c = g.Count() });
            foreach (var item in count)
            {
                if ((item.n == 0 && item.c > 1) || item.c > 2)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            long ans = 1;

            for (int i = 0; i < n/2; i++)
            {
                ans = (ans * 2) % 1000000007;
            }

            Console.WriteLine(ans);
        }
    }
}


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

vector<int> v(pow(2,18)+1,0),w(pow(2,18)+1,0);
vector<vector<int>> dp(2048,vector<int>(1e5+1,0));

int dfs(int V,int W,int C){
  if(W<0){
    return 0;
  }
  if(V<2048){
    return dp[V][W]+C;
  }
  int s=dfs(V/2,W-w[V],C+v[V]),t=dfs(V/2,W,C);
  return max(s,t);
}

int main() {
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> v[i+1] >> w[i+1];
  }
  for(int i=1;i<2048;i++){
    if(i>N){
      break;
    }
    for(int j=1;j<1e5+1;j++){
      if(j>=w[i]){
        dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i]]+v[i]);
      }
      else{
        dp[i][j]=dp[i/2][j];
      }
    }
  }
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int V,W;
    cin >> V >> W;
    cout << dfs(V,W,0) << endl;
  }
}


Measured memory_bytes: 808268
#include <cstdio>

using namespace std;

const int N = 100'009;

int a[N];
int f[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; ++i) {
    f[i] = -1;
  }
  for (int i = 0; i < n; ++i) {
    int l = -1, r = n;
    while (r - l > 1) {
      int s = (l + r) / 2;
      if (a[i] <= f[s]) {
        l = s;
      } else {
        r = s;
      }
    }
    f[l + 1] = a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (f[i] != -1) {
      ++ans;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 896
n = int(input())
t, a = map(int, input().split())
k = (t-a)/0.006
li = list(map(int, input().split()))
ans = float("inf")
wer = 0
for i in range(n):
    if abs(k - li[i]) < ans:
        ans = abs(k - li[i])
        wer = i
print(wer+1)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(void)
{
    string s,t;
    int n;
    cin >> n;
    cin >> s >> t;
    for(int i=0;i<2*n;i++)
    {
        if(i%2==0)
            cout << s[i/2];
        else
            cout << t[i/2];
    }
}

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

ll func(ll a,ll b){
  if(b ==0) return a;
  else return func(b, a%b);
}
int main(){
  int N; cin >> N;
  vector<int> A(N); cinf(N,A);
  ll ans=A[0];
  rep(i,N)
    ans=func(ans,A[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n; double x[100000], y[100000];
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        scanf("%lf", &x[i]);
        scanf("%lf", &y[i]);
    }
    
    pair<double, double> p1[100000], p2[100000];
    
    for(int i = 0; i < n; i++)
    {
        p1[i] = make_pair(x[i], y[i]);
    }
    
    for(int i = 0; i < n; i++)
    {
        p2[i] = make_pair(y[i], x[i]);
    }
    
    sort(p1, p1 + n);
    sort(p2, p2 + n);
    
    double sqr_ans = 100000000.0;
    
    const int loops = 150;
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p1[i + j].first - p1[i].first) * (p1[i + j].first - p1[i].first) + (p1[i + j].second - p1[i].second) * (p1[i + j].second - p1[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p2[i + j].first - p2[i].first) * (p2[i + j].first - p2[i].first) + (p2[i + j].second - p2[i].second) * (p2[i + j].second - p2[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    printf("%.15f\n", sqrt(sqr_ans));
    
    return 0;
}

Measured memory_bytes: 7400
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
const double eps=1e-10;
struct qnode{
	int id;
	double val;
	bool operator<(qnode b)const{
		return val>b.val;
	}
};
struct node{
	int to,nxt;
	double weigh;
}edge[3001000];
struct Point{
	int x,y,r;
}s,t,a[2010];
double dis[2010];
int head[2010],S,T,vis[2010];
int n,m,x,y,z,cnt;
std::priority_queue<qnode>q;
double dist(Point a,Point b){
	return sqrt(1ll*(a.x-b.x)*(a.x-b.x)+1ll*(a.y-b.y)*(a.y-b.y));
}
void addedge(int x,int y,double z){
	edge[++cnt].to=y;
	edge[cnt].nxt=head[x];
	head[x]=cnt;
	edge[cnt].weigh=z;
}
void Dijkstra(){
	for(int i=S;i<=T;i++)
		dis[i]=1e100;
	dis[S]=0;
	memset(vis,false,sizeof(vis));
	q.push((qnode){S,0});
	while(!q.empty()){
		int x=q.top().id;
		q.pop();
		if(vis[x])continue;
		vis[x]=true;
		for(int i=head[x];i;i=edge[i].nxt){
			int upup=edge[i].to;
			dis[upup]=std::min(dis[upup],dis[x]+edge[i].weigh);
			if(!vis[upup])q.push((qnode){upup,dis[upup]});
		}
	}
}
int main(){
	scanf("%d%d%d%d",&s.x,&s.y,&t.x,&t.y);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r);
	S=0,T=n+1;
	addedge(S,T,dist(s,t));
	addedge(T,S,dist(s,t));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if(i==j)continue;
			double Dis=dist(a[i],a[j]);
			Dis-=a[i].r+a[j].r;
			if(Dis<eps)addedge(i,j,0),addedge(j,i,0);
			else addedge(i,j,Dis),addedge(j,i,Dis);
		}
	for(int i=1;i<=n;i++){
		double Dis=dist(s,a[i]);
		Dis-=a[i].r;
		if(Dis<eps)addedge(S,i,0),addedge(i,S,0);
		else addedge(i,S,Dis),addedge(S,i,Dis);
		Dis=dist(t,a[i]);
		Dis-=a[i].r;
		if(Dis<eps)addedge(T,i,0),addedge(i,T,0);
		else addedge(i,T,Dis),addedge(T,i,Dis);			
	}
	Dijkstra();
	printf("%.10lf\n",dis[T]);
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

bool isValid(const vl &a, ll mid, ll k) {
	ll cnt = 0;
	for(ll i=a.size()-1; i>=0; i--) {
		if(a[i]>mid) {
			cnt += a[i]/mid;
		}else break;

		if(cnt>k) return false;
	}
	return true;
}

ll solve(const vl &a, ll k, ll l, ll r) {
	ll ans = r;
	while(l<=r) {
		ll mid = l + (r-l)/2;
		// cout<<l<<" "<<r<<" "<<mid<<"\n";
		if(isValid(a, mid, k)) {
			r = mid-1;
			ans = mid;
		}else l = mid+1;
	}
	return ans;
}

int main() {
	doublade();
	// w(t) {
		ll n, k;
		cin >> n >> k;
		ll sum = 0;
		vl a(n);
		rep(i, n) {
			cin>>a[i];
			sum += a[i];
		}
		if(k>=sum) {
			cout<<"1\n";
			return 0;
		}else {
			sort(all(a));
			ll l=0, r=a[n-1];
			cout<<solve(a, k, l, r)<<"\n";
		}
	// }
	return 0;
}

Measured memory_bytes: 4756
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll n, m;

	if (n == 1 && m == 1)
		return OUT(1);

	if (n == 1)
		return OUT(m - 2);

	if (m == 1)
		return OUT(n - 2);

	return OUT((n - 2) * (m - 2));
}


Measured memory_bytes: 256
#include<stdio.h>

main()
{
 int a,b;

 scanf("%d %d",&a,&b);

 if(a > b) 
 {
 printf("a > b\n");

 }
else if(a < b){
  printf("a < b\n");
 }
else{
 
 printf("a == b\n");

 }

 return 0;
}


Measured memory_bytes: 2056
#include<stdio.h>
int a[505];
int b[505];
int c[505];
int main()
{
	int x;
	scanf("%d",&x);
	for(int i=1;i<x;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	
	for(int i=1;i<x;i++)
	{
		int sum=a[i]+b[i];
		for(int j=i+1;j<x;j++)
		{
			if(sum>b[j])
			{
				if((sum-b[j])%c[j]==0)
					sum=sum+a[j];
				else
				{
					sum=sum+c[j]-(sum-b[j])%c[j]+a[j];
				}
			}
			else
			{
				sum=b[j]+a[j];
			}	
		}	
		printf("%d\n",sum); 
	
	
	
	
	
	}
	 
	printf("0\n");
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define m 0x3f3f3f3f
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n;
int main()
{
    cin>>n;
    if(n%2){
        cout<<0;
    }
    else{
        n/=2;
        ll ans=0,mod=5;
        while(mod<=n){
            ans+=n/mod;
            mod*=5;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);
        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        {
            Console.WriteLine("Possible");
        }
        else
        {
            Console.WriteLine("Impossible");
        }
    }
}


Measured memory_bytes: 11092
size = [60,80,100,120,140,160]
weight = [2,5,10,15,20,25]
cost = [6,8,10,12,14,16]
while True:
	n = int(raw_input())
	if n == 0: break
	ans = 0
	for i in range(n):
		x,y,h,w = map(int, raw_input().split())
		xyh = x+y+h
		for j in range(6):
			if xyh <= size[j] and w <= weight[j]:
				ans += cost[j]*100
				break
	print ans

Measured memory_bytes: 4524
MOD = 10**9 + 7

r1, c1, r2, c2 = map(int, input().split())

def getComb(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

def f(i, j):
    return getComb(i+j, j, MOD)

ans = f(r2+1, c2+1) - f(r2+1, c1) - f(r1, c2+1) + f(r1, c1)
ans %= MOD

print(ans)


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

long computeXOR(const long n) 
{ 
    switch(n & 3) // n % 4  
    { 
    case 0: return n;
    case 1: return 1;
    case 2: return n + 1;    
    case 3: return 0;   
    } 
}

int main()
{
  long long N, M;
  cin >> N >> M;
  long long ans = N;
  if (N == M) {
    cout << N << endl;
    return 0;
  }
  
  long before = computeXOR(N - 1);
  long after = computeXOR(M);
  ans = before ^ after;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"
var a [100100] int

func fun (k int,n int ) int{

	for i:=0;i<n;i++{
		if k==0 {break}
		if a[i] == 0 {
			a[i]=1
			if i+1<n&&a[i+1]==1{
				k--
			}
		}

	}
	ans:=0
	for i:=1;i<n;i++{
		if a[i]==a[i-1]{
			ans++
		}
	}
	return ans
}

func main() {
	var s string
	var n,k int
	fmt.Scanf("%d%d",&n,&k)
	fmt.Scanf("%s",&s)
	for i:=0;i<n;i++{
		if s[i]=='L'{
			a[i]=0
		}else {
			a[i]=1
		}
	}
	ans1 := fun(k,n)

	for i:=0;i<n;i++{
		if s[i]=='L'{
			a[i]=1
		}else {
			a[i]=0
		}
	}
	ans2 :=fun(k,n)
	if ans1>ans2{
		fmt.Println(ans1)
	}else {
		fmt.Println(ans2)
	}

}


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

int sum = 0;
long long n;

int check(long long x){
  ostringstream oss;
  oss << x;
  string s = oss.str();
  bool flag[3];
  flag[0] = flag[1] = flag[2] = false;
  for ( int i = 0; i < s.length(); i++){
    if ( s[i] == '3'){
      flag[0] = true;
    } else if (s[i] == '5') {
      flag[1] = true;
    } else if ( s[i] == '7') {
      flag[2] = true;
    }
  }

  if(flag[0] && flag[1] && flag[2]){
    return 1;
  } else {
    return 0;
  }
}

void rec(long long x, int cnt){
  if ( x > n){
    return;
  }
  sum += check(x);
  rec(10*x + 3, cnt+1);
  rec(10*x + 5, cnt+1);
  rec(10*x + 7, cnt+1);
}

int main(){
  cin >> n;

  rec(3, 0);
  rec(5, 0);
  rec(7, 0);
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath> 
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;

struct node{
	ll x,y;
	
}r[1010];
bool cmp(node a,node b){
		return atan2(a.x,a.y) < atan2(b.x,b.y);//atan2：斜角计算函数 
	}
int main(){
	ll n,x,y;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>r[i].x>>r[i].y;
	}
	ll ans=0;
	sort(r,r+n,cmp);//只有按照极角排序之后才能保证可以达到最大的向量和是最大的。 
	for(int i=0;i<n;i++){
		x=r[i].x;
		y=r[i].y;
		ans=max(ans,x*x+y*y);
		for(int j=(i+1)%n;j!=i;j=(j+1)%n){
			x+=r[j].x;
			y+=r[j].y;
			ans=max(ans,x*x+y*y);
		}
	}
//	cout<<ans<<endl;
	double ans1=sqrt(ans);
	printf("%.13lf\n",ans1);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
long long dp[10][1001];
int main(){
	int n,s;
	while(true){
	cin>>n>>s;
	if(n==0&&s==0)break;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=s;j++){
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int k=0;k<=100;k++){
		for(int i=n-1;i>=0;i--){
			for(int j=0;j+k<=s;j++){
				dp[i+1][j+k]+=dp[i][j];
			}
		}
	}
	cout<<dp[n][s]<<endl;
	}
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1232
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
#h+w回確認する
import numpy as np
change_h=0
change_w=w
ans=[]
for i in range(h):
    if l[i].count('.')!=w:
        ans+=[l[i][:]]
        change_h+=1
l_count=[]
for i in range(w):
    count=0
    for j in range(h):
        if l[j][i]=='.':
            count+=1
    
    if count==h:
        l_count+=[i]
    
l_count=sorted(l_count,reverse=True)#削除したい列番号を後ろから削除する
for i in l_count:
    ans=np.delete(ans,i,axis=1)
    #np.delete(a,b,c):a:配列,b:削除したい行・列番号,c:列か行か

#最後の出力
for i in range(change_h):
    print(*ans[i],sep='')

Measured memory_bytes: 13620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ans = 0;
		for (long i = 1; i <= N; i++) {
			if (i * i <= N) {
				ans = i * i;
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
//kuch motivational line which i cannot think of coz i lack motivation

#include<bits/stdc++.h>//works like magic, but at cost
using namespace std;

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mod 100000009
void solve() { 
 int x,y,z;
 cin>>x>>y>>z;
 cout<<z<<" "<<x<<" "<<y<<endl;
	
}

int32_t main() {
    fastio;
    int t = 1;
    // cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	vector<double> dp(n+1), p(n);
	/// dp[i] = probabilidade de ter i heads
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> p[i];
		dp[i+1] = dp[i]*p[i];
		for(int j = i; j > 0; j--){
			dp[j] = dp[j-1]*p[i] + dp[j]*(1.0-p[i]);
		}
		dp[0] = dp[0]*(1.0-p[i]);
	}
	double ans = 0;
	for(int i = (n+1)/2; i <= n; i++){
		ans += dp[i];
	}
	cout << setprecision(10) << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n; cin>>n;
	int a; cin>>a;
	for(int i=1; i<n; i++){
		int b; cin>>b;
		a = __gcd(a,b);
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
    long long X, K, D;
    cin >> X >>K >> D;

    long long x = abs(X);

    
    K -= x/D;
    x = x%D;

    if (K<=0){
        cout << x-D*K << endl;
        return 0;
    }
    if  (K>0 && K%2 == 1){
        x = x-D;
    }

    cout << abs(x) << endl;

}



Measured memory_bytes: 3636
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include<stack>
#include<queue>
#include <cassert>
using namespace std;

 
int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}


fn main(){
    const MAX_N : usize = 100010;

    let v = read_t_in_line::<i32>();
    let(n, h) = (v[0] as usize, v[1]);
    let mut aa = [0 ; MAX_N];
    let mut bb = [0 ; MAX_N];

    for i in 0..n {
        let v2 = read_t_in_line::<i32>();
        let (a, b) = (v2[0], v2[1]);
        aa[i] = a;
        bb[i] = b;
    }

    // aaとbbをそれぞれsort
    // bbを大きい順番に使う, aaは一番大きい値しか利用しない
    let a_slice : &mut [i32] = &mut aa[0..n]; 
    sort_rev(a_slice);
    let b_slice : &mut [i32] = &mut bb[0..n]; 
    sort_rev(b_slice);

    let a_max = a_slice[0];
    let mut min_count = (h + a_max - 1) / a_max;
    let mut b_sum = 0;
    for i in 0..b_slice.len() {
        b_sum += b_slice[i];
        if b_sum >= h {
            min_count = cmp::min(min_count, i as i32 + 1);
            break;
        }
        else{
            min_count = cmp::min(min_count, ((h - b_sum) + a_max - 1) / a_max + i as i32 + 1);
        }
    }

    println!("{}", min_count);


}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << a * b / 2 << endl;
	
	return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}


vector<pair<long long, long long> > prime_factorize(long long n) { //素因数分解、pairのfirstに底、secondに底の何乗
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll k;
    cin >> k;
    ll cur = 0;
    rep(i,k+1){
        cur = cur * 10 + 7;
        cur %= k;
        if(cur == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;


    

}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	static int solve(int n, int x, int t) {

		int minute;
		if (n % x == 0)
			minute = (n / x) * t;
		else
			minute = (n / x + 1) * t;

		return minute;
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n, x, t;

		n = stdIn.nextInt();
		x = stdIn.nextInt();
		t = stdIn.nextInt();

		int result = solve(n, x, t);
		System.out.println(result);

		stdIn.close();
	}
}


Measured memory_bytes: 27008