akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int k;
  cin >> k;

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

  return 0;
}


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

int main() 
{
	int H;
	cin >> H;
	int tree[250];
	
	for (int i = 1; i <= H; i++) 
	{
		int key;
		cin >> key;
		tree[i] = key;
	}
	for (int i = 1; i <= H; i++) 
	{
		cout << "node " << i << ": key = " << tree[i] << ", ";
		if (i / 2 > 0) cout << "parent key = " << tree[i / 2] << ", ";
		if (i * 2 <= H) cout << "left key = " << tree[i * 2] << ", ";
		if (i * 2 + 1 <= H) cout << "right key = " << tree[i * 2 + 1] << ", ";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	string s;
	cin >> s;
	Int len = s.size();
	s.push_back('R');//右端の処理用

	vector<Int> ans(len, 0);

	Int flag = 0;
	Int count = 0;

	for (Int i = 0; i < len; i++) {
		if (flag == 0 && s[i + 1] == 'R') {
			count++;
			continue;
		}
		if (flag == 0 && s[i + 1] == 'L') {
			count++;
			flag = 1;
			ans[i] += (count + 1) / 2;
			ans[i + 1] += count / 2;
			count = 0;
			continue;
		}
		if (flag == 1 && s[i + 1] == 'L') {
			count++;
			continue;
		}
		if (flag == 1 && s[i + 1] == 'R') {
			count++;
			flag = 0;
			ans[i - count] += count / 2;
			ans[i - count + 1] += (count + 1) / 2;
			count = 0;
			//continue;
		}
	}

	for (Int i = 0; i < len; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

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

int output1(long a, long b, long k) {
    for (int i = a; i < a + k; i++) {
        cout << i << endl;
    }
    for (int i = b - k + 1; i <= b; i++) {
        cout << i << endl;
    }
    return 0;
}

int output2(long a, long b) {
    for (int i = a; i <= b; i++) {
        cout << i << endl;
    }
    return 0;
}


int main() {
    long a, b, k;
    cin >> a >> b >> k;
    
    if ((b - a + 1) > (k * 2)) {
        output1(a,b,k);
    } else {
        output2(a,b);
    }
    
}


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

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin>>str;
    int o=0,I=0;
    int sum=0;
    for(int i=0;i<str.length();i++)
    {
        if(str[i]=='0')
        {
            if(I==0){
                    o++;
            }
            else{
                I--;
                sum+=2;
            }
        }
        else
        {
            if(o==0){
                    I++;
            }
            else{
                o--;
                sum+=2;
            }
        }
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 512
# ABC70, B - two switches
a, b, c, d = [int(el) for el in input().split(' ')]
A = set([i for i in range(a, b+1)])
B = set([j for j in range(c, d+1)])
common = A.intersection(B)
if common:
    print(max(common) - min(common))
else:
    print(0)


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll res = 0;
    rep(i, n) {
        if (a[i] <= b[i]) {
            res += a[i];
            b[i] -= a[i];
        }
        else {
            a[i] -= b[i];
            res += b[i];
            b[i] = 0;
        }

        if (a[i+1] <= b[i]) {
            res += a[i+1];
            a[i+1] = 0;
        }
        else {
            res += b[i];
            a[i+1] -= b[i];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
var dp = Array(100001) { -1L }
val g = mutableMapOf<Int, MutableList<Int>>()

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    for (i in 1..m) {
        val (x, y) = readLine()!!.split(' ').map(String::toInt)
        if (g.containsKey(x)) g[x]!!.add(y) else g[x] = mutableListOf(y)
    }
    var temp = 0L
    g.keys.forEach { temp = Math.max(temp, rec(it)) }
    println(dp.max())

}

fun rec(cur: Int): Long {
    if (dp[cur] != -1L) return dp[cur]
    var temp = 0L
    g[cur]?.forEach {
        temp = Math.max(temp, rec(it) + 1)
    }
    dp[cur] = temp
    return temp
}

Measured memory_bytes: 81560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		int r = Integer.parseInt(spl[0]);
		int D =Integer.parseInt(spl[1]);
		int x2000 = Integer.parseInt(spl[2]);
		sc.close();
      
		int[] X = new int[10];
		int x = x2000;
		for(int i = 0;i < X.length;i++){
			X[i] = r * x - D;
			System.out.println(X[i]);
			x = X[i];
		}
	}
}

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

// c >= b-a+1
// c > a-b
// c < a+b
// c >= b >= a
int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; ++i) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  for(int i = 0; i < N; ++i){
    int l = i, r = i;
    for(int j = i+1; j < N-1; ++j){
      while(l <= j) ++l;
      while(r <= j) ++r;
      int a = L[i], b = L[j];
      int mi = max(b,b-a+1), ma = a+b;
      while(L[l] < mi) ++l;
      while(r < N and L[r] < ma) ++r;
      // int t = lower_bound(L.begin(), L.end(), ma) - lower_bound(L.begin(), L.end(), mi);
      int t = r-l;
      // cerr << a << " " << b << " " << l << " " << r << endl;
      ans += t;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,s;
    cin>>k>>s;
    int c=0;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            int p = s -(i+j);
            if(p>=0&&p<=k)
                c++;
        }
    }
    cout<<c<<endl;
}


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

 int main()
 {
  int n,b[100],i,j,k,ans;
   b[0]=1000000;
   ans=0;
   cin>>n;
   for(i=1;i<n;i++){cin>>b[i];}
   //for(i=0;i<n;i++){cout<<b[i]<<endl;}
   for(i=0;i<n-1;i++){ans+=min(b[i],b[i+1]);}
   ans+=b[n-1];
   cout<<ans<<endl;
 }

Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

ll A, B, C, D;

ll number_of_multipliers(ll c, ll N)
{
    if(N == 0) return 0;
    auto ret = N / c;
    
    return ret;
}

ll query(ll start, ll end, ll c)
{
    return number_of_multipliers(c, end) - number_of_multipliers(c, start - 1);
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> A >> B >> C >> D;
    ll ggcd = gcd(C, D);
//    C /= ggcd; D /= ggcd;
    
    
    ll ret = B - A + 1;
    ret -= query(A, B, C);
    ret -= query(A, B, D);
    ret += query(A, B, C * D / ggcd);
    
    cout << ret << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> N;
    vi h(N);
    cin >> h;
    ll tmp = 0;
    REP(i, N) {
        if (i == 0)
            continue;
        if (h[i] <= h[i - 1]) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    cout << ans << endl;
}

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

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A>B){
		if(A>C){
			cout << A*10+B+C << endl;
		}else{
			cout << C*10+A+B << endl;
		}
	}else{
		if(B>C){
			cout << B*10+A+C << endl;
		}else{
			cout << C*10+A+B << endl;
		}
	}
}

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

