akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
    int s_num,len,bonus,b[20];
    int count=0;
    int i,j,temp,sum;
    scanf("%d %d %d",&s_num,&len,&bonus);
    for(i=0;i<len;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<s_num;i++){
        sum=0;
        for(j=0;j<len;j++){
            scanf("%d",&temp);
            sum+=temp*b[j];
        }
        if(sum+bonus>0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int gcd(int x,int y,int z){
    int res=__gcd(x,y);
    res=__gcd(res,z);
    return res;
}
int main(){
    int k;
    ll ans = 0;
    cin >> k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int s=1;s<=k;s++){
                ans += gcd(i,j,s);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
n = list(map(int,input().rstrip()))
for i in range(2**3):
  ope = []
  ans = n[0]
  for j in range(3):
    if (i >> j) & 1:
      ope.append("+")
      ans += n[j+1]
    else:
      ope.append("-")
      ans -= n[j+1]
  if ans == 7:
    res = [ope[i]+str(n[1+i]) for i in range(3)]
    res = "".join(res)
    res = str(n[0]) + res + "=7"
    print(res)
    break

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  int cur = 1e9;
  rep(i, n) {
    cur = min(cur, p[i]);
    if(cur == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
def main():
    N, M = map(int, input().split(" "))
    ac = 0
    wa = 0
    answer = ["C"] * N  # C: 適当な初期値
    for _ in range(M):
        ps = input().split(" ")
        p = int(ps[0]) - 1
        if not answer[p][-1] == "A":
            answer[p] = answer[p] + ps[1][0]
    if M > 0:
        for a in answer:
            if a[-1] == "A":
                ac += 1
                wa += (len(a) - 2)
    print(ac, wa)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9324
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
string s;
int k;
signed main() {
	cin >> s >> k;
	rep(i, s.size()) {
		if ((int)(s[i] - 'a') + k >= 26 && s[i] != 'a') {
			k -= 26 - (int)(s[i] - 'a');
			s[i] = 'a';
		}
	}
	if ((char)(s[s.size() - 1] + k % 26) <= 'z')s[s.size() - 1] += (k % 26);
	else {
		s[s.size() - 1] += (k % 26);
		s[s.size() - 1] -= 26;
	}
	cout << s << endl;
	endre;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt(),A[]=new int[n+1];
		
		for(int i=0;i<=n;i++) {
			if(i==0 || i==1)A[i]=1;
			else A[i]=A[i-1]+A[i-2];
		}
		
		System.out.println(A[n]);
	}

}



Measured memory_bytes: 26224
import sys
sys.setrecursionlimit(10 ** 9)
#島ごとに　島の人口ー友達の数ーブロックの数ー自分一人＝友達候補の数
N,M,K = map(int,input().split())
G = [[] for i in range(N+1)]
for i in range(M):
  a,b = map(int,input().split())
  G[a].append(b)
  G[b].append(a)
bl = [[] for i in range(N+1)]  
for i in range(K):  
  c,d = map(int,input().split())
  bl[c].append(d)
  bl[d].append(c)

seen = [False for i in range(N+1)]  
lcnt = [1]
lmen = []
def dfs(p):
  for v in G[p]:
    if seen[v] == False:
      seen[v] = True
      lmen.append(v)
      lcnt[0] += 1
      dfs(v)

#unionfind
lp = [i for i in range(N+1)] #親のリスト
#木の根を求める
def root(x):
  if lp[x] == x:
    return x
  else:
    lp[x] = root(lp[x])
    return lp[x]
#xとyが同じ集合に属するか否か
def det(x,y):
  return root(x) == root(y)
#xとYが属する集合の併合 Yが親になる
def unite(x,y):
  x = root(x)
  y = root(y)
  if x != y:
    lp[x] = y      

popu = [0 for i in range(N+1)] 
bpopu = [0 for i in range(N+1)]
seen = [False for i in range(N+1)] 
for i in range(1,N+1):
  if seen[i] == False:
    seen[i] = True

    lcnt = [1]
    lmen = [i]
    dfs(i)
    #根iに人口を記載
    popu[i]=lcnt[0]
    for j in lmen:
      unite(j,i)
    for j in lmen:  
      c = 0
      for k in bl[j]:
        if det(k,i):
          c += 1
      bpopu[j] = c
###
for i in range(1,N+1):
  print( popu[root(i)]-len(G[i])-bpopu[i]-1 )

Measured memory_bytes: 68580
#include <iostream>
#include <string>
 using namespace std;
 int main() {
    int a,b,t;
	cin >> a >> b >> t;
    int n = 1;
	int total = 0;
	while (a*n < t + 0.5) {
		total += b;
		n++;
	}
	cout << total << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, N);

    rep(i, 0, 2 * N) {
        if (int(i * 1.08) == N) {
            print(i);
            return 0;
        }
    }

    print(":(");

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  tmp1=input[1].split(" ");
  tmp2=input[2].split(" ");
  tmp3=input[3].split(" ");
  a = new Array(n).fill(0);
  b = new Array(n).fill(0);
  c = new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp1[i]);
  }
  for(i=0;i<n;i++){
    b[i]=parseInt(tmp2[i]);
  }
  for(i=0;i<n;i++){
    c[i]=parseInt(tmp3[i]);
  }
  var ans=0;
  a.sort(function(a,b){
          if( a < b ) return -1;
          if( a > b ) return 1;
          return 0;
  });
  b.sort(function(a,b){
          if( a < b ) return -1;
          if( a > b ) return 1;
          return 0;
  });
  c.sort(function(a,b){
          if( a < b ) return -1;
          if( a > b ) return 1;
          return 0;
  });
  b1 = new Array(n).fill(0);
  b2 = new Array(n).fill(0);
  for(i=0;i<n;i++){
    if(i==0||b1[i-1]==0){
      var x=0;
    }else{
      var x=b1[i-1]-1;
    }
    for(j=x;b[i]>a[j];j++){
      b1[i]=j+1;
    }
  }
  for(i=n-1;i>=0;i--){
    if(i==n-1||b2[i+1]==0){
      var x=n-1;
    }else{
      var x=n-(b2[i+1]);
    }
    for(j=x;b[i]<c[j];j--){
      b2[i]=n-j;
    }
  }
  for(i=0;i<n;i++){
    ans=ans+b1[i]*b2[i];
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 57048
#include <iostream>
#include <string>

using namespace std;

int main() {
    string today;
    
    cin >> today;

    if (today == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (today == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (today == "Rainy") {
        cout << "Sunny" << endl;
    }
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a;
    int res=100000;
    for(int i=0; i<n; i++){
        int cnt=0;
        cin >> a;
        while(a%2 == 0){
            a /= 2;
            cnt++;
        }
        res = min(res,cnt);
    }

    cout << res << endl;

}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vector<int> > dp(n+1, vector<int>(m+1, 0));
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=m; ++j){
            if(i < n && j < m && s[i] == t[j])
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            if(i < n)
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j < m)
                dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
        }
    }

    int i = n;
    int j = m;
    string ans;
    while(i > 0 && j > 0){
        if(dp[i-1][j] == dp[i][j]){
            -- i;
        }
        else if(dp[i][j-1] == dp[i][j]){
            -- j;
        }
        else{
            -- i;
            -- j;
            ans += s[i];
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35584
using System;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());

            var table = new int[10, 10];
            for (int i = 1; i <= N; i++)
            {
                table[FirstDigit(i), i % 10]++;
            }

            var result = 0;
            for (int i = 1; i <= N; i++)
            {
                result += table[i % 10, FirstDigit(i)];
            }
            Console.WriteLine(result);
        }

        static int FirstDigit(int num)
        {
            while (num >= 10)
            {
                num /= 10;
            }
            return num;
        }
    }
}


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

