akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
 
using namespace std;

void solve() {

}

bool ok(vector<int> A, int c, int S) {
	int sum = 0;
	for (int i = 0; i < c; i++) {
		sum += A[i];
	}
	for (int i = c; i < A.size(); i++) {
		if (sum >= S) {
			return true;
		}
		sum = sum - A[i - c] + A[i];
	}
	if (sum >= S) {
		return true;
	}
	return false;
}

int main(int argc, char const *argv[]) {
	int N, S;
	cin >> N >> S;
	vector<int> A;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
		sum += a;
	}
	if (sum < S) {
		cout << 0 << endl;
		return 0;
	}
	if (N == 1) {
		if (A[0] >= S) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
		return 0;
	}
	int l = 0;
	int r = A.size();
	while(r - l > 1) {
		int c = (r + l) / 2;
		if (ok(A, c, S)) {
			r = c;
		} else {
			l = c;
		}
	}
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b;

    cin >> a >> b;

    a--; b--;

    cout << a * b << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
int main()
{
    fastio;
    int n,m;
    cin>>n>>m;
    int ans[n+1] = {0};
    int h[n+1];
    for(int i=1;i<=n;i++)cin>>h[i];
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        if(h[y]<=h[x])ans[y] = -1;
        if(h[x]<=h[y])ans[x] = -1;
    }
    int cnt = 0;
    for(int i=1;i<=n;i++)
    {
        if(ans[i]==0)
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
struct node{
	int a,b,c,d;
}edge[51];
signed main(void){
	int n,m,q,maxv=0;
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++){
		cin>>edge[i].a>>edge[i].b>>edge[i].c>>edge[i].d;
	}
	int a[n+1];
	memset(a,1,sizeof(a));
	for(int i=0;i<=n;i++) a[i]=1;
	while(a[0]==1){
		int now=0,j=n;
		for(int i=1;i<=q;i++){
			if(a[edge[i].b]-a[edge[i].a]==edge[i].c) now+=edge[i].d;
		}
		maxv=max(maxv,now);
		while(a[j]==m) j--;
		for(int i=j+1;i<=n;i++) a[i]=a[j]+1;
		a[j]++;
	}
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int main(){
    int n;
    cin >> n;
    vi l(n);
    Srep(n) cin >> l[i];
    Vsort(l);
    int sum = 0;
    Srep(n-1) sum += l[i];
    cout << (sum > l[n-1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3616
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);

    auto ps = eratos(100);

    debug {
        //writeln(ps);
    }

    auto cnt = new int[](n + 1);

    foreach (i ; 2 .. n + 1) {
        debug {
            //writeln(i);
        }
        foreach (p ; ps) {
            while (i % p == 0) {
                i /= p;
                cnt[p]++;
            }
        }

        debug {
            //writeln(cnt);
        }
    }

    debug {
        //writeln(cnt);
    }

    auto cs = cnt.filter!"a > 0".array.sort!();

    debug {
        writeln(cs);
    }

    auto m = cs.length.to!int;

    long ans;

    foreach (i ; 0 .. m) {
        if (cs[i] >= 2) {
            auto fu = cs.upperBound(3).length.to!int;
            if (cs[i] > 3) {
                fu--;
            }
            fu = max(fu, 0);
            ans += 1L * fu * (fu - 1) / 2;

            auto cu = cs.upperBound(23).length.to!int;
            if (cs[i] > 23) {
                cu--;
            }
            cu = max(cu, 0);
            ans += cu;
        }

        if (cs[i] >= 4) {
            auto fu = cs.upperBound(13).length.to!int;
            if (cs[i] > 13) {
                fu--;
            }
            fu = max(fu, 0);
            ans += fu;
        }

        if (cs[i] >= 74) {
            ans++;
        }
    }

    writeln(ans);
}

int[] eratos(int n) {
    auto s = new bool[](n);
    s[] = true;
    s[0] = s[1] = false;

    for (int p = 2; p*p < n; p++) {
        if (s[p]) {
            for (int q = p*p; q < n; q += p) {
                s[q] = false;
            }
        }
    }

    return iota(n).filter!(i => s[i]).array;
}
























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)n - 1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
typedef pair<ll, ll> pll;

template <int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0)
            v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp &r) const noexcept {
        return Fp(*this) += r;
    }
    constexpr Fp operator-(const Fp &r) const noexcept {
        return Fp(*this) -= r;
    }
    constexpr Fp operator*(const Fp &r) const noexcept {
        return Fp(*this) *= r;
    }
    constexpr Fp operator/(const Fp &r) const noexcept {
        return Fp(*this) /= r;
    }
    constexpr Fp &operator+=(const Fp &r) noexcept {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os,
                                         const Fp<MOD> &x) noexcept {
        return os << x.val;
    }
    friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

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

    int S;
    cin >> S;
    vector<mint> dp(S + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= S; i++) {
        if (i - 3 >= 0) {
            dp[i] = dp[i - 1] + dp[i - 3];
        }
    }

    cout << dp[S] << endl;
}

