akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String[] c = new String[2];
        String tmpa = "";
        for(int i = 0; i < b; i++){
            tmpa += String.valueOf(a);
        }
        c[0] = tmpa;
        String tmpb = ""; 
        for(int i = 0; i < a; i++){
            tmpb += String.valueOf(b);
        }
        c[1] = tmpb;
        Arrays.sort(c);
        System.out.println(c[0]);
    }
}

Measured memory_bytes: 23252
n,h = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int,input().split())
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = 0
j = 0
while j<n:
    if b[j] > a[0]:
        c += b[j]
    else:
        break
    j += 1
    if c >= h:
        break

if c < h:
    j += -(-(h-c)//a[0])
print(j)

Measured memory_bytes: 17620
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(void){
  int n;cin>>n;
  cout<<(n%2==0?(double)0.5:(double)(n/2+1)/n)<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a=sorted(a)
c=sorted(c)
import bisect
ans=0
for i in b:
    x=bisect.bisect_left(a,i)
    y=n-bisect.bisect_right(c,i)
    ans+=x*y
print(ans)

Measured memory_bytes: 23328
#include<stdio.h>
#include<math.h>
 
int main(void){
    double x1,x2,y2,y1;
 
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
 
    printf("%lf\n",sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    return 0;
}


Measured memory_bytes: 2148
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]
# n, k = 10, 4
# nums = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]

expected_values = [num * (num + 1) / 2 / num for num in nums]

accums = [0]
for e in expected_values:
    accums.append(accums[-1] + e)

m = 0
for i in range(n-k+1):
    m = max(m, accums[i+k] - accums[i])
print(m)


Measured memory_bytes: 25188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int N[] = new int[a];
		int b = sc.nextInt();
		for (int i = 0; i < N.length; i++) {
			N[i] = sc.nextInt();
		}

		Arrays.sort(N);
		int sum = 0;


		for (int i = 0; i < b; i++) {
			sum += N[i];
		}

		System.out.println(sum);
		sc.close();

	}
}

Measured memory_bytes: 38928
x, y = map(int, input().split())
if x + y == 2:
  print(1000000)
elif x + y == 3:
  print(500000)
elif x + y == 4:
  print(400000)
elif x + y == 5:
  print(300000)
elif x + y == 6:
  print(200000)
elif x == 1 or y == 1:
  print(300000)
elif x == 2 or y == 2:
  print(200000)
elif x == 3 or y == 3:
  print(100000)
else:
  print(0)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

const int N = 300001;
bool sieve[N] = {true, true};

