akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
const int N = 2*five;
set<int> dp[N];
bool vis[N];
int curr;
void dfs(int i)
{
       curr++;
       vis[i] = true;
       tra(it,dp[i]){
              if(!vis[*it])dfs(*it);
       }
}
int main()
{
       int n,m;
       cin>>n>>m;
       fri(i,0,m)
       {
              int a,b;
              cin>>a>>b;
              --a;--b;
              dp[a].insert(b);
              dp[b].insert(a);
       }
       int ans = 0;
       memset(vis,false,sizeof vis);
       for(int i = 0 ; i < n ; i++)
       {
              if(!vis[i]){
                     curr = 0;
                     dfs(i);
                     ans = max(ans,curr);
              }
       }
       cout<<ans<<endl;
}


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

int main() {
   int N;
   cin >> N;
   vector<ll> A(N);

   __int128 ans = 1;

   for(int i=0;i<N; i++) {
      cin >> A[i];
      if(A[i] == 0) {
         cout << 0 << endl;
         return 0;
      }
   }

   for(int i=0; i<N; i++) {
      ans *= A[i];
      if(ans > 1000000000000000000) {
         cout << -1 << endl;
         return 0;
      }
   }
   cout << (ll)ans << endl;
}


Measured memory_bytes: 4040
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         int N=gi();
         String s1=gs();
         String s2=gs();

         boolean tf=false;
         boolean btf=false;
         boolean sf=true;
         long ans=1;
         for (int i=0; i<N;i++) {
             char c1=s1.charAt(i);
             char c2=s2.charAt(i);
             if(c1==c2) {
                 tf=true;
             } else {
            	 tf=false;
            	 i++;
             }
             if(sf) {
            	 sf=false;
            	 if(tf) {
            		 ans=3;
            	 } else {
            		 ans=6;
            	 }
            	 btf=tf;
             } else {
            	 if(tf) {
            		 if (btf) {
            		     ans=(ans * 2)%1000000007;
            		 }
            	 } else {
            		 if(btf) {
            			 ans=(ans*2)%1000000007;
            		 } else {
            			 ans=(ans*3)%1000000007;
            		 }
            	 }
            	 btf=tf;
             }
         }
       System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace Aisingcontest2020
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c()
        {
            int n = int.Parse(Console.ReadLine());
            int[] ans = new int[n];
            for(int i = 1; i <= 100; i++)
            { 
                for(int j = 1; j <= 100; j++)
                {
                    for(int k = 1; k <= 100; k++)
                    {
                        int x = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (i * k);
                        if( x <= n)
                        ans[x - 1]++;
                    }
                }
            }
            foreach(var x in ans)
            {
                Console.WriteLine(x);
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
    for (int i = 0 ; i < N ; i++){
    int A;
    cin >> A;
    int temp = 0;
    while ( A%2 == 0 ){
      A /= 2;
      temp ++;
    }
    if ( i == 0 ) sum = temp;
    else if ( temp < sum ) sum = temp; 
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var map = {};
  var k = n;
  for(var i = 2; i*i <= k; i++){
    if(k % i === 0){
      map[i] = 0;
      while(k % i === 0)map[i]++,k /= i;
    }
  }
  if(k > 1)map[k] = 1;
  var a = [];
  for(var i in map)a.push(map[i]);
  var ans = 0;
  a.sort((a,b) => b-a);
  for(var i = 0; i < a.length; i++){
    for(var j = 1; j <= a[i]; j++){
      ans++;
      a[i] -= j;
    }
  }
  return ans;
}

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

map< ll, int > prime_factor(ll n) {
  map< ll, int > res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main(){
  ll N,P;
  cin >> N >> P;
  auto mp = prime_factor(P);
  ll res = 1;
  for(auto e : mp) {
    ll tmp = e.second / N;
    res *= (ll)pow(e.first,tmp);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    ODD = list(map(str, sys.stdin.readline().rstrip()))
    EVEN = list(map(str, sys.stdin.readline().rstrip()))+[""]

    for o, e in zip(ODD, EVEN):
        print(o+e, end="")


if __name__ == '__main__':
    main()

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

int main()
{
    int r;
    int n;
    while (cin >> r >> n, r | n)
    {
        vector<pair<pair<int, int>, int>> bd(n);
        for (int i = 0; i < n; i++)
        {
            int a, b, h;
            cin >> a >> b >> h;
            bd[i] = make_pair(make_pair(a, b), h);
        }

        sort(bd.begin(), bd.end());
        set<pair<int, int>> check;
        vector<int> height(41);
        for (int i = 0; i < n; i++)
        {
            int start = bd[i].first.first + 20;
            int end = bd[i].first.second + 20;
            int h = bd[i].second;
            for (int j = start; j < end; j++)
            {
                height[j] = max(height[j], h);
            }
        }

        for (int i = 0; i < 40; i++)
        {
            if (height[i] != height[i + 1])
            {
                check.insert(make_pair(i + 1 - 20, max(height[i], height[i + 1])));
                check.insert(make_pair(i + 1 - 20, min(height[i], height[i + 1])));
            }
        }
        check.insert(make_pair(0, max(height[20], height[19])));
        // cout << "=======" << endl;

        // for (int i = 0; i < 40; i++)
        // {
        //     cout << height[i] << '\t';
        // }
        // cout << endl;
        // for (int i = 0; i < 40; i++)
        // {
        //     cout << height[i] << '\t';
        // }
        // cout << endl;
        // for (auto x : check)
        // {
        //     cout << x.first << " " << x.second << endl;
        // }
        // cout << "=======" << endl;

        double t = 0;
        const double dt = 0.0005;
        while (1)
        {
            int found = 0;
            t += dt;
            double xc = 0.0;
            double yc = t - (double)r;
            for (auto x : check)
            {
                double xd = (double)x.first;
                double yd = (double)x.second;
                if ((xd - xc) * (xd - xc) + (yd - yc) * (yd - yc) < (double)(r * r))
                {
                    found = 1;
                    break;
                }
            }
            if (found)
                break;
        }
        cout << fixed << setprecision(10) << t - dt << endl;
    }
    return 0;
}


Measured memory_bytes: 3264
#include <stdio.h>

int main() {
	int a, b, c, z;
	scanf("%d %d %d", &a, &b, &c);
	
	if (a > b) {
		z = a;
		a = b;
		b = z;
	}

	if (b > c) {
		z = b;
		b = c;
		c = z;
	}

	if (a > b) {
		z = a;
		a = b;
		b = z;
	}
	

	printf("%d %d %d\n", a, b, c);

	return 0;
}



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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};

class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};

int X, Y;

int main() {
    cin >> X >> Y;
    Combination comb(1000000);
    int x = 0, y = 0;
    ll ans = 0;
    while (x <= X && y <= Y) {
        if ((X - x) % 2 == 0) {
            if ((X - x) / 2 == Y - y) {
                ans = (ans + comb.comb(Y - y + x, x)) % MOD;
            }
        }
        x += 1;
        y += 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
def get_ints():
    return list(map(int,input().split()))

n = int(input())
a, b = [], []
for i in range(n):
    x, y = get_ints()
    a.append(x-y)
    b.append(x+y)

a.sort()
b.sort()
ans = max(a[-1] - a[0], b[-1] - b[0])
print(ans)

Measured memory_bytes: 25548
//atcoder clange
#include <stdio.h>

int main(void){
 
    char str[4];
    int i=0;
  
    scanf("%s", str);//文字列取得
  
  for(i=0;i<3;i++){
		if(str[i] == str[i+1]){
         printf("Bad");
          return 0;
        }
  }
  
  printf("Good");
  
    return 0;
}

Measured memory_bytes: 128
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

ll a[maxn],b[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
    sort(a+1,a+1+n),sort(b+1,b+1+n);
    if(n&1)cout<<b[(n+1)/2]-a[(n+1)/2]+1;
    else cout<<b[n/2]+b[n/2+1]-a[n/2]-a[n/2+1]+1;
    return 0;
}


Measured memory_bytes: 6728
#include <iostream>
#include <algorithm>
#include <cmath>

#define ll long long
using namespace std;
ll mn(ll a, ll b, ll c){
    if(a<=b && a<=c){
        return a;
    }
    if(b<=c && b<=a){
        return b;
    }
    return c;
}

ll mx(ll a, ll b, ll c){
    if(a>=b && a>=c){
        return a;
    }
    if(b>=c && b>=a){
        return b;
    }
    return c;
}

int main(){
    long long i,h,w,ans=10000000;
    cin >> h  >> w;
    if(h%3==0 || w%3==0){
        cout << 0 << endl;
        return 0;
    }
    for(i=1;i<h;i++){
        ans = min(ans,mx(i*w,w/2*(h-i),(w-w/2)*(h-i))-mn(i*w,w/2*(h-i),(w-w/2)*(h-i)));
    }
    for(i=1;i<w;i++){
        ans = min(ans,mx(i*h,h/2*(w-i),(h-h/2)*(w-i))-mn(i*h,h/2*(w-i),(h-h/2)*(w-i)));
    }
    ans = min(ans,h);
    ans = min(ans,w);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	int n,i;
	cin >> n >> i;
	cout << n-i+1 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

# M以下の整数の素因数分解を高速に
# 前処理O(MloglogM)
# 一計算O(logK)
def mae_syori(M):
    D = [0] * (M + 1)
    for i in range(2, M+1):
        if D[i] != 0: continue
    #     print(i, list(range(i*2, M + 1, i)))
        for j in range(i*2, M+1, i):
            if D[j] == 0:
                D[j] = i
    return D

def p_bunkai(K):
    assert 2 <= K <= len(D)-1
    k = K
    ret = []
    while True:
        if k == 1:
            break
        if D[k] == 0:
            ret.append((k, 1))
            break
        else:
            p = D[k]
            count = 0
            while k % p == 0:
                count += 1
                k //= p
            ret.append((p, count))
    return ret
 

# 最大公約数
# ユークリッドの互除法
def my_gcd(a, b):
    if b == 0:
        return a
    else:
        return my_gcd(b, a%b)

c_gcd = A[0]
for a in A:
    c_gcd = my_gcd(c_gcd, a)

if c_gcd == 1:
    max_A = max(A)
    D = mae_syori(max_A)
    yakusu = set()
    ok = True
    for a in A:
        if a == 1: continue
        p_bunkai_result = p_bunkai(a)
        p_list = [p[0] for p in p_bunkai_result]
        for p in p_list:
            if p not in yakusu:
                yakusu.add(p)
            else:
                ok = False
        if not ok:
            break
    if ok:
        print('pairwise coprime')
    else:
        print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 133116
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		HashSet<String> hs = new HashSet<String>();
		for(int i = 0; i < n; i++){
		    hs.add(sc.next());
		}
		
		// 計算
		int result = 0;
		result = hs.size();
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 65992
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
/*
int solve(vector<bool>reach, vector<int>a_v, ll k){
    vector<int> city(1,1);
    int rep = 1;//移動回数
    int now = 1;
    int next = a_v[now-1];
    while(!reach[next-1]){
        now = next;
        city.push_back(now);
        reach[now-1] = true;
        next = a_v[now-1];
        rep++;
    }
    int i=0;
    while(city[i]!=next) i++;
    int j;
    if(i>k) j = city[i];
    else {
        k = k-i;
        int num;
        num = (k-i)%(rep-i);
        j = city[i+num];
    }
    return j;
}
*/

int solve(vector<bool>reach, vector<int>a_v, ll k){
    vector<int> city(1,1);
    int now = 1;
    int next = a_v[now-1];
    while (!reach[next-1])
    {
        now = next;
        next = a_v[now-1];
        reach[now-1] = true;
        city.push_back(now);
    }
    int i=0;
    while(city[i]!=next) i++;
    int j;
    if(i>k) j = city[k];
    else {
        k = k-i;
        int num;
        num = (k)%(city.size()-i);
        j = city[i+num];
    }
    return j;    
}

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<bool> reach(n, false);
    vector<int> a_v(n);
    rep(i,n) {
        cin >> a_v[i];
    }
    reach[0] = true;
    int a;
    a = solve(reach, a_v, k);
    cout << a <<endl;
}


Measured memory_bytes: 5952
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

void dfs(ll a, ll c, const vvll &e, vb &ald, map<P, ll> &col){
    ald[a] = true;
    ll n = 1;
    for(auto x: e[a]){
        if(!ald[x]){
            if(n == c){n++;}
            P g = mp(a, x), h = mp(x, a);
            if(col.find(g) == col.end()){
                col[g] = n;
            }
            if(col.find(h) == col.end()){
                col[h] = n;
            }
            dfs(x, n, e, ald, col);
            n++;
        }
    }
}

int main(){
    ll N; cin >> N;
    vvll e(N+1, vll(0));
    vvll m(N-1, vll(2));
    rep(i,0, N-1){
        ll a, b; cin >> a >> b;
        m[i][0] = a; m[i][1] = b;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    ll ma = 0;
    rep(i, 1, N+1){
        ma = max(ma, sz(e[i]));
    }
    vb ald(N+1, false);
    map<P, ll> col;
    dfs(1, 0, e, ald, col);
    prtl(ma);
    rep(i, 0, N-1){
        P b = mp(m[i][0], m[i][1]);
        prtl(col[b]);
    }
}

Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    double p[n];
   // float mul = 1.0;
    double dp[n + 1][n + 1];
    memset(dp,0.0,sizeof(dp));
    dp[0][0]= 1.0;
    for(int i=0;i<n;i++){
        cin >> p[i];
       // mul = mul * (1 - p[i])*1.0;
       dp[i+1][0] = dp[i][0]*(1-p[i])*1.0;
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            dp[i][j] = dp[i-1][j] * (1 - p[i-1])*1.0 + dp[i-1][j-1]*p[i-1]*1.0;
        }
    }
    double ans = 0.0;
    for(int i=(n+1)/2;i<=n;i++){
        ans += dp[n][i]*1.0;
    }
printf("%.10lf",ans);
//cout<<ans<<endl;
  
}

Measured memory_bytes: 70528
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid -left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++) L[i] = A[left + i];
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for ( k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p- 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if ( p < r) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q -1);
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);

    for (i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit ) stable = 0;
    }
    
    if (stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }
    
    return 0;
}


