akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;

  ll ans = 1;
  bool flag_zero = false;
  bool flag_minus = false;
  for (auto &v : vec) {
    if (v == 0)
      flag_zero = true;
    else if (v <= static_cast<ll>(1e18) / ans)
      ans *= v;
    else
      flag_minus = true;
  }

  cout << (flag_zero ? 0 : flag_minus ? -1 : ans) << endl;
}


Measured memory_bytes: 4004
#include <stdio.h>

#define N 100

void trace(int A[], int n){
    for(int i = 0; i < n; i++){
            printf("%d", A[i]);
            if(i != n - 1){
                printf(" ");
            }

    }
    printf("\n");
}
 
int bubblesort(int A[], int n){
    int j, t;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        j = n - 1;
        while(j > i){
            /* exchange */
            if(A[j - 1] >  A[j]){
                t = A[j - 1];
                A[j - 1] = A[j];
                A[j]  = t;
                cnt ++; 
                
            }
            j--;
        }

    }

    trace(A, n);
    return cnt;
}

int main(){
    int n, i;
    int A[N + 1];

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

    printf("%d\n", bubblesort(A, n));

    return 0;
}


Measured memory_bytes: 1976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    {
        cout << "Possible\n";
    }
    else
    {
        cout << "Impossible\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	double x1,y1,x2,y2;
	double x;
	
	cin>>x1>>y1>>x2>>y2;
	x=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
	cout<<fixed;
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int t, num;
    cin >> t >> num;
    if (t == 0 && num == 0){
      break;
    }
    int mx = 0;
    int cnt = 0;
    string S = to_string(num);
    int N = S.size();
    vector<int> ans;
    for (int i = 0; i < (1 << (N - 1)); i++){
      vector<int> p(1, 0);
      for (int j = 0; j < N; j++){
        p.back() = p.back() * 10 + S[j] - '0';
        if (j < N - 1){
          if (i >> j & 1){
            p.push_back(0);
          }
        }
      }
      int sum = 0;
      for (int x : p){
        sum += x;
      }
      if (sum <= t){
        if (sum > mx){
          mx = sum;
          ans = p;
          cnt = 1;
        } else if (sum == mx){
          cnt++;
        }
      }
    }
    if (mx == 0){
      cout << "error" << endl;
    } else if (cnt >= 2){
      cout << "rejected" << endl;
    } else {
      cout << mx;
      for (int x : ans){
        cout << ' ' << x;
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.SQLOutput;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        System.out.println(Math.max(C-(A-B),0));
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);

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

	int N, W;
	cin >> N >> W;
	P p[N];
	rep(i,N){
		cin >> p[i].first >> p[i].second;
	}
	sort(p,p+N);
	if(p[0].first > 300){
		int K = W/p[0].first;
		W = W % p[0].first;
		if(K > N){
			int ans = 0;
			rep(i,N){
				ans += p[i].second;
			}
			cout << ans << endl;
			return 0;
		}
		int _ = p[0].first;
		rep(i,N){
			p[i].first -= _;
		}
		int dp[N+1][K+1][500]{};
		rep(i,N){
			rep(j,K+1){
				rep(k,400){
					chmax(dp[i+1][j][k], dp[i][j][k]);
					if(j>0 && k-p[i].first>=0){
						chmax(dp[i+1][j][k], dp[i][j-1][k-p[i].first]+p[i].second);
					}
				}
			}
		}
		cout << dp[N][K][min(W,(int)350)] << endl;
	}
	else{
		W = min(W, N*p[N-1].first);
		int dp[N+1][W+1]{};
		dp[0][0] = 0;
		rep(i,N){
			rep(j,W+1){
				chmax(dp[i+1][j], dp[i][j]);
				if(j-p[i].first>=0){
					chmax(dp[i+1][j], dp[i][j-p[i].first]+p[i].second);
				}
			}
		}
		cout << dp[N][W] << endl;
	}
}

Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i,n-1) if (s[i] == s[i+1]) score++;
    int ans = min(n-1, score + (2 * k));
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    int flag = 0;
    for (auto i = 0; i < N; ++i) {
        char s;
        std::cin >> s;
        switch (s) {
        case 'P':
            flag = flag | 0b0001;
            break;
        case 'W':
            flag = flag | 0b0010;
            break;
        case 'G':
            flag = flag | 0b0100;
            break;
        case 'Y':
            flag = flag | 0b1000;
            break;
        default:
            break;
        }
    }
    if (flag == 0b0111) {
        std::cout << "Three" << std::endl;
    } else {
        std::cout << "Four" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
w,h,n = [int(i) for i in input().split()]

width = np.ones(w,dtype = np.int64)
height = np.ones(h,dtype = np.int64)

l = [[int(i) for i in input().split()] for _ in range(n)]

for i in l:
    if i[2] == 1:
        width[:i[0]] = 0
    elif i[2] == 2:
        width[i[0]:] = 0
    elif i[2] == 3:
        height[:i[1]] = 0
    else:
        height[i[1]:] = 0
        
width = np.count_nonzero(width)
height = np.count_nonzero(height)
print(width * height)


Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> s;
	vector<int> e(n), w(n);
	w[0]   = 0;
	e[n-1] = 0;
	f = 1000000;
 
	for(int i=1;i<n;i++){
		w[i] = w[i-1];
		if(s[i-1] == 'W') w[i] = w[i-1] + 1;
 
		e[n-i-1] = e[n-i];
		if(s[n-i] == 'E') e[n-i-1] = e[n-i] + 1;
	}
    for(int i=0;i<n;i++){
        f = min(f,w[i] + e[i]);
    }
	cout<<f<<endl;
    return 0;
}

