akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

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

	vector<int>cnts(N);
	int max_cnt = 0;

	for (int i = 1; i <= N; i++)
	{
		int x = i;
		int cnt = 0;
		while (x < K)
		{
			x *= 2;
			cnt++;
		}

		cnts[i - 1] = cnt;
		max_cnt = max(max_cnt, cnt);
	}

	double ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += (1 << max_cnt - cnts[i]);
	}
	ans /= (1 << max_cnt);
	ans /= N;

	cout << fixed << setprecision(10) << ans << endl;


	return 0;
}

Measured memory_bytes: 640
/**
*    created: 05.07.2020 17:10:30
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
def solve(string):
    ans = 0
    i = 0
    while i < len(string):
        j = 0
        while i + j < len(string) and string[i + j] in "ATGC":
            j += 1
        ans = max(ans, j)
        i += j + 1
    return str(ans)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define f(n) for(int i=0;i<n;i++)
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define OJ \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
	int n,e;
	cin>>n;
	vi a,r={0};
	for(int i=0;i<n;i++) cin>>e,a.emplace_back(e);
	r.emplace_back(abs(a[0]-a[1]));
	for(int i=2;i<n;i++)  r.emplace_back(min(r[i-2]+abs(a[i]-a[i-2]),r[i-1]+abs(a[i-1]-a[i])));
	cout<<r[n-1];

}

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

	// OJ;

	// clock_t start,stop;
	// start=clock();
	int t = 1;
	// cin >> t;
	while(t--) {
	  solve();
	}
	// stop=clock();
	// cout<<endl<<stop-start<<"ms";

	return 0;
}

Measured memory_bytes: 4264
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,x[100010],y[100010];
char s[5];
L p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	L k,l,u;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  {
	   if(i>1)
	     {
		  scanf("%s",s);
		  if(s[0]=='-')
		    y[i]=1;
		 }
	   scanf("%d",&x[i]);
	  }
	p=1e18;
	for(i=1,j=0,k=0,l=0,u=0;i<=n;i++)
	  {
	   if(y[i])
	     {
	      if(!j)
	        j=1,k=0;
	      else
	        p=min(p,k+l),k=0;
	      l+=u;
	      u=x[i];
		 }
	   k+=x[i];
	  }
	if(j)
	  p=min(p,k+l);
	if(p>1e17)
	  p=0;
	else
	  p*=-2;
	for(i=1;i<=n;i++)
	  p+=x[i];
	printf("%lld\n",p);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n; std::vector<int> a(n);
    rep(i,n) cin >> a[i];
    int m=0;

    std::vector<int> ans(n+1,0);

    for(int i=n;i>0; --i){

        int multiples_num = 0, k=i*2;

        while(k<=n){
            if(ans[k]==1){
                multiples_num++;
            }
            k+=i;
        }

        ans[i] = (multiples_num%2)^a[i-1];
    }

    rep(i,n+1){
        if(ans[i]==1) m++;
    }
    cout << m << endl;
    if(m==0) return 0;


    rep(i,n+1){
        if(ans[i] == 1) cout << i << ' ';
    }
    cout << '\n';
    
    return 0;
}

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

string W, T;
int c, n;

int main() {
    cin >> W;
    W = " " + W + " ";
    while (true) {
        cin >> T;
        if (T == "END_OF_TEXT") break;
         T = " " + T + " ";
        int x = T.length();
        for (int i=0; i<x; i++) {
            if (T[i]>=65 && T[i]<=90) T[i]+=32;
        }
        for (int i=0; i<x; i++){
            n = T.find(W);
            if (n != -1) {
                c++;
                i=n+W.length();
            }
            else i = x;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#define MAX_N 100
#define MAX_T 200
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;
 
int main(){
  int n,ans;
  int a[100001]={};
  cin>>n;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    a[temp]++;
  }
  ans=0;
  for(int i=1;i<100000;i++){
    ans=max(ans, a[i-1]+a[i]+a[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(a%2==0){
      if(a%3!=0 && a%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int H, W, i, j;
	
	while(1){
		scanf("%d %d", &H, &W);
		
		if(H == 0 && W == 0)break;
		
		for(i = 0; i < H ;i++){
			for(j = 0; j < W ;j++){
				if((i+j) % 2 == 0)
				putchar('#');
				else
				putchar('.');
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}";}
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "<<arg1<<endl;}
template<typename Arg1, typename ... Args>void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,','); cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif

const int N =3e5+50;
int v[N];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
	
	int n; cin >> n;
	//vi v(n);
	int cur =1 ;
	int cnt = 0;
	for(int i=1 ; i<=n ;++i){
		cin>>v[i];
		if(v[i]==cur) { cur++; cnt++;}
	}
	if(cnt == 0 )cout<<-1;
	else cout<< n -cnt ;
	
    
    

#ifdef np
    cerr <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
 return 0; 
 }


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <iostream> 
#include <vector>
#include <utility>
#include <stack>
using namespace std;

#define FOR(i,m,n)  for(int i = m; i < n; i++)
#define ITR(a)  for (auto itr = a.begin(); itr != a.end(); itr++)


int n, m;
vector<pair<int, int>> num;
int ans = 0;

int main() {


    cin >> n >> m;

    FOR(i, 0, m) {    
        pair<int, int> temp;
        cin >> temp.first >> temp.second;
        num.push_back(temp);
    }





    FOR(i, 0, m) {
        vector<bool> side(n,true);
        side[0] = false;
        int count = 1;
        stack<int> st;
        st.push(1);
        while (!st.empty()) {
            int temp = st.top();
            st.pop();
            FOR(j, 0, m) {
                if (j != i) {
                    if ((temp == num[j].first) && (side[num[j].second - 1])) {
                        side[num[j].second - 1] = false;
                        st.push(num[j].second);
                        count++;
                    }
                    else if ((temp == num[j].second) && (side[num[j].first - 1])) {
                        side[num[j].first - 1] = false;
                        st.push(num[j].first);
                        count++;
                    }

                }
            }
        }
        if (count != n)  ans++;
    }
    


    cout << ans << endl;



    return 0;

}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parsing")
}

fn pair(x: usize) -> (usize, usize) {
  let a: usize = x % 10;
  let b: usize = x
    .to_string()
    .chars()
    .nth(0)
    .unwrap()
    .to_string()
    .parse::<usize>()
    .unwrap();
  (a, b)
}

fn main() {
  let n: usize = read::<usize>();

  let mut freq: HashMap<(usize, usize), usize> = HashMap::new();

  for i in 1..(n + 1) {
    let p = pair(i);
    freq.entry(p).or_insert(0);
    let count = freq.get(&p).unwrap() + 1;
    freq.insert(p, count);
  }

  let mut ans: usize = 0;

  for i in 1..(n + 1) {
    let p = pair(i);
    let q = (p.1, p.0);
    match freq.get(&q) {
      Some(n) => {
        ans = ans + n;
      }
      None => {}
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
n, k = [int(i) for i in input().split()]
sushi = [[int(i) for i in input().split()] for _ in range(n)]
sushi.sort(key=lambda x: x[1], reverse=True)

#print(sushi)

num = 0
kind = set()
changable = []

for i in range(k):
    num += sushi[i][1]
    if sushi[i][0] in kind:
        changable.append(sushi[i][1])
    else:
        kind.add(sushi[i][0])

#print(kind)
#print(changable)

num += len(kind) ** 2
ans = num

for i in range(k, n):
    if not changable:
        break

    if sushi[i][0] not in kind:
        num += sushi[i][1] + 2 * len(kind) + 1 - changable.pop()
        kind.add(sushi[i][0])
        ans = max(ans, num)

print(ans)

Measured memory_bytes: 23908
#include "bits/stdc++.h"

using namespace std;
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; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
ll a[100010][3];

ll dp[100010][3];

int main(void){
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++) cin>>a[i][j];

	for(int i=0;i<n;i++) {	
		for(int j=0;j<3;j++) {
			for(int k=0;k<3;k++) {
				if(j == k) continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}

	ll res = 0;
	for(int j=0;j<3;j++) chmax(res, dp[n][j]);

	cout<< res <<endl;

	return 0;
}

Measured memory_bytes: 4992
def solve2(arr)
  ans = { }
  ans[[0, 0]] = true
  limit = arr.inject(0) { |s, e| s + e}
  arr.each_with_index do |elem, ind|
    (0..limit).each do |sum|
      ans[[ind + 1, sum]] = (ans[[ind, sum]] or ans[[ind, sum - elem]])                                                                                                                                              
    end
  end
  ans  
end

def main2
  n = gets.chomp.to_i
  arr = gets.chomp.split(/\s/).collect { |x| x.to_i}
  q = gets.chomp.to_i
  questions = gets.chomp.split(/\s/).collect { |x| x.to_i}
  ans = solve2(arr)
  questions.each do |question|
    if ans[[arr.size, question]]
      puts "yes"
    else
      puts "no"
    end
  end  
end

main2

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

#define int long long

typedef pair <int, int> pii;

const int N = 1e5 + 10;
int n, cnt[N], par[N], sum[N], mark[N];
pii ar[N];
map <int, int> mp;
vector <int> ch[N];

void dfs(int v) {
	mark[v] = 1;
	for (int i : ch[v]) {
		dfs(i);
		sum[v] += sum[i] + cnt[i];
	}
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	fill(cnt, cnt + N, 1);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i].first;
		ar[i].second = i;
		mp[ar[i].first] = i;
	}
	sort(ar, ar + n);
	
	for (int i = n - 1; i > 0; i--) {
		int v = ar[i].second;
		int nd = ar[i].first - n + 2 * cnt[v];
		if (mp.find(nd) == mp.end() || 2 * cnt[v] > n)
			return cout << -1, 0;
		
		int p = mp[nd];
		ch[p].push_back(v);
		par[v] = p;
		cnt[p] += cnt[v];
	}
	
	dfs(ar[0].second);
	if (sum[ar[0].second] != ar[0].first)
		return cout << -1, 0;
	
	for (int i = 0; i < n; i++)
		if (!mark[i])
			return cout << -1, 0;
	
	for (int i = 0; i < n; i++)
		if (i != ar[0].second)
			cout << i + 1 << " " << par[i] + 1 << '\n';
}

Measured memory_bytes: 20224
# ABC 059: B – Comparison
a, b = [input() for _ in range(2)]

if len(a) > len(b):
    print('GREATER')
elif len(a) < len(b):
    print('LESS')
else:
    if a > b:
        print('GREATER')
    elif a < b:
        print('LESS')
    else:
        print('EQUAL')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=3005,mod=1e9+7;
int n,q;
int a[N];
int x[N],y[N];
int inv2=(mod+1)/2;
int dp[N][N],tmp[N];
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1)
			ans=1LL*ans*x%mod;
	return ans;
}
int main(){
	n=read(),q=read();
	for (int i=1;i<=n;i++)
		a[i]=read();
	memset(dp,0,sizeof dp);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			dp[i][j]=a[i]<a[j]?1:0;
	for (int t=1;t<=q;t++){
		int a=read(),b=read();
		if (a==b)
			continue;
		if (a>b)
			swap(a,b);
		for (int i=1;i<=n;i++){
			if (i==a||i==b)
				continue;
			dp[i][a]=dp[i][b]=(LL)inv2*(dp[i][a]+dp[i][b])%mod;
			dp[a][i]=dp[b][i]=(LL)inv2*(dp[a][i]+dp[b][i])%mod;
		}
		dp[a][b]=dp[b][a]=(LL)inv2*(dp[a][b]+dp[b][a])%mod;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<i;j++)
			ans=(ans+dp[i][j])%mod;
	ans=(LL)ans*Pow(2,q)%mod;
	cout << ans;
	return 0;
}

Measured memory_bytes: 35584
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
edges = [inpl() for _ in range(m)]
res = 0
for ind in range(m):
    e = [[] for _ in range(n)]
    for i,(a,b) in enumerate(edges):
        if i == ind: continue
        e[a-1].append(b-1)
        e[b-1].append(a-1)
    seen = [False]*n
    cnt = 0
    for i in range(n):
        if seen[i]: continue    
        q = deque([])
        q.append(i)
        cnt += 1
        while q:
            now = q.popleft()
            if seen[now]: continue
            seen[now] = True
            for nx in e[now]:
                if seen[nx]: continue
                q.append(nx)
    if cnt != 1:
        res += 1
print(res)

Measured memory_bytes: 77876
N,M,X,Y = gets.split.map(&:to_i)
max_x = gets.split.map(&:to_i).max
min_y = gets.split.map(&:to_i).min
war = true
(-100..100).each do |z|
  if (X < z && z <= Y) && max_x < z && min_y >= z
    war = false
  end
end

puts war ? 'War' : 'No War'

Measured memory_bytes: 1788
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        string s = sc.Next();
        int min = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            cnt += s[i] == '(' ? 1 : -1;
            min = Math.Min(min, cnt);
        }


        int f = Math.Max(0, -min);

        int b = cnt + f;

        Console.WriteLine($"{new string('(', f)}{s}{new string(')', b)}");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.length();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
typedef long long ll; typedef long double db;

string str[6] = { "dreameraser","dreamerase","dream","dreamer","erase","eraser" };
string c;
bool judge(int i, int j, int f)
{
	int cnt = 0;
	for (int k = i; k < j; ++k)
	{
		if (c[k] != str[f][cnt++]) return 0;
	}
	return 1;
}
bool solve()
{
	int len = (int)c.size();
	int i = 0;
	while (i < len)
	{
		if (judge(i, i + 11, 0)) i += 11;
		else if (judge(i, i + 10, 1)) i += 10;
		else if (judge(i, i + 7, 3)) i += 7;
		else if (judge(i, i + 5, 2)) i += 5;
		else if (judge(i, i + 6, 5)) i += 6;
		else if (judge(i, i + 5, 4)) i += 5;
		else return 0;
	}
	return 1;
}

int main()
{
	cin >> c;
	if (solve()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int maxn=753;
    int ans=INT_MAX,num;
    for(int i=0;i<=n-3;i++)
    {
        num=100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
        ans=min(ans,abs(maxn-num));
        
    }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K; cin >> N >> K;
    int cnt = 0;
    for (int i = 1; i <= N; i += 2){
        cnt++;
    }
    YES((cnt >= K));
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s, t;
    cin >> s >> t;

    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));

    Yn(s < t)

}

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


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

  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> v;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    v.pb({a,b});
  }
  sort(v.begin(),v.end());

  priority_queue<int> q;
  int ind = 0;
  ll ans=0;
  rep1(i,m){
    
    while(ind<n && v[ind].first<=i){
      q.push(v[ind].second);
      ind++;
    }
    if(!q.empty()){
      ans += q.top();q.pop();
    }
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 1908
def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = {i: 0 for i in range(10 ** 5 + 1)}
    for i in range(n):
        count[a[i]] += 1
    answer = 0
    for i in range(1, 10 ** 5):
        answer = max(answer, count[i - 1] + count[i] + count[i + 1])
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 20472
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    
    if(A>C){
        if(B<C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    }else{
        if(B>C){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
    }
    }
    
    return 0;
}



Measured memory_bytes: 256
a,b,c=map(int,input().split())
k=int(input())

ans=0

while(1):
    if(b<=a):
        b=b*2
        ans+=1
    else:
        break
while(1):
    if(c<=b):
        c=c*2
        ans+=1
    else:
        break    
        
if(ans > k):
    print('No')
else:
    print('Yes') 

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

void solve()
{
    int n;
    cin >> n;
    int cost = 0;
    while(cost < n)
        cost += 1000;
    cout << cost-n << endl;
}


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


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e15;

void chmin( ll &a, ll b){ if( a > b){ swap(a,b); } return ;}

int main(){
  
  ll N,M; cin >> N >> M;
  
  ll dp[1010][(1<<15)];
  for(ll i = 0; i < 1010; i++){
    for(ll j = 0; j < (1<<15); j++){
      dp[i][j] = inf;
    }
  }
  
  vector<ll> key(M+1,0); vector<ll> a(M+1,0); 
  
  for(ll i = 0; i < M; i++){
    ll b; cin >> a[i+1] >> b;
    ll res = 0;
    for(ll t = 0; t < b; t++){
      ll c; cin >> c; res |= 1 << (c-1);
    }
    
    key[i+1] = res;
    
    dp[i+1][res] = a[i+1];
  }
  
  //何も鍵を使わない状況を表すために、keyもdpも1-indexedである
  
  dp[0][0] = 0; //何も鍵を使わず、何も開けない時のコストは明らかに0
      
  for(ll i = 1; i < M; i++){
    for(ll j = 0; j < (1<<N); j++){
      if( dp[i][j] == inf){ continue;}
      
      chmin( dp[i+1][j], dp[i][j]); //i+1番目の鍵を使わない時
      
      chmin( dp[i+1][j|key[i+1]], dp[i][j]+a[i+1]);
      //i+1番目の鍵を使った時
    }
  }
  
  ll res = dp[M][(1<<N)-1];
  if( res == inf){ cout << -1 << endl; }
  else{ cout << res << endl;
      }
  return 0;
}
      
      
      
  

Measured memory_bytes: 258944
#include<iostream>
#include<cstdio>
using namespace std;
 
int main(void){
  double a,b,c,d,e,f;
  double x,y;
  while(cin >> a >> b >> c >> d >> e >> f){
    double det = a * e -b * d;
    x = (c * e - b * f) / det;
    y = (a * f - c * d) / det;
    if(x == -0){
      x = 0;
    }
    if(y == -0){
      y = 0;
    }
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstdlib>
#include<iostream>
#define llong long long
using namespace std;

void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

const int N = 1e5;
llong a[N+3];
llong ans,sum;
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]==0) {ans+=(sum>>1); sum = 0;}
		sum += a[i];
	}
	ans+=(sum>>1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
w,h,n = map(int,input().split())
mode = [[0],[w],[0],[h]]
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        mode[0].append(x)
    elif a == 2:
        mode[1].append(x)
    elif a == 3:
        mode[2].append(y)
    else:
        mode[3].append(y)
b = [min(mode[1])-max(mode[0]),min(mode[3])-max(mode[2])]
print(b[0]*b[1] if (0 < b[0] and 0 < b[1]) else 0)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

void solve(int N, int T, int A, vector<int> H) {
  double t = 1e6;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    double tmp = abs(A - (T - H[i] * 0.006));
    if (tmp < t) {
      t = tmp;
      ans = i;
    }
  }
  printf("%d\n", ans + 1);
}

int main() {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  solve(N, T, A, H);
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    h: usize,
    w: usize,
    }
    let ret = calc(h, w);
    println!("{}", ret);
}

fn calc(h: usize, w: usize) -> usize {
    if h == 1 || w == 1 {
        1
    } else if (h * w) % 2 == 1 {
        (h * w + 1) / 2
    } else {
        h * w / 2
    }
}

Measured memory_bytes: 4352
from collections import defaultdict
d= defaultdict(list)
n,m = [int(i) for i in input().split()]
visited = [False for i in range(n)]
for i in range(m):
    a,b=  map(int,input().split())
    a-=1
    b-=1
    d[a].append(b)
    d[b].append(a)
def dfs(a):
    count = 0
    stack = [a]
    while(stack):
        curr = stack.pop()
        count+=1
        visited[curr]=True
        for i in d[curr]:
            if visited[i]==False:
                visited[i]=True
                stack.append(i)
        #print(count)
    return count
ca=0
for i in range(n):
    if visited[i]==False:
        c= dfs(i)
        ca = max(ca,c)
print(ca)
    

Measured memory_bytes: 56012
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

map<int,pair<int,int>> M;

int main(){
    ll H,W,D,A[307][307],Q,c,L,R,B[900019];
    cin >> H >> W >> D;
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
            M[A[i][j]]=mp(i,j);
        }
    }
    for(auto P : M){
        if(P.first<=D){
            B[P.first]=0;
        }
        else{
            B[P.first]=B[P.first-D]+abs(M[P.first].first-M[P.first-D].first)+abs(M[P.first].second-M[P.first-D].second);
        }
    }
    cin >> Q;
    rep(i,Q){
        cin >> L >> R;
        cout << B[R]-B[L] << endl;
    }
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s == t)
  {
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] array = in.nextIntArray0indexed(n);

            int ans = 0;
            for (int i = 0; i < n - 2; i++) {
                if (array[i] == i) {
                    ans++;

                    int tmp = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = tmp;
                }
            }

            if (array[n - 2] == n - 2 || array[n - 1] == n - 1) ans++;

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray0indexed(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt() - 1;
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 33908
n = int(input())
a = [ int(x) for x in input().split() ]

if min(a) == 0:
  print(0)
else:


  ans = 1
  f = False

  for e in a:
    ans *= e
    if ans > 1e18:
      f = True
      print(-1)
      break

  if not f:
    print(ans)

Measured memory_bytes: 21784
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
long long s[10000001];
using namespace std;
int main()
{ 
int y;
cin>>y;
int a[y];


FOR(y) {int r;cin>>r;a[i]=r;s[r]++;}

  long long int t=0;
FOR(10000001) {t+=(1LL*s[i]*(s[i]-1))/2;}

  
for(int j=0;j<y;j++)
{
   
    cout<<t-(s[a[j]]-1)<<"\n";
}


return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if(0 < a && a  < 10 && 0 < b && b < 10) {
    cout << a*b << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef STOP_DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  string s, t; cin >> t >> s;
  cout << s << t << '\n';
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int n;
ll a[200010];
ll b[200010];

int main ()
{
    cin >> n;
    REP(i,n) cin >> a[i] >> b[i];

    REP(i,n) {
        ll sq  = (ll)sqrt(a[i] * b[i]);
        ll ans = (a[i] * b[i] - (a[i] != b[i])) / sq + sq - 2;
        cout << ans << endl; 
    }

    return 0;
}

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

int main(){
	int n,c,k;
	cin>>n>>c>>k;
	int a[100001];
	for (int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int ans=n,o=c-1,t=a[0];
	for (int i=1;i<n;i++){
		if (a[i]-t<=k&&o>0)ans--,o--;
		else {o=c-1;t=a[i];continue;}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	std::vector<int> L(N);
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}

	sort(L.begin(), L.end());
	int sum =0;

	for (int a = 0; a < N-2 ; a++){
		for (int b = a+1; b < N-1; b++){
			for (int c = b+1; c < N; c++){
				if (abs(L[a]-L[b]) < L[c] && 
					L[c] < L[a]+L[b])
				{
					sum += 1;
				}
			}
		}
	}
	cout << sum << 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<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s;
	cin >> s;
	rep(i,s.size() - 8) {
		cout << s[i];
	}
	cout << endl;
}	


Measured memory_bytes: 256
import itertools
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    line = list(input())
    grid.append(line)
# 横に割る方法は2**(H-1)、高々2**9=512通り
# これを決め打ちして、縦の割り方はGreedyに

ans = 10**9

# 割る場合を1, 割らない場合を0で表すことにする
for ptn in itertools.product([0, 1], repeat=H - 1):

    # 不可能な場合、そのパターンはスキップする############################
    able = True
    for w in range(W):
        # それぞれのブロックにおける白の数
        lines = [0] * (sum(ptn) + 1)
        # 今、上から何ブロック目か
        line_num = 0
        for h in range(H):
            # 白の場合
            if grid[h][w] == "1":
                lines[line_num] += 1

            # 境界を引く場合
            # h=H-1の時、indexが範囲外になるのでminを使って調整
            if ptn[min(h, H - 2)] == 1:
                line_num += 1
        # 1列でK個を超えるブロックがある場合、その割り方は不適。
        if max(lines) > K:
            able = False
            break
    if able == False:
        continue
    # 以下、実現が可能なものとして考える################################

    # それぞれのブロックにおける白の数
    lines = [0] * (sum(ptn) + 1)
    # 横に割った回数
    cnt = sum(ptn)
    # ダメだったら1個前に戻る、という処理をしたいのでwhileで書く
    # for内でデクリメントしてもループにならない(自戒)
    w = 0
    while w < W:
        line_num = 0
        for h in range(H):
            # 白の場合
            if grid[h][w] == "1":
                lines[line_num] += 1
            # 境界を引く場合
            # h=H-1の時、indexが範囲外になるのでminを使って調整
            if ptn[min(h, H - 2)] == 1:
                line_num += 1
        # Kを超えるブロックができてしまう場合
        # 一つ前の列で切って、今の列からlinesを数え直す
        if max(lines) > K:
            cnt += 1
            lines = [0] * (sum(ptn) + 1)
            w -= 1
        w += 1
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 75640
/*
srt: 2017年05月20日 17時26分14秒
宋之问 《题大庾岭北驿》
阳月南飞雁，传闻至此回。
我行殊未已，何日复归来。
江静潮初落，林昏瘴不开。
明朝望乡处，应见陇头梅。
end: 2017年05月20日 17時48分55秒
*/

