akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>

using namespace std;
const int maxn = 1e7+5;
typedef long long ll;

map<int,int>mp;
int num[maxn];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    ll ans = 0;
    num[0] = 0;
    mp[0] = 1;
    for(int i=1; i<=n; i++)
    {
        int a;
        scanf("%d",&a);
//        if(a%m==0)
//            ans++;
        num[i] = (num[i-1] + a)%m;
//        if(num[i] == 0)
//            ans++;
        ans += mp[num[i]];
        mp[num[i]] ++;

    }

    printf("%lld\n",ans);


    return 0;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3
import numpy as np
stdin = open(0)

A = np.fromstring(stdin.read(), np.int64, sep=' ')[1:]
A = A[A % 2 == 0]
if np.all((A % 3 == 0) | (A % 5 == 0)):
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 21116
s = list(input())
l = [-1]
i = 0

while i < len(s):
    if s[i] == "<":
        l.append(l[i] + 1)
    if s[i] == ">":
        cnt = 0
        while s[i + cnt] == ">":
            if i + cnt == len(s) -1:
                cnt += 1
                break
            cnt += 1
        if l[i] < cnt:
            l.append(cnt)
        else:
            l.append(l[i] + 1)
        i += cnt
        cnt -= 1
        while cnt != -1:
            l.append(cnt)
            cnt -= 1
    i += 1
if s[len(s) -1] == "<":
    l.append(l[i] + 1)
del l[0]
ans = sum(l)
print(ans)

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int64_t sum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  double x=(double)sum/(4*M);
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)>=x){
      count++;
    }
  }
  if(count>=M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);

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

    int ans = 0;
    for(int bith = 0; bith < (1 << h); bith++){
        for(int bitw = 0; bitw < (1 << w); bitw++){

            int cntb = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(c[i][j] == '#'){
                        if(((bith >> i) & 1) == 0 && ((bitw >> j) & 1) == 0){
                            cntb++;
                        }
                    }
                }
            }
            if(cntb == k) ans++;

        }
    }
    cout << ans << endl;
    return 0;
}

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



char slide(char ch, int dif) {
  if( ! isalpha(ch) ) return ch;

  int n = ch - 'a';
  n = (n + dif ) % 26;
  return 'a' + n;
}

