akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
long long d[100005];
typedef pair<int,int>P;
vector<P>vec[100005];
void dfs(int x,int y)
{
     int k=vec[x].size();
     for(int i=0;i<k;i++)
     {
          P s=vec[x][i];
          if(s.first!=y)
          {
               d[s.first]=d[x]+s.second;
               dfs(s.first,x);
          }
     }
}
int main()
{
     int n;
     scanf("%d",&n);
     for(int i=0;i<n-1;i++)
     {
          int a,b,c;
          scanf("%d%d%d",&a,&b,&c);
          vec[a].push_back(P(b,c));
          vec[b].push_back(P(a,c));
     }
     int m,k;
     scanf("%d%d",&m,&k);
     d[k]=0;
     dfs(k,k);
     for(int i=0;i<m;i++)
     {
          int a,b;
          scanf("%d%d",&a,&b);
          printf("%lld\n",d[a]+d[b]);
     }
     return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, d; cin>>n>>d;
    vector<int> a(n);
    int num=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        a[i]--;
        a[i]%=(d+1);
        num^=a[i];
    }

    if(num==0) cout << "Second" << endl;
    else cout << "First" << endl;
}


Measured memory_bytes: 3888
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int now = 0;
        int chain = 0;
        for(int i = 0; i < n; i++){
            int h = sc.nextInt();
            if(now < h){
                ans = Math.max(ans,chain);
                chain = 0;
            }else{
                chain++;
            }
            now = h;
        }
        System.out.println(Math.max(ans,chain));
    }
}
 

Measured memory_bytes: 48776
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
int main()
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];

    vector<int> dp(n,INF);
    dp[0] = 0;
    int count = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));           
        }
    }

    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<array>