Measured memory_bytes: 5016
#include <iostream>
#include <queue>
#include <string>
using namespace  std;

typedef pair<string, int> PAIR;

void fnInput(int &rnMaxProc, int &rnQtm, queue<PAIR> &rqPPrc)
{
  cin >> rnMaxProc >> rnQtm;
  
  for (int i = 0; i < rnMaxProc; i++)
  {
    string sPrcNam;
    int nPrcTim;
    cin >> sPrcNam >> nPrcTim;
    rqPPrc.push(PAIR(sPrcNam, nPrcTim));
  }
}

void fnSchedule(int nQtm, queue<PAIR> &rqPPrc)
{
  int nTtlTim = 0;
  while (rqPPrc.size())
  {
    PAIR PProcess = rqPPrc.front(); rqPPrc.pop(); 
    if (PProcess.second > nQtm)
    {
      PProcess.second -= nQtm;
      rqPPrc.push(PProcess);
      nTtlTim += nQtm;
    }
    else
    {
      nTtlTim += PProcess.second;
      cout << PProcess.first << " " << nTtlTim << endl;
    }
  }
}

int main()
{
  int nMaxPrc, nQtm;
  queue<PAIR> qPPrc;
  
  fnInput(nMaxPrc, nQtm, qPPrc);
  fnSchedule(nQtm, qPPrc);

  return 0;
}

