akhauriyash/Code-Regression huggingface dataset:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m,k=MI()
lisa=LI()
lisb=LI()
u=list(accumulate(lisa))
v=list(accumulate(lisb))
u=[0]+u
v=[0]+v
for i in range(n+1):
    if u[i]>k:
        i-=1
        break
'''print(i)
print(u)
print(v)'''
j=0
count=[]
while True:
    if i<0:
        i+=1
        count.append(i+j)
        break
    while True:
        #print(i,j)
        if j>=m+1:
            j-=1
            count.append(i+j)
            break
        if u[i]+v[j]<=k:
            j+=1
        else:
            j-=1
            count.append(i+j)
            break
    i-=1
print(max(count))
    
            
        
        
    
    
    
    

    
    


    
    

        
        
    


    

Measured memory_bytes: 131604
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long        ll;
typedef unsigned long long    ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;

map<int,ll> elems;

#define MODULO (1000*1000*1000+7)

void make_elems(int n)
{
	int d = n-1;
	int is_prime = true;
	while(n>1&&d>1) {
		if(n%d==0) {
			is_prime=false;
			n=n/d;
			make_elems(d);
		}
		else {
			d--;
		}
	}
	if(is_prime) {
		if(elems.find(n)!=elems.end()) {
			elems[n] += 1;
		}
		else {
			elems.insert(MP(n,1));
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

	while(N>1) {
		make_elems(N);
		N--;
	}


	map<int,ll>::iterator it = elems.begin();
	ll count = 1;
	for(;it!=elems.end();it++) {
		// DOUT << "it->first="<<it->first<<", it->second="<<it->second<<endl;
		count = ((it->second+1)*count)%MODULO;
	}

	cout << count << endl;


	return 0;
}
 


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String input = in.next();
            int count = 0;
            int len = input.length();
            for (int i = 0; i < len; i++) {
                if (input.charAt(i) == '1') {
                    count++;
                }
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 21844
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    
     ll t; t = 1;
     while(t--){
     	ll n, m; cin >> n >> m;
     	vector<int> h(n);
     	for(auto &x:h)
     		cin >> x;
     	std::vector<int> v(n+1, 0);
     	while(m--){
     		int x, y; cin >> x >> y;
     		if(h[y-1] > v[x])
     			v[x] = h[y-1];
     		if(h[x-1] > v[y])
     			v[y] = h[x-1];
     	}
     	int ans = 0;
     	for(int i = 1; i <= n; i++){
     		if(v[i] < h[i - 1])
     			ans++;
     	}
     	cout << ans;
     }
    	return 0;
}

Measured memory_bytes: 4784
//Think simple yet elegant
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll maxn=5e6+5;
const ll mod=1e9+7;

int main(){
	fast;
	ll x,i,j;
	cin>>x;
	for(i=-120;i<=120;++i){
		for(j=-120;j<=i;++j){
			if((ll)(pow(i,5) - pow(j,5)) == x){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  string S;
int i,make;
  make=0;
cin>>S;
for(i=0;i<15;i++){
if(S[i]=='x') make++;
}
  if(make<8){
  cout<<"YES"<<endl;
  }else{
  cout<<"NO"<<endl;
  }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int f(string s) {
  int res = 0;
  rep(i, s.size()) res = 10 * res + (s[i] - '0');
  return res;
}

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

  int v = f(a + b);

  for (int i = 1; i * i <= v; i++) {
    if (i * i == v) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

// 実験を繰り返して成立するパターンを見つける
// まずは何らかの偶奇で考える。
int main() {
  int N, K; cin >> N >> K;
  ll ans = 0;
  if(K % 2 == 1) {
    ans += N / K;
    cout << (ll)pow(ans, 3) << endl;
  } else {
    ll tmp = (N + (N % K)) / K;
    ans += (ll)pow(tmp, 3);
    ans += (ll)pow(N / K, 3);
    cout << ans << endl;
  }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
        cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(a);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;
const int mxN = 1e5+5;

void solve(){
	int h,w;
	cin>>h>>w;
	vector<string> a(h+1);
	rep(i,1,h) cin>>a[i], a[i] = '#'+a[i];
	vvi dp(h+1,vi(w+1));
	dp[1][1]=1;
	rep(i,1,h){
		rep(j,1,w){
			if(a[i][j]=='#') continue;
			
			if(i>1){
				dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
			}
			if(j>1){
				dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
			}
		}
	}

	cout<<dp[h][w];
}

int main(){
	solve();
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int c=0;
  for(int i=l;i<=r;i++){
    if(i%d==0){
      c++;
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3464
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstdlib>
using namespace std;
  
int main() {
     
    while(true){
        string num;
        cin>>num;
        if (num=="0") break;
        int size = num.size();
 
        int a[1000];
        for (int i = 0; i < size; ++i)
        {
            a[i]=num[i]-'0';
        }
        int sum=0;
        for (int j = 0; j < size; ++j)
        {
            sum+=a[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3164
#include<stdio.h>
#include<stdlib.h>
#define size 100001
int*pass[size];
int deep[size];
int pass_s[size];
int qu[size];
int N,M;
void set()
{
    int a,b;
    for(int j=0;j<N;j++){
       deep[j]=-1;
       pass_s[j]=0; 
    }
    deep[0]=0;
    for(int i=0;i<M;i++){
        scanf("%d %d",&a,&b);
        a--;b--;
        pass[a]=(int*)realloc(pass[a],sizeof(int)*(pass_s[a]+1));
        pass[a][pass_s[a]]=b;
        pass_s[a]++;
         pass[b]=(int*)realloc(pass[b],sizeof(int)*(pass_s[b]+1));
        pass[b][pass_s[b]]=a;
        pass_s[b]++;
    }
}
void sys()
{
    int point=0,tar=0,nm=0;
    while(1){
        for(int i=0;i<pass_s[tar];i++){
             if(deep[pass[tar][i]]!=-1)continue;
             deep[pass[tar][i]]=tar+1;//指向房间号的deep为当前房间号+1即为题设房间号//deep[pass[tar][i]]=deep[tar]+1;这是计算深度用的
            qu[nm]=pass[tar][i];
            nm++;
        }
        if(nm==point) break;
        tar=qu[point];
        point++;
    }

}
int main(){
    scanf("%d %d",&N,&M);
    set();
    sys();
    printf("Yes\n");
    for(int i=1;i<N;i++){
     printf("%d\n",deep[i]);
    }
    return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <math.h>

int rheight(double h){
	return (int)ceil(h / 5) + 1;
}

int main(void){
	double v = 0.0;
	double t, y;
	while(scanf("%lf", &v) != EOF){
		y = v * v / 9.8 / 2;
		printf("%d\n", rheight(y));
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;

int main(){
	stack<int> s1;
	stack<pair<int,int> > s2;
	char ch;
	int sum=0,a;
	for(int i=0;(ch=getchar())!='\n';i++){
		if(ch=='\\')s1.push(i);
		else if(ch=='/'&&s1.size()>0){
			int j=s1.top();s1.pop();
			sum+=i-j;
			a=i-j;
			while(s2.size()>0&&s2.top().first>j){
				a+=s2.top().second;s2.pop();//计算每一处积水的面积和 
			}
			s2.push(make_pair(j,a)); 
		}
	}
	vector<int> ans;
	while(s2.size()>0){
		ans.push_back(s2.top().second);s2.pop();
	}
	reverse(ans.begin(),ans.end());//翻转，从前往后输出 
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i=0;i<ans.size();i++){
		cout<<" "<<ans[i];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 3232
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> h;
    ll ans = 0;
    ll curh = 0;
    ll curs = 0;
    for (int i = 0; i < n; i++) {
        ll h; cin >> h;
        if (curh < h) {
            ans = max(ans, curs);
            curs = 0;
        } else {
            curs++;
        }
        curh = h;
    }
    cout << max(ans, curs) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    int n;
    cin >> n;
    map<int, bool>p;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (p[x]) {
            cout << "NO" << endl;
            return 0;
        }
        p[x] = 1;
    }
    cout << "YES" << endl;

    return 0;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;
	vector<int> P(N);

	rep(i, 0, N)
	{
		cin >> P[i];
	}

	int sum = 0;
	int maxs = 0;
	int ansi = 0;

	int l = 0;
	rep(r, 0, N)
	{
		if (r - l >= K)
		{
			sum -= P[l];
			l++;
		}
		sum += P[r];
		if (chmax(maxs, sum))
		{
			ansi = l;
		}
	}

	double ans = 0.0;
	rep(i, ansi, ansi + K)
	{
		ans += (P[i] + 1) / 2.0;
	}

	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int X,Y;
    cin>>X>>Y;
    vector<int>v;
    int go=0;
    for(int i=0;i<n;i++){
        if(s[i]=='F')go++;
        else{
            v.push_back(go);
            go=0;
        }
    }
    v.push_back(go);
    set<int>x;
    set<int>y;
    x.insert(v[0]);
    y.insert(0);
    for(int i=1;i<v.size();i++){
        vector<int>ins;
        vector<int>ers;
        if(i%2){
            for(auto itr=y.begin();itr!=y.end();++itr){
                int now=*itr;
                ers.push_back(now);
                ins.push_back(now-v[i]);
                ins.push_back(now+v[i]);
            }
            for(int j=0;j<ers.size();j++)y.erase(ers[j]);
            for(int j=0;j<ins.size();j++)y.insert(ins[j]);
        }
        else{
            for(auto itr=x.begin();itr!=x.end();++itr){
                int now=*itr;
                ers.push_back(now);
                ins.push_back(now-v[i]);
                ins.push_back(now+v[i]);
            }
            for(int j=0;j<ers.size();j++)x.erase(ers[j]);
            for(int j=0;j<ins.size();j++)x.insert(ins[j]);
        }
    }
    if(x.count(X) && y.count(Y))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();

		int blackstartcount = 0;
		int whitestartcount = 0;

		for(int i=0;i<s.length();i++) {
			char si = s.charAt(i);

			if(i%2 == 0) {
				blackstartcount += (si == '0') ? 1 : 0;
				whitestartcount += (si == '1') ? 1 : 0;
			}else {
				blackstartcount += (si == '1') ? 1 : 0;
				whitestartcount += (si == '0') ? 1 : 0;
			}
		}

		System.out.println(Math.min(blackstartcount, whitestartcount));
	}

}

Measured memory_bytes: 27588
N,K=map(int,input().split())
a=list(map(int,input().split()))

dp=[False]*(K+1)

for i in range(N):
    dp[a[i]]=True

for k in range(K+1):
    for n in range(N):
        if k>=a[n]:
            dp[k]=not dp[k-a[n]]
        if dp[k] is True:
            break

if dp[-1] is True:
    print("First")
else:
    print("Second")

Measured memory_bytes: 42476
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

double comb(int n, int r){
    double u = 1, d = 1;
    for(int i=0; i<r; i++) u *= (n - i);
    for(int i=1; i<=r; i++) d *= i;
    return u / d;
}

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

    int n, m, l; cin>>n>>m>>l;
    vector<double> p(n), t(n), v(n);
    for(int i=0; i<n; i++) cin>>p[i]>>t[i]>>v[i];

    vector<vector<double>> proba(n, vector<double>(m+1));
    for(int i=0; i<n; i++){
        for(int j=0; j<=m; j++){
            proba[i][j] = pow(1. * p[i] / 100, j) * pow(1 - 1. * p[i] / 100, m - j) * comb(m, j);
        }
    }

    for(int i=0; i<n; i++){
        double ans = 0;
        for(int j=0; j<=m; j++){
            double ctime = 1. * l / v[i] + t[i] * j;
            double sum = 1;
            for(int ii=0; ii<n; ii++){
                if(i == ii) continue;
                double proba_sum = 0;
                for(int jj=0; jj<=m; jj++){
                    double ntime = 1. * l / v[ii] + t[ii] * jj;
                    if(ctime < ntime){
                        proba_sum += proba[ii][jj];
                    }
                }
                
                sum *= proba_sum;
            }

            ans += sum * proba[i][j];
        }

        printf("%.10f\n", ans);
    }

    return 0;
}


Measured memory_bytes: 3636
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    int MaxValue = Integer.MAX_VALUE / 1000;
    int AbcLen = 26;

    void solve() {
        char[] inputCharArray = in.nextToken().toCharArray();
        int inputLen =inputCharArray.length;
        int[] dp = new int[inputLen];
        int[] last = new int[AbcLen];
        int[] lastPos = new int[AbcLen];
        Arrays.fill(lastPos, inputLen);
        int[] resultCharIndex = new int[inputLen];
        int[] resultCharList = new int[inputLen];

        for (int inputIndex = inputLen - 1; inputIndex >= 0; inputIndex--) {
            int inputChar = inputCharArray[inputIndex] - 'a';
            dp[inputIndex] = MaxValue;
            for (int AbcIndex = 0; AbcIndex < AbcLen; AbcIndex++) {
                if (last[AbcIndex] + 1 < dp[inputIndex]) {
                    dp[inputIndex] = last[AbcIndex] + 1;
                    resultCharIndex[inputIndex] = lastPos[AbcIndex];
                    resultCharList[inputIndex] = AbcIndex;
                }
            }
            last[inputChar] = dp[inputIndex];
            lastPos[inputChar] = inputIndex;
        }

        int resultBegin = -1, addCharPos = -1;
        for (int i = 0; i < AbcLen; i++) {
            if (resultBegin == -1 || last[i] < last[resultBegin]) {
                resultBegin = i;
                addCharPos = lastPos[resultBegin];
            }
        }

        StringBuilder sb = new StringBuilder();
        sb.append((char) (resultBegin + 'a'));
        while (addCharPos < inputLen) {
            sb.append((char) (resultCharList[addCharPos] + 'a'));
            addCharPos = resultCharIndex[addCharPos];
        }
        out.println(sb.toString());
    }

    FastScanner in;
    PrintWriter out;

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

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

}

Measured memory_bytes: 29744
#include <iostream>

using namespace std;

int main(){
  int n, now, count;
  while(1){
    cin >> n;
    now = 0;
    count = 0;
    if(n==0) break;
    
    while(1){
      if(1000-n-now >= 500){
        now += 500;
        count++;
      } else if (1000-n-now >= 100){
        now += 100;
        count++;
      } else if (1000-n-now >= 50){
        now += 50;
        count++;
      } else if (1000-n-now >= 10){
        now += 10;
        count++;
      } else if (1000-n-now >= 5){
        now += 5;
        count++;
      } else {
        now += 1;
        count++;
      }

      if(1000-n-now == 0) {
        cout << count << endl;
        break;
      }
    }
  }

  return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b , c;

int main()
{
    _FastIO;
    string s;
    cin >> s;
    int n = s.size();
    string t = s;
    reverse(t.begin() , t.end());
    int k = n / 2 - 1;
    if(n % 2) k++;
    int ans = 0;
    for(int i = 0; i <= k; i++){
        if(t[i] != s[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    }
}


Measured memory_bytes: 23124
open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f
                                                 
let () =
  let n = read_int () in
  let al = Array.make (n+1) [] in
  let dist = Array.make (n+1) (-1) in
  let q = Queue.create () in
  let rec read x =
    if x = 0 then ()
    else
      begin
        (match read_list int_of_string with
           u :: _ :: vs -> al.(u) <- vs
         | _ -> failwith "read");
        read (x-1)
      end
  in
  let rec loop () =
    if Queue.is_empty q then ()
    else begin
        let u = Queue.pop q in
        List.iter (fun v ->
                   if dist.(v) = (-1) then begin
                       dist.(v) <- dist.(u) + 1;
                       Queue.push v q
                     end
                  ) al.(u);
        loop ()
      end
  in
  read n;
  Queue.push 1 q;
  dist.(1) <- 0;
  loop ();
  Array.iteri (fun i v -> if i > 0 then (string_of_int i) ^ " " ^ (string_of_int v) |> print_endline) dist

Measured memory_bytes: 2428
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>

using namespace std;
using ll = long long;

vector<ll> nums;

void dfs(ll x){
        nums.push_back(x);
        if(x<=1000000000){
                dfs(10*x+3);
                dfs(10*x+5);
                dfs(10*x+7);
        }
        return;
}

int main(){ 
        ll n,ans;
        cin >> n;
        dfs(0);
        sort(nums.begin(),nums.end());
        for(ll i=0;i<nums.size();i++){
                string str = to_string(nums[i]);
               int flag[3]={};
               //if(i<100) cout << str << endl;
                for(int j=0;j<str.size();j++){
                        if(str[j]=='3') flag[0]=1;
                        if(str[j]=='5') flag[1]=1;
                        if(str[j]=='7') flag[2]=1;
                }
                for(int j=0;j<3;j++){
                        if(flag[j]!=1){
                                //cout << nums[i] << endl;
                                    nums.erase(nums.begin()+i);
                                    i--;
                                    break;
                        }
                }
        }
        for(ans=0;;ans++){
                if(nums[ans]>n)   break;
               // cout << nums[ans] << endl;
        }
        cout << ans << endl;
        return 0;
}

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

using namespace std;

int main(){
	int p,q,r;
  	scanf("%d %d %d",&p,&q,&r);
  	int ans  = min( min(p,r)+q, min(  min(p,q)+r, min(q,r)+p ) );
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 2e6 + 5;
const int K = (1 << 17) + 10;
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

vii V[N];
int dp[N];

int dfs(int node , int p) {
	dp[node] = 0;
	int child = 0;
	vii X;
	for(auto v : V[node])
		if (v != p) {
			dfs(v , node);
			X.pb(dp[v]);
		}
	sort(all(X));
	int r = X.size();
	for(int i = r - 1 , c = 0;i >= 0;i-- , c++)
		dp[node] = max(dp[node] , 1 + c + X[i]);
	return dp[node];
}

int main(int argc, char const *argv[])
{
	fast;

	int n;
	cin >> n;

	frep(i , 2 , n) {
		int x;
		cin >> x;
		// cout << i << ' ' << x << endl;
		V[x].pb(i);
		V[i].pb(x);	
	}

	cout << dfs(1 , -1) << endl;

	return 0;
}

Measured memory_bytes: 60032
#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>;
 
const int MX = 100005;

int main() {
    int n;
    cin >> n;
    vector<ll> cnt(MX);
    rep(i,n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll tot =0;
    rep(i, MX) tot += i*cnt[i];

    int q;
    cin >> q;
    rep(i, q){
        int b, c;
        cin >> b >> c;
        tot -= b*cnt[b];
        tot -= c*cnt[c];
        cnt[c] += cnt[b]; cnt[b] = 0;
        tot += b*cnt[b];
        tot += c*cnt[c];
        cout << tot << endl;
    }
    return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define ll long long
#define ull unsigned long long
using namespace std;


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

	int n;
	cin >> n;
	vector<double> V(n);
	for (auto &v : V) cin >> v;
	vector<vector<double>> DP(n, vector<double>(n + 1));
	DP.at(0).at(0) = 1.0  - V.at(0);
	DP.at(0).at(1) = V.at(0);

	for (int i = 1; i < n; i++){
		DP.at(i).at(0) = DP.at(i - 1).at(0) * (1.0 - V.at(i));
		for (int j = 1; j <= (i + 1); j++){
			DP.at(i).at(j) = DP.at(i - 1).at(j - 1) * V.at(i)
							+ DP.at(i - 1).at(j) * (1.0 - V.at(i));
		}
	}

	int start = n / 2 + 1;
	double ans = 0;
	for (int i = start; i <= n; i++){
		ans += DP.back().at(i);
	}
	cout.precision(12);
	cout << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 70784
solve :: [Int] -> [Int]	-> [Int]
solve list (a:b:c:d:xs)	
  | null xs = list
  | otherwise = solve (take (i-1) list ++ d+list !! (i-1):[] ++ drop i list) xs
  where i = (a-1)*30 + (b-1)*10 + c

mklist :: Int -> [Int] -> [String]
mklist n (x:xs)
  | null xs = []
  | mod n 30 == 0 = " " : shows x "\n" : (replicate 20 '#') : "\n" : mklist (n+1) xs
  | mod n 10 == 0 = " " : shows x "\n" : mklist (n+1) xs
  | otherwise = " " : show x : mklist (n+1) xs

main = getContents >>= putStr . take 315 . concat . mklist 1 . (++[1]) . solve (replicate 120 0) . (++[1,1,1,1]) . map read . tail . words

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

int main(){
  int n;
  
  
  cin >> n;
  
  vector<int> d(n);
  
  for(int i = 0; i < n;i++){
      cin >> d[i];
  }
  
  
  int ans = 0;
  for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n;j++){
          ans += d[i] * d[j];
          
          
    
      }
      
      
  }
  
  cout << ans << endl;
  
  return 0;
  
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,i, actual=0,ant=0, resp;
  scanf("%d", &n);
  int h[n+1];
  scanf("%d", &h[0]);
  for(i=1;i<n;i++){
    scanf("%d", &h[i]);
    if(h[i-1]>=h[i]){
      actual++;
    } else {
      if(actual>ant) {
        ant=actual;
        actual=0;
      } else {
        actual=0;
      }
    }
  }
  if(actual==0 && ant==0) {
    resp=0;
  } else if(actual==0 && ant!=0) {
    resp=ant;
  } else if(actual!=0 && ant==0) {
    resp=actual;
  } else if(actual!=0 && ant!=0) {
    if(actual>=ant){
      resp=actual;
    } else {
      resp=ant;
    }
  }
  printf("%d", resp);
  return 0;
}



Measured memory_bytes: 512
// atcoder/abc159/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  double L;
  while (cin >> L) {
    double x = L / 3.0;
    cout << x * x * x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

int main()
{
  int n, i, j, temp, min, flag=0, count=0, a[MAX];
  scanf("%d", &n);
  
  for( i=0; i<n; i++)
    {
      scanf("%d", &a[i]);
    }
  
  for (i = 0; i < n-1; i++)
    {
      min = i;
      for (j = i + 1; j < n; j++)
	{
	  if (a[j] < a[min])
	    {
	      min = j;
	      flag = 1;
	    } 
	}
      if(flag)
	{
      temp = a[i];
      a[i] = a[min];
      a[min] = temp;
      count++;
      flag = 0;
	}
    }
  
  for(i = 0; i < n-1; i++)
    {
      printf("%d ", a[i]);
    }
  printf("%d\n", a[n-1]);
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2100
S = [s for s in str(input())]
d = len(S) // 3
from collections import Counter
cntr = sorted(list(Counter(S).values()))
if len(S) == 1:
  print('YES')
elif cntr == [1,1]:
  print('YES')
elif cntr == [d,d,d] or cntr == [d,d,d+1] or cntr == [d,d+1,d+1]:
  print('YES')
else:
  print('NO')

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

int main() {
  long long l,r,b;
  int a=2019;
  cin>>l>>r;
  for(long long i=l;i<r;i++){
    for(long long j=r;i<j;j--){
      b=(i*j)%2019;
      if(b==0){
        cout<<0;return 0;
      }
      if(a>b){
        a=b;
      }
    }
  }
  cout<<a;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    int a[100];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int t1,t2;
    t1=sum/n;
    t2=sum/n+1;
    int ans1=0,ans2=0;
    for(int i=0;i<n;i++){
        int x=a[i];
        ans1+=(x-t1)*(x-t1);
        ans2+=(x-t2)*(x-t2);
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    d[0]=0;
    color[0]=GRAY;
    while(1){
        minv=INFTY;
        int u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=INFTY;
        }
    }
    int k,c,u,v;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            M[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}



Measured memory_bytes: 3116
#!/usr/bin/env python3


def main():
    N = int(input())
    ps = list(map(int, input().split()))
    ps = [0] + ps

    cnt = 0
    for i in range(1, N + 1):
        if ps[i] == i:
            continue
        if ps[ps[i]] == i:
            cnt += 1
        else:
            print('NO')
            return
    if cnt <= 2:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

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

	set<int> S;

	int query, x;
	int L, R;

	for (int i = 0; i < q; i++) {
		cin >> query;
		if (query == 0) {
			cin >> x;
			S.insert(x);
			cout << S.size() << endl;
		}
		else if (query == 1){
			cin >> x;
			if (S.find(x) != S.end())
				cout << 1 << endl;
			else
				cout << 0 << endl;		
		}
		else if(query == 2){
			cin >> x;
			S.erase(x);		
		}
		else {
			cin >> L >> R;
			for (auto itr = S.lower_bound(L); itr != S.upper_bound(R); itr++) {
				cout << *itr << endl;
			}
		}
	}
}


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

int main()
{
  vector<int>N(5);
  for(int i=0;i<5;i++){
  cin >> N.at(i);
  if(N.at(i)==0){
    cout << i+1 << endl;
    return 0;
  }
  }


  

return 0;
}


Measured memory_bytes: 3592
import sys
from itertools import product

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    ps = [[] for i in range(n)]
    # eva = [[] for i in range(n)]
    for i in range(n):
        a = II()
        for j in range(a):
            ps[i].append(LI())
    max_ = 0
    for c in product([0, 1], repeat=n):
        c = list(c)
        # print(c)
        for i, p in enumerate(c):
            if p == 1:
                for opp in ps[i]:
                    # print(c[opp[0] - 1], opp[1])
                    if c[opp[0] - 1] != opp[1]:
                        # print(c[opp[0] - 1], opp[1])
                        break
                else:
                    continue
                break
        else:
            # print(c)
            max_ = max(max_, sum(c))
    print(max_)

if __name__ == '__main__':
    main()

Measured memory_bytes: 46576
N,u,v=map(int,input().split())
E=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)
  
distU=[0]*N
distV=[0]*N

stack=[]
stack.append([u-1,0,-1])
while stack:
  node=stack.pop()
  e=node[0]
  dist=node[1]
  parent=node[2]
  distU[e]=dist
  children=E[e]
  for child in children:
    if child==parent:
      continue
    stack.append([child,dist+1,e])
    
stack=[]
stack.append([v-1,0,-1])
while stack:
  node=stack.pop()
  e=node[0]
  dist=node[1]
  parent=node[2]
  distV[e]=dist
  children=E[e]
  for child in children:
    if child==parent:
      continue
    stack.append([child,dist+1,e])

maxdist=0
for i in range(N):
  if maxdist<distV[i] and distU[i]<distV[i]:
    maxdist=distV[i]

print(maxdist-1)


Measured memory_bytes: 29360
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;
int n;
int main(int argc, char *argv[]) {
    cin >> n;
    vector<int> dp(3);
    for (int day = 0; day < n; ++day) {
        vector<int> c(3);
        vector<int> new_dp(3, 0);
        for (int i = 0; i < 3; ++i) {
            cin >> c[i];
        }
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	cout<<((n*(n-1)))/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero\n";
	}
	else if (b < 0) {
		if ((b - a + 1) & 1) {
			cout << "Negative\n";
		}
		else {
			cout << "Positive\n";
		}
	}
	else {
		cout << "Positive\n";
	}
}	

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

int main() {
  long ans,n,k,d,e;
  ans=0;
  cin>>n>>k;
  vector<long> vec(n);
  for(long i=0; i<n; i++){
    vec.at(i)=0;
  }
  for(long i=0; i<k; i++){
    cin>>d;
    for(long j=0; j<d; j++){
      cin>>e;
      vec.at(e-1)=vec.at(e-1)+1;
    }
  }
  for(long i=0; i<n; i++){
    if(vec.at(i)==0){
      ans++;
    }
  }
  cout<<ans;
}

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

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
map<LL, int> mp;
LL N,P;

int main(){
	//freopen("in.txt", "r", stdin);
	while(cin >> N >> P){
		mp.clear();
		for(LL i = 2; i*i <= P; ++i){
			while(P%i == 0){
                ++mp[i];
                P /= i;
            }
            dbg(P);
		}
		if(P!=1) ++mp[P];
		LL ans = 1;
		for(auto &x:mp){
			dbg(x.first);
			dbg(x.second);
			for(int i = 1; i <= x.second/N; ++i){
				ans *= x.first;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	X,N = inputMap()
	p = inputList()

	sa = inf
	pointer = 0
	for i in range(200,-100,-1):
		if i in p:
			continue
		tmp = abs(X-i)
		if tmp <= sa:
			sa = tmp
			pointer = i

	if sa == inf:
		if X > 50:
			print(101)
		else:
			print(0)
	else:
		print(pointer)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 70828
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int value = scanner.nextInt();
        int count = scanner.nextInt();
        scanner.nextLine();
        String anti = scanner.nextLine();
        String[] val = anti.split(" "); 
        int i = value;
        aaa: while(true) {
            String va = String.valueOf(i);
            i++;
            for (String v : val) {
                if(-1 < va.indexOf(v)) {
                    value++;
                    continue aaa;
                }
            }
            break;
        }
        System.out.println(value);
    }
}

Measured memory_bytes: 24404
n=gets.to_i
a=gets.split.map.with_index{|num,i| num.to_i-(i+1)}.sort
b= n.odd? ? a[n/2]:(a[(n/2)-1]+a[(n/2)-1])/2
sum=0
a.each{|an| sum+=(an-b).abs}
puts sum


Measured memory_bytes: 19072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  
        String[] tmp = br.readLine().split(" ");
        int n = Integer.parseInt(tmp[0]);
        int w = Integer.parseInt(tmp[1]);
        int[] vi = new int[n];
        int[] wi = new int[n];
        for(int i = 0; i < n; i++) {
            tmp = br.readLine().split(" ");
            vi[i] = Integer.parseInt(tmp[0]);
            wi[i] = Integer.parseInt(tmp[1]);
        }
  
        int[][] dp = new int[n + 1][w + 1];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= w; j++) {
                if(j >= wi[i]) dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - wi[i]] + vi[i]);
                else dp[i + 1][j] = dp[i][j];
            }
        }
  
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 29048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < (s.size()/2); i++){
        if(s[i] != s[s.size()-i-1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256