#include<cstdio>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();while(c>='0'&&c<='9');
}
inline void writeln(int w)
{
	static char s[20];
	static int top=0;
	do s[top++]=w%10+'0';while(w/=10);
	while(top)putchar(s[--top]);
	putchar(10);
}

int a[100001],dp[100001],first[100001];

struct ac{ int to,nx; }e[200001];
inline void readedge()
{
	static int L=1;int u,v;read(u),read(v);
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	e[L].to=u,e[L].nx=first[v],first[v]=L++;
}

void dfs(int u,int l,int r,int c)
{
	if(r<=dp[u])return;
	if(l<=dp[u])l=dp[u];
	l?l--:a[u]=c,dp[u]=r--;
	for(int j=first[u];j;j=e[j].nx)
		dfs(e[j].to,l,r,c);
}

struct query{ int u,d,c; }q[200000];
int main()
{
	int n,m,i;read(n),read(m);
	while(m--)readedge();

	read(m);
	for(i=0;i<m;i++)
		read(q[i].u),read(q[i].d),read(q[i].c);
	while(m--)
		dfs(q[m].u,0,q[m].d+1,q[m].c);
	for(i=1;i<=n;i++)
		writeln(a[i]);
}

Measured memory_bytes: 4736
#include "bits/stdc++.h"
using namespace std;

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

    vector<vector<int>> F(N, vector<int>(10));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }
    vector<vector<int>> P(N, vector<int>(11));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> P[i][j];
        }
    }

    int ans = -1000000000;
    for (int i = 1; i < 1024; i++) {
    	int res = 0;
        vector<int> shop(N);
      
        vector<int> keta = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
        int t = i;
        for (int j = 0; t != 0; j++) {
            keta[9 - j] = t % 2;
            t /= 2;
        }
        
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < N; k++) {
                if (keta[j] == 1 && F[k][j] == 1) {
                    shop[k]++;
                }
            }
        }

        for (int j = 0; j < N; j++) {
            res += P[j][shop[j]];
        }
        ans = max(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int H, W;
    cin >> H >> W;
    char bomd[H + 2][W + 2];
    int res[H + 2][W + 2];
    
    for (int i = 0; i < H + 2; i++)
    {
        for (int j = 0; j < W + 2; j++)
            res[i][j] = 0;
    }
    
    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            cin >> bomd[i][j];
        }
    }
    
    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
            if (bomd[i][j] == '#')
            {
                res[i - 1][j - 1] += 1;
                res[i][j - 1] += 1;
                res[i + 1][j - 1] += 1;
                res[i - 1][j] += 1;
                res[i + 1][j] += 1;
                res[i - 1][j + 1] += 1;
                res[i][j + 1] += 1;
                res[i + 1][j + 1] += 1;
            }
    }

    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            if(bomd[i][j] == '.')
            {
                cout << res[i][j];
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256