akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
vi pos,neg;
ll nc,z,n;
ll calc(ll x)
{
    if(x==0)return z+nc;
    if(x<0)
    {
        ll ans=0;
        for(int i=0;i<neg.size();i++)
        {
            ll j=pos.end()-lower_bound(pos.begin(),pos.end(),(x+neg[i]+1)/neg[i]);
            assert(j>=0);
            ans+=j;
        }
        return ans;
    }
    ll ans=nc+z;
//    DBG(ans);
    for(int i=0;i+1<pos.size();i++)
    {
        ll j=upper_bound(pos.begin()+i+1,pos.end(),x/pos[i])-pos.begin();
        j-=i;
        assert(j>0);
        j--;
        ans+=j;
    }
//    DBG(ans);
    for(int i=0;i+1<neg.size();i++)
    {
        ll j=neg.end()-lower_bound(neg.begin()+i+1,neg.end(),x/neg[i]);
        assert(j>=0);
        ans+=j;
    }
    return ans;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1; qq<=T; qq++)
    {
        ll k;
        cin>>n>>k;
        ll zer=0;
        pos.clear();neg.clear();
        for(int i=0;i<n;i++)
        {
            ll x;
            cin>>x;
            if(x<0)neg.push_back(x);
            else if(x>0)pos.push_back(x);
            else zer++;
        }
        z=zer*(n-zer)+zer*(zer-1)/2;
        nc=(ll)pos.size()*(ll)neg.size();
        sort(pos.begin(),pos.end());
        sort(neg.begin(),neg.end());
        ll lo=-1e18,hi=1e18;
        while(lo+1<hi)
        {
            ll mid=(lo+hi)/2;
//            cout<<lo<<' '<<hi<<endl;
//            cout<<mid<<' '<<calc(mid)<<endl;
//            system("pause");
            if(calc(mid)<k)lo=mid;
            else hi=mid;
        }
        if(calc(lo)>=k)
            cout<<lo<<endl;
        else cout<<hi<<endl;
    }
    return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll nC2(ll n) {
    return n * (n - 1) / 2;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    REP(i, n) a[i]--;

    vector<int> count(n);
    REP(i, n) count[a[i]]++;

    ll total = 0;
    REP(i, n) total += nC2(count[i]);

    REP(i, n) {
        ll ans = total;
        ans -= nC2(count[a[i]]);
        count[a[i]]--;
        ans += nC2(count[a[i]]);
        count[a[i]]++;
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <bitset>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    ll N;
    cin >> N;
    ll a[5],c[5];
    int flag=0;
    for(int i=0;i<5;i++){
        cin >> a[i];
        c[i] = a[i];
    }
    sort(a,a+5);
    ll minn = a[0],I;
    for(int i=0;i<5;i++){
        if(a[0]==c[i]){
            I=i;
            break;
        }
    }
    ll ans=0;
    ans = N/c[I]+5;
    if(c[I]==1){
        cout << ans-1 << endl;
    }else{
        cout << ans << endl;
    }
}

    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

template <typename T>
struct SegTree {
    typedef function<T(T, T)> F;
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegTree(){}
    SegTree(F f, T ti): f(f), ti(ti){}

    void init(int n_) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n<<1, ti);
    }

    void build(const vector<T> &v) {
        int n_ = v.size();
        init(n_);
        for(int i = 0; i < n_; ++i) dat[n+i] = v[i];
        for(int i = n-1; i; --i) dat[i] = f(dat[(i<<1)|0], dat[(i<<1)|1]);
    }

    void set_val(int k, T x) {
        dat[k += n] = x;
        while(k >>= 1) dat[k] = f(dat[(k<<1)|0], dat[(k<<1)|1]);
    }

    T query(int a, int b) {
        if(a >= b) return ti;
        T vl = ti, vr = ti;
        for(int l = a+n, r = b+n; l < r; l >>= 1, r >>= 1) {
            if(l&1) vl = f(vl, dat[l++]);
            if(r&1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }

    template <typename C>
    int find(int st, C &check, T &acc, int k, int l, int r) {
        if(l+1 == r) {
            acc = f(acc, dat[k]);
            return check(acc) ? k-n : -1;
        }
        int m = (l+r)>>1;
        if(m <= st) return find(st, check, acc, (k<<1)|1, m, r);
        if(st <= 1 && !check(f(acc, dat[k]))) {
            acc = f(acc, dat[k]);
            return -1;
        }
        int vl = find(st, check, acc, (k<<1)|0, l, m);
        if(~vl) return vl;
        return find(st, check, acc, (k<<1)|1, m, r);
    }

    template <typename C>
    int find(int st, C &check) {
        T acc = ti;
        return find(st, check, acc, 1, 0, n);
    }
};

ll n, k;

int main() {
    cin >> n >> k;
    vector<ll> avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> avec[i];

    auto f = [](ll a, ll b) { return a+b; };
    SegTree<ll> seg(f, 0);
    seg.build(vector<ll>(n, 0));
    for(int i = 0; i < n; ++i) seg.set_val(i, avec[i]);

    vector<ll> value;

    for(int i = 0; i < n; ++i) {
        for(int j = i; j < n; ++j) {
            value.emplace_back(seg.query(i, j+1));
        }
    }
    sort(value.begin(), value.end(), greater<ll>());
    
    vector<ll> sumvec = value;
    for(int i = 63; i >= 0; --i) {
        int cnt = 0;
        vector<ll> check;
        for(auto x : sumvec) {
            if(x&(1LL<<i)) {
                cnt++;
                check.emplace_back(x);
            }
        }
        if(cnt >= k) sumvec = check;
        if((int)sumvec.size() == k) break;
    }

    ll ans = sumvec[0];
    for(int i = 0; i < k; ++i) ans &= sumvec[i];
    cout << ans << endl;
}

Measured memory_bytes: 12976
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
int a[200005];
int main()
{
	int n;
	cin>>n;
	map<int,int> m;
	for(int i=0;i<n;i++)
	cin>>a[i],m[i-a[i]]++;
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=(ll)m[i+a[i]];
	}
	cout<<ans<<endl;
} 

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