Measured memory_bytes: 4400
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}
struct UFTree {
    roots: Vec<usize>,
    ranks: Vec<usize>,
}

impl UFTree {
    fn new(num: usize) -> UFTree {
        let mut rs = vec![0; num];
        for i in 0..num {
            rs[i] = i;
        }

        UFTree {
            roots: rs,
            ranks: vec![1; num],
        }
    }

    fn find(&mut self, v: usize) -> Option<usize> {
        if self.roots.len() <= v {
            None
        }
        else {
            let vr = self.roots[v];

            if vr == v {
                Some(v)
            }
            else if let Some(r) = self.find(vr) {
                self.roots[v] = r;

                Some(r)
            }
            else {
                None
            }
        }
    }

    fn unite(&mut self, u: usize, v: usize) {
        if let (Some(ur), Some(vr)) = (self.find(u), self.find(v)) {
            if ur == vr {
                return;
            }

            if self.ranks[ur] < self.ranks[vr] {
                self.roots[ur] = vr;
            }
            else {
                self.roots[vr] = ur;

                if self.ranks[ur] == self.ranks[vr] {
                    self.ranks[ur] += 1;
                }
            }
        }
    }

    fn same(&mut self, u: usize, v: usize) -> bool {
        if let (Some(ur), Some(vr)) = (self.find(u), self.find(v)) {
            ur == vr
        }
        else {
            false
        }
    }
}