Measured memory_bytes: 3076
// AOJ 2247 Two-Wheel Buggy
// 2018.2.18 bal4u

#include <stdio.h>
#include <math.h>

#define PI		3.1415926535897932384626433832795
#define PI180	0.01745329251994329576923690768489
#define EPS		1e-7
#define EQ(a,b) (fabs((a)-(b))<=EPS)
#define ABS(a)  ((a)>=0?(a):-(a))

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main() 
{
	int N, D, L, R, T;
	double x, y, d, a, t, tx, ty, u, v;

	while (N = in()) {
		D = in();

		x = 0, y = 0, d = PI/2;
		while (N--) {
			L = in(), R = in(), T = in();

			if (L == R)	{
				t = T*L*PI180;
				x += t*cos(d);
				y += t*sin(d);
				continue;
			}

			t = L-R, t = D*(L+R)/t, a = T*PI180;
			if (!EQ(t,0) && t < EPS) a *=  R/ABS(D-t);
			else                     a *= -L/ABS(D+t);
			tx = x + t*sin(d), ty = y - t*cos(d);
			u = x-tx, v = y-ty;
			x = tx + u*cos(a)-v*sin(a);
			y = ty + u*sin(a)+v*cos(a);
			d += a;
		}
		printf("%.20lf\n%.20lf\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 2048
# Node
class Node
  attr_accessor :id, :edges, :cost, :done

  def initialize(id, edges = [], cost = nil, done = false)
    @id, @edges, @cost, @done = id, edges, cost, done
  end
end

# Edge
class Edge
  attr_accessor :to, :cost

  def initialize(to, cost)
    @to, @cost = to, cost
  end
end

# Dijkstra
class Dijkstra
  attr_accessor :nodes

  def initialize(data)
    @nodes = {}
    data.each do |id, edges|
      edges.map! { |edge| Edge.new(*edge) }
      @nodes[id] = Node.new(id, edges)
    end
  end

  def start(start_id)
    @nodes.each do |id, node|
      node.done = false
      node.cost = node.id == start_id ? 0 : -1
    end

    loop do
      done_node = nil
      @nodes.each do |id, node|
        next if node.done || node.cost < 0
        done_node = node if done_node.nil? || node.cost < done_node.cost
      end
      break if done_node.nil?
      done_node.done = true
      done_node.edges.each do |edge|
        node = @nodes[edge.to]
        cost = done_node.cost + edge.cost
        node.cost = cost if node.cost < 0 || cost < node.cost
      end
    end
  end
end

data1, data2 = {}, {}

n = gets.chomp.to_i
m = gets.chomp.to_i

m.times do
  a1, b1, c1, d1 = gets.chomp.split(',').map(&:to_i)
  data1[a1] ||= []
  data1[b1] ||= []
  data1[a1] << [b1, c1]
  data1[b1] << [a1, d1]
  data2[a1] ||= []
  data2[b1] ||= []
  data2[a1] << [b1, c1]
  data2[b1] << [a1, d1]
end

x1, x2, y1, y2 = gets.chomp.split(',').map(&:to_i)

dijkstra1 = Dijkstra.new(data1)
dijkstra2 = Dijkstra.new(data2)

dijkstra1.start(x1)
dijkstra2.start(x2)

forward_path_cost = dijkstra1.nodes[x2].cost
backward_path_cost = dijkstra2.nodes[x1].cost

puts y1 - y2 - forward_path_cost - backward_path_cost

Measured memory_bytes: 8676
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    int n, a[100010], num[100010] = {};
    cin >> n;

    REP(i, n)
    {
        cin >> a[i];
        num[a[i]]++;
    }

    int ans = 0;
    for (int i = 2; i < 100000; i++)
    {
        ans = max(ans, num[i] + num[i - 1] + num[i - 2]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;

int main(){
  int n,l;
  cin >> n >> l;
  string s[n];
  r(i,n) cin >> s[i];
  sort(s,s+n);
  r(i,n) cout << s[i];
  cout << endl;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
int MOD = 998244353;
const int e5 = (int) 1e5 + 5;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    LL x;
    Mint() {x = 0;}
    Mint(int _x): x(_x) {}
    Mint(LL _x): x(_x) {}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        LL res = x + rhs.x; if(res >= MOD) res -= MOD; return Mint(res);
    }
    Mint operator - (const Mint &rhs) const{
        LL res = x - rhs.x; if(res < 0) res += MOD; return Mint(res);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint(x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    Mint& operator += (const Mint &rhs) {
        x += rhs.x; if(x >= MOD) x -= MOD; return *this;
    }
    Mint& operator *= (const Mint &rhs) {
        x = (x * rhs.x) % MOD; return *this;
    }
    bool operator == (const Mint &rhs) const{
        return x == rhs.x;
    }
    bool operator != (const Mint &rhs) const{
        return x != rhs.x;
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};

void work()
{
    int k; read(k);

    LL s = 0;
    for(int i = 1; i <= k; i++)
        for(int j = 1; j <= k; j++)
            for(int c = 1; c <= k; c++)
                s += __gcd(i, __gcd(j ,c));
    cout <<s <<endl;
}

int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 3648
//??????????SM??????????

//  -------------Sourav Mondal----------   
//        _____________________________________"GUN IS ON FIRE~SM"
//..._|.._|___________________, ,) ----)           "KILL YOUR headache Shoot iT"
//....../ `---___________----_____|]_____)     ********* 2eZ4@SM
//...../_==o;;;;;;;;_______.:/ 
//.....), ---.(_(__) /                                   ask2sm*********
//....// (.||_.) ), ----" 
//...//___//
//../|___/|                              
//.||___||
//----------------------------------------------------------------------------


#include<bits/stdc++.h>
using namespace std;
#define llt long long int
int main(){
	int n,k,c=0;
	string s;
	cin>>n;
	cout<<pow(n,3)<<endl;

return 0;
}
//-------------------------------------IND------------------------------------

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int  a = scanner.nextInt();
	  	int  b = scanner.nextInt();
        System.out.print(a*b +" ");
        System.out.println((a+b)*2);
        scanner.close();
  }
}


Measured memory_bytes: 26064
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    int d,m;
    int date = 2;
    auto ds = ["Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday","Monday"];
    auto a = [31,29,31,30,31,30,31,31,30,31,30,31];
    while(true){
	date = 2;
	auto s = split(readln());
	d = to!int(s[0]);
	m = to!int(s[1]);
	if(d == 0 && m == 0) break;
	for(int i=0;i<d-1;i++){
	    date += a[i];
	}
	    date += m-1;
	date = date % 7;
	writeln(ds[date]);
    }
}

Measured memory_bytes: 2472
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <array>
#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;

#define ALL(a) (a).begin(),(a).end()
#define REP(index, begin, end) for (int (index) = (begin); (index) < (end); (index)++)
#define RE(index, end) REP(index, 0, end)
#define INF INT_MAX / 3
#define DINT(x) printf(#x " = %d\n", x);
#define GETINT(x) scanf("%d", &x)
#define GETSTR(x) scanf("%s", x)

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

struct column_num
{
	char white,
		blue,
		red;
};

int main()
{
	int h, w;
	array<column_num, 50> row;
	GETINT(h);
	GETINT(w);
	RE(i, h)
	{
		char temp[51] = {};
		GETSTR(temp);
		column_num col = {};
		RE(j, w)
		{
			switch (temp[j])
			{
			case 'W':
				col.white++;
				break;
			case 'B':
				col.blue++;
				break;
			case 'R':
				col.red++;
				break;
			}
		}
		row[i] = col;
	}
	int result = 0;
	REP(w_len, 0, h - 2)
	{
		int w_sum = 0;
		REP(i, 0, w_len + 1)
		{
			w_sum += row[i].white;
		}
		REP(b_len, w_len + 1, h - 1)
		{
			int b_sum = 0;
			REP(i, w_len + 1, b_len + 1)
			{
				b_sum += row[i].blue;
			}
			{
				int r_sum = 0;
				REP(i, b_len + 1, h)
				{
					r_sum += row[i].red;
				}
				int sum_all = w_sum + b_sum + r_sum;
				if (result < sum_all)
				{
					result = sum_all;
				}
			}
		}
	}
	printf("%d\n", (w * h) - result);
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define upper_index(v,a) (int)distance(v.begin(), upper_bound((v).begin(),(v).end(),a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
typedef long long ll;
const ll INF=1e18;
const ll MOD=1e9+7;

int main(){
    string S,T;cin>>S>>T;
    ll A,B;cin>>A>>B;
    string U;cin>>U;
    if(S==U){
        cout<<A-1<<" "<<B<<endl;
    }else{
        cout<<A<<" "<<B-1<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int             max(int left, int right)
{
        if (left >= right)
                return (left);
        else
                return (right);
}

int             main(void)
{
        int     n;
        int     a[100000];
        int     b[100000];
        int     c[100000];
        int     happiness[3][100000] = {0};
        int     ret;
        int     i;

        scanf("%d", &n);
        for (i = 0; i < n; i++)
        {
                scanf("%d%d%d", &a[i], &b[i], &c[i]);
        }
        happiness[0][0] = a[0];
        happiness[1][0] = b[0];
        happiness[2][0] = c[0];
        for (i = 0; i < n - 1; i++)
        {
                happiness[0][i + 1] = a[i + 1] + max(happiness[1][i], happiness[2][i]);
                happiness[1][i + 1] = b[i + 1] + max(happiness[0][i], happiness[2][i]);
                happiness[2][i + 1] = c[i + 1] + max(happiness[0][i], happiness[1][i]);
        }
        if (happiness[0][n - 1] >= happiness[1][n - 1])
                ret = happiness[0][n - 1];
        else
                ret = happiness[1][n - 1];
        if (ret < happiness[2][n - 1])
                ret = happiness[2][n - 1];
        printf("%d\n", ret);
        return (0);
}

Measured memory_bytes: 4076
#include <cstdio>
#include <algorithm>

int main() {
  int N, M, X;
  scanf("%d %d %d", &N, &M, &X);

  int f0 = 0;
  int f1 = 0;
  for (int i = 0; i < M; ++i) {
    int A;
    scanf("%d", &A);
    ++((A < X)? f0:f1);
  }
  printf("%d\n", std::min(f0, f1));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int greater1(int a, int b){
   if(a > b){
        return a;
    } 
    else if(b > a){
        return b;
    }
    else{
        return '=';
    }
}


int main(){
    int a, b, k, greater, smaller;
    scanf("%d %d", &a, &b);
    greater = greater1(a, b);
    if(greater == a){
        smaller = b;
    }
    else if(greater == b){
        smaller = a;
    }
    else{
        printf("0\n");
        return 0;
    }

    k = smaller;
    while(k != greater){
        if(abs(a - k) == abs(b - k)){
            printf("%d\n", k);
            return 0;
        }
        else{
            k++;
        }
    }

    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  string s;
  int q;
  cin >> s >> q;
  bool flag = true;
  string s1, s2;
  s1 = s;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) swap(s1, s2);
    if (t == 2) {
      int f;
      string c;
      cin >> f >> c;
      if (f == 1)
        s2 += c;
      else
        s1 += c;
    }
  }
  reverse(s2.begin(), s2.end());
  cout << s2 << s1 << endl;
}


Measured memory_bytes: 3920
from numpy import*
from scipy.sparse import*
def main():
  f=csgraph.floyd_warshall
  t=int32(open(0).read().split())
  n,m,l=t[:3]
  t=t[3:]
  m*=3
  print('\n'.join(map(str,map(int,clip(f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),(n+1,n+1)),0)<=l)[t[m+1::2],t[m+2::2]],0,n)%n-1))))
main()

Measured memory_bytes: 41944
#https://atcoder.jp/contests/dp/tasks/dp_f
#2019-01-14
S = input()
T = input()

#初期化
dp = [[0 for i in range(len(T)+1)] for j in range(len(S)+1)]

#DP
for i in range(len(S)):
    for j in range(len(T)):
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j], dp[i][j] + (S[i] == T[j]))

st = []

x = len(S)
y = len(T)
while x > 0 and y > 0:
    if dp[x][y] == dp[x-1][y]: x -= 1
    elif dp[x][y] == dp[x][y-1]: y -= 1
    else: 
        x -= 1
        y -= 1
        st += S[x]
print("".join(reversed(st)))

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

typedef long long int ll;
#define REP(i,a,b) for(ll i = ll(a); i < ll(b); i++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, a, b;
	cin>>n>>a>>b;
	if(a == 0)
		cout<<0;
	else{
		cout<<(n/(a+b))*a + min((n%(a+b)), a); 		
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
st = input()
a = list(st.split())
for i in range(n):
    a[i] = int(a[i])
dp = list()
for i in range(n):
    dp.append(0)
for i in range(n):
    if i == 0:
        dp[i] == 0
    elif i == 1:
        dp[i] = abs(a[1] - a[0])
    else:
        dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]))
