akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const long long mod = 1e9 + 7;
const ll INF = 1000000000000000;

int main(){
  int N;
  ll  W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<int> v(N);
  rep(i, N){
    cin >> w[i] >> v[i];
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(100001, INF));
  dp[0][0] = 0;
  for (int i = 1; i < N + 1; i++) {
    for (int j = 0; j < 100001; j++){
      if(j - v[i-1] >= 0){
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i-1]] + w[i-1]);
      }else {
        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      }
    }
  }
  int ans = 100000;
  while(dp[N][ans] > W)ans--;
  cout << ans << endl;
}

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<lli, lli>
#define ps pair<double, string>
#define pib pair<pi, bool>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 13
#define MAXL 10001
#define mod 1000000007

int n, m, x;
int ans;
vector<int> costs;
int mat[MAXN][MAXN];

void solve(int i, int sum, vector<int> skills)
{
  if (i == n)
  {
    bool can = true;
    for (auto const &j : skills)
      if (j < x)
        can = false;
    if (can)
      ans = min(ans, sum);
    return;
  }
  solve(i + 1, sum, skills); // nao compra
  for (int j = 0; j < m; j++)
    skills[j] += mat[i][j];
  solve(i + 1, sum + costs[i], skills); // compra
}
signed main()
{
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++)
  {
    int c;
    cin >> c;
    costs.pb(c);
    for (int j = 0; j < m; j++)
      cin >> mat[i][j];
  }
  ans = INT_MAX;
  vector<int> skills(m, 0);
  solve(0, 0, skills);
  (ans == INT_MAX) ? cout << "-1\n" : cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int cnt[1000009];

void solve() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n - 1) cin >> a[i];
	sort(all(a));
	rep(i, 0, n - 1) {
		if (cnt[a[i]] != 0) {
			cnt[a[i]] = 2;
			continue;
		}
		for (int j = 1; j * a[i] <= a[n - 1]; ++j) {
			cnt[a[i]*j]++;
		}
	}
	int ans = 0;
	rep(i, 0, n - 1) {
		if (cnt[a[i]] == 1)
			ans++;
	}
	cout << ans;
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

Measured memory_bytes: 12524
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
    string a, b;
    cin >> a >> b;
    int r = 0;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] != b[i])r++;
    }
    cout << r << endl;
    return 0;

}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define oo int(1e9)
using namespace std;
int n, k;

int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
	cin >> n;
	vector<vector<int>> vac,dp;
	vac.resize(n, vector<int> (3));
	dp.resize(n, vector<int> (3));
	for (int i = 0; i < n; i++) cin >> vac[i][0] >> vac[i][1] >> vac[i][2];
	dp[0] = vac[0];
	for (int i = 1; i < n; i++)
	    for (int j = 0; j < 3; j++)
	        for (int k = 0; k < 3; k++)
	            if (k != j) dp[i][j] = max(dp[i][j] , dp[i - 1][k] + vac[i][j]);
	
	int ans = 0;
	for (int j = 0; j < 3; j++) ans = max(ans, dp[n - 1][j]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 11136
# 桁DP
N, K = map(int,input().split())
A = list(map(int,input().split()))
dp = [[-1]*2 for _ in range(100)]
MAX_DIGIT = 50

dp[0][0] = 0
for i in range(MAX_DIGIT):
    bitmask = 1 << (MAX_DIGIT-i-1)
    bit1_num = 0
    for a in A:
        if bitmask & a:
            bit1_num += 1

    score0 = bitmask*bit1_num  # Xのi桁目を0した時のfへの寄与
    score1 = bitmask*(N-bit1_num)

    if dp[i][1] != -1:
        dp[i+1][1] = max(dp[i+1][1],dp[i][1] + max(score0,score1))

    if dp[i][0] != -1:
        if K & bitmask:
            dp[i+1][1] = max(dp[i+1][1],dp[i][0] + score0)

    if dp[i][0] != -1:
        if K & bitmask:
            dp[i+1][0] = max(dp[i+1][0],dp[i][0] + score1)
        else:
            dp[i+1][0] = max(dp[i+1][0], dp[i][0] + score0)


ans = max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1])
print(ans)

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


long long n, m, ans;
vector<long long> a;