int main(void) {
	int result = 700;
	std::string a;
	std::cin >> a;
	for (int i = 0; i < 3; i++) {
		if (a[i] == 'o') {
			result = result + 100;
		}
	}
	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
a = []

for i in range(n):
    if bisect.bisect_left(a, s[i]) == bisect.bisect_right(a, s[i]):
        a.append(s[i])
print(len(a))

Measured memory_bytes: 108704
def make_divisors(n):
    ret = []
    d = 1
    while d * d <= n:
        if n % d == 0:
            ret.append(d)
            if d != n // d:
                ret.append(n // d)
        d += 1
    return ret

# n = int(input())
def test(n):
    ret = 0
    for i in range(1, n + 1):
        if n // i == n % i:
            ret += i
    return ret


def main(n):
    d = make_divisors(n)
    # print("d =", d)
    ans = 0
    for i in d:
        m = i - 1
        if 1 <= n // (m + 1) < m:
            ans += m
    return ans
    # print(ans)

n = int(input())
print(main(n))

# for i in range(1, 1000):
#     ans_main = main(i)
#     ans_test = test(i)
#     if ans_main != ans_test:
#         print(i)        
#         print("ans_main =", ans_main)
#         print("ans_test =", ans_test)

Measured memory_bytes: 9176
n = int(input())
a = list(map(int, input().split()))

for i in range(n-1):
    if a[i] < 0:
        a[i] = -a[i]
        a[i+1] = -a[i+1]

if a[n-1] >= 0:
    print(sum(a))
else:
    a[n-1] = -a[n-1]
    print(sum(a) - 2 * min(a))


Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

vector<vl> g;

ll dfs(ll i) {
  ll res = 0;
  priority_queue<ll> q;
  for(auto v : g[i]) q.push(dfs(v));
  for(ll j = 0; !q.empty(); j++) {
    ll now = q.top() + j;
    res = max(res, now);
    q.pop();
  }
  return res + 1;
}

int main() {
  ll n;
  cin >> n;
  g.resize(n);
  rep(i, n - 1) {
    ll a;
    cin >> a;
    a--;
    g[a].push_back(i + 1);
  }
  cout << dfs(0) - 1 << endl;
}

Measured memory_bytes: 17876
import sys
sys.setrecursionlimit(1000000)
N, u, v = map(int, input().split())
u -= 1
v -= 1

G = [[] for _ in range(N)]
elens = [0] * N

for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
    elens[a] += 1
    elens[b] += 1
depths = [0] * N
dists = [0] * N


TAKAHASHI = [0] * N
AOKI = [0] * N

def dfs_aoki(cur: int, past: int, d: int):
    AOKI[cur] = d

    for nx in G[cur]:
        if nx == past:
            continue
        dfs_aoki(nx, cur, d + 1)

def dfs_takahashi(cur: int, past: int, d: int):
    TAKAHASHI[cur] = d

    for nx in G[cur]:
        if nx == past:
            continue
        dfs_takahashi(nx, cur, d + 1)

dfs_takahashi(u, -1, 0)
dfs_aoki(v, -1, 0)

ans = 0

for i in range(N):
    if TAKAHASHI[i] < AOKI[i]:
        ans = max(ans, AOKI[i] - 1)

print(ans)


Measured memory_bytes: 103888
#include<bits/stdc++.h>
using namespace std;
const int maxm = 1e5+10;

int m;
int s[maxm];

int onside(int x,int y)
{
    if(y==s[x])return 1;
    if(y>=s[x+1])
        return 1;
    return 0;
}
int fr(int y)
{
    for(int i=1;i<=m;i++)
        if(s[i]<=y)
            return i-1;
    return m;
}
int fu(int x)
{
    for(int i=1;i<=s[x];i++)
        if(s[x]>=i && s[x+1]<=i)
            return i;
    return s[x+1];
}

int query(int x,int y)
{
    int ret;
    if(onside(x+1,y+1))
    {
        int up = (fu(x)-y)%2;
        int right = (fr(y)-x)%2;
//        cout<<"up="<<up<<" right="<<right<<endl;
        ret= 1^(up && right);
    }
    else
        return query(x+1,y+1);
//    cout<<"query (x,y)="<<x<<","<<y<<"  ret="<<ret<<endl;
    return ret;
}

int main()
{
    //freopen("output.txt","w",stdout);
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
        scanf("%d",&s[i]);
    sort(s+1,s+m+1,greater<int>());
    int ans = query(0,0);
    if(ans==0)
        cout<<"Second"<<endl;
    else
        cout<<"First"<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
int main(){
	ios_base::sync_with_stdio(false);
	int x,a,b;
	cin>>x>>a>>b;
	a=abs(x-a);
	b=abs(x-b);
	if(a>b) cout<<"B";
	else cout<<"A";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, l;
  cin >>n >> l;
  vector<pii> a;
  rep(i, n) {
    a.push_back(pii(abs(i+l), i+l));
  }
  sort(all(a));

  ll sum = 0;
  rep(i, n) {
    sum += a[i].second;
  }

  cout << sum-a[0].second << endl;
}


Measured memory_bytes: 256
#import functools

def main():
    X, Y = tuple(int(c) for c in input().split(' '))
    for i in range(X+1):
        ashi = i*2 + (X-i)*4
        if ashi==Y:
            print('Yes')
            #print(i, X-i)
            break
    else:
        print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
x,n=map(int,input().split())

sett=list(map(int,input().split()))
arr=[i for i in range(-1,102) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)


Measured memory_bytes: 9184
import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())

G = [[] for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    G[x].append(y)

lst = [-1] * (N + 1)


def calc(x):
    if lst[x] != -1:
        return lst[x]
    tmp = 0
    for next_ in G[x]:
        tmp = max(tmp, calc(next_))
    
    lst[x] = tmp + 1
    return tmp + 1

ans = 0
for i in range(1, N + 1):
    if lst[i] == -1:
        ans = max(ans, calc(i))

print (ans - 1)

Measured memory_bytes: 59056
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; cin>>n>>m;
  int a[200020];
  for(int i=0; i<2*n; i++) cin>>a[i];
  sort(a, a+2*n);
  int l=0, r=n+1;
  while(r-l>1){
    int mid=(l+r)/2;
    int mn=2*m;
    for(int i=0; i<mid; i++){
      mn=min(mn, a[2*n-1-i]+a[2*n-1-(2*mid-1-i)]);
    }
    if(mn>=m) l=mid;
    else r=mid;
  }
  int q=l;
  auto check=[&](int x){
    int l=0, r=n+1;
    while(r-l>1){
      int mid=(l+r)/2;
      int mx=0;
      for(int i=0; i<mid; i++){
        mx=max(mx, a[i]+a[2*mid-1-i]);
      }
      if(mx<=x) l=mid;
      else r=mid;
    }
    int p=l;
    if(p==n) return true;
    l=0, r=n+1;
    while(r-l>1){
      int mid=(l+r)/2;
      int mx=0;
      for(int i=0; i<mid; i++){
        mx=max(mx, a[2*n-1-i]+a[2*n-1-(2*mid-1-i)]);
      }
      if(mx<=m+x) r=mid;
      else l=mid;
    }
    //cout<<p<<" "<<q<<" "<<r<<endl;
    if(r>q || q<n-p) return false;
    else return true;
  };
  l=-1, r=m-1;
  while(r-l>1){
    int mid=(l+r)/2;
    if(check(mid)) r=mid;
    else l=mid;
  }
  cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int a,b,r=0;
  cin>>a>>b;
  if(a>b){
    r=a;
    a--;
  }
  else{
    r=b;
    b--;
  }
  if(a>b) r+=a;
  else r+=b;

  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
double l(double x){
  double c=1;
  while(x>c)
    c*=2;
  return c;
}
int main(){
  double n,k,d=0;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    d+=1/l(k/i);
  }
  cout<<fixed<<setprecision(15)<<d/n<<endl;
}

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

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

    int i;
    vector<int> P;
    for(i=0; i<N; i++){
        int pi;
        cin >> pi;
        P.push_back(pi);
    }

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

    int sum;
    sum = 0;
    for(i=0; i<K; i++){
        sum += P[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define pb(x) push_back(x)
#define HAYAKU_HAYAKU ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    HAYAKU_HAYAKU; 
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k; 
    while(b <= a){
        b = b * 2;
        k--;
    }
    while(c <= b){
        c = c * 2;
        k--;
    }
    k >= 0 ? cout<<"Yes" : cout<<"No";
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, A;
int x[60];
map<int, llint> dp[60][60];


void makeDP(){
	dp[0][1][x[0]] = 1;
	rep(i, 1, N){
		repe(j, 1, i){
			for(auto it = dp[i-1][j].rbegin();it != dp[i-1][j].rend();it++){
				int k = it->fi;
				dp[i][j+1][k+x[i]] += dp[i-1][j][k];
			}
			for(pair<int, llint> p : dp[i-1][j]) dp[i][j][p.fi] += p.se;
		}
		dp[i][1][x[i]]++;
	}
}


llint solve(){
	llint ans = 0;
	repe(i, 1, N) ans += dp[N-1][i][i*A];
	return ans;
}


signed main(){
	cin >> N >> A;
	rep(i, 0, N) cin >> x[i];

	makeDP();

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 22528
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int m = Integer.parseInt(line[1]);
        int x = Integer.parseInt(line[2]);
        String[] str_a = br.readLine().split(" ");
        int[] a = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = Integer.parseInt(str_a[i]);
        }
        
        
        int after = 0;
        int before = 0;
        for (int aa : a) {
            if (aa > x) after++;
            else before++;
        }
        System.out.println(Math.min(after, before));
    }
}


Measured memory_bytes: 21204
s=input()
if s[0]!='A':
    print('WA')
elif s[1].isupper():
    print('WA')
elif s[-1].isupper():
    print('WA')
else:
    C=0
    s=s[2:-1]
    for c in s:
        if c=='C':
            C+=1
            if  C>1:
                print('WA')
                break
    if C==1:
        print('AC')
    elif C==0:
        print('WA')


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

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  string ans;
  int length=S.size();
  if (length <= K) cout << S << endl;
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
  cout << "..." << endl;
  } 
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

const int N = 2005;
vector <vector<int>> tree(2, vector<int>(N, 0));
void update(int id, int val, int p) {
	while(id < N) {
		tree[p][id] += val;
		id += (id & -id); 
	}
}
int getsum(int id, int p) {
	int res = 0;
	while(id > 0) {
		res += tree[p][id];
		id -= (id & -id);
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	vector <vector<int>> pb(2 * n + 1, vector<int>(n + 1, 0));
	vector <vector<int>> pw(2 * n + 1, vector<int>(n + 1, 0));
	vector <int> posb(n + 1);
	vector <int> posw(n + 1);
	int cb = 0, cw = 0;
	for (int i = 1; i <= 2 * n; i++) {
		char ch;
		int x;
		cin >> ch >> x;
		if(ch == 'B') {
			update(x, 1, 0);
			cb++;
			posb[x] = i;
		}
		if(ch == 'W') {
			update(x, 1, 1);
			cw++;
			posw[x] = i;
		}
		for (int j = 0; j <= n; j++) {
			pb[i][j] = getsum(n, 0) - getsum(j, 0);
			pw[i][j] = getsum(n, 1) - getsum(j, 1);
		}
	}
	
	vector <vector<int>> dp(n + 1, vector<int>(n + 1, 0));
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i - 1][0] + pb[posb[i]][i] + pw[posb[i]][0];
		dp[0][i] = dp[0][i - 1] + pw[posw[i]][i] + pb[posw[i]][0];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			int a = dp[i - 1][j] + pb[posb[i]][i] + pw[posb[i]][j];
			int b = dp[i][j - 1] + pw[posw[j]][j] + pb[posw[j]][i];
			dp[i][j] = min(a, b);
		}
	}
	cout << dp[n][n];
}