print(dp[n - 1])

Measured memory_bytes: 11692
def cin
  gets.split.map(&:to_i)
end

n = gets.to_i
b = cin

arr = []
arr << b.first

(n - 2).times do |i|
  arr << (b[i] < b[i + 1] ? b[i] : b[i + 1])
end
arr << b.last

puts arr.inject(:+)

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var s = CRL();
        if (s.Count(x => x == 'R') > s.Count(x => x == 'B'))
        {
            CWL("Yes");
        }
        else
        {
            CWL("No");
        }
    }
}

public static partial class Program
{
    //テンプレここから
    private static int ToInt(this string str) => int.Parse(str);
    private static long ToLong(this string str) => long.Parse(str);
    private static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SpTInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SpTLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long ToLong(this char c) => c.ToString().ToLong();
    //テンプレここまで
}


Measured memory_bytes: 11220
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int64_t N;
	int keta_search;
	int64_t search;
	int64_t search_max;
	int64_t yakusimaruhiroko = 0;
	if (scanf("%" SCNd64, &N) != 1) return 1;
	search_max = 1;
	for (keta_search = 1; keta_search <= 12; keta_search++) {
		search_max *= 3;
		for (search = 0; search < search_max; search++) {
			int64_t kugyu = 0;
			int i;
			int64_t hayaminn = search;
			int yosinagasayuri = 0;
			for (i = 0; i < keta_search; i++) {
				kugyu = kugyu * 10 + (3 + (hayaminn % 3) * 2);
				yosinagasayuri |= 1 << (hayaminn % 3);
				hayaminn /= 3;
			}
			if (kugyu <= N && yosinagasayuri == 7) yakusimaruhiroko++;
		}
	}
	printf("%" PRId64 "\n", yakusimaruhiroko);
	return 0;
}