//判定
bool chk(long long x) {
	long long cnt = 0;
	for(int i=0; i<n; i++) {
		long long pos = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
		cnt += (n-pos);
	}
	return cnt < m;//X以上の和がM個未満かどうか
}

int main() {
	cin >> n >> m;
	a.resize(n);
	for(int i=0; i<n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	//二分探索
	long long ng = 0, ok = LLONG_MAX;
	while (abs(ok - ng) > 1) {
		long long mid = (ok + ng) / 2;
		if (chk(mid)) ok = mid;
		else ng = mid;
	}
	//終了時にngにX-1,okにXが入っている。


	vector<long long> wa(n + 1); //Aの累積和
	for(int i=0; i<n; i++)wa[i + 1] = wa[i] + a[i];
	for(int i=0; i<n; i++) {
		long long pos = upper_bound(a.begin(), a.end() , ng - a[i]) - a.begin();
		long long cnt = n - pos;
		ans += cnt * a[i] + (wa[n] - wa[pos]);
		m -= cnt;
	}
	ans += m * ng;
	cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = inp()
x = 1
ans = 1
for i in range(1,n+1):
    x *= i
cnt = Counter(prime_factorize(x))
# print(cnt)
for value in cnt.values():
    ans *= (value+1)
print(ans%mod)

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

const long long int modul = 1e9 + 7;
int main()
{
  long long int n, m;
  cin >> n >> m;
  vector <vector<char> > mat(n, vector<char> (m));
  vector <vector<long long int> > dp(n, vector<long long int> (m));
  for(long long int i=0; i < n; i++)
    for(long long int j=0; j < m; j++)
      cin >> mat[i][j];
  
  if(mat[0][0] == '#')
  {
    cout << 0;
    return 0;
  }
  dp[0][0] = 1;
  for(long long int i=1; i < n; i++)
  {
    if(mat[i][0] == '.' && dp[i-1][0] != 0)
      dp[i][0] = 1;
    else
      dp[i][0] = 0;
  }
  for(long long int i=1; i < m; i++)
  {
    if(mat[0][i] == '.' && dp[0][i-1] != 0)
      dp[0][i] = 1;
    else
      dp[0][i] = 0;
  }
  for(long long int i=1; i < n; i++)
  {
    for(long long int j=1; j < m; j++)
    {
      if(mat[i][j] == '.')
      {
        if(dp[i-1][j] == 0)
          	dp[i][j] = dp[i][j-1];
       	else if(dp[i][j-1] == 0)
          	dp[i][j] = dp[i-1][j];
        else
        	dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % modul;
      }
      else
   	   dp[i][j] = 0;
    }
  }
  cout << dp[n-1][m-1];
  return 0;
}


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

using namespace std;

typedef long long ll;

int n;
ll x, y, k;

int main() {
	cin >> n >> k;
	int res = 0;
	while (n--) {
		cin >> x >> y;
		ll dis = x * x + y * y;
		if (dis <= k * k) res++;
 	}
 	cout << res << endl;

	return 0;
}



Measured memory_bytes: 3628
n,m,q = map(int, input().split())
res = 0
a = []*n

for i in range(q):
  a.append(list(map(int, input().split())))
for i_1 in range(1,m+1):
  for i_2 in range(i_1,m+1):
    for i_3 in range(i_2,m+1):
      for i_4 in range(i_3,m+1):
        for i_5 in range(i_4,m+1):
          for i_6 in range(i_5,m+1):
            for i_7 in range(i_6,m+1):
              for i_8 in range(i_7,m+1):
                for i_9 in range(i_8,m+1):
                  tmp = 0
                  arr = [1,i_1,i_2,i_3,i_4,i_5,i_6,i_7,i_8,i_9]
                  for i in range(q):
                    if arr[a[i][1]-1] - arr[a[i][0]-1] == a[i][2]:
                      tmp += a[i][3]
                  res = max(res,tmp)
print(res)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    bool is_res = false;
    ll gcd = L_INF;
    rep(i,n){
        cin >> a[i];
        if(i == 0)gcd = a[0];
        else gcd = __gcd(gcd,a[i]);
        if(a[i] == k)is_res = true;
    }

    rep(i,n){
        ll dif = a[i] - k;
        if(dif >= 0){
            if(dif % gcd == 0)is_res = true;
        }
    }
    cout << (is_res?"POSSIBLE":"IMPOSSIBLE") << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

int a[200000];

int main(void){
  int n;
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  ll ans = 0;
  int mh = 2;
  rep(i,n){
    if(i == 0){
      ans += a[i]-1;
    }else{
      if(a[i] == mh){
        mh++;
      }else{
        if(a[i]%mh == 0)ans--;
        ans+=a[i]/mh;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

B = [A[i] - (i + 1) for i in range(N)]

B.sort()

b = B[len(B) // 2]

ans = 0

for j in range(N):
    ans += abs(A[j] - (b + j + 1))

print(ans)


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

int main()
{
    set<int> a;
    vector<int> b(3);
    for(int i = 0;i < 3;i++){
        cin >> b[i];
        a.insert(b[i]);
    }
    cout << a.size() << endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b;
  if((a<10)&&(b<10)){
    c = a*b;
    cout << c << endl;
  }else{
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
        int n;
        double t;
        double x, h;
        double max_atan = 0;
        scanf("%d %lf", &n, &t);
        for(int i = 0;i < n;++i){
                scanf("%lf %lf", &x, &h);
                max_atan = max(max_atan, atan(h / x));
        }
         
        printf("%.6lf\n", t * tan(max_atan));
         
        return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    cout << n-k+1 << endl;
}

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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    vector <long long> a(n);
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long m;
    cin>>m;
    vector <long long> b(m);
    for(long long i=0;i<m;i++)
    {
        cin>>b[i];
    }
    cout<<includes(a.begin(),a.end(),b.begin(),b.end())<<endl;
    return 0;
}




Measured memory_bytes: 5900
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        e[s].push_back(t);
    }

    double dp[n];
    fill(dp, dp+n, 0);
    for (int i = n - 1; i >= 0; i--) {
        for (int j : e[i]) {
            dp[i] += (dp[j] + 1) / e[i].size();
        }
    }

    double p[n];
    fill(p, p+n, 0);
    p[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j : e[i]) {
            p[j] += p[i] / e[i].size();
        }
    }

    double rmmx = 0;
    for (int i = 0; i < n; i++) {
        if (e[i].size() == 1) {
            continue;
        }

        for (int j : e[i]) {
            double e1 = (dp[i] * e[i].size() - dp[j] - 1) / (e[i].size() - 1);
            rmmx = max(rmmx, (dp[i] - e1) * p[i]);
        }
    }

    cout << fixed << setprecision(10) << dp[0] - rmmx << endl;

    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
import sys
from collections import deque
import numpy as np
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    L,A,B,M=map(int,input().split())
    S=lambda i:A+B*i
    sec=[]
    
    def nibutan(ok,ng,k):
        while abs(ok-ng) > 1:
            mid = (ok + ng) // 2
            if solve(mid,k):
                ok = mid
            else:
                ng = mid
        return ok
    
    def solve(mid,k):
        return len(str(S(mid)))<k
    
    left=L-1
    for k in range(19,0,-1):
        if len(str(S(left)))==k:
            right=nibutan(-1,left,k)
            sec.append((k,left,right))
            left=right
    
    X=np.array([0,A%M,1],dtype=np.int64)
    for k,left,right in sec[::-1]:
        n=left-right
        doubling=[np.array([[pow(10,k,M),0,0],[1,1,0],[0,B%M,1]],dtype=np.int64)]
        for i in range((10**18).bit_length()):
            doubling.append(np.dot(doubling[i],doubling[i])%M)
        n=left-right
        for i in range(len(doubling)):
            if n&1:
                X=np.dot(X,doubling[i])%M
            n>>=1
            if n==0:
                break
    print(X[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 12516
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (){
    int n, m, x;
    cin >> n >> m >> x;
    int a[114514];
    int count1 = 0, count2 = 0;
    for (int i = 0; i < m; i++){
        cin >> a[i];
        if (a[i] < x){
            count1++;
        }
        else if (a[i] > x){
            count2++;
        }
    }
    cout << min(count1, count2) << endl;
    return 0;
    }
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
#define MOD 1000000007
#define INF 1000000000000000007LL


const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int a, b; cin>>a>>b;
    cout<<(a*b);
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3648
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 1005
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

ll mul(ll a, ll b) {
    if (a*b/a != b) return oo;
    return min(oo, a*b);
}

int x, y;

int main () {
    scanf("%d%d", &x, &y);
    if (x%y == 0) puts("-1");
    else printf("%d\n", x);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
long long dp[N];
long long fw[N];
long long a[N];
long long h[N];
int n;
void update(int now,long long num){
    for(int i=now;i<=n;i+=(i&-i))    fw[i] = max(fw[i],num);
}
long long query(int now){
    long long ma = 0;
    for(int i=now;i>0;i-=(i&-i))    ma = max(ma,fw[i]);
    return ma;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)    scanf("%lld",&h[i]);
    for(int i=0;i<n;i++)    scanf("%lld",&a[i]);
    long long ans = 0;
    for(int i=0;i<n;i++){
        dp[i] = query(h[i] - 1) + a[i];
        update(h[i],dp[i]);
        ans = max(ans,dp[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6528
from collections import Counter
import sys

for t in sys.stdin:
    l=sorted(map(int,t[:-1].split(",")))
    s=False
    p1=Counter(l)
    p2=Counter(p1.values())

    if 3 in p2 and 2 in p2:
        print("full house")
    elif 2 in p2:
        if p2[2]==1:
            print("one pair")
        elif p2[2]==2:
            print("two pair")
    elif 3 in p2:
        print("three card")
    elif 4 in p2:
        print("four card")
    else:
        for i in range(1,10):
            if list(range(i,i+5))==l:
                print("straight")
                s=True
                break
        if [1,10,11,12,13]==l:
            print("straight")
            s=True
        if not s:
            print("null")



Measured memory_bytes: 5992
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vll p5(202,0);
    REP(i,202){
        ll k = 1;
        REP(j,5){
            k *= i;
        }
        p5[i]=k;
    }
    ll x;
    cin >> x;
    REP(i,202){
        REP(j,202){
            if(p5[i]-p5[j]==x){
                cout << i << " " << j << endl;
                return 0;
            }else if(p5[i]+p5[j]==x){
                cout << i << " " << (-j) << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    int a = N % 10;
    vector<int> h = {2,4, 5, 7, 9};
    vector<int> p = {0, 1, 6, 8};
    for(int i = 0; i < h.size(); i++){
        if(a == h[i]){
            cout << "hon" << endl;
            return 0;
        }
    }
    for(int i = 0; i < p.size(); i++){
        if(p[i] == a){
            cout<< "pon" << endl;
            return 0;
        }
    }
    cout << "bon" << endl;
    return 0;

}


Measured memory_bytes: 3632
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    string s;
    cin >> n >> s;

    ll ans = 0;
    for (int i = 1; i < n - 1; i++) {
        vector <int> left(3), right(3), same(3);
        for (int j = 0; j < i; j++) {
            if (s[j] == 'R') left[0]++;
            if (s[j] == 'G') left[1]++;
            if (s[j] == 'B') left[2]++;
        }
        for (int j = i + 1; j < n; j++) {
            if (s[j] == 'R') right[0]++;
            if (s[j] == 'G') right[1]++;
            if (s[j] == 'B') right[2]++;
        }

        if (s[i] == 'R') {
            ans += left[1] * right[2];
            ans += left[2] * right[1];
        } else if (s[i] == 'G') {
            ans += left[0] * right[2];
            ans += left[2] * right[0];
        } else {
            ans += left[1] * right[0];
            ans += left[0] * right[1];
        }

        for (int j = 1; i - j >= 0 && i + j < n; j++) {
            if (s[i - j] != s[i] && s[i] != s[i + j] && s[i + j] != s[i - j]) {
                ans--;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

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

int pow_mod(int n, int m, int mod_num) {
  if (m == 0) return 1;
  long res = pow_mod(n, m/2, mod_num);
  res = res * res; res %= mod_num;
  if (m % 2 == 1) {
    res *= n; res %= mod_num;
  }
  return res;
}

int div(int A, int B, int mod_p) {
  stack<int> q_stack;
  int a = B, b = mod_p, r;
  while (b) {
    q_stack.push(a / b);
    r = a % b; a = b; b = r;
  }
  long u = 1, v = 0;
  while (!q_stack.empty()) {
    int q = q_stack.top(); q_stack.pop();
    long u1 = v, v1 = u-q*v; u = u1 % mod_p; v = v1 % mod_p;
  }
  return (long)A * (u + mod_p) % mod_p;
}
 
int num_com(int n, int k, int mod_p) {
  int k2 = min(k, n - k);
  long nmr = 1, dnm = 1;
  for (int i = 1; i <= k2; i++) {
    nmr *= n + 1 - i; nmr %= mod_p;
    dnm *= i; dnm %= mod_p;
  }
  return div(nmr, dnm, mod_p);
}

int main() {
  int DIV = 1e+9 + 7;
  int N, A, B;
  cin >> N >> A >> B;
  int res = pow_mod(2, N, DIV);
  res--;
  res -= num_com(N, A, DIV); res = (res + DIV) % DIV;
  res -= num_com(N, B, DIV); res = (res + DIV) % DIV;
  cout << res << endl;
}

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

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let d: i32 = iter.next().unwrap().parse().unwrap();

    let start = if a < c { c } else { a };
    let end = if b < d { b } else { d };
    println!("{}", if end - start < 0 { 0 } else { end - start });
}


Measured memory_bytes: 4352
m,n,x=[int(i) for i in input().split()]
k,l,y=[int(i) for i in input().split()]

res=0.5*(1.0+((m**2+n**2)**x)/((m+n)**(2*x)))
res*=0.5*(1.0+((k**2+l**2)**y)/((k+l)**(2*y)))
print(res)



Measured memory_bytes: 5620
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	long long a, b;
	long long c, d;
	cin >> a >> b >> c >> d;
	long long waruCTop = b / c;
	long long waruCUnder = a / c;
	long long cDivide = waruCTop - waruCUnder + (a % c == 0 ? 1 : 0);
	long long waruDTop = b / d;
	long long waruDUnder = a / d;
	long long dDivide = waruDTop - waruDUnder + (a % d == 0 ? 1 : 0);
	long long lcmValue = lcm(c, d);
	long long waruCDTop = b / lcmValue;
	long long waruCDUnder = a / lcmValue;
	long long  cdDivide = waruCDTop - waruCDUnder + (a % lcmValue == 0 ? 1 : 0);
	cout << ((b - a + 1) - cDivide - dDivide + cdDivide);
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n, m, x[1001], y[1001], z[1001];
  cin >> n >> m;
  rep(i, 0, n) {
    cin >> x[i] >> y[i] >> z[i];
  }

  int ans = 0;

  rep(i, 0, 2) rep(j, 0, 2) rep(k, 0, 2) {
    int dp[1004][1004] = {};
    rep(l, 0, n + 1) rep(o, 1, m + 1) dp[l][o] = -1145141919810893;
    int k1 = 1, k2 = 1, k3 = 1;
    if(i) k1 = -1;
    if(j) k2 = -1;
    if(k) k3 = -1;
    rep(l, 0, n) rep(o, 0, m + 1) {
      dp[l + 1][o + 1] = max(dp[l + 1][o + 1], dp[l][o] + x[l] * k1 + y[l] * k2 + z[l] * k3);
      dp[l + 1][o] = max(dp[l + 1][o], dp[l][o]);
    }
    ans = max(ans, dp[n][m]);
  }

  cout << ans << endl;
}


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


int main() {
  int a,p;
  cin>>a>>p;
  
  cout<<(3*a+p)/2<<endl;

}

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

#include <bits/stdc++.h>

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

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

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

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<pair<lli, lli>> v(n);
    cin >> v;

    lli x = 1;
    lli y = 1;
    each (i, v) {
      lli a = ((x / i.first) + bool(x % i.first));
      lli b = ((y / i.second) + bool(y % i.second));
      x = i.first * max(a, b);
      y = i.second * max(a, b);
    }
    cout << x + y << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val map = mutableMapOf<Int, Int>()
    for (i in 1..n) {
        map[i] = scanner.nextInt()
    }
    val result = map.toList().sortedBy { it.second }.toMap()
    result.forEach {println(it.key) }
}


Measured memory_bytes: 96740
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
#define double long double
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    if (x1 > x2) {
        swap(x1, x2);
        swap(y1, y2);
    }
    bool flag = false;
    if (y1 > y2) {
        swap(y1, y2);
        flag = true;
    }

    int n;
    cin >> n;
    vector<pair<int, int>> a;
    while (n-- > 0) {
        int x, y;
        cin >> x >> y;
        if (x1 <= x && x <= x2 && y1 <= y && y <= y2) {
            if (flag) {
                y = (y2 - y) + y1;
            }
            a.push_back(make_pair(x, y));
        }
    }
    sort(a.begin(), a.end());
    vector<int> lis;
    for (const pair<int, int>& p: a) {
        int pos = lower_bound(lis.begin(), lis.end(), p.second) - lis.begin();
        if (pos == SZ(lis)) {
            lis.push_back(p.second);
        } else {
            lis[pos] = p.second;
        }
    }
    cout << setprecision(14) << fixed;
    double ans = ((y2 - y1) + (x2 - x1)) * 100.0L;
    ans -= 2 * 10.0L * SZ(lis);
    ans += 5.0L * M_PI * SZ(lis);
    if (SZ(lis) == min(y2 - y1 + 1, x2 - x1 + 1)) {
        ans += 5.0L * M_PI;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3696
#include<stdio.h>

int n,a[20];
int solve(int ,int );

int main(){

  int i,q,m[200];

  scanf("%d",&n);

  for(i=0;i<=n-1;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&q);

  for(i=0;i<=q-1;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<=q-1;i++){
    
    if(solve(0,m[i])){
      printf("yes\n");
    }

    else printf("no\n");
  }

  return 0;

}


int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  return solve(i+1,m)||solve(i+1,m-a[i]);
}
    
   



Measured memory_bytes: 2104
n, q = map(int, input().split())

g = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add(b)
    g[b].add(a)

ctr = [0] * n
for _ in range(q):
    it = map(int, input().split())
    p = next(it) - 1
    x = next(it)
    ctr[p] += x

st = [(0, -1)]
while st:
    v, par = st.pop()
    for u in g[v]:
        if u == par: continue
        ctr[u] += ctr[v]
        st.append((u, v))
print(*ctr)


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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

int dfs(int now,const vector<vector<int>>& e){
    vector<int> me(e[now].size());
    rep(i,e[now].size()){
        me[i]=dfs(e[now][i],e);
    }
    sort(me.begin(),me.end(),greater<>());
    int ret=0;
    rep(i,me.size()){
        ret=max(ret,me[i]+i+1);
    }
    return ret;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;

    int n;
    cin>>n;

    vector<vector<int>> e(n+1);
    rep(i,2,n+1){
        int in;
        cin>>in;
        e[in].push_back(i);
    }

    cout<<dfs(1,e)<<endl;
}


Measured memory_bytes: 13568
while True:
    a,b = map(int,input().split())
    if a == 0  and b == 0:
        break
    print("#"*b)
    if a == 2:
        pass
    else:
        for i in range(a-2):
            c = "."*(b-2)
            print(f"#{c}#")
    print("#"*b)
    print()


Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;
int main()
{
    // 文字列の入力
	int N;
	int L[101];
	cin >> N;
	
	for(int i = 1; i <= N; i++) {
		cin >> L[i];
	}
	
	int result = 0;
	
	for(int i = 1; i <= N; i++) {
		for(int j = i + 1; j <= N; j++) {
			for(int k = j + 1; k <= N; k++) {
				if((L[i] != L[j]) && (L[i] != L[k]) && L[j] != L[k]) {
					int a[3];
					a[0] = L[i];
					a[1] = L[j];
					a[2] = L[k];
					
					for(int m = 0; m < 3; m++ ){
						for(int n = m; n < 3; n++) {
							if(a[m] < a[n]) {
								int temp = a[m];
								a[m] = a[n];
								a[n] = temp;
							}
						}
					}
					
					if(a[0] < (a[1] + a[2])) {
						result++;
					}
				}
			}
		}
	}
	
	
	printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 3764
n = int(input())
x =[]
y =[]
for i in range(n):
    a, b = map(int,input().split())
    x.append(a)
    y.append(b)
x =sorted(x)
y =sorted(y,reverse = True)

ans = 0
if n %2 == 0:
    m = n //2 -1
    ans = y[m] + y[m+1]-x[m]-x[m+1] +1
    print(ans)
    exit()
else:
    m = n//2
    ans = y[m] - x[m] + 1
    print(ans)
    exit() 

Measured memory_bytes: 26932
let n, ans = read_int (), ref min_int
let fs = Array.(init n @@ fun _ -> init 5 @@ fun _ -> init 2 @@ fun _ -> Scanf.scanf " %d" (+) 0)
let ps = Array.(init n @@ fun _ -> init 11 @@ fun _ -> Scanf.scanf " %d" (+) 0)
let g b w d = (d + (b lsr w) land 1) / 2
let f b = Array.(fold_left (fun (s, i) f -> s + ps.(i).(fst @@ fold_left (fun (c, w) d -> c + g (b land 31) w d.(0) + g (b lsr 5) w d.(1), w + 1) (0, 0) f), i + 1) (0, 0) fs) |> fst
let _ = for i = 1 to 1 lsl 10 - 1 do ans := max !ans @@ f i done; Printf.printf "%d\n" !ans

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

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    if (A % 2 == 1 && B % 2 == 1)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* delimiter = "";
  for (const auto& x:v) cout << exchange(delimiter, ",") << x;
  return os;
}
int32_t main(){
  size_t N,W; cin>>N>>W;
  const size_t V=100*N,INF=1<<30;
  vector<size_t> v(N),w(N);
  for(size_t i=0; i<N; ++i) cin>>v[i]>>w[i];
  vector<vector<size_t>> dp(N+1,vector<size_t>(V+1));
  dp[0][0]=0;
  for(size_t j=1; j<V+1; ++j) dp[0][j]=INF;
  for(size_t i=1; i<N+1; ++i){
    for(size_t j=1; j<V+1; ++j){
      dp[i][j]=dp[i-1][j];
      if(j>=v[i-1]) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
    }
  }
  // for(const auto& x:dp) cout<<x<<endl;
  cout<<(rend(dp[N])-find_if(rbegin(dp[N]),rend(dp[N]),[W](size_t x){ return x<=W; })-1)<<endl;
}


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

using namespace std;

int main(void){
  int X,A,B;
  cin >> X >> A >> B;
  if(B-A<=0){
    cout << "delicious" << endl;
  }
  else if(B-A<=X){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	int[] ls = readln.chomp.split.map!(to!int).array;
	
	ls.sort!"a > b"();
	
	int ans;
	foreach(i, l; ls) ans += l * (i % 2);
	
	ans.writeln;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	string A,B,C;
	cin>>A>>B>>C;
	string ans="NO";
	if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0])ans="YES";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
#define endl "\n"





int main() 
{ 
    
   string st;
   cin>>st;

   if(st[0]=='7' || st[1]=='7' || st[2]=='7')
   	d1("Yes");
   else
   	d1("No");
    return(0);
}

Measured memory_bytes: 3636
using System;
using System.Linq;

namespace AApplePie
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = inputs[0];
            var p = inputs[1];

            var pies = (3 * a + p) / 2;
            
            // 解答の出力
            Console.WriteLine(pies);
        }
    }
}


Measured memory_bytes: 13268
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if c[i][j] > c[i][k] + c[k][j]:
                c[i][j] = c[i][k] + c[k][j]

ans = 0
for h in range(H):
    for w in range(W):
        if A[h][w] != -1 and A[h][w] != 1:
            ans += c[A[h][w]][1]
print(ans)

Measured memory_bytes: 3444
#include<iostream>
using namespace std;
 
int main(){
   int H,W;
    
   while(true){
       cin >> H >> W;
       if( H == 0 && W == 0) break;
       if(H == 1 && W == 1) cout << "#" << endl;
 
       if(H==1 && W != 1){
         for(int j = 1;j < W;j +=2){
               cout << "#" << ".";
           } 
           if(W%2 == 1) cout << "#"; 
           cout << endl;
       }
        
        
       for(int i = 1; i < H; i += 2){
           for(int j = 1;j < W;j +=2){
               cout << "#" << ".";
           }
           if(W%2 == 1) cout << "#";
           cout << endl;
           for(int j = 1;j < W;j +=2){
               cout << "." << "#";
           }
           if(W%2 == 1) cout << ".";
           cout << endl;
       }
       if(H%2 == 1 && H !=1){
               for(int j = 1;j < W;j +=2){
               cout << "#" << ".";
           }
           if(W%2 == 1) cout << "#";
           cout << endl;
           }
       cout << endl;
   }
   return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    int x[100000]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        x[a[i]-1]++;
    }
    int eat=0;
    for(int i=0;i<100000;i++){
        if(x[i])eat+=x[i]-1;
    }
    if(eat%2)eat++;
    cout<<n-eat<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

struct node {
  int p;
  int v;
  int s;
};

int get_pid(vector<node> &vec, int i) {
  int p = i;
  while (p != vec[p].p)
    p = vec[p].p;
  int c = i;
  while (c != vec[c].p) {
    int n = vec[c].p;
    vec[c].p = p;
    c = n;
  }
  return p;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<node> vec(n + 1);
  for (int i = 1; i <= n; ++i)
    vec[i] = {i, i, 1};

  vector<pair<int, int>> vec2(m);
  for (auto &v : vec2) {
    int a, b;
    cin >> a >> b;
    v = make_pair(a, b);
  }

  reverse(vec2.begin(), vec2.end());

  vector<int> ans;
  for (auto &v : vec2) {
    int a = v.first;
    int b = v.second;
    int ap = get_pid(vec, a);
    int bp = get_pid(vec, b);
    if (ap == bp) {
      ans.push_back(0);
    } else {
      int s = vec[ap].s + vec[bp].s;
      ans.push_back(vec[ap].s * vec[bp].s);
      vec[bp].p = ap;
      vec[ap].s = s;
    }
  }

  ll vsum = 0;
  for (auto itr = ans.rbegin(); itr != ans.rend(); ++itr) {
    vsum += *itr;
    cout << vsum << endl;
  }
}

Measured memory_bytes: 5728
import heapq
n, m = map(int, input().split())
_a = list(map(int, input().split()))
a = [-i for i in _a]
lc = set()
bcount = dict()
heapq.heapify(a)
for i in range(m):
    b, c = map(int, input().split())
    lc.add(-c)
    if str(c) in bcount.keys():
        bcount[str(c)] += b
    else:
        bcount[str(c)] = b


lc = list(lc)
heapq.heapify(lc)

cnt = 0
ans = 0

while cnt < n:
    amax = -a[0]
    cmax = -1 if len(lc) == 0 else -lc[0]
    if amax >= cmax:
        cnt += 1
        ans += heapq.heappop(a)
    else:
        take = min(n - cnt, bcount[str(cmax)])
        cnt += take
        ans += heapq.heappop(lc) * take

print(-ans)


Measured memory_bytes: 37360
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    int ct = 1;
    ll X = 26;
    while (n >= X) {
        n -= X;
        X *= 26;
        ++ct;
    }

    string ans = "";
    rep(i, ct) {
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(all(ans));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {
  var s, t string
  fmt.Scanf("%s", &s)
  fmt.Scanf("%s", &t)

  ans := 0
  for i := 0; i < 3; i++{
    if s[i:i+1] == t[i:i+1] {
      ans++
    }
  }
  fmt.Printf("%d\n", ans)
}

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

void sort(string str[], int n);
void display(string str[], int n);

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

  string str[n];

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

  sort(str, n);
  display(str, n);
}


void sort(string str[], int n){
  string tmp;

  for(int i = n-1; i > 0; i--){
    for(int j = 0; j < i; j++){
      if(str[j] > str[j+1]){
	tmp = str[j];
	str[j] = str[j+1];
	str[j+1] = tmp;
      }
    }
  }
}

void display(string str[], int n){
  for(int i = 0; i < n; i++){
    cout << str[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
w=input()
ans="Yes"
w_len=len(w)
if w_len%2==1:
    ans="No"
else:
    for i in range(w_len):
        w_i=w[i]
        w_count=w.count(w_i)
        if w_count%2==1:
            ans="No"
print(ans)

Measured memory_bytes: 2940
x, y = map(int,input().split())
a = []
b = []

for i in range(x):
    a.append(list(input()))
for i in range(y):
    b.append(list(input()))

for i in range(x-y+1): #Aの中縦移動
    for j in range(x-y+1): #Aの中横移動→位置確定
        flag = 1
        for k in range(y): #bの全ての行
            if b[k] != a[i+k][j:j+y]:
                flag = 0
                break
        if flag == 1:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 38256