Measured memory_bytes: 3660
#include <stdio.h>
int main(void){
    // Your code here!
    int h1, m1, h2, m2, k;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    int timea, hour;
    hour = h2 - h1;
    timea = hour*60 + m2 - m1 - k;
    printf("%d", timea);
}


Measured memory_bytes: 1704
from itertools import combinations, product
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
println = stdout.write

def main():
    N, M = map(int, input().split())
    XYZ = [tuple(map(int, input().split())) for _ in [0] * N]

    cake = [0] * N
    ans = -float('inf')
    for kx, ky, kz in product((1, -1), repeat=3):
        for i, (x, y, z) in enumerate(XYZ):
            cake[i] = sum((x * kx, y * ky, z * kz))
        cake.sort(reverse=1)
        ans = max(ans, sum(cake[:M]))
    print(ans)

main()


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

void fnInput(vector<int>& rvnMonstr, vector<int>& rvnBrave)
{
  int nMonstrSiz;
  cin >> nMonstrSiz;
  rvnMonstr.resize(nMonstrSiz + 1);
  rvnBrave.resize(nMonstrSiz);

  for (int& rnMonstr : rvnMonstr)
    cin >> rnMonstr;

  for (int& rnBrave : rvnBrave)
    cin >> rnBrave;
}
  
llong fnStrikMonstr(vector<int>& rvnMonstr, vector<int>& rvnBrave)
{
  llong nSumStrikMon = 0;

  for (int nBgn = 0; nBgn < rvnBrave.size(); nBgn++)
    for (int nFoward = nBgn; nFoward < nBgn + 2; nFoward++)
    {
      int nStrikMonstr = min(rvnBrave[nBgn], rvnMonstr[nFoward]);
      rvnMonstr[nFoward] -= nStrikMonstr;
      rvnBrave[nBgn] -= nStrikMonstr;
      nSumStrikMon += nStrikMonstr;
    }

  return nSumStrikMon;
}
  
int main()
{
  vector<int> vnMonstr, vnBrave;

  fnInput(vnMonstr, vnBrave);
  cout << fnStrikMonstr(vnMonstr, vnBrave) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m; cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
    }
    sort(all(l)); sort(all(r));
    int lmax = l[m-1];
    int rmin = r[0];
    if (rmin-lmax < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << rmin-lmax+1 << endl;

}

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