vector<pair<ll,int>> func(ll n){
    vector<pair<ll,int>> v;
    for(ll i=2;i*i<=n;i++){
        if(n%i) continue;
        v.emplace_back(i,0);
        while(n%i==0){
            n/=i;
            v.back().second++;
        }
    }
    if(n!=1) v.emplace_back(n,1);
    return v;
}

int main(){
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    auto f=func(g);
    cout<<f.size()+1<<endl;
}

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

int main() {
	int h, w;
	cin >> h >> w;

	string c[h];
	for (int i = 0; i < h; i++) {
		cin >> c[i];
	}

	cout << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < 2; j++) {
			cout << c[i] << endl;
		}
	}
	return 0;
}

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

int main(){
	int a[10000];
	int x = 0;
	int y;
	for (int i = 0; x != 1 ;i++){
		
		cin >> a[i];
		y = i;
		if (a[i] == 0){
			x = 1;
		}
	}
	
	for (int i = 0; i != y; i++){
		cout << "Case "<< i + 1 << ": " << a[i] << endl;
	}
		
		
		return 0;
}




Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <unordered_map>
#include <map>

using namespace std;

using ll = long long;

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

	vector<double> v;

	for (int i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		v.push_back(t);
	}

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

	for (int i = 0; i < N-1; i++)
	{
		double x = v.at(0);
		double y = v.at(1);
		double temp = (x + y) / 2.0;

		v.erase(v.begin(), v.begin()+2);

		v.insert(v.begin(), temp);
	}

	cout << v.at(0) << endl;

	return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    vector<vector<int>> left(H+2, vector<int>(W+2));
    vector<vector<int>> right(H+2, vector<int>(W+2));
    vector<vector<int>> top(H+2, vector<int>(W+2));
    vector<vector<int>> bottom(H+2, vector<int>(W+2));
    for (int h = 1; h <= H; ++h) {
        int i = h - 1;
        for (int w = 1; w <= W; ++w) {
            int j = w - 1;
            if (S[i][j] == '#') {
                left[h][w] = 0;
                top[h][w] = 0;
            } else {
                left[h][w] += left[h][w-1] + 1;
                top[h][w] += top[h-1][w] + 1;
            }
        }
    }
    for (int h = H; h >= 1; --h) {
        int i = h - 1;
        for (int w = W; w >= 1; --w) {
            int j = w - 1;
            if (S[i][j] == '#') {
                right[h][w] = 0;
                bottom[h][w] = 0;
            } else {
                right[h][w] += right[h][w+1] + 1;
                bottom[h][w] += bottom[h+1][w] + 1;
            }
        }
    }

    int ans = 0;
    for (int h = 1; h <= H; ++h) {
        for (int w = 1; w <= W; ++w) {
            int tmp = left[h][w] + right[h][w] + top[h][w] + bottom[h][w] - 3;
            //cout << left[h][w] << right[h][w] << top[h][w] << bottom[h][w] << " ";
            ans = max(ans, tmp);
        }
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    int N,Q; cin >> N >> Q;
    string S; cin >> S;
    vei l(Q),r(Q);
    rep(i,Q) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    vei check(N-1, 0);

    rep(i,N){
        if(S[i-1] == 'A' and S[i] == 'C') {
            check[i] = check[i-1] + 1;
        }
        else check[i] = check[i-1];
    }
    int ans;
    rep(i,Q) {
        cout << check[r[i]] - check[l[i] ] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
n = int(input())

mins = []
maxs = []

for i in range(n):
    a, b = map(int, input().split())
    mins.append(a)
    maxs.append(b)

mins.sort()
maxs.sort()


if n % 2 == 1:
    mid = n // 2
    print(maxs[mid] - mins[mid] + 1)

else:
    mid1 = n//2
    mid2 = mid1-1
    smallest = mins[mid1] + mins[mid2]
    largest = maxs[mid1] + maxs[mid2]
    print(largest - smallest + 1)
    

Measured memory_bytes: 25408
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#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>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int N;
    int cnt[2][100010] {};

    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        int v; cin >> v;
        a[i] = v;
        cnt[i & 1][v] += 1;
    }

    if (all_of(all(a), [&](int n) { return n == a[0]; })) {
        cout << N / 2 << endl;
        return 0;
    }

    i64 sum0 = 0;
    i64 sum1 = 0;

    vector<pii> x;
    vector<pii> y;
    rep(i, 100010) {
        sum0 += cnt[0][i];
        x.emplace_back(cnt[0][i], i);

        sum1 += cnt[1][i];
        y.emplace_back(cnt[1][i], i);
    }

    sort(all(x), greater<>());
    sort(all(y), greater<>());

    if (x[0].second == y[0].second) {
        cout << min(
                (sum0 - x[0].first) + (sum1 - y[1].first),
                (sum0 - x[1].first) + (sum1 - y[0].first)) << endl;
    } else {
        cout << (sum0 - x[0].first) + (sum1 - y[0].first) << endl;
    }

    return 0;
}