int main() {
  int n, a, p = 1001, q = -1;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a;
    p = min(p, a);
    q = max(q, a);
  }

  cout << q - p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  string s;
  cin >> s;
  bool ok = true;
  rep(i,s.size()){
    if(i&1){
      if(s[i]=='L' || s[i] == 'U' || s[i]=='D')continue;
      else ok = false;
    }
    else{
      if(s[i]=='R' || s[i] == 'U' || s[i]=='D')continue;
      else ok = false;
    }
  }
  if(ok)cout<<"Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
  int X;
  cin >> X;
  int ans=1;
  for(int i=2; i<=X; i++){
    for(int j=2; j<10; j++){
      int z=std::pow(i,j);
      if(z<=X) ans=max(ans, z);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
K=int(input())
sum=0
for i in range(1, K+1):
    for j in range(i+1, K+1):
        for k in range(j+1, K+1):
            sum += 6*gcd(i, j, k)
for i in range(1, K+1):
    for j in range(i+1, K+1):
        sum += 2*3*gcd(i, j)
sum += int( (K+1)*K/2 )
print(sum)


Measured memory_bytes: 9564
using System;

namespace ITP1_11_D
{
    class Dice : IEquatable<Dice>
    {
        private int top, btm, front, back, left, right;
        private int[] vals = new int[6];
        public int Top { get { return vals[top]; } }
        public int Btm { get { return vals[btm]; } }
        public int Front { get { return vals[front]; } }
        public int Back { get { return vals[back]; } }
        public int Left { get { return vals[left]; } }
        public int Right { get { return vals[right]; } }
        public Dice(int[] values)
        {
            Array.Copy(values, vals, 6);
            Reset();
        }
        public void Reset()
        {
            top = 0; btm = 5; front = 1; back = 4; left = 3; right = 2;
        }

        public void W()
        {
            int tmp = left;
            left = top;
            top = right;
            right = btm;
            btm = tmp;
        }

        public void E()
        {
            int tmp = right;
            right = top;
            top = left;
            left = btm;
            btm = tmp;
        }

        public void C()
        {
            int tmp = front;
            front = right;
            right = back;
            back = left;
            left = tmp;
        }

        public bool Equals(Dice other)
        {
            var roll = "OCCCWCCCECCCECCCWCCCWCCC";
            foreach (var c in roll)
            {
                switch (c)
                {
                    case 'C': C(); break;
                    case 'W': W(); break;
                    case 'E': E(); break;
                    default: break;
                }
                if (Top == other.Top && Btm == other.Btm && Front == other.Front && Back == other.Back && Left == other.Left && Right == other.Right)
                {
                    Reset();
                    return true;
                }
            }
            Reset();
            return false;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Dice[] dice = new Dice[n];
            for (int i = 0; i < n; i++) dice[i] = new Dice(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
            Console.WriteLine(ExistSame(dice) ? "No" : "Yes");
        }

        static bool ExistSame(Dice[] dice)
        {
            for (int i = 0; i < dice.Length; i++)
            {
                for (int j = i + 1; j < dice.Length; j++)
                {
                    if (dice[i].Equals(dice[j])) return true;
                }
            }
            return false;
        }
    }
}

Measured memory_bytes: 8972
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    string out = "No";
    if(s<t) out = "Yes";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  ll a[26] = {0};
  REP(i,s.size()){
    a[s[i]%26]++;
  }
  bool f = true;
  REP(i,26){
    if(a[i]%2 == 1)
      f = false;
  }
  if(f){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int N, A[200001], tmp;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    int *res = new int[N];
    for (int i = 1; i < N; i++) cin >> tmp, A[i] = tmp, res[tmp - 1]++;
    for (int i = 0; i < N; i++) cout << res[i] << " ";

    return 0;
}



Measured memory_bytes: 5156
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final List<Integer> list = new ArrayList<>();
        final Map<Integer, Integer> countMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            final int a = scanner.nextInt();
            list.add(a);
            countMap.compute(a, (k, v) -> v == null ? 1 : v + 1);
        }

        list.sort(Comparator.naturalOrder());
        int pow = 1 << 30;
        int count = 0;
        for (int i = list.size() - 1; i >= 0; i--) {
            final int value = list.get(i);
            if (countMap.get(value) == 0) {
                continue;
            }
            countMap.compute(value, (k, v) -> --v);

            while (pow >> 1 > value) {
                pow = pow >> 1;
            }

            final int index = Collections.binarySearch(list, pow - value);
            if (index < 0) {
                continue;
            }
            final int sbj = list.get(index);
            if (countMap.get(sbj) > 0) {
                count++;
                countMap.compute(sbj, (k, v) -> --v);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 104908
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];
ll a[10*MAX];

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

a[1]=1;
fr(i,2,10*MAX)
{
	a[i]++;
	for(j = i;j<10*MAX;j+=i)
		a[j]++;
	a[i]*=i;
}
ll ans =0;
cin >> n;
fr(i,1,1+n)
	ans+=a[i];
cout << ans;

eNd();
  return 0;
 
}


Measured memory_bytes: 81740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    int a[n+1] = {0};
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=n;i++)
    cout<<a[i]<<'\n';
    // cout<<lower_bound(v.begin(),v.end(),10) - v.begin();
	return 0;
}


