akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll n,m;
    cin>>n>>m;
    ll res=(n*(n-1))/2 + (m*(m-1))/2;
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop

X,Y,Z,K = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)
hp = []
checked_dict = {}
max_abc = a_list[0] + b_list[0] + c_list[0]
heappush(hp, (-max_abc,0,0,0))
for _ in range(K):
  ans, ai, bi, ci = heappop(hp)
  print(-ans)
  if ai < X-1 and not (ai+1, bi, ci) in checked_dict:
    checked_dict[(ai+1,bi,ci)] = 1
    heappush(hp, (-(a_list[ai+1]+b_list[bi]+c_list[ci]),ai+1,bi,ci))
  if bi < Y-1 and not (ai,bi+1,ci) in checked_dict:
    checked_dict[(ai,bi+1,ci)] = 1
    heappush(hp, (-(a_list[ai]+b_list[bi+1]+c_list[ci]),ai,bi+1,ci))
  if ci < Z-1 and not (ai,bi,ci+1) in checked_dict:
    checked_dict[(ai,bi,ci+1)] = 1
    heappush(hp, (-(a_list[ai]+b_list[bi]+c_list[ci+1]),ai,bi,ci+1))
             



Measured memory_bytes: 4780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int N;
    cin >> N;
    vector<int> A,B,X,Y;
    int a,b;
    for(int i = 0; i < N;i++){
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    for(int i = 0; i < N;i++){
        for(int l = 0; l < N;l++){
            if(i != l){
                X.push_back(A[i] - A[l]);
                Y.push_back(B[i] - B[l]);
            }   
        }
    }

    int max = 0;
    for(int i = 0; i < X.size();i++){
        int count = 0;
        for(int l = i; l < X.size();l++){
            if(X[i] == X[l] && Y[i] == Y[l]){
                count++;
            }
        }
        if(max < count) max = count; 
    }

    cout << N - max << endl;

    return 0;
}

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

using namespace std;

#define int long long

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, w;
    cin >> h >> w;
    if (min(h, w) == 1) {
        cout << 1 << '\n';
        exit(0);
    }
    cout << (h * w + 1) / 2;
    return 0;
}



Measured memory_bytes: 256
s = input()
t = input()
dp = [[0]*(len(t)+1) for i in range(len(s)+1)]
#dp[i+1][j+1]sのi文字目までとtのj文字目までを比較したときのLCS
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])

i = len(s)-1
j = len(t)-1
ans = ''
while j>= 0 and i >= 0:
    if dp[i][j+1] == dp[i+1][j+1]:i-= 1
    elif dp[i+1][j] == dp[i+1][j+1] :j-= 1
    else:
        ans = s[i] + ans
        i -= 1
        j -= 1
        
print(ans)


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

using namespace std;

#define REP(i, b, e) for(int i = (int)(b); i < (int)(e); i++)
#define rep(i, n) REP(i, 0, n)
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

vector<int> es[21];
int n, m;

ll dp[8][(1<<8)];

ll f(int p, int mask) {
	if(dp[p][mask] != -1) return dp[p][mask];
	if(mask == ((1<<n)-1)) return dp[p][mask] = 1LL;
	ll ret = 0LL;
	for(auto& to : es[p]) {
		if(mask & (1 << to)) continue;
		int nxt = mask | (1<< to);
		ret += f(to, nxt);
	}
	return dp[p][mask] = ret;
}