#[derive(Copy, Clone)]
struct E {
    u: usize,
    v: usize,
    cost: i64,
}

fn main() {
    let n = readln();

    let mut xys = vec![];
    let mut xys2 = vec![];

    for i in 0..n {
        let x: Vec<usize> = reads();

        xys.push((x[0], x[1], i));
        xys2.push((x[1], x[0], i));
    }

    xys.sort();

    let mut es = vec![];

    for i in 0..(n - 1) {
        let v1 = xys[i];
        let v2 = xys[i + 1];

        let e = E {u: v1.2, v: v2.2, cost: (v1.0 as i64 - v2.0 as i64).abs()};

        es.push(e);
    }

    xys2.sort();

    for i in 0..(n - 1) {
        let v1 = xys2[i];
        let v2 = xys2[i + 1];

        let e = E {u: v1.2, v: v2.2, cost: (v1.0 as i64 - v2.0 as i64).abs()};

        es.push(e);
    }

    es.sort_by(|&lhs, &rhs| {
        lhs.cost.cmp(&rhs.cost)
    });

    let mut uf = UFTree::new(n);
    let mut res = 0;

    for e in es {
        if !uf.same(e.u, e.v) {
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 21992
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
int main()
{
	int n,i;cin>>n;
	string s;
	map<string,int> cnt;
	for(i=0;i<n;i++)
	{
		cin>>s;
		cnt[s]++;
	}
	printf("AC x %d\n",cnt["AC"]);
	printf("WA x %d\n",cnt["WA"]);
	printf("TLE x %d\n",cnt["TLE"]);
	printf("RE x %d\n",cnt["RE"]);
}


Measured memory_bytes: 3732
#D
a,b=map(int,input().split())
#x>y
def gcd(x,y):
    if y==0:
        return x
    elif y==1:
        return 1
    else:
        return gcd(y,x%y)
c=gcd(a,b)
def f(n):
    s = []
    while n % 2 == 0:
        s.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            s.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        s.append(n)
    return s
d=f(c)
t=len(d)
count=0
if t!=0:
    count+=1
for i in range(t-1):
    if d[i]!=d[i+1]:
        count+=1
print(count+1)

Measured memory_bytes: 38512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,b,c;
    cin >> a >> b>> c;
    cout << min(c,b/a)<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N - 1; i++) cin >> C[i];
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += B[A[i] - 1];
        if(i > 0 && A[i - 1] + 1 == A[i]) sum += C[A[i - 1] - 1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
  double a, b, C, angleC, S, L, h;
  cin >> a >> b >> C;
  angleC = C*M_PI/180;
  S = a*b*sin(angleC)/2;
  L = a + b + sqrt(a*a+b*b-2*a*b*cos(angleC));
  h = b*sin(angleC);

  cout << fixed << setprecision(5)
       << S << endl
       << L << endl
       << h << endl;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 100000000000000
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////
ll n,q;

ll val[200005];
ll num[200005];
ll bt[200005];
vector<ll> vec[200005]{};

void bfs(ll u,ll d){
	ll k=0;
for(int i=0;i<vec[u].size();i++){
	if(d<num[vec[u][i]]){
		num[vec[u][i]]=d+1;
		k=1;
		bfs(vec[u][i],d+1);
	}
	
}
if(k==0){bt[u]=1;}
return;

}

void bfs2(ll u,ll v){
for(int i=0;i<vec[u].size();i++){
	if(num[u]<num[vec[u][i]]){
		val[vec[u][i]]+=v;
		bfs2(vec[u][i], val[vec[u][i]]);
	}
}
return ;

}



int main() {

cin>>n>>q;

rep(i, n){
	bt[i]=0;
	val[i]=0;
	num[i]=(ll)100000000;
}



rep(i,n-1){
	ll p,q;
	cin>>p>>q;
	vec[p].push_back(q);
	vec[q].push_back(p);
}

num[1]=0;
bfs((ll)1,(ll)0);



rep(i,q){
	ll p,r;
	cin>>p>>r;
	val[p]+=r;
}


bfs2(1,val[1]);


rep(i, n){
	cout<<val[i]<<" ";
}
cout<<endl;



}



Measured memory_bytes: 31360
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 7;

LL sum[maxn];
LL a[maxn];

int main() {
    int n;
    sd(n);
    rep(i,1,n) {
        slld(a[i]);
        sum[i] = (sum[i-1] + a[i]) % mod;
    }
    LL ans = 0;
    rep(i,1,n) {
        ans = (ans + (a[i] * (sum[n] - sum[i] + mod) % mod) % mod) % mod;
    }
    plld(ans);
    return 0;
}

Measured memory_bytes: 6876
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  if (a + b >= 10){
    cout << "error" << endl;
  }else{
    cout << a + b << endl;
  }
}


Measured memory_bytes: 3560
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    S = [input().rstrip() for i in range(N)]

    C = {'AC':0,'WA':0,'TLE':0,'RE':0}

    for i in range(N):
        C[S[i]] += 1

    print('AC x ',C['AC'])
    print('WA x ',C['WA'])
    print('TLE x ',C['TLE'])
    print('RE x ',C['RE'])



main()


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

namespace atcoder01a
{
    class Program
    {
        static void Main(string[] args)
        {
            string b =Console.ReadLine();
            if (b == "A")
            {
                Console.WriteLine("T");
            }
            else if (b == "C")
            {
                Console.WriteLine("G");
            }
            else if (b == "T")
            {
                Console.WriteLine("A");
            }
            else if (b == "G")
            {
                Console.WriteLine("C");
            }
        }
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }   
  vector<bool> vis(n);
  function<void(int)> dfs = [&](int source) {
    vis[source] = true;
    for (int to : adj[source]) {
      if (!vis[to]) {
        dfs(to);
      }
    }
  };
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {  
      ++res;
      dfs(i);
    }
  }
  cout << res - 1 << '\n';
  return 0;
}

Measured memory_bytes: 10060
n = int(input())
name = ''
l = 0
for i in range(1,99):
    if n - 26**i <= 0:
        l = i
        break
    else:
        n -= 26**i
n -= 1
for j in range(l):
    name = chr(ord('a') + n%26) + name
    n = n//26
print(name)

Measured memory_bytes: 9088
import java.util.Scanner;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        //System.out.println(N);
        double[] x = new double[N];
        String[] u = new String[N];
        for (int i = 0; i < N; i++) {
        	x[i] = sc.nextDouble();
        	u[i] = sc.next();
        }

        double ans = 0;
        for (int i = 0; i < N; i++) {
        	double ans2 = 0;
        	if (u[i].equals("JPY")) {
        		ans2 = x[i];
        	} else if (u[i].equals("BTC")) {
        		ans2 = x[i] * 380000.0;
        	}
        	//System.out.println(ans2);
        	ans += ans2;
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 23380
#include<stdio.h>


int main(){

  int N, i, K, P, W;

  scanf("%d", &N);

  for(i=0;i < N;i++){

    scanf("%d %d", &K, &P);

    if(K > P){

      W = K % P;

      if(W != 0)

	printf("%d\n", W);

      else

	printf("%d\n", P);
      
    }else
      
      printf("%d\n", K);

    
  }
    

  return 0;
  
}

Measured memory_bytes: 596
#include<stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(a<=b){
    if(c<=d){
      printf("%d\n",a+c);
    }else{
      printf("%d\n",a+d);
    }
  }else{
    if(c<=d){
      printf("%d\n",b+c);
    }else{
      printf("%d\n",b+d);
    }
  }
  
  return 0;
}

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

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }

    std::sort(l.begin(), l.end(), std::greater<int>());

    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += l[i];
    }

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


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