Measured memory_bytes: 5220
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline






def main():
    def segfunc(x, y):
        return x + y

    def init(init_val):
        for i in range(n):
            seg[i + num - 1] = init_val[i]

        for i in range(num - 2, -1, -1):
            seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

    def update(k, x):
        k += num - 1
        seg[k] = x
        while k:
            k = (k - 1) // 2
            seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])

    def query(p, q):
        if q <= p:
            return ide_ele
        p += num - 1
        q += num - 2
        res = ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = segfunc(res, seg[p])
            if q & 1 == 1:
                res = segfunc(res, seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = segfunc(res, seg[p])
        else:
            res = segfunc(segfunc(res, seg[p]), seg[q])
        return res

    N, Q = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    # seg tree初期値 (単位元)
    n = N
    ide_ele = 0
    num = 2 ** (n - 1).bit_length()
    seg = [ide_ele] * 2 * num

    init(A)

    for _ in range(Q):
        q, p, x = [int(x) for x in input().split()]
        if q == 0:
            A[p] += x
            update(p, A[p])
        else:
            print(query(p, x))





if __name__ == '__main__':
    main()



Measured memory_bytes: 132204
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;

vector<string> v;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    while (cin >> n >> k, n || k)
    {
        ll arr[n + 1];
        for (int i = 0; i < n; ++i)
            cin >> arr[i];

        for (int i = 0; i < n; ++i)
        {
            arr[i + 1] += arr[i];
        }

        ll maxV = 0;
        for (int i = 0; i < n - k; ++i)
        {
            maxV = max(maxV, arr[i + k] - arr[i]);
        }
        cout << maxV << endl;
    }
    return 0;
}


