akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[20];
int B[20];
int C[20];
int main(){
  int i;
  int res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(N);KL2GvlyY++){
      rd(B[KL2GvlyY]);
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=0;Q5VJL1cS<(N-1);Q5VJL1cS++){
      rd(C[Q5VJL1cS]);
    }
  }
  {
    int e98WHCEY;
    int cTE1_r3A;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = B[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A += B[e98WHCEY];
      }
    }
    res =cTE1_r3A;
  }
  for(i=(1);i<(N);i++){
    if(A[i-1]+1==A[i]){
      res += C[A[i-1]];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// int N, A[20], B[20], C[20];
// {
//   int res;
//   rd(N,(A--)(N),B(N),C(N-1));
//   res = sum(B(N));
//   rep(i,1,N) if(A[i-1]+1==A[i]) res += C[A[i-1]];
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	char a[2][3];
	for(int i=0;i<2;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	if(a[0][0]==a[1][2]&&a[0][1]==a[1][1]&&a[0][2]==a[1][0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class BIT():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.UNITY_SUM = 0
        self.dat = [[self.UNITY_SUM for i in range(n + 1)] for j in range(2)]
    
    def sub_ADD(self, p, a, x):
        i = a
        while i < len(self.dat[p]):
            self.dat[p][i] = self.dat[p][i] + x
            i += i & -i
    
    def ADD(self, a, b, x):
        self.sub_ADD(0, a, x * -(a - 1))
        self.sub_ADD(1, a, x)
        self.sub_ADD(0, b, x * (b - 1))
        self.sub_ADD(1, b, x * (-1))
    
    def sub_SUM(self, p, a):
        res = self.UNITY_SUM
        i = a
        while i > 0:
            res += self.dat[p][i]
            i -= i & -i
        return res
    
    def SUM(self, a, b):
        return self.sub_SUM(0, b - 1) + self.sub_SUM(1, b - 1) * (b - 1) - self.sub_SUM(0, a - 1) - self.sub_SUM(1, a - 1) * (a - 1)
    
    def PRINT(self):
        for i in range(1, len(self.dat[0])):
            print(self.SUM(i, i + 1), end = "")
            print(",", end = "")
        print()

def main():
    N, Q = map(int,readline().split())
    C = list(map(int,readline().split()))  #対象のリスト
    S = sys.stdin.readlines()
    lefts = [0] * Q
    rights = [0] * Q
    ids = [0] * Q
    for i in range(Q):
        lefts[i], rights[i] = map(int,S[i].split())
        lefts[i] -= 1
        ids[i] = i
    
    ids = sorted(ids, key=lambda x: rights[x])

    bit = BIT(N+5)
    prev = [-1] * 1100000
    res = [0] * Q
    r = 0
    for i in ids:
        while r < rights[i]:
            bit.ADD(prev[C[r]]+2, r+2, 1)
            prev[C[r]] = r
            r += 1
        tmp = bit.SUM(lefts[i]+1, lefts[i]+2)
        res[i] = max(res[i], tmp)
    for i in range(Q):
        print(res[i])

main()

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

int main() {
  int n;
  int a;
  int max = 0;
  int min = 1000000000 + 1;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    if(a >= max) max = a;
    if(a <= min) min = a;
  }
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	double a,b,C,c;
	double S,L,h;
	
	scanf("%lf %lf %lf",&a,&b,&C);
	
	C =C*3.14159265 / 180;
	
	S = 0.5*a*b*sin(C);
	c = sqrt(a*a+b*b-2*a*b*cos(C));
	L = a+b+c;
	h = S*2/a;
	printf("%.5f\n",S);
	printf("%.5f\n",L);
	printf("%.5f\n",h);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 200005
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
  ll res = 1;

  x = x % p;

  if (x == 0)
    return 0;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }

  return res;
}
void solve()
{
  ll n;
  cin>>n;
  if(n==1)
  {
    cout<<0<<endl;
    return;
  }
  if(n==2)
  {
    cout<<2<<endl;
    return;
  }
  ll tot=power(10,n,mod);
  ll m1=power(8,n,mod);
  ll m2=(power(9,n,mod)-power(8,n,mod)+mod)%mod;
  m2*=2;
  ll ge=(m1+m2)%mod;
  cout<<(tot-ge+mod)%mod<<endl;


}

int main()
{
  speed;
  ll kk;
  kk = 1;
  //cin >> kk;
  while (kk--)
  {
    solve();
  }
  return 0;
}

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

int main()
{
	ll n,w;
	cin>>n>>w;

	ll*weight=new ll[n];
	ll*value=new ll[n];

	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;

		weight[i]=x;
		value[i]=y;
	}

	vector<vector<ll> > dp(n+1,vector<ll> (w+1,0));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(j-weight[i-1]>=0)
				dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);

			else
				dp[i][j]=dp[i-1][j];
		}
	}

	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    set < int > s;
    for (int i = 1; i <= n; i++) s.insert(i);
    for (int i = 1; i <= k; i++) {
        int x;
        cin >> x;
        for (int j = 1; j <= x; j++) {
            int y;
            cin >> y;
            s.erase(y);
        }
    }
    cout << s.size() << '\n';
    return 0; 
}
 

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		//String s = sc.next();
		long count=0;
		long l=0,x=0;
		String buff="";
		//long[][] array=new long[n][2];

		if(n<=m) {
			for(int i=0;i<m;i++) {
				buff+=n;
			}
			System.out.println(Integer.parseInt(buff));
		}else {
			for(int i=0;i<n;i++) {
				buff+=m;
			}
			System.out.println(Integer.parseInt(buff));
		}

		//System.out.println(count);
	}
}




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