Measured memory_bytes: 4716
import math
d0=0
N=int(input())
x=[list(map(int,input().split())) for i in range(N)]
for j in range(0,N-1):
    for k in range(j+1,N):
        d=math.sqrt((x[j][0]-x[k][0])**2+(x[j][1]-x[k][1])**2)
        d0=d+d0
print(d0*2/N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double N,K;
  double sum,ans,k;
  cin >> N >> K;
  for(int i=1;i<N+1;i++){
    k=1.0;
    int ii=i;
    while(ii<K){
      ii*=2;
      k/=2;
    }
    sum+=k;
  }
  ans = sum/N;
  printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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;
    if(s == "RRR") cout << 3 << endl;
    else if(s == "RRS" || s == "SRR") cout << 2 << endl;
    else if(s == "SSS") cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
using ll = long long;

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  ll R, S, P; cin >> R >> S >> P;
  string T; cin >> T;

  ll ans = 0;
  rep(i, N) {
    if (i-K >= 0 && T[i] == T[i-K])
      T[i] = 0;

    if (T[i] == 'r')
      ans += P;
    if (T[i] == 's')
      ans += R;
    if (T[i] == 'p')
      ans += S;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    x = 1999-x;
    cout << x/200+1 << endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e5 + 5;


int n, C;

int a[32][maxn];

int act[maxn];

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

    cin>>n>>C;
    for (int i=0; i<n; i++) {
	int s,t,c; cin>>s>>t>>c;
	for (int j=s; j<t; j++) {
	    a[c][j]=1;
	}
    }


    for (int i=0; i<=int(1e5); i++) {
	for (int j=1; j<32; j++) {
	    if (a[j][i] || a[j][i+1]) {
		act[i]++;
	    }
	}
    }

    int res = 0;
    for (int i=1; i<=int(1e5); i++) {
	res = max(res, act[i]);
    }

    out(res);
    
    return 0;
}


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


int main()
{
	int n,m,k,sum=0,min=99999;
	cin>>n>>k;
	for(int i=1;i<=n;i++) 
	{
		cin>>m;
		if(m<min) min=m;
		k-=m;
		sum++;
	}
	sum+=k/min;
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n;
  string s;
  char c[40][40];
  ll num[40][40];
 
  while(1){
    cin>>n;
    if(n==0)break;
 
    for(int i=0;i<40;i++){
      for(int j=0;j<40;j++){
    c[i][j]='.';
    num[i][j]=-1;
      }
    }
    for(int i=0;i<n;i++){
      cin>>s;
      for(int j=0;j<s.length();j++){
    c[i][j]=s[j];
    if('0'<=s[j] && s[j]<='9')num[i][j]=s[j]-'0';
      }
    }
      vector<int> v;
    for(int j=39;j>=1;j--){
      for(int i=n-1;i>=1;i--){
    if(num[i][j]!=-1)v.push_back(num[i][j]);
    if(c[i-1][j-1]=='+'){
      ll sum=0;
      for(int k=0;k<v.size();k++)sum+=v[k];
      num[i-1][j-1]=sum;
      v.clear();
    }
    if(c[i-1][j-1]=='*'){
      ll sum=1;
      for(int k=0;k<v.size();k++)sum*=v[k];
      num[i-1][j-1]=sum;
      v.clear();
    }
      }
    }
    cout<<num[0][0]<<endl;
  }
  return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	ll a,b,c,d;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	ll lcm = c*d/__gcd(c,d);
	ll tot = b - a + 1;
	ll tot1 = (b / c) - ((a-1) / c);
	ll tot2 = (b / d) - ((a-1) / d);
	ll tot3 = (b / lcm) - ((a-1) / lcm);
	ll totSemua = tot1 + tot2 - tot3;
	printf("%lld\n",tot - totSemua);
	return 0;
};

Measured memory_bytes: 256
N = int(input())
S = input()

score = 0
ln = 0
rn = 0

for s in S:
    if s == '(':
        score += 1
    elif s == ')':
        score -= 1

    if score < 0:
        ln += 1
        score = 0

if score > 0:
    rn = score
    score = 0

S = '('*ln + S + ')'*rn
print(S)

Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        d: usize, x: usize,
        a: [usize; n],
    }

    println!("{}", a.iter().map(|a| (d - 1) / a + 1).sum::<usize>() + x);
}


