akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

vector<int>rinsetu[2000];
int mincost[2000];
void DFS(int a){
	for(int b:rinsetu[a]){
		if(mincost[b]==-1){
			mincost[b]=mincost[a]+1;
			DFS(b);
			}
		}
	}
signed main(){
	int a,b;cin>>a>>b;
	for(int c=1;c<a;c++){
		int d,e;cin>>d>>e;
		d--;e--;
		rinsetu[d].push_back(e);
		rinsetu[e].push_back(d);
		}
	int ans=1<<29;	
	if(b&1){
		for(int i=0;i<a;i++){
			for(int k:rinsetu[i]){
				memset(mincost,-1,sizeof(mincost));
			mincost[i]=mincost[k]=0;
			DFS(i);
			DFS(k);
			int sum=0;
			for(int j=0;j<a;j++){
				if(mincost[j]<=b/2)sum++;
				}
			ans=min(ans,a-sum);	
				}
			}
		}
	else{
		for(int i=0;i<a;i++){
			memset(mincost,-1,sizeof(mincost));
			mincost[i]=0;
			DFS(i);
			int sum=0;
			for(int j=0;j<a;j++){
				if(mincost[j]<=b/2)sum++;
				}
			ans=min(ans,a-sum);	
			}
		}		
	cout<<ans<<endl;	
	}



Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const ll inf=ll(1e18)+1;