int main(int argd, char* argv[])
{
  int n; cin >> n;
  vector<int> v(n);
  for(int i=0; i<n-1; ++i)
  {
    int tmp; cin >> tmp;
    v[tmp-1]++;
  }
  for(auto x:v)
  {
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 4056
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	char x, y;
	cin>>x>>y;
	if(x > y) printf(">\n");
	else if(x < y) printf("<\n");
	else printf("=\n");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			s = new string(s.Select(c => (char)(c + (c > 'C' ? -3 : +23))).ToArray());
			Console.WriteLine(s);
		}
	}
}

Measured memory_bytes: 5532
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	ll a, b, c, k;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
	if (k % 2 == 0) {
		PRINTD(a - b);
	}
	else {
		PRINTD(b - a);
	}
}

Measured memory_bytes: 128
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    ll r=0,b=0,g=0;
    r=0;
    ans=1;
    ll baisu=1;
    for(int i=0;i<n;i++){
        int cnt=0;
        int color=0;
        if(a[i]==r){
            cnt++;
            color=1;
        }
        if(a[i]==b)
        {
            cnt++;
            color=2;
        }
        if(a[i]==g)
           {
                cnt++;
                color=3;
            }
        if(cnt==1){
            if(color==1)
                r++;
            else if(color==2)
                b++;
            else
                g++;
        }
        else{
            ans*=cnt;ans%=MOD;
            if(color==1)
                r++;
            else if(color==2)
                b++;
            else
                g++;
        }
    }
    
    cout<<ans%MOD<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto&& i : p){
        cin >> i;
    }
    if(is_sorted(begin(p), end(p))){
        cout << "YES\n";
        return 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            swap(p[i], p[j]);
            if(is_sorted(begin(p), end(p))){
                cout << "YES\n";
                return 0;
            }
            swap(p[i], p[j]);
        }
    }
    cout << "NO\n";
}