Measured memory_bytes: 2192
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br
		= new BufferedReader(new InputStreamReader(System.in));


		int n=Integer.parseInt(br.readLine());
		for(int i=0;i<n;i++){
			char[][] data={br.readLine().toCharArray(),br.readLine().toCharArray()};
			plus(data);
		}
	}

	private static int plus(char[][] data){
		int [] sum=new int[data[0].length >data[1].length ? data[0].length:data[1].length];
		if(sum.length>80){
			System.out.println("overflow");
			return 0;
		}
		for(int i=0;i<data.length;i++){
			for(int j=(data[i].length-1),k=0;j>=0;j--,k++){
				sum[k]+=data[i][j]-'0';
			}
		}

		for(int i=1;i<sum.length;i++){
			if(sum[i-1]>=10){
				sum[i]++;
				sum[i-1]%=10;
			}
		}
		if(sum.length>=80 && sum[sum.length-1]>=10){
			System.out.println("overflow");
			return 0;
		}
		for(int i=sum.length-1;i>=0;i--){
			System.out.print(sum[i]);
		}
		System.out.println();
		return 1;
	}
}

Measured memory_bytes: 9196
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  return s[0]===s[1]||s[1]===s[2]||s[2]===s[3]?"Bad":"Good";
}


Measured memory_bytes: 22076
x, n = map(int, input().split())
p = list(map(int, input().split()))


