akhauriyash/Code-Regression huggingface dataset:
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int main() {
	int a, b;
	char k[100][100];
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cin >> k[i][j];
		}
	}
	int ans[100][100];
	int count = 0;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			if (k[i][j] == 'c') {
				ans[i][j] = 0;
				count++;
			}
			if (count == 0) {
				ans[i][j] = -1;
			}
			else if (count >= 1 && k[i][j] == '.') {
				for (int kk = j - 1; kk >= 0; kk--) {
					if (k[i][kk] == 'c') {
						ans[i][j] = j - kk;
						break;
					}
				}
			}
		}
		count = 0;
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			if (j != b - 1)
				cout << ans[i][j] << ' ';
			else {
				cout << ans[i][j] << endl;
			}
		}
	}
}


Measured memory_bytes: 3128
s = int(input())
a = [s]
m = 0
for i in range(1, 1000001):
    if a[i-1]%2 == 0:
        b = int(a[i-1]/2)
    else:
        b = 3*a[i-1]+1
    if b in a:
        m = i + 1
        break
    else:
        a.append(b)
print(m)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

int main()
{
    IOS;
    int a,b;
    cin>>a>>b;
    if(a>=13) cout<<b<<endl;
    else if(a>=6 && a<=12) cout<<b/2<<endl;
    else cout<<0<<endl;
    return 0;
}

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

int main(void) {
  int a,b;
  std::cin >> a >> b;
  if(a > 100 || b > 100){
    std::cout << "a<=100 && b<=100" << "\n";
    return 0;
  }
  else{
    if(a <= b*2) {
      std::cout << "0" << std::endl;
    }
    else{
      std::cout << a-b*2 << std::endl;
    }
  }
}


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

c = []
c.append(0)

for i in range(1,n):
    c.append(min([ c[max(i-j,0)] + abs(h[i] - h[max(i-j,0)]) for j in range(1,k+1) ]))

print(c[n-1])

Measured memory_bytes: 85492
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 modpow(i64 a, int p = MOD - 2)
{
	if (p == 0) return 1;
	i64 ret = modpow(a, p / 2);
	ret = ret * ret % MOD;
	if (p % 2 == 1) ret = ret * a % MOD;
	return ret;
}

int N, M, A[16];

i64 dp[1 << 16]; // occupied by prohibited pats
i64 fact[70000], facti[70000];

i64 C(int a, int b)
{
	if (!(0 <= b && b <= a)) return 0LL;
	return fact[a] * facti[b] % MOD * facti[a - b] % MOD;
}

int main()
{
	fact[0] = facti[0] = 1;
	for (int i = 1; i < 70000; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		facti[i] = facti[i - 1] * modpow(i) % MOD;
	}
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) scanf("%d", A + i);

	for (int i = 0; i < (1 << N); ++i) {
		dp[i] = 0;
	}
	dp[0] = 1;
	for (int i = M - 1; i >= 0; --i) {
		for (int m = (1 << N) - 1; m >= 0; --m) {
			int used = 0;
			for (int j = 0; j < N; ++j) if (m & (1 << j)) used += (1 << j);
			int rem = (1 << N) - A[i] - used;
			for (int j = 0; j < N; ++j) if ((m & (1 << j)) == 0) {
				ADD(dp[m | (1 << j)], dp[m] * C(rem, (1 << j) - 1));
			}
		}
	}

	i64 ret = 0;
	for (int m = 0; m < (1 << N); ++m) {
		i64 tmp = dp[m];
		int sgn = 1;
		int used = 0;
		for (int j = 0; j < N; ++j) if (m & (1 << j)) used += (1 << j);

		int rem = (1 << N) - 1 - used;
		for (int i = 0; i < N; ++i) {
			if (m & (1 << i)) {
				sgn = -sgn;
			} else {
				tmp = tmp * C(rem, 1 << i) % MOD;
				rem -= (1 << i);
			}
		}
		if (sgn == -1) tmp = MOD - tmp;
		ADD(ret, tmp);
	}

	ret = ret * (1 << N) % MOD;
	for (int i = 0; i < N; ++i) ret = ret * fact[1 << i] % MOD;
	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))

S = []
count = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        S.append(count)
        count = 0
        
S.append(count)

print(max(S))