Measured memory_bytes: 256
import itertools
import math





N,A,B = list(map(int,input().split(" ")))
hs = [int(input()) for _ in range(N)]


OK = 10 ** 10 #この以上回数やればOK
NG = 0  # この回数以下だとNG

while OK - NG > 1:
    target = (OK + NG) // 2 #  今回試される数字
    s = 0 # 合計s回魔法が使われる
    for h in hs:
        temp = (h- target * B)/(A-B)
        temp = math.ceil(temp)
        s += max(temp,0)
    if target >= s:
        OK = target
    else:
        NG = target
print(OK)



Measured memory_bytes: 52824
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int a,b,c,d,e,f;
		double temp1,temp2;
		double x,y;
		while(s.hasNext()){
			a=s.nextInt();
			b=s.nextInt();
			c=s.nextInt();
			d=s.nextInt();
			e=s.nextInt();
			f=s.nextInt();
			temp1=a*e-b*d;
			temp2=c*e-b*f;
			x=temp2/temp1;
			if(x==0)
				x=0;
			y=(c-a*x)/b;
			System.out.printf("%1.3f %1.3f\n",x,y);
		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N, K;
int C[2005], G[2005];

vi books[11];

int dp[11][2005]; // dp[i][j] := i?¨?????????§???j????????£?????????????????????????????§???

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

    rep(i, N) {
        cin >> C[i] >> G[i];
        books[G[i]].PB(C[i]);
    }

    rep1(i, 10) {
        sort(all(books[i]), greater<int>());

        books[i].insert(begin(books[i]), 0);

        for (int j = 1; j < books[i].size(); ++j) {
            books[i][j] += books[i][j - 1];
            books[i][j] += (j - 1) * 2;
        }
    }

    for (int i = 1; i <= 10; ++i) {
        for (int j = 0; j <= K; ++j) {
            for (int k = 0; j + k <= K; ++k) {
                if (k >= books[i].size()) break;
                chmax(dp[i][j + k], dp[i - 1][j] + books[i][k]);
            }
        }
    }

    cout << *max_element(dp[10], dp[10] + K + 1) << endl;
}

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

namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define OP minmax

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
}

const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;

int N;
vi L;

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

	cin >> N;
	L.resize(2*N);
	FOR(i,0,2*N) cin >> L[i];
	
	sort(ALL(L));
	
	ll ans = 0;
	FOR(i,0,N) ans += L[2*i];
  
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include<cstring>

using namespace std;

int main(){
  int n;
  cin>>n;
  long l[87];
  l[0] = 2;
  l[1] = 1;
  for(int i = 2;i<=n;i++){
    l[i] = l[i-1] + l[i-2];
  }
  cout<<l[n]<<endl;

  return 0;
}


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