if p == []:
    print(x)
    exit()

for i in range(101):
    if (x - i) not in p or (x + i) not in p:
        if x - i in p:
            print(x + i)
            exit()
        print(x - i)
        exit()


Measured memory_bytes: 9180
#include<iostream>

using namespace std;

int calc_ketasuu(int n);
bool check(int n);
int kirai[10];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0;i < 10;i++) {
		kirai[i] = 0;
	}
	for (int i = 0;i < k;i++) {
		int t;
		cin >> t;
		kirai[t] = 1;
	}
	while (1) {
		if (check(n))break;
		n++;
	}
	cout << n << endl;

}

int calc_ketasuu(int n) {
	int ans = 0;
	while (n > 0) {
		ans++;
		n /= 10;
	}
	return ans;
}

bool check(int n) {
	while (n > 0) {
		if (kirai[n % 10])return false;
		n /= 10;
	}
	return true;
}

Measured memory_bytes: 3172
##templete
n = gets.chomp.to_i
h = gets.chomp.split(" ").map { |e| e.to_i }

ans = 1

for i in 1..n-1 do
  ans += 1
    for j in 0..i-1 do
      if h[j] > h[i]
        ans -= 1
        break
      end
    end
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <unordered_map>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int m, n;
pair<int, int> s[200], p[1000], d, r;
unordered_map<long, bool> mp;

long hs(pair<int, int> z) {
  return (long) z.first * 1000001 + z.second;
}

bool at(pair<int, int> z) {
  return 0 <= z.first && z.first <= 1000000 && 0 <= z.second && z.second <= 1000000;
}