using namespace std;

#define ll               long long int
#define endl             '\n'

static const int maxn = 3e5 + 5;

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


      string s, t;
      cin >> s >> t;
      int ans = 0;
      for (int i = 0; i < 3; i++) if (s[i] == t[i]) ++ans;
      cout << ans << endl;
}


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

#define int long long
#define all(x) x.begin(), x.end()
#define forn(i, x) for(int i = i; i < x; ++i)

using namespace std;

int INF = 1e16 + 7;

void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s) cout << "Yes";
    else cout << "No";
}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cout << setprecision(10) << fixed;
   
    solve();

    return 0;
}

Measured memory_bytes: 3168
N,M = map(int,input().split())
P=[]
for _ in range(M):
  p,y = map(int,input().split())
  P.append((p,y))
d = {}
for p,y in P:
  if p not in d:
    d[p]=[]
  d[p].append(y)
sd = {k:dict(zip(sorted(v),range(1,1+len(v))))
      for k,v in d.items()}
for p,y in P:
  print('%06d%06d' % (p, sd[p][y]))


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

//#pragma GCC optimize("Ofast")
const int maxn = 1e6 + 1;
using namespace std;
using ld = long double;
using ll = int64_t;
const ld EPS = 1e-9;

int main() {
#ifdef zxc
//    freopen("../farhod_output.txt", "w", stdout);
//    freopen("../kolya_input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int k;
    cin >> k;
    if (s.size() == 1) {
        cout << k / 2;
        return 0;
    }
    if (k == 1) {
        int cnt = 1;
        int ans = 0;
        for (int i = 0; i + 1 < s.size(); ++i) {
            if (s[i] == s[i + 1]) {
                ++cnt;
            } else {
                ans += cnt / 2;
                cnt = 1;
            }
        }
        ans += cnt / 2;
        cout << ans;
        return 0;
    }
    vector<pair<int, int>> pp;
    int l = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != s[l]) {
            pp.emplace_back(l, i - 1);
            l = i;
        }
    }
    pp.emplace_back(l, (int) s.size() - 1);
    if (pp.size() == 1) {
        cout << (ll(s.size()) * k) / 2;
    } else {
        ll ans = 0;
        if (s.back() == s.front()) {
            int len = pp.back().second - pp.back().first + 1 + pp.front().second - pp.front().first + 1;
            ans = 1ll * (len / 2) * (k - 1);
            for (int i = 1; i + 1 < pp.size(); ++i) {
                ans += 1ll * (pp[i].second - pp[i].first + 1) / 2 * k;
            }
            ans += 1ll * (pp[0].second - pp[0].first + 1) / 2;
            ans += 1ll * (pp.back().second - pp.back().first + 1) / 2;
        } else {
            for (int i = 0; i < pp.size(); ++i) {
                ans += 1ll * (pp[i].second - pp[i].first+1) / 2 * k;
            }
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    printf("%d\n", (int)pow((int)sqrt(N), 2));

    return 0;
}

Measured memory_bytes: 2116
import java.util.Scanner;

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

        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        if (a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)){
        	System.out.println("YES");
        }else {
        	System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22740
import bisect

N = int(input())
s = sorted(list(map(int,input().split())))
m = sorted(list(map(int,input().split())))
l = sorted(list(map(int,input().split())))
count = 0
for mitem in m:
  count += bisect.bisect_left(s,mitem)*(N-bisect.bisect_right(l,mitem))
print (count)

Measured memory_bytes: 23476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll X; cin >> X;
    if (X<600) cout << 8 << "\n";
    else if (X<800) cout << 7 << "\n";
    else if (X<1000) cout << 6 << "\n";
    else if (X<1200) cout << 5 << "\n";
    else if (X<1400) cout << 4 << "\n";
    else if (X<1600) cout << 3 << "\n";
    else if (X<1800) cout << 2 << "\n";
    else if (X<2000) cout << 1 << "\n";
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = (n - 1 + k - 2) / (k - 1);
		System.out.println(ans);

	}

}


Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.println(s.substring(0, 1) + String.valueOf(s.length() - 2) + s.substring(s.length()-1, s.length()));
	}

}