Measured memory_bytes: 3856
#include <stdio.h>
int main(void) {
	int h1, h2, k1, k2, a, b, c, d, i, e, f, g, j, A, B;
	scanf("%d",&h1);
	scanf("%d",&h2);
	scanf("%d",&k1);
	scanf("%d",&k2);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	e = h1*a+c*(h1/10);
	f = k1*a+c*(k1/10);
	g = h2*b+d*(h2/20);
	j = k2*b+d*(k2/20);
	A = e + g;
	B = f + j;
	if (A < B) {
		printf("kenjiro\n");
	}
	else if (A > B) {
		printf("hiroshi\n");
	}
	else {
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2616
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        M: i32,
    }

    let ans = 24 + (24 - M);
    println!("{}", ans);
}


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

int main(){
    int N;
    cin>>N;
    long long res=0;
    vector<vector<long long> > num(10,vector<long long>(10,0));
    for(int n=1;n<=N;++n){
        vector<int> d;
        int nn=n;
        while(nn){
            d.push_back(nn%10);
            nn/=10;
        }
        int a=d[0];
        int b=d.back();
        if(!a || !b)continue;
        ++num[a][b];

    }
    for(int a=1;a<10;a++){
        for(int b=1;b<10;b++){
            res+=num[a][b]*num[b][a];
        }
    }
    cout<<res<<endl;
}

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

    #define ll long long
    #define mp make_pair
    #define rep(i, a, b) for(int i = (a);i <= (b);i++)
    #define per(i, a, b) for(int i = (a);i >= (b);i--)

    using namespace std;

    typedef pair<int, int> pii;
    typedef double db;
    const int N = 1e6 + 50;
    int n, k, a[N], cnt = 0, flag = 0; 
    int ans = 0, maxx, minn, pmax, pmin;
    int vis[N], f[N];
    priority_queue < int, vector<int>, greater<int> > q;
    priority_queue < int, vector<int>, less<int> > p;
    inline int read(){
        int x = 0, f = 1;
        char ch = getchar();
        while(ch < '0' || ch > '9'){if(ch == '-') f = -1; ch = getchar();}
        while(ch >='0' && ch <='9'){x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
        return x*f;
    }
    void init(){
        n = read(); k = read(); 
        rep(i, 1, n) a[i] = read();
        rep(i, 1, k) p.push(a[i]), q.push(a[i]);
        rep(i, 2, n){
            if(a[i] > a[i-1]){
                int sum = 0;
                while(a[i] > a[i-1] && i <= n) i++, sum++;
                if(sum >= k-1) cnt ++;
            }
        }
        ans = n-k+1;
        int l = 1, r = k;
        while(r <= n){
            r++;
            if(r > n) break;
            while(vis[q.top()]) q.pop(); 
            while(f[p.top()]) p.pop();
            if(a[l] == q.top() && a[r] > p.top()){
                q.pop(); p.push(a[r]);
                q.push(a[r]);
                f[a[l]] = 1;
                ans --;
            }
            else if(a[l] == q.top() && a[r] < p.top()){
                q.pop(); p.push(a[r]);
                q.push(a[r]);
                f[a[l]] = 1;
            }
            else if(a[l] == p.top()){
                p.pop(); p.push(a[r]);
                q.push(a[r]);
                vis[a[l]] = 1;
            }
            else if(a[l] != q.top() && a[l] != p.top()){
                p.push(a[r]); q.push(a[r]);
                f[a[l]] = 1, vis[a[l]] = 1;
            }
            l++;
        }
        if(!cnt) printf("%d\n", ans);
        else printf("%d\n", ans - cnt+1);
    }
    int main(){
        init();
        return 0;
    }

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    ll n;
    cin >> n;
    ll a, b;
    for(int i = sqrt(n); i >= 1; i--)
    {
        if (n % i == 0)
        {
            a = i;
            b = n/a;
             break;
        }
    }

    string s1 = to_string(a);
    string s2 = to_string(b);

    cout << max(s1.size(), s2.size()) << endl;

}


