akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll> > ab(n);
    REP(i, n) scanf("%lld %lld", &ab[i].second, &ab[i].first);
    sort(ab.begin(), ab.end());
    ll time = 0;
    REP(i, n) {
        time += ab[i].second;
        if (time > ab[i].first) {
            OUT("No");
            return 0;
        }
    }
    OUT("Yes");
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int cnt = 0;
  int ans = 0;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  for(int i = 1; i < N; i++){
    if(H.at(i) <= H.at(i - 1)){
      cnt++;
    }
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
#include <climits>
#include <deque>
#include <numeric>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    string S, T; cin >> S >> T;
    int i, ok = 0;
    for (i = S.size() - T.size(); i >= 0; i--) {
        ok = 1;
        for (int j = 0; j < T.size(); j++) {
            if (S[i+j] == T[j] || S[i+j] == '?') {}
            else {
                ok = 0;
                break;
            }
        }
        if (ok) break;
    }
    if (ok) {
        replace(S.begin(), S.end(), '?', 'a');
        copy(T.begin(), T.end(), S.begin() + i);
        cout << S << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}


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

using namespace std;

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

    int a=0,b=0;
    a=N%10;
    b=N/10;

    if(a==9||b==9)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 384
function Main(input) {
  input = input.trim().split('\n');
  K = input[0].split(' ')[1];
  console.log(input[1].split(' ').sort((a,b) => b-a).map(Number).reduce((a,v,i) => i < K ? a : a + v, 0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35744
H, W = gets.split.map(&:to_i)

k, m, r = Array.new(W, 0), Array.new(W, 0), 0
H.times do
  l = 0
  s = gets.chomp
  (0 ... W).each do |j|
    if s[j] == '.'
      if l == 0
        t = j + 1
        while t < W && s[t] == '.'
          t += 1
        end
        l = t - j
      end
      k[j] += 1
      m[j] = l if l > m[j]
    else
      x = k[j] + m[j]
      r = x if x > r
      l = 0
      k[j] = 0
      m[j] = 0
    end
  end
end
(0 ... W).each{|j| x = k[j] + m[j]; r = x if x > r}
puts r - 1

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

int main() {
  int n,a=0,b=0,p=0,d=0;
  cin>>n;
  string s[100010];
  rep(i,n) cin>>s[i];
 rep(i,n){
   if(s[i]=="AC"){
     a++;
   }
   else if(s[i]=="WA"){
     b++;
   }
   else if(s[i]=="TLE"){
     p++;
   }
   else if(s[i]=="RE"){
     d++;
   }
 }
  cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<b<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<p<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<d<<endl;
}
     

Measured memory_bytes: 6752
H,W=map(int,input().split())
while(H>0 and W>0):
    for i in range(H):
        for j in range(W):
            if(i==0 or i==H-1 or j==0 or j==W-1):
                print('#', end='')
            else:
                print(".", end="")
        print()
    print()
    H,W=map(int,input().split())


Measured memory_bytes: 7000
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord
import Control.Monad


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main = do 
    [x,a,b] <- r'
    putStrLn $ if b<=a then "delicious" else if b-a <= x then "safe" else "dangerous"


Measured memory_bytes: 380
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const list = lines[1].split(" ").map(v=>v-0);
    let ans = 0;
    for(let i=0;i<list.length-1;i++){
        ans+=Math.min(list[i],list[i+1])
    }
    ans += list[list.length-1] + list[0];
    console.log(ans);
});


Measured memory_bytes: 30976
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int N, A, B;
	string S;

	cin >> N >> A >> B;
	cin >> S;
	int cnt = 0, cnt_b = 0;
	for(auto c: S){
		bool ans = false;
		if( c == 'a' ){
			if( cnt < A+B ){
				cnt++;
				ans = true;
			}
		}else if( c == 'b' ){
			if( cnt < A+B && cnt_b < B ){
				cnt++;
				cnt_b++;
				ans = true;
			}
		}
		cout << (ans?"Yes":"No") << endl;
	}

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m, v, p;
	cin >> n >> m >> v >> p;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(RALL(a));

	auto is_ok = [&] (ll x) {
		if (a[x] + m < a[p - 1]) return false;
		if (v <= p) return true;
		ll sum = 0;
		for (ll i = p - 1; i < n; i++) {
			if (i == x) continue;
			sum += min(a[x] + m - a[i], m);
		}
		return (sum >= (v - p) * m);
	};

	if (!is_ok(p)) {
		cout << p << endl;
		return 0;
	}
	if (is_ok(n - 1)) {
		cout << n << endl;
		return 0;
	}

	ll ok = p, ng = n - 1;
	while (ok + 1 < ng) {
		ll mid = (ok + ng) / 2;
		if (is_ok(mid)) ok = mid;
		else ng = mid;
	}
	cout << ng << endl;
}

Measured memory_bytes: 3956
def main():
    s = [int(item) for item in input().split()]
    _, _, X, Y = s
    xs = [int(item) for item in input().split()]
    ys = [int(item) for item in input().split()]
    mx = max(xs)
    my = min(ys)
    can = False
    for i in range(mx+1, my+1):
        if X < i <= Y:
            can = True
            break
    if can:
        print('No War')
    else:
        print('War')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
import math
def resolve():
    A,B,C,D=pin()
    E=(C*D)//gcd(C,D)#lcm
    a=[]
    for x in [C,D,E]:
        s=((A-1)%x)+1
        t=(B)%x
        
        a.append((B-A+s-t)//x)
    #print(a)
    print(B-A+1-a[0]-a[1]+a[2])
    
    
#%%submit!
resolve()

Measured memory_bytes: 64620
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool is_same(int x, int y) {
            return find(x) == find(y);
        }

        // CAUTION!! : This method is heavy due to scanning linearly.
        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind fr(n);
    vector<int> dfr(n, 0);
    vector<int> dbr(n, 0);
    int a, b;
    REP(i, m) {
        cin >> a >> b;
        a--; b--;
        fr.unite(a, b);
        dfr[a]++;
        dfr[b]++;
    }
    REP(i, k) {
        cin >> a >> b;
        a--; b--;
        if (fr.is_same(a, b)) {
            dbr[a]++;
            dbr[b]++;
        }
    }

    vi ans(n);
    REP(i, n) {
        ans[i] = fr.size(i) - 1 - dfr[i] - dbr[i];
    }
    printv(ans);
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  int w, h, n;
  cin >> w >> h >> n;
  int x1 = 0, x2 = w, y1 = 0, y2 = h;
  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      chmax(x1, x);
    } else if (a == 2) {
      chmin(x2, x);
    } else if (a == 3) {
      chmax(y1, y);
    } else if (a == 4) {
      chmin(y2, y);
    }
  }

  if (x1 >= x2 || y1 >= y2) puts("0");
  else cout << (x2 - x1) * (y2 - y1) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M = [int(i) for i in input().strip().split()]
    links = [None] * M
    for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

    u = UnionFind(N)
    ans = list()
    x = N * (N - 1) // 2

    for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
    return ans