Measured memory_bytes: 14252
import itertools
n,m,q=map(int,input().split())
d=[list(map(int,input().split())) for i in range(q)]
ans=0
for i in list(itertools.combinations_with_replacement(list(range(1,m+1)), n)):
  a=list(i)
  hantei=0
  for j in range(q):
    if (a[d[j][1]-1]-a[d[j][0]-1])==d[j][2]:
      hantei+=d[j][3]
  ans=max(ans,hantei)
print(ans)

Measured memory_bytes: 21620
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)




int main(void)
{
    int n;
    string a;
    cin>>n>>a;
    int ans;
    bool f1,f2,f3;
    f1 =f2=f3=false;
    rep(i,1000)
    {
        string s;
        s = to_string(i);
        if(s.size()==1) s="00"+s;
        if(s.size()==2) s="0"+s;
        int keta =0;
        for(int j=0;j<a.size();j++)
        {
        if(s[keta] == a[j]) keta++;
        
        if(keta==3) break;
        }
        if(keta>=3) ans++;
    
    }
    


    cout<<ans<<endl;




}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++) L[i]=A[left+i];
    for(int i=0; i<n2; i++) R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    int i=0, j=0;
    for(int k = left; k<right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k]=L[i++];
        } else {
            A[k]=R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left ,int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    int A[MAX], n, i;
    cnt=0;
    
    cin>>n;
    for(i=0; i<n; i++)cin >> A[i];
    mergeSort(A,n,0,n);
    for(i=0; i<n;i++){
        if(i)cout<<" ";
        cout << A[i];
        
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 6896
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=3e6+5;

ll f[N],inv[N],m=1e9+7;

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

ll ncr(ll n,ll r)
{
	if(r>n||r<0)return 0;
	ll ans=(f[n]*inv[r])%m;
	return (ans*inv[n-r])%m;
}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
f[0]=1;
rep(i,1,N-1)f[i]=(f[i-1]*i)%m;
inv[N-1]=p(f[N-1],m-2);
ren(i,N-2,0)inv[i]=(inv[i+1]*(i+1))%m;
ll k,n;
string s;
cin>>k>>s;
n=s.length();
ll ans=0;

for(ll lst=0;lst<=k;lst++)
{
	ll mul=(p(26,lst)*p(25,k-lst))%m;
	ll res=ncr(k-lst+n-1,n-1);
	ans=(ans+res*mul)%m;
}
ol(ans);
return 0;
}



Measured memory_bytes: 51132
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

int n, k, q;
int a[MAX_Q];
int b[MAX_N];

int main() {

  cin >> n >> k >> q;
  rep(i, q) {
    cin >> a[i];
    --b[a[i]-1];
  }

  rep(i, n) {
    b[i] += q;
    if(k-b[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


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

int main() {
	
	int n,i;
	
	cin>>n;
	
	int a[n-1];
	for(i=0;i<n-1;i++)
	cin>>a[i];
	
	map<int,int> m;
	
	for(i=0;i<n-1;i++){
		
		m[a[i]]++;
	}
	
	for(i=1;i<=n;i++)
	cout<<m[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 13788
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  
        static long[] a;
        static long N;
        static long K;
        
        static void Main(string[] args)
        {
          //入力を受け取る
          long N = int.Parse(Console.ReadLine());
          long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          var count = 0;
          for(int i = 0 ; i < N ; i++){
            if(A[i] < 0){
              A[i] = -1*A[i];
              count++;
            }
          }
          long min = A.Min();
          long res;
          if(count%2 == 0 || N == 1){
            res = A.Sum();
          }else{
            res =A.Sum()-2*min;
          }
          //結果を出力
          Console.WriteLine(res);
        }
 }

Measured memory_bytes: 33244
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
	char a[40];
	int j=0;
	char c;
	while((c=getchar())!='\n')
	{
		a[j] = c;
		j++;
	}
	int result = 0;
	for(int i=0; i<strlen(a); i++)
	{
		if(a[i]==' ') continue;
		else result = result*10 + a[i]-'0';
	}
	int i;
	for(i=1;i*i<result;i++);
	
	if(i*i == result) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

const ll n_max = 100000;
vector<ll> edge[n_max];
int visited[n_max];
vector<ll> nodes[2];

bool dfs(ll n, int l){
  //cout << n << " " << l << endl;
  visited[n] = l;
  if(l==1){
    nodes[1].push_back(n);
  }else{
    nodes[0].push_back(n);
  }
  for(auto v:edge[n]){
    if(visited[v]==l) return false;
    if(visited[v]==0&&!dfs(v,l*(-1))) return false;
  }
  return true;
}

int main(){
  ll n,m;
  cin >> n >> m;
  REP(i,m){
    ll a,b;
    cin >> a >> b;
    edge[a-1].push_back(b-1);
    edge[b-1].push_back(a-1);
  }

  fill(visited,visited+n,0);
  if(dfs(0,1)){
    ll n1 = nodes[0].size();
    ll n2 = nodes[1].size();
    cout << n1*n2-m << endl;
  }else{
    cout << n*(n-1)/2-m << endl;
  }
  return 0;
}


Measured memory_bytes: 8700
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};

    let mut v: Vec<Vec<i64>> = vec![vec![-1; 15]; 15];

    for i in 0..n {
        input! {a: usize};
        for _ in 0..a {
            input! {x: usize, y: i64};
            v[i][x - 1] = y;
        }
    }

    let mut ans = 0;
    for i in 0..1 << n {
        let mut d = vec![0; n];
        let mut ok = true;
        for j in 0..n {
            if i >> j & 1 == 1 {
                d[j] = 1;
            }
        }

        for j in 0..n {
            if d[j] == 1 {
                for k in 0..n {
                    if v[j][k] == -1 {
                        continue;
                    }

                    if v[j][k] != d[k] {
                        ok = false;
                        break;
                    }
                }
            }
        }
        if ok {
            ans = std::cmp::max(ans, (i as i32).count_ones());
        }
    }

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


Measured memory_bytes: 2212
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    IOS
    int n;
    lli x,ans = 0;
    cin>>n>>x;
    lli a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        x = x - a[i];
        if(x>=0) ans++;
        else break;
    }
    if(x>0) ans--;
    cout<<ans;
    return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  vector<int> dp(K + 1, 0);
  vector<int> sum(K + 1, 0);
  dp[K] = 1;

  for (int i = 0; i < N; i++) {

    sum[0] = dp[0] % MOD;
    for (int j = 1; j <= K; j++) {
      sum[j] = (sum[j - 1] % MOD + dp[j] % MOD) % MOD;
    }

    for (int j = 0; j <= K; j++) {
      dp[j] = sum[min(K, j + a[i])] % MOD;
      if (j != 0) dp[j] = (dp[j] - sum[j - 1] + MOD) % MOD;
    }

    if (i == N - 1) {
      cout << dp[0] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	final double INF = 5000.;
	
	String solve(final int s, final int e, final double[][] map, final int n){
		boolean[] used = new boolean[n];
		double d[] = new double[n];
		Arrays.fill(d, INF);
		d[s] = 0;
		ArrayList<LinkedList<Integer>> list = new ArrayList<LinkedList<Integer>>();
		for(int i=0; i<n; ++i){
			LinkedList<Integer> l = new LinkedList<Integer>();
			l.add(s);
			list.add(l);
		}
		
		while(true){
			int u=-1;
			for(int v=0; v<n; ++v){
				if(!used[v] && (u==-1 || d[v] < d[u])){
					u=v;
				}
			}
			if(u==-1)break;
			used[u] = true;
			for(int v=0; v<n; ++v){
				if(d[v] > d[u] + map[u][v] && map[u][v] <= 50){
					d[v] = d[u] + map[u][v];
					@SuppressWarnings("unchecked")
					LinkedList<Integer> l = (LinkedList<Integer>) list.get(u).clone();
					l.add(v);
					list.set(v, l);
				}
			}
		}
		
		return d[e]==INF ? "NA" : listToString(list.get(e));
	}
	
	String listToString(final LinkedList<Integer> list){
		String str = new String();
		for(int i=0; i<list.size(); ++i){
			str += list.get(i)+1;
			if(i+1<list.size()) str += " ";
		}
		
		return str;
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		while(true){
			final int n = sc.nextInt();
			if(n==0)break;
			int b_info[][] = new int[n][2];
			double[][] map = new double[n][n];
			
			for(int i=0; i<n; ++i){
				final int b=sc.nextInt()-1;
				final int x=sc.nextInt();  final int y = sc.nextInt();
				b_info[b][0] = x;
				b_info[b][1] = y;
			}
			
			for(int i=0; i<n; ++i){
				for(int j=0; j<n; ++j){
					final double dis = Math.sqrt(
						Math.pow(b_info[i][0]-b_info[j][0], 2)
						+ Math.pow(b_info[i][1]-b_info[j][1], 2)
					);
					map[i][j] = dis;
				}
			}
			
			final int m = sc.nextInt();
			for(int i=0; i<m; ++i){
				final int s = sc.nextInt()-1;
				final int g = sc.nextInt()-1;
				System.out.println(solve(s, g, map, n));
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}

}

Measured memory_bytes: 12000
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def solve(bomb):
    count = 0
    for i in range(N):
        remain = H[i] - (B*bomb)
        # まだ残ってる場合、中心爆発分で追加ダメージが必要なのでカウントする
        if remain > 0:
            additional_damage = (A-B)
            c = -(-remain // additional_damage)
            count += c

    if count <= bomb:
        return True
    else:
        return False


# leftは条件を満たす値、rightは満たさない値
def meguru(left, right):
    while abs(left - right) > 1:
        mid = (left + right) // 2;

        if (solve(mid)):
            left = mid
        else:
            right = mid;

    return left


# 問題を「k回の爆発でクリアできるか」に置き換えれば、めぐる式二分探索が使える
print(meguru(max(H), 0))

Measured memory_bytes: 7076
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define INF 0x3f3f3f3f
typedef unsigned long long ll;
using namespace std;
int n, q, m, pre[100010];
char c;
int find(int x)
{
	while(x != pre[x]){
		x = pre[x];
	}
	return x;
}
int main()
{
	IO;
	while(cin >> n >> q){ 
		if(!n&&!q) break;
		ll sum=0;
		pre[1] = 1;
		for(int i = 2; i <= n; i++){
			cin >> pre[i];
		}
		for(int i = 0; i < q; i++){
			cin >> c >> m;
			if(c == 'Q') 
				sum += find(m);
			else {
				pre[m] = m;
			}
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3388
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
using namespace std;

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; i--)
#define rek(i,a,b) for (int i=(a),_##i=(b); i>=_##i; i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(b))
#pragma comment(linker, "/STACK:102400000,102400000")
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}

int a[100100],b[100100],maxn,n,ans,cnt,x,ret;

int main()
{
    while(scanf("%lld",&n)==1)
    {
        mem(a,0);ans=cnt=maxn=ret=0;
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&x);a[x]++;maxn=max(maxn,x);
        }
        for(int i=1;i<=maxn;++i)
        {
            if(a[i])
            {
                a[i]=(a[i]&1)?1:2;
                b[++cnt]=i;
                if(a[i]%2==0) ret++;
            }
        }
       // printf("cnt=%d ret=%d\n",cnt,ret);
        if(ret&1) ans=cnt-1;else ans=cnt;
        printf("%d\n",ans);
    }
    return 0;
}


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

int n;
void dfs(string s, char mx) {
	if (s.size() == n){
		cout << s << endl;
		return;
	}
	for (char c = 'a'; c <= mx + 1; c++) {
		string t = s;
		t += c;
		dfs(t, max(mx, c));
	}
}

int main() {
	cin >> n;
	dfs("", 'a' - 1);
	return 0;
}


Measured memory_bytes: 1536
<?php
  const DIRS = "RDLU";
  $h[] = "000000";
  $v[] = "0000000";
  for($i=0;$i<4;$i++) {
      $h[] = "0".trim(fgets(STDIN))."0";
      $v[] = "0".trim(fgets(STDIN))."0";
  }
  $h[] = "0".trim(fgets(STDIN))."0";
  $v[] = $v[0];
  $h[] = $h[0];

  $x=2; $y=1; $dir=0; $p='R';
  $stepx =  array(1,0,-1,0);
  $stepy = array(0,1,0,-1);

  while(!($x==1 && $y==1)) {
    for($i=0;$i<4;$i++) {
      $d = ($dir+$i)%4;
      if(($d==0 && $v[$y-1][$x]) || ($d==1 && $h[$y][$x])
        || ($d==2 && $v[$y][$x]) || ($d==3 && $h[$y][$x-1])) {
        $d2 = ($d+3)%4;
        $x += $stepx[$d2];
        $y += $stepy[$d2];
        $dir = $d2;
        break;
      }
    }
    $p.=DIRS[$dir];
  }
  echo $p.PHP_EOL;

Measured memory_bytes: 15092
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define R register
typedef long long ll;
int n,D1,D2,pow2_1,pow2_2,cnt;
int main(){
	scanf("%d %d %d",&n,&D1,&D2);
	while(~D1&1) ++pow2_1,D1>>=1;
	while(~D2&1) ++pow2_2,D2>>=1;
	for (R int i=0; i<n<<1; ++i){
		for (R int j=0; j<n<<1; ++j)
			if (((pow2_1&1)?((~(i>>(pow2_1>>1)))&1):((i>>(pow2_1>>1))&1)==((j>>(pow2_1>>1))&1))&&
				((pow2_2&1)?((~(i>>(pow2_2>>1)))&1):((i>>(pow2_2>>1))&1)==((j>>(pow2_2>>1))&1))){
					printf("%d %d\n",i,j);
					++cnt;if (cnt==n*n) break;
				}
		if (cnt==n*n) break;
	}return 0;
}

Measured memory_bytes: 768
n = int(input())
p = list(map(int, input().split()))
p_sort = sorted(p)
flag = False

for i in range(n):
    for j in range(n):
        p_tmp = p[:]
        tmp = p_tmp[i]
        p_tmp[i] = p_tmp[j]
        p_tmp[j] = tmp
        match = True
        for k in range(n):
            if p_tmp[k] != p_sort[k]:
                match = False
        if match:
            flag = True
            break
    if flag:
        break

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
int main(){
  int n; cin >>n; ll ans=0;
  vector<int>v(n); map<int,int>mp;
  for(int i=0; i<n; i++){
    int a; cin >>a; v[i]=i+a; mp[i-a]++;
  }
  for(int i=0; i<n; i++) ans+=mp[v[i]];
  cout <<ans;
return 0;}

Measured memory_bytes: 21000
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            bool x = true, y = true;
            string read = Console.ReadLine(), msg;
            var temp_string = read.Split(' ');
            int box_w = int.Parse(temp_string[0]), box_h = int.Parse(temp_string[1]),
                circle_x = int.Parse(temp_string[2]), circle_y = int.Parse(temp_string[3]), circle_r = int.Parse(temp_string[4]);


            if(circle_x - circle_r < 0||
               circle_x + circle_r > box_w)
            {
                x = false;
            }
            if (circle_y - circle_r < 0 ||
                circle_y + circle_r > box_h)
            {
                y = false;
            }

            if(x&&y)
            {
                msg = "Yes";
            }
            else
            {
                msg = "No";
            }

            Console.WriteLine(msg);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8964
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111



int main(void) {
  set<ll> a;
  cin >> n;
  FOR(i, 2, 30000 + 1) {
	if (a.size() >= n) break;
	if (i % 2 == 0 || i % 3 == 0) {
	  a.insert(i);
	  sum += i;
	}
  }
  m = sum % 6;
  
  if (m == 2) {
	a.erase(2);
	a.insert(30000);
  }
  else if (m == 3 ) {
	if (n == 3) {
	  a.erase(4);
	  a.insert(25);
	}
	else {
	  a.erase(6);
	  a.insert(29997);
	}
  }
  else if (m == 5) {
	a.erase(2);
	a.insert(29997);
  }

  for (auto it : a) {
	cout << it << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer M = nextInt(sc);
        System.out.println(24-M+24);
        sc.close();
    }
 
    static int nextInt(Scanner sc){
        return Integer.parseInt(sc.next());
    }
 
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<pair<int,int>>> g(n);
  vector<int> deg(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    deg[u]++; deg[v]++;
    g[u].emplace_back(v, i);
    g[v].emplace_back(u, i);
  }

  auto k = max_element(deg.begin(), deg.end());
  vector<int> color(n - 1);

  function<void(int,int,int)> dfs = [&](int u, int pa, int pa_color) {
    int color_iter = 0;
    for (auto to : g[u]) {
      if (to.first == pa) continue;
      if (color_iter == pa_color) color_iter++;
      dfs(to.first, u, color_iter);
      color[to.second] = color_iter++;
    }
  };
  dfs(k - deg.begin(), -1, -1);

  cout << *k << '\n';
  for (int i = 0; i < n - 1; i++) {
    cout << color[i] + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 13116
N = int(input())
l = []
for i  in range(5):
    l.append(int(input()))
btlneck = min(l)
if btlneck >= N:
    ans = 5
else:
    q = N // btlneck
    r = N % btlneck
    ans = q + 5
    if r == 0:
        ans -= 1
print(ans)

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

int main() {
    ll n;
    std::cin >> n;
    vector<pair<string,ll>> st(n);
    for (int i = 0; i < n; i++) {
        std::cin >> st[i].first>>st[i].second;
    }
    string x;
    std::cin >> x;
    bool ok = false;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if(ok){
            res += st[i].second;
        }
        if(st[i].first == x){
            ok=true;
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include "string.h"
using namespace std;
#define int long long

int pf[1000006];
void fun()
{
	pf[1]=1,pf[0]=1;
	for(int i=0;i<1000006;i++)
		pf[i]=i;
	for(int i=2;i*i<1000006;i++)
	{
		if(pf[i]==i)
		{
			for(int j=i;j<1000006;j+=i)
			{
				if(pf[j]==j)
					pf[j]=i;
			}
		}
	}
}
int fun1(int x)
{
	int c=1;
	while(x!=1)
	{
		int t=pf[x],c1=0;
		while(x%t==0)
		{
			x/=pf[x];
			c1++;
		}
		c+=c*c1;
	}
	return c;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(20)<<fixed;

	int n;
	cin>>n;
	fun();
	int c=0;
	for(int i=1;i<n;i++)
	{
		int t=fun1(n-i);
		//cout<<t<<endl;
		c+=t;
	}
	cout<<c<<endl;
	return 0;
}

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

void fastio() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int main(int argc, char const *argv[])
{
	#define double long double

	int n;
	cin >> n;
	vector<double> prob(n + 1);
	for (int i = 1; i <= n; ++i) cin >> prob[i];

	vector<vector<double> > dp(n + 1, vector<double>(n + 1, 0.0));
	dp[1][0] = (1-prob[1]);
	dp[1][1] = prob[1];
	for (int i = 2; i <= n; ++i) {
		for (int k = 0; k <= i; ++k) {
			dp[i][k] = dp[i-1][k] * (1-prob[i]);
			if (k > 0) dp[i][k] += dp[i-1][k-1] * prob[i];
		}
	}
	double ans = 0;
	for (int i = (n/2) + 1; i <= n; ++i) {
		ans += dp[n][i];
	}
	cout << setprecision(12) << fixed << ans << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int k,s;
  int ans=0;
  cin>>k>>s;
  //z=s-x-yを考える
  rep(x,k+1){
    rep(y,k+1){
      int z=s-x-y;
      if(z<=k &&z>=0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline

N, Q = map(int, input().split())
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

for i in range(Q):
    node, x = map(int, input().split())
    node -= 1
    cnt[node] += x

visited[0]=1
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)    

print(*cnt)

Measured memory_bytes: 80544
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.14159265359;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<=n;i++){ // i represents number whose multiples are taken
        ll y=n/i;
        ans+=(i*y*(y+1))/2;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        int[] p = new int[m];
        for(int i = 0; i < m; i++) {
            int k = sc.nextInt();
            ArrayList<Integer> list = new ArrayList<>();
            for(int j = 0; j < k; j++) {
                list.add(sc.nextInt());
            }
            map.put(i, list);
        }
        for(int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
        }
        int num = 1 << n;
        int ans = 0;
        // numは電球のon/off
        for(int i = 0; i < num; i++) {
            ans++;
            for(Map.Entry<Integer, ArrayList<Integer>> entry: map.entrySet()) {
                int index = entry.getKey();
                ArrayList<Integer> list = entry.getValue();
                int c = count(list, i);
                if(c % 2 != p[index]) {
                    ans--;
                    break;
                }
            }
        }
        System.out.println(ans);
    }
    // いくつの電球がonかを数える
    private static int count(ArrayList<Integer> list, int num) {
        int count = 0;
        // i番目の電球を調べる
        for(int i: list) {
            i--;
            if((num & (1 << i)) != 0) count++;
        }
        return count;
    }
}

Measured memory_bytes: 23892
#include<stdio.h>
int main()
{
    int x,a,b,c,d;
    scanf("%d%d%d",&x,&a,&b);
    if((x-a)>0) c=x-a;
    else c=a-x;
    if((x-b)>0) d=x-b;
    else d=b-x;
    if(c<d) printf("A");
    else printf("B");
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

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

using namespace std;

using ll = long long;
using PII = pair<int, int>;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int main(void){
	int N;
	vector<int> a;
	cin >> N;
	REP(i, N*2){
		int b;
		cin >> b;
		a.push_back(b);
	}
	sort(all(a));
	ll res = 0;
	REP(i, N){
		res += a[2*i];
	}
	cout << res << endl;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	int answer = 0;
	switch(x){
	case 1: answer += 300000; break;
	case 2: answer += 200000; break;
	case 3: answer += 100000; break;
	}
	switch(y){
	case 1: answer += 300000; break;
	case 2: answer += 200000; break;
	case 3: answer += 100000; break;
	}
	if(x == 1 && y == 1){ answer += 400000; }
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define inf 1000000007
#define MAXN 250
#define MAXT 250
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;

	
int32_t main(){
	fastio;
	int r,D,x;
	cin>>r>>D>>x;
	for(int i=0;i<10;i++){
		x = r*x-D;
		cout<<x<<endl;
	}
}

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

using namespace std;

using ll = long long;

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

    ll len = 0;

    for (ll i = 0; i < 50; ++i) {
        if ((1LL << i) - 1 <= N) continue;
        len = i - 1;
        N -= (1LL << len) - 1;
        break;
    }

    // まずは(1, 2, ..., len)を作る
    vector<ll> p(len);
    for (ll i = 0; i < len; ++i) {
        p[i] = i + 1;
    }

    // len+1を適宜追加していく
    for (ll i = len; i >= 0; --i) {
        if ((1LL << i) <= N) {
            // iとi+1の間にlen + 1を追加
            p.insert(p.begin() + i, ++len);
            N -= (1LL << i);
        }
    }

    cout << len * 2 << endl;

    // 前半は作った1~lenの順列
    for (ll n : p) {
        cout << n << " ";
    }

    // 後半は1~lenの昇順列
    for (ll i = 1; i <= len; ++i) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,sum1=0,sum2=0;
   cin >> n ;
   int a[n],b[n],c[n]={0};

   for(int x=0 ; x<n ;x++)
   {
       cin >> a[x];
   }
   for(int x=0 ; x<n ;x++)
   {
       cin >> b[x];
       sum2+=b[x];
   }
    for(int x=0 ;x<n ;x++)
    {
       c[x]=a[x]+sum1+sum2;
        sum2-=b[x];
        sum1+=a[x];
    }
    sort(c,c+n);

    cout << c[n-1]<<endl;

      return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int A[100][100], B[100][100];
  long long C[100][100];
  int n, m, l; cin >> n >> m >> l;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> B[i][j];
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < l; k++) {
      C[i][k] = 0;
      for (int j = 0; j < m; j++) {
	C[i][k] += A[i][j]*B[j][k];
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      cout << C[i][j];
      if (j < l-1) {
	cout << ' ';
      } else {
	cout << endl;
      }
    }
  }
  return 0;
}

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

int main(){
    int n;
    int w,h;
    while(cin>>n,n){
        cin>>w>>h;
        vector<vector<int>> p(h,vector<int>(w,0));
        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            x--;
            y--;
            p[y][x]=1;
        }
        int s,t;
        cin>>s>>t;
        int res=0;
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++){
                if(i+t-1<h && j+s-1<w){
                    int cnt=0;
                    for(int k=i;k<=i+t-1;k++)
                        for(int r=j;r<=j+s-1;r++)
                            if(p[k][r])
                                cnt++;
                    res=max(res,cnt);

                }


            }
        cout<<res<<endl;
    }



}

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

int main()
{
    int n;cin>>n;
    vector<int> a(n+2,0);
    int i;
    for(i=1;i<=n;i++)cin>>a.at(i);
    vector<int> sum(n+2,0);
    for(i=1;i<=n+1;i++)sum.at(i)=sum.at(i-1)+abs(a.at(i)-a.at(i-1));
    for(i=1;i<=n;i++)cout<<sum.at(i-1)+abs(a.at(i+1)-a.at(i-1))+sum.at(n+1)-sum.at(i+1)<<endl;
}


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

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	int ara[n+1];
	int sum = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> ara[i];
		sum += ara[i];
	}
	double k = sum/(4.0*m);
	sort(ara+1,ara+n+1);
	int bd = 0;
	for(int i = n; i > 0; i--)
	{
		if(ara[i] >= k)
			bd++;
	}
	if(bd >= m)
		cout <<"Yes" << endl;
	else
		cout <<"No" << endl;
	return 0;
}

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

using namespace std;

#define vt vector
#define llint long long int
#define REP(i,s,l) for(int i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    //N個の宝石 i番目Vi原価 Ci経費
    int qnt;
    vector<int> genka(qnt);
    vector<int> keihi(qnt);
    int mouke = 0;
    int sagaku;

    cin >> qnt ;
    REP(i,0,qnt){ cin >> genka[i];}
    REP(i,0,qnt){ cin >> keihi[i];}

    REP(i,0,qnt){
        // if(genka[i] > keihi[i]) mouke += genka[i] - keihi[i];
        if((genka[i] - keihi[i])>0 ) mouke += genka[i] - keihi[i];
    }

    cout << mouke << endl;

    return 0;
}

Measured memory_bytes: 512
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    ll n;
    cin >> n;

    ll ans = 0;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            if(i - 1 != 0){
                if(n / (i - 1) == n % (i - 1)){
                    ans += i - 1;
                }
            }
            if(i * i != n){
                if(n / (n / i - 1) == n % (n / i - 1)){
                    ans += n / i - 1;
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, X, N);
    ll ans = INF;
    REP1(i, 100)
    {
        ll s = 0;
        FOR(x, X)
        {
            s += pow((x - i), 2);
        }
        CH(min, ans, s);
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n, t, a, x; cin >> n >> t >> a;
	int ans = 0; double tp = 0;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (!i)tp = t - (double)x*0.006;
		else {
			if (abs(a - tp) > abs(a - (t - (double)x*0.006))) {
				ans = i;
				tp = t - (double)x*0.006;
			}
		}
	}cout << ++ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define INF 1e9
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int n;
	cin>>n;
	string s;
	int c1=0, c2=0,c3=0,c4=0;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="AC")
		c1++;
		else if(s=="WA")
		c2++;
		else if(s=="TLE")
		c3++;
		else c4++;
		
	}
	cout<<"AC x "<<c1<<endl;
		cout<<"WA x "<<c2<<endl;
			cout<<"TLE x "<<c3<<endl;
				cout<<"RE x "<<c4<<endl;
	
	}

Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	X := scanInt()
	Y := scanInt()
	Z := scanInt()
	K := scanInt()
	a := scanInts(X)
	b := scanInts(Y)
	c := scanInts(Z)

	bc := make([]int, Y*Z)
	for i := 0; i < Y; i++ {
		for j := 0; j < Z; j++ {
			bc[i*Z+j] = b[i] + c[j]
		}
	}

	sort.Ints(bc)
	bc = bc[max(0,len(bc)-K):len(bc)]

	n := len(bc)
	l, r := 0, 1<<40
	for l+1 < r {
		mid := (l + r) / 2
		cnt := 0
		for i := 0; i < X; i++ {
			cnt += n - sort.Search(n, func(j int) bool {
				return mid <= a[i]+bc[j]
			})
		}

		if cnt >= K {
			l = mid
		} else {
			r = mid
		}
	}

	arr := []int{}

	for i := 0; i < X; i++ {
		for j := 0; j < n; j++ {
			if a[i]+bc[n-1-j] < l {
				break
			}
			arr = append(arr, a[i]+bc[n-1-j])
		}
	}

	sort.Ints(arr)

	for i := 0; i < K; i++ {
		fmt.Fprintln(wr, arr[len(arr)-1-i])
	}
}


Measured memory_bytes: 93184