int main(void) {
  while(cin >> m, m != 0) {
    mp.clear();
    REP(i, 0, m) {
      cin >> s[i].first >> s[i].second;
    }
    cin >> n;
    REP(i, 0, n) {
      cin >> p[i].first >> p[i].second;
      mp[hs(p[i])] = true;
    }

    REP(i, 0, n) {
      d = pair<int, int>(p[i].first - s[0].first, p[i].second - s[0].second);

      REP(j, 1, m) {
        r = pair<int, int>(s[j].first + d.first, s[j].second + d.second);
        if(!(at(r) && mp[hs(r)])) goto CONT;
      }

      cout << d.first << " " << d.second << endl;
      goto NEXT;

CONT:;
    }

NEXT:;
  }

  return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << (N - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

unsigned long long gcd( unsigned long long a, unsigned long long b ) {

	unsigned long long r = 1;

	while ( r != 0 ) {

		r = a % b;
		a = b;
		b = r;

	}

	return a;

}

int main( void ) {

	unsigned long long a, b;

	while ( scanf( "%llu %llu", &a, &b ) != EOF ) {
 
        printf( "%llu %llu\n", gcd( a, b ), a * b / gcd( a, b) );

	}

	return 0;

}

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

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

  while(1){
    c -=b;
    if(c<=0)
      break;
    a-=d;
    if(a<=0)
      break;
  }

  if(a<=0)
    cout<<"No"<<endl;
  else if(c<=0)
    cout<<"Yes"<<endl;


  return 0;
}


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

#define REP(i, n) for(int i=0; i<n; i++)
#define REPA(i, a, n) for(int i=a; i<n; i++)
#define REPE(i, a, n) for(int i=a; i<=n; i++)
#define SetArray(a, n) for(int array_i=0; array_i<n; array_i++) cin >> a[array_i]
#define print(x) cout << x
#define printw(x) cout << x << " "
#define println(x) cout << x << endl
#define printl() cout << endl
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
typedef long long ll;
typedef unsigned int uint;
typedef vector<int> vi;

int length(char* str){
    int i = 0;
    while(*(str+i) != '\0'){
        i++;
    }
    return i;
}

int main(){
    char s[11] = {'\0'}, t[12] = {'\0'};
    cin >> s >> t;
    t[length(s)] = '\0';
    if(strcmp(s, t) == 0)
        println("Yes");
    else
        println("No");

    return 0;
}




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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(1e6+5);

void pre() {

}

int f(int x,int y,int z) {
  return (x*x + y*y + z*z + x*y + y*z + z*x);
}

void solve() {
  int n;  cin>>n;
  vector<int> ans(n+1,0);
  for(int x = 1; f(x,x,x) <= n; x++) {
    for(int y = x; f(x,y,y) <= n ; y++) {
      for(int z = y; f(x,y,z) <= n; z++) {
        int c;
        if(x == y and y == z) c = 1;
        else if(x == y or y == z or z == x) c = 3;
        else  c = 6;
        ans[f(x,y,z)] += c;
      }
    }
  }
  repi(i,1,n) cout<<ans[i]<<'\n';
}

int main() {
  ios::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 t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
//    cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3668
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;
 
int main() {
        string l;
        while((l = readln(), l.length)){
                l = l.split("\n")[0];
                int s = to!int(l);
                int a, b, c, d;
                int cnt = 0;
                for(a = 0; a <= 9; a++) for(b = 0; b <= 9; b++) for(c = 0; c <= 9; c++) for(d = 0; d <= 9; d++){
                        if(a + b + c + d == s) cnt += 1;
                        }
                printf("%d\n", cnt);
                }
        return 0;
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,c=0;
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++) cin>>b[i];
    for(int i=1;i<a-1;i++){
        if(b[i-1]<b[i]&&b[i]<b[i+1]) c++;
        if(b[i-1]>b[i]&&b[i]>b[i+1]) c++;
    }
    cout<<c;
}


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

using namespace std;

const int N = (int) 1e5;
int n,k;
long long a[N+5],ans=(long long)2e15;
int main()
{

    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
     for(int i=1;i+k-1<=n;i++)
    {  
        int l=i,r=i+k-1;
        ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


int main() {
   string a,b;
   cin >> a >> b;


   int A = stoi(a);
   int B = stoi(b);

   string str_a = "";
   string str_b = "";

    for (int i = 0; i < B; ++i) {
        str_a += a;
    }
    for (int i = 0; i < A; ++i) {
        str_b += b;
    }

    if(str_a < str_b) print(str_a);
    else print(str_b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

int main()
{
    s64 n;
    cin >> n;
    vector<s64> a(n);
    for(s64 i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    s64 sum = 0;
    s64 jSum = 0;
    s64 div = pow(10, 9) + 7;
    for(s64 i = n - 2; i >= 0; i--)
    {
        s64 j = i + 1;
        jSum = a[j] + jSum;
        jSum %= div;
        sum += a[i] * jSum;
        sum %= div;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int A,B;
  cin>>A>>B;
  uint64_t C=(A-1)*(A%4%2)+1-1*(A%4/2),D=B*((B+1)%4%2)+1-1*((B+1)%4/2);
  cout<<(C^D)<<endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000


int min(int a, int b){
  if(a>=b){
    return b;
  }
  else{
    return a;
  }
}


void merge_sort(long *t1, int left, int right){    //アドレスが渡される
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        merge_sort(t1,left,left+n2-1);
        merge_sort(t1,left+n2,right);

        long t2[n2];
        long t3[n3];
        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
        }

        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]>t3[k])){
                t1[left+i]=t2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                k++;
            }
        }
    }
}


int main(){
  char buf[20000];
  int X,Y,Z,K;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d %d %d", &X, &Y, &Z, &K);

  long *A=(long *)malloc(sizeof(long)*X);
  rep(i,X){
    scanf("%ld",&A[i]);
  }
  long *B=(long *)malloc(sizeof(long)*Y);
  rep(i,Y){
    scanf("%ld",&B[i]);
  }
  long *C=(long *)malloc(sizeof(long)*Z);
  rep(i,Z){
    scanf("%ld",&C[i]);
  }

  long *array=(long *)malloc(sizeof(long)*X*Y);
  rep(i,X){
    rep(j,Y){
      array[Y*i+j]=A[i]+B[j];
    }
  }

  merge_sort(array, 0, X*Y-1);

  int L=min(K,X*Y);
  long *array2=(long *)malloc(sizeof(long)*L*Z);
  rep(i,L){
    rep(j,Z){
      array2[Z*i+j]=array[i]+C[j];
    }
  }

  merge_sort(array2, 0, L*Z-1);

  rep(i,K){
    printf("%ld\n", array2[i]);
  }

  return 0;

}


Measured memory_bytes: 55040
from bisect import bisect_left, bisect_right
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        ab = L[i]+L[j]
        r = bisect_left(L,ab)
        ans += r-(j+1)
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int ans=0;
  if(a<=b){
    ans+=a;
  }else{
    ans+=b;
  }
  if(c<=d){
    ans+=c;
  }else{
    ans+=d;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
from sys import stdin 

n = int(input())
p = [int(x) for x in stdin.readline().rstrip().split()]
c= 0
q = sorted(p)

for i in range(n):
	if p[i] != q[i]:
		c += 1

if c>2:
	print("NO")

else:
	print("YES")

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

int nwin(char s){
    if(s == 'r')    return 2;
    else if(s == 's')    return 0;
    else    return 1;
}

int main(){
    int n;  cin >> n;
    int k;  cin >> k;
    vector<int>a(3);
    rep(i, 3)   cin >> a[i];
    string t;   cin >> t;
    //modKで分割
    vector<string>mod(k);
    rep(i, n){
        mod[i%k] += t[i];
    }
    //DP
    int ans = 0;
    vector<pair<int, int> >dp(n+1);
    rep(i, k){
        rep(j, mod[i].size()){
            if(!j){ //1回目
                dp[j].first     = a[nwin(mod[i][j])];
                dp[j].second    = nwin(mod[i][j]);
            }else{
                if(nwin(mod[i][j]) != dp[j-1].second){
                    dp[j].first  = dp[j-1].first + a[nwin(mod[i][j])];
                    dp[j].second = nwin(mod[i][j]);
                }else{
                    dp[j].first = dp[j-1].first;
                    dp[j].second = -1;
                }
            }
        }
        ans += dp[mod[i].size()-1].first;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;
ll n, k, a[50][50], b[50][50];

void mul(ll x[50][50], ll y[50][50]) {
	ll pdt[50][50];
	memset(pdt, 0, sizeof(pdt));
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			for (int k=0; k<n; k++) {
				pdt[i][j] += x[i][k]*y[k][j];
				pdt[i][j] %= M;
			}
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			x[i][j] = pdt[i][j];
}

void pow(ll m[50][50], ll n) {
	if (n>1) { 
		if (n==2)
			mul(m, m);
		else {
			pow(m, n/2);
			mul(m, m);
			if (n%2) 
				mul(m, a);
		}
	}
}

int main() {
	cin >> n >> k;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++) {
			cin >> a[i][j];
			b[i][j] = a[i][j];
		}
	pow(b, k);
	ll cnt = 0;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			cnt += b[i][j];
			cnt %= M;
		}
	}
	cout << cnt << "\n";
} 

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t sum = 0;
    std::vector<int64_t> S;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        S.push_back(t);
        sum += t;
    }

    std::sort(std::begin(S), std::end(S));

    if (sum % 10 == 0) {
        for (auto i = S.begin(); i != S.end(); ++i) {
            if (*i % 10 != 0) {
                sum -= *i;
                break;
            }
        }
    }

    if (sum % 10 == 0) {
        sum = 0;
    }
    std::cout << sum << std::endl;

    return 0;
}


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

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1 && b!=1)
        cout<<"Alice"<<endl;
    else if(b==1 && a!=1)
        cout<<"Bob"<<endl;
    else if(a>b)
        cout<<"Alice"<<endl;
    else if(b>a)
        cout<<"Bob"<<endl;
    else
        cout<<"Draw"<<endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a<b && b<c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    //if (N % 2 == 0 || M % 2 == 0) cout << 0 << endl;
    cout << abs((N - 2)) * abs((M - 2)) << endl;

    return 0;
}