if __name__ == "__main__":
    for ans in main()[::-1]:
        print(ans)


Measured memory_bytes: 31856
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
//#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n;
   cin>>n;
   if(n/100%10==7 || n/10%10==7 || n%10==7) cout<<"Yes"<<endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 3576
from sys import exit, setrecursionlimit


def get_node_id(i, j, node_id_db):
    if i < j:
        return node_id_db[i][j]
    else:
        return node_id_db[j][i]


def dfs(node_id, edges, dp):
    t = dp[node_id]
    if t >= 0:
        return t
    dp[node_id] = 0
    result = 0
    for n in edges[node_id]:
        t = dfs(n, edges, dp)
        if t == 0:  # looped
            print(-1)
            exit()
        if t > result:
            result = t
    result += 1
    dp[node_id] = result
    return result


def main():
    N = int(input())
    A = [[int(e) - 1 for e in input().split()] for _ in range(N)]

    node_id_db = [[0] * N for _ in range(N)]
    v = 0
    for i in range(N):
        for j in range(i + 1, N):
            node_id_db[i][j] = v
            v += 1

    start_nodes = []
    edges = [[] for _ in range(N * (N - 1) // 2)]
    for i in range(N):
        Ai = A[i]
        from_id = get_node_id(i, Ai[0], node_id_db)
        if i < Ai[0]:
            start_nodes.append(from_id)
        for j in range(1, N - 1):
            to_id = get_node_id(i, Ai[j], node_id_db)
            edges[from_id].append(to_id)
            from_id = to_id

    dp = [-1 for _ in range(N * (N - 1) // 2)]
    print(max(dfs(n, edges, dp) for n in start_nodes))


setrecursionlimit(1000000)
main()


Measured memory_bytes: 138976
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int a[4];
int f(int n){
	a[4]=n%10;
	a[3]=(n/10)%10;
	a[2]=(n/1000)%10;
	a[1]=n/10000;
	if(a[4]==a[1]&&a[2]==a[3])
		return 1;
	else
		return 0;

}
int main(){
	int a,b,sum=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(f(i)){
			sum++;
		}
	}
			printf("%d\n",sum);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
    int a, b, c, tmp;

    cin >> a >> b >> c;

    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }

    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3096
# -*- coding: utf-8 -*-

def main():
  inline = [input() for i in range(1)]
  outline = 0

  try:
    wk_inline = int(inline[0])
  except Exception as e:
    print('整数値を入力してください')
    return 0

  if wk_inline % 2 == 0:
      outline = wk_inline //2 -1
  else:
      outline = wk_inline // 2

  print(outline)
  return 0

main()

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    int u = p[i];
    a[u] = (u + 1) * n;
    b[u] = (n - u) * n + i;
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", a[i], " \n"[i + 1 == n]);
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", b[i], " \n"[i + 1 == n]);
  }

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define VI vector<ll>
#define int long long
using namespace std;

#define INF 1e18
using P = pair<int, int>; // (distance, v)
struct edge {
  int to;
  int cost;
};
vector<int> dijkstra(vector<vector<edge>>& G, int start) {
  priority_queue<P, vector<P>, greater<P>> que;
  vector<int> d = vector<int>(G.size(), INF);
  d[start] = 0;
  que.push(P(0, start));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) { continue; }
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[v] + e.cost < d[e.to]) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  return d;
}