int main(){
	cin>>n>>m;
	rep(i, m){
		int a, b;
		cin>>a>>b;	
		a--;
		b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	rep(i, 8) rep(j, 1<<8) dp[i][j] = -1;
	cout<<f(0, 1)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int N, K;
	int* A;
	cin >> N;
	cin >> K;
	A = alloc(N, int);
	repeat(i, i < N) {
		scanf("%d", &A[i]);
	}

	
	//DEBUG();
	for (int i = 0; i < N - K; i++) {
		//printf("%d %d", A[i], A[K + i]);
		if (A[i] < A[K + i]) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}

	free(A);
	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N, X, Y, ans[MAXN];
int dist(int a, int b){
	return min({abs(b-a), abs(a-X)+abs(b-Y)+1, abs(a-Y)+abs(b-X)+1});
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> X >> Y;
	FOR(i,1,N) FOR(j,i+1,N){
		ans[dist(i,j)]++;
	}
	FOR(i,1,N-1) cout << ans[i] << "\n";
}


Measured memory_bytes: 256
def get_next_expect_color(color) :
    if (color == "1") :
        return "0"
    else :
        return "1"

S = input()

must_reversed_count = 0
expect_color = S[0]

must_reversed_count2 = 1 # 最初が反転なので1にする
expect_color2 = get_next_expect_color(S[0])

for i in range(1,len(S)) :
    if (S[i] == expect_color) :
        must_reversed_count += 1
    
    if (S[i] == expect_color2) :
        must_reversed_count2 += 1

    expect_color = get_next_expect_color(expect_color)
    expect_color2 = get_next_expect_color(expect_color2)

# print(must_reversed_count)
# print(must_reversed_count2)
print(min([must_reversed_count,must_reversed_count2]))





Measured memory_bytes: 3316
N = int(input())
xyh = [[int(i) for i in input().split()] for i in range(N)]

tmpx,tmpy,tmph=0,0,0
for x,y,h in xyh:
    if h>0:
        tmpx,tmpy,tmph=x,y,h
        break

truecx,truecy,trueh=0,0,0
for cx in range(101):
    for cy in range(101):
        largeh=tmph+abs(tmpx-cx)+abs(tmpy-cy)
        flag=True
        for x,y,h in xyh:
            if h != max(largeh-abs(x-cx)-abs(y-cy),0):
                flag = False
                break
        if flag:
            truecx,truecy,trueh=cx,cy,largeh
            break
print(truecx,truecy,trueh)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
  double mx = -1;
  int mx_a = 0, mx_b = 0;
  for (int i = 0; i <= f; i += a) {
    for (int j = 0; i + j <= f; j += b) {
      if (i + j == 0) continue;
      for (int k = 0; i + j + k <= f; k += c) {
        for (int l = 0; i + j + k + l <= f; l += d) {
          if (100 * (k + l) > (i + j) * e) break;
          if (chmax(mx, 100.0 * (k + l) / (i + j + k + l))) {
            mx_a = i + j + k + l;
            mx_b = k + l;
          }
        }
      }
    }
  }
  cout << mx_a << " " << mx_b << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n; long long a[100000], ans = 0, x;
  scanf("%d %lld", &n, &x);
  for(int i = 0; i < n; i++) scanf("%lld", &a[i]);

  if(a[0] >= x){
    ans = a[0] - x;
    a[0] = x;
  }

  for(int i = 0; i < n - 1; i++){
    if(a[i] + a[i + 1] > x){
      ans += a[i] + a[i + 1] - x;
      a[i + 1] -= a[i] + a[i + 1] - x;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a==1)cout<<"1"<<endl;
	else if(2<=a&&a<4)cout<<"2"<<endl;
	else if(4<=a&&a<8)cout<<"4"<<endl;
	else if(8<=a&&a<16)cout<<"8"<<endl;
	else if(16<=a&&a<32)cout<<"16"<<endl;
	else if(32<=a&&a<64)cout<<"32"<<endl;
	else if(64<=a)cout<<"64"<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
x = [int(i) for i in input().split()]
mul=1
check=10**18
count=x.count(0)
if(count>=1):
    print("0")
else:
    for i in range(n):
        mul*=int(x[i])
        if(check<mul):
            break
    if(check<mul):
        print("-1")
    else:
        print(mul)

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

using namespace std;

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

    int n, sol = 0;
    cin >> n;
    vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < 2 * n; i += 2)
    {
        sol += a[i];
    }
    cout << sol << "\n";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int ans = 0;
		for (int i = 0; i < 5; i++) {
			if (sc.nextInt() - 1 != i) ans = i + 1;
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32700
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	while (cin >> n, n){
		int count = 0;
		bool floor = true;
		bool floor_l = true;
		bool floor_r = true;
		REP(i, n){
			string s;
			cin >> s;
			if (s == "lu")floor_l = false;
			if (s == "ru")floor_r = false;
			if (s == "ld")floor_l = true;
			if (s == "rd")floor_r = true;
			if (floor&&!floor_l&&!floor_r){
				count++;
				floor = false;
			}
			else if (!floor&&floor_l&&floor_r){
				count++;
				floor = true;
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
vector<int> prime;
bool isPrime[1300000];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 1300000; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < 1300000; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		if(isPrime[n])
		{
			cout << 0 << endl;
			continue;
		}
		for(int i = 0; i < prime.size() - 1; ++i)
		{
			if(prime[i] <= n && n <= prime[i + 1])
			{
				cout << prime[i + 1] - prime[i] << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>




int t, n, m;
vector<vector<int> > g;
bool v[100010];
int sg[100010];



int32_t main(){
INIT
cin>>n>>m;
g.resize(n+5);


for(int i=1; i<=m; i++){
    int a, b;
    cin>>a>>b;
    g[b].pb(a);
    g[a].pb(b);
}




queue<int> q;
q.push(1);
v[1]=true;

while(!q.empty()){
    int f=q.front(); q.pop();

    for(int i=0; i<g[f].size(); i++){
        if(!v[g[f][i] ] ){
            v[g[f][i] ]=true;
            sg[g[f][i] ]=f; q.push(g[f][i]);
        }
    }
}


cout<<"Yes\n";

for(int i=2; i<=n ;i++){
    cout<<sg[i]<<"\n";
}


return 0;
}


Measured memory_bytes: 10312
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s;
  cin >> s;
  int n = sz(s);

  bool good = true;
  rep(i,n) {
    if (i%2 == 0 && s[i] == 'L') good = false;
    if (i%2 == 1 && s[i] == 'R') good = false;
  }

  if (good) puts("Yes"); else puts("No");
}

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

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int n,m,a,i,arr[10000],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&arr[i]);
        sum += arr[i];
    }
    a = n-sum;
    if(a>=0)
        printf("%d\n",a);
    else
        printf("-1\n");


    return 0;
}


Measured memory_bytes: 1772
#include <iostream>

int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    
    // input
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    
    // output
    if( a < 0 || a > 100 || b < 0 || b > 100 || c < 0 || c > 100 )
    {
        std::cout << "Error : out of range!" << std::endl;
        return -1;
    }
    
    if( a < b && b < c )
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i = 0; i < n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};

int main(){
    ll N, K; cin >> N >> K;
    init();
    ll ans = 0;
    for (int i = 0; i < min(N, K+1); i++){
        ll cur = COM(N, i) * COM(N-1, i) % MOD;
        ans += cur;
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
const int maxV = 1e5 + 2;
const int maxN = 102;
int w[maxN], v[maxN];
long long dp[maxN][maxV];

int main() {
	int n, W;
	cin >> n >> W;
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}
	const int maxV = 1e5;
	for (int i = 0; i < n; ++i) {
		dp[i][0] = 0;
	}
	for (int i = 1; i <= maxV; ++i) {
		dp[0][i] = W + 1;
	}
	dp[0][v[0]] = w[0];
	for (int i = 1; i < n; ++i) {
		for (int j = maxV; j > 0; --j) {
			dp[i][j] = dp[i-1][j];
			if (j >= v[i]) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
		}
	}
	int res = 0;
	for (int i = 1; i <= maxV; ++i) {
		if (dp[n-1][i] <= W) res = i;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 81676
#include<stdio.h>
#include<string.h>
int main()
{   int i;
    char str1[3],str[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    scanf("%s",str1);
    for(i=0;i<7;i++)
    {
        if(strcmp(str1,str[i])==0)
        break;
    }
    
    printf("%d",7-i);
    return 0;
}

Measured memory_bytes: 128
def bb
    n = gets.chomp.to_i
    v = gets.chomp.split(/\s/).map{|x| x.to_i}
    c = gets.chomp.split(/\s/).map{|x| x.to_i}

    cost = 0
    for i in 1..n
        j = i - 1
        cost += v[j]-c[j] if v[j] > c[j]
    end

    puts cost
end

bb

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

int n;
int num[26][5];
int bl[26];
int fst;

int front(int a){
	if(a==-1) return 0;
	cout<<" "<<a;
	front(num[a][2]);
	front(num[a][3]);
}

int md(int a){
	if(num[a][2]!=-1) md(num[a][2]);
	cout<<" "<<a;
	if(num[a][3]!=-1) md(num[a][3]);
}

int la(int a){
	if(num[a][2]!=-1) la(num[a][2]);
	if(num[a][3]!=-1) la(num[a][3]);
	cout<<" "<<a;
}

int main(){
	cin>>n;
	int k;
	for(int i=0;i<=n-1;i++){
		cin>>k;
		cin>>num[k][2]>>num[k][3];
	}
	for(int i=0;i<=n-1;i++){
		if(num[i][2]!=-1) bl[num[i][2]]=1;
		if(num[i][3]!=-1) bl[num[i][3]]=1;
	}
	for(int i=0;i<=n-1;i++){
		if(bl[i]==0) {
			fst=i;
			break;
		}
	}
	cout<<"Preorder"<<endl;
	front(fst);
	cout<<endl;
	cout<<"Inorder"<<endl;
	md(fst);
	cout<<endl;
	cout<<"Postorder"<<endl;
	la(fst);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <string>
#define fflush(stdout) flush
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


#define N 100005
class uf {
private:
    int par[N] = {}, r[N] = {}, size[N] = {};

public:
    uf(int n) {
        int i;
        for (i = 0; i < n; i++) {
            par[i] = i;
            size[i] = 1;
        }
    }

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

    void unite(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (r[a] > r[b]) {
            par[b] = a;
            r[a]++;
            size[a] += size[b];
        }
        else {
            par[a] = b;
            r[b]++;
            size[b] += size[a];
        }
    }

    int show_size(int a) {
        return size[root(a)];
    }

    int group(int n) {
        int i, t, res = 0;
        bool u[N] = { false };
        for (i = 0; i < n; i++) {
            t = root(i);
            if (!u[t]) {
                res++;
                u[t] = true;
            }
        }
        return res;
    }

};

int main(void) {
    int n, m, i, j, ans;
    P e[53];

    scanf("%d%d", &n, &m);
    for (i = 0; i < m; i++) {
        scanf("%d%d", &e[i].first, &e[i].second);
    }

    ans = 0;
    for (i = 0; i < m; i++) {
        uf g(n);

        for (j = 0; j < m; j++) {
            if (i != j) {
                g.unite(e[j].first, e[j].second);
            }
        }

        if (g.group(n) > 1) {
            ans++;
        }

    }

    printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q;
  int s[1000000];
  int tp[1000000];
  cin>>n>>q;
  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
    tp[i]=s[i];
  }
  map<int,int> mp;
  sort(s,s+n);
  for(int i=0;i<n;i++)mp[s[i]]=i;
  vector<int> ld;
  while(q--){
    string str;
    int a;
    cin>>str>>a;
   
    if(str[0]=='A'){
      a--,ld.push_back(mp[tp[a]]);
      sort(ld.begin(),ld.end());
    }
     
    if(str[0]=='R'){
      a--;
      int b=mp[tp[a]];
      for(int i=0;i<ld.size();i++){
    if(b==ld[i]){
      ld.erase(ld.begin()+i);
      break;
    }
      }
    }
 
    if(str[0]=='C'){
      int l=0,r=1e9+10,m; 
 
      while(l<r){
    m=(l+r)/2;
 
    int pr=1e9,res=0;
 
    for(int i=ld.size()-1;i>=0;i--){
      int nld=ld[i];
      if(pr<nld)nld=pr;
      pr=lower_bound(s,s+n,s[ld[i]]-m)-s;
      pr--;
      if(nld>pr)res+=(nld-pr);
    }
    if(n-res<=a)r=m;
    else l=m+1;
      }
 
       
      if(r==1e9+10)cout<<"NA"<<endl;
      else cout<<r<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 57892
#include <stdio.h>

int main(void){

    int a, b;
    int i;

    scanf("%d", &a);
    scanf("%d", &b);

    for(i = 1; (i * 8 / 100) <= a; i++){
        if(((i * 8 / 100) == a) && ((i / 10) == b)){
            printf("%d", i);
            return (0);
        }
    }
    printf("-1");
}

Measured memory_bytes: 128
#include<iostream>

struct Card  {char suit, value; };

void bubble(struct Card A[], int N)  {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i; j--) {
			if (A[j].value < A[j-1].value) {
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			std::cout << " ";
		}
		std::cout << A[i].suit << A[i].value;
	}
	std::cout << std::endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if(C1[i].suit != C2[i].suit) {
			return false;
		}
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; i++) {
		C2[i] = C1[i];
	}

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	std::cout << "Stable" << std::endl;
	print(C2, N);
	if (isStable(C1, C2, N)) {
		std::cout << "Stable" << std::endl;
	} else {
		std::cout << "Not stable" << std::endl;
	}

	return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define maxn 108
int h,w;
char map1[maxn][maxn];
int vis[maxn][maxn];
int if_ok[maxn];
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>map1[i][j];
	for(int i=1;i<=h;i++){
		bool flag1=true;
		for(int j=1;j<=w;j++){
			if(map1[i][j]=='#'){
				flag1=false;
				break;
			}
		}
		if(flag1){
			for(int j=1;j<=w;j++){
				vis[i][j]=1;
			}
			if_ok[i]=1;
		}
	}
	for(int i=1;i<=w;i++){
		bool flag1=true;
		for(int j=1;j<=h;j++){
			if(map1[j][i]=='#'){
				flag1=false;
				break;
			}
		}
		if(flag1){
			for(int j=1;j<=h;j++){
				vis[j][i]=1;
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(!vis[i][j]){
				cout<<map1[i][j];
			}
		}
		if(!if_ok[i])
			cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
x=int(input())
if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
elif 1800<=x<=1999:
    print(1)

Measured memory_bytes: 61620
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	int k = 0, ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		if (i) {
			if (H[i-1] >= H[i]) {
				k++;
				ans = max(ans, k);
			}
			else {
				k = 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
string s;
cin>>s;
ll ans=1;
bool flag=false;
for(ll i=1;i<s.size();i++)
{
    if(s[i]==s[i-1]&&flag==false)
    {
        flag=true;
        if(i+1!=s.size())
        {
        ans++;
        }
        i++;
    }else
    {
        flag=false;
        ans++;
    }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,c) for (int i=0;i<c;i++)
using namespace std;
typedef long long ll;
 
 
int main(){
    ll X;
    ll f = 100;
    ll ans = 0;

    cin >> X;
    rep(i,100000000){
        f = f*(1.01);
        ans++;
        if(f >= X) break;
        
    }
    cout << ans << endl;


}

Measured memory_bytes: 3636
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

const INF: i32 = 1001001001;
const LNF: i64 = 1001001001001001001;
const MOD: i32 = 1000000007;

#[fastout]
fn main() {
  input! {
    n: usize,
    k: i64,
    a: [i64; n],
  }
  let k = k + n as i64;
  let mut ok: i64 = LNF;
  let mut ng: i64 = 0;
  while (ok - ng).abs() != 1 {
    let x = (ok + ng) >> 1;
    let mut cnt = 0;
    for i in 0..n {
      cnt += (a[i] + x - 1) / x;
    }
    if cnt <= k {
      ok = x;
    } else {
      ng = x;
    }
  }
  println!("{}", ok);
}


Measured memory_bytes: 5388
#include<iostream> 
 #include<iomanip>
 #include<algorithm>
 #include<cmath>
 #include<string>
 #include<cstring>
 using namespace std;
 long long i,n,b,ans,o;
 int main()
{
    cin>>n;
    for(i=sqrt(n);i>=1;i--)
    {
    	if(n%i==0)
    	{
			b=n/i;
    		break;
		}
	}    
	while(ans==0)
	{
		if(b/10!=0)
		{
		    b=b/10;
			o++;	
		}
		else
		{
			ans=o+1;
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

struct edge { ll to, cost; };//行き先,距離
// firstは最短距離、secondは頂点の番号
ll V;//頂点数
vector<edge> G[1000000LL]; ll d[1000000LL];//G=隣接リスト(vectorの配列),d=sからの距離
void dijkstra(ll s) {
	// greater<P>を指定することでfirstが小さい順に取り出せるようにする 
	priority_queue<P, vector<P>, greater<P>> que; 
	fill(d, d + V + 1, LINF);
	d[s] = 0LL;
	que.push(P(0LL, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		for (ll i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to)); 
			}
		}	 	
	}
}

int main(){
	ll e,r;cin>>V>>e>>r;
	for(int i = 0; i < e; i++) {
		ll s,t,d;cin>>s>>t>>d;
		edge e = {t,d};
		G[s].pb(e);
	}
	dijkstra(r);
	for(int i = 0; i < V; i++) {
		if (d[i] != LINF){
			cout << d[i] << endl;	
		}
		else{
			cout << "INF" << endl;
		}
	}
	return 0;
}


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

int main(){
int a[1000000],b[1000000],c;
for(int i=1;i<1000000;i++){
cin>>a[i]>>b[i];
c++;
if(a[i]==0 && b[i]==0){
goto aa;
}
}
aa:;
for(int i=1;i<c;i++){
for(int j=0;j<a[i];j++){
for(int k=0;k<b[i];k++){
cout<<"#";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}

Measured memory_bytes: 3204
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN=100005;
int n;
vector<int>w[MAXN];
queue<int>Q;
int rd[MAXN];
bool vis[MAXN];
int main()
{
	//freopen("blackwhite.in","r",stdin);
	//freopen("blackwhite.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		w[u].push_back(v);
		w[v].push_back(u);
		rd[u]++;
		rd[v]++;
	}
	for(int i=1;i<=n;i++)
		if(rd[i]==1)
			Q.push(i);
	while(!Q.empty())
	{
		int k=Q.front();
		Q.pop();
		if(rd[k]!=1||vis[k])
			continue;
		int u=0;
		for(int i=0;i<int(w[k].size());i++)
		{
			int v=w[k][i];
			if(!vis[v])
			{
				u=v;
				break;
			}
		}
		vis[k]=vis[u]=1;
		for(int i=0;i<int(w[u].size());i++)
		{
			int v=w[u][i];
			rd[v]--;
			if(rd[v]==1)
			{
				Q.push(v);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			printf("First\n");
			return 0;
		}
	}
	printf("Second\n");
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
#define MAX_HEAP 1500000
#define NEG_INF -100000
 
int heap_size = 1;
int parent(int);
int left(int);
int right(int);
 
void maxHeapfy(int *, int);
void maxHeapInsert(int *, int);
void heapIncreaseKey(int *, int, int);
int heapExtractMax(int *);
 
int main(void) {
  int key;
  int ary[MAX_HEAP];
  char order[10];
 
  while (1) {
    scanf("%s %d", order, &key);
    if (order[0] == 'i') {
      maxHeapInsert(ary, key);
    } else if (order[1] == 'x') {
      int max = heapExtractMax(ary);
      printf("%d\n", max);
    } else {
      break;
    }
  }
     
  return 0;
}
 
int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i + 1;
}
 
void maxHeapify(int *A, int i) {
  int l = left(i);
  int r = right(i);
  int largest;
 
  if (l <= heap_size && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= heap_size && A[r] > A[largest]) {
    largest = r;
  }
 
  if (largest != i) {
    /* A[i]とA[largest]の値を交換 */
    int tmp = A[largest];
    A[largest] = A[i];
    A[i] = tmp;
 
    maxHeapify(A, largest);
  }
}
 
void maxHeapInsert(int *A, int key) {
  heap_size++;
  A[heap_size] = NEG_INF;
  heapIncreaseKey(A, heap_size, key);
}
 
void heapIncreaseKey(int *A, int i, int key) {
  if (key < A[i]) {             /* 新しいキーは現在のキーより小さい */
    return;
  }
 
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    /* 親と子を入れ替える */
    int tmp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = tmp;
    i = parent(i);
  }
}
 
int heapExtractMax(int *A) {
  if (heap_size < 1) {          /* ヒープアンダーフロー */
    return -1;
  }
 
  int max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHeapify(A, 1);
  return max;
}

Measured memory_bytes: 5488
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;

int main(){
	string s;
	int ans = 700;
	cin >> s;
	for (int i = 0; i < 3;i++) {
		if (s[i] == 'o') {
			ans += 100;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i,c=0,d;
    cin>>a;

    for(i=1;i<=9;i++)
    {
        if(a%i==0)
        {
            d=a/i;
            {
                if(d>0 && d<10)
                    c++;
            }
        }
    }
    if(c>=1)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

using namespace std;

string lcs(string& s,string& t){
    vector<vector<int>> dp(s.length()+1,vector<int>(t.length()+1,0));
    for(int i=1;i<=s.length();i++){
        for(int j=1;j<=t.length();j++){
            if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string res="";
    int i=s.length(),j=t.length();
    while(i>0 && j>0){
      if(dp[i][j]==dp[i-1][j]) i--;
      else if(dp[i][j]==dp[i][j-1]) j--;
      else {
        res=s[i-1]+res;
        i--; j--;
      }
    }
    return res;                          
}

int main(){
    ios_base::sync_with_stdio(false) ;
 	cin.tie(NULL) ;
   	cout.tie(NULL) ;
  string s,t;
  cin>>s>>t;
  cout<<lcs(s,t);
}


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

using namespace std;

using d_t = std::vector<int64_t>;

d_t subsolve(int k, const std::vector<int64_t>& as,
             const std::vector<int64_t>& bs) {
  int const x = as.size();
  int const y = bs.size();
  d_t rets(x * y);
  int i = 0;
  for (auto const a : as) {
    for (auto const b : bs) {
      rets[i++] = a + b;
    }
  }
  std::sort(rets.rbegin(), rets.rend());
  rets.resize(k);
  return rets;
}

d_t solve(int x, int y, int z, int k, const d_t& as, const d_t& bs,
          const d_t& cs) {
  auto abs = subsolve(std::min(k, x * y), as, bs);
  auto rets = subsolve(k, abs, cs);
  return rets;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int x, y, z, k;
  std::cin >> x >> y >> z >> k;
  d_t as(x);
  d_t bs(y);
  d_t cs(z);
  for (int i = 0; i < x; ++i) {
    std::cin >> as[i];
  }
  for (int i = 0; i < y; ++i) {
    std::cin >> bs[i];
  }
  for (int i = 0; i < z; ++i) {
    std::cin >> cs[i];
  }
  auto rets = solve(x, y, z, k, as, bs, cs);
  for (auto const r : rets) {
    std::cout << r << std::endl;
  }
  return 0;
}

Measured memory_bytes: 31488
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int s,ans;
  int maxm = pow(10,6);
  int a[maxm];
  bool ok = false;
  cin >> s;
  for(int i=0;i<maxm;i++){
    if(i==0){
      a[i] = s;
    }
    else{
      if(a[i-1]%2==0){
        a[i] = a[i-1]/2;
      }
      else{
        a[i] = 3*a[i-1]+1;
      }
      for(int j=0;j<i;j++){
        if(a[j] == a[i]){
          ok = true;
          ans = i;
          break;
        }
      }
      if(ok){
        break;
      }
    }
    if(ok){
      break;
    }
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=2000;
int n,k;
int f[maxn+8][maxn+8],g[maxn+8][maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k)
{
    if (k<0) return 1;
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
	if (k&1)
	    sum=1ll*sum*a%mod;
    return sum;
}

int main()
{
    n=read(),k=read();
    for (int i=1;i<=n;i++) g[0][i]=1;
    for (int i=1;i<k;i++)
	for (int j=i+1;j<=n;j++)
	        g[i][j]=(g[i-1][j]+g[i][j-1])%mod;
    printf("%lld\n",1ll*g[k-1][n]*power(2,n-k-1)%mod);
    return 0;
}


Measured memory_bytes: 16640
n = gets.chomp.to_i
rod = gets.chomp.split(" ").map(&:to_i).sort
ans = 0
n.times do |a|
    (a+1).upto(n-1) do |b|
        tmp = rod[a] + rod[b]
        c = rod.bsearch_index{|x| x >= tmp} || n
        ans += c-b-1 if b-a < c
    end
end

puts ans

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

int gcd(int a,int b) {
    if (b==0) {
        return a;
    }
    return gcd(b,a%b);
}
int main() {
    int N,X;
    cin>>N>>X;
    int x[N+1];
    int dis[N];
    for (int i=0; i<N; i++) {
        dis[i]=0;
    }
    for (int i=0; i<N; i++) {
        cin>>x[i];
    }
    x[N]=X;
    sort(x,x+N+1);
    for (int i=0; i<N; i++) {
        dis[i]=x[i+1]-x[i];
    }
    int D=dis[0];
    for (int i=1; i<N; i++) {
        D=gcd(D,dis[i]);
    }
    cout<<D<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24;
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int a[5];
	int k;
	int b;
	for(b=0;b<5;b++){
		scanf("%d",&a[b]);
	}
	scanf("%d",&k);
	int c;
	int count=0;
	for(b=0;b<5;b++){
		for(c=0;c<5;c++){
			if((abs(a[b]-a[c]))>k){
				count++;
			}
		}
	}
	if(count==0){
		printf("Yay!");
	}else{
		printf(":(");
	}
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b+c>=a)
    ou(c-(a-b));
  else if(b+c<a)
    ou(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int a[n + 2];
    a[0] = 0;
    a[n + 1] = 0;
    repd(i, 1, n + 1) { cin >> a[i]; }

    int b[n + 1];
    rep(i, n + 1) { b[i] = abs(a[i] - a[i + 1]); }

    int c[n];
    rep(i, n) { c[i] = abs(a[i] - a[i + 2]); }

    ll sum = 0;
    rep(i, n + 1) { sum += b[i]; }

    repd(i, 1, n + 1) {
        ll ans = sum - b[i - 1] - b[i];
        ans += c[i - 1];
        cout << ans << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
const int maxn = 1e6+55;
#define LL long long
string s;
int k;
int num=0;
void dfs(string ss)
{
	for(char i='a';i<='z';i++){
		string sss=ss+i;
		if(num==k){
			return;
		}
		if(s.find(sss)==string::npos){

		}
		else{
			num++;
			if(num==k){
				cout<<sss<<endl;
				return;
			}
			dfs(sss);
		}
	}
}

int main()
{
	cin>>s;
	cin>>k;
	string ss="";
	dfs(ss);

	return 0;
}


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

int main(){
    int N;
    string S;
    char A[10000];

    cin >> N;
    cin >> S;

    int size = S.size();
    for(int i=1; i<N; i++){
        if(S[i]==S[i-1]){
            size--;
        }
    }

    cout << size << endl;
    return 0;
}

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

int main() {
	int N,c=0;
	ll m=INF,s=0;
	cin >> N;
	vector<ll> A(N);
	rep(i,N) {
		cin >> A.at(i);
		if(A.at(i) < 0)
			++c;
		s += abs(A.at(i));
		m = min(m, abs(A.at(i)));
	}

	cout << s-((c%2)?m*2:0) <<endl;
}

Measured memory_bytes: 1024