Measured memory_bytes: 23124
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int n;
  cin >> n;
  int a[101];
  rep(i, n) cin >> a[i];
  int alice = 0;
  int bob = 0;

  sort(a, a+n, greater<int>());

  rep(i, n) {
    if(i%2) {
      bob += a[i];
    }else {
      alice += a[i];
    }
  }

  cout << alice-bob << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	cin >> n;
	vector<int> A(n + 1);
	vector<vector<long long>> dp(n + 1, vector<long long>(2));
	for (int i = 1; i <= n; ++i) {
		cin >> A[i];
	}		
	dp[1][0] = A[1];
	dp[1][1] = -A[1];
	for (int i = 2; i <= n; ++i) {
		dp[i][0] = max(dp[i - 1][0] + A[i], dp[i - 1][1] - A[i]);
		dp[i][1] = max(dp[i - 1][0] - A[i], dp[i - 1][1] + A[i]);
	}
	
	cout << dp[n][0];
	return 0;
}

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

using namespace std;

using int64 = long long;

vector< string > rot(vector< string > &s) {
  vector< string > t(s[0].size(), string(s.size(), '*'));
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < s[i].size(); j++) {
      t[j][i] = s[i][s[i].size() - j - 1];
    }
  }
  return t;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector< string > S(H);
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }

  int64 ret = 0;
  for(int i = 0; i < 4; i++) {
    S = rot(S);
    vector< int > st[600];
    for(int j = 0; j < S.size(); j++) {
      for(int k = 0; k < S[j].size(); k++) {
        if(S[j][k] == '#') st[j + k].emplace_back(j - k);
      }
    }
    for(int j = 0; j < 600; j++) {
      sort(begin(st[j]), end(st[j]));
    }
    for(int j = 0; j < 600; j++) {
      for(int k = 0; k < st[j].size(); k++) {
        for(int l = k + 1; l < st[j].size(); l++) {
          auto d = st[j][l] - st[j][k];
          if(j + d >= 600) continue;
          auto &it = st[j + d];
          ret += lower_bound(begin(it), end(it), st[j][l]) - lower_bound(begin(it), end(it), st[j][k]);
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 900
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner (System.in);
    String str = sc.next();
    char[] array = str.toCharArray();
    String ans = "Yes";
    A:for (int j=0; j<array.length; j++) {
      if (j%2 != 0) {
        switch (array[j]) {
          case 'R':
            ans = "No";
            break A;
        }
      } else {
        switch (array[j]) {
          case 'L':
            ans = "No";
            break A;
        }
      }
    }
      System.out.println(ans);
  }
}

Measured memory_bytes: 35548
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
#define gcn(N) \
    int N;     \
    cin >> N;
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e)
{
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v)
{
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv)
{
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
/*


*/

signed main()
{
    gcn(N);
    string S;
    cin >> S;
    int count = 1;
    rep(i, N - 1)
    {
        if (!(S[i] == S[i + 1]))
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 512
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, W; cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  ll V = 1000 * n;
  vector<vector<ll>> dp(2, vector<ll>(V+1, linf));
  dp[0][0] = 0;
  rep(i, n) {
    dp[i+1&1].assign(V+1, linf);
    rep(j, V+1) {
      chmin(dp[i+1&1][j], dp[i&1][j]);
      ll nj = j + v[i];
      if (nj <= V) {
        chmin(dp[i+1&1][nj], dp[i&1][j]+w[i]);
      }
    }
  }
  ll ans = 0;
  rep(j, V+1) if (dp[n&1][j] <= W) chmax(ans, j);
  cout << ans << endl;
}


Measured memory_bytes: 2560
N = int(input())
S = input()
ans = N

A = []
w = 0
for si in S:
    if si == 'W':
        w += 1
    A.append(w)

e = 0
for i, si in enumerate(S[::-1]):
    if si == 'E':
        e += 1
    ans = min(ans, A[-1 * i - 1] + e - 1)

print(ans)

Measured memory_bytes: 15392
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <cmath>
#include <string>
#include <sstream>
#include <cstdlib>
#include <iomanip>

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define debug(x) cout << #x << " : " << x << endl

using namespace std;

typedef vector<int> VI;
typedef long long LL;


int main()
{
    int n,k;
    cin >> n >> k;
    LL res = k * pow(k-1, n-1);
    std::setprecision(10);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b){cout<<"YES";}
    else{cout<<"NO";}
    
    
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;

struct init_{init_(){ ios::sync_with_stdio(false); cin.tie(0); }} init__;

static const long long mo = 1e9+7;

int main(void) {
    ll n, c; cin >> n >> c;
    vll a(n), b(n); rep(i, n) cin >> a[i]; rep(i, n) cin >> b[i];
    ll M = 410;
    vvll dp(M, vll(M));
    vvll jk(M, vll(M, 1)); // j^k
    rep(j, M) rep(k, M-1) {
        (jk[j][k+1] = j * jk[j][k]) %= mo;
    }

    vvll jksum(M, vll(M)); // \sum_{x \in [0, k)} j^x 
    rep(k, M) rep(j, M-1) {
        (jksum[j+1][k] = jk[j][k] + jksum[j][k]) %= mo;
    }

    // \sum_{j \in [l, r]} j^k = jksum[r+1][k] - jksum[l][k];
    auto f = [&](ll i, ll k) {
        return (jksum[b[i]+1][k] - jksum[a[i]][k] + mo) % mo;
    };

    dp[0][0] = 1;
    repi(alpha, 1, n+1)  rep(beta, c+1) rep(k, beta+1) 
        (dp[alpha][beta] += f(alpha-1, k) * dp[alpha-1][beta - k]) %= mo;

    cout << (dp[n][c] + mo) % mo << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int INF = 1e9;


int main(int argc, char *argv[])
{
  int H, W, N, sx, sy;
  string S, T;
  int sl = 0, sr = 0, su = 0, sd = 0, tl = 0, tu = 0, td = 0, tr = 0;
  cin >> H >> W >> N;
  cin >> sy >> sx;
  cin >> S;
  cin >> T;
  int midx = W/2, midy = H/2;

  bool found = false;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'D') { sd++; }
    else if (S[i] == 'U') { su++; }
    else if (S[i] == 'L') { sl++; }
    else if (S[i] == 'R') { sr++; }

    if (W < sx + sr) {
      found = true;
    } else if (0 >= sx - sl) {
      found = true;
    } else if (H < sy + sd) {
      found = true;
    } else if (0 >= sy - su) {
      found = true;
    }

    if (found) break;

    if (T[i] == 'D') {
      if (sy - su < midy) su--;
    } else if (T[i] == 'U') {
      if (sy + sd > midy) sd--;
    } else if (T[i] == 'L') {
      if (sx + sr > midx) sr--;
    } else if (T[i] == 'R') {
      if (sx - sl < midx) sl--;
    }
  }

  if (found) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define iter(a, b, c) for(auto(a) = (b); (a) < (c); ++(a))

using namespace std;
using namespace __gnu_pbds; 

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pp;
typedef vector<pp> vpp;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef tree<int, null_type, less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int fpower(int x, unsigned int y, int p)  
{  
    int res = 1; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

int minimum(int x,int y){
    if(x<y)
        return x;
    else return y;
}

int maximum(int x,int y){
    if(x>y)
        return x;
    else return y;
}

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

int lcm(int a,int b){
    return (a*b/gcd(a,b));
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int k = 1;
  	while((n*k)%360!=0)
   		k++;
  	cout<<k<<endl;
}

Measured memory_bytes: 3656
import sys
INF = 10**9
sys.setrecursionlimit(INF)


def main():
    s, t = open(0).read().split()

    if s == t[:-1]:
        ans = 'Yes'
    else:
        ans = 'No'

    print(ans)
    return(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8980
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    double hea=0;
    ll n;
    cin >> n;
    vector<ll> a(n);
    int i;
    long double go=0;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        go+=a.at(i);
    }
    long avg;
    avg = go/n;
    hea= (go/n)-avg;

    ll cost=0;
    if(hea>0.5)avg++;
    for(i=0;i<n;i++){
        ll p;
        p=pow((a.at(i)-avg),2);
        cost+=p;
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[[[0 for _ in range(10)]for _ in range(3)]for _ in range(4)]
for i in range(n):
    b,f,r,v=map(int, input().split())
    a[b-1][f-1][r-1]+=v
for bb in range(4):
    for ff in range(3):
        print(*[""]+a[bb][ff])
    if bb==3:
        break
    else:
        print("#"*20)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char x;
    cin>>x;
    if(x>=65 && x<=90)
    cout<<"A";
    else
    cout<<"a";
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}


int main() {
    int N(in()), M(in());
    set<int> k[M];

    for (int i = 0; i < M; i++) {
        int temp(in());
        for (int j = 0; j < temp; j++) {
            k[i].insert(in() - 1);
        }
    }

    int p[M];
    for (int i = 0; i < M; i++) {
        p[i] = in();
    }

    int end =  pow(2, N);
    int count = 0;
    for (int machine = 0; machine < end; machine++) {
        bitset<10> temp(machine);
        int i;
        for (i = 0; i < M; i++) {
            int minCount = 0;
            for (auto j : k[i]) {
                if (temp.test(j)) minCount++;
            }
            if ((minCount & 1) != p[i]) break;
           
        }
        if (i == M) count++;
    }

    cout << count << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<Integer, Integer> m = new HashMap<>();
        for (int i = 0; i < 12; i++) {
            int n = sc.nextInt();
            if (m.containsKey(n)) {
                m.put(n, m.get(n) + 1);
            } else {
                m.put(n, 1);
            }
        }
       boolean f=true;
        for (Map.Entry<Integer, Integer> e : m.entrySet()) {
            if (e.getValue() % 4 != 0) {
                f=false;
            }
        }
        System.out.println(f ? "yes" : "no");
    }
}


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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M, Q; 
  cin >> N >> M >> Q;
  N++;


  vector<vector<int>> ans(1000, vector<int>(1000));
  REP(i, M){
    int l, r;
    cin >> l >> r;
    ans[l][r]++;
  }

  REP(i, N+1) FOR(j, 1, N+1) ans[i][j] += ans[i][j-1];
  FOR(i, 1, N+1) REP(j, N+1) ans[i][j] += ans[i-1][j];

  REP(i, Q){
    int p, q;
    cin >> p >> q;
    cout << ans[q][q]-ans[q][p-1]-ans[p-1][q]+ans[p-1][p-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <string>
using namespace std;
int centerLength(string s){
    int length=s.length();
    char c=s[length/2];
    int left=(length-1)/2;
    int right=length-left-1;
    int ans=-length%2;
    for(int i=0;i<=left;i++){
        if(c==s[left-i]&&c==s[right+i]){
            ans+=2;
        }else{
            return ans;
        }
    }
    return length;
}
int main(){
    string s;
    cin>>s;
    int w=centerLength(s);
    cout<<w+(s.length()-w)/2<<endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) {
    cin >> s[i];
  }
  // Now, s[i][j] is the cell
  vector<vector<ll> > ans(h, vector<ll>(w, -1));

  vector< vector<ll> > straberies(h);
  ll strabery = 1;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') {
        straberies[i].push_back(strabery);
        strabery = min(k, strabery + 1);
      }
    }
  }

  rep(i, h) {
    if (straberies[i].size() == 0) {
      // We set this value later.

      // if (i == 0) { continue; } // Treat later.

      // rep(j, w) {
      //   ans[i][j] = ans[i-1][j]; // Same with prev.
      // }
    } else { // straberies[i].size() >= 1
      ll ss = straberies[i][0];
      ll last_s = straberies[i][straberies[i].size()-1];
      rep(j, w) {
        if (s[i][j] == '#') { // s found
          ans[i][j] = ss;
          ss = min(last_s, ss + 1); // Set next strabery
        } else {
          ans[i][j] = ss;
        }
      }
    }
  }

  // We set -1
  rep(i, h) {
    rep(j, w) {
      if (ans[i][j] == -1) { // not defined.
        if (i >= 1) {
          ans[i][j] = ans[i-1][j];
        }
      }
    }
  }
  for (int i = h - 1; i >= 0; --i) {
    rep(j, w) {
      if (ans[i][j] == -1) { // not defined.
        if (i+1 <= h-1) {
          ans[i][j] = ans[i+1][j];
        }
      }
    }
  }

  // TODO(set i = 0 and cnts[0] = 0 case.)
  // if ((straberies[0].size() == 0) && (h >= 2)) {
  //   rep(j, w) {
  //     ans[0][j] = ans[1][j];
  //   }
  // }

  rep(i, h) {
    rep(j, w) {
      cout << ans[i][j];
      if (j != w-1) {
        cout << " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int h,w;
vector<vector<char>> grid;
vector<vector<int>> dist;
int sx,sy,ex,ey;
int d4x[] = {0,1,0,-1};
int d4y[] = {1,0,-1,0};

void bfs( int x , int y ){
    deque<pair<int,int>> q;
    q.push_front({x,y});
    while(!q.empty()){
        pair<int,int> p = q.front();
        q.pop_front();
        int fx = p.ft;
        int fy = p.sd;
        rep(d,0,4){
            int nx = fx + d4x[d];
            int ny = fy + d4y[d];
            if ( nx >= h || ny >= w || nx < 0 || ny < 0 )continue;
            if ( grid[nx][ny] == '#' )continue;
            if ( dist[fx][fy] < dist[nx][ny] ){
                dist[nx][ny] = dist[fx][fy];
                q.push_front({nx,ny});
            }
        }

        for ( int dx = -2 ; dx <= 2 ; dx++ ) {
            for ( int dy = -2 ; dy <= 2 ; dy++ ){
                int nx = fx + dx;
                int ny = fy + dy;
                if ( nx >= h || ny >= w || nx < 0 || ny < 0 )continue;
                if ( grid[nx][ny] == '#' )continue;
                if ( dist[fx][fy] + 1 < dist[nx][ny] ){
                    dist[nx][ny] = 1 + dist[fx][fy];
                    q.push_back({nx,ny});
                } 
            }
        }
    }
}

//START OF CODE ->->->->->->->

void solve()
{
    cin>>h>>w;
    cin>>sx>>sy;
    cin>>ex>>ey;
    sx--;sy--;ex--;ey--;
    grid = vector<vector<char>>(h,vector<char>(w));
    dist = vector<vector<int>>(h,vector<int>(w,inf));
    dist[sx][sy] = 0;
    rep(i,0,h){
        rep(j,0,w){
            cin>>grid[i][j];
        }
    }
    bfs(sx,sy);

    cout<<((dist[ex][ey] == inf)?-1:dist[ex][ey])<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 12552
#include <iostream>
#include <cstdio>
#include <algorithm>

typedef long long LL;

const int MAXN = 2e5;
const LL INF = 0x3f3f3f3f;

int n;
int mins[MAXN | 1], maxs[MAXN | 1];
LL ans;

struct Num {
	int a, b;
	Num() {}
	friend bool operator < (const Num &x, const Num &y) {
		return x.a < y.a;
	}
} p[MAXN | 1];

inline int read() {
	register int x = 0;
	register char ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}

int main() {
	n = read();
	int min = 0, max = INF;
	int bmax = -1, rmax = -1;
	int bmin = INF, rmin = INF;
	for (int i = 1; i <= n; ++i) {
		p[i].a = read();
		p[i].b = read();
		if (p[i].a > p[i].b) std::swap(p[i].a, p[i].b);
		bmax = std::max(bmax, p[i].b);
		bmin = std::min(bmin, p[i].b);
		rmax = std::max(rmax, p[i].a);
		rmin = std::min(rmin, p[i].a);
	}
	std::sort(p + 1, p + 1 + n);
	ans = 1LL * (bmax - bmin) * (rmax - rmin);
	bmin = rmin;
	LL ans2 = INF;
	maxs[1] = mins[1] = p[1].b;
	for (int i = 2; i <= n; ++i) {
		maxs[i] = std::max(maxs[i - 1], p[i].b);
		mins[i] = std::min(mins[i - 1], p[i].b);
		if (i != n) ans2 = std::min(ans2, 1LL * std::max(maxs[i], p[n].a) - std::min(mins[i], p[i + 1].a));
	}
	printf("%lld\n", std::min(ans, ans2 * (bmax - bmin)));
	return 0;
}


Measured memory_bytes: 3328
/*
 * ===================================================================
 *
 *       Filename:  ata.cpp
 *
 *           Link:  
 *
 *        Created:  2019/04/20 20时00分32秒
 *
 *         Author:  duny31030 , duny31030@126.com
 *   Organization:  duny31030.top
 *
 * ===================================================================
 */
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define pre(i,a,n) for(int i=n;i>=a;i--)
#define ll long long
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int a,b,c;

int main()
{
	cin >> a >> b >> c;
	if(a < b && c < b && a < c)
	{
		cout << "Yes" << endl;
	}
	else 
	{
		if(a > b && a > c && c > b)
		{
			cout << "Yes" << endl;
		}
		else 
		{
			cout << "No" << endl;
		}
	}
    

    return 0;
}



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

bool ok(int i){
	int a=i/1000;
	int b=i%100;
	int c1=a/10,c2=a%10,d1=b/10,d2=b%10;
//	printf("%d %d%d %d%d\n",i,c1,d2,c2,d1);
	if(c1==d2&&c2==d1)return 1;
	else return 0;
}

	
		
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int sum=0;
	for(int i=a;i<=b;i++){
		if(ok(i)){sum++;}
	}
	printf("%d\n",sum);
	return 0;
}
	

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll n;
    cin >> n;

    ll ans(0);
    for (ll i=1; i<=n; ++i)
    {
        if (i%3 == 0)
            continue;

        if (i%5 == 0)
            continue;

        //cout << i << endl;

        ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
N = int(input())
S = list(input())
ans = []
abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(len(S)):
    for j in range(len(abc)):
        if S[i] == abc[j].upper():
            if j + N < 26:
                ans.append(abc[j + N])
            else:
                ans.append(abc[j + N -26])


print("".join(ans).upper())


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int [] a = new int[m];
        for (int i = 0 ; i < m ; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0 ; i < m ; i++) {
            sum += a[i];
        }
        System.out.println(Math.max(-1, n - sum));
    }

}


Measured memory_bytes: 46308
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let split: Vec<&str> = input.split(' ').collect();

    let a: i32 = split[0].trim().parse().unwrap();
    let b: i32 = split[1].trim().parse().unwrap();
    let c: i32 = split[2].trim().parse().unwrap();

    if 0 <= a && a <= 100 && 0 <= b && b <= 100 && 0 <= c && c <= 100 {
        if a < b && b < c {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}



Measured memory_bytes: 5028
#include <stdio.h>

int main()
{
    int arr1[]={1,3,5,7,8,10,12};
    int arr3[]={2};
    int arr2[]={4,6,9,11};
    int x,y,i,flag1=2,flag2=3,flag3=4,flag4=5;
    scanf("%d%d",&x,&y);
    if((x==2)||(y==2))
    {
        printf("No");
        exit(0);
    }
     for(i=0;i<7;i++)
    {
        if(x==arr1[i])
        flag1=1;
    }
    for(i=0;i<7;i++)
    {
        if(y==arr1[i])
        flag2=1;
    }
     for(i=0;i<4;i++)
    {
        if(x==arr2[i])
        flag3=1;
    }
     for(i=0;i<4;i++)
     {
        if(y==arr2[i])
        flag4=1;
    }
    if((flag1==flag2)||(flag3==flag4))
    {
        printf("Yes");
        exit(0);
    }
    else printf("No");
    return 0;
}


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

#define MOD 998244353

typedef long long ll;

ll fct[222222] = { 1, 1 }, inv[222222] = { 1, 1 }, fiv[222222] = { 1, 1 }, pow[222222] = { 1 };

ll combination(ll n, ll r)
{
	return fct[n] * fiv[r] % MOD * fiv[n - r] % MOD;
}

int main(void)
{
	ll n, m, k, i, ans = 0;

	cin >> n >> m >> k;

	pow[1] = m - 1;
	for (i = 2; i < n; i++)
	{
		fct[i] = fct[i - 1] * i % MOD;
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fiv[i] = fiv[i - 1] * inv[i] % MOD;
		pow[i] = pow[i - 1] * (m - 1) % MOD;
	}

	for (i = 0; i <= k; i++)
	{
		ll add = m * combination(n - 1, i) % MOD * pow[n - 1 - i] % MOD;
		ans = (ans + add) % MOD;
	}

	cout << ans;
	return 0;
}

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

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


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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = in.nextInt();
		}
		Arrays.sort(h);
		int min = h[k-1] - h[0];
		for(int i=k;i<n;i++) {
			min = Math.min(min, h[i]-h[i-k+1]);
		}
		System.out.println(min);
		in.close();
	}

}


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

int main(void)
{
	int t;
	cin >> t;
	int hour = t / 3600;
	int min = (t - 3600 * hour) / 60;
	int sec = t - 3600 * hour - 60 * min;

	cout << hour << ":" << min << ":" << sec << endl;
	return 0;
}


Measured memory_bytes: 3116
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int bit = 0;
        for (int i=0; i<a; i++) {
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}


Measured memory_bytes: 23508