bool Solve(int n, const vector<int>& xs) {
  if (n == 1) {
    return false;
  }

  int even_count = 0;
  for (int x : xs) {
    if (x % 2 == 0) even_count++;
  }

  if (n % 2 == 0) {
    return even_count % 2 == 1;
  } else {
    if (even_count <= n - 2) {
      return even_count % 2 == 1;
    } else {
      vector<int> ys(n);
      for (int i = 0; i < n; i++) {
        if (xs[i] % 2 == 1) {
          if (xs[i] == 1) return false;
          ys[i] = xs[i] - 1;
        } else {
          ys[i] = xs[i];
        }
      }
      int d = ys[0];
      for (int i = 1; i < n; i++) {
        d = gcd(ys[i], d);
      }
      for (int i = 0; i < n; i++) {
        ys[i] /= d;
      }
      return !Solve(n, ys);
    }
  }
}

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

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

  bool ans = Solve(n, xs);
  if (ans) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

Measured memory_bytes: 12560
#include <iostream>
#include <vector>

static const int IINF = 1 << 30;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

int main() {
  // Input
  std::string S;
  int K;
  int N;
  std::cin >> S;
  std::cin >> K;
  N = S.length();

  // Initialization
  // auto dp = vectors<int>(1 + N + 1, 1 + N + 1, 1 + K + 1, -IINF);
  auto dp = vectors<int>(1 + N + 1, 1 + N + 1, 1 + K + 1, 0);

  // Initial condition
  // dp[0][0][0] = 0;

  // DP main
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      for (int k = 0; k <= K; ++k) {
        chmax(dp[i + 1][j][k], dp[i][j][k]);
        chmax(dp[i][j + 1][k], dp[i][j][k]);
        // chmax(dp[i + 1][j][k + 1], dp[i][j][k] + 1);
        // chmax(dp[i][j + 1][k + 1], dp[i][j][k] + 1);
        chmax(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1);
        if (i < N and k < N and S[i] == S[N - j - 1])
          chmax(dp[i + 1][j + 1][k], dp[i][j][k] + 1);
      }
    }
  }

  // Output
  int res = -1;
  // for (int k = 0; k <= K; ++k) {
  for (int i = 0; i <= N; ++i)
    chmax(res, 2 * dp[i][N - i][K]);
  for (int i = 0; i < N; ++i)
    chmax(res, 2 * dp[i][N - i - 1][K] + 1);
  // }

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 111104
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