int main() {
  for(string line; getline(cin, line); ){
  
  for(int dif = 0; dif < 26; dif++) {
    string str = line;
    
    for(int i = 0; i < (int)str.size(); i++) 
      str[i] = slide( str[i], dif);

    if( str.find("the") != string::npos ||
        str.find("this") != string::npos ||
        str.find("that") != string::npos ) {
      cout << str << endl;
      break;
    }
  }
    
} 
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

int main(){
    int N,M;
    ll L;
    cin>>N>>M>>L;
    vector<pair<int,ll>> edge[300];
    int a,b;
    ll c;
    rep(i,M){
        cin>>a>>b>>c;
        a--;b--;
        edge[a].push_back(make_pair(b,c));
        edge[b].push_back(make_pair(a,c));
    }
    ll d[300][300];
    rep(i,N) rep(j,N) d[i][j] = -1;
    rep(start,N){
        priority_queue<pair<pair<int,ll>,int>,vector<pair<pair<int,ll>,int>>,greater<pair<pair<int,ll>,int>>> q;
        q.push(make_pair(make_pair(0,-L),start));
        int num = 0;
        while(!q.empty()){
            pair<pair<int,ll>,int> p = q.top();
            q.pop();
            if(d[start][p.second]!=-1) continue;
            d[start][p.second] = p.first.first;
            num++;
            if(num==N) break;
            rep(i,edge[p.second].size()){
                pair<int,ll> hoge = edge[p.second][i];
                if(d[start][hoge.first]!=-1) continue;
                if(-p.first.second>=hoge.second) q.push(make_pair(make_pair(p.first.first,p.first.second+hoge.second),hoge.first));
                else if(hoge.second>L) continue;
                else q.push(make_pair(make_pair(p.first.first+1,-L+hoge.second),hoge.first));
            } 
        }
    }

    int Q;
    cin>>Q;
    int s,t;
    rep(i,Q){
        cin>>s>>t;
        s--;t--;
        cout<<d[s][t]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

int a[100005];
int main()
{

    int n,L,R;
    while(scanf("%d",&n)==1)
    {
        int maxn=-1;
        memset(a,0,sizeof(a));
        while(n--)
        {
            scanf("%d%d",&L,&R);
            if(L>maxn) maxn=L;
            if(R>maxn) maxn=R;
            for(int i=L;i<=R;i++)
            {
                a[i]=1;
            }
        }
        int sum=0;
        for(int i=1;i<=maxn;i++)
        {
            if(a[i]==1)
                sum++;
        }
        printf("%d\n",sum);

    }



    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 100010;
const LL INF = 100000000000000LL;
const LL mod = 1e9 + 9;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)

int n;
int sum[maxn];

void init() {
    sum[0] = 0;
    for(int i = 1;i < maxn;i++) {
        if(i < 10) sum[i] = i;
        else {
            sum[i] = i % 10 + sum[i / 10];
        }
    }
}

void solve() {
    int ans = 1e9;
    for(int i = 1;i < n;i++) {
        int a = i, b = n - i;
        ans = min(ans, sum[a] + sum[b]);
    }
    cout << ans << endl;
}

int main() {
	int t = 1;
	init();
	while(~scanf("%d",&n)) {
		solve();
	}/*
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;*/
    return 0;
}


Measured memory_bytes: 640
#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 rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
    boost;
    ll n,i,j,x,t;
    char c;
    cin>>c;
    c++;
    cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y,ans=0;
    cin>>n>>x>>y;
    while(n--){
        int a,b;
        cin>>a>>b;
        if(a>=x&&b>=y)
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
char s[100][100];
int d[8][2]={-1,-1,0,-1,1,-1,-1,0,1,0,-1,1,0,1,1,1};
int main(void)
{
     int i,j,k,n,m,a,b,c;
     scanf("%d%d",&n,&m);
     for(i=0;i<n;i++)
     {
          scanf("%s",s[i]);
     }
     for(i=0;i<n;i++)
     {
          for(j=0;j<m;j++)
          {
               if(s[i][j]=='#')
                    printf("%c",s[i][j]);
               else
               {
                    k=0;
                    for(int ii=0;ii<8;ii++)
                    {
                         int x=i+d[ii][0];
                         int y=j+d[ii][1];
                         if(x>=0&&x<n&&y>=0&&y<m)
                         {
                              if(s[x][y]=='#')
                                   k++;
                         }
                    }
                    printf("%d",k);
               }
          }
          printf("\n");
     }
     return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();

    let mut dp = [0; 4];
    dp[0] = 1;
    for c in s.chars() {
        match c {
            'A' => dp[1] += dp[0],
            'B' => dp[2] += dp[1],
            'C' => dp[3] += dp[2],
            '?' => {
                for i in (1..4).rev() {
                    dp[i] = 3 * dp[i] + dp[i - 1];
                }
                dp[0] = 3 * dp[0];
            }
            _ => unreachable!(),
        }
        for i in 0..4 {
            dp[i] %= 1_000_000_007u64;
        }
    }
    println!("{}", dp[3]);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
    int n;
    cin >> n ;
    vector<double>a(n),b(n-1);
    for(int i=0; i<n; i++){
        cin>> a.at(i);
    }
    sort(a.begin(),a.end());
    b.at(0)=(a.at(0)+a.at(1))/2;
    for(int i=2; i<n; i++){
        b.at(i-1)=(a.at(i)+b.at(i-2))/2;
    }
    cout << b.at(n-2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  int64_t Q=1000000007;
  vector<int64_t> p(N);
  vector<int64_t> q(N);
  p[0]=2;
  q[0]=1;
  for(int i=1;i<N;i++){
    if(S[i]=='1'){
      p[i]=(p[i-1]*2)%Q;
      q[i]=(p[i-1]+q[i-1]*3)%Q;
    }
    else{
      p[i]=p[i-1];
      q[i]=(q[i-1]*3)%Q;
    }
  }
  cout<<(p[N-1]+q[N-1])%Q<<endl;
}



Measured memory_bytes: 5060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

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

    vector<int> H;
    H.resize(N);
    rep(i,N) cin >> H[i];

    vector<int> memo;
    memo.resize(N);
    rep(i,N) memo[i] = i;

    rep(i,M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(H[a] < H[b]){
            memo[a] = b;
        }
        else if(H[a] > H[b]){
            memo[b] = a;
        }
        else{
            memo[a] = b;
            memo[b] = a;
        }
    }

    int cnt = 0;
    rep(i,N){
        if(memo[i]==i) cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3996
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct TopologicalSort {

    vector< int > order;
    vector< int > degree;
    vector< vector< int > > G;
    TopologicalSort (int n) : order(n,-1), degree(n,0), G(n) {}

    void add_edge(int from, int to) {
        G[from].push_back(to);
        degree[to]++;
    }

    bool build() {
        priority_queue< int, vector< int >, greater< int > > que;
        for (int i = 0; i < G.size(); i++) {
            if (degree[i] == 0) {
                que.push(i);
            }
        }
        int k = 0;
        while (!que.empty()) {
            int v = que.top();
            que.pop();
            order[v] = k++;
            for (int i = 0; i < G[v].size(); i++) {
                if (--degree[G[v][i]] == 0) {
                    que.push(G[v][i]);
                }
            }
        }
        for (int i = 0; i < G.size(); i++) {
            if (order[i] < 0) return false;
        }
        return true;
    }

    int operator [] (int n) {
        return order[n];
    }

};

const int INF = 1e9;
int N;
int A[1010][1010];
map<pair<int,int>, int> trans;
vector<int> G[1000010];
int memo[1000010];

int dfs (int v)
{
    if (memo[v] < INF) {
        return memo[v];
    }
    if (G[v].size() == 0) {
        return memo[v] = 0;
    }
    int ret = 0;
    REP(i,G[v].size()) {
        ret = max(ret, dfs(G[v][i]));
    }
    return memo[v] = ret + 1;
}

int main ()
{
    scanf("%d", &N);
    REP(i,N) REP(j,N - 1) scanf("%d", A[i] + j);

    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            trans[make_pair(i, j)] = 0;
        }
    }

    int cnt = 0;
    for (auto &x: trans) {
        x.second = cnt++;
    }

    TopologicalSort inst(1000010);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 2; j++) {
            int a = i + 1;
            int b = A[i][j];
            int c = A[i][j + 1];
            int from = trans[make_pair(min(a, b), max(a, b))];
            int to   = trans[make_pair(min(a, c), max(a, c))];
            inst.add_edge(from, to);
            G[from].push_back(to);
        }
    }

    if (!inst.build()) {
        cout << -1 << endl;
        return 0;
    }

    fill(memo, memo + 1000010, INF);
    for (int i = 0; i < trans.size(); i++) {
        dfs(i);
    }

    int ans = 0;
    for (int i = 0; i < trans.size(); i++) {
        ans = max(ans, memo[i]);
    }

    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 125432
n=int(input())
s=input()
a=0
for i in range(1,n):
    x=list(set(s[:i]))
    y=s[i:]
    k=0
    for j in range(len(x)):
        if x[j] in y:
            k+=1
    a=max(a,k)
print(a)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long lol;
lol gcd(lol a,lol b);
lol lcm(lol a,lol b);
int main(){
    lol n;
    cin>>n;
    vector<lol> t(n+10,1);
    for(lol i=0;i<n;i++){
        cin>>t[i];
    }
    lol ans=lcm(t[0],t[1]);
    for(lol i=2;i<n;i++){
        ans=lcm(ans,t[i]);
    }
    cout<<ans<<"\n";
    return(0);
}

lol gcd(lol a,lol b){
    while(b!=0){
        lol r=a%b;
        a=b;
        b=r;
    }
    return(a);
}

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

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

d = 60
dp = [[-1]*N for _ in range(d+1)]
for i in range(N):
    dp[0][i] = a[i]-1

for i in range(d):
    for j in range(N):
        dp[i+1][j] = dp[i][dp[i][j]]

ans = 0

for i in range(d):
    if K & (1<<i):
        ans = dp[i][ans]

print(ans+1)




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

int main() {
    string s, t;
    char a = 'a';
    char b = 'b';
    char c = 'c';
    char d = 'd';
    char e = 'e';
    char f = 'f';
    char g = 'g';
    char h = 'h';
    char i = 'i';
    char j = 'j';
    char k = 'k';
    char l = 'l';
    char m = 'm';
    char n = 'n';
    char o = 'o';
    char p = 'p';
    char q = 'q';
    char r = 'r';
    char ss = 's';
    char tt = 't';
    char u = 'u';
    char v = 'v';
    char w = 'w';
    char x = 'x';
    char y = 'y';
    char z = 'z';
    cin >> s;
    cin >> t;
    if (t == s + a || t == s + b || t == s + c || t == s + d || t == s + e || t == s + f || t == s + g || t == s + h || t == s + i || t == s + j || t == s + k || t == s + l || t == s + m || t == s + n || t == s + o || t == s + p || t == s + q || t == s + r || t == s + ss || t == s + tt || t == s + u || t == s + v || t == s + w || t == s + x || t == s + y || t == s + z) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int main(){
  int n;
  cin>>n;
  vector<int>A(n);
  rep(i,n)cin>>A[i];//ここまで入力
  
  vector<int>ans(n);//答の配列
  rep(i,n)ans[A[i]-1]=i+1;
//左辺：与えられるA[i]は到着時の人数で1始まり⇒1引いて0始まりへ
//右辺：iは0始まりで、求めたいのは順番なので1足す
  rep(i,n){//出力、縦に出る
    cout<<ans[i]<<endl; 
  }  
  return 0;
}


Measured memory_bytes: 1664
<?php
list($A, $B, $M) = ints();
$a = ints();
$b = ints();
$min = min($a)+min($b);
for($i = 0; $i < $M; $i++){
    list($x, $y, $c) = ints();
    chmin($min, $a[$x-1]+$b[$y-1]-$c);
}
echo $min;


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 20976
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
vector<int> to[maxn];
int lim;
bool can;
int solve(int cur, int par){
	vector<int> f;
	for(int nxt : to[cur]){
		if(nxt == par) continue;
		f.push_back(solve(nxt, cur));
	}
	if(f.size() % 2 == 0) f.push_back(0);
	sort(f.begin(), f.end());
	int len = f.size();
	int lo = 0, hi = len - 1, ans = -1;
	while(lo <= hi){
		int mid = (lo + hi)>>1;
		auto get = [&](int x){
			if(x >= mid) x++;
			return f[x];
		};
		bool ok = true;
		for(int i = 0; i < (len - 1)/2; i++){
			int ri = (len - 2) - i;
			ok &= get(i) + get(ri) <= lim;
		}
		if(ok) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	if(ans == -1){
		can = false;
		return 0;
	}
	return f[ans] + 1;
}
int main(){
	int n; cin >> n;
	for(int i = 0; i < n - 1; i++){
		int a, b; cin >> a >> b; a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int A = 0;
	for(int i = 0; i < n; i++) A += to[i].size()%2;
	int leaf = -1;
	for(int i = 0; i < n; i++) if(to[i].size() == 1) leaf = i;
	assert(~leaf);
	int lo = 1, hi = n - 1, ans = n;
	while(lo <= hi){
		int mid = (lo + hi)>>1;
		lim = mid;
		can = true;
		if(solve(leaf, -1) <= lim + 1 && can){
			ans = mid;
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	cout << A/2 << " " << ans << endl;
	return 0;
}


Measured memory_bytes: 18176
def combinations(coin, total):
    dp = [int(i % coin[0] == 0) for i in range(total + 1)]
    for coin in coin[1:]:
        for i in range(coin, total+1):
            dp[i] += dp[i-coin]
    return dp[-1]

coin = [100, 101, 102,103,104,105]
total = int(input())
if total>615*1e6:
    print("0")
else:
    if combinations(coin,total)==0:
        print("0")
    else:
        print("1")


Measured memory_bytes: 7448
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int INF = 1e9;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/

int n, m, q;
int ans = 0;
vi a(51), b(51), c(51), d(51), g(11); 

void solve (int cnt, int now) {
	if (cnt == n) {
		int count = 0;
		for (int i = 0; i < q; ++i) {
			if (g[b[i]] - g[a[i]] == c[i]) {
				count += d[i];
			}
		}
		ans = max (ans, count);
		return ;
	}
	for (int i = now; i <= m; ++i) {
		g[cnt] = i;
		solve (cnt + 1, i);
	}
}


int main(){
	FASTIO
	
	cin >> n >> m >> q;
	
	int aa, bb, cc, dd;
	
	for (int i = 0; i < q; ++i) {
		cin >> aa >> bb >> cc >> dd;
					aa--, bb--;
		a[i] = aa, b[i] = bb, c[i] = cc, d[i] = dd;
	}
	
	solve (0, 1);
	
	cout << ans << endl;
	
    return 0;
}

/*

*/


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

int main(void){
    ll x;
    cin>>x;
    if(x==0)cout<<'1'<<endl;
    else cout<<'0'<<endl;
    
}


Measured memory_bytes: 3544
module app;

import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto input = parseInput();
	real temp = 0;
	foreach (r; input.a)
	{
		temp += 1.0 / r;
	}
	
	writefln("%.20f", 1.0 / temp);
}

struct Input
{
	uint n;
	real[] a;
}

Input parseInput()
{
	Input input = void;
	input.n = readln().strip().to!uint;
	input.a = readln().strip().split().map!(s => s.to!real).array;
	return input;
}


Measured memory_bytes: 256
s = input()
mod = 10**9+7
dp = [[0]*13 for i in range(len(s))]
if s[0] != '?':
  dp[0][int(s[0])] = 1
else:
  for i in range(10):
    dp[0][i] = 1
for i in range(1,len(s)):
  if s[i] != '?':
    for j in range(13):
      t = (j*10+int(s[i]))%13
      dp[i][t] += dp[i-1][j]
      dp[i][t] = dp[i][t]%mod
  else:
    for k in range(10):
      for j in range(13):
        t = (j*10+k)%13
        dp[i][t] += dp[i-1][j]
        dp[i][t] = dp[i][t]%mod
print(dp[len(s)-1][5]%mod)

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

int main(){
    int a,b,c,x;
    int sum = 0, counter = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                sum = 500 * i + 100 * j + 50 * k;
                if (sum == x){
                    counter++;
                }
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import numpy as np

### TESTCASE
test = ""
#test = \
"""
4 6
#..#..
.....#
....#.
#.#...
ans 8
"""

"""
8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#
ans 13
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
####### MAIN

h, w = map(int, input2().split())
s = [["#"] * (w+1)]
s += [list("#" + input2()) for _ in range(h)]
s = np.array(s)

hs = np.zeros((h+1, w+1), dtype="int64")
ws = np.zeros((h+1, w+1), dtype="int64")

for hi in range(1, h+1):
    htmp = np.array(s[hi] == ".", dtype="int")
    hs[hi] = hs[hi-1] * htmp + htmp
    
for hj in range(h-1, 0, -1):
    hs[hj] = np.maximum(hs[hj], np.minimum(hs[hj+1], hs[hj] * hs[hj+1]))
    
for wi in range(1, w+1):
    wtmp = np.array(s[:, wi] == ".", dtype="int")
    ws[:, wi] = ws[:, wi-1] * wtmp + wtmp
    
for wj in range(w-1, 0, -1):
    ws[:, wj] = np.maximum(ws[:, wj], 
      np.minimum(ws[:, wj+1], ws[:, wj] * ws[:, wj+1]))
    
print(np.max(ws + hs) - 1)    
    
    



Measured memory_bytes: 141792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AWheresSnuke {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            for (int i = 1; i <= h; i++) {
                for (int j = 0; j < w; j++) {
                    String s = in.next();
                    if (s.equals("snuke")) {
                        out.println((char) (j + 'A') + "" + i);
                        return;
                    }
                }
            }

        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public void close() {
        }

    }
}



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

int main(){
    ll a,b,c[1001],k=0,sum=0;
    cin >> a>>b;
    rep(i,a){
        cin >> c[i];
        sum+=c[i];
    }
    rep(i,a){
        if(c[i]*4*b>=sum){
            k++;
        }
    }
    if(k>=b){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){


    string s;
    cin >> s;

    int flag = 1;
    rep(i,s.size()){
        if (i%2==1 && s[i] == 'R') flag = 0;
        else if (i%2 == 0 && s[i] == 'L') flag = 0;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    

}





//              g++ -std=c++1z


Measured memory_bytes: 384
[K,N]= [int(x) for x in input().split()]

lists = [int(x) for x in input().split()]
lists.sort()
sor = []
for i in range(N-1):
    sor.append(lists[i+1]-lists[i])
sor.append(K-lists[N-1]+lists[0])
print(K-max(sor))

Measured memory_bytes: 24636
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

h1,m1,h2,m2,k = MI()
res = (h2-h1)*60
res += m2-m1
print(res-k)


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

int n, a[80];
ll m = 1000, s = 0;

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

	for (int i = 0; i < n; ++i) {
		int j = i;
		while (j < n - 1 && a[j] <= a[j + 1])
			++j;
		s = m / a[i];
		m %= a[i];
		m += a[j] * s;
		i = j;
	}
	cout << m << endl;
}


Measured memory_bytes: 3632
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll,int>> factor(ll x) {
        vector<pair<ll,int>> res;
        for (int p : primes) {
            int y = 0;
            while (x%p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p,y);
        }
        if (x != 1) res.emplace_back(x,1);
        return res;
    }
};

int dp[30][80];

int main() {
    int n;
    cin >> n;
    Sieve sieve(n);
    map<int,int> mp;
    for (int i = 1; i <= n; i++) {
        vector<P> a = sieve.factor(i);
        for (auto p : a) {
            mp[p.first] += p.second;
        }
    }
    vector<int> d;
    d = sieve.primes;
    
    dp[0][1] = 1;
    rep(i,d.size()) {
        int x = mp[d[i]];
        for (int j = 1; j <= 75; j++) {
            if (dp[i][j] == 0) continue;
            for (int k = 0; k <= x; k++) {
                if (j*(k+1) > 75) break;
                dp[i+1][j*(k+1)] += dp[i][j];
            }
        }
    }
    cout << dp[d.size()][75] << endl;
    return 0;
}

Measured memory_bytes: 3520
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	int N;
	int h[100010]={};
	int dp[100010]={};
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> h[i];
	
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<N;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	
	cout << dp[N-1] << endl;
	return 0;
}



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

int f[1000000] = {};

int fib(int n){
    if(n == 1 || n == 0){
        return f[n] = 1;
    }
    if(f[n]){
        return f[n];
    }
    return f[n] = fib(n - 2) + fib(n - 1);
}

int fib2(int n){
    int ff[100000] = {};
    ff[0] = 1;
    ff[1] = 1;
    for(int i = 2; i <= n; i++){
        ff[i] = ff[i-2] + ff[i-1];
    }
    return ff[n];
}

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

    cout << fib2(n) << endl;
    return 0;
}


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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;


int main(){
    int n;
    ll k;
    cin >> n >> k;
    map<int ,int > tenso;
    for(int i=1;i<=n;i++){
        int a;
        cin >> a;
        tenso[i]=a;
    }
    int loopcount = 1;
    int temp=1;
    vb machi(n+1,false);
    machi[1]=true;
    int loopfirst;
    //cout << "kanikani" << endl;
    while(1){
        temp=tenso[temp];
        if(machi[temp]){
            loopfirst=temp;
            break;
        }
        machi[temp]=true;
        loopcount++;       
        //cout << temp << endl;
    }
    //cout << "loopcont" << loopcount << endl;

    int toloopfirst=0;
    temp=1;
    while(1){
        if(temp==loopfirst) break;
        toloopfirst++;
        temp=tenso[temp];
    }
    //cout << "loopfirst " << loopfirst  << endl;

    int ans=1;
    if(k<toloopfirst){
        for(int i=0;i<k;i++){
            ans=tenso[ans];
        }
        cout << ans << endl;
        return 0;
    }
    //cout << "toloopcount" << toloopfirst << endl;
    int place;
    place=(k-toloopfirst)%(loopcount-toloopfirst);
    ans=loopfirst;
    for(int i=0;i<place;i++){
        ans=tenso[ans];
    }
    //cout << " kanikanikani 3" << endl;

    cout << ans << endl;
}

Measured memory_bytes: 13024
//package atcoder;
import java.util.*;
import java.lang.Math.*;
class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		double sum=0;
		for(int i=1;i<=n;i++)
		{
			int j=i;
			int x=0;
			while(j<k)
			{
				j=j*2;
				x++;
			}
			sum=sum +(double)((1/(double)n)*(Math.pow((1/(double)2),x)));
		}
		System.out.printf("%.12f",sum);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  int n;
  cin>>n;
  long long a[n],b[n];
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  bool balanced[n]={};
  //a[i]>b[i]なるb[i]に対して+1する操作を先にやってしまいたい。
  long long cnt = 0;
  REP(i,n){
    if(a[i]>b[i]){
      cnt += a[i] - b[i];
      balanced[i] = true;
    }else if(a[i]==b[i]){
      balanced[i] = true;
    }else{
      continue;
    }
  }
  //以後a[i]<b[i]となっているiについて扱う
  long long cnt2=0;
  REP(i,n){
    if(balanced[i])continue;
    cnt2 += (b[i]-a[i])/2;
  }
  
  if(cnt<=cnt2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
    
  return 0;
}


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

int main()
{
    int a,b,c,k,t;
    int ans=0;
    cin>>a>>b>>c;
    cin>>k;
    ans=a+b+c;
    t=max(max(a,b),c);
    ans-=t;
    while(k--)
    {
        t=t*2;
    }
    ans+=t;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b, box;
	while (scanf("%d %d", &a, &b))
	{
		if(a > b)
		{
			box = b;
			b = a;
			a = box;	
		
	    }
		else if(a == b && b == 0)
		{
			break;
		}
		printf("%d %d\n", a, b);
	}
	return 0;	
}


Measured memory_bytes: 1972
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int ans=0;
        string w;
        cin>>w;
        transform(w.begin(), w.end(), w.begin(), ::toupper);
        for(;;){
                string chk;
                cin>>chk;
                if(chk=="END_OF_TEXT")break;
                transform(chk.begin(), chk.end(), chk.begin(), ::toupper);
                if(chk==w)ans+=1;
        }
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int main(){
    int num,i;
    cin >> num;
    vector<long int> n(87);
    n.at(0) = 2LL;
    n.at(1) = 1LL;
    for (i = 2;i <= num;i++){
        n.at(i) = n.at(i-1) +n.at(i-2);
    }
    cout << n.at(num) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <algorithm>
#include <utility>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;


#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> f,p;
	for(int i = 0; i < n; i++){
		f.push_back({});
		for(int j = 0; j < 10; j++){
			int a;
			cin >> a;
			f[i].push_back(a);
		}
	}
	for(int i = 0; i < n; i++){
		p.push_back({});
		for(int j = 0; j < 11; j++){
			int a;
			cin >> a;
			p[i].push_back(a);
		}
	}

	ll maxim = -INF;
	for(int i = 1; i <= 1023; i++){
		ll sum = 0;
		for(int j = 0; j < p.size(); j++){
			int opent = 0;
			for(int k = 0; k < f[j].size(); k++){
				if((i & (1 << k)) >= 1)
					opent += f[j][k];
			}
			sum += p[j][opent];
		}
		maxim = max(maxim,sum);
	}

	cout << maxim << '\n';



}



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

using namespace std;

using ll = long long;

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

    int n, a;

    cin >> n >> a;
    n %= 500;
    if (n <= a) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()

# 隣接リストを作成(key:b, val:a)
edges = []
for _ in range(m):
    ai, bi, ci = li()
    ai -= 1
    bi -= 1
    edges.append((ai, bi, ci))

# ベルマンフォード
dist = [[-10**18]*n for _ in range(2*n+3)]
for i in range(2*n+2):
    dist[i][0] = 0

ans = -10**18
chk = -10**18

for i in range(2*n+2):
    for ai, bi, ci in edges:
        dist[i+1][bi] = max(dist[i+1][bi],
                            dist[i][bi],
                            dist[i][ai] + ci)
    if i == n:
        ans = dist[i][n-1]
        
    elif i == 2*n+1:
        chk = dist[i][n-1]
        
print(ans if ans >= chk else "inf")

Measured memory_bytes: 58864
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N
point=1
m,l=0,0
if K>N:
    for i in range(N):
        if B[point-1]==0:
            B[point-1]=i+1
            point=A[point-1]
        else:
            m=i+1-B[point-1]
            l=B[point-1]
            break
    if m!=0:
        m=(K-l)%m
    else:
        m=N
else:
    m=K
ans=1
for i in range(l+m):
    ans=A[ans-1]
 
print(ans)

Measured memory_bytes: 32380
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    
    cin >> a >> b;
    
    cout << "a" ;
    if(a > b){
        cout << " > ";
    }else if(a < b){
        cout << " < " ;
    }else{
        cout <<  " == ";
    }
    cout << "b" << endl;
    
    return 0;
}


Measured memory_bytes: 3108
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			final int n = sc.nextInt();
			final int r = sc.nextInt();
			
			int[] array = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = i;
			}
			
			for(int i = 0; i < r; i++){
				
				int c = sc.nextInt();
				
				LinkedList<Integer> A = new LinkedList<Integer>();
				LinkedList<Integer> B = new LinkedList<Integer>();
				LinkedList<Integer> C = new LinkedList<Integer>();
				
				for(int j = 0; j < n; j++){
					if(j <= (n / 2 - 1)){
						B.addLast(array[j]);
					}else{
						A.addLast(array[j]);
					}
				}
				
				while(!A.isEmpty() || !B.isEmpty()){
					int size = A.size();
					for(int j = 0; j < Math.min(c, size); j++){
						C.addLast(A.poll());
					}
					
					size = B.size();
					for(int j = 0; j < Math.min(c, size); j++){
						C.addLast(B.poll());
					}
				}
				
				int index = 0;
				for(int num : C){
					array[index++] = num;
				}
			}
			
			
			System.out.println(array[n - 1]);
		}
	}

}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;
const int mod = 1e9 + 7;

using namespace std;

int main(void) {
	long double a, b; cin >> a >> b;

	printf("%lld\n", (ll)floor(a * b));

	return 0;
}

Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {

	static int N,W;
	static int[][] P;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		W = sc.nextInt();
		P = new int[N+1][3];

		for (int i=1; i <= N; i++) {
			P[i][1] = sc.nextInt();
			P[i][2] = sc.nextInt();
		}
		sc.close();

		long[][] dp = new long[N+1][W+1];

		for(int i = 1 ; i <= N ; i++){
			for(int j = 1 ; j <= W ; j++){

				if(j < P[i][1]){
					dp[i][j] = dp[i-1][j];
				}
				else{
					dp[i][j] = Math.max(dp[i-1][j-P[i][1]] + P[i][2], dp[i-1][j]);
				}

			}
		}

		/*
		for(int i = 0 ; i < N+1 ; i++){
			for(int j = 0 ; j < W+1; j++){
				System.out.print(dp[i][j]+",");
			}
			System.out.print(" ");
		}
		*/
		System.out.println(dp[N][W]);
	}
}


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

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

  int64_t N, T;
  cin >> N >> T;
  pair<int64_t, int64_t> P[N];
  rep(i,N){
    cin >> P[i].first >> P[i].second;
  }
  sort(P, P+N);
  int64_t ans = 0;
  int64_t dp[N+1][T] = {};
  for(int i=1;i<=N;i++){
    for(int j=1;j<T;j++){
      ans = max(ans, dp[i-1][j] + P[i-1].second);
      if(P[i-1].first > j){
        dp[i][j] = dp[i-1][j];
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-P[i-1].first] + P[i-1].second);
      }
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 70656
package main

import "fmt"

func main() {

	var H, W int

	fmt.Scan(&H, &W)

	prod := H * W
	if H < 2 || W < 2 {
		fmt.Println(1)
	} else if prod%2 == 0 {
		fmt.Println(prod / 2)
	} else {
		fmt.Println(prod/2 + 1)
	}

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define maxn 200010
char c[maxn];
int cnt[2][maxn];
int main()
{
        int n;scanf("%d",&n);
        int ans=maxn;
        scanf("%s",c+1);
        for(int i=1;i<=n;i++)
        {
                cnt[0][i]=cnt[0][i-1]+(c[i]=='.');
                cnt[1][i]=cnt[1][i-1]+(c[i]=='#');
        }
//      for(int i=1;i<=n;i++)printf("%d ",cnt[0][i]);puts("");
//      for(int i=1;i<=n;i++)printf("%d ",cnt[1][i]);puts("");
        for(int i=0;i<=n;i++)
        {
                ans=min(ans,(i-cnt[0][i])+(n-i-(cnt[1][n]-cnt[1][i])));
        }
        printf("%d\n",ans);
        return 0;
}

Measured memory_bytes: 2048