Measured memory_bytes: 256
/*
F(SS)->G(STST)
这里T是S的最短非完整周期，即T是S的前缀，S是T...T的前缀。
那么只需要考虑S->ST的变换，手玩发现规律得
S->ST->STS->STSST...
f(i+2)=f(i+1)+f(i)
每次取最长的一个前缀f(d)删去以后递归即可，O(logW) 
*/

#include<cstdio>
#include<cstring>

typedef long long ll;
const int N=200005;

char s[N]; ll L,R;
int n,m,fail[N],cnt[26][N];

void init()
{
	for(int j=0; j<26; ++j)
		for(int i=1; i<=n; i++)
			cnt[j][i]=cnt[j][i-1]+(s[i]-'a'==j);
	for(int i=2,j; i<=n; i++)
	{
		for(j=fail[i-1];j&&s[j+1]!=s[i];j=fail[j]);
		fail[i]=j+(s[j+1]==s[i]);
	}
	m=n-fail[n];
}

ll solve(int j,ll a)
{
	if(a<=n)
		return cnt[j][a];
	ll p=n,q=m,x=cnt[j][n],y=cnt[j][m],tmp;
	while(p+q<=a)
	{
		tmp=p;
		p+=q;
		q=tmp;
		tmp=x;
		x+=y;
		y=tmp;
	}
	return x+solve(j,a-p);
}

