akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	set <string> s;
	FOR (i, 1, n)
	{
	    string str;
	    cin >> str;
	    s.insert(str);
	}
	
	cout << sz(s);
}














Measured memory_bytes: 19292
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int xorbelow(int x) {
    //0^1^2^3^...^x
    int ans = 0;
    if (x % 4 == 1 || x % 4 == 2)ans = 1;
    for (int i = 1; i < 50; ++i) {
        int cycle = (1ll << (i + 1));
        int cnt = (x + 1) % cycle;
        if (cnt <= cycle / 2)continue;
        cnt -= cycle / 2;
        if (cnt % 2 == 1)ans += 1ll << i;
    }
    return ans;
}

signed main() {
    int A, B;
    cin >> A >> B;
    cout << (xorbelow(A - 1) ^ xorbelow(B)) << endl;
    return 0;
}


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

int dp[2][200005];

int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> dp[0][i];
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++) dp[i % 2][j] = 0;
        for(int j = 0; j < n; j++){
            dp[i % 2][max(0, j - dp[(i + 1) % 2][j])]++;
            dp[i % 2][min(n, j + dp[(i + 1) % 2][j] + 1)]--;
        }
        for(int j = 1; j < n; j++) dp[i % 2][j] += dp[i % 2][j - 1];
        bool f = true;
        for(int j = 0; j < n; j++){
            if(dp[i % 2][j] != n) f = false;
        }
        if(f){
            k = i;
            break;
        }
    }
    for(int j = 0; j < n; j++) cout << dp[k % 2][j] << " ";
    cout << endl;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

vector<lint> a;
vector<lint> inv[MAX];
int main(){
    lint n, k; cin >> n >> k;
    rep(i, n){
        lint x; cin >> x;
        a.push_back(x);
        inv[x].push_back(i);
    }

    lint s = 0; lint b;
    vector<lint> v;
    while(1){
        if(s == n){
            v.push_back(n); break;
        }
        b = a[s];
        auto itr = upper_bound(all(inv[b]), s);
        if(itr == inv[b].end()){
            v.push_back(s);
            s = inv[b][0] + 1;
            continue;
        }
        s = (*itr) + 1;
    }

    lint p = v.size(); k = (k - 1) % p;
    s = v[k]; vector<lint> ans;
    while(s < n){
        b = a[s];
        auto itr = upper_bound(all(inv[b]), s);
        if(itr == inv[b].end()){
            ans.push_back(b); s++;
        }
        else{
            s = (*itr) + 1;
        }
    }

    rep(i, ans.size()){
        cout << ans[i] << " ";
    }
    cout << endl;;
}


Measured memory_bytes: 17392
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::string str;

using namespace std;

inline int nxt(){int x;cin>>x;return x;}

inline str nxt_str(){str x;cin>>x;return x;}