Measured memory_bytes: 256
n,h = map(int,input().split())
A = []
B = []
m = 0
for j in range(n):
    a,b = map(int,input().split())
    m = max(a,m)
    A.append(a)
    B.append(b)
B.sort(reverse=True)
for i in range(n):
    if B[i] > m:
        h -= B[i]
    else:
        print(i+1+(h-1)//m)
        break
    if h <= 0:
        print(i+1)
        break
else:
    print(n+1+(h-1)//m)

Measured memory_bytes: 11352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n, x, k, y;
	
	scanf("%d%d%d%d", &n, &k, &x, &y);
	ll s = 0;
	if (n > k) {
		s = 1ll * k * x + 1ll * (n - k) * y;
	} else {
		s = 1ll * n * x;
	}
	printf("%lld\n", s);
}

Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 04.29.2020 02:19:55
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 998244353;

ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

int N, S;
vector<int> A;

void solve() {
  vector<vector<ll>> dp(N + 1, vector<ll>(S + 1, 0));
  dp[1][0] = 1;
  if (A[0] <= S) {
    dp[1][A[0]] = 1;
  }
  for (int i = 2; i <= N; i++) {
    int a = A[i - 1];
    for (int s = 0; s <= S; s++) {
      dp[i][s] = 2 * dp[i - 1][s] - dp[i - 2][s];
      if (s >= a) {
        dp[i][s] += dp[i - 1][s - a] - dp[i - 2][s - a];
      }
      if (s == 0 || s == a) dp[i][s]++;
      dp[i][s] %= MOD;
    }
  }
  cout << (dp[N][S] % MOD + MOD) % MOD << endl;
}

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

  cin >> N >> S;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  solve();
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  vvi a(3,vi(3));
  rep(i,3) rep(j,3)
    cin >> a[i][j];

  i64 n;
  cin >> n;
  vv(bool) x(3,v(bool)(3,false));

  i64 b;
  bool ans = false;
  rep(i,n){
    cin >> b;
    rep(i,3) rep(j,3)
      if(a[i][j]==b) x[i][j]=true;
  }
    
  rep(i,3){
    if(x[0][i] && x[1][i] && x[2][i]) ans = true;
    if(x[i][0] && x[i][1] && x[i][2]) ans = true;
  }
  if(x[0][0] && x[1][1] && x[2][2]) ans = true;
  if(x[2][0] && x[1][1] && x[0][2]) ans = true;

  if(ans) cout << "Yes\n";
  else cout << "No\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


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

int main()
{

 int n, k;
 cin >> n >> k;

 vector<int> v(n,0);
 for(int i=0; i<n; i++)
  cin >> v[i];

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

  vector<bool> dp(k+1, false);
  
  bool at;
  for(int i=v[0]; i<=k; i++)
  {
    at = true;
    for(int j=0; j<n; j++)
    {
      if(i-v[j]>=0)
        at &= dp[i-v[j]];
    }
    if(at)
      dp[i] = false;
    else
      dp[i] = true;
  }

  if(dp[k])
    cout<<"First";
  else
    cout<<"Second";

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

r = 0
g = 0
b = 0

for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1
ans = r * g * b

for i in range(n):
    for j in range(min(i, n - 1 - i)):
        if s[i]!=s[i+j+1] and s[i]!=s[i-j-1] and s[i+j+1]!=s[i-j-1]:
            ans -= 1

print(ans)

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

#define ll long long

int main(){
    map<string,int> m;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        m[s] += 1;
    }
    int maxn=0;
    for(auto& x : m){
        int v = x.second;
        maxn = max(maxn, v);
    }
    for(auto x : m){
        if(x.second == maxn){
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 19228
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 998244353;//1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e6+5;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int mx=0;
	for(int i=0;i<n;i++) mx=max(mx,a[i]);
	multiset<int> s;
	int lowest=-1;
	int k=mx;
	if(mx%2==0)
	{	
		lowest=k/2+1;
		for(int i=k/2;i<=k;i++) s.insert(i);
		for(int i=k/2+1;i<=k;i++) s.insert(i);		 
	}
	else{
		lowest=(k+1)/2+1;
		for(int i=(k+1)/2;i<=k;i++) s.insert(i);
		for(int i=(k+1)/2;i<=k;i++) s.insert(i);	
	}
	set<int> left;
	for(int i=0;i<n;i++)
	{
		if(s.find(a[i])!=s.end())
		{
			s.erase(s.find(a[i]));
		}
		else left.insert(a[i]);
	}
	if(s.size()!=0)
	{
		cout<<"Impossible";
		return 0;
	}

	for(auto x:left)
	{
		if(x<lowest)
		{
			cout<<"Impossible";
			return 0;
		}
	}
	cout<<"Possible";
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 256
#set(s)種類の文字で作れる文字列を考える
#s=abcab なら 
# 2個のaのどちらを使うか＋使わない => 3
# 2個のbのどれを使うか　＋　使わない => 3
# 1個のcを使うか　＋　使わない　=> 2
#3*3*2 からどれも使わない場合を覗くので3*3*2-1
from collections import Counter
n = int(input())
s = input()
a = Counter(s).values()
ans = 1
for i in a:
    ans *= i+1
print((ans-1)%1000000007)

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

int main() {
  int n, p;
  while(cin >> n >> p, (n|p)) {
    int c = p, curr = 0;
    vector<int> v(n);
    
    while(1) {
      if(c == 0) {
	c += v[curr];
	v[curr] = 0;
      } else {
	v[curr] ++;
	c--;
	if(v[curr] == p) break;
      }
      curr = (curr+1)%n;
    }
    cout << curr << endl;
  }
  
  return 0;
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;
int MIN_INT = -1e9;

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

  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(5*2)), P(N, vector<int>(11));
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int res = MIN_INT;

  for(int open = 1; open < (1 << 10); open++) {
    int cc = 0;
    for(int i = 0; i < N; i++) {
      int c = 0;
      for(int j = 0; j < 10; j++) {
        if((open >> j & 1) && F[i][j]) {
          c++;
        }
      }
      cc += P[i][c];
    }
    if(res < cc) {
      res = cc;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b;
    cin>>a>>b;
    if(a+b==15)cout << "+"<<endl;
    else if(a*b==15)cout << "*"<<endl;
    else cout << "x"<<endl;



}


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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> h(n, 0);
  for (ll i = 0; i < n; ++i) {
    cin >> h[i];
  }
  
  ll x = 0;
  for (auto itr = h.begin(); itr != h.end(); ++itr) {
    if (x-*itr > 1) {
      cout << "No" << endl;
      return 0;
    }

    if (x < *itr) x = *itr;
  }

  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pb(a) push_back(a)
#define in(a) insert(a)
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;


void Main() {
  ll n,m,c,sum=0;
  cin >> n >> m >> c;
  vector<P> v[n];
  rep(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    sum+=z;x--,y--;
    v[x].pb(P(y,z));
    v[y].pb(P(x,z));
  }
  P d[n];
  rep(i,n) d[i]=P(MAXL,i);
  d[0].F=0;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,0));
  while(!que.empty()) {
    P p=que.top();que.pop();
    int x=p.S;
    if(d[x].F<p.F) continue;
    rep(i,v[x].size()) {
      int y=v[x][i].F;
      if(d[y].F>d[x].F+v[x][i].S) {
	d[y].F=d[x].F+v[x][i].S;
	que.push(P(d[y].F,y));
      }
    }
  }
  sort(d,d+n);
  ll ans=MAXL,z=0;
  set<ll> s;
  rep(i,n) {
    int x=d[i].S;
    rep(j,v[x].size()) {
      if(s.count(v[x][j].F)) z+=v[x][j].S;
    }
    s.insert(x);
    ans=min(ans,sum-z+d[i].F*c);
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);Main();
  return 0;
}


Measured memory_bytes: 20248
A, B, C = map(int, input().split())
L = sorted([A, B, C])

ans = (L[1] - L[0]) / 2 + (L[2] - L[1])

if (L[0] % 2 == 1 and L[1] % 2 == 0) or (L[1] % 2 == 1 and L[0] % 2 == 0):
  ans = ans + 1.5
print(int(ans))

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

int main() {
  int N;
  scanf("%d", &N);

  int sum = 0;
  int tmp = N;
  while (tmp > 0) {
    int t = tmp % 10;
    sum += t;
    tmp = tmp / 10;
  }

  if (sum == 1) printf("10");
  else printf("%d", sum);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define pli pair<LL,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
 	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define M 530010
#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(LL x,LL y){return x*y%mod;}
	inline void upd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
	inline void dec(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
	inline int qpow(int x,int sq){LL res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
LL a[M],p[63];
char s[M];
int n;
inline bool ins(LL num){
	for(int i=62;i>=0;--i) if((num>>i)&1){
		if(!p[i]){p[i]=num;return true;}
		num^=p[i];
	} return false;
}
inline bool solve(){
	n=read(),memset(p,0,sizeof(p));
	for(int i=1;i<=n;i++) a[i]=read();
	scanf("%s",s+1);
	for(int i=n;i>=1;--i){
		if(s[i]=='1'){if(ins(a[i])) return true;}
		else ins(a[i]);
	} return false;
}
int main(){
	for(int Cas=read();Cas;--Cas) puts(solve()?"1":"0");
	return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a >= b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, t;
	cin >> n >> t;
	vector<int> weight(n), value(n);
	REP(i, n) {
		cin >> weight[i] >> value[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(t + 1));
	vector<vector<ll>> dp2(n + 1, vector<ll>(t + 1));
	REP(i, t + 1) {
		dp[0][i] = 0;
	}
	REP(i, n) {
		REP(j, t + 1) {
			if (j >= weight[i]) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
			} else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	REP(i, t + 1) {
		dp2[n][i] = 0;
	}
	RREP(i, n) {
		REP(j, t + 1) {
			if (j >= weight[i]) {
				dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - weight[i]] + value[i]);
			} else {
				dp2[i][j] = dp2[i + 1][j];
			}
		}
	}
	ll res = 0;
	REP(i, n) {
		ll temp = 0;
		REP(j, t) {
			chmax(temp, dp[i][j] + dp2[i][t - j]);
		}
		chmax(res, temp);
	}
	put(res);
 	return 0;
}

Measured memory_bytes: 159088
#include <iostream>
#include <string.h>
#include <map>
#include <vector>
using namespace std;

#define ll long long 

int main () {
  string h;
  cin >> h;
  for (int i = 0; i <= h.size(); i++) {
    string first = h.substr(0, i);
    if (first == "keyence") {
      cout << "YES" << endl;  
      return 0;
    }
    for (int j = (i + 1); j < h.size(); j++) {
      string second = h.substr(j, h.size() - j);
      if (first + second == "keyence") {
        cout << "YES" << endl;
        return 0;  
      }
    }  
  }
  cout << "NO" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
#define P 1000000007
using namespace std;

int n;
long long a[N], inv[N], sum[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sum[0] = 0, inv[1] = 1;
    for (int i = 1; i <= n; ++i) {
        if (i > 1) inv[i] = (P - P / i) * inv[P % i] % P;
        sum[i] = (sum[i - 1] + inv[i]) % P;
    }
    long long ret = 0, fact = 1;
    for (int i = 1; i <= n; ++i) 
        ret = (ret + (sum[i] + sum[n - i + 1] - 1) * a[i] % P) % P, fact = fact * i % P;
    cout << ret * fact % P << endl;  
    return 0;
}

Measured memory_bytes: 2560
-- SPDX-License-Identifier: X11
-- 2020-09-20
-- Go to Jail (200pt)

f :: [[String]] -> String
f l = if g 0 l then "Yes" else "No"
  where
    g :: Int -> [[String]] -> Bool
    g 3 _  = True
    g _ [] = False
    g c ([a, b] : xs)
      | a == b    = g (c + 1) xs
      | otherwise = g 0 xs
    g _ _  = error "f.g: Unhandled case"

main :: IO ()
main = getContents >>= \x -> putStrLn . f . map words . tail . lines $ x


Measured memory_bytes: 3804
// To Infinity

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

string s;
long k;

int main() {
    cin >> s;
    cin >> k;

    int one_conti = 0;
    for (int i = 0; s[i] == '1' && i < s.size(); i++) {
        one_conti++;
    }

    if (k <= one_conti) {
        cout << 1 << endl;
    } else {
        cout << s[one_conti] << endl;
    }



    return 0;
}


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

int main(void){
    string s;
    cin >> s;
    int q;
    cin >> q;
    int rev=0;  //反転回数
    vector<char> moji;    //付け加える文字一覧
    vector<int> time;    //付け加わった時点での反転回数
    vector<bool> front;  //前後判定
    for(int i=0;i<q;i++){
        int k;
        cin >> k;
        if(k==1) rev++;
        else{
            char f,c;
            cin >> f >> c;
            moji.push_back(c);
            time.push_back(rev);
            if(f=='1') front.push_back(true);
            else front.push_back(false);
        }
    }

    if(rev%2==1) reverse(s.begin(),s.end());
    string s1,s2;
    for(int i=0;i<moji.size();i++){
        if((rev-time[i])%2==0){
            if(front[i]) s1 = moji[i] + s1;
            else s2 = s2 + moji[i];
        }else{
            if(front[i]) s2 = s2 + moji[i];
            else s1 = moji[i] + s1;
        }
    }
    cout << s1 << s << s2 << endl;
}

Measured memory_bytes: 2292
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

ll gcd(ll a,ll b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}
int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    s = min(s, min(q * 4, h * 2));
    d = min(d, s * 2);
    if(n % 2 == 0)
        cout<<n * d / 2<<endl;
    else cout<<s + (n / 2) * d << endl;

}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

string s;
int aa[26];
bool a=1;

main(){
	cin>>s;
	rep(i,s.size())aa[(int)(s[i]-'a')]++;
	rep(i,26){
		if(aa[i]>1){
			cout<<-1<<endl;
			return 0;
		}
	}
	if(s.size()==26){
		if(s=="zyxwvutsrqponmlkjihgfedcba")cout<<-1<<endl;
		else{
			string t=s,ans;
			next_permutation(s.begin(),s.end());
			debug(s);
			rep(i,26){
				ans+=s[i];
				if(t[i]!=s[i])break;
			}
			cout<<ans<<endl;
		}
	}
	else rep(i,26){
		if(aa[i]==0){
			cout<<s;
			cout<<(char)(i+'a')<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
n=int(input())

for i in range(1,n+1):
  x=i
  if x%3==0:
    print(" ",i,end="",sep="")
    continue

  while True:
    if x%10==3:
      print(" ",i,end="",sep="")
      break
    x//=10
    if x==0:
      break

print("")


Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A=0, T=0, R=0, N = 0, K = 0;
char H ;
cin >> N >> K;
vector<int> F(N);
for(int i = 0; i<N; i++){
cin >> F.at(i);
}
sort(F.begin(),  F.end());
for(int i = 0; i  < K; i++){
A += F.at(i);
}
cout << A <<endl;

}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	long int i, j;
	long int n, k, q;
	long int sum;
	long int max;
	long int flgk, flgg;
	long int count;
	long int a[100000];
	char str[200];
	
	scanf("%s", str);
	
	if(str[0] == 'S') {
		printf("Cloudy\n");
	} else if(str[0] == 'C') {
		printf("Rainy\n");
	} else if(str[0] == 'R') {
		printf("Sunny\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <atcoder/convolution>

using namespace std;

int main(){
    int N, M; cin >> N >> M;
    vector<long long> a(N);
    vector<long long> b(M);
    for(auto& t : a) cin >> t;
    for(auto& t : b) cin >> t;
    auto c = atcoder::convolution(a, b);
    for(int i=0;i<N+M-1;i++) cout << c[i] << " ";
    cout << endl;
}

Measured memory_bytes: 27292