Measured memory_bytes: 128
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
lb, ub = 0, 10**9
while ub > lb + 1:
    mid = (lb + ub) // 2
    t, C, cnt = mid * B, A - B, 0
    for h in H:
        if h > t:
            tmp = h - t
            cnt += tmp // C + (tmp % C != 0)
            if cnt > mid:
                break
    if mid < cnt:
        lb = mid
    else:
        ub = mid
print(ub)


Measured memory_bytes: 7072
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 100005
using namespace std;
int n;
ll arr[N];
ll gcd1[N];
ll gcd2[N];
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&arr[i]);
    gcd1[0]=arr[0];
    gcd2[n-1]=arr[n-1];
    for(int i=1;i<n;i++){
        gcd1[i]=__gcd(arr[i],gcd1[i-1]);
    }
    for(int i=n-2;i>=0;i--){
        gcd2[i]=__gcd(arr[i],gcd2[i+1]);
    }
    ll ans=0;
    ans=max(gcd1[n-2],gcd2[1]);
    for(int i=1;i<n-1;i++){
        ans=max(ans,__gcd(gcd1[i-1],gcd2[i+1]));
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

int main(){
  int i,j,k;
  int n;
  string s,t;
  bool flag,flag2=false;
  cin >> s;
  cin >> t;
  for(i=(int)s.size()-(int)t.size();i>=0;i--){
    flag = true;
    for(j=0;j<(int)t.size();j++){
      if(t[j]!=s[i+j] && s[i+j]!='?')flag = false;
    }
    if(flag){
      for(j=0;j<(int)t.size();j++){
	s[i+j]=t[j];
      }
      flag2=true;
      break;
    }
  }
  for(i=0;i<(int)s.size();i++)if(s[i]=='?')s[i]='a';
  if(flag2)cout << s  << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	vl a(n);
	rep(i,0,n)cin>>a[i];
	ll ans=1;
	ll now;
	ll tmp;
	rep(i,1,n){
		if(a[i-1]<a[i])now=1;
		else if(a[i-1]>a[i])now=-1;
		else now=0;
		if(i==1 || tmp==0)tmp=now;
		if(now==0)continue;
		if(now!=tmp){
			ans++;
			tmp=0;
		}

	}
	cout<<ans<<endl;

	
	return 0;
}

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

int main() {
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double arg_h = M_PI/2 - (h + m/60) * M_PI/6;
  double arg_m = M_PI/2 - m*M_PI/30;
  double h_x = a*cos(arg_h); double h_y = a*sin(arg_h);
  double m_x = b*cos(arg_m); double m_y = b*sin(arg_m);
  double length = sqrt((h_x - m_x)*(h_x - m_x) + (h_y - m_y)*(h_y - m_y));
  printf("%.12lf\n",length);
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int q; cin >> q;
    priority_queue<ll> fr;
    priority_queue<ll, vector<ll>, greater<ll>> ba;
    ll fs = 0, bs = 0;
    ll c = 0;

    auto update = [&](ll a, ll b){
        c += b;
        if(fr.size() > ba.size()){
            ll prev_m = fr.top();
            if(prev_m <= a){
                ba.push(a);
                bs += a;
            }
            else{
                fr.pop(); fs -= prev_m;
                fr.push(a); fs += a;
                ba.push(prev_m); bs += prev_m;
            }
        }
        else{
            if(fr.empty()){
                fr.push(a); fs += a;
            }
            else{
                ll prev_m = ba.top();
                if(a <= prev_m){
                    fr.push(a); fs += a;
                }
                else{
                    ba.pop(); bs -= prev_m;
                    ba.push(a); bs += a;
                    fr.push(prev_m); fs += prev_m;
                }
            }
        }
    };

    rep(i,q){
        int type; cin >> type;
        if(type == 1){
            ll a,b; cin >> a >> b;
            update(a,b);
        }
        else{
            ll x = fr.top();
            ll y = (x*(int)fr.size() - fs) + (bs - x*(int)ba.size()) + c;
            cout << x << " " << y << endl;
        }
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m,i,j,taro[100],hanako[100];
  int sum_taro,sum_hanako,min,ansTaro,ansHanako;
  while(1){
    min = 201;
    sum_taro = sum_hanako = 0;
    scanf("%d%d",&n,&m);
    if(n == 0 && m == 0){ break; }
    for(i = 0 ; i < n ; i++){
      scanf("%d",&taro[i]);
      sum_taro += taro[i];
    }
    for(i = 0 ; i < m ; i++){
      scanf("%d",&hanako[i]);
      sum_hanako += hanako[i];
    }

    /* テ・ツ?ィテ」ツ?ヲテ」ツ?ョテ、ツコツ、テヲツ渉崚」ツδ妥」ツつソテ」ツδシテ」ツδウテ」ツつ津ィツ?ε」ツ?暗」ツつ凝」ツ??*/
    for(i = 0 ; i < n ; i++){
      for(j = 0 ; j < m ; j++){
        /* テ」ツ?禿」ツ?禿」ツ?ァテ」ツつォテ」ツδシテ」ツδ嘉」ツつ津、ツコツ、テヲツ渉崚」ツ?療」ツ?淌」ツ?ィテ」ツ?催」ツ?ョテァツつケテヲツ閉ーテ」ツつ津ヲツッツ氾ィツシツε」ツ?凖」ツつ凝」ツ??*/
        if(sum_taro-taro[i]+hanako[j] == sum_hanako-hanako[j]+taro[i]){
          /* テァツュツ氾」ツ?暗」ツ?ッティツ、ツ?ヲツ閉ーテヲツ慊嘉」ツつ甘・ツセツ療」ツつ凝」ツ?ョテ」ツ?ァテ」ツ??」ツ?敕」ツ?ョテ、ツクツュテ」ツ?ァテ、ツコツ、テヲツ渉崚」ツ?療」ツ?淌」ツつォテ」ツδシテ」ツδ嘉」ツ?ョテ・ツ青暗ィツィツ暗・ツ?、テ」ツ??
             テ」ツ?ァテ」ツ?催」ツつ凝」ツ??」ツ?妥・ツーツ湘」ツ?陛」ツ??」ツつづ」ツ?ョテ」ツつ津ヲツ篠。テァツ板ィテ」ツ?凖」ツつ凝」ツ??
           */
          if(taro[i]+hanako[j] < min){
            min = taro[i]+hanako[j];
            ansTaro = taro[i];
            ansHanako = hanako[j];
          }
        }
      }
    }
    /* テヲツ慊?・ツーツ湘・ツ?、テ」ツ?古・ツ按敕」ツつ?」ツ?凝」ツつ嘉・ツ、ツ嘉ヲツ崢エテ」ツ?療」ツ?ェテ」ツ??・ツ?エテ・ツ青暗」ツ?ッテ」ツ?ゥテ」ツ?ョテ」ツつ暗」ツ??」ツ?ェテ、ツコツ、テヲツ渉崚」ツつ津」ツ?療」ツ?ヲテ」ツつづァツつケテヲツ閉ーテ」ツ?古・ツ青古」ツ?佚」ツ?ォテ」ツ?ェテ」ツつ嘉」ツ?ェテ」ツ??」ツ??*/
    if(min == 201){
      printf("-1\n");
    }else{
      printf("%d %d\n",ansTaro,ansHanako);
    }
  }
  return 0;
}

Measured memory_bytes: 612
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int rpar[202020];
int rrank[202020];
int tpar[202020];
int trank[202020];
int n, k, l;

void init(){
  rep(i, n){
    rpar[i] = i;
    rrank[i] = 0;
    tpar[i] = i;
    trank[i] = 0;
  }
}

int rfind(int x){
  if(rpar[x] == x) return x;
  else return rpar[x] = rfind(rpar[x]);
}
int tfind(int x){
  if(tpar[x] == x) return x;
  else return tpar[x] = tfind(tpar[x]);
}

void runit(int x, int y){
  x = rfind(x); y = rfind(y);
  if (x == y) return ;

  if(rrank[x] < rrank[y]) rpar[x] = y;
  else{
    rpar[y] = x;
    if(rrank[x] == rrank[y]) rrank[x]++;
  }
}
void tunit(int x, int y){
  x = tfind(x); y = tfind(y);
  if (x == y) return ;

  if(trank[x] < trank[y]) tpar[x] = y;
  else{
    tpar[y] = x;
    if(trank[x] == trank[y]) trank[x]++;
  }
}

bool rsame(int x, int y){
  return rfind(x) == rfind(y);
}
bool tsame(int x, int y){
  return tfind(x) == tfind(y);
}

int main(){
  cin >> n >> k >> l;
  init();
  int a, b;
  rep(i, k){
    cin >> a >> b;
    runit(a-1, b-1);
  }
  rep(i, l){
    cin >> a >> b;
    tunit(a-1, b-1);
  }
  map <P,int> link;
  rep(i,n) link[mp(tfind(i), rfind(i))]++;
  rep(i,n) cout << link[mp(tfind(i), rfind(i))] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    string k1, k2;
    for(ll i = 0; i < a; i++)
    {
        k1 += b + 48;
    }
    for(ll i = 0; i < b; i++)
    {
        k2 += a + 48;
    }   
    if(k1 == k2)
    {
        cout << k1 << endl;
    }
    else if(k1 > k2)
    {
        cout << k2 << endl;
    }
    else
    {
        cout << k1 << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
  bool b = true;
  string input;
  set<char> s;
  getline(cin, input);
  
  for (int i =0; i < input.size(); i++){
    s.insert(input[i]);
  }
  
  s.size() == 1 ? cout<<"No" : cout<<"Yes" ;

  return 0;
}


Measured memory_bytes: 3632
///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mk make_pair
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl; 
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
// <=================================================================================================================================
// <=================================================================================================================================
int power(int num,int powe){
    int ans=1;

    while(powe>0){
        if(powe&1) ans=(ans%M*num%M)%M;
        num=(num%M*num%M)%M;
        powe>>=1;
    }
    return ans;
}

void fun(){
    int n;cin>>n;
    int ans=(power(10,n)-((2*power(9,n))%M)+power(8,n)+M)%M;
    cout<<ans;
}

signed  main() {
    lets_go

    int t;
    t=1;
    //cin >> t;
    while (t--) {            
         fun();             
    }                        
                            
                            
    return 0;

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int mod=998244353;
int main(){
    ll cnt=0;
    string s;cin>>s;
    rep(i,(s.size()+1)/2){
        if(s[i]!=s[s.size()-1-i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e18;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n, k;
    cin >> n >> k;
    vl a(n+2);
    a[0] = 0;
    for(ll i=1;i<=n;i++){
        cin >> a[i];
    }
    if(k>=10000){
      for (ll i = 1; i <= n;i++){
        cout << n << " ";
      }
      cout << endl;
      return 0;
    }
    vl dp(n + 1, 0);
    rep(i,k){
      for (ll j = 1; j <= n;j++){
        ll in = j - a[j];
        if(in<=0)in = 1;
        ll out = j + a[j]+1;
        if(out>n)out = n + 1;
        dp[in]++;
        dp[out]--;
      }
      ll count = 0;
      for (ll j = 1; j <= n; j++){
        count += dp[j];
        a[j] = count;
        dp[j] = 0;
      }
    }
    for (ll i = 1; i <= n;i++){
      cout << a[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6372
#include <stdio.h>
int main(void){
    int a, h, m, s;
    scanf("%d", &a);
    h = a / 3600;
    m = (a - h*3600)/60;
    s = a - (h*3600 + m*60);
    printf("%d:%d:%d\n", h,m,s);
    return 0;
}



Measured memory_bytes: 2100
import java.lang.Math.pow

//

fun main() {
    abc173c()
}

fun abc173c() {
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    val row = IntArray(h) {0}
    val column = IntArray(w) {0}
    val table = List(h) { CharArray(w) }
    var total = 0
    for (i in 0 until h) {
        var rowCount = 0
        val s = readLine()!!
        for (j in 0 until w) {
            if (s[j] == '#') {
                rowCount++
                column[j]++
                total++
            }
            table[i][j] = s[j]
        }
        row[i] = rowCount
    }
    val rowBit = IntArray(h) {i -> (1 shl i)}
    val colBit = IntArray(w) {i -> (1 shl (h + i))}
    val pattern = ((pow(2.0, h.toDouble())) * (pow(2.0, w.toDouble()))).toInt()
    var count = 0
    for (i in 0 until pattern) {
        var blacks = 0
        val selectedRow = mutableListOf<Int>()
        val selectedCol = mutableListOf<Int>()
        for ((index, r) in rowBit.withIndex()) {
            if (i and r == r) {
                selectedRow.add(index)
                blacks += row[index]
            }
        }
        for ((index, c) in colBit.withIndex()) {
            if (i and c == c) {
                selectedCol.add(index)
                blacks += column[index]
            }
        }
        if (selectedRow.size == 0 || selectedCol.size == 0) {
        } else {
            for (r in selectedRow) {
                for (c in selectedCol) {
                    if (table[r][c] == '#') blacks--
                }
            }
            
        }
        if (total - blacks == k) count++
    }
    println(count)
}


Measured memory_bytes: 40616
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int ans[305][305];
int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    rep(i,h) cin >> v[i];
    vector<int> strb[305];
    rep(i,h) rep(j,w) if(v[i][j]=='#') strb[i].push_back(j);
    
    int now = 1;
    rep(i,h) {
        rep(j,w) {
            if(strb[i].size()==0) continue;
            ans[i][j] = now;
            if(now==k) continue;
            if(v[i][j]=='#') {
                if(strb[i][strb[i].size()-1]>j) now++;
            }
            if(j==w-1) {
                now++;
            }
        }
    }
    rep(i,h-1) {
        rep(j,w) {
            if(strb[i+1].size()==0) {
                ans[i+1][j] = ans[i][j];
            }
        }
    }
    for(int i = h-1; i >= 1; i--) {
        rep(j,w) {
            if(strb[i-1].size()==0) {
                ans[i-1][j] = ans[i][j];
            }
        }
    }
    rep(i,h) {
        rep(j,w) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
n=int(input())
count=[[0 for i in range(10)]for i in range (10)]
ans=0
for i in range(1,(n+1)):
    s=str(i)
    h=int(s[0])
    t=int(s[len(s)-1])
    count[h][t]+=1
for i in range(1,(n+1)):
    s=str(i)
    h=int(s[0])
    t=int(s[len(s)-1])
    ans+=count[t][h]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

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

	ll A, B;
	cin >> A >> B;
	ll g = gcd(A, B);
	ll res = 1;
	for (ll i = 2;i * i <= g;++i) {
		if (g % i == 0) ++res;
		while (g % i == 0) g /= i;
	}
	if (g > 1) ++res;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
    ll A;
    double B;
    cin>>A>>B;
    ll BLL=B*100+0.001;
    cout<<(A*BLL)/100<<endl;
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (auto& x : A) {
		cin >> x;
	}

	for (int i = K; i < N; ++i) {
		if (A[i - K] < A[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 4048
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll W, H, x,y;
    cin>>W>>H>>x>>y;
    long double cx = (long double)W/2;
    long double cy = (long double)H/2;
    bool ans = false;
    if(abs(cx-x)<1e-9 and abs(cy-y)<1e-9) ans = true;
    long double S = (long double)H*W/2.0;
    cout << fixed << setprecision(10) << S << " ";
    if(ans) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
    return 0;
}

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

int main(){
    int cnt = 0;
    int H,A;
    cin>>H>>A;
    while(H>0){
    H-=A;
    cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    input()
    s=list(map(int,input().split()))
    input()
    t=list(map(int,input().split()))
    s=set(s)
    t=set(t)
    print(len(s&t))

main()



Measured memory_bytes: 18688
program main
implicit None
	integer(8)::n,m,i,j,q,r
	integer(8),allocatable::p(:),y(:),a(:),b(:),c(:)
	
	read*,n,m
	allocate(p(m),y(m),a(m),b(m))
	
	do i = 1,m
		read*,p(i),y(i)
		a(i) = i
	enddo
	
	b = p
	call h2(p,a,m)
	p = b
	call h2(p,y,m)
	deallocate(b)
	
	q = 1
	r = 1
	
	do
		do
			if(r+1 > m)exit
			if(p(r+1)/=p(r))exit
			r = r+1
		enddo
		j = r-q+1
		allocate(b(j),c(j))
		b(1:j) = y(q:r)
		c(1:j) = a(q:r)
		call h2(b,c,j)
		do i = 1,j
			b(i) = i
		enddo
		y(q:r) = b(1:j)
		a(q:r) = c(1:j)
		q = r+1
		r = r+1
		deallocate(b,c)
		if(r>m)exit
	enddo
	
!	do i = 1,m
!	print *,p(i),y(i),a(i)
!	enddo
	
	allocate(b(m))
	b = a
	call h2(a,p,m)
	a = b
	call h2(a,y,m)
	
	do i = 1,m
		y(i) = p(i)*1000000+y(i)
	enddo
	
	do i = 1,m
	print"(i12.12)",y(i)
	enddo
	
end program main


subroutine h2(a,b,n)
implicit None
	integer(8)::a(n),b(n),x,y
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);y = b(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie);y = b(ie)
		a(ie) = a(1);b(ie) = b(1)
		a(1) = x;b(1) = y
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h2

Measured memory_bytes: 5104