int main(){
  ll n,k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  ll l=-inf,r=inf;
  while(r-l!=1){
    ll x=(l+r)/2;
    bool ok=[&]{
      ll cnt=0;
      rep(i,n){
        ll l=-1,r=n;
        if(a[i]<0){
          while(r-l!=1){
            ll mid=(l+r)/2;
            if(a[i]*a[mid]<=x) r=mid;
            else l=mid;
          }
          cnt+=n-r;
        }
        else{
          while(r-l!=1){
            ll mid=(l+r)/2;
            if(a[i]*a[mid]<=x) l=mid;
            else r=mid;
          }
          cnt+=r;
        }
        if(a[i]*a[i]<=x) cnt--;
      }
      cnt/=2;
      return cnt>=k;
    }();
    if(ok) r=x;
    else l=x;
  }
  cout << r << endl;
  
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

auto chmax = [](auto&& a, auto b) { return a < b ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = size(s);
  vector dp(n + 1, vector(2, -inf<int>));
  vector prv(n + 1, vector(2, -1));
  dp[0][1] = 0;
  for (int i = 0; i < n; ++i) {
    for (int p : {0, 1}) {
      if (s[i] != 'D') {
        if (chmax(dp[i + 1][0], dp[i][p])) {
          prv[i + 1][0] = p;
        }
      }
      if (s[i] != 'P') {
        if (chmax(dp[i + 1][1], dp[i][p] + 1 + (p == 0))) {
          prv[i + 1][1] = p;
        }
      }
    }
  }
  int i = n, p = max_element(begin(dp[n]), end(dp[n])) - begin(dp[n]);
  while (i) {
    s[i - 1] = "PD"[p];
    p = prv[i][p];
    --i;
  }
  cout << s << '\n';
}


Measured memory_bytes: 25276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  while(k > 0) {
    if (c <= b) {
      c *= 2;
    } else if (b <= a) {
      b *= 2;
    } else {
      break;
    }
    k--;
  }


  if (b > a && c > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
import sys
from collections import deque, Counter, defaultdict
import heapq


def resolve():
    n_rows, n_cols = map(int, sys.stdin.readline().strip().split())
    matrix = [[]] * n_rows
    n_whites = 0
    for i in range(n_rows):
        row = list(sys.stdin.readline().strip())
        for c in row:
            if c == '.':
                n_whites += 1
        matrix[i] = row

    shortest_path = 1
    queue = deque()
    queue.append((0, 0))
    found = True
    while queue:
        shortest_path += 1
        for _ in range(len(queue)):
            x, y = queue.popleft()
            nexts = (
                (x+1, y),
                (x-1, y),
                (x, y+1),
                (x, y-1),
            )
            for nx, ny in nexts:
                if (nx, ny) == (n_rows-1, n_cols-1):
                    break
                if 0 <= nx < n_rows and 0 <= ny < n_cols and matrix[nx][ny] == '.':
                    matrix[nx][ny] = '#'
                    queue.append((nx, ny))
            else:
                continue
            break
        else:
            continue
        break
    else:
        found = False

    if found:
        print(n_whites - shortest_path)
    else:
        print(-1)

if __name__ == "__main__":
    resolve()


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

int main(){
  int a, b;
  cin >> a >> b;
  if (a == 1) a += 13;
  if (b == 1) b += 13;
  if (a > b) printf("Alice\n");
  else if (b > a) printf("Bob\n");
  else printf("Draw\n");
  return 0;
}


Measured memory_bytes: 256
W = [int(input()) for i in range(10)]
K = [int(input()) for i in range(10)]

W_sorted = sorted(W)
K_sorted = sorted(K)

W_top_three = sum(W_sorted[7:])
K_top_three = sum(K_sorted[7:])

print("{} {}".format(W_top_three, K_top_three))

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

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

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


int main(){
  int n=0,i=0,d=0,a[101];
  char s[500];
  
  scanf("%d\n",&n);
  fgets(s,sizeof(s),stdin);
  a[0] = atoi(strtok(s," "));
  for(i=1;i<n;i++){
    a[i]=atoi(strtok(NULL, " "));
  }

  for(i=0;i<=n;i=i+2){
    //printf("%d\n",i);
    if(a[i]%2==1){
      d++;
      //printf("%d\n",i);
    }
  }

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

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

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

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> A){

}

int main(){
    long long N;
    scanf("%lld",&N);
    map<ll,ll> A;
    for(int i = 0 ; i < N ; i++){
        ll tmp;
        cin >> tmp;
        A[tmp] = i+1;
    }

    for (int i = 1; i <= N ; i++)
    {
        cout << A[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;


int main()
{
	int count;
	string input, _input;

	getline(cin, _input);

	count = stoi(_input);

	for (int i = 0; i < count; i++)
	{
		getline(cin, input);
	

		while (input.find("Hoshino") != string::npos)
		{
			input.replace(input.find("Hoshino"), 7 ,"Hoshina");
		}

		cout << input << endl;
	}

	



}

Measured memory_bytes: 3144
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<ctime>
#include<sstream>
#define rep(i,l,r) for (ll i=l;i<=r;i++)
#define down(i,l,r) for (ll i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define inf 1152921504606846976
#define ll long long
#define maxn 210050
#define eps 1e-5
#define mm 2147483648
#define low(x) (x&(-x))
#define pb(x) push_back(x)
#define vi vector<string>
using namespace std;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int a[maxn],n,k;
int gcd(int x,int y){
	if (y==0) return x;
	return gcd(y,x%y);
}
int main(){
//	freopen("in.txt","r",stdin);
	n=read(); k=read();
	rep(i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	if (a[n]<k||(n==1&&a[n]!=k)) {
		puts("IMPOSSIBLE");
		return 0;
	}
	else {
		int d=a[1];
		rep(i,2,n) d=gcd(d,a[i]);
		if ((a[n]-k)%d==0) puts("POSSIBLE");
		else puts("IMPOSSIBLE");
	}
//	fclose(stdin); fclose(stdout);
    return 0;
}

Measured memory_bytes: 640
def gcd(x,y):
    return x if y==0 else gcd(y, x%y)

def factorize(n):
    pnum = []
    for i in range(2,int(n**0.5)+1):
        if n%i != 0:
            continue
        pnum.append([i,0])
        while n%i == 0:
            n /= i
            pnum[-1][1] += 1
    if n != 1:
        pnum.append([int(n),1])
    return pnum
    
a,b = map(int,input().split())
n = gcd(a,b)
pnum = factorize(n)
print(len(pnum)+1)

Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << std::max({A + B, A - B, A * B}) << std::endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    vector<char> s(4);
    rep(i, 4) cin >> s.at(i);
    sort(all(s));
    cout << (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2) ? "Yes" : "No") << endl;
    // end

    return 0;
}


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

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var B = new long[N + 1];
            for (var i = 0; i < N; i++)
            {
                B[A[i]]++;
            }

            var sum = 0L;
            for (var i = 1; i < N + 1; i++)
            {
                sum += B[i] * (B[i] - 1) / 2;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(sum - (B[A[i]] - 1));
            }
        }
    }
}


Measured memory_bytes: 38732
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)

    if op == "+":
        print(a + b)

    elif op == "-":
        print(a - b)

    elif op == "*":
        print(a * b)

    elif op == "/":
        print(a // b)

    else:
        break



Measured memory_bytes: 5596
#include <stdio.h>

int main(void)
{
	int n, k;
	int x, y, ti;
	int i;
	
	scanf("%d", &n);
	scanf("%d", &k);
	
	for (i = 0; i < k; i++){
		scanf("%d %d", &x, &y);
		
		if (x > (n + 1) / 2){
            x = n + 1 - x;
        }
		
        if (y > (n + 1) / 2){
            y = n + 1 - y;
        }
 
        if (y > x){
            ti = ((x - 1) % 3) + 1;
        }
        else {
            ti = ((y - 1) % 3) + 1;
        }
         
        printf("%d\n", ti);
    }
     
    return (0);
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int l[n];
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l,l+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(l[j]!=l[i])
            {
                for(int k=j+1;k<n;k++)
                {
                    if(l[i]+l[j]>l[k] && l[k]!=l[j] && l[k]!=l[i])ans++;
                }
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3644
#include <iostream>
#include <list>
#include <string>
#include <stdio.h>
#include <stdint.h>
using namespace std;
using uint = unsigned int;
using int64 = int64_t;
using uint64 = uint64_t;

int main()
{

  int A1;
  int A2;
  int A3;

  cin >> A1 >> A2 >> A3;
  cin.ignore();

  cout << (max)((max)(A1,A2),A3) - (min)((min)(A1,A2),A3) << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    N_MAX = 10 ** 6

    min_factor = list(range(N_MAX + 1))
    min_factor[2::2] = [2] * (N_MAX // 2)
    for i in range(3, int(N_MAX ** 0.5) + 2, 2):
        if min_factor[i] != i:
            continue
        for j in range(i * i, N_MAX + 1, 2 * i):
            if min_factor[j] > i:
                min_factor[j] = i

    def prime_factorize_fast(n):
        a = Counter()
        while n != 1:
            f = min_factor[n]
            p = 0
            while min_factor[n] == f:
                p += 1
                n //= f
            a[f] = p

        return a

    lcm_prime = Counter()
    for a in A:
        for p, n in prime_factorize_fast(a).items():
            if lcm_prime[p] < n:
                lcm_prime[p] = n

    l = 1
    for p, n in lcm_prime.items():
        l = l * pow(p, n, MOD) % MOD

    ans = 0
    for a in A:
        ans = (ans + pow(a, MOD - 2, MOD)) % MOD

    ans = ans * l % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


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

signed main(){
  lint sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  for(lint i = sy; i < ty; i++) cout << 'U';
  for(lint i = sx; i < tx; i++) cout << 'R';
  for(lint i = sy; i < ty; i++) cout << 'D';
  for(lint i = sx; i < tx; i++) cout << 'L';
  cout << 'L';
  for(lint i = sy; i < ty; i++) cout << 'U';
  cout << 'U';
  for(lint i = sx; i < tx; i++) cout << 'R';
  cout << 'R';
  cout << 'D';
  cout << 'R';
  for(lint i = sy; i < ty; i++) cout << 'D';
  cout << 'D';
  for(lint i = sx; i < tx; i++) cout << 'L';
  cout << 'L';
  cout << 'U';
  cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int varN = Integer.parseInt(sc.next());
        sc.close();

        int result = 0;
        result = 1000 - (varN % 1000);
        if (result == 1000) {
            result = 0;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35556
<?php

while (true) {
    fscanf(STDIN, "%d", $num_people);
    if ($num_people == 0) {
        break;
    }
    
    $scores = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $dev_value = 0;
    $average = array_sum($scores) / $num_people;
    foreach ($scores as $score) {
        $dev_value += pow($score - $average, 2);
    }
    
    echo sqrt($dev_value/$num_people)."\n";
}





Measured memory_bytes: 9640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint N;
  cin >> N;

  map<lint, lint> mp;
  for(lint x=1; x*x<=N; x++)
  for(lint y=1; y*y<=N; y++)
  for(lint z=1; z*z<=N; z++) {
    mp[x*x + y*y + z*z + x*y + y*z + z*x]++;
  }

  for(lint i=1; i<=N; i++) {
    cout << mp[i] << endl;
  }
}

Measured memory_bytes: 6048
// 2401.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"

#include<iostream>
#include<string>
#include <map>
 
 
using namespace std;
bool arg[11];
 
typedef pair<bool,int> BI;
 
BI next(string s){
    switch(s[0]){
        case '-':
                {
                        BI sub=next(s.substr(1));
                        return BI(!sub.first,sub.second+1);
                }
        case '(':
                {
                        BI sub1=next(s.substr(1));
                        char op=s[sub1.second+1];
                        int len=op=='-'?2:1;
                        BI sub2=next(s.substr(sub1.second+1+len));
                        return BI(op=='*'?sub1.first&&sub2.first:
                                op=='+'?sub1.first||sub2.first:
                                !sub1.first||sub2.first,1+sub1.second+len+sub2.second+1);
                }
        case 'T':
        case 'F':
                return BI(s[0]=='T',1);
        default:
                break;
        }
        return BI(arg[s[0]-'a'],1);
 
}
 
int main(){
        string str;
        while(cin>>str&&str!="#"){
                bool ok=true;
                for(int i=0;i<1<<11;i++){
                        for(int j=0;j<11;j++){
                                arg[j]=(i&(1<<j))!=0;
                        }
                        BI sub1=next(str);
                        BI sub2=next(str.substr(sub1.second+1));
                        if(sub1.first!=sub2.first){
                                ok=false;
                                break;
                        }
                }
                cout<<(ok?"YES":"NO")<<endl;
        }
        return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

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

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 888
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static long C(long n,long k)
    {
        long nn = 1;
        long kk = 1;
        long nk = 1;
        for(long i = 1; i <= n; i++)
        {
            nn *= i;
        }
        for (long i = 1; i <= k; i++)
        {
            kk *= i;
        }
        for (long i = 1; i <= n-k; i++)
        {
            nk *= i;
        }
        return nn / nk / kk;
    }
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var n = Read();
        var m = n / 7;
        bool b = false;
        for(int i = 0; i <= m; i++)
        {
            if ((n - 7 * i) % 4 == 0)
                b = true;
        }
        if (b)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");

        Console.Out.Flush();
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i) cin >> a[i];
    vector<int> b(a);
    sort(a.begin(), a.end(), greater<int>());

    int first = a[0];
    int second = a[1];

    for(auto num : b){
        if(num == first) cout << second << endl;
        else cout << first << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
import numpy as np

N, M =  map(int, input().split())
X = np.zeros([M,2], dtype=int)

for i in range(M):
    X[i,0], X[i,1] = map(int, input().split())

col_num = 1
X = X[np.argsort(X[:, col_num])]
cnt = 1
r_min = X[0,1]
for i in range(1,M):
    if X[i,0] >= r_min:
        cnt += 1
        r_min = X[i,1]
print(cnt)

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

int main(){
  int a,b,wa=0,i;
  cin>>a>>b;
  int n[b];
  for(i=0;i<b;i++){
    cin>>n[i];
    wa+=n[i];
  }
  a-=wa;
  if(a<0){
    cout<<-1;
  }else{
    cout<<a;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=1e5+10;
int n,r,l,ans,mi,m;
struct node{int l,r;}a[N],b[N];

const bool cmp(node x,node y){return x.l<y.l;}

int main(){
	scanf("%d",&n); l=r=1;
	rep (i,1,n){
		scanf("%d%d",&a[i].l,&a[i].r);
		if (a[i].l>a[l].l) l=i;
		if (a[i].r<a[r].r) r=i;
	}
	rep (i,1,n) if (i!=l&&i!=r) ans=max(a[i].r-a[i].l+1,ans);
	ans+=max(a[r].r-a[l].l+1,0);
	if (l==r) return printf("%d\n",ans),0;
	rep (i,1,n) if (i!=l&&i!=r){
		b[++m]=a[i];
		b[m].l=max(a[r].r-a[i].l+1,0);
		b[m].r=max(a[i].r-a[l].l+1,0);
	}
	sort(b+1,b+1+m,cmp);
	rep (i,1,m) b[i].l=min(b[i].l,a[r].r-a[r].l+1);
	mi=a[l].r-a[l].l+1;
	rep (i,1,m){
		ans=max(ans,b[i].l+mi);
		mi=min(mi,b[i].r);
	}
	ans=max(ans,a[r].r-a[r].l+1+mi);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void) {
  int s,t,n,o;
  int i;
  scanf("%d",&s);
  int w[s+1];
  for(i=0;i< s;i++)
    w[i]=i+1;
  scanf("%d",&t);
  for(i=0;i< t;i++) {
    scanf("%d,%d",&n,&o);
    w[s]=w[n-1];
    w[n-1]=w[o-1];
    w[o-1]=w[s];
  }
  for(i=0;i< s;i++)
    printf("%d\n",w[i]);
  return 0;
}

Measured memory_bytes: 0
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CCleaning {
public:

    vector<ll> a;
    vector<int> graph[100005];
    vector<ll> now;
    vector<bool> used;
    bool flag = true;

    void dfs(int p) {
      if (!flag) return; // fast fail
      used[p] = true;
      ll ma = 0;
      int cnt = 0;
      ll sum = 0;
      for(auto e: graph[p]) {
        if (used[e]) continue;
        dfs(e);
        chmax(ma, now[e]);
        sum += now[e];
        cnt++;
      }
      // p == 0
      if (p == 0) {
        if (cnt==1 && a[p]==sum) {
          return;
        }
        // cnt>1
        if (sum%2 != 0 || a[p] != sum/2) {
          flag = false;
          return;
        }
        if (ma > sum/2) {
          flag = false;
          return;
        }
        return;
      }

      // p != 0
      if (cnt==0 || a[p] == sum) {
        now[p] = a[p];
        return;
      }
      if (a[p] > sum) {
        flag = false;
        return;
      }

      if (a[p] < sum) {
        auto k = sum - a[p];
        auto r = min(sum - ma, sum/2);
        if (k > r) {
          flag = false;
        }
        now[p] = a[p] - k;
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      a.resize(n);
      now.resize(n);
      used.resize(n);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
      }
      dfs(0);
      if (flag) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
};

signed main() {
  CCleaning solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 12288
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,m;
vector<int> G[max_n];
int dis[max_n];
int ans[max_n];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v),G[v].push_back(u);
    }
    for(int i=1;i<=n;i++)dis[i]=inf;
    dis[1]=0;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int u=que.front();que.pop();
        for(auto v:G[u]){
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                que.push(v);
            }
        }
    }
    for(int i=2;i<=n;i++){
        for(auto v:G[i]){
            if(dis[v]+1==dis[i]){
                ans[i]=v;
            }
        }
    }
    printf("Yes\n");
    for(int i=2;i<=n;i++)printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 10964
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,1000000){
	bool flg = true;
	for(int j=0;primes[j]*primes[j]<=i;j++){
	    if(i % primes[j] == 0 ) {
	    flg = false;
	    break;
	    }
	}
	if(flg) primes.PB(i);
	i++;
    }

    int n;
    while(true){
	cin >> n;
	if(cin.eof())break;
	int res = upper_bound(ALL(primes),n) - primes.begin();
	cout << res << endl;
    }

    return 0;
}

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

#define endl ("\n")

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invaraibly fail
    

    int n;
    cin >> n;
    int arr[n+1];
    arr[0] = 0;
    for(int i = 0;i < n;i++)
        cin >> arr[i+1];
    sort(arr, arr+n +1);
    int mid = n/2;
    if(n%2 == 0)
    {
        if(arr[mid] == arr[mid + 1])
        {
            cout << 0;
        }
        else
        {
            cout << arr[mid + 1] - arr[mid];
        }
    }
    else
    {
        cout << arr[mid + 1] - arr[mid];
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (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; }

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
const int MOD = 1000000007;
using mint = ModInt< MOD >;

const int MAX = 2000100;
long long fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  rep(i, min(k+1, n)) {
    mint res = 1;
    int rem = n-i;
    res *= comb(n, i);
    res *= comb(i+rem-1, i);
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 47104
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, m, x) = input_tuple();
    let a_vec = input_vec();
    let mut right = 0;
    for i in x..(n+1) {
        if a_vec.contains(&i) {
            right += 1;
        }
    }
    let mut left = 0;
    for i in 0..(x+1) {
        if a_vec.contains(&i) {
            left += 1;
        }
    }
    println!("{}", min(left, right));
}


Measured memory_bytes: 2140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class16
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            char[] R = new char[S.Length];
            for(int i = 0; i < S.Length; i++)
            {
                int c = S[i]+N>90?S[i]+N-26:S[i]+N;
                R[i] = (char)c;
            }
            Console.WriteLine(R);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
long long int power(long long int a,long long int b){
    long long int r=1;
    while(b){
        if(b & 1){
            r=r*a;
            b--;
        }
        a=a*a;
        b>>=1;
    }
    return r;
}
int main()
{
    ll int n,k,ans;
    cin>>n>>k;
    if(n==1) cout<<k<<endl;
    else{
        ans=k*power(k-1,n-1);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int h,w;
  cin>>h>>w;
  string s[60];
  
  for(int i = 1; i <= h; i++)
  {
    cin >> s[i];
  }
  
  for(int i = 0; i < w; i++)
  {
    s[0] = s[0] + ".";
    s[h + 1] = s[h + 1] + ".";
  }
  
  
  for(int i = 0; i <= h + 1; i++)
  {
    s[i] = "." + s[i] + ".";
  }
  
  
  for(int i = 1; i <= h; i++)
  {
    
    for(int j = 1; j <= w; j++)
    {
      int cnt = 0;
      if(s[i][j] == '.') {
        if(s[i-1][j-1] == '#') cnt++;
        if(s[i-1][j] == '#') cnt++;
        if(s[i-1][j+1] == '#') cnt++;
        if(s[i][j-1] == '#') cnt++;
        if(s[i][j+1] == '#') cnt++;
        if(s[i+1][j-1] == '#') cnt++;
        if(s[i+1][j] == '#') cnt++;
        if(s[i+1][j+1] == '#') cnt++;
        s[i][j] = to_string(cnt)[0];
      }
    }
  }
  
  for(int i = 1; i <= h; i++)
  {
      cout << s[i].substr(1,w) << endl;
  }
  
  
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
 
 
 
int main(){
    
    int x,y;
    
    cin>>x>>y;
    if(x==4||x==6||x==9||x==11)x=1;
    else if(x==2)x=2;
    else x=0;
    if(y==4||y==6||y==9||y==11)y=1;
    else if(y==2)y=2;
    else y=0;
    if(x==y)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll K, A, B;
    in >> K;
    in >> A >>B;
    RANGE(i, A, B) {
        if (i % K ==0) {
            cout << "OK" <<endl;
            return 0;
        }
    }
    cout << "NG" <<endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 3644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(all(d));
  
  int a = d[n/2 - 1], b = d[n/2];
  cout << b-a << endl;
}

Measured memory_bytes: 640
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    Hs = list(map(int, input().split()))
    i = 0
    cnt = 0
    island = 0
    while True:
        if i >= n:
            i = 0
        if sum(Hs) == 0:
            break
        if Hs[i] == 0:
            i += 1
            continue
        else:
            cnt += 1
            while (i < n and Hs[i] > 0):
                Hs[i] -= 1
                i += 1

    print(cnt)
    return

if __name__ == '__main__':
    main()

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

int main()
{
  int i, x, y, ck = 0;
  
  cin >> x >> y;
  
  for(i=0; i<=x; i++)
  {
   	if(2*i+4*(x-i) == y)
    {
      ck = 1;
      break;
    }
  }
  
  if(ck)	cout << "Yes" << endl;
  else		cout << "No"  << endl;
  
 return 0; 
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();

			if (a+b==c || b+c==a || c+a==b) {
				out.println("Yes");
			} else {
				out.println("No");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 int a, b, d, x;
  cin >> a >> b;
  x = (a + b) / 2;
  d = (a + b) % 2;
  
 int answer;
  answer = x + d;
  cout << answer << endl;
}

Measured memory_bytes: 3608
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n; cin>>n;
  int a[100],b[100];
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];

  int mx=0;

  rep(i,n){
    int sum=a[0];
    for(int j=1; j<=i;j++){
      sum+=a[j];
    }
    for(int j=i;j<n;j++){
      sum+=b[j];
    }
    
    if(sum>mx) mx=sum;
  }
  cout<<mx<<endl;
}


Measured memory_bytes: 256
solve :: Int -> [Int] -> Int
solve diff [x2, x3] = diff
solve diff (x1:x2:x3:xs) = solve diff' (x2:x3:xs)
  where x = x1 * 100 + x2 * 10 + x3
        diff' = if abs (x - 753) < diff
                then abs (x - 753)
                else diff

main :: IO ()
main = do
  s <- map (read . (:[])) <$> getLine
  print $ solve 642 s

Measured memory_bytes: 508
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())

    ans = 0
    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        ans += i
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9116
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int N,M;
vvi field;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void dfs(int x,int y){
	field[x][y]=1;
	rep(i,4){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx<0||ny<0||nx>=N||ny>=M||field[nx][ny])continue;
		dfs(nx,ny);
	}
}
int main(){
	int n;
	while(cin>>n,n){
		vi x,y;
		vvi in(n,vi(4));
		rep(i,n)rep(j,4){
			cin>>in[i][j];
			in[i][j]*=2;
			loop(k,-1,2)if(j%2){
				y.pb(in[i][j]+k);
			}else{
				x.pb(in[i][j]+k);
			}
		}
		sort(all(x));
		sort(all(y));
		x.erase(unique(all(x)),x.end());
		y.erase(unique(all(y)),y.end());
		rep(i,n)rep(j,4)if(j%2==0)in[i][j]=lower_bound(all(x),in[i][j])-x.begin();
						else in[i][j]=lower_bound(all(y),in[i][j])-y.begin();
		N=x.size();
		M=y.size();
		field=vvi(N,vi(M));
		rep(i,n){
			loop(j,in[i][0],in[i][2]+1)field[j][in[i][1]]=field[j][in[i][3]]=1;
			loop(j,in[i][3],in[i][1]+1)field[in[i][0]][j]=field[in[i][2]][j]=1;
		}
		int out=0;
		rep(i,N)rep(j,M)if(field[i][j]==0){
			out++;
			dfs(i,j);
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 4600
// E
// DeP
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 2e5+5, P = 1e9+7;

int fac[MAXN], ifac[MAXN];

inline int C(int n, int m) {
    if (n < m) return 0;
    return 1LL * fac[n] * ifac[m] % P * ifac[n-m] % P;
}

int fpow(int base, int b) {
    int ret = 1;
    while (b > 0) {
        if (b & 1) ret = 1LL * base * ret % P;
        base = 1LL * base * base % P, b >>= 1;
    }
    return ret;
}

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    ifac[0] = fac[0] = 1;
    for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i-1] * i % P;
    ifac[n] = fpow(fac[n], P-2);
    for (int i = n; i; --i) ifac[i-1] = 1LL * ifac[i] * i % P;
    for (int i = 0; i <= min(n, k); ++i)
        ans = (ans + 1LL * C(n, i) * C(n-1, i) % P) % P;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define MAX 250
int parent (int i){ return  i / 2; }
int left (int i){ return 2*i; }
int right (int i){ return 2*i+1; }

int main (){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i = 1;i <= H;i++ )
    {
      printf("node %d: key = %d, ",i,A[i]);
	if(parent(i)>=1)
	  {
	    printf("parent key = %d, ",A[parent(i)]);
	  }
      if(left(i)<=H)
	{
	  printf("left key = %d, ",A[left(i)]);
	}
      if(right(i)<=H) 
	{
          printf("right key = %d, ",A[right(i)]);
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


signed main() {
	FAST_IO;
	// int q;
	// cin >> q;
	// while (q--) {	
		string s;
		cin >> s;
		int n = s.size();
		forn(i, n) {
			if (s[i] == '?') {
				if (i - 1 >= 0) {
					if (s[i - 1] == 'P') {
						s[i] = 'D';
						continue;
					}
				}
				if (i + 1 < n) {
					if (s[i + 1] == 'D' || s[i + 1] == '?') {
						s[i] = 'P';
					} else {
						s[i] = 'D';
					}
				} else {
					s[i] = 'D';
				}
			}
		}
		cout << s << "\n";
	// }
 	return 0;
}

Measured memory_bytes: 3780
#include<stdio.h>
#define MAX 100
#define INFTY 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void dijkstra(void);

void dijkstra(){
  int minv, i, j, u;
  int d[MAX], color[MAX];

  for(i=0; i<n; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i=0; i<n; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(j=0; j<n; j++){
      if(color[j] != BLACK && M[u][j] != INFTY){
        if(d[j] > d[u] + M[u][j]){
          d[j] = d[u] + M[u][j];
          color[j] = GRAY;
        }
      }
    }
  }
  
    for(i=0; i<n; i++){
    if(d[i] != INFTY) printf("%d %d\n", i, d[i]);
    else printf("%d -1\n", i);
  }
}

int main(){
  int i, j, k, c, u, v;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d%d", &v, &c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}


Measured memory_bytes: 2060