class Matrix{
private:
    int m;
    int n;
public:
    vvll data;
    Matrix(int m, int n=1): m(m), n(n){
        auto ret = zeros(m, n);
        data = ret.data;
    }
    Matrix(vvll mat): data(mat), m(mat.size()), n(mat[0].size()){};
    static Matrix zeros(int m, int n=1){ return Matrix(vvll(m, vll(n)));};
    static Matrix ones(int m, int n=1){ return Matrix(vvll(m, vll(n, 1)));};

    void operator+=(const Matrix& other){REP(i, m) REP(j, n) data[i][j] += other.data[i][j];}
    bool operator>=(ll x) {REP(i, m) REP(j, n) {if (data[i][j] < x) return false;} return true;}
};

int main() {

    int N, M, X;
    cin >> N >> M >> X;

    vector<tuple<ll, Matrix>> V(N, tuple<ll, Matrix>{0, {M, 1}});
    REP(i, N) {
        cin >> get<0>(V[i]);
        REP(j, M) {
            cin >> get<1>(V[i]).data[j][0];
        }
    }

    ll ans = 1e20;
    bool flag = false;
    REP(i, (1 << N)) {
        ll ret = 0;
        Matrix skill(M);
        REP(j, N) {
            if (i & (1 << j)) {
                ret += get<0>(V[j]);
                if (ret >= ans) break;
                skill += get<1>(V[j]);
                if (skill >= X) {
                    flag = true;
                    chmin(ans, ret);
                    break;
                }
            }
        }
    }

    if (flag) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;i++)