inline ll nxt_ll(){ll x;cin>>x;return x;}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n=nxt();
    str s=nxt_str();
    int ans=1;
    char cur=s[0];
    rep(i,1,n-1){
        if(s[i]!=cur){
            cur=s[i];
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

vector<vector<int>> to;
void dfs(int now, int prev, int dep, int& mx, int& node) {
  if (chmax(mx, dep))
    node = now;
  for (auto next : to[now]) {
    if (next == prev)
      continue;
    dfs(next, now, dep+1, mx, node);
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << "First\n";
    return 0;
  }
  to.resize(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int k = 1, root = 0;
  dfs(0, -1, 1, k, root);
  dfs(root, -1, 1, k, root);
  if (k%3 != 2)
    cout << "First\n";
  else
    cout << "Second\n";
  return 0;
}

Measured memory_bytes: 29776
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int cnt[60*60*24 + 1];

int main(){
  int n;
  while(scanf("%d",&n), n){
    int h,m,s,hh,mm,ss;
    memset(cnt, 0, sizeof(cnt));
    REP(i,n){
      scanf("%d:%d:%d %d:%d:%d",&h,&m,&s,&hh,&mm,&ss);
      //printf("%d:%d:%d %d:%d:%d\n",h,m,s,hh,mm,ss);
      int st = h * 3600 + m * 60 + s;
      int ed = hh* 3600 + mm* 60 + ss;

      do{
        ++cnt[st];
      }while(++st < ed);
    }

    int ans = 0;
    REP(i,60*60*24+1)
      ans = max(ans, cnt[i]);

    print(ans);
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();		
		int t = 0, x = 0, y = 0;
		boolean flg = true;
		for (int i = 0; i < N; i++) {
			int nowT = sc.nextInt();
			int nowX = sc.nextInt();
			int nowY = sc.nextInt();
			int time = nowT - t;
			int dist = Math.abs(x - nowX) + Math.abs(y - nowY);
			if (time < dist || time%2 != dist%2) {
				flg = false;
				break;
			}
			t = nowT;
			x = nowX;
			y = nowY;
		}
		System.out.println(flg ? "Yes" : "No");
	}
}

Measured memory_bytes: 86804
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 1<<17, rt = 1<<10;
int n;
vi a, b, c, sa, sb;
bool check() {
	map<int, int> cnt;
	for(int p = 0, i = 0; i < n-1; i++) {
		if(cnt[p]++) return true;
		p = c[p];
	}
	return false;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	a.resize(n);
	for(auto &i : a) cin >> i;
	sa = a;
	sort(all(sa));
	b.resize(n);
	for(auto &i : b) cin >> i;
	sb = b;
	sort(all(sb));
	for(int i = 0; i < n; i++) if(sa[i] > sb[i]) return cout << "No", 0;
	for(int i = 1; i < n; i++) if(sa[i] <= sb[i-1]) return cout << "Yes", 0;
	for(auto &i : a) i = lower_bound(all(sa), i) - sa.begin();
	for(auto &i : b) i = lower_bound(all(sb), i) - sb.begin();
	map<int, int> pos;
	for(int i = 0; i < n; i++) pos[a[i]] = i;
	for(auto i : b) c.push_back(pos[i]);
	cout << (check() ? "Yes" : "No");
}


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

def bubble_sort(A, N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1
                flag = 1
    return A, count


A, count = bubble_sort(A, N)
string = list(map(str, A))
print(' '.join(string))
print(count)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double ld;
ld dist(P p1,P p2){
  ll s2=(p1.first-p2.first)*(p1.first-p2.first);
  s2+=(p1.second-p2.second)*(p1.second-p2.second);
  return sqrt((ld)s2);
}
int main(){
  int n;
  cin>>n;
  int perm2[10];
  for(int i=0;i<10;i++) perm2[i]=i;
  vector<P> vec;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    vec.push_back(P(a,b));
  }
  ld ans=0;
  do{
    for(int i=0;i<n-1;i++) ans+=dist(vec[perm2[i]],vec[perm2[i+1]]);
  }while(next_permutation(perm2,perm2+n));
  ll av=1;
  for(int i=n;i>=1;i--) av*=i;
  cout<<fixed;
  cout<<setprecision(10)<<ans/(ld)av<<endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;
typedef long long ll;

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

int main() {

    string S;
    cin >> S;
    ll N = S.length();
    string out = "Yes";
    rep(i,N/2){
        if(S[i] != S[N-1-i]){
            out = "No";
            break;
        }
    }
    rep(i,(N-1)/4){
        if(S[i] != S[(N-1)/2-1-i]){
            out = "No";
            break;
        }
    }
    for(ll i = (N+3)/2-1; i < (int)(N); i++){
        if(S[i] != S[N-1-i]){
            out = "No";
            break;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num[100] = { 0 };
	int money[100] = { 0 };
	int i = 0;
	float kai = 0.0;
	int tmp = 0, ans = 0;
	float number = 0.0;
	int ans_num = 0;
	
	while (scanf("%d,%d", &money[i], &num[i]) != EOF){
		ans += (num[i] * money[i]);
		number += num[i];
//		if ((num[i] == 0) && (money[i] == 0)){
//			break;
//		}
		i++;
		kai += 1.0;
	}
	
//	printf("***%.0f***%.0f***\n", number, kai);
	
	ans_num = ((((number / kai) + 0.5) * 10) / 10);
	
	printf("%d\n", ans);
	printf("%d\n", ans_num);
	
	return (0);
}

Measured memory_bytes: 0
import os
import sys
from collections import deque

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

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
CD = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

S = N * 2
T = N * 2 + 1

graph = [[] for _ in range(N * 2 + 2)]
for i, (a, b) in enumerate(AB):
    for j, (c, d) in enumerate(CD):
        if a < c and b < d:
            rev = [i, 0]
            edge = [j + N, 1, rev]
            rev.append(edge)
            graph[i].append(edge)
            graph[j + N].append(rev)
for i in range(N):
    rev = [S, 0]
    edge = [i, 1, rev]
    rev.append(edge)
    graph[S].append(edge)
    graph[i].append(rev)
for i in range(N):
    rev = [i + N, 0]
    edge = [T, 1, rev]
    rev.append(edge)
    graph[i + N].append(edge)
    graph[T].append(rev)


def bfs(s):
    # s からの距離
    ret = [-1] * len(graph)
    ret[s] = 0
    que = deque([(s, 0)])
    while que:
        v, d = que.popleft()
        for u, cap, _ in graph[v]:
            if ret[u] < 0 and cap > 0:
                ret[u] = d + 1
                que.append((u, d + 1))
    return ret


def dinic(v, t, f, dist, iter):
    if v == t:
        return f
    while iter[v] < len(graph[v]):
        edge = graph[v][iter[v]]
        to, cap, rev = edge
        if dist[v] < dist[to] and cap > 0:
            d = dinic(to, t, min(f, cap), dist, iter)
            if d > 0:
                edge[1] -= d
                rev[1] += d
                return d
        iter[v] += 1
    return 0


flow = 0
while True:
    dist = bfs(S)
    if dist[T] < 0:
        break
    while True:
        f = dinic(S, T, INF, dist, [0] * len(graph))
        if f == 0:
            break
        flow += f
print(flow)


Measured memory_bytes: 4084
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll fn = 0;
    for(ll n2 = n; n2 > 0; n2 /= 10){
        fn += n2 % 10;
    }
    if(n % fn == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{

  
int N,n;
cin >> N >> n;
int a[n],sum=N; 
for(int i=0;i<n;i++) cin >> a[i];


  int ans=a[n-1]-a[0];
  for(int i=0;i<n-1;i++)
  {
    ans=min(ans,sum-(a[i+1]-a[i]));
  }
cout<<ans;

  return 0;
}

Measured memory_bytes: 1792
A, B, N = map(int, input().split())
if B == 1:
    print(0)
else:
    ans = (A * N) // B - A * (N // B)
    for a in range(A):
        x = B * a + (B - 1)
        if x > N:
            break
        test = (A * x) // B - A * (x // B)
        ans = max(ans, (A * x) // B - A * (x // B))
    print(ans)

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

long long diff (long long target, const vector <long long> & pos, const vector <long long> & neg) {
	long long ans = 0;
	int r = 0;
	for (int l = pos.size() - 1; l >= 0; --l) {
		while (r < neg.size() && pos[l] * neg[r] > target) ++r;

		ans += neg.size() - r;
	}

	return ans;
}

long long same (long long target, const vector <long long> & v) {
	long long ans = 0;
	int r = v.size () - 1;
	for (int l = 0; l < v.size(); ++l) {
		while (r >= 0 && v[l] * v[r] > target) --r;

		ans += r + 1;
		if (l <= r)
			--ans;
	}

	return ans;
}

long long count (long long target, const vector <long long> & pos, const vector <long long> & neg) {
	long long ans = diff (target, pos, neg);
	// cout << " (ans = " << ans << ") ";
	ans += (same (target, pos) + same (target, neg)) >> 1LL;
	return ans;
}

int main () {

	int n;
	cin >> n;

	long long k;
	cin >> k;
	
	vector <long long> pos, neg;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf ("%d", &x);

		if (x < 0)
			neg.push_back (x);
		else
			pos.push_back (x);
	}

	sort (pos.begin(), pos.end());
	sort (neg.begin(), neg.end());
	reverse (neg.begin(), neg.end());

	// for (int i = -10; i <= 10; ++i)
		// cout << i << ": " << count (i, pos, neg) << endl;

	long long l = -1000000000000000001LL, r = 1000000000000000000LL;
	while (l + 1 < r) {
		long long mid = (l + r) >> 1LL;
		if (count (mid, pos, neg) < k)
			l = mid;
		else
			r = mid;
	}

	cout << r << endl;
	

	return 0;
}

Measured memory_bytes: 2548
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    import itertools
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ks = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    p = list(map(int, input().rstrip('\n').split()))
    a_cnt = 0
    for v in itertools.product([True, False], repeat=n):
        b = True
        for j, vv in enumerate(ks):
            cnt = 0
            for i in range(vv[0]):
                if v[vv[i+1]-1]:
                    cnt += 1
            if cnt % 2 != p[j]:
                b = False
                break
        if b:
            a_cnt += 1
    print(a_cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 66540
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int num;
    int count=0;
    scanf("%d", &num);
    for(int i=0; i<3; i++){
        if(num%2==1) count++;
        num/=10;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
(setq s(loop for i from 1 to 3 collect(map'list #'(lambda(c)(-(char-code c)97))(read-line))))
(setq f 0)
(loop
  (if(null(nth f s))(return))
  (setq v f)
  (setq f(car(nth f s)))
  (setf(nth v s)(cdr(nth v s))))
(princ(code-char(+ f 65)))

Measured memory_bytes: 13156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[100000];
int H[100000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		H[i] = rei();
	}
	DP[1] = abs(H[1]-H[0]);
	for(int i=2;i<N;i++){
		DP[i] = min(abs(H[i]-H[i-2])+DP[i-2],abs(H[i]-H[i-1])+DP[i-1]);
	}
	cout << DP[N-1] << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1408
#pragma region header
#define _GLIBCXX_DEBUG 
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
signed main() {
    int N,K;
    cin>>N>>K;
    int ans=0;

    vector<int>l(N);
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    sort(l.begin(), l.end()); // {1, 2, 2, 5}
    reverse(l.begin(), l.end());
    for(int i=0;i<K;i++){
        ans+=l[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
N = int(input())
X = [int(x) for x in input().split()]
_X = [x for x in X]
_X.sort()
x1 = _X[N // 2 - 1]
x2 = _X[N // 2]
for x in X:
  print(x2 if x <= x1 else x1)

Measured memory_bytes: 26356
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, X: "List[int]"):
    ret = float('inf')
    for p in range(101):
        tmp = 0
        for u in X:
            tmp += (u - p) ** 2
        ret = min(ret, tmp)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
const ll mod = 1e9 + 7;
vector<int>g[maxn];
ll dp[maxn][2], n;
ll u, v;

void dfs(int node, int p) {
    if((g[node].size() == 1 && g[node][0] == p) || g[node].size() == 0) {
        dp[node][0] = dp[node][1] = 1LL;
    }

    dp[node][0] = 1LL;
    dp[node][1] = 1LL;
    for(int i:g[node]) {
        if(i != p) {
            dfs(i, node);
            dp[node][0] *= dp[i][1];
          	dp[node][0] %= mod;
            dp[node][1] *= ((dp[i][0] + dp[i][1])%mod);
          	dp[node][1] %= mod;
        }
    }
}

int main() {
    cin>>n;
    for(int i=0;i<n-1;i++) {
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }

    dfs(1, -1);
    cout<<(dp[1][0] + dp[1][1])%mod<<"\n";
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
    int n;
  cin>>n;
  map<int,int> K;
  fx(n){
    int a;
    cin>>a;
    K[x+1]=a;
  }
  int ans=0;
  fx(n){
    if(K[K[x+1]]==x+1){
      ans++;
    }
  }
  ce(ans/2)
    return 0;
}



Measured memory_bytes: 4992
import sys
f = sys.stdin

p = [
(27,28,29, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,15,14,16,17,20,19,18,21,22,23,24,25,26, 0, 1, 2),
( 0, 1, 2, 3, 4, 5,21,22,23,11,10, 9,17,13,14,15,16,12,18,19,20, 6, 7, 8,24,25,26,27,28,29),
( 0, 1,21, 3, 4,24, 6, 7,27, 9,10,18,14,13,12,15,16,17,11,19,20, 2,22,23, 5,25,26, 8,28,29),
(23, 1, 2,26, 4, 5,29, 7, 8,20,10,11,12,13,14,17,16,15,18,19, 9,21,22, 0,24,25, 3,27,28, 6)]

def t(c,p):
    return tuple(c[i] for i in p)

start = (1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3)
cache ={start:0}

def create_cache(c,cnt):
    cnt += 1
    if cnt > 8:
        return
    for pi in p:
        ci = t(c,pi)
        if ci not in cache or cache[ci] > cnt:
            cache[ci] = cnt
            create_cache(ci, cnt)

create_cache(start, 0)
            

n = int(f.readline())
for i in range(n):
    c = tuple(map(int, f.readline().split()))
    if c in cache:
        print(cache[c])
    else:
        print('not found')

Measured memory_bytes: 6840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll N;
	ll D, X;
	cin >> N;
	cin >> D >> X;
	ll A[N + 3];
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
  	ll sum=0;
	for (ll i = 0; i < N; i++) {
		ll j = 1;
		while (j <= D) {
			j += A[i];
			sum++;
		}
	}
	cout << sum + X << endl;
	
}



Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[][] dp=new int[n+1][40001];
int[] a=new int[n];
StringTokenizer st1=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++){
a[i]=Integer.parseInt(st1.nextToken());
}
int m=Integer.parseInt(br.readLine());
int[] b=new int[m];
StringTokenizer st2=new StringTokenizer(br.readLine());
int max=Integer.MIN_VALUE;
for(int i=0;i<m;i++){
b[i]=Integer.parseInt(st2.nextToken());
max=Math.max(max,b[i]);
}
dp[n][0]=1;
for(int i=n-1;i>=0;i--){
for(int j=0;j<=max;j++){
if(j<a[i]) dp[i][j]=dp[i+1][j];
else dp[i][j]=Math.max(dp[i+1][j],dp[i+1][j-a[i]]);
}
}
for(int i=0;i<m;i++){
out.println(dp[0][b[i]]==1?"yes":"no");
}
out.flush();
}
}
}

Measured memory_bytes: 23856
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>

using namespace std;

int main()
{
	int n;
	while(cin>>n,n){
		vector<long long> dp(n);
		long long res;
		cin>>dp[0];
		res=dp[0];

		for(int i=1;i<n;i++){
			long long a;
			cin>>a;
			dp[i]=max(dp[i-1]+a,a);
			res=max(res,dp[i]);
		}
		cout<<res<<endl;
	}


	return 0;
}

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

int main()
{
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << 4 + (n + min({a, b, c, d, e}) - 1) / min({a, b, c, d, e}) << endl;
}

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

int main(void) {
    int N;
    int maxh; 
    int H,cnt;

    maxh = 0;
    cnt = 0;

    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> H;
        if(maxh <= H) {
            cnt++;
            maxh = H;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int n, r = 0, d, s = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> d;
    r += s * d;
    s += d;
  }
  cout << r;

  return 0;
}


Measured memory_bytes: 888
import Data.List
main = do
       as<-getLine
       xs<-getLine
       ys<-getLine
       let (n:m:x:y:[])=(map read . words) as::[Int]
           xs2=(map read . words) xs::[Int]
           xs3=x:xs2
           ys2=(map read . words) ys::[Int]
           ys3=y:ys2
           x2=(maximum xs3)+1
       putStrLn $ if length (filter (>=x2) ys3)==length ys3 then "No War" else "War"
       -- your code goes here

Measured memory_bytes: 1020
#include <iostream>
	const int AMAX=100000;
    long long Z[AMAX+1];
    int main(void){
        int N;
        long long K;
        std::cin>>N>>K;
        
        for(int i=0;i<N;++i){
            int A,B;
            std::cin>>A>>B;
            Z[A]+=B;
        }
        for(int ans=1;ans<=AMAX;++ans){
            if(K<=Z[ans]){
                std::cout<<ans<<std::endl;
                break;
            }
            K-=Z[ans];
        }
    }

Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int vs[100000+10];
int hist[2][100000+10];

struct K {
  int v;
  int num;
};
bool operator<(const K& k1, const K& k2) {
  return k1.num < k2.num;
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
    hist[i%2][vs[i]]++;
  }
  vector<K> ks[2];
  REP(i, 2) {
    REP(j, 100000+1) {
      ks[i].push_back((K){j, hist[i][j]});
    }
    sort(ks[i].begin(), ks[i].end());
    reverse(ks[i].begin(), ks[i].end());
  }
  int res = n;
  REP(i1, 2) REP(i2, 2) {
    if(i1 < (int)ks[0].size() && i2 < (int)ks[1].size()) {
      if(ks[0][i1].v != ks[1][i2].v) {
        res = min(res, ((n+1)/2-ks[0][i1].num) + (n/2-ks[1][i2].num));
      }
    }
  }
  printf("%d\n", res);
  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<vector<int>> v(m);
    vector<int> p(m);
    inc(i, 0, m){
        int k;cin >> k;
        inc(j, 0, k){
            int s;cin >> s;s--;
            v[i].pb(s);
        }
    }
    inc(i, 0, m){
        cin >> p[i];
    }

    int ans = 0;
    inc(bit, 0, 1<<n){
        int sum = 0;
        inc(i, 0, m){
            int cnt = 0;
            for(auto s : v[i]){
                if((bit>>s)%2){
                    cnt++;
                }
            }
            if(cnt%2 == p[i]){
                sum++;
            }
        }
        if(sum == m){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
typedef pair<int, int> P;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}
void eulerTour(int now, int& cnt, int dist, int parent, const vector<vector<int>>& edge, vector<P>& v_arr) {
	v_arr[cnt++] = {dist, now};
	for (auto it : edge[now]) {
		if (parent != it) {
			eulerTour(it, cnt, dist + 1, now, edge, v_arr);
			v_arr[cnt++] = {dist, now};
		}
	}
}

vector<pair<long long, long long>> eulerTour(int v, const vector<vector<int>>& edge, int s = 0) {
	int cnt = 0;
	vector<pair<long long, long long>> v_arr((v - 1) * 2 + 1);
	eulerTour(s, cnt, 0, -1, edge, v_arr);
	return v_arr;
}

class RMQ {
	vector<pair<long long, long long>> node;
	int size = 1;
	const pair<long long, long long> inf = {INT_MAX, INT_MAX};

  public:
	RMQ(int n) {
		while (size < n) size *= 2;
		node.resize(size, inf);
	}

	RMQ(int n, vector<pair<long long, long long>> list) {
		while (size < n) size *= 2;
		node.resize(size * 2, inf);
		for (int i = 0; i < list.size(); i++) node[i + size] = list[i];
		int l = 0, r = size-1;
		l += size, r += size;
		l /= 2, r /= 2;
		while (true) {
			if (l == 0) break;
			for (int i = l; i <= r; i++) {
				node[i] = min(node[i * 2], node[i * 2 + 1]);
			}
			l /= 2, r /= 2;
		}
	}

	void update(int index, pair<long long, long long> element) {
		index += size;
		node[index] = element;
		index /= 2;
		while (true) {
			if (index == 0) break;
			node[index] = min(node[index * 2], node[index * 2 + 1]);
			index /= 2;
		}
	}

	pair<long long, long long> query(int a, int b, int x = 1, int l = 0, int r = -1) {
		if (r == -1)r = size - 1;
		if(r<a||b<l)return inf;
		if(a<=l&&b>=r)return node[x];
		return min(query(a,b,x*2,l,(l+r)/2),query(a,b,x*2+1,(l+r)/2+1,r));
	}
};

signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 998244353;
	int n;
	cin >> n;
	vector<vector<int>> e(n);
	rep(i, n) {
		int k;
		cin>>k;
		rep(j,k){
			int c;
			cin>>c;
			e[i].push_back(c);
			e[c].push_back(i);
		}
	}
	vector<P> ret = eulerTour(n, e);
	vector<int> memo(n+1,LLONG_MAX);
	rep(i,ret.size()){
		memo[ret[i].second]=min(memo[ret[i].second],i);
	}
	RMQ tree((n-1)*2+1,ret);
	int q;
	cin>>q;
	rep(i,q){
		int a,b;
		cin>>a>>b;
		a=memo[a],b=memo[b];
		if(a>b)swap(a,b);
		cout<<tree.query(a,b).second<<endl;
	}
}



Measured memory_bytes: 32928
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N = ii()
    X = input()
    X_POP = X.count('1')
    X_POP_P = X_POP + 1
    X_POP_N = X_POP - 1
    FX_P = 0
    FX_N = 0
    for i, b in enumerate(X):
        FX_P <<= 1
        FX_N <<= 1
        if b=='1':
            FX_P += 1
            FX_N += 1
        FX_P %= X_POP_P
        FX_N %= X_POP_N or 1
    #
    def popcount(n):
        return bin(n).count('1')
    @lru_cache(None)
    def f(n):
        if n==0:
            return 0
        else:
            return f(n % popcount(n)) + 1
    ans = []
    for i, b in enumerate(reversed(X)):
        if b=='0':
            fx = f((FX_P + pow(2, i, X_POP_P)) % X_POP_P)+1
        else:
            if X_POP_N==0:
                fx = 0
            else:
                fx = f((FX_N - pow(2, i, X_POP_N)) % X_POP_N)+1
        ans.append(fx)
    print(*reversed(ans))



main()



Measured memory_bytes: 15736
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 55;
const int mo = 1e9+7;

int n;
LL js[N],inv[N];
LL f[N][N][N];

LL add(LL x,LL y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	n=get();
	js[0]=js[1]=1;
	inv[0]=inv[1]=1;
	fo(i,2,n)js[i]=js[i-1]*i%mo;
	fo(i,2,n)inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	fo(i,2,n)inv[i]=inv[i]*inv[i-1]%mo;
	f[0][0][0]=1;
	fo(i,0,n-1)
		fo(x,0,n)
			fo(y,0,n)
			if (f[i][x][y]){
				fo(a,0,n)
					fo(b,0,n)
					if (a+b>0&&i+a+b<=n&&x+b>=y&&y+a>=x)f[i+a+b][y+a-x][x+b-y]=add(f[i+a+b][y+a-x][x+b-y],f[i][x][y]*inv[a]%mo*inv[b]%mo);
			}
	LL ans=f[n][1][0]*js[n]%mo;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
t, a = gets.split.map(&:to_i)
hs = gets.split.map(&:to_f)

ans = 1
diff = (-60 - 10**5 * 0.006).abs

hs.each.with_index(1) do |h, i|
  ai = t - h * 0.006
  d = (ai - a).abs

  if d <= diff
    ans = i
    diff = d
  end
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,c=0;
cin >> n;
while(n!=0)
{
int d=n%10;
if(d==7)
{
c=c+1;
}
n=n/10;
}
if(c>0)
{
cout << "Yes";
}
else
{
cout << "No";
}
return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 200005
#define pi 3.14159
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res='1'; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/='2'; } return res;}
ll exp(ll x,ll y){ ll res='1'; while(y) {if(y%2) res=(res*x); x=(x*x); y/='2'; } return res;}



int main(){
    ll n,k; cin>>n>>k;
    vector<ll> sum(N,0);
    ll ans=0;
       for(ll i=1;i<=n+1;i++){
           sum[i]=sum[i-1]+i-1;
       }
       for(ll i=k;i<=n+1;i++){
           ll min=sum[i];
           ll max=sum[n+1]-sum[n+1-i];
           ans=(ans+max-min+1+mod)%mod;
       }
       cout << ans;
    
    return 0;
}
 


Measured memory_bytes: 4848
from itertools import product
D, G = map(int, input().split())
P, C = zip(*[map(int, input().split()) for _ in range(D)])
INF = 10**18
ans = INF
for bit in product((0, 1), repeat=D):
    p = list(P)
    cnt = 0
    score = 0
    for i in range(D):
        if bit[i]:
            score += C[i]
            score += P[i]*100*(i+1)
            cnt += P[i]
            p[i] = 0
 
    if score+sum(p[i]*100*(i+1) for i in range(D)) < G:
        continue
 
    idx = D-1
    while score < G:
        while not p[idx]:
            idx -= 1
        score += 100*(idx+1)
        p[idx] -= 1
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define rep(i, n) for(LL i = 0;i < n;i++)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int T

/*************** using variables ***************/

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

template <typename T>
struct Edge {
  int from, to;
  T cost;
  Edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
using Edges = vector<Edge<T>>;
template <typename T>
using AdjList = vector<Edges<T>>;

template <typename T>
class Dinic {
 private:
  int V;  // 頂点数
  vector<T> minCost;
  vector<int> iter;
  AdjList<T> graph;
  const T INF = numeric_limits<T>::max() / 10;
  bool Bfs(int s, int t);
  T Dfs(int idx, const int t, T flow);

 public:
  explicit Dinic(int n);
  void AddEdge(int from, int to, T cost);
  T Run(int s, int t);
};

template <typename T>
Dinic<T>::Dinic(int n) : V(n), graph(n) {}

template <typename T>
void Dinic<T>::AddEdge(int from, int to, T cost) {
  graph[from].push_back(Edge<T>(static_cast<int>(graph[to].size()), to, cost));
  graph[to].push_back(
      Edge<T>(static_cast<int>(graph[from].size() - 1), from, 0));
}

template <typename T>
bool Dinic<T>::Bfs(int s, int t) {
  minCost.assign(graph.size(), -1);
  queue<int> que;
  minCost[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int p = que.front();
    que.pop();
    for (auto &e : graph[p]) {
      if (e.cost > 0 && minCost[e.to] < 0) {
        minCost[e.to] = minCost[p] + 1;
        que.push(e.to);
      }
    }
  }
  return (minCost[t] != -1);
}

template <typename T>
T Dinic<T>::Dfs(int idx, const int t, T flow) {
  if (idx == t) return flow;
  for (int &i = iter[idx]; i < static_cast<int>(graph[idx].size()); ++i) {
    Edge<T> &e = graph[idx][i];
    if (e.cost > 0 && minCost[idx] < minCost[e.to]) {
      T d = Dfs(e.to, t, min(flow, e.cost));
      if (d > 0) {
        e.cost -= d;
        graph[e.to][e.from].cost += d;
        return d;
      }
    }
  }
  return 0;
}

template <typename T>
T Dinic<T>::Run(int s, int t) {
  T flow = 0;
  while (Bfs(s, t)) {
    iter.assign(graph.size(), 0);
    T f = 0;
    while ((f = Dfs(s, t, INF)) > 0) {
      flow += f;
    }
  }
  return flow;
}
signed main(){
    int n;
    vector<P> blue, red;

    cin >> n;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        red.pb(P(a, b));
    }
    rep(i, n){
        int c, d;
        cin >> c >> d;
        blue.pb(P(c, d));
    }

    Dinic<LL> f(n*2 + 2);
    rep(i, n){
        f.AddEdge(0, i+1, 1);
        f.AddEdge(n+1+i, n*2+1, 1);
    }
    rep(i, n){
        rep(j, n){
            if(red[i].first < blue[j].first && red[i].second < blue[j].second){
                f.AddEdge(i+1, j+n+1, 1);
            }
        }
    }

    cout << f.Run(0, n*2+1) << endl;
}


Measured memory_bytes: 384
N = int(input())

max_coef_4 = N // 4
max_coef_7 = N // 7

possible_price = set()

for coef_4 in range(max_coef_4 + 1):
    for coef_7 in range(max_coef_7 + 1):
        possible_price.add(4 * coef_4 + 7 * coef_7)

if N in possible_price:
    print("Yes")
else:
    print("No")


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int t = In[0];
            int x = In[1];
            Console.WriteLine((double)t / x);
        }
    }
}


Measured memory_bytes: 28128
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}



Measured memory_bytes: 3108
N,M=map(int,input().split())
a=[]
b=[]
for i in range(M):
  L,R=map(int,input().split())
  a.append(L)
  b.append(R)
c=sorted(a)
d=sorted(b)
if d[0]-c[M-1]>=0:
  print(d[0]-c[M-1]+1)
else:
  print(0)

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

const int DIM = 2e5 + 5;

pair<long long, long long> sgt[DIM << 2];

void update( int n, int l, int r, int p, long long v ) {
    if( r < p || p < l )
        return;
    
    if( l == r )
        sgt[n] = make_pair( v - p, v + p );
    else {
        int m = ( l + r ) >> 1;
        
        update( n << 1, l, m, p, v );
        update( n << 1 | 1, m + 1, r, p, v );
        
        sgt[n] = make_pair( min( sgt[n << 1].first , sgt[n << 1 | 1].first  ),
                            min( sgt[n << 1].second, sgt[n << 1 | 1].second ) );
    }
    
    return;
}

pair<long long, long long> query( int n, int l, int r, int st, int en ) {
    if( r < st || en < l )
        return make_pair( numeric_limits<long long> :: max() / 2,
                          numeric_limits<long long> :: max() / 2 );
    
    if( st <= l && r <= en )
        return sgt[n];

    int m = ( l + r ) >> 1;
    pair<long long, long long> qry1, qry2;

    qry1 = query( n << 1, l, m, st, en );
    qry2 = query( n << 1 | 1, m + 1, r, st, en );
    
    return make_pair( min( qry1.first , qry2.first  ),
                      min( qry1.second, qry2.second ) );
}

void solve( int n, int l, int r, long long &ans ) {
    if( l == r )
        ans = min( ans, sgt[n].first + l );
    else {
        int m = ( l + r ) >> 1;
        
        solve( n << 1, l, m, ans );
        solve( n << 1 | 1, m + 1, r, ans );
    }
    
    return;
}

int main( void ) {
    
    int n, q, a, b;
    cin >> n >> q >> a >> b;
    
    long long ans = numeric_limits<long long> :: max() / 2;
    fill( sgt + 1, sgt + (n << 2), make_pair( numeric_limits<long long> :: max() / 2,
                                              numeric_limits<long long> :: max() / 2 ) );
    update( 1, 1, n, a, 0 );
    
    long long sum = 0;
    for( int i = 1, p = b; i <= q; i ++ ) {
        int x;
        cin >> x;
        
        long long s = min( query( 1, 1, n, 1, x ).first  + x,
                           query( 1, 1, n, x, n ).second - x );
    
        update( 1, 1, n, p, s - abs( x - p ) );
        sum += abs( x - p ); p = x;
    }
    
    solve( 1, 1, n, ans );
    cout << ans + sum << endl;
    
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<7;
  else if(s=="MON") cout<<6;
  else if(s=="TUE") cout<<5;
  else if(s=="WED") cout<<4;
  else if(s=="THU") cout<<3;
  else if(s=="FRI") cout<<2;
  else if(s=="SAT") cout<<1;
}
  

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

int main ()
{
	ll n;
	cin >> n;
	
	vector<ll>prim;
	for (int i = 1; i <= sqrt(n); i++)
	{
		if (n % i == 0) {
			prim.push_back(i);
			prim.push_back(n/i);
		}
	}
	sort( prim.begin(), prim.end());
	ll ans = 10;
	for (auto i : prim)
	{
		for (auto j : prim)
		{
			if (i * j == n) 
			{
				ll f = prim[prim.size()/2-1], s = prim[prim.size()/2];
				ll ff=0, ss= 0;
				while (f) 
				{
					f/=10LL;
					ff++;
				}
				while (s)
				{
					s/=10LL;
					ss++;
				}
				ans = min( max(ff, ss)  , ans );
			}
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int A,B;
    cin >> A >> B;
    if(A>8||B>8){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 3552