Measured memory_bytes: 78848
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int p[n];
    REP(i,n)cin >> p[i];
    int cnt=0;
    int i = 0;
    while(i<n){
        if(i+1==p[i]){
            if(i+2==p[i+1]){
                cnt++;
                i++;
            }else{
                cnt++;
            }
        }
        i++;
    }
    cout << cnt<< endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) (int)a.size()
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;

int32_t main()
{
	IOS;
	int a,b,k;
	cin>>k;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
using namespace std;

long long cnt[10000010];

int main() {
    for(int i = 1;i <= 10000000;i ++) {
        for(int j = 1;j * i <= 10000000;j ++) {
            cnt[i * j] += 1;
        }
    }
    long long n;
    cin >> n;
    long long sum = 0;
    for(int i = 1;i <= n;i ++) {
        sum = sum + (long long)i * cnt[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 81744
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner  = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] x = new int[n];
		int[] x2 = new int[n];
		int[] y = new int[n - 1];
		int[] b = new int[n];
		int m = 0;
		int m2 = 0;
		for (int i = 0; i < n; i++) {
			x[i] = scanner.nextInt();
		}
		scanner.close();
		
		System.arraycopy(x, 0, x2, 0, n);
		Arrays.sort(x2);
		m = x2[n / 2 - 1];
		m2 = x2[n / 2];
		for (int i = 0; i < n; i++) {
			if (x[i] <= m) {
				System.out.println(m2);
			}else {
				System.out.println(m);
			}
		}
		

	}

}


Measured memory_bytes: 91656
// #define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (i64 i = s; i < (i64)(n); ++i)

void solve() {
    i64 d, t, s;
    cin >> d >> t >> s;
    if (d <= s * t) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3604
/*
今回は　入力される値の最大値がわかっているので、sentinelを使った実装にする
*/

#include <iostream>
#include <vector>

#define SENTINEL 1000000001 //10^9 + 1

using namespace std;

int count=0;


void Merge(vector<int>& A, int left, int mid, int right){
	int i,j,k;
	int n1 = mid-left+1;
	int n2 = right - mid;
	vector<int> L;
	vector<int> R;

	for(i=0; i<n1; i++) L.push_back(A.at(left+i));
	for(i=0; i<n2; i++) R.push_back(A.at(mid+i+1));

	//sentinelを入れる。
	L.push_back(SENTINEL);
	R.push_back(SENTINEL);

	i=0;
	j=0;
	for(k=left; k<=right; k++){
		count++; //比較回数数える
		if( L.at(i)<=R.at(j) ){
			A[k] =L.at(i); //vectorへの上書きこれでいいのか？
			i++;
		}
		else{
			A[k] =R.at(j); //vectorへの上書きこれでいいのか？
			j++;
		}
	}
}


void Merge_Sort(vector<int>& A, int left, int right){
	int mid;

	if(left+1<=right){ //要素が２つ以上あったら
		mid =(left+right)/2;
		Merge_Sort(A, left, mid);
		Merge_Sort(A, mid+1, right);
		Merge(A, left, mid, right);
	}

}


int main() {
    int i,j;
	int buf, n;
    vector<int> S; //AとSどちらにしようか迷ったが、mainの中ではSにした。
    
    cin >> n;
	for(i=0;i<n;i++) {
		cin >> buf;
		S.push_back(buf);
	}

	Merge_Sort(S, 0, n-1);
    
	for(i=0;i<n;i++) {
		cout << S.at(i);
		if(i!=n-1) cout << ' '; else cout << endl; //スペース出すか、改行だすか
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 6004
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String s;
    char[] c;
    int i, j;

    c = new char[10];
    for(;sc.hasNext();){
      s = sc.next();
      for(i = 0;i < 10;i++)c[i] = (char)(s.charAt(i) - '0');
      for(i = 0;i < 10 - 1;i++){
        for(j = 0;j < 9 - i;j++){
          c[j] += c[j + 1]; c[j] = (char)(c[j] % 10);
        }
      }
      out.println((char)(c[0] + '0'));
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17136
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    bool yes = false;
    rep(i,3){
        if(N%10 == 7) yes = true;
        N /= 10;
    }
    cout<<(yes ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
	int i,a=0,b;
	int n, m, k;
	int d, t, s;

	scanf("%d%d%d", &d,&t,&s);

if(d<=s*t)
printf("Yes");
else
{
	printf("No");
}

	return 0;
}

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

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

    int H, W;
    string s = "";
    while(1){
        cin >> H >> W;
        if(H == 0 and W == 0) break;
        else{
            for(int i = 0; i < H; i++){
                if(i % 2 != 0){
                    for(int j = 0; j < W; j++){
                        if(j % 2 != 0) s += "#";
                        else s += ".";
                    }
                }else{
                    for(int j = 0; j < W; j++){
                        if(j % 2 != 0) s += ".";
                        else s += "#";
                    }
                }
                cout << s << endl;
                s = "";
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef complex<double> C;

vector<string> split(stringstream& ss){
	string str;
	vector<string> res;
	while(ss>>str)res.push_back(str);
	return res;
}

int main(){
	int n,d[3][2],t[3];
	string s;
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,3)rep(j,2)d[i][j]=0;
		rep(i,n){
				scanf("%d%*c%d%d",&t[0],&t[1],&t[2]);
				if(t[0]>=11&&t[0]<=14){
						d[0][0]++;
						if((t[2]+60-t[1])%60<=8)d[0][1]++;
				}else if(t[0]>=18&&t[0]<=20){
						d[1][0]++;
						if((t[2]+60-t[1])%60<=8)d[1][1]++;
				}else if((t[0]>=21)||(t[0]>=0&&t[0]<=1)){
						d[2][0]++;
						if((t[2]+60-t[1])%60<=8)d[2][1]++;
				}
		}
		rep(i,3)t[i]=0;
		rep(i,3)if(d[i][0])t[i]=100*(double)d[i][1]/(double)d[i][0];
		cout<<"lunch ";
		if(!d[0][0])cout<<"no guest"<<endl;
		else cout<<t[0]<<endl;
		cout<<"dinner ";
		if(!d[1][0])cout<<"no guest"<<endl;
		else cout<<t[1]<<endl;
		cout<<"midnight ";
		if(!d[2][0])cout<<"no guest"<<endl;
		else cout<<t[2]<<endl;
	}
}

Measured memory_bytes: 1248
n = int(input())
A = list(map(int, input().split()))
d = {}

A.sort()
irregular_cnt=0
reg_cnt = 0
for i in range(n):
    a = A[i]
    a //= 400
    if a>7:
        irregular_cnt += 1
    else:
        d[a] = d.get(a, 0)+1

maxi, mini = 0, 0
for i in d:
    if d[i]>0:
        maxi += 1
        mini += 1
if irregular_cnt:
    maxi += irregular_cnt
    if not mini:
        mini += 1
print(mini, maxi)


Measured memory_bytes: 8952
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		boolean[] red = new boolean[n];
		int[] ball = new int[n];
		Arrays.fill(ball, 1);
		red[0] = true;
		int x, y;
		for (int i = 0; i < m; i++) {
			x = sc.nextInt() - 1;
			y = sc.nextInt() - 1;
			if (red[x]) {
				red[y] = true;
				if (ball[x] == 1) red[x] = false;
			}
			ball[x]--;
			ball[y]++;
		}
		
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (red[i]) count++;
		}
		
		out.println(count);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    fastio();
    int n, m, a, b;
    cin >> n >> m;

    mk(obs, n + 1, int);
    mk(visited, n + 1, bool);

    for (int i = 1; i <= n; i++) {
        cin >> obs[i];
        visited[i] = false;
    }

    vector<int> v[n + 1];

    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int ans = 0;

    for (int i = 1; i <= n; i++) {
        if (visited[i]) continue;

        int nSize = v[i].size();

        if (nSize == 0) {
            ans++;
            visited[i] = true;
            continue;
        }

        int j;
        for (j = 0; j < nSize; j++) {

            if (obs[v[i][j]] < obs[i]) {
                visited[v[i][j]] = true;
            } else {
                visited[i] = true;
                break;
            }
        }

        if (j == nSize) {
            ans++;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 9280
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        
        ArrayList<Integer> m = new ArrayList<Integer>();
        for(int i=0; i<N; i++){
            m.add(Integer.parseInt(sc.next()));
        }
        
        Collections.sort(m);
        
        int ans=0;
        for(int i=0; i<m.size(); i++){
            X -= m.get(i);
            ans++;
        }
        
        while(m.get(0) <= X){
            X -=m.get(0);
            ans++;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,M = MI()
l = LI()
n = N
for i in l:
    n = n-i
    if n<0:
        print(-1)
        break
else:
    print(n)


Measured memory_bytes: 73080
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef double ld;
int n,r;
ld a[50],b[50],A,B,l,P,c;
ld dist(ld a,ld b){
    return a*a+b*b;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        A+=a[i];
        B+=b[i];
    }
    A/=n;
    B/=n;
    P=0.1;
    for(int i=0;i<30000;i++){
        l=dist(a[0]-A,b[0]-B);
        r=0;
        for(int j=1;j<n;j++){
            c=dist(a[j]-A,b[j]-B);
            if(l<c){l=c;r=j;}
        }
        A+=(a[r]-A)*P;
        B+=(b[r]-B)*P;
        P*=0.999;
    }
    cout<<setprecision(15)<<sqrt(l)<<endl;
}


Measured memory_bytes: 256
S = list(input())
count1 = 0
count2 = 0

for i in range(int(len(S)/2)):
    if S[2*i] == "0" and S[2*i+1] == "1":
        count1 += 2
    elif S[2*i] == "1" and S[2*i+1] == "0":
        count2 += 2
    else:
        count1 += 1
        count2 += 1

if len(S)%2 == 0:
    if count1 >= count2:
        print(count2)
    else:
        print(count1)
else:
    if S[-1] == "0":
        count1 += 1
    else:
        count2 += 1
    
    if count1 >= count2:
        print(count2)
    else:
        print(count1)

Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var ps = P.Make(nm[0], nm[1]);
        var bo = new bool[nm[0]];
        var res = true;
        for (var i = 0; i < nm[0]; i++)
            ps[i].Weight = 0;
        for(var i = 0; i < nm[0]; i++)
            if (!bo[i])
            {
                if (!res) break;
                res=dfs(ps, i, bo);
            }
        WriteLine(res ? "Yes" : "No");
    }
    private static bool dfs(P[] ps,int index,bool[] bo)
    {
        bo[index] = true;
        var h = true;
        foreach (var ad in ps[index].adj)
        {
            if (!h) break;
            if (!bo[ad])
            {
                ps[ad].Weight = ps[index].Weight + ps[index].dist[ad];
                h = dfs(ps, ad, bo);
            }
            if (bo[ad])
                h &= ps[ad].Weight - ps[index].Weight == ps[index].dist[ad];
        }
        return h;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class P : IComparable<P>
{
    public int index;
    public List<int> adj;
    public Dictionary<int, int> dist;
    public long Weight;
    public P(int index)
    {
        this.index = index;
        adj = new List<int>();
        dist = new Dictionary<int, int>();
        Weight = long.MaxValue;
    }
    public static P[] Make(int num, int edge, bool isNotDirection = true, bool isWeighted = true)
    {
        var ps = Enumerable.Range(0, num).Select(v => new P(v)).ToArray();
        for (var i = 0; i < edge; i++)
        {
            var inp = Input.ar;
            inp[0]--;
            inp[1]--;
            for (var j = 0; j <= ToInt32(isNotDirection); j++)
            {
                ps[inp[j]].adj.Add(inp[1 - j]);
                if(isWeighted)
                ps[inp[j]].dist[inp[1 - j]] = (1-2*j)*inp[2];
            }
        }
        return ps;
    }
    public override string ToString()
        => $"{index + 1} {Weight}";
    public override int GetHashCode()
        => index.GetHashCode();
    public int CompareTo(P p)
        => Weight.CompareTo(p.Weight);
}


Measured memory_bytes: 74916
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  string s; cin >> s;
  int count = 0;
  REP(i, s.length()) if (s[i] == 'o')  count += 100;
  cout << 700 + count << endl;
}


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

int lcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) {
    return a;
  } else {
    return lcd(b, a % b);
  }
}

vector<int> O;

int b_search(int s, int e, int t) {
  int m = e / 2;
  if (O[m] == t) {
    return m;
  } else if (t < O[m]) {
    return b_search(s, m, t);
  } else {
    return b_search(m, e, t);
  }
}

int main() {
  vector<int> ABC(3);
  for (int i = 0; i < 3; ++i) {
    cin >> ABC[i];
  }
  int K;
  cin >> K;
  int ch = *max_element(ABC.begin(), ABC.end()) * pow(2, K);
  int result = accumulate(ABC.begin(), ABC.end(), 0) - *max_element(ABC.begin(), ABC.end()) + ch;
  cout << result << endl;
}

Measured memory_bytes: 384
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    a=0
    m=0
    do i=2,n
        if(x(i-1)>=x(i))then
            a=a+1
        else
            if(a>m)then
               m=a
            end if

            a=0
        end if
    end do
    if(a>m)then
        m=a
    end if



    write(*,*)m
  
    stop
end program sample
  



Measured memory_bytes: 3740
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int n, m;
    string s, t;
    cin >> n >> m >> s >> t;

    Int ans = -1;
    if (gcd(n, m) == 1) {
        if (s.front() == t.front()) {
            ans = n * m;
        }
    } else {
        Int g = gcd(n, m);
        Int l = lcm(n, m);

        Int bas = l / g;
        Int ro = g;
        bool isex = true;
        for (Int i = 0; i < ro; i++) {
            Int a = i * (n / g);
            Int b = i * (m / g);

            if (s[a] != t[b]) {
                isex = false;
                break;
            }
        }

        if (isex) {
            ans = l;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {   
    public static void main(String[] args) {    	    	
        long N, M;
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt(); M = sc.nextInt();

		if (N>=2 && M>=2) System.out.println((N-2)*(M-2));
		else if (N==1 && M==1) System.out.println(1);
		else if (N==1) System.out.println(M-2);
		else System.out.println(N-2);	
		
		sc.close();
    }
}

Measured memory_bytes: 21844
from heapq import heappush, heappop


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    h = []
    for a in A:
        heappush(h, -a)
    for _ in range(M):
        x = -heappop(h)
        heappush(h, -(x//2))
    ans = -sum(h)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64792
#include <iostream>
using namespace std;
#define ll long long

int main() {
	ll a,b,c,d,maxi;
	
	cin>>a>>b>>c>>d;
	maxi = a*c;
	maxi = max(maxi , a*d);
	maxi = max(maxi, b*c);
	maxi  = max(maxi, b*d);
	
	cout<<maxi;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define N 10
using namespace std;

int main(){
  int a[N],b[N],ansa,ansb;
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  sort(a,a+N,greater<int>());
  sort(b,b+N,greater<int>());
  ansa=ansb=0;
  for(int i=0;i<3;i++)ansa+=a[i];
  for(int i=0;i<3;i++)ansb+=b[i];
  cout<<ansa<<' '<<ansb<<endl;
  return 0;
}

Measured memory_bytes: 1176
using System;
class Program
{
	static void Main()
	{
	int a = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    string[] stringPlus = new string[a];
      for(int i = 0; i < a; i++)
	stringPlus[i] = Console.ReadLine();//Splitで区切り文字を指定して複数個受け取る。
      int b = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    string[] stringMinus = new string[b];
      for(int i = 0; i < b; i++)
	stringMinus[i] = Console.ReadLine();
      
      int maxPoint = 0;
      int point = 0;
      
      for(int i = 0; i < a; i++)
      {
        point = 0;
        for(int j = 0; j < a; j++)
        {
          if(stringPlus[i] == stringPlus[j])point++;
        }
        for(int j = 0; j < b; j++)
        {
          if(stringPlus[i] == stringMinus[j])point--;
        }
        if(point > maxPoint)maxPoint = point;
      }

	//出力
	Console.WriteLine(maxPoint);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#define CLR(array) memset( array, 0, sizeof array )
typedef long long int ll;



int n,k;

int const MAXN = 510000;
int const MOD = 1000000007;

long long fac[MAXN], finv[MAXN], inv[MAXN];
long long A[MAXN];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAXN; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool cmp_reverse( int a, int b ){
	return a > b;
}



int main(){
	COMinit();

	std::cin >> n >> k;

	for( int i = 1; i <= n; i++ )
		std::cin >> A[i];

	

	ll maxsum = 0;
	ll minsum = 0;

	std::sort( A+1, A+1+n );
	for( int i = k; i <= n; i++ ){
		maxsum = ( maxsum + A[i] * COM( i-1, k-1 ) % MOD ) % MOD;
		// printf("maxsum = %lld\n", maxsum);
	}

	std::sort( A+1, A+1+n, cmp_reverse );
	for( int i = k; i <= n; i++ ){
		minsum = ( minsum + A[i] * COM( i-1, k-1 ) % MOD ) % MOD;
	}
	
	// printf("maxsum = %lld, minsum = %lld\n", maxsum, minsum );
	std::cout << (maxsum - minsum + MOD) % MOD << std::endl;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int Q;
    cin >> Q;

    priority_queue<ll, vector<ll>, less<ll>> left;
    priority_queue<ll, vector<ll>, greater<ll>> right;

    left.push(-INF);
    right.push(INF);

    int n = 0;
    ll f = 0;

    REP(i, Q){
        int q;
        cin >> q;

        if(q == 2){
            cout << left.top() << " " << f << '\n';
            continue;
        }

        ll a, b;
        cin >> a >> b;

        ll l = left.top(), r = right.top();
        f += (l <= a && a <= r ? 0 : min(abs(a-l), abs(a-r))) + b;

        if(n%2 == 0){
            if(a > r){
                left.push(r);
                right.push(a);
            }else if(a < l){
                left.push(a);
                right.push(l);
            }else{
                left.push(a);
                right.push(a);
            }
        }else{
            if(a >= r){
                right.pop();
                right.push(a);
            }else{
                left.pop();
                left.push(a);
            }
        }

        n++;
    }
}


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

typedef unsigned long long ll;

int n;
vector<int> V;

void solve(){
	V.clear();
	for(int i=0;i<n;i++){
		int r;
		cin>>r;
		V.push_back(r);
	}

	vector<ll> now(21,0),bef(21,0);

	bef[V[0]]=1;

	for(int i=1;i<n-1;i++){
		int r=V[i];
		for(int z=0;z<=20;z++){
			if(r+z>=0 && r+z<=20)
				now[r+z]+=bef[z];
			if(z-r>=0 && z-r<=20)
				now[z-r]+=bef[z];
		}
		swap(now,bef);
		now.assign(21,0);
	}

	cout<<bef[V[n-1]]<<endl;

}

int main()
{
	while(cin>>n){
		solve();
	}
	return 0;
}

Measured memory_bytes: 0