#define rp(i,n) for(i=0;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

vl v[N];
ll dp[N][4];

void dfs(ll s, ll p)
{
    dp[s][1]=1, dp[s][2]=1;
    for(auto it:v[s])
        if(it!=p)
        {
            dfs(it, s);
            dp[s][1]=(dp[s][1]*(dp[it][1]+dp[it][2]))%mod;
            dp[s][2]=(dp[s][2]*dp[it][1])%mod; 
        }
    return;
}

int main()
{
    FIO;
    ll n,i,x,y;
    cin>>n;
    fr(i,n-1) cin>>x>>y, v[x].PB(y), v[y].PB(x);
    dfs(1,1);
    cout<<(dp[1][1]+dp[1][2])%mod<<endl;
    return 0;
}


Measured memory_bytes: 17792
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let x = read int
    let y = x / 100

    if 100 * y <= x && x <= 105 * y then printfn "1"
    else printfn "0"
    0 // return an integer exit code


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

int main(){
    int n;
    string s;
    int ans = 0;

    cin >> n >> s;
    for(int i = 0;i < n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
  int k;
  scanf("%d",&k);
  char str[1000];
  scanf("%s",str);
  
  int n=strlen(str);
  if(n<=k){
    printf("%s\n",str);
  }
  else{
    int i;
    for(i=0;i<k;i++){
      printf("%c",str[i]);
    }
    printf("...\n");
  }
  
  
  return 0;
}


Measured memory_bytes: 1628
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

h=int(input())
ans=0
now=1
while h:
    h//=2
    ans+=now
    now*=2

print(ans)

Measured memory_bytes: 66540
from collections import defaultdict
import bisect
def f():
    return []

d=defaultdict(f)
n=int(input())
a=list(map(int,input().split()))
x=[i+1+a[i] for i in range(n)]
y=[i+1-a[i] for i in range(n)]
for i in range(n):
    d[y[i]].append(i)

ans=0
for i in range(n):
    p=x[i]
    ans+=len(d[p])-bisect.bisect_right(d[p],i)
print(ans)

Measured memory_bytes: 139124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1<<29;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int N; cin >> N;
    int a[2][110] = {0};
    REP(i, 1, N + 1) cin >> a[0][i];
    REP(i, 1, N + 1) cin >> a[1][i];
    REP(i, 1, N + 1){
        a[0][i] += a[0][i - 1];
        a[1][i] += max(a[0][i], a[1][i - 1]);
    }
    cout << a[1][N] << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

li = [0]
char = 'R'
for i in S:
    n = len(li)
    if i == char:
        li[n-1] += 1
    else:
        li.append(1)
        char = i
n = len(li)
ans = []
for i in range(n//2):
    k = li[2*i] + li[2*i+1]
    for j in range(li[2*i] - 1):
        ans.append(0)
    if (k%2 == 0):
        ans.append(int(k/2))
        ans.append(int(k/2))
    else:
        if li[2*i]%2 == 0:
            ans.append(int(k//2))
            ans.append(int(k//2) + 1)
        else:
            ans.append(int(k//2) + 1)
            ans.append(int(k//2))
    for j in range(li[2*i+1] - 1):
        ans.append(0)

print(*ans)

Measured memory_bytes: 7156
from collections import Counter
N = int(input())
scounter = Counter([input() for _ in range(N)])
M = int(input())
tcounter = Counter([input() for _ in range(M)])

nums = []
for s in scounter.keys():
    nums.append(scounter[s] - tcounter[s])

max_num = max(nums)
print(max_num if max_num > 0 else 0)


Measured memory_bytes: 3436