int main()
{
  for (int i = 0; sq(i * 7 + 1) < N; i++){
    int x = i * 7 + 1;
    if (!sieve[x]){
      for (int j = x * 2; j < N; j += x){
        sieve[j] = true;
      }
    }
    x += 5;
    if (!sieve[x]){
      for (int j = x * 2; j < N; j += x){
        sieve[j] = true;
      }
    }
  }
  vector<int> smv;
  for (int i = 0; i < N; i++){
    if ((i % 7 == 1 || i % 7 == 6) && !sieve[i]) smv.push_back(i);
  }
  int v;
  while (v = in(), v != 1){
    vector<int> fct;
    for (const auto& d : smv){
      if (v % d == 0) fct.push_back(d);
    }
    printf("%d: ", v);
    show(fct, Out<int>);
  }
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

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

int p(int x, int y){
    int a = 1;
    for(int i = 0; i < y; i++){
        a *= x;
    }
    return a;
}
 
int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 1; i <= x; i++){
        for(int j = 2; j <= x; j++){
            if(pow(i, j) <= x) ans = max(ans, p(i,j));
            else break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.chomp

gu, ki = [], []

s.length.times do |i|
  gu << s[i].to_i if i%2 == 0
  ki << s[i].to_i if i%2 == 1
end

gu_sum = !gu.empty? ? gu.inject(&:+) : 0
ki_sum = !ki.empty? ? ki.inject(&:+) : 0

plan1 = gu.length - gu_sum + ki_sum
plan2 = ki.length - ki_sum + gu_sum

ans = [plan1, plan2].min


puts ans

Measured memory_bytes: 2956
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	ans := make([]int, n)
	for i := 0; i < n-1; i++ {
		ans[intScanner()-1]++
	}
	for i := 0; i < n; i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 6184
import sys
S = input()
T = input()
tmp1 = [set() for i in range(26)]
tmp2 = [set() for i in range(26)]
alpha2num = lambda c: ord(c) - ord('a')
for i in range(len(S)):
    tmp1[alpha2num(S[i])].add(T[i])
    tmp2[alpha2num(T[i])].add(S[i])
for i in range(26):
    if len(tmp1[i]) > 1 or len(tmp2[i]) > 1:
        print("No")
        sys.exit()
print("Yes")


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

using namespace std;

#define ll       long long
#define PII      pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3010;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);

int n, t, dp[N][N];
pair<int, int> a[N];

int fun(int pos, int timeTaken) {
    if (pos == n || timeTaken >= t) {
        return 0;
    }
    int &tmp = dp[pos][timeTaken];
    if (tmp != -1) {
        return tmp;
    }
    tmp = 0;
    tmp = max(tmp, a[pos].second + fun(pos + 1, timeTaken + a[pos].first));
    tmp = max(tmp, fun(pos + 1, timeTaken));
    return tmp;
}

bool cmp(pair<int, int> x, pair<int, int> y) {
    if (x.first == y.first) {
        return x.second > y.second;
    } else {
        return x.first < y.first;
    }
}

int main() {
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n, cmp);
    memset(dp, -1, sizeof dp);
    cout << fun(0, 0) << '\n';
    return 0;
}


Measured memory_bytes: 35840
K = int(input())

if K == 1:
    print("ACL")
elif K == 2:
    print("ACLACL")
elif K == 3:
    print("ACLACLACL")
elif K == 4:
    print("ACLACLACLACL")
else:
    print("ACLACLACLACLACL")

Measured memory_bytes: 9152
#include <iostream>
using namespace std ; 
int main()
{
	char letter,a,o,i,u,e;
	cin>>letter;
	if(letter=='a'||letter=='e'||letter=='i'||letter=='o'||letter=='u')
	{
		cout<<"vowel"<<endl;
	}
	else
	cout<<"consonant"<<endl;
	return 0 ;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 086 B - 1 21
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/25
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <numeric>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

string a;
string b;

void solve() {

    string s_num = a+b;
    int num = stoi(s_num);
    int root = sqrt(num);
    if ((int)pow(root, 2) == num)
        printf("Yes\n");
    else
        printf("No\n");

}

int main() {

    cin >> a >> b;

    solve();

}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
using namespace std;
int main() 
{
	int a,b,k;
	cin>>a>>b>>k;
	int qwq=min(a,b);
	int e[101];
	int pwp=1;
	for (int i=1;i<=qwq;i++)
	{
		if ((a%i==0)&&(b%i==0))
		{
			e[pwp++]=i;
		}
	}
	sort(e+1,e+pwp);
	cout<<e[pwp-k];
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  int ans = 0;
  int m = INF;
  while (N--) {
    int p; cin >> p;
    m = min(p, m);

    if (p <= m) {
      ans++;
    }
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

struct UnionFind {
    vector<int> par;
    vector<int> cnt;

    UnionFind(int N) : par(N), cnt(N) {  // 初期化
        for (int i = 0; i < N; i++) {
            par[i] = i;
            cnt[i] = 1;
        }
    }

    void print() {
        for (int i = 0; i < par.size(); i++)
            printf("par[%d] = %d\n", i, par[i]);

        for (int i = 0; i < par.size(); i++)
            printf("cnt[%d] = %d\n", i, cnt[i]);
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {  // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (cnt[rx] < cnt[ry]) {
            par[rx] = ry;
            cnt[ry] += cnt[rx];
        } else {
            par[ry] = rx;
            cnt[rx] += cnt[ry];
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size() {
        int N = par.size();
        set<int> s;
        for (int i = 0; i < N; i++) {
            s.insert(root(i));
        }
        return s.size();
    }

    int count(int x) {
        return cnt[root(x)];
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> Friend(N, 0);
    UnionFind uf(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Friend[a]++;
        Friend[b]++;
        uf.unite(a, b);
    }
    vector<vector<int>> Block(N);
    rep(i, K) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Block[a].push_back(b);
        Block[b].push_back(a);
    }
    rep(i, N) sort(all(Block[i]));

    rep(i, N) {
        int root       = uf.root(i);
        int blockCount = 0;
        for (auto e : Block[i]) {
            if (uf.root(e) == root) blockCount++;
        }
        cout << uf.count(i) - 1 - Friend[i] - blockCount << " ";
    }
		cout << endl;
}

Measured memory_bytes: 7168
#include <stdio.h>

int main(void){
    int n,i,a[3],j;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        for (j=0; j<3; j++) {
            scanf("%d",&a[j]);
        }
        if(a[0]*a[0]==a[1]*a[1]+a[2]*a[2]
           ||a[1]*a[1]==a[0]*a[0]+a[2]*a[2]
           ||a[2]*a[2]==a[1]*a[1]+a[0]*a[0]){
            printf("YES\n");
        }
        else
            printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      string s,t;
      cin>>s>>t;
      int a[s.length()+1][t.length()+1];
      int i=0,j=0;
      memset(a[0],0,sizeof(a[0]));
      for(j=0;j<=s.length();j++)
        a[j][0]=0;
      for(i=1;i<=s.length();i++)
      {
       for(j=1;j<=t.length();j++)
       {
         if(s[i-1]==t[j-1])
         {
          a[i][j]=1+a[i-1][j-1]; 
         }
         else
         {
           a[i][j]=max(a[i-1][j],a[i][j-1]); 
         }
       }
       cout<<endl;
      }
      stack<char> st;
      i=s.length();
      j=t.length();
      while(i!=0 && j!=0)
      {
        if(s[i-1]==t[j-1])
        {
          st.push(s[i-1]);
          i--;
          j--;
        }
        else if(a[i][j]==a[i-1][j])
        {
         i--; 
        }
        else
          j--;
      }
      while(st.empty()!=true)
      {
       cout<<st.top();
        st.pop();
      }
      return 0; 
    }

Measured memory_bytes: 35456
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    while(--q >= 0){
        int c, a, n;
        cin >> c >> a >> n;
        int ret = 0;
        for(int i=0; i<=1000; ++i){
            for(int j=0; j<=1000; ++j){
                int c2 = c - 2 * i - 3 * j;
                int a2 = a - i;
                if(c2 >= 0 && a2 >= 0)
                    ret = max(ret, i + j + min(min(c2, a2), n));
            }
        }
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    ll A,B;
    cin>>A>>B;
    ll ans  = 0;
    if(B == 1){
        cout<<0<<endl;
        return 0;
    }
    rep(i,1000){
        ll cnt = A + (A-1)*(i-1);
        if(cnt>=B){
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string str[3];
    cin >> str[0] >> str[1] >> str[2];

    int ptr[3] = {};
    int ind = 0;
    while(1){
        if(ptr[ind] >= str[ind].size()){
            break;
        }
        ind = str[ind][ptr[ind]++] - 'a';
    }
    cout << (char)('A' + ind) << endl;
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,w; cin>>n>>w;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin>>a[i].first>>a[i].second;
	sort(a.begin(),a.end());
	vector<vector<long long int>> dp(n+1,vector<long long int>(w+1));
   for(int i=0;i<=n;i++){
   for(int j=0;j<=w;j++){
       if (i == 0 ||j == 0)
         dp[i][j] = 0;
       else if(j>=a[i-1].first){
           dp[i][j]=max(dp[i-1][j-a[i-1].first]+a[i-1].second,dp[i-1][j]);
       }
       else dp[i][j]=dp[i-1][j];
     }
   } 
    cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 82740
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2){
        cout << "No" << endl;
    }
    else{
        if(s.substr(n/2, n/2) == s.substr(0, n/2))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int,input().split())
x1 = A * math.cos(math.radians(30*H+0.5*M))
y1 = A * math.sin(math.radians(30*H+0.5*M))
x2 = B * math.cos(math.radians(6*M))
y2 = B * math.sin(math.radians(6*M))
print(math.sqrt((x1-x2)**2+(y1-y2)**2))

Measured memory_bytes: 9432
#include<iostream>
using namespace std;
int main(){
	int n,p,d1,d2,maxp,maxv;
	while(1){
		cin >> n;
		if(n == 0) break;
		maxp = maxv = 0;
		while(n --){
			cin >> p >> d1 >> d2;
			if(maxv < d1+d2){
				maxp = p;
				maxv = d1+d2;
				}
		}
		cout<< maxp <<" "<<  maxv<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int N,A,B,C,D;
char str[(int)2e5+100];

int main()
{
    int i,j,cnt;
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    while(cin>>N>>A>>B>>C>>D)
    {
        A--,B--,C--,D--;
        cin>>str;
        for(i=A,cnt=0;i<=C;i++)
        {
            if(str[i]=='#')
                cnt++;
            else
                cnt=0;
            if(cnt==2)
                break;
        }
        for(j=B,cnt=0;j<=D;j++)
        {
            if(str[j]=='#')
                cnt++;
            else
                cnt=0;
            if(cnt==2)
                break;
        }
        if(i<=C || j<=D)
        {
            cout<<"No"<<endl;
            continue;
        }
        if(C>D && str[D-1]!='.')
        {
            for(i=B-1,cnt=0;i<=D;i++)
            {
                if(str[i]=='.')
                    cnt++;
                else
                    cnt=0;
                if(cnt==3)
                    break;
            }
            if(cnt==3)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}


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

int main(){
  
  int n;
  cin >> n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;i++){
    cin >> b.at(i);
  }
  int ans=b.at(0)+b.at(n-2);
  for(int j=0;j<n-2;j++){
    ans+=min(b.at(j),b.at(j+1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def xor_matching(M, K):
    # 0と1はコーナーケースっぽい
    if M == 0:
        return [0, 0] if K == 0 else [-1]
    if M == 1:
        return [0, 1, 1, 0] if K == 0 else [-1]

    if K >= (1 << M):
        return [-1]

    values = list(range(1 << M))
    Amax = values[-1]
    res = []
    res.append(K)
    for v in values:
        if v == K:
            continue
        res.append(v)
    res.append(K)
    for v in values[::-1]:
        if v == K:
            continue
        res.append(v)
    return res


if __name__ == "__main__":
    M, K = map(int, input().split())
    ans = xor_matching(M, K)
    print(*ans)


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

using namespace std;

void solve() {
  int n;
  cin >> n;
  vector<pair<int,int>> pos, neg;
  long long sum = 0;

  for (int i = 0; i < n; i++) {
    int k, l, r;
    cin >> k >> l >> r;
    if (l > r) {
      pos.emplace_back(k, l - r);
    } else {
      neg.emplace_back(n - k, r - l);
    }
    sum += min(l, r);
  }
  
  {
    sort(pos.begin(), pos.end());
    multiset<int> q;
    int k, v;
    for (auto c : pos) {
      tie(k, v) = c;
      q.insert(v);
      if (q.size() > k) q.erase(q.begin());
    }
    for (auto v : q) sum += v;
  }
  {
    sort(neg.begin(), neg.end());
    multiset<int> q;
    int k, v;
    for (auto c : neg) {
      tie(k, v) = c;
      q.insert(v);
      if (q.size() > k) q.erase(q.begin());
    }
    for (auto v : q) sum += v;
  }

  cout << sum << '\n';
  return;
}

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

  int tt;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 9596
#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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<int> num(m), pr(m);
  rep(i, n) num[a[i]%m]++;
  rep(i, n-1) {
    if (a[i] == a[i+1]) {
      pr[a[i]%m]++;
      i++;
    }
  }
  int ans = num[0]/2;
  if (m/2+m/2 == m)
    ans += num[m/2]/2;
  for (int i = 1; i < m-i; i++) {
    int p = min(num[i], num[m-i]);
    num[i] -= p;
    num[m-i] -= p;
    ans += p+min(num[i]/2, pr[i])+min(num[m-i]/2, pr[m-i]);
  }
  cout << ans << endl;
  return 0;
}

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

int maxtime(int n){
  n = (n + 9) / 10 * 10;
  return n;
}

int retime(int n){
  return maxtime(n) - n;
}

int main(){
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
  sum -= max({retime(A), retime(B), retime(C), retime(D), retime(E)});
  cout << sum << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 金  2/22 10:36:58 2019

# Usage
#
"""
from collections import Counter

def i():
    n_people = int(input().split()[0])
    likes = []

    for i in range(n_people):
        likes.extend(input().split()[1:])

    return n_people, [int(l) for l in likes]

def s(n_people, likes):
    re = 0
    cn = Counter(likes)
    food = cn.keys()
    for f in food:
        if cn[f] == n_people:
            re += 1
    return re

if __name__ == '__main__':
	print(s(*i()))

Measured memory_bytes: 3316
import math


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)


n = int(input())
a = list(map(int, input().split()))
num = a[0]
for i in range(1, n):
    num = math.gcd(num, a[i])
if num != 1:
    print("not coprime")
    exit()
prime_memo = {}
for i in range(n):
    prime_number = prime_factorize(a[i])
    for num in prime_number:
        if num not in prime_memo.keys():
            prime_memo[num] = 1
        else:
            print("setwise coprime")
            exit()
print("pairwise coprime")


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

int main()
{

    string s,t;

    int n;

    cin>>n;
    n = s.size();
    cin>>s;

    t = "ABC";

    int count = 0;

    int sz = t.size();

    for(int i=0;i<s.size();i++)
    {
        string k_string = s.substr(i,sz);

        if(k_string==t)
        {
            count++;
        }
    }
    cout<<count;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;

typedef long long ll;

const ll q = 10000000000 + 7;

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n-1; i++)
	{
		cin >> c[i];
	}

	int sum = 0;

	sum += b[a[0]];
	for (int i = 1; i < n; i++)
	{
		sum += b[a[i]];
		if (a[i - 1] + 1 == a[i]) {
			sum += c[a[i - 1]];
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  size_t N;

  map<string, ll> m;

  cin >> N;
  for (size_t i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    m[tmp]++;
  }

  cin >> N;
  for (size_t i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    m[tmp]--;
  }

  ll ans = 0;
  for(auto& kv : m){
    if (kv.second > ans) ans = kv.second;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,MA,MB = gets.chomp.split.map(&:to_i)

abc = []
a_sum = 0
b_sum = 0
N.times do |i|
  a,b,c = gets.chomp.split.map(&:to_i)
  a_sum += a
  b_sum += b
  abc.push([a,b,c])
end

INF = 10**9

dp = Array.new(N+11) { Array.new(a_sum + 11) { Array.new(b_sum + 11, INF) } }

dp[0][0][0] = 0

1.upto(N) do |i|
  a,b,c = abc[i-1]

  0.upto(a_sum) do |j|
    0.upto(b_sum) do |k|
      next if dp[i-1][j][k] == INF

      # 選ぶ
      dp[i][j+a][k+b] = [dp[i-1][j][k] + c, dp[i][j+a][k+b]].min

      # 選ばない
      dp[i][j][k] = [dp[i-1][j][k], dp[i][j][k]].min
    end
  end
end

ans = INF

1.upto(a_sum) do |j|
  1.upto(b_sum) do |k|
    if j*MB == k*MA
      ans = [dp[N][j][k] ,ans].min
    end
  end
end

if ans == INF
  p -1
else
  p ans
end


Measured memory_bytes: 27644
#include <iostream>
using namespace std;
int main(){
	int n , hon[220] , number[120] ;
	cin >> n ;
	int i , j , k , l , num=0;
	for( i=1 ; i<=n*2 ; i++ )
		cin >> hon[i] ;
	for( i=1 ; i<=n*2 ; i++ ){
		for( j=1 ; j<=n*2 ; j++ ){
			if( hon[i] < hon[j] )
				swap(hon[i] , hon[j] );
		}
	}
	for( i=1 ; i<=n*2 ; i++ ){
		if( i%2 != 0 )
			number[i] = hon[i] ;
	}
	for( i=1 ; i<=n*2 ; i++ ){
		if( i%2 !=0 )
			num += number[i] ;
	}
	cout << num << endl ;
}

Measured memory_bytes: 256
open Batteries
open Printf

let ($) g f x = g (f x)

module MyList = struct
  include List
  let foldl = fold_left
  let foldli = fold_lefti
  let foldr = fold_right
  let foldri = fold_righti
  
  let flatmap = concat_map

  let zipf = map2
  let zipfi = map2i
end

module L = MyList

let atoi = int_of_string
let itoa = string_of_int
let atof = float_of_string
let ftoa = string_of_float
let ctoi = int_of_char
let itoc = char_of_int

let stocl = String.to_list
let cltos = String.of_list
let spsp s = String.split_on_char ' ' s

module MyString = struct
  include String

  let map' f s = L.map f (stocl s)
  let mapi' f s = L.map f (stocl s)

  let zipf f a b = L.zipf f (stocl a) (stocl b)
  let zipfi f a b = L.zipfi f (stocl a) (stocl b)

  let mkstr f sep ls =
    L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)
end

module S = MyString

let rds () = read_line ()

let rdi () = atoi @@ rds ()

let rdhs () = spsp @@ rds ()
let rdhi () = rdhs () |> L.map atoi

let rdi2 () = match rdhi () with
  | a::b::_ -> (a, b)
  | _ -> (0, 0)

let rdi3 () = match rdhi () with
| a::b::c::_ -> (a, b, c)
| _ -> (0, 0, 0)

let rdi4 () = match rdhi () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0, 0, 0, 0)

let rdv n rdf =
  let rec rdv' n =
    if n <= 0 then []
    else (
      let s = rdf () in
      s::(rdv' (n - 1))
    )
  in rdv' n

let rdvi n = rdv n rdi
let rdvi2 n = rdv n rdi2
let rdvi3 n = rdv n rdi3
let rdvi4 n = rdv n rdi4

let puts s = print_endline s
let putyn b = puts (if b then "Yes" else "No")
let puti i = puts @@ itoa i

let set_power ls =
  let rec set_power' ls pls =
    match ls with
    | [] -> pls
    | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)
  in set_power' ls [[]]

let _ =
  let k = rdi () in
  let s = rds () in
  puts (if S.length s <= k then s else (S.left s k) ^ "...");; 



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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int64_t M = 0;
  int64_t A = 0;
  int64_t R = 0;
  int64_t C = 0;
  int64_t H = 0;
  
  for(int j=0; j<N; j++){
    string S = vec.at(j);
    if(S.at(0) == 'M'){
      M++;
    }
    if(S.at(0) == 'A'){
      A++;
    }
    if(S.at(0) == 'R'){
      R++;
    }
    if(S.at(0) == 'C'){
      C++;
    }
    if(S.at(0) == 'H'){
      H++;
    }
  }
  
  vector<int64_t> MARCH(5);
  MARCH.at(0) = M;
  MARCH.at(1) = A; 
  MARCH.at(2) = R;
  MARCH.at(3) = C; 
  MARCH.at(4) = H;
  sort(MARCH.begin(),MARCH.end());
  
  int64_t ans = 0;
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(3) * MARCH.at(4);
    ans += MARCH.at(1) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(2) * MARCH.at(3) * MARCH.at(1); 
    ans += MARCH.at(0) * MARCH.at(1) * MARCH.at(2);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(1);
    ans += MARCH.at(0) * MARCH.at(1) * MARCH.at(4);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(2);
    ans += MARCH.at(0) * MARCH.at(2) * MARCH.at(4);
    ans += MARCH.at(0) * MARCH.at(3) * MARCH.at(4);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 6144
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = MAP()
X = sorted(X)
print(X[0] + X[1])


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

int cnt;

void chev(int n){
  int f=1;
  for(int i=n+1;i<=2*n;i++){
    f=1;
    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0)f=0;
    }
    if(f)cnt++;
  }
}

int main(){
  while(1){
    cnt=0;
    int n;
    cin >> n;
    if(n==0)break;
    chev(n);
    cout << cnt <<endl;
  }
}

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

int main() {
  string A, B;
  cin >> A >> B;
  
  if ( A.at(0) == B.at(2) && ( A.at(1) == B.at(1) && A.at(2) == B.at(0) )){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

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

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

  cout << a[0]*a[1]/2 << endl;

  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/25  Problem: ABC 049 C / Link: http://abc049.contest.atcoder.jp/tasks/abc049_c  ----- */
/* ------問題------

問題違うけど

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */
int dfs(int v, int p, int c, VVI &G, VI&color) {
	color[v] = c;
	FOR(i, 0, SZ(G[v])) {
		int nv = G[v][i];
		if (nv == p)continue;
		if (color[nv] == 0) {
			dfs(nv, v, c, G, color);
		}
	}

}

LL N;

LL ans = 0LL;

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

	int K, L;
	cin >> N>>K>>L;
	VI Qcolor(N,0);
	VVI QG(N);
	VVI LG(N);
	FOR(i, 0, K) {
		int a, b; cin >> a >> b;
		a--, b--;
		QG[a].push_back(b);
		QG[b].push_back(a);
	}

	VI Lcolor(N,0);
	FOR(i, 0, L) {
		int a, b; cin >> a >> b;
		a--, b--;
		LG[a].push_back(b);
		LG[b].push_back(a);
	}

	{
		int c = 0;
		FOR(i, 0, N) {
			if (Qcolor[i] == 0) {
				c ++;
				dfs(i, -1, c, QG, Qcolor);
			}
		}
	}
	{
		int c = 0;
		FOR(i, 0, N) {
			if (Lcolor[i] == 0) {
				c++;
				dfs(i, -1, c, LG, Lcolor);
			}
		}
	}
	map<PII, int>Map;
	FOR(i, 0, N) {
		Map[PII(Qcolor[i] ,Lcolor[i])] ++;
	}
	FOR(i, 0, N) {
		cout << Map[PII(Qcolor[i], Lcolor[i])] << endl;
	}

	return 0;
}


Measured memory_bytes: 27776
n=int(input())
red=[]
blue=[]
for i in range(n):
    red.append(tuple(map(int,input().split())))
for i in range(n):
    blue.append(tuple(map(int,input().split())))
red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue)
count=0
i=0

while i<len(blue):
    for j in range(len(red)):
        if red[j][0]<blue[i][0] and red[j][1]<blue[i][1]:
            count+=1
            del red[j]
            del blue[i]
            break
    else:
        i+=1
print(count)

Measured memory_bytes: 3064
N, M = map(int, input().split())
st = [1 for _ in range(N+1)]
for _ in range(M):
    st[int(input())] = 0
dp = [0 for _ in range(N+1)]
MOD = int(1e9) + 7
dp[0] = 1
# DP
if st[1]:
    dp[1] = 1
for i in range(2, N+1):
    if st[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[-1])

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

using namespace std;

const int MAXN = 300300;

int N, M;
vector<int> divs[MAXN];
vector<int> add[MAXN];
vector<int> delt[MAXN];

int ft[MAXN];
int ans[MAXN];

void addf(int p, int val) {
   for (; p <= M; p += p & -p) ft[p] += val;
}

int getf(int p) {
   int ans = 0;
   for (; p > 0; p -= p & -p) {
      ans += ft[p];
   }
   return ans;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin >> N >> M;
   for (int i = 1; i <= N; ++i) {
      int l, r;
      cin >> l >> r;
      add[l].emplace_back(l);
      delt[r].emplace_back(l);
   }
   for (int i = 1; i <= M; ++i) {
      for (int j = i; j <= M; j += i) {
         divs[j].emplace_back(i);
      }
   }
   for (int i = 1; i <= M; ++i) {
      for (int v : add[i]) {
         addf(v, +1);
      }
      for (int v : divs[i]) {
         ans[v] += getf(i) - getf(i - v);
      }
      for (int v : delt[i]) {
         addf(v, -1);
      }
   }
   for (int i = 1; i <= M; ++i) {
      cout << ans[i] << "\n";
   }
}


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

if N == 0:
    print(2)
    exit()
elif N == 1:
    print(1)
    exit()

L_2 = 2
L_1 = 1
for i in range(N-1):
    L = L_1+L_2
    L_2 = L_1
    L_1 = L
print(L)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////

ll ap[1900];

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

    ll n,m;

    cin>>n;

    ll gcd = 0;
    

    for(ll i=0;i<n;i++){
      ll l;
      cin>>l;
      gcd = __gcd(l,gcd);
    }

    cout<<gcd;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
#include <stdlib.h>
int main(void){
    int n,m;
    cin>>n>>m;
    int* a=(int*)malloc(sizeof(int)*n*m);
    int* b=(int*)malloc(sizeof(int)*m);
    int* retval=(int*)malloc(sizeof(int)*n);

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i*m+j];
        }
        retval[i]=0;//initialize
    }
    for(int j=0;j<m;j++){
        b[j]=0;
        cin>>b[j];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            retval[i]+=b[j]*a[i*m+j];
        }
        printf("%d\n",retval[i]);
    }


    return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int a,b,c;
	cin >> a >> b >> c;
	int ans = max({a,b,c}) - min({a,b,c});
	cout << ans << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;

double dig(ll val){
    ll  num, sum = 0;
    num = val;
    while (num != 0)
    {
        sum = sum + num % 10;
        num = num / 10;
    }
    return (double)sum;
}

pair<double,int> A[X17];
void _() {
//    int j=0;
//    for (int i = 99; i < 400000; i+=100) {
//        A[j++]={i*1./dig(i),i};
//    }
//    for (int i = 0; i < 4000; ++i) {
//        auto pos=min_element(A+i,A+4000);
//        if((pos-A==i)){
//            cout << A[i].second <<"\n";
//        }
//    }
    ll k;
    cin >> k;
    ll inc=1,n=1;
    int j=1;
    bool flg=true;
    if(k==1){cout << 1;
        return;}
        cout << 1 <<"\n";
    while(j<k){

//        if(n==29999){
//
//            inc=inc;
//            inc =10*10*10;
//        }
        if((n+inc)/dig(n+inc)>(n+inc*10)/dig(n+10*inc)){

            inc *=10;
            n+=inc;
            j++;
            while(dig(n)==dig(n+inc)-1){
                cout << n <<"\n";
                n+=inc;

                j++;
                if(j>k)return;
            }
            cout << n <<"\n";
        }
        else {
            n+=inc;
            j++;
            while(dig(n)==dig(n+inc)-1){
                cout << n <<"\n";
                n+=inc;
                j++;
                if(j>k)return;
            }
            cout << n <<"\n";
        }
    }
}


int main() {
#if __MINGW32__
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Input.txt", "r", stdin);
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








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

int main(){
  ll a,b;
  string s;
  char c;

  //cin >>c;
  //cout << c << endl;
  //cout << (int)c<< endl;
  ll y=0;
  rep(i,4){
    cin >>c;
    y*=10;
    y+=(int)c-(int)('0');
  }
  cin >> c;
  rep(i,2){
    cin >>c;
    y*=10;
    y+=(int)c-(int)('0');
  }
  cin >> c;
  rep(i,2){
    cin >>c;
    y*=10;
    y+=(int)c-(int)('0');
  }
  //cout << y << endl;

  if(y<=20190430)cout << "Heisei" <<endl;
  else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;
int t, T;

int main() {
#ifdef Albin
	freopen("Input.txt", "r", stdin);
	//freopen("Output.txt", "w", stdout);
#endif // Albin
	int a[10005], n, m, s = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		s += a[i];
	}
	if (s > n)cout << -1 << endl;
	else cout << n - s << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
typedef long long ll;
using namespace std;

const int INF = 1<<30;
typedef pair<int,int> P;
int h,w,n;
int dis[60][60];
string board[60];
int sx, sy;
int dx4[] = {1,0,-1,0};
int dy4[] = {0,1,0,-1};

void init(){
    for (int i = 0; i < 60; i++)for (int j = 0; j < 60; j++) dis[i][j] = INF;
}

int BFS(){
    init();
    queue<P> que;
    que.push(make_pair(sx,sy));
    dis[sy][sx] = 1;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        for (int j = 0; j < 4; j++) {
            int nx = p.first + dx4[j], ny = p.second + dy4[j];
            if(nx<0 || nx>=w || ny<0 || ny>=h) continue;
            if(board[ny][nx] == '#')continue;
            if(dis[ny][nx]==INF){
                que.push(make_pair(nx,ny));
                dis[ny][nx] = dis[p.second][p.first] + 1;
            }
        }
    }
    return dis[h-1][w-1];
}


int main(){
    cin >> h >> w;
    int black = 0;
    for (int i = 0; i < h; i++) {
        cin >> board[i];
        for (int j = 0; j < w; j++) if(board[i][j] == '#') black++;
    }
    sx = 0, sy = 0;
    int dist = BFS();
    if(dist != INF) cout << h*w - black - dist << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import math
A,B = map(int,input().split())

mina = math.ceil(A/0.08)
if math.floor((A+1)/0.08) == (A+1)/0.08:
  maxa = (A+1)/0.08 -1
else:
  maxa = math.floor((A+1)/0.08)
minb = math.ceil(B/0.1)
if math.floor((B+1)/0.1) == (B+1)/0.1:
  maxb = (B+1)/0.1 -1
else:
  maxb = math.floor((B+1)/0.1)

if maxa < minb or maxb < mina:
  print(-1)
else:
  print(max(mina,minb))


Measured memory_bytes: 39824
#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[10000+1], q, key, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int dp[41][41];
int main(void)
{
	int n,i,j,k,a,b,x,y;
	while(1) {
		cin>>a>>b;
		if(!a&&!b) break;
		cin>>n;
		for(i=0;i<b;i++) {
			for(j=0;j<a;j++) {
				dp[i][j]=0;
			}
		}
		for(i=0;i<n;i++) cin>>x>>y,x--,y--,dp[y][x]=-1;
		dp[0][0]=1;
		for(i=0;i<b;i++) {
			for(j=0;j<a;j++) {
				if(dp[i][j]!=0&&dp[i][j]!=-1) {
					if(dp[i+1][j]!=-1)dp[i+1][j]+=dp[i][j];
					if(dp[i][j+1]!=-1)dp[i][j+1]+=dp[i][j];
				}
			}
		}
		cout<<dp[b-1][a-1]<<endl;
	}
}

Measured memory_bytes: 3100
#include <cstdio>
#define N 999999
unsigned char p[((N+1)/2+7)/8];
int main() {
    int i,j,s,n=3;
    for(i=0;n*n<=N;i++,n+=2)
        if(!(p[i/8]&(1<<(i%8))))
            for(j=i+n;j<((N+1)/2);j+=n)p[j/8]|=(1<<(j%8));
    while(scanf("%d",&n)!=EOF) {
        if(n<2){printf("0\n");continue;}
        if(n==2){printf("1\n");continue;}
        for(i=3,j=0,s=1;i<=n;i+=2,j++)
            s+=!(p[j/8]&(1<<(j%8)));
        printf("%d\n",s);
    }
}

Measured memory_bytes: 1096