int main(){
	string s; cin>>s;
	int i=0;
	while(i<s.size()-1){
		if(s[i]=='S' and s[i+1]=='T'){
			s.erase(i,2);
			if(s.size()==0) break;
			if(i==0 or i==1) i=0;
			else i--;
		}else{
			i++;
		}
	}
	cout<<s.size()<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    REP(i, 0, C) {
        REP(j, 0, C) {
            cin >> D[i][j];
        }
    }
    vector<vector<int>> c(N, vector<int>(N));
    REP(i, 0, N) {
        REP(j, 0, N) {
            cin >> c[i][j];
        }
    }
    vector<lli> memo[3];
    REP(i, 0, N) {
        REP(j, 0, N) {
            int ind = (i + j) % 3;
            memo[ind].push_back(c[i][j]);
        }
    }
    vector<vector<lli>> res(3, vector<lli>(C, 0));
    REP(i, 0, 3) {
        REP(j, 0, C) {
            REP(k, 0, memo[i].size()) {
                res[i][j] += D[memo[i][k] - 1][j];
            }
        }
    }
    lli ans = 1LL << 60;
    REP(i, 0, C) {
        REP(j, 0, C) {
            REP(k, 0, C) {
                if (i == j || j == k || k == i) {
                    continue;
                }
                ans = min(ans, res[0][i] + res[1][j] + res[2][k]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

W = list(map(int, input().split()))

Wmax = sum(W)
d = 9999999
mi = 0
ma = 0

for i in range(N):
    mi += W[i]
    ma = Wmax - mi
    if d > abs(ma - mi):
        d = abs(ma - mi)
    else:
        print(d)
        break

Measured memory_bytes: 3064
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[200002], saishou[200002], saidai[200002];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

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


	int N = getint();
	int A[200001];
	rep1(i, N) A[getint()] = i;
	
	rep(i, N + 2) P[i] = -1;

	ll kotae = 0;
	for (int i = N; i > 0; i--) {
		int a = A[i];
		int b = Find(a - 1);
		int c = Find(a + 1);
		int l = saishou[b];
		if (!l) l = a;
		int r = saidai[c];
		if (!r) r = a;
		kotae += (ll)(a - l + 1) * (r - a + 1) * i;
		if (saishou[b] && saidai[c]) {
			saidai[b] = saidai[c];
			P[c] = b;
		}
		else if (saishou[b]) {
			saidai[b] = a;
			P[a] = b;
		}
		else if (saidai[c]) {
			saishou[c] = a;
			P[a] = c;
		}
		else {
			saishou[a] = a;
			saidai[a] = a;
		}
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n; cin >> n;
  vector<int>a(n);
  long long s = 0;
  for (int i = 0; i < n; i++) cin >> a[i], s += a[i];
  vector<vector<long long>>dpX(n + 1, vector<long long>(n + 1, 0));
  for (int i = 1; i <= n; i++) {
    dpX[i][i] = a[i-1];
  }
  for (int l = 1; l <= n; ++l) {
    for (int i = 1; i <= n - l; i++) {
      int j = i + l;
      if (j == i + 1) {
        dpX[i][j] = max(a[i-1], a[j-1]);
        continue;
      }
      long long first = a[i-1] + min(dpX[i+1][j-1], dpX[i+2][j]);
      long long last = a[j-1] + min(dpX[i][j-2], dpX[i+1][j-1]);
      dpX[i][j] = max(first, last);
    }
  }
  // for (int i = 1; i <= n; i++) {
  //   for (int j = i + 1; j <= n; j++) {
  //     if (j == i + 1) {
  //       dpX[i][j] = max(a[i-1], a[j-1]);
  //       continue;
  //     }
  //     long long first = a[i-1] + min(dpX[i+1][j-1], dpX[i+2][j]);
  //     long long last = a[j-1] + min(dpX[i][j-2], dpX[i+1][j-1]);
  //     dpX[i][j] = max(first, last);
  //     cout << i << " " << j << " " << dpX[i][j] << endl;
  //   }
  // }
  cout << 2 * dpX[1][n] - s << endl;
  return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

string S;
unsigned int n;

int main(void){
    getline(cin,S);
    n = S.length();
    for(int i = 0; i < n; i++){
        char c = S[i];
        int n = ((c - 'A') + 23)%26;
        
        printf("%c",'A' + n);
    }
    printf("\n");
}

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

int main() {
	
	int H,W;
	cin>>H>>W;
	fx(H){
		string s;
		cin>>s;
		ce(s)
		ce(s)
	}
	
	
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int c=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
					if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[k]+a[i]>a[j]){
						c++;
					}
				}
			}
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
    ll n,x,t; cin>>n>>x>>t;
    ll ans=(n/x)*t;
    ll temp=(n%x);
    if(temp>0){
        ans+=t;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int,string>;

int main() {
 int n,x;
 cin >> n >> x;
 vector<int> a(n);
 rep(i,n) cin >> a.at(i);
 int b = x;
 rep(i,n) b-=a.at(i);
 sort(a.begin(),a.end());
 int ans = n + b/a.front();
 cout << ans << endl;
 } 

Measured memory_bytes: 3620
N, M = map(int, input().split())
citys =[list(map(int, input().split())) for i in range(M)]
cs = {}
ans = {}
for p, y in citys:
    if p in cs:
        cs[p].append(y)
    else:
        cs[p] = [y]
for p, v in cs.items():
    v.sort()
    for i in range(len(v)):
        ans[(p, v[i])] = '0'*(6-len(str(p)))+str(p) + '0'*(6-len(str(i+1))) +str(i+1)
for p, y in citys:
    print(ans[(p, y)])

Measured memory_bytes: 63192
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <cstdint>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        sum ^= a[i];
    }
    for (int i = 0; i < N; ++i) {
        int temp = sum ^ a[i];
        cout << temp << " ";
    }
    cout << endl;
    return 0;

}


Measured memory_bytes: 3892
#include <stdio.h>

int main()
{
	long long a;
	int b0, b1;

	scanf("%lld", &a);
	scanf("%d.%d", &b0, &b1);

	long long c0, c1;
	c0  = a * b0;
	c1 = (a * b1) / 100;

	printf("%lld", c0 + c1);

	return 0;
}


Measured memory_bytes: 1736
#include<iostream>
 #include<algorithm>
using namespace std; 
#define N 100010
 int main(){
 int n,m,h[N],ma[N];
 cin>>n>>m;
 for(int i=1;i<=n;i++){
 cin>>h[i];
 ma[i]=0;
 }
for(int i=0;i<m;i++){
 int a,b;
 cin>>a>>b;
 ma[a]=max(ma[a],h[b]);
 ma[b]=max(ma[b],h[a]);
 }
 int ans=0;
 for(int i=1;i<=n;i++){
 ans+=h[i]>ma[i];
 }
 cout<<ans<<endl;
 }


Measured memory_bytes: 4332
#DP B
import sys
N, K = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))

dp = [-1 for _ in range(N)]
#print(dp)
#print(H)
dp[0] = 0
#print(dp)

for i in range(1, N):
    for k in range(1, K+1):
        if i-k>=0:
            tmp = abs(H[i]-H[i-k]) + dp[i-k]
            if dp[i] ==-1 or tmp < dp[i]:
                dp[i] = tmp
    #print(dp)
print(dp[-1])

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

using namespace std;
int n, a, b, res = 0;
map<int, bool> mp;

int rev(int num){
	int temp = 0;
	while(num > 0){
		temp += num % 10;
		num /= 10;
	} return temp;
}

int main(){
	scanf("%d %d %d", &n, &a, &b);
	for(int i = a; i <= b; i++) mp[i] = 1;
	for(int i = 1; i <= n; i++){
		if(mp[rev(i)] == 1) res += i;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll r, g, b, n;
    cin >> r >> g >> b >> n;

    ll ans = 0;
    rep(i, n+1) {
        rep(j, n+1) {
            ll x = r*i + g*j;
            if(x <= n && (n-x)%b == 0) {
                ans++;
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define INF 1e9

int gcd(int a,int b){return b==0 ? a : gcd(b,a%b);}

vector<vector<int>> g;

bool dfs(int v,vector<int> &match,vector<bool> &used){
    used[v] = true;
    for(int u : g[v]){
        int w = match[u];
        if(w<0 || (!used[w] && dfs(w,match,used))){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}
 
int bipartite_matching() {
    int res = 0;
    int V = g.size();
    vector<int> match(V, -INF);
    rep(v,V){
        if(match[v] < 0){
            vector<bool> used(V, false);
            if(dfs(v,match,used)){
                res++;
            }
        }
    }
    return res;
}

int main(void){
    int m,n;
    while(cin>>m>>n, n|m){
        vector<int> b(m),r(n);
        g.clear();
        g.resize(m+n);
        rep(i,m) cin>>b[i];
        rep(i,n) cin>>r[i];

        rep(i,m)rep(j,n){
            if(gcd(b[i],r[j]) > 1){
                g[i].push_back(m+j);
                g[m+j].push_back(i);
            }
        }
        cout<<bipartite_matching()<<endl;
    }

    return 0;
}



Measured memory_bytes: 4444
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 3e18
#define ULMAX 18446744073709551615
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline int add(int a, int b){a = (a+b); if(a>=mod)a-=mod; return a;}
inline int sub(int a, int b){a = a-b; if(a<0)a+=mod; return a;}
inline int mul(int a, int b){a = (a*b)%mod; return a;}
inline int power(int x, int y){ int res = 1,temp = x;while(y > 0){if(y&1) res *= temp;temp *= temp;y /= 2;}return res;}
inline int power(int x,  int y,  int m) {if (y == 0) return 1; int p = power(x, y/2, m) % m; p = (p * p) % m; return (y%2 == 0)? p : (x * p) % m; } 



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

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
}
return 0;
}
/*

*/

Measured memory_bytes: 3800
import sys


def main():
    S = list(input())[::-1]
    T = list(input())[::-1]
    d = len(S) - len(T) + 1

    for i in range(d):
        cnt = 0
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                cnt += 1

        if cnt == len(T):
            for k in range(len(T)):
                S[i+k] = T[k]
            break

    else:
        print('UNRESTORABLE')
        sys.exit()

    for i in range(len(S)):
        if S[i] == '?':
            S[i] = 'a'

    print(''.join(S)[::-1])


main()


Measured memory_bytes: 3064
n = input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])

for i in range(2**3):
  ans = a
  temp=[]
  for j in range(3):#1=+,0=-
    if i >> j & 1:
      temp.append("+")
    else:
      temp.append("-")
  for i,j in zip([b,c,d],temp):
    if j == "+":
      ans+=i
    else:
      ans-=i
  if ans == 7:
    print(str(a) + temp[0] + str(b) + temp[1] + str(c) + temp[2] +str(d) + "=7")
    break
  

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long int
#define ld long long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 3;
 
int main(){
    fast;
    char a;
    cin >> a;
    if(a >= 'A' && a <= 'Z')
        cout << 'A';
    else
        cout << 'a';
    return 0;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

struct UnionFind {
  vector<int> data;

  UnionFind(int sz) { data.assign(sz, -1); }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool issame(int a, int b) { return find(a) == find(b); }

  int size(int k) { return (-data[find(k)]); }
};

void solve() {
  int n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);
  vector<unordered_set<int>> s(n);

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    uf.unite(a, b);
    s[a].insert(b);
    s[b].insert(a);
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (uf.issame(a, b)) {
      s[a].insert(b);
      s[b].insert(a);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << uf.size(i) - s[i].size() - 1 << ' ';
  }
  cout << uf.size(n - 1) - s[n - 1].size() - 1 << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 25600
#include<stdio.h>
int A[100000],n;
int binarySearch(int key){
    int left=0, right=n,mid;
    while(left<right){
        mid=(left+right)/2;
        if(A[mid]==key) return 1;
        else if(key<A[mid]) right=mid;
        else left=mid+1;
    }
    return 0;
}

int main(void){
    int i,q,k,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",&k);
        if(binarySearch(k)) sum++;
    }
    printf("%d\n",sum);
    return 0;
    
    
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string S;
  cin >> S;

  ll ans = 0;
  ll tmp = 1;
  ll pre_tmp = 1;
  bool watasu = false;
  for(int i = 0; i < S.length()-1; i++){
    if(S[i] == S[i+1]){
      tmp++;
    }else{
      if(watasu){
        if(tmp%3==0){
          ans += (tmp/3) * 2;
          watasu = true;
        }else if(tmp%3 == 1){
          ans += (tmp/3) * 2 + 1;
          watasu = false;
        }else{
          ans += (tmp/3) * 2 + 2;
          watasu = false;
        }
      }else{//渡さない
        if(tmp%3 == 0){
          ans += (tmp/3) * 2;
          watasu = false;
        }else if(tmp%3 == 1){
          ans += (tmp/3) * 2 + 1;
          watasu = false;
        }else{
          ans += (tmp/3) * 2 + 1;
          watasu = true;
        }
      }
      tmp = 1;
    }
  }

  
      if(watasu){
        if(tmp%3==0){
          ans += (tmp/3) * 2;
          watasu = true;
        }else if(tmp%3 == 1){
          ans += (tmp/3) * 2 + 1;
          watasu = false;
        }else{
          ans += (tmp/3) * 2 + 2;
          watasu = false;
        }
      }else{//渡さない
        if(tmp%3 == 0){
          ans += (tmp/3) * 2;
          watasu = false;
        }else if(tmp%3 == 1){
          ans += (tmp/3) * 2 + 1;
          watasu = false;
        }else{
          ans += (tmp/3) * 2 + 1;
          watasu = true;
        }
      }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define aint(v) v.begin(), v.end()
using P = pair<int, int>;
constexpr int mod = 1000000007;
class mint {
public:
    int x;
    constexpr mint(long long x=0) : x((x % mod + mod) % mod) {}
    constexpr mint operator-() const { 
      return mint(-x);
    }
    constexpr mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    constexpr mint inv() const {
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};
class Combination {
public:
    vector<int> fac, finv, inv;
    Combination(int n) : fac(n), finv(n), inv(n) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n; ++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;
        }
    }
    int calc(int n, int k){
        if (n < k){
            return 0;
        }
        if (n < 0 || k < 0){
            return 0;
        } 
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

signed main() {

    int n, k;
    cin >> n >> k;
    
    mint ans = 0;
    REP(i, k, n+2){
        mint mn(i*(i-1)/2);
        //cout << "min" << mn << endl;
        mint mx(i*(2*n-i+1)/2);
        //cout << "max" << mx << endl;
        ans += mx - mn + 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
from collections import deque
n = deque(list(input()))
digit = n.popleft()
cnt = 1
while n:
    if cnt == 3:
        break
    d = n.popleft()
    if d == digit:
        cnt += 1
    else:
        digit = d
        cnt = 1

if cnt == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9316
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

a1, a2, a3 = [int(item) for item in input().split()]
sumation = a1 + a2 + a3
if sumation >= 22:
    print("bust")
else:
    print("win")

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a;cin >> a; 
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)

int main()
{
  //input
  inputInt(N);inputInt(M);
  int l[M],r[M];
  fN(i,M) cin>>l[i]>>r[i];
  
  //main
  sort(l,l+M,greater<int>());
  sort(r,r+M);
  int left = l[0];
  int right = r[0];
  int ans = (r[0]-l[0]+1 > 0) ? r[0]-l[0]+1 : 0;
  // 出力
  output(ans);
    
  return 0;
}

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

bool check(vector< vector<int> >& C, int a1, int a2, int a3) {
  vector<int> A = {a2, a3};
  vector<int> B = {C[0][0] - a1, C[0][1] - a1, C[0][2] - a1};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      if (A[i] + B[j] != C[i+1][j]) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  int tmp;
  vector< vector<int> > C(3);
  for (int i = 0; i < 3; i++) {
    cin >> tmp; C[i].push_back(tmp);
    cin >> tmp; C[i].push_back(tmp);
    cin >> tmp; C[i].push_back(tmp);
  }
  for (int a1 = 0; a1 <= 100; a1++) {
    for (int a2 = 0; a2 <= 100; a2++) {
      for (int a3 = 0; a3 <= 100; a3++) {
        if (check(C, a1, a2, a3)) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256