signed main() {
  int money = 1e15;
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  vector<vector<edge>> G1(n);
  vector<vector<edge>> G2(n);
  REP (i, m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    G1[u].push_back({v, a});
    G1[v].push_back({u, a});
    G2[u].push_back({v, b});
    G2[v].push_back({u, b});
  }

  vector<int> d1(dijkstra(G1, s));
  vector<int> d2(dijkstra(G2, t));

  vector<int> ans(n+1);
  ans[n] = 0;
  for (int i = n-1; i >= 0; i--) {
    ans[i] = max(ans[i+1], money - (d1[i] + d2[i]));
  }

  REP (i, n) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 19012
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools

def input():
    return sys.stdin.readline()


def resolve():
    n, m, q = map(int, input().split())
    a_d_list = []
    for i in range(q):
        a_d_list.append(list(map(int,input().split())))

    l = [i for i in range(1, m+1)]
    combi_list = list(itertools.combinations_with_replacement(l, n))

    ans_dic = {}
    for combi in combi_list:
        ans_dic[str(combi)] = 0

    for combi in combi_list:

        for i, a_d in enumerate(a_d_list):
            a = a_d[0]
            b = a_d[1]
            c = a_d[2]
            d = a_d[3]

            if combi[b-1] - combi[a-1] == c:

                ans_dic[str(combi)] += d


    print(max(ans_dic.values()))





if __name__ == "__main__":
    resolve()



Measured memory_bytes: 101632
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cmath>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e3+5;
char a[N], b[N];
int n, t, f[N], g[N], p[N], q[N], vis[N], ans;
bool cmpf(int i, int j) { return f[i] < f[j]; }
bool cmpg(int i, int j) { return g[i] < g[j]; }
int main()
{
    scanf("%s%s", a, b), n = strlen(a), g[n] = -1, f[0] = (b[0] == '1')-1, ans = n<<4;
    for(int i = 0; a[i] == b[i]; ++i) if(i == n-1) return puts("0"), 0;
    for(int i = 1; i < n; ++i) if(b[i] == '1') f[i] = i; else f[i] = f[i-1];
    for(int i = n-1; ~i; --i) if(b[i] == '1') g[i] = i; else g[i] = g[i+1];
    if(f[n-1] == -1) return puts("-1"), 0;
    for(int i = 0; i < n; ++i) f[i] = f[i] == -1?n-f[n-1]+i:i-f[i], g[i] = g[i] == -1?g[0]+n-i:g[i]-i;
    for(int i = 0; i < n; ++i)
    {
        int t = 0;
        for(int j = 0; j < n; vis[j] = 0, ++j) if(a[(i+j)%n] != b[j]) p[++t] = (i+j)%n, q[t] = (i+j)%n;
        sort(p+1, p+1+t, cmpf), sort(q+1, q+1+t, cmpg);
        for(int j = t, k = 0; ~j;--j)
        {
            int a = j?f[p[j]]:0, b = k?g[q[k]]:0;
            ans = min(min(b*2+abs(i-a)+a, a*2+abs(n-i-b)+b)+t, ans);
            for( ++k; !vis[p[j]]; ++k) vis[q[k]] = 1; --k;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  int count = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = 1; j < N; j++){
      if(i >= j) continue;
      for(int k = 2; k < N; k++){
        if(j >= k) continue;
        vector<int> vec(3);
        vec.at(0) = L.at(i);
        vec.at(1) = L.at(j);
        vec.at(2) = L.at(k);
        
        sort(vec.begin(), vec.end());
        if(vec.at(0) == vec.at(1) || vec.at(1) == vec.at(2)) continue;
        
        if(vec.at(0) < vec.at(1) + vec.at(2)){
          if(vec.at(1) < vec.at(2) + vec.at(0)){
            if(vec.at(2) < vec.at(0) + vec.at(1)){
              count++;
            }
          }
        }
        
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

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

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}


int main() {
	ll N, M;
	cin >> N >> M;

	multiset<ll> A;

	rep(i, N) {
		ll a;
		cin >> a;
		A.insert(a);
	}

	rep(i, M) {
		auto it = A.end();
		it--;
		ll tmp = *it;
		tmp /= 2;
		A.erase(it);
		A.insert(tmp);
	}

	ll sum = 0;
	for (auto itr = A.begin(); itr != A.end(); ++itr) {
		sum += *itr;
	}
	cout << sum << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a[100005] = {}, ans = 1;
  cin >> n;
  rep(i, 0, n) {
    int x;
    cin >> x;
    a[x]++;
  }
  if(n % 2) {
    if(a[0] != 1) {
      cout << 0 << endl;
      return 0;
    }
    for(int i = 2; i < n; i += 2) {
      if(a[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
  }else {
    for(int i = 1; i < n; i += 2) {
      if(a[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  rep(i, 0, n / 2) {
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. 132B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP  PIC X(60).
01 N    PIC 9(2).
01 TBL.
   03 P PIC 9(2) OCCURS 20.
01 P1   PIC 9(2).
01 P2   PIC 9(2).
01 I    PIC 9(2).
01 K    PIC 9(2).
01 OUT  PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
*>
    MOVE INP(P1:P2 - P1) TO P(I) 
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE 0 TO K.
  PERFORM VARYING I FROM 2 BY 1 UNTIL I >= N
   IF (P(I - 1) < P(I) AND P(I) < P(I + 1)) OR
      (P(I - 1) > P(I) AND P(I) > P(I + 1))
     ADD 1 TO K
    END-IF
  END-PERFORM.
*>
  MOVE K TO OUT.
  DISPLAY OUT.
*>
  STOP RUN.


Measured memory_bytes: 636
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){

	ll t[5];
	ll r[5];
	ll max=0;
	for(ll i=0;i<5;i++){
		cin>>t[i];
		for(ll j=0;j<10;j++){
			if((t[i]+j)%10==0){
				r[i]=t[i]+j;
			}
		}
	}

	for(ll i=0;i<5;i++){
		if(max<(r[i]-t[i])){
			max=r[i]-t[i];
		}
	}

	ll ans=0;
	for(ll i=0;i<5;i++){
		ans+=r[i];
	}
	ans-=max;

	cout<<ans<<endl;


	
}


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, y, z;
    cin >> x >> y >> z;
    x -= z * 2;
    int cnt = 0;

    while( x >= y ) {
        x -= y;
        ++cnt;
        x -= z;
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;
typedef pair<int, P> P_P;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループのノード数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};

int main()
{
    int N;
    cin >> N;
    UnionFind Uni(N);
    vector<P> xpair(N), ypair(N);
    for(int i=0; i<N; i++){
        int x,y;
        cin >> x >> y;
        xpair[i]=make_pair(x, i);
        ypair[i]=make_pair(y, i);
    }

    sort(xpair.begin(), xpair.end());
    sort(ypair.begin(), ypair.end());

    vector<P_P> rootlist(2*N-2);
    for(int i=0; i<N-1; i++){
        rootlist[2*i]=make_pair(xpair[i+1].first-xpair[i].first, P(xpair[i+1].second, xpair[i].second));
        rootlist[2*i+1]=make_pair(ypair[i+1].first-ypair[i].first, P(ypair[i+1].second, ypair[i].second));
    }
    sort(rootlist.begin(), rootlist.end());

    ll ans=0;
    for(int i=0; i<2*N-2; i++){
        if(Uni.connect(rootlist[i].second.first, rootlist[i].second.second)){
            ans+=rootlist[i].first;
        }
    }





    cout << ans << endl;

    return 0;
}


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

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

  vector<int> s(n - 1);
  for (int i = 0; i < n - 1; i++) {
    int s1, s2;
    s1 = s2 = 0;
    for (int j = 0; j <= i; j++) {
      s1 += w[j];
    }
    for (int l = i + 1; l < n; l++) {
      s2 += w[l];
    }
    s[i] = abs(s1 - s2);
  }

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

  cout << s[0] << endl;
};


Measured memory_bytes: 256
from math import sqrt


def prime_factorize(n):
    result = []
    for i in range(2, int(sqrt(n)) + 1):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


N = int(input())

t = [0] * (N + 1)
for i in range(2, N + 1):
    for p, c in prime_factorize(i):
        t[p] += c

result = 1
for i in range(2, N + 1):
    if t[i] == 0:
        continue
    result = result * (t[i] + 1) % 1000000007
print(result)


Measured memory_bytes: 3064
/********************************************//**
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
//fix the sqrt (int) (sqrt(n) + 1e-9)
#define endline "\n"
const ll INF = 1e18L + 5;
const int inf = 1e9 + 5;
typedef pair<double, long> key;
struct comp {
	bool operator()(pair<int, int> p1, pair<int, int> p2) {
		if (p1.first < p2.first) return false;
		if (p2.first < p1.first) return true;
		return p1.second < p2.second;
	};
};
//greater<pair<int,int> , greater<int>>

// vector<int> graph[N];
// vector<int> weight(N);
// void dfs(int node, int parent)
// {
// 	for (int to : graph[node]) {
// 		if (to == parent)
// 			continue;
// 		dfs(to, node);
// 		weight[node] += weight[to];
// 	}
// }
// bool prime(int n) {
// 	if (n <= 1)
// 		return false;
// 	for (int i = 2; i < n; i++)
// 		if (n % i == 0)
// 			return false;
// 	return true;
// }

vector<int> graph[M];
int n , m;
bool visited[M];

int DFSrec(int s) {
	int count = 0;
	visited[s] = true;
	count += 1;
	for (int i = 0; i < graph[s].size(); i++) {
		if (visited[graph[s][i]] == false) {
			count += DFSrec(graph[s][i]);
		}
	}
	return count;
}
int main() {
	int test = 1;
	//cin >> test;
	while (test--) {
		cin  >> n >> m;
		for (int i = 0; i < m; i++) {
			int x , y;
			cin >> x >> y;
			graph[x].pb(y);
			graph[y].pb(x);
		}
		int ans = 0;
		for (int i = 0; i <= n; i++) visited[i] = false;
		for (int i = 1; i <= n ; i++) {
			if (visited[i] == false) {
				int count = DFSrec(i);
				ans = max(ans , count);
			}
		}
		// for (int i = 1; i <= n ; i++) {
		// 	if (visited[i] == false) {
		// 		int count = 0;
		// 		queue<int> q;
		// 		q.push(i);
		// 		count++;
		// 		visited[i] = true;
		// 		while (q.empty() == false) {
		// 			int c = q.front();
		// 			q.pop();
		// 			for (int j = 0; j < graph[c].size(); j++) {
		// 				if (visited[graph[c][j]] == false) {
		// 					visited[graph[c][j]] = true;
		// 					q.push(graph[c][j]);
		// 					count++;
		// 				}
		// 			}
		// 		}
		// 		ans = max(ans , count);
		// 	}
		// }
		cout << ans << endl;
	}
	return 0;
}

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

int main(){

    int cnt=0;
    string s,t;
    cin>>s>>t;
    if(s.at(0)==t.at(0))cnt++;
    if(s.at(1)==t.at(1))cnt++;
    if(s.at(2)==t.at(2))cnt++;

    cout<<cnt<<endl;


    return 0;
}

Measured memory_bytes: 256
/* DSL1_A: Disjoint Set */

#include <iostream>
#include <cstdio>

int *parents;
int *ranks;

int find(int x) {
    if (parents[x] == x)
        return x;
    else
        return parents[x] = find( parents[x] );
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if ( ranks[x] < ranks[y] ) {
        parents[x] = y;
    }
    else if ( ranks[y] < ranks[x] ) {
        parents[y] = x;
    }
    else if (x != y) {
        parents[x] = y;
        ranks[y] += 1;
    }
}

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    parents = new int[n];
    ranks   = new int[n];
    for (int i = 0; i < n; i++) {
        parents[i] = i;
        ranks[i]   = 0;
    }

    int command, x, y;
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d\n", &command, &x, &y);
        switch (command) {
            case 0:
                unite(x, y);
                break;
            case 1:
                printf("%d\n", find(x) == find(y) );
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 1268
import java.io.IOException;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Map<String, Integer> memo = new TreeMap<String, Integer>(
				new Comparator<String>() {

					@Override
					public int compare(String o1, String o2) {
						if (o1.length() == o2.length())
							return o1.compareTo(o2);
						return o1.length() - o2.length();
					}
				});
		for (int i = 0; i < n; i++) {
			String s = scanner.next();
			int a = scanner.nextInt();
			if (memo.containsKey(s))
				memo.put(s, memo.get(s) + a);
			else
				memo.put(s, a);
		}
		for (Entry<String, Integer> entry : memo.entrySet()) {
			System.out.println(entry.getKey() + " " + entry.getValue());
		}
	}
}

Measured memory_bytes: 38272
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    int i = 0, k = 1, cnt = 0;
    bool yes = false;
    rep(i,n) {
        if (b[i] == k) {
            k++;
            yes = true;
        }
        else if (b[i] != k) {
            cnt++;
        }
    }
    if (yes) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<int, int> n;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    if (n.find(A) == n.end()) n[A] = 0;
    ++n[A];
  }
  vector<int> vec;
  for (const auto& x : n) {
    if (x.second >= 4) vec.push_back(x.first);
    if (x.second >= 2) vec.push_back(x.first);
  }
  sort(vec.rbegin(), vec.rend());
  if (vec.size() < 2) {
    cout << 0 << endl;
  } else {
    cout << (int64_t)vec[0] * vec[1] << endl;
  }
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
 int a, b ;
  cin >> a >> b ; 
  
  cout << a * b ;
  
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////////
ll mypow_core(ll x, int n, ll result) {
  if (n == 0) {
    return result;
  }

  if (n % 2 == 0) {
    return mypow_core(x * x, n / 2, result);
  }
  else {
    return mypow_core(x, n - 1, x * result);
  }
}

ll mypow(ll x, int n) {
  return mypow_core(x, n, 1);
}
/////////////////////////////////////////////////////////////

ll n, k;

double ans;

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &k);

  for (ll i = 1; i <= n; ++i) {
    ll kdivi = k / i;
    ll around = log2(kdivi);

    ll times;

    for (ll j = around; j <= around + 1; ++j) {
      if (i * mypow(2, j) >= k) {
        times = j;
        break;
      }
    }

    double bottom = mypow(2, times);

    ans += 1.0 / bottom;
  }

  ans /= (double)(n);

  printf("%.10lf\n", ans);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct node{
	int a1,b1;
}a[6];
int c[4];
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	
	for(i=1; i<=m; i++)
		cin>>a[i].a1>>a[i].b1;
	for(i=1; i<=m; i++)
	{
		for(j=1; j<i; j++)
			if(a[i].a1==a[j].a1)
				if(a[i].b1!=a[j].b1)
				{
					cout<<"-1";
					return 0;
				}
		if(a[i].a1==1 && a[i].b1==0 && n!=1)
		{
			cout<<"-1";
			return 0;
		}
		c[a[i].a1]=a[i].b1;
	}
	if(c[1]==0 && n!=1)
		c[1]=1;
	for(i=1; i<=n; i++)
		cout<<c[i];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,n,counta=0,countb=0;
	string s;
	cin>>n>>a>>b>>s;
	string* ans=new string[n];
	a+=b;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='c')
		{
			ans[i]="No";
			continue;
		}
		else if(s[i]=='a')
		{
			if(counta<a)
			{
				counta++;
				ans[i]="Yes";
				continue;
			}
			else
			{
				ans[i]="No";
				continue;
			}
		}
		else
		{
			if(counta<a&&countb<b)
			{
				counta++;countb++;
				ans[i]="Yes";
				continue;
			}
			else
			{
				ans[i]="No";
				continue;
			}
		}
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c; cin >> a >> b >> c;
  cout << (a == b && b == c ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		if (n.charAt(0) == n.charAt(n.length() - 1))
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int n;
	int a,b,c;
	cin>>n;
	a=0;
	for(int i=0;i<n;i++){
		cin>>b;
		a^=b;
	}
	print_Yes_No(a==0);
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=100000000;
#define F first
#define S second
char hw[55][55];int d[55][55];
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
queue<P> Q;
int main(void){
    for(int i=0;i<55;i++){
        for(int j=0;j<55;j++){
            if(i==1&&j==1)d[i][j]=0;
            else d[i][j]=INF;
        }
    }
    int h,w,cnt=0;cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>hw[i][j];
            if(hw[i][j]=='.')cnt++;
        }
    }
    Q.push(P(1,1));
    while(!Q.empty()){
        P p=Q.front();Q.pop();
        if(p.F==h&&p.S==w)break;
        for(int i=0;i<4;i++){
            int x=p.F+dx[i],y=p.S+dy[i];
            if(hw[x][y]=='.'&&d[x][y]==INF){
                Q.push(P(x,y));
                d[x][y]=d[p.F][p.S]+1;
            }
        }
    }
    if(d[h][w]==INF){
        cout<<-1<<endl;return 0;
    }else{
        cout<<cnt-d[h][w]-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!python3

from time import perf_counter
tick = perf_counter() + 1.92

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from random import randrange
from bisect import bisect

def resolve():
    G = 26
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(G)]
    S = [[next(it) for i in range(G)] for i in range(D)]
    L = [[-1] for i in range(G)]
    T = [0] * D

    def update(di, qi):

        score = 0
        t0 = T[di]
        score += S[di][qi]-S[di][t0]

        a1 = li = L[t0][:]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.pop(ii)

        a2 = li = L[qi][:]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        return score, (a1, a2)

    U = 7
    def calc(i, j):
        score = S[i][j]
        for k in range(G):
            u = k - L[k][-1]
            score -= C[k] * (u + u + U) * U // 2
        score += C[k] * U * (i-L[j][-1])
        return score

    for di in range(D):
        i, score = 0, calc(di, 0)
        for qi in range(1, G):
            x = calc(di, qi)
            if x > score:
                i, score = qi, x
        T[di] = i
        L[i].append(di)

    while perf_counter() < tick:
        di, qi = randrange(0, D), randrange(0, G)
        diff, swap = update(di, qi)
        if diff > 0:
            score += diff
            q0, T[di] = T[di], qi
            L[q0], L[qi] = swap

    print(*(i+1 for i in T), sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 90612
n=int(input())
point=[]
for i in range(n):
    a,b=map(int,input().split())
    point.append((b,a,0))
for i in range(n):
    a,b=map(int,input().split())
    point.append((b,a,1))
point.sort()
stock=[]
ans=0
for p in point:
    if p[2]==0:
        stock.append(p)
    else:
        if stock==[]:
            pass
        else:
            I=-1
            D=300
            for i in range(len(stock)):
                if stock[i][1]<p[1]:
                    if p[1]-stock[i][1]<D:
                        D=p[1]-stock[i][1]
                        I=i
            if I==-1:
                pass
            else:
                ans=ans+1
                del stock[I]
print(ans)


Measured memory_bytes: 38768