int main() {
    vector<vector<int>> num(3, vector<int> (3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> num[i][j];
        }
    }
    int b1, b2, b3;
    bool can = true;
    //iをa1として決め打ちする
    for (int i = 0; i <= 100; i++) {
        b1 = num[0][0]-i;
        b2 = num[0][1]-i;
        b3 = num[0][2]-i;
        //i=1,2に関してnum[i][j]-bjが全て等しくなるか判定
        for (int i = 1; i <= 2; i++) {
            int s, t, u;
            s = num[i][0]-b1;
            t = num[i][1]-b2;
            u = num[i][2]-b3;
            if (s != t || t != u || u != s) {
                can = false;
            }
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int> score(3);
    for (auto& s : score)
    {
        cin >> s;
    }

    string t;
    cin >> t;

    // dp[i][j] := i ターン目で 出した手が j の時の 最大得点

    vector<vector<char>> hands(k);
    for (int i = 0; i < n; i++)
    {
        hands[i % k].push_back(t[i]);
    }
    auto toint = [](char ch) { return ch == 'r' ? 0 : ch == 's' ? 1 : 2; };

    const string hand_str = "rsp";

    auto get_score = [&](vector<char>& hs) -> int64_t {
        vector<vector<int>> dp(hs.size() + 1, vector<int>(3, 0));
        for (int i = 1; i <= hs.size(); i++)
        {
            for (int j = 0; j < 3; j++)
            {
                const int op = toint(hs[i - 1]);
                const int win = (op + 3 - 1) % 3;

                for (int k = 0; k < 3; k++)
                {
                    if (j != k && j == win)
                    {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k] + score[j]);
                    }
                    else
                    {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k]);
                    }
                }
            }
        }
        return max(dp.back()[0], max(dp.back()[1], dp.back()[2]));
    };

    int64_t ans = 0;
    for (auto& h : hands)
    {
        ans += get_score(h);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5888
#include <stdio.h>
#include <math.h>

struct Point { double x, y; };

void koch(int n, Point a, Point b)
{
    if (n == 0) return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}


int main(int argc, char const *argv[])
{
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}



Measured memory_bytes: 2668
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

int popcnt[1<<16] = {};
int dp[31][1<<16], a[31], b[31];
bool valid[31][1<<16];

int main(){
    vector<int> popcnt(1<<16, 0);
    for(int i = 1; i < 1<<16; i++){
        for(int j = 0; j < 16; j++) popcnt[i] += (i>>j)&1;
    }
    int n, c;
    while(cin >> n >> c, n+c){
        memset(dp, 0, sizeof(dp));
        memset(valid, 0, sizeof(valid));
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        valid[0][0] = true;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 16; j++){
                int x;  cin >> x;
                a[i] += (1<<j)*x;
            }
        }
        for(int i = 0; i < c; i++){
            for(int j = 0; j < 16; j++){
                int x;  cin >> x;
                b[i] += (1<<j)*x;
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 1<<16; j++){
                if(!valid[i][j])    continue;
                int nj = j|a[i];
                for(int k = 0; k < c; k++){
                    valid[i+1][~b[k]&nj] = true;
                    dp[i+1][~b[k]&nj] = max(dp[i+1][~b[k]&nj], dp[i][j]+popcnt[nj&b[k]]);
                }
            }
        }
        int ans = 0;
        for(int j = 0; j < 1<<16; j++){
            if(valid[n][j]) ans = max(ans, dp[n][j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 13064
#include <bits/stdc++.h>
using namespace std;
#define at(t, i) get<i>(t)
typedef pair<int, int> Pr;
typedef tuple<int, int, int> Tp;
const int INF = 1 << 28;
const int dx[] = {0, -1, -1, 0, 1, 1};
const int dy[][6] = {
	{-1, 0, 1, 1, 1, 0},
	{-1, -1, 0, 1, 0, -1},
};

int m, n;
int s, t;
Pr pos[11];
int dist[11][128][128];

int solve()
{
	fill_n(**dist, 11 * 128 * 128, INF);
	for (int i = 0; i <= s; i++){
		for (int j = 0; j <= 127; j++){
			for (int k = 0; k <= 127; k++){
				if (j == 0 || k == 0 || j == 127 || k == 127){
					dist[i][j][k] = 0;
				}
			}
		}
	}
	
	for (int i = 0; i <= s; i++){
		dist[i][pos[i].first][pos[i].second] = 0;
		queue<Tp> que;
		for (que.push(Tp(pos[i].first, pos[i].second, 0)); que.size(); que.pop()){
			Tp t = que.front();
			int x = at(t, 0);
			int y = at(t, 1);
			int d = at(t, 2);
			//printf("%d %d %d\n", x, y, d);
			if (dist[i][x][y] < d) continue;
			for (int dir = 0; dir < 6; dir++){
				int nx = x + dx[dir];
				int ny = y + dy[x & 1][dir];
				if (dist[i][nx][ny] > d + 1){
					dist[i][nx][ny] = d + 1;
					que.push(Tp(nx, ny, d + 1));
				}
			}
		}
	}
	
	/*for (int i = 0; i <= s; i++){
		for (int j = 1; j <= n; j++){
			for (int k = 1; k <= m; k++){
				printf("%d ", dist[i][j][k]);
			}
			puts("");
		}
		puts("\n");
	}*/
	
	int res = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			int p = 0;
			for (int k = 1; k <= s; k++){
				if (dist[p][i][j] >= dist[k][i][j]){
					p = k;
				}
			}
			if (p == 0) res++;
		}
	}
	
	return res;
}

int main()
{
	while (scanf("%d %d", &m, &n), m){
		scanf("%d", &s);
		for (int i = 0; i < s; i++){
			int x, y;
			scanf("%d %d", &x, &y);
			pos[i + 1] = Pr(y, x);
		}
		
		int res = 0;
		scanf("%d", &t);
		for (int i = 0; i < t; i++){
			int p, q;
			scanf("%d %d", &p, &q);
			pos[0] = Pr(q, p);
			res = max(res, solve());
		}
		
		printf("%d\n", res);
	}
}

Measured memory_bytes: 1904
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

bool ans;

int main(){
    int a,b;
    cin>>a>>b;
    if((a*b)%2==0)ans=false;
    else ans=true;
    ans?cout<<"Yes"<<endl:cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
	int br=0;
	char s[4],i;
	scanf("%s", &s);
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='+')
		br=br+1;
		else
		br=br-1;
	}
	printf("%d", br);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i,cnt=0;
    cin>>s;
    for(i=0;i<3;i++)
    {
        if(s[i]=='R')
            cnt++;
    }
    if(cnt>1&&s[1]=='S')
        cnt--;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3620
s = input()
s_s = list(s)

ans = [0] * len(s_s)

cnt = 0
cur = 'R'
for i in range(len(s_s) + 1):
  if i < len(s_s) and s_s[i] == cur:
    cnt += 1
  else:
    if cur == 'R':
      ans[i - 1] += cnt // 2 + cnt % 2   #R
      ans[i] += cnt // 2                 #L
    else:
      #cur == 'L':
      ans[i - cnt - 1] += cnt // 2       #R
      ans[i - cnt] += cnt // 2 + cnt % 2 #L
    
    if i == len(s_s):
      break
      
    cnt = 1
    cur = s_s[i]
 

print(" ".join([str(a) for a in ans]))

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

int main(){
    string s, t; cin >> s >> t;
    int ans = t.size();
    for(int start = 0; start <= (int)(s.size() - t.size()); start++){
        int diff = 0;
        for(int i = 0; i < (int)t.size(); i++){
            if(t[i] != s[start+i]) diff++;
        }
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	ll x; cin >> x;
	ll c = x / 100;
	ll r = x % 100;

	for (int i5 = 0; i5 <= c; i5++) {
		for (int i4 = 0; i4 <= c; i4++) {
			for (int i3 = 0; i3 <= c; i3++) {
				for (int i2 = 0; i2 <= c; i2++) {
					for (int i1 = 0; i1 <= c; i1++) {
						for (int i0 = 0; i0 <= c; i0++) {
							if ((i5 * 5 + i4 * 4 + i3 * 3 + i2 * 2 + i1) == r) {
								if ((i5 + i4 + i3 + i2 + i1 + i0) == c) {
									cout << 1 << endl;
									return 0;
								}
							}
						}
					}
				}
			}
		}
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

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

int main () {

    int n;
    cin >> n;

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

    long long res = 100000000;
    for (int i = 0; i <= 100; i++) {
        long long sum = 0;
        for (int j = 0; j < n; j++) {
            sum += (i - a[j]) * (i - a[j]);
        }
        res = min(res, sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int dp[1002][5][2];
int k;
string str;
int n;
int solve(int pos , int cnt , bool tight){
   if(pos == n && cnt == k)
   return 1;
   else if(pos == n && cnt != k)
   return 0;
 if(dp[pos][cnt][tight] != -1)
 return dp[pos][cnt][tight];
 ll ret = 0;
 ll en = tight?(str[pos]-'0'):9;
 for(int i = 0 ; i <= en ; i++){
  ll cntupd = cnt + (i > 0);
  if(cntupd <= k){
     ret += solve(pos + 1 , cntupd , (tight&(i==en)));
  }
 }
 return (dp[pos][cnt][tight] = ret);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>str;
n = str.length();
cin>>k;
memset(dp , -1 , sizeof dp);
//~ for(int i = 0 ; i < 1002 ; i++){
 //~ for(int j = 0 ; j < 5 ; j++){
  //~ for(int k = 0 ; k < 2 ; k++){
   //~ cout<<dp[i][j][k]<<" ";
  //~ }
  //~ //cout<<endl;
 //~ }}
ll ans = solve(0 , 0 , true);
cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int n,k,m;
	cin >> n >> k;
	if(n%2==0) m=n/2;
	else m=(n+1)/2;
	if(k>m) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int idx=Integer.parseInt(buf.readLine()); 
        int ans=0;
        for(int i=0;i<idx;i++){
            int x=Integer.parseInt(buf.readLine());
            int flg=0;
            
            if(x==2){
                flg=0;
            }else if(x%2==0 || x<2){
                flg=1;
            }else{
                double sqrt=Math.sqrt(x);
                for(int j=3;j<=sqrt;j+=2){
                    if(x%j==0){
                        flg=1;break;
                    }
                }
            }
            if(flg==0){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  int N;
  cin >> N;
  
  if(N==1){cout<<1<<endl;}
  else if(N<=3){cout<<2<<endl;}
  else if(N<=7){cout<<4<<endl;}
  else if(N<=15){cout<<8<<endl;}
  else if(N<=31){cout<<16<<endl;}
  else if(N<=63){cout<<32<<endl;}
  else {cout<<64<<endl;}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;
const int max_n = 1e6 + 5;

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

int main() {
	makev(v, 4);
	sort(all(v));
	if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3]==9) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<pll,ll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a,b,c;
vi res;

void f(int k){
	assert(0<k&&k<n);
	for(int i=k;i<n;i++){
		swap(a[i],a[i-k]);
		swap(b[a[i]],b[a[i-k]]);
	}
	res.push_back(k);
}

void Open(){
	for(int i=0;i<n;i++) cout<<a[i]<<' ';
	cout<<endl;
}

int main(){
	cin>>n;
	a=b=c=vi(n);
	int N=n/2;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]=i;
		c[i]=abs(N-i);
		if(n%2==0&&i<N) c[i]--;
	}
	if(n%2==1) while(a[N]!=N) f(1);
	for(int i=0;i<N;i++){
		int L=N-i-1,R=N+i+n%2;
		if(c[b[L]]!=c[b[R]]){
			int x=(c[b[L]]<c[b[R]]?L:R),y=L+R-x;
			f(N+c[b[x]]);
			if((b[L]<N)^(b[R]<N)) f(n-1);
			f(N+c[b[y]]+1);
			bool B=b[x]>=N,T=n%2==0&&!i;
			while(B&&b[y]||!B&&b[y]!=n-1) f(1);
			f(n-1);
			while(T&&c[b[x]]!=c[b[y]]||!T&&a[N]!=N) f(1);
		}
		f(max(b[L],b[R]));
		if(b[R]) f(n-1);
		f(R);
	}
	int S=res.size();
	cout<<S<<endl;
	for(int i=0;i<S;i++) cout<<res[i]<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int mod=(1e9)+7;
const int maxn=1010;
int n,m,dp[maxn][maxn];
char s[maxn][maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	if (s[1][1]=='#') { printf("0\n"); return 0; }
	dp[1][1]=1;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++) {
		if (i==1&&j==1) continue;
		if (s[i][j]=='#') continue;
		dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int a = 0, b = 0;

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

	if (a > b) {
		printf("a > b\n");
	} else if (a < b) {
		printf("a < b\n");
	} else {
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
from sys import stdin
import collections

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
A = collections.Counter(A)
for i in range(M):
    B, C = [int(x) for x in stdin.readline().rstrip().split()]
    A[C] += B 
A = dict(A)
A = dict(sorted(A.items()))

S = 0
j = -1

A_key = list(A.keys())
A_value = list(A.values())

while True:
    if A_value[j] < N:
        S += A_value[j] * A_key[j]
        N -= A_value[j]
        j -= 1
    else:
        S += N * A_key[j]
        break
print(S)


Measured memory_bytes: 63844
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int A,B;
    string S;
    cin >> A >> B >> S;
    
    int cnt = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == '-'){
            cnt++;
        }
    }
    if(S.size() == A+B+1 && S[A] == '-' && cnt == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int X;
	cin >> X;
	int ans = 1000*(X/500);
	X -= ans/2;
	ans += 5*(X/5);
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
    int K, X;
    cin >> K >> X;

    if(500 * K >= X) cout << "Yes" << endl;
    else            cout << "No"  << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long s;
    cin>>s;
    cout<<s*(s-1)/2<<endl;
    return 0;
}


Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	map<int, vi> days;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		days[a].push_back(b);
	}
	long long res = 0;

	for (int i = 1; i <= m; i++)
	{
		for (int curb : days[i])
			q.push(curb);
		if (q.empty())
			continue;
		int cur = q.top(); q.pop();
		res += cur;

	}
	cout << res;
	return 0;
}

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

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

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // end

    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

vector<ll> v, vr;
ll n, k;

ll calc_max(ll cl, ll cr) {
  if (cl + cr > n) {
    return 0;
  }

  vector<ll> j;
  j.reserve(cl + cr);

  if (cl) {
    j.insert(j.end(), v.begin(), v.begin() + cl);
  }
  if (cr) {
    j.insert(j.end(), vr.begin(), vr.begin() + cr);
  }
  sort(all(j));

  rep(i, min(k - cl - cr, cl + cr)) {
    if (j[0] >= 0) {
      break;
    }
    j.erase(j.begin());
  }

  return accumulate(all(j), 0);
}

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

  cin >> n >> k;

  rep(i, n) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  vr.reserve(n);
  vr = v;
  reverse(all(vr));

  // ll cl; // 左から宝石を取る回数
  // ll cr; // 右から宝石を取る回数
  // ll cd; // 宝石を戻す回数
  // cl+cr+cd <= kとなるなかでの最大値を求める

  ll ans = 0;
  rep(cl, min(n + 1, k + 1)) {
    rep(cr, min(n + 1 - cl, k + 1 - cl)) {
      chmax(ans, calc_max(cl, cr));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#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" << endl;
            break;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef unsigned long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

ll modpow(ll m, ll p) {
    if (p == 0) return 1;
    if (p % 2)
        return m * modpow(m, p - 1);
    else {
        ll res = modpow(m, p / 2);
        return res * res;
    }
}

int main() {
    ll n;
    cin >> n;
    if (n % 2 == 0) {
        ll ans = 0;
        for (ll i = 1; i <= 25; i++) {
            ans += n / (modpow(5, i) * 2);
        }
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}


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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// --------------------------------------------------------------------------------

void solve_main()
{
    int x;cin>>x;
    int ans;
    if(x>=1800)ans=1;
    else if(x>=1600)ans=2;
    else if(x>=1400)ans=3;
    else if(x>=1200)ans=4;
    else if(x>=1000)ans=5;
    else if(x>=800)ans=6;
    else if(x>=600)ans=7;
    else if(x>=400)ans=8;
    cout<<ans<<"\n";
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int t=1;
    // cin>>t;
    while(t--)
    {
    	solve_main();
    }    
}

Measured memory_bytes: 3588
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int M = sc.nextInt();
       
       Long[][] m = new Long[(int)M][4];
       for (int i=0 ; i<M; i++) {
           m[i][0] = (long) i;
           m[i][1] = sc.nextLong();
           m[i][2] = sc.nextLong();
       }
       
       Arrays.sort(m, (b, c) -> Long.compare(b[2], c[2]));
       int[] cnt=new int[N+5];
       Arrays.fill(cnt, 0);

       for(int i=0;i<M;i++) {
    	   double d =(double)m[i][1];
    	   
    	   cnt[(int)d]++;
    	   m[i][3]=(long) cnt[(int) d];
       }

       Arrays.sort(m, (b, c) -> Long.compare(b[0], c[0]));
	   StringBuffer s=new StringBuffer();
       for(int i=0;i<M;i++) {
    	   for(int j=0;j<6-String.valueOf( m[i][1] ).length();j++) {
        	   s.append(0);    		   
    	   }
    	   s.append(m[i][1]);
    	   for(int j=0;j<6-String.valueOf( m[i][3] ).length();j++) {
        	   s.append(0);    		   
    	   }
    	   s.append(m[i][3]);
    	   s.append("\n");
       }
	   System.out.println(s);
   }
}

Measured memory_bytes: 119108
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,M;
	cin>>N>>M;
	vector<pair<int,int>> LR(M);
	for(int i=0;i<M;i++){
		cin>>LR[i].first>>LR[i].second;
	}
	sort(LR.begin(),LR.end());
	int min=0,max=INF;
	for(int i=0;i<M;i++){
		if(LR[i].second<max) max=LR[i].second;
		if(LR[i].first>min) min=LR[i].first;
	}
	if(max-min+1>0) cout<<max-min+1<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 1024
A,B,K = map(int, raw_input().split())
  
for i in range(K):
    if A + i >= A and A + i <= B:
        print(A + i)
for i in range(K):
    if B - K + 1 + i >= A and B - K + 1 + i <= B and B - K + 1 + i > A + K -1:
        print(B - K + 1 + i)

Measured memory_bytes: 2568
import sys
N, M = map(int, input().split())
L0, R0 = map(int, input().split())

if M > 1:
	for i in range(M - 1):
		L, R = map(int, input().split())
		if (R0 < L) | (R < L0):
			print(0)
			sys.exit()
		else:
			L0 = max(L0, L)
			R0 = min(R0, R)
	print(R0 - L0 + 1)
else:
	print(R0 - L0 + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(){
    int con = 1000000007LL;
    int n;
    cin >> n;
    string s1,s2;
    cin >> s1 >> s2;
    long long ans = 1LL;
    bool flag;
    for(int i = 0; i < n; i++)
    {
        if (i==0) {
            if (s1[i]==s2[i]) {
                ans *= 3;
                flag = true;
            }
            else
            {
                ans *= 6;
                flag = false;
                i++;
            }
        }
        else
        {
            if (flag) {
                if (s1[i]==s2[i]) {
                    ans *= 2;
                }
                else
                {
                    ans *= 2;
                    flag = false;
                    i++;
                }
            }
            else
            {
                if (s1[i]==s2[i]) {
                    ans *= 1;
                    flag = true;
                }
                else
                {
                    ans *= 3;
                    i++;
                }
            }
        }
        ans %= con;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
string mp[110];
int main()
{
    int n,m;
    while(~scanf("%d %d",&n,&m))
    {
        for(int i=0;i<n;i++)
            cin>>mp[i];
        sort(mp,mp+n);
        for(int i=0;i<n;i++)
            cout<<mp[i];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	if (N%K == 0) {
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const double eps = 0.0001;

int main()
{
    double a, b, x; cin >> a >> b >> x;
    double res;
    if(x - a*a*b/2.0 > eps){
        res = (180.0/M_PI)*atan(2.0*b/a-2.0*x/(a*a*a));
    }else if(a*a*b/2.0 - x > eps){
        res = (180.0/M_PI)*(M_PI/2.0-atan(2.0*x/(a*b*b)));
    }else{
        res = (180.0/M_PI)*atan(b/a);
    }
    printf("%.6f\n", res);
}

Measured memory_bytes: 4020
N = int(input())
memo = {}
for _ in range(N):
    Ai = int(input())
    try:
        memo[Ai] += 1
    except:
        memo[Ai] = 1

ans = 0
for i in memo:
    if memo[i] % 2 == 1:
        ans += 1

print(ans)


Measured memory_bytes: 15072
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	A := ReadInts(N)
	s := make([]int, N+1)
	for i := 0; i < N; i++ {
		s[i+1] = (s[i] + A[i]) % M
	}
	ans := 0
	m := make(map[int]int)
	for i := 0; i < N+1; i++ {
		ans += m[s[i]]
		m[s[i]]++
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 9412
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

for i in range(1, n):
    a1[i] += a1[i - 1]

for i in range(n - 2, -1, -1):
    a2[i] += a2[i + 1]

res = 0
for i in range(n):
    tmp = a1[i] + a2[i]
    res = max(tmp, res)

print(res)


Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  
  REP(i,S.length()){
      if ((i%2==1 && S[i]=='R') || (i%2==0 && S[i]=='L')){
          cout << "No" << "\n";
          return 0;
      }
  }
  cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100100; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for(int i=0;i<N;i++){
        for(int j=1;j<=K;j++){
            dp[i+j]=min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
inp = list(map(int, input().split()))
n = inp[0]
X = inp[1:3]
Y = inp[3:5]

if n % X[0] == 0:
    costx = 0
else:
    costx = 1
    
if n % Y[0] == 0:
    costy = 0
else:
    costy = 1
x = (n//X[0] + costx)*X[1]
y = (n//Y[0] + costy)*Y[1]
print(min(x,y))


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#define int long long
#define iris 1000000007
using namespace std;

int arr[100010];
bool flag[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m,ans,pt,a;
	string s;
	cin>>n>>m;
	ans=pt=0;
	while(m--)
	{
		cin>>a>>s;
		if(s=="AC")
		{
			if(!flag[a])
			{
				flag[a]=1;
				pt+=arr[a];
				ans++;
			}
		}
		else
		{
			arr[a]++;
		}
	}
	cout<<ans<<' '<<pt<<'\n';
	
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			int x = scanner.nextInt();
			System.out.println((k * 500 >= x) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 22996
S = input()

if S.count("K") != 1 or S.count("I") != 1 or S.count("H") != 1 or S.count("B") != 1 or S.count("R") != 1:
    print("NO")
    exit()

for s in S:
    if s not in "KIHBRA":
        print("NO")
        exit()

if S.find("K") + 1 != S.find("I"):
    print("NO")
    exit()

if S.find("I") + 1 != S.find("H"):
    print("NO")
    exit()

if S.find("H") > S.find("B"):
    print("NO")
    exit()

if S.find("B") > S.find("R"):
    print("NO")
    exit()

if S.find("K") >= 2:
    print("NO")
    exit()

if S.find("B") - S.find("H") >= 3:
    print("NO")
    exit()

if S.find("R") - S.find("B") >= 3:
    print("NO")
    exit()

if len(S) - S.find("R") >= 3:
    print("NO")
    exit()

print("YES")


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

using namespace std;

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

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

  long long ans = 0;
  for(int b=0; b<n; b++){
    for(int a=0; a<b; a++){
      int r = lower_bound(Li.begin(), Li.end(), Li[a]+Li[b]) - Li.begin();
      int l = b + 1;
      ans += r - l;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[]){
    int A, B;
    std::cin >> A >> B;
    int money;
    if(13<=A){
        money = B;
    }else if(6<=A && A<13){
        money = B>>1;
    }else{
        money = 0;
    }
    std::cout << money << std::endl;
    return 0;
}


Measured memory_bytes: 256