akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def f(n):
    r = (n - 2)
    m = (4 * (1 - pow(2, r, MOD))) // (1 - 2)
    return (3 + m) % MOD


def modinv(a):
    return pow(a, MOD-2, MOD)


def cmb(n, r):
    p = 1
    c = 1
    for i in range(r):
        p *= (n - i)
        c *= (i + 1)
        p = p % MOD
        c = c % MOD
    return p * modinv(c) % MOD


def main():
    n, a, b = MI()
    first = cmb(n, a)
    second = cmb(n, b)
    ans = f(n)
    print((ans - first - second) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38892
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;

#define F first
#define S second


using namespace std;

int main() {

	SINT32 N = 0;
	SINT8 S;

	cin >> N;

	
	rep(i,0,N) {
		cin >> S;
		if (S == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    set<string> st;
    int N; cin >> N;
    rep(i, N){
        string s; cin >> s; st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 19272
A = []
a = []
for i in range(3):
    A.append(list(map(int, input().split())))
    a.append([0, 0, 0])

N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                a[j][k] += 1

judge = 'No'
for i in range(3):
    if a[0][i] == 1 and a[1][i] == 1 and a[2][i] == 1:
        judge = "Yes"
    elif a[i][0] == 1 and a[i][1] == 1 and a[i][2] == 1:
        judge = "Yes"
if a[0][0] == 1 and a[1][1] == 1 and a[2][2] == 1:
    judge = 'Yes'
elif a[0][2] == 1 and a[1][1] == 1 and a[2][0] == 1:
    judge = 'Yes'

print(judge)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		
		out.println((t/a)*b);
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef long long int LL;
typedef string STR;
/*FIN*/

int main()
{
	FAST;
	int n;
	cin>>n;
	V<LL> a(n+1), s(n+1);
	for(auto &i:a) cin>>i;
	LL _t = 1LL;
	bool f=1;
	for(int i=0;i<=n;i++) {
        if(_t < 1e18) s[i] = _t - a[i], _t = 2LL*s[i] ;
        else s[i] = 1e18 ;
		if(s[i]<0) {
			f=0;
			break;
		}
	}
	if(a[n]==0) f=0;
	LL ans=0;
	if(f) {
		ans += a[n];
		for(int d = n-1; d>=0; d--) {
			if(a[d+1] > 2*s[d]) {
				f=0;
				break;
			}
			ans += min(a[d+1], s[d]) + a[d];
			a[d] += min(a[d+1],s[d]);
		}
	}
	if(f) cout<<ans<<endl;
	else cout<<"-1\n";
	return 0;
}


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

string myitoa(int n){
    string res("");
    while( n > 0 ){
        char c = n%10 + '0';
        res = c + res;
        n /= 10;
    }
    return res;
}

string oper(string s){
    int n = 0;
    char c = s[0];
    string result("");
    for( string::iterator it = s.begin(); it != s.end(); it++){
        if( *it == c ){
            n++;
        }else{
            string h = myitoa(n);
            result.append( h );
            result.append( 1, c );
            c = *it;
            n = 1;
        }
    }
    string h = myitoa(n);
    result.append( h );
    result.append( 1, c );
    return result;
}

int main(){
    string s;
    int n;
    while( true ){
        cin >> n;
        if( !n ) break;
        cin >> s;
        while( n-- > 0 ){
            s = oper( s );
        }
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 1344
a, b, c, k = map(int, input().split())

flg = 0
if a - b > 0 and k % 2 == 0 or a-b < 0 and k % 2 == 0:
    flg = 1
elif a - b < 0 and k % 2 == 1 or a-b > 0 and k % 2 == 1:
    flg = -1

if abs(a-b) > 10 ** 18:
    print("Unfair")
else:
    print((a-b)*flg)

Measured memory_bytes: 38384
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


if __name__ == "__main__":
    n, m = map(int, input().split())

    g1 = Graph()

    for i in range(m):
        a, b = map(int, input().split())
        g1.add_edge(a-1, b-1)
        g1.add_edge(b-1, a-1)

    d = Dijkstra(g1, 0)

    if d.dist[n-1] == 2:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  i64 N, Q; string s;
  input(N, Q, s);

  vector<i64> cum(N + 10);
  rep(i, N - 1) {
    i64 j = i + 1;
    if (s.substr(i, 2) == "AC") cum[j+1]++;
    cum[j+2] = cum[j+1];
  }

  rep(i, Q) {
    var(i64, l, r);
    outl(cum[r] - cum[l]);
  }

  return 0;
}


Measured memory_bytes: 1872
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 15:32:11 2019

@author: Yamazaki Kenichi
"""

N = int(input())
pre = list(map(int,input().split()))
ino = list(map(int,input().split()))

tree = [[-1,-1,-1] for i in range(N+1)]
def make_tree(pre,ino):
    if len(pre)==0:
        return
    indx = ino.index(pre[0])
    if indx > 0:
        tree[pre[0]][1] = pre[1]
        tree[pre[1]][0] = pre[0]
        make_tree(pre[1:indx+1],ino[:indx])
    if indx != len(ino)-1:
        tree[pre[0]][2] = pre[indx+1]
        tree[pre[indx+1]][0] = pre[0]
        make_tree(pre[indx+1:],ino[indx+1:])
make_tree(pre,ino)

def pos(u,tree):
    res = []
    if tree[u][1] != -1:
        res += pos(tree[u][1],tree)
    if tree[u][2] != -1:
        res += pos(tree[u][2],tree)
    res += [str(u)]
    return res
ans = pos(pre[0],tree)
print(' '.join(ans))



Measured memory_bytes: 5628
#include<iostream>
using namespace std;
int main(){
int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k-a<=0){
    cout << k << endl;
  }
  else{
    if(k-a-b<=0){
    cout << a << endl;
    }
    else{
    cout << a-(k-a-b) << endl;
    }
  }
}

Measured memory_bytes: 3616
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
// int t;
// t = 1;
// cin >>t;
// while(t--){

string s;
string t;
cin >>s >> t;
  int ans = INT_MAX;
    int n = s.size(), k = t.size();
    for(int i=0; i<n-k+1; i++){
	string tmp = s.substr(i, (int)t.size());
	//cout << tmp << "\n";
	int cnt = 0;
	for(int i=0; i<(int)t.size(); i++){
	    if(tmp[i] != t[i])
		cnt++;
	}
	ans = min(ans, cnt);
    }
    cout << ans << "\n";
// }
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

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

int main() {
  int n, m, x; cin >> n >> m >> x;
  int c[n], a[n][m];
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  }
  
  int min_cost = 10000000;
  for (int bit = 0; bit < (1 << n); ++bit) {
    int cost = 0, sum_cmpr[m] = {};
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        cost += c[i];
        for (int j = 0; j < m; ++j) sum_cmpr[j] += a[i][j];
      }
    }
    bool ok = true;
    for (int i = 0; i < m; ++i) if (sum_cmpr[i] < x) ok = false;
    
    if (ok) min_cost = min(min_cost, cost);
  }
  
  if (min_cost == 10000000) cout << -1 << endl;
  else cout << min_cost << endl;
  
  return 0;
}

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

pair<int, int> A[ 100010 ];
pair<int, int> B[ 100010 ];

#define ff first
#define ss second

int main()
{
int i;
int j;
int n;
int v;

	cin >> n;

	for( i = 0; i < n; i += 2 )
	{
		cin >> v;

		A[ v ].ff++;
		A[ v ].ss = v;

		cin >> v;

		B[ v ].ff++;
		B[ v ].ss = v;
	}

	sort( A, A + 100000, std::greater<pair<int, int>>() );
	sort( B, B + 100000, std::greater<pair<int, int>>() );

	if( A[ 0 ].ss == B[ 0 ].ss )
	{
		if( A[ 1 ].ff == 0 && B[ 1 ].ff == 0 )
			cout << n / 2 << endl;
		else if( A[ 1 ].ff < B[ 1 ].ff )
			cout << n - A[ 0 ].ff - B[ 1 ].ff << endl;
		else
			cout << n - A[ 1 ].ff - B[ 0 ].ff << endl;
	}
	else
		cout << n - A[ 0 ].ff - B[ 0 ].ff << endl;

	return 0;
}




Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;


int main() {
	int a,b;
	cin>>a>>b;
	cout<<100<<" "<<100<<endl;
	a--;
	rep(i,0,25){
		rep(i,0,50){
			if(a>0){
				cout<<".#";
				a--;
			}else{
				cout<<"##";
			}
		}
		cout<<endl;
		rep(i,0,100)cout<<"#";
		cout<<endl;
	}
	b--;
	rep(i,0,25){
		rep(i,0,100)cout<<".";
		cout<<endl;
		rep(i,0,50){
			if(b>0){
				cout<<".#";
				b--;
			}else{
				cout<<"..";
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
   int n, t;
   int R[200000];
   int min, max;

   scanf("%d", &n);

   for ( t = 0; t < n; t++ ) {
      scanf("%d", &R[t]);
   }

   min = R[0];
   max = R[1] - R[0];

   for ( t = 1; t < n; t++ ) {
      if ( max < R[t] - min ) {
         max = R[t] - min;
      }
      if ( min > R[t] ) {
         min = R[t];
      }
   }
   printf("%d\n", max);

   return 0;
}
   

Measured memory_bytes: 2584
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

    if(x >= a && (a+b >= x)) puts("YES");
    else puts("NO");

    
}

Measured memory_bytes: 256
import sys
import collections as cc
import bisect as bi
I=lambda:list(map(int,input().split()))
n,=I()
s=int(n**0.5)
ans=0
for i in range(1,n+1):
    ans+=(n//i)
    if (n==(i)*(n//i)):
        ans-=1
print(ans)

Measured memory_bytes: 68412
import sys

input = sys.stdin.readline

def main():
    n = int(input())
    o = list(map(int, input().split()))
    l = [0]*n
    for i in range(n):
        l[o[i]-1] = i+1
    print(" ".join(map(str,l)))
if __name__ == '__main__':
    main()

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

int main(){
    cin >> n >> m;
    vector<int> a(n); //vectorを宣言するならnは先に代入しないといけない
    int sum = 0;
    rep(i,n){
        cin >> x;
        a[i] = x;
        sum += x;
    } 
    sort(a.begin(), a.end());
    int b = a[n-m];
    
    if(b*4*m < sum){
        cout << "No"<<endl;
    }
    else cout << "Yes" << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int enum_divisors(int N) {
    int res = 0;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            ++res;
            if (N/i != i) ++res;
        }
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    ll res = 0;
    for (int i = 1; i < N; ++i) {
        if (i >= N) break;
        int b = N / i;
        int c = N % i;
        if (c == 0) {
            res += b-1;
        } else res += b;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
    char b;
    cin >> b;
    if (b=='A')
    cout << 'T' << endl;
    else if (b=='C')
    cout << 'G' << endl;
    else if (b=='G')
    cout << 'C' << endl;
    else if (b=='T')
    cout << 'A' << endl;
}

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

int main() {
	int n;
	bool a[4][13];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 13; j++)
			a[i][j] = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char c;
		int r;
		cin >> c >> r;
		switch (c) {
		case 'S':
			a[0][r - 1] = false;
			break;
		case 'H':
			a[1][r - 1] = false;
			break;
		case 'C':
			a[2][r - 1] = false;
			break;
		case 'D':
			a[3][r - 1] = false;
			break;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (a[i][j]) {
				switch (i) {
				case 0:
					cout << "S " << j + 1 << endl;
					break;
				case 1:
					cout << "H " << j + 1 << endl;
					break;
				case 2:
					cout << "C " << j + 1 << endl;
					break;
				case 3:
					cout << "D " << j + 1 << endl;
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 3104
#include <stdio.h>

inline static int read_int() {
    int x = 0, k;
    while ((k = getchar_unlocked() - 'L') >= 0) x = x * 10 + k;
    return x;
}

inline static void put_int(int x) {
    int s = 0;
    char f[6] = {'0', '0', '0', '0', '0', '0'};
    if (!x) {
        putchar_unlocked('0');
        return;
    }
    while (x) {
        f[s++] += x % 10;
        x /= 10;
    }

    while (s--) putchar_unlocked(f[s]);
}

int main() {
    int flag = 0, l = 0, r = 0, i = 0, tmp, first = 1;

    for (;(tmp = getchar_unlocked() - 'L') >= 0; i++) {
        if (tmp) {
            // if c is R
            if (flag) {
                flag = 0;

                for (tmp = r + 1; tmp < l; tmp++) {
                    if (first) {
                        first = 0;
                    } else {
                        putchar_unlocked(' ');
                    }
                    putchar_unlocked('0');
                }

                if (first) {
                    first = 0;
                } else {
                    putchar_unlocked(' ');
                }
                tmp = (l - r + 1) / 2 + (i - l) / 2;
                put_int(tmp);
                putchar_unlocked(' ');
                tmp = (i - r) - tmp;
                put_int(tmp);

                for (tmp = l + 1; tmp < i; tmp++) {
                    putchar_unlocked(' ');
                    putchar_unlocked('0');
                }
                r = i;
            }
        } else {
            // if c is L
            if (!flag) {
                flag = 1;
                l = i;
            }
        }
    }

    for (tmp = r + 1; tmp < l; tmp++) {
        if (first) {
            first = 0;
        } else {
            putchar_unlocked(' ');
        }
        putchar_unlocked('0');
    }

    if (first) {
        first = 0;
    } else {
        putchar_unlocked(' ');
    }
    tmp = (l - r + 1) / 2 + (i - l) / 2;
    put_int(tmp);
    putchar_unlocked(' ');
    tmp = (i - r) - tmp;
    put_int(tmp);

    for (tmp = l + 1; tmp < i; tmp++) {
        putchar_unlocked(' ');
        putchar_unlocked('0');
    }

    putchar_unlocked('\n');
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	
	int h,r,ans;
	
	scanf("%d %d",&h,&r);
	
	ans=h+r;
	
	if(ans>=1){
		printf("%d\n",1);
	}else if(ans<=-1){
		printf("%d\n",-1);
	}else{
		printf("%d\n",0);
	}
	return 0;
}

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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

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

    string s;
    cin >> s;
    const int N = s.size();

    string s1;
    for (const char c : s) {
        if (c != 'x') {
            s1.push_back(c);
        }
    }
    string s2 = s1;
    reverse(s2.begin(), s2.end());
    if (s1 == s2) {
        const int size = s2.size() + 1;
        vector<int> num(size, 0);
        int ind = 0;
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (s[i] == 'x') {
                cnt++;
            } else {
                num[ind] = cnt;
                ind++;
                cnt = 0;
            }
        }
        num[size - 1] = cnt;

        ll sum = 0;
        for (int i = 0; i < size - 1 - i; i++) {
            sum += abs(num[i] - num[size - 1 - i]);
        }
        cout << sum << endl;

    } else {
        cout << -1 << endl;
    }


    return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
 
typedef long long ll;
typedef long double ld;
 
#define X first
#define Y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define deb(x) cerr << #x << " " << x << '\n';
#define fo(i, n) for(int i = 0; i < n; i++)
#define Fo(i, k, n) for(int i = k; k < n ? i < n : i > n; k < n ? i++ : i--)

#define int ll
 
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
using namespace std;

// vector<vector<int> > g(maxn);
// vector<int> used(maxn);
 
void pudge(){ 
    for (int i = 1; i <= 5; i++){
        int x;
        cin >> x;
        if (!x) cout << i << '\n';
    }
}
 
// #define PUDGE
// #define TIME

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

#ifdef PUDGE
    freopen("input.txt", "r", stdin);
    // freopen("pudge.out", "w", stdout);
#endif

#ifdef TIME
    auto start = chrono::steady_clock::now();
#endif
    
    // int q; cin >> q; while(q--)
    pudge();

#ifdef TIME
    auto end = chrono::steady_clock::now();
    auto diff = end - start;
    cout << chrono::duration <double, milli> (diff).count() << " ms\n";
#endif

    return 0;
}



Measured memory_bytes: 3608
<?php
fscanf(STDIN, '%d', $cnt);
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
$memo = [];
$ans = 0;
$mod = 1000000007;
$sum = array_fill(0, $cnt+1, 0);
for ($i=0; $i < $cnt; $i++) { 
    $sum[$i+1] = $sum[$i] + $nums[$i];
}
$ans = 0;
for ($i=0; $i < $cnt; $i++) { 
    $rui = ($sum[$cnt] - $sum[$i + 1]) % $mod;
    $ans += $nums[$i] * $rui;
    $ans %= $mod;
}
echo $ans;

Measured memory_bytes: 37996
N,A,B = map(int,input().split())
tmp = 0
x = 0
s = 0
for n in range(1,N+1):
  x = n
  tmp = 0
  while (x > 0):
    tmp = tmp + (x % 10)
    x = x // 10
  if (A <= tmp <= B):
    s = s + n
print(str(s))

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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && a != c){
    cout << "Yes" << endl;
  }
  else if(a == c && a != b){
    cout << "Yes" << endl;
  }
  else if(b == c && a != c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 3600
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	string S;cin>>S;

	// 解法
	if (S=="Sunny") printf("Cloudy");
	else if (S=="Cloudy") printf("Rainy");
	else if (S=="Rainy") printf("Sunny");
}


Measured memory_bytes: 256
n, k = map(int, input().split())

cnt = [0]*n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for _ in a:
        cnt[_-1] += 1

ans = 0

for c in cnt:
    if c == 0:
        ans += 1


print(ans)

Measured memory_bytes: 67704
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#include<map>
#include<list>
using namespace std;

int p[1005];

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&p[i]);
	}
	sort(p+1,p+n+1);
	int sum=0;
	for(int i=1; i<=k; i++) sum+=p[i];
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3772
import java.util.*;
import java.io.*;

// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		double[] x=new double[N];
		double[] y=new double[N];
		for(int i=0;i<N;++i){
			x[i]=sc.nextDouble();
			y[i]=sc.nextDouble();
		}
		double eps=1e-7;
		double ans=9e5;
		for(int i=0;i<N;++i){
			for(int j=0;j<N;++j){
				double mx=(x[i]+x[j])*0.5;
				double my=(y[i]+y[j])*0.5;
				double l=Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
				boolean flag=true;
				for(int k=0;k<N;++k){
					double dx=mx-x[k];
					double dy=my-y[k];
					flag&=eps>Math.sqrt(dx*dx+dy*dy)-l/2;
				}
				if(flag)ans=Math.min(ans,l/2);
			}
		}
		
		for(int i=0;i<N;++i){
			for(int j=i+1;j<N;++j){
				for(int k=j+1;k<N;++k){
					double[] pos=f(new double[]{x[i],x[j],x[k]},new double[]{y[i],y[j],y[k]});
					double mx=pos[0];
					double my=pos[1];
					double l=2*Math.sqrt((x[i]-mx)*(x[i]-mx)+(y[i]-my)*(y[i]-my));
					boolean flag=true;
					for(int m=0;m<N;++m){
						double dx=mx-x[m];
						double dy=my-y[m];
						flag&=eps+l/2>Math.sqrt(dx*dx+dy*dy);
					}
					if(flag)ans=Math.min(ans,l/2);
				}
			}
		}
		System.out.println(ans);
	}
	
	double[] f(double[] x,double[] y){
		double[] X=new double[3];
		for(int i=0;i<3;++i){
			X[i]=x[i]*x[i]+y[i]*y[i];
		}
		double[][] v={{X[0]-X[1]},{X[1]-X[2]}};
		double a=x[0]-x[1];
		double b=y[0]-y[1];
		double c=x[1]-x[2];
		double d=y[1]-y[2];
		double det=2*(a*d-c*b);
		if(det==0)return new double[]{0,0};
		return new double[]{1/det*(d*v[0][0]-b*v[1][0]),1/det*(-c*v[0][0]+a*v[1][0])};
	}
	
	
	void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}
// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase
	

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

typedef long long ll_t;

#define PERR(fmt, ...) \
    do { \
        fprintf(stderr, fmt, ##__VA_ARGS__); \
    } while (0) 

ll_t N, M;
ll_t X;

int main() {
    scanf("%lld%lld", &N, &M);
        
    if (N >= M / 2)
        X = M / 2;
    else 
        X = N + (M - 2 * N) / 4;

    printf("%lld\n", X);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    int tmp = A - (B * 2);

    if(tmp > 0){
        cout << tmp << endl;
        return 0;
    }
    else {
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	ll a;
	cin>>a;
	ll ans;
	for(ll i=1;i*i<=a;i++)
	{
		if(a%i==0)
			ans=i;
	}
	ans = ans + a/ans-2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mod=1000000007;
int n,k;
vector<int> g[100001];
ll dfs(int par,int mul,int v){
    ll ret=mul;
    mul=k-2;
    if(par==-1) mul=k-1;
    if(k<=0) return 0;
    rep(i,g[v].size()){
        if(g[v][i]==par) continue;
        ret*=dfs(v,mul,g[v][i])%mod;
        --mul;
        ret%=mod;
    }
    return ret;
}
int main(){
    cin>>n>>k;
    int ai,bi;
    rep(i,n-1){
        cin>>ai>>bi;
        --ai,--bi;
        g[ai].pb(bi);
        g[bi].pb(ai);
    }
    cout<<dfs(-1,k,0)<<endl;
    return 0;
}


Measured memory_bytes: 11520
import sys

readline = sys.stdin.readline

def main():
    N = int(input())
    store = []
    for i in range(N):
        S, P = readline().split()
        P = int(P)
        store.append([i+1,S,P])
    store.sort(key=lambda x: x[2], reverse=True)
    store.sort(key=lambda x: x[1])
    
    for s in store:
        print(s[0])

if __name__ == "__main__":
    main()


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(3), B(3);
    cin >> A[0] >> A[1] >> A[2];
    cin >> B[0] >> B[1] >> B[2];
    vector<ll> dp1(N+1, N);
    for (int i = 0; i < 3; i++) {
        if (A[i] >= B[i]) continue;
        for (ll j = A[i]; j <= N; j++) {
            dp1[j] = max(dp1[j], dp1[j-A[i]]+B[i]-A[i]);
        }
    }
    ll M = N;
    for (ll m : dp1) M = max(M, m);
    
    vector<ll> dp2(M+1, M);
    for (int i = 0; i < 3; i++) {
        if (A[i] <= B[i]) continue;
        for (ll j = B[i]; j <= M; j++) {
            dp2[j] = max(dp2[j], dp2[j-B[i]]+A[i]-B[i]);
        }
    }
    ll ans = 0;
    for (ll l : dp2) ans = max(ans, l);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_N = 105;
const int MAX_K = 1e5 + 5;

namespace modOp {
    int add(int a, int b, int mod = MOD) { return (a + b) % mod; }
    int sub(int a, int b, int mod = MOD) { return (a - b + mod) % mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a * b % mod; }
}
using namespace modOp;

int N, K;
int a[MAX_N];
ll dp[MAX_N][MAX_K];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> K;
	for (int i = 1; i <= N; ++i) {
		cin >> a[i];
	}


	dp[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= K; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (j != 0) dp[i - 1][j] = add(dp[i - 1][j], dp[i - 1][j - 1]);
		}
		for (int j = K; j >= 1; --j) {
			dp[i][j] = add(dp[i][j], sub(dp[i - 1][j - 1], (j - a[i] <= 0 ? 0 : dp[i - 1][j - a[i] - 1])));
		}
	}

	cout << dp[N][K] << '\n';

	return 0;
}

Measured memory_bytes: 80128
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
ll N, L, T;
ll X[MAX_N+1], W[MAX_N+1];

int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);
  
  cin >> N >> L >> T;
  repa(i, 1, N) cin >> X[i] >> W[i];

  vector<int> pos(N);
  for (int i = 1; i <= N; ++i) {
    if (W[i] == 1) {
      pos[i-1] = mod(X[i]+T, L);
    } else {
      pos[i-1] = mod(X[i]-T, L);
    }
  }
  ll pos0 = pos[0];
  sort(all(pos));

  ll id = 0;
  if (W[1] == 1) {
    for (int i = 2; i <= N; ++i) {
      if (W[i] == 2) {
        if (X[i]-X[1] > 2*T) continue;
        ll K = (2*T-X[i]+X[1])/L + 1;
        if ((2*T-X[i]+X[1])%L == 0) --K;
        id += K;
        id %= N;
      }
    }
    id = mod(id, N);
  } else {
    for (int i = 2; i <= N; ++i) {
      if (W[i] == 1) {
        if (L-X[i]+X[1] > 2*T) continue;
        ll K = (2*T-L+X[i]-X[1])/L + 1;
        id -= K;
        id %= N;
      }
    }
    id = mod(id, N);
  }

  vector<Pii> ans;
  int i = lower_bound(all(pos), pos0) - pos.begin();
  for (int k = 0; k < N; ++k) {
    ans.push_back(Pii(mod(id-i+k, N), pos[k]));
  }
  sort(all(ans));

  for (int i = 0; i < N; ++i) {
    cout << ans[i].sc << endl;
  }

  return 0;
}


Measured memory_bytes: 4084
import sys
sys.setrecursionlimit(10**6)

N=int(input())
H=list(map(int,input().split()))

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])



Measured memory_bytes: 13924
#include <stdio.h>
#include <string.h>
int main(){
int a,b,x,y;
char c[100];
scanf("%d",&a);
getchar();
scanf("%[^\n]",&c);

x=strlen(c);
y=x-a;
if(x>a){
	for (int i=0;i<a;i++){
		printf("%c",c[i]);
	}
	printf("...\n");
}

else{
	for(int i=0;i<x;i++){
		printf("%c",c[i]);
	}
}
}

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

int main(){

    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    
    vector<vector<long long> > dp(100, vector<long long>(2, -1));
    dp[45][0] = 0;
    for(int d = 44; d >= 0; d--){
        long long mask = 1LL << d;
        int num = 0;
        for(int i = 0; i < N; i++) if(A[i] & mask) num++;
        
        if(dp[d + 1][1] >= 0) dp[d][1] = max(dp[d][1], dp[d + 1][1] + mask * max(num, N - num));
        if(dp[d + 1][0] >= 0){
            if(K & (1LL << d)){
                dp[d][1] = max(dp[d][1], dp[d + 1][0] + mask * num);
                dp[d][0] = max(dp[d][0], dp[d + 1][0] + mask * (N - num));
            }else{
                dp[d][0] = max(dp[d][0], dp[d + 1][0] + mask * num);
            }
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, l, q;
int x[100010];
int table[100010][20];
signed main() {
    cin >> n;
    rep(i,0,n) cin >> x[i];
    cin >> l >> q;
    int cur = 0;
    rep(i,0,n) {
        while(cur < n && x[i] + l >= x[cur]) cur++;
        table[i][0] = cur - 1;
    }
    rep(j,1,20) rep(i,0,n) {
        table[i][j] = table[table[i][j-1]][j-1];
        // printf("table[%lld][%lld] = %lld\n", i, j, table[i][j]);
    }
    rep(i,0,q) {
        int a, b; cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);
        int ans = 1, idx = a;
        repr(j,19,0) {
            if(table[idx][j] < b) {
                idx = table[idx][j];
                ans += (1 << j);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 17280
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

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

  int ans = 0;
  FOR(i, 1, n - 1){
    vec t = {p[i-1], p[i], p[i+1]};
    int max = *max_element(t.begin(),t.end());
    int min = *min_element(t.begin(),t.end());
    if(t[1] != max && t[1] != min){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int x, y;

	for (;;){

		scanf("%d %d", &x, &y);

		if (x == 0 && y == 0) return 0;

		if (x <= y){
			printf("%d %d\n", x, y);
		}
		else{
			printf("%d %d\n", y, x);
		}
	}

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  double maxCons = -1;
  pair<int, int> maxPair;
  rep(b, F/(B*100)+1) {
    int G = F-b*B*100;
    rep(a, G/(A*100)+1) {
      int H = G-a*A*100;
      rep(d, H/D+1) {
        int I = H-d*D;
        rep(c, I/C+1) {
          int sug = c*C+d*D;
          int wat = a*A+b*B;
          if(sug <= wat*E && 100.0*sug/(wat*100+sug) > maxCons)
            maxCons = 100.0*sug/(wat*100+sug), maxPair = make_pair(wat*100+sug, sug);
        }
      }
    }
  }
  cout << maxPair.first << ' ' << maxPair.second << endl;
  return 0;
}



Measured memory_bytes: 256
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

print(int(a + b/2))

Measured memory_bytes: 38384
n = int(input())
s = str(input())

ans_s = s
ans_head = 0
ans_tail = 0

def remove(s):
    while True:
        if len(s) <= 0:
            break
        pre_len = len(s)
        s = s.replace("()", "")
        if len(s) == pre_len:
            break
    return s

s = remove(s)
while len(s) > 0:
    s = remove(s)
    if s[0] == ')':
        ans_head += 1
        s = remove('(' + s)
    else:
        ans_tail += 1
        s = remove(s + ')')
    # print(s)
print('('*ans_head + ans_s + ')' * ans_tail)



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


int main(){
  int N;
	cin>>N;
  vector<vector<int>> info(N);
  rep(i,N){
    ll x,y,h; cin>>x>>y>>h;
    info.at(i).pb(x);
    info.at(i).pb(y);
    info.at(i).pb(h);
  }
  ll high;

  int flag;
  rep(i,N){
    if (info.at(i).at(2) > 0){
      flag=i;
      break;
      }
  }
  int x = info.at(flag).at(0);
  int y = info.at(flag).at(1);
  ll h = info.at(flag).at(2);
  int cnt;
  //全探索
  rep(i,101){
    rep(j,101){
      cnt=0;
      high = h + abs(i-x) + abs(j-y);
      bool flag = true;
      rep(k,N){
        
        int x = info.at(k).at(0);
        int y = info.at(k).at(1);
        ll h = info.at(k).at(2);
        ll hh = high - abs(i-x) - abs(j-y);
        hh = max(hh,0LL);
        if(h != hh) flag = false;
        
      }
      if(flag == true){cout<<i<<' '<<j<<' '<<high<<endl;}
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main(){
  int A,N;
  map<int,int> cnt;
  cin  >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    cnt[A]++;
  }
  int ans = 0;
  for(auto & x : cnt){
    if(x.second % 2 == 1) ans ++;
  }
  cout << ans  << endl;
}


Measured memory_bytes: 4864