int main()
{
	scanf("%s%lld%lld",s+1,&L,&R);
	n=strlen(s+1)/2;
	init();
	for(int j=0; j<26; j++)
		printf("%lld ",solve(j,R)-solve(j,L-1));
	return 0;
}


Measured memory_bytes: 20224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int p[3];
  int ans=0;
  cin >> p[0]>>p[1]>>p[2];
  ans = p[0]+p[1]+p[2]-max(p[0],max(p[1],p[2]));
  cout << ans;
}


Measured memory_bytes: 256
n = int(input())
list_n = list((map(int, input().split())))


def bubbleSort(list_a, n):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for j in list(range(1,n))[::-1]:
            if list_a[j] < list_a[j-1]:
                (list_a[j], list_a[j-1]) = (list_a[j-1], list_a[j])
                count += 1
                flag = 1
    return list_a,count
list_n,count = bubbleSort(list_n, n)
print(" ".join(str(number) for number in list_n))
print(count)



Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>

using namespace std;

bool row[100][100], column[100][100];
int n, data[100][100];

main(){
  while(cin >> n && n){
    fill(row[0], row[100], false);
    fill(column[0], column[100], false);
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> data[i][j];
    for(int i=0;i<n;i++){
      int valm = 100000000;
      for(int j=0;j<n;j++) if(valm > data[i][j]) valm = data[i][j];
      for(int j=0;j<n;j++) if(data[i][j] == valm) row[i][j] = true;
    }
    for(int j=0;j<n;j++){
      int valM = -100000000;
      for(int i=0;i<n;i++) if(valM < data[i][j]) valM = data[i][j];
      for(int i=0;i<n;i++) if(data[i][j] == valM) column[i][j] = true;
    }
    int ans = 0;
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(row[i][j] && column[i][j]) ans = data[i][j];
    cout << ans << endl;
  }
}

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

using namespace std;
int n,m,k;
string s;
int v[1001][1001],minim;
void child(vector<int> a)
{
    int rez=a.size();
    a.push_back(n);
    int nums[20];
    memset(nums,0,sizeof(nums));
    for(int j=1;j<=m;j++)
    {
        /*for(int q=1;q<=10;q++)
            nums1[q]=nums[q];*/
        int l=1;
        for(int q=0;q<a.size();q++)
        {
            int poz=q+1;
            while(l<=a[q])
            {
                nums[poz]+=v[l][j];
                l++;
            }
        }
        bool found=0;
        for(int q=1;q<=10;q++)
            if(nums[q]>k)
            {
                found=1;
                break;
            }
        if(found)
        {
            rez++;
            memset(nums,0,sizeof(nums));
            int l=1;
            for(int q=0;q<a.size();q++)
            {
                int poz=q+1;
                while(l<=a[q])
                {
                    nums[poz]+=v[l][j];
                    l++;
                }
            }
            found=0;
            for(int q=1;q<=10;q++)
            if(nums[q]>k)
            {
                found=1;
                break;
            }
            if(found==1)
            {
                rez=-1;
                break;
            }
        }
    }
    if(rez!=-1&&rez<minim)
        minim=rez;
}
int main()
{
    cin>>n>>m>>k;
    minim=n+2*m;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        for(int j=0;j<m;j++)
            v[i][j+1]=s[j]-'0';
    }
    for(int mask=0;mask<(1<<n-1);mask++)
    {
        vector<int> w;
        for(int j=0;j<n-1;j++)
            if((mask>>j)&1)
                w.push_back(j+1);
        child(w);
    }
    cout<<minim;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i;
  	int a[100];
	int n;

	scanf("%d",&n);
  	for(i=0; i<n; i++){
    	scanf("%d",&a[i]);
    }
  	for(i=0; i<n; i++){
      	if(a[i]%2==0 && a[i]%3 != 0 && a[i]%5 != 0){
        	puts("DENIED");
      		return 0;
        }
    }
  	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int d=sc.nextInt();
    System.out.println(Math.max(Math.min(b,d)-Math.max(a,c),0));
  }
}

Measured memory_bytes: 21460