akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// template {{{
/* vim: set foldmethod=marker: */

// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14

// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

// input
template <class T> inline T in_(){ T x; cin >> x; return x; }

// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

// repetition
#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 REPit(type, i, obj) for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj) for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)

// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) obj.size()
#define sza(ary) (sizeof(ary) / sizeof(*ary))
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define cleAR(ary) memset((ary), 0, sizeof(ary))

// print util
#define print(x) cout << (x) << endl
#define printd(x, d) cout << fixed << setprecision(d) << (x) << endl
#define printv(v) REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1]
#define printa(ary) REP(i, sza(ary)) cout << ary[i] << "\n "[i < sza(ary) - 1]
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

signed main()
{
    ll n = in_<ll>();
    ll x = in_<ll>();

    if (n % 2 < x) x = n - x;
    ll gcd = __gcd(n, x);
    print((n / gcd - 1) * 3 * gcd);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    rep(i, 0, M)
    {
        cin >> B.at(i);
    }
    int sum = C;
    int ans = 0;
    int a;
    rep(i, 0, N)
    {
        rep(j, 0, M)
        {
            cin >> a;
            sum += a * B.at(j);
        }
        if (sum > 0)
        {
            ans++;
        }
        sum = C;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        int[] answer = new int[N];
        for (int i = N; 1 <= i; i--) {
            int sum = 0;
            for (int j = 2; i * j <= N; j++) {
                sum += answer[i*j-1];
            }
            answer[i-1] = (sum + A[i-1]) % 2;
        }
        StringBuilder sb = new StringBuilder();
        int M = 0;
        for (int i = 1; i <= N; i++) {
            int t = answer[i-1];
            if (0 < t) {
                M += 1;
                sb.append(i + " ");
            }
        }
        System.out.println(M);
        if (0 < M) {
            System.out.println(sb.substring(0, sb.length() - 1));
        }
    }
}


Measured memory_bytes: 84920
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
	long long W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << fixed << setprecision(6) << double(W) * double(H) / 2 << " " << ((x * 2 == W && y * 2 == H) ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    FOR(i,1,a+1){
        if(i==a&&i>b){
            continue;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())

A=list(map(int,input().split()))

ov=0
res=0
C=[0]*8

for i in A:
    if 1<=i and i<400:
        C[0]+=1
    elif 400<=i and i<800:
        C[1]+=1
    elif 800<=i and i<1200:
        C[2]+=1
    elif 1200<=i and i<1600:
        C[3]+=1
    elif 1600<=i and i<2000:
        C[4]+=1
    elif 2000<=i and i<2400:
        C[5]+=1        
    elif 2400<=i and i<2800:
        C[6]+=1
    elif 2800<=i and i<3200:
        C[7]+=1
    else:
        ov+=1

for j in C:
    if j!=0:
        res+=1
if res!=0:
    print(str(res)+' '+str(res+ov))
else:
    print(str(1)+' '+str(ov))

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000;
#define MAX_N 300
ll d[MAX_N][MAX_N];
bool road[MAX_N][MAX_N];

bool correctStructure = true;

void init(){
	rep(i,MAX_N){
		rep(j,MAX_N){
			d[i][j] = INF;
			road[i][j] = true;
		}
		d[i][i] = 0;
	}
}

void warshall_floyd(int n){
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if( d[i][k] == INF || d[k][j] == INF){
					// do nothing
				}else{
					if( d[i][j] > (d[i][k] + d[k][j])){
						correctStructure = false;
					}else if(d[i][j] == (d[i][k] + d[k][j]) && (d[i][k] != 0) && (d[k][j] != 0)){
						road[i][j] = false;
					}
					//d[i][j] = min(d[i][j],d[i][k] + d[k][j]);	
				}
			}
		}
	}
}


int main()
{
	init();
	int n;
	cin>>n;
	rep(i,n){
		rep(j,n){
			cin>>d[i][j];
		}
	}
	correctStructure = true;
	warshall_floyd(n);
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i; j < n; j++){
			if( road[i][j] == true){
				ans += d[i][j];
			}
		}
	}
	if( correctStructure == false){
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int a1 = 0, a2 = 0, b1 = 0, b2 = 0;
	for(a1=1; a1<N; a1++){a2 = a2+a1;}
	for(b1=1; b1<M; b1++){b2 = b2+b1;}
	(N+ M>= 2) ? printf("%d", a2 + b2) : printf("0");
	return 0;}


Measured memory_bytes: 1724
def main():
    I=lambda:input()
    L=lambda:list(map(int,input().split()))
    n,m=L()
    sc=[]
    for i in range(m):
        si,ci=L()
        sc.append([si,ci])
    mini=0 if n==1 else 10**(n-1)
    for i in range(mini,10**n):
        tmp=str(i)
        flag=True
        for j in range(m):
            if tmp[sc[j][0]-1]!=str(sc[j][1]):
                flag=False
        if flag:
            print(i)
            exit()
    print(-1)
        
    
    
if __name__ == '__main__':
    main()

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

const int maxn = 1e5+10;
const long long M = 1e9+7;
typedef long long ll;

int n, a, b, c, powa[maxn], powb[maxn], inv[maxn], Cn[maxn<<1];
long long ans;

int main() {
	scanf("%d%d%d%d", &n, &a, &b, &c);
	inv[1] = 1; // Caculate inverse
	for (int i = 2; i < maxn; ++i) {
		inv[i] = (M-(M/i)*inv[M%i]%M)%M;
//		assert((ll)i*inv[i]%M == 1);
	}
	powa[0] = powb[0] = 1; //Calculate pow
	for (int i = 1; i <= n; ++i) {
		powa[i] = (ll)powa[i-1]*a%M*inv[a+b]%M;
		powb[i] = (ll)powb[i-1]*b%M*inv[a+b]%M;
	}
	Cn[n-1] = 1; // Calculate i choose n-1
	for (int i = n; i < 2*n; ++i) {
		Cn[i] = (ll)Cn[i-1]*i%M*inv[i-n+1]%M;
//		printf("C(%d, %d) = %d\n", i, n-1, Cn[i]);
	}
	for (int i = n; i < 2*n; ++i) {
		ans = (ans+(ll)i*Cn[i-1]%M*(((ll)powa[n]*powb[i-n]+(ll)powb[n]*powa[i-n])%M))%M;
//		printf("%lld\n", ans);
	}
	ans = ans*100%M*inv[100-c]%M;
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long N = array[0];
			long Y = array[1];
			long x = -1;
			long y = -1;
			long z = -1;
			long maxCount = Y / 1000;

			for (var i = 0; i <= maxCount; ++i) {
				for (var j = 0; j <= maxCount; ++j) {
					long k = N - i - j;
					if (k < 0) {
						break;
					}

					long total = 10000 * i + 5000 * j + 1000 * k;
					if (total == Y) {
						x = i;
						y = j;
						z = k;
						break;
					}
				}
			}

			Console.WriteLine($"{x} {y} {z}");

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int a[10000], b[10000];
int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) cin >> b[i];
    int sum = b[1];
    a[0] = b[1];
    for (int i = 1; i < n-1; i++) {
        a[i] = min(b[i], b[i+1]);
        sum += a[i];
    }
    cout << sum + b[n-1] << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
int main() {
  cout << fixed << setprecision(16);
  ll x,y;
  cin>>x>>y;
 
  if(x<10&&y<10){
    putout(x*y);
  }
  else putout(-1);
}

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

typedef pair <int, int> ii;
const int maxn = 2222;

int N;
int L[maxn], R[maxn];
char A[maxn], B[maxn];

int add(int x, int y) {
    x += y;
    if (x >= N) x -= N;
    if (x < 0) x += N;
    return x;
}

int main() {
//    freopen("input.in", "r", stdin);
  //  freopen("output.out", "w", stdout);

    scanf("%s%s", A, B);
    N = strlen(A);
    int c1 = 0, c2 = 0;
    for (int i = 0; i < N; ++i) {
        c1 += A[i] == '1';
        c2 += B[i] == '1';
    }
    if (!c2) {
        puts(!c1 ? "0" : "-1");
        return 0;
    }
    for (int i = 0; i < N; ++i) {
        for (L[i] = 0; B[add(i, -L[i])] == '0'; L[i]++);
        for (R[i] = 0; B[add(i, R[i])] == '0'; R[i]++);
    }
    int ans = 1e9 + 7;
    for (int d = -N; d <= N; ++d) {
        int cnt = 0;
        vector <ii> c;
        for (int i = 0; i < N; ++i) {
            int id = (i + d + N) % N;
            if (A[i] == B[id]) continue;
            cnt++;
            int lo = L[i] - max(-d, 0);
            int hi = R[i] - max(d, 0);
            if (lo >= 0 && hi >= 0) c.push_back(ii(lo, hi));
        }
        int cur = 1e9 + 7;
        sort(c.begin(), c.end());
        int mx = 0;
        for (int i = (int) c.size() - 1; i >= 0; --i) {
            cur = min(cur, c[i].first + mx);
            mx = max(mx, c[i].second);
        }
        cur = min(cur, mx);
        ans = min(ans, abs(d) + 2 * cur + cnt);
    }
    printf("%d\n", ans);

    return 0;
}


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

using namespace std;

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

    string s;
    cin>>s;

    for(int i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<"\n";return 0;
        }
    }

    for(int i=0;i<s.length()-2;i++){
        if(s[i]==s[i+2] && s[i]!=s[i+1]){
            cout<<i+1<<" "<<i+3<<"\n";return 0;
        }
    }

    cout<<-1<<" "<<-1<<"\n";


    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int n;
int u;

int main() {
	cin >> n;
	int p = -1;
	int c = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (x == p) {
			c++;
		} else {
			u += c/2;
			c = 1;
		}
		p = x;
	}
	u += c/2;
	cout << u << "\n";
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, pi>a,pair<ll,pi>b)
{
    if(a.se.fi==b.se.fi)return a.se.se>b.se.se;
    return a.se.fi>b.se.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll a,x; cin>>a>>x;
ll b,y; cin>>b>>y;
ll t; cin>>t;
ll dist = llabs(a-b);
if(dist==0)cout<<"YES\n";
else
{
    if(x<=y)cout<<"NO\n";
    else
    {
        if((x-y)*t>=dist)cout<<"YES\n";
        else cout<<"NO\n";
    }
}
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 3596
#include"bits/stdc++.h"
#include"math.h"
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 m; cin >> m;
  vector<bool> a(n+1,false);
  int b;
  rep(i,m){
    cin >>b;
    a[b]=true;}
  ll dp[n+1];
  dp[0]=1;
  dp[1]=1;
  for(int i=1;i<n+1;i++){
    
    if(a[i])dp[i]=0;
    else if(i>1){dp[i] = (dp[i-1] + dp[i-2])%1000000007;}
  }
  cout << dp[n] << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int d, n;
  cin >> d >> n;

  if(n == 100) n++;
  cout << (int)(pow(100, d) * n) << endl;

  return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
#define length(a) (hypot((a).imag() , (a).real()))
#define eps 1e-8
#define vec(a,b) ((b)-(a))
#define dot(a,b) ( (conj(a)*(b)).real() )
#define polar(r,t) ((r)*exp(point(0,(t))))
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define point complex <ld>
#define x real()
#define y imag()
#define pi acos(-1)

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

    ll a,b,c,d,cc=1;
    cin >> a >> b >> c >> d;
    while(a > 0 && c>0)
    {
        if (cc%2) c -= b;
        else a -= d;
        cc++;
    }

    if (a <= 0) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x * f;
}
const int inf=9999999;
const int maxn=100000;
long long a,b,c,d,a1,b1,c1,d1;
long long n,m;
int main()
{
    a=read();
    b=read();
    c=read();
    d=read();
    a1=a;
    b1=b;
    c1=c;
    d1=d;
    n=read();
    a=a/0.25,b=b/0.5,d=d/2;
    if(a<b && a<c && a<d) 
	{
        printf("%lld\n",(long long)a1*n*4);
	}
	else if(b<a && b<c && b<d)
	{
        printf("%lld\n",(long long)b1*n*2);
    }
    else if(c<a && c<b && c<d)
    {
        printf("%lld\n",(long long)c1*n);
    }
    else
    {
        if(n&1) printf("%lld\n",(long long)(n/2)*d1+min(a1*4,min(b1*2,c1)));
        else printf("%lld\n",(long long)(n/2)*d1);
    }
	return 0;
}

Measured memory_bytes: 256
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n, t; cin >> n >> t;
    VI a(t + 1);
    FOR(i, 0, n) {
        int l, r; cin >> l >> r;
        ++a[l], --a[r];
    }

    int ans = 0;
    FOR(i, 0, t) {
        chmax(ans, a[i]);
        a[i + 1] += a[i];
    }
    cout << ans << "\n";

    return 0;
}


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

    int ans;
    if (A - B > 1) ans = A + A - 1;
    else if (A - B < -1) ans = B + B - 1;
    else ans = A + B;

    cout << ans << endl;
}


Measured memory_bytes: 256
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();
		int C = sc.nextInt();
		
		int B [] = new int [M];
		for (int i=0; i<M; i++){
			B[i]=sc.nextInt();
		}
		int cnt = 0;
		for (int i=0; i<N; i++){
			int temp = 0;
			
			for (int j=0; j<M; j++){
				int aj = sc.nextInt();
				temp+=(B[j]*aj);
			}
			if (temp+C>0)
				cnt++;
		
		}
		System.out.println(cnt);
		sc.close();
	}

}

Measured memory_bytes: 22356
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;



int main(){
    ll x,y,z,a[1010],b[1010],c[1010],k;
    vector<ll> v(x*y),ans(x*y*z);
    cin >>x>>y>>z>>k;
    rep(i,x) cin>>a[i];
    rep(i,y) cin>>b[i];
    rep(i,z) cin>>c[i];
    rep(i,x){
        rep(j,y){
            v.push_back(a[i]+b[j]);
        }
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    rep(i,min(k,x*y)){
        rep(j,z){
            ans.pb(v[i]+c[j]);
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    rep(i,k){
        cout <<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 43108
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
struct permutation : std::vector<int>
{
	permutation(int n = 0) { resize(n); for (int i = 0; i < n; i++) at(i) = i; }
	inline permutation operator *(const permutation &a) const
	{
		permutation res(size());
		for (int i = 0; i < size(); i++)
			res[i] = at(a[i]);
		return res;
	}
	inline permutation inv() const
	{
		permutation res(size());
		for (int i = 0; i < size(); i++)
			res[at(i)] = i;
		return res;
	}
};
inline permutation quick_pow(permutation a, int n)
{
	permutation res(a.size());
	while (n)
	{
		if (n & 1)
			res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}
inline void output(permutation a)
{
	for (int i = 0; i < a.size(); i++)
		printf("%d%c", a[i] + 1, " \n"[i + 1 == a.size()]);
}
int main()
{
	// freopen("AGC031-D.in", "r", stdin);
	int n, k;
	scanf("%d%d", &n, &k);
	permutation a(n), b(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		a[i]--;
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &b[i]);
		b[i]--;
	}
	if (k == 1)
	{
		output(a);
		return 0;
	}
	if (k == 2)
	{
		output(b);
		return 0;
	}
	permutation ra = a.inv(), rb = b.inv();
	if (k == 3)
	{
		output(b * ra);
		return 0;
	}
	k -= 4;
	permutation pl = quick_pow(rb * a * b * ra, k / 6);
	permutation pr = quick_pow(ra * b * a * rb, k / 6);
	k %= 6;
	std::vector<permutation> vec = {rb, a, b, ra};
	std::vector<int> len = {1, 3, 4, 5, 7, 8};
	for (int i = 0; i < 4; i++)
	{
		if (i * 2 < len[k])
			pl = pl * vec[i];
		if (i * 2 + 1 < len[k])
			pr = vec[i] * pr;
	}
	output(b * ra * pl * pr);
	return 0;
}


Measured memory_bytes: 6232
#include<bits/stdc++.h>
using namespace std;
const int INF=2E5;
typedef pair<int,int> Pair;

int main(){
    int N;
    int A[10000];
    int B[10000];
    int SUMA[10000]={0};
    int SUMB[10000]={0};
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
        SUMA[i+1]=SUMA[i]+A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
        SUMB[i+1]=SUMB[i]+B[i];
    }
    int ans=-1e9;
    for(int i=0;i<N;i++){
        ans=max(ans,SUMA[i+1]+SUMB[N]-SUMB[i]);
    }


    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int V[] =new int[2*N];
    int x=0;
    for(int i=0;i<2*N;i++){
      if(i<N){V[i]=sc.nextInt();}
      else{V[i]=V[i-N]-sc.nextInt();
           if(V[i]>0){x=x+V[i];}}}
    System.out.println(x);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
namespace my_header {
#define pb push_back
#define mp make_pair
#define pir pair<int, int>
#define vec vector<int>
#define pc putchar
#define clr(t) memset(t, 0, sizeof t)
#define pse(t, v) memset(t, v, sizeof t)
#define bl puts("")
#define wn(x) wr(x), bl
#define ws(x) wr(x), pc(' ')
    const int INF = 0x3f3f3f3f;
    typedef long long LL;
    typedef double DB;
    inline char gchar() {
        char ret = getchar();
        for(; (ret == '\n' || ret == '\r' || ret == ' ') && ret != EOF; ret = getchar());
        return ret; }
    template<class T> inline void fr(T &ret, char c = ' ', int flg = 1) {
        for(c = getchar(); (c < '0' || '9' < c) && c != '-'; c = getchar());
        if (c == '-') { flg = -1; c = getchar(); }
        for(ret = 0; '0' <= c && c <= '9'; c = getchar())
            ret = ret * 10 + c - '0';
        ret = ret * flg; }
    inline int fr() { int t; fr(t); return t; }
    template<class T> inline void fr(T&a, T&b) { fr(a), fr(b); }
    template<class T> inline void fr(T&a, T&b, T&c) { fr(a), fr(b), fr(c); }
    template<class T> inline char wr(T a, int b = 10, bool p = 1) {
        return a < 0 ? pc('-'), wr(-a, b, 0) : (a == 0 ? (p ? pc('0') : p) : 
            (wr(a/b, b, 0), pc('0' + a % b)));
    }
    template<class T> inline void wt(T a) { wn(a); }
    template<class T> inline void wt(T a, T b) { ws(a), wn(b); }
    template<class T> inline void wt(T a, T b, T c) { ws(a), ws(b), wn(c); }
    template<class T> inline void wt(T a, T b, T c, T d) { ws(a), ws(b), ws(c), wn(d); }
    template<class T> inline T gcd(T a, T b) {
        return b == 0 ? a : gcd(b, a % b); }
    template<class T> inline T fpw(T b, T i, T _m, T r = 1) {
        for(; i; i >>= 1, b = b * b % _m)
            if(i & 1) r = r * b % _m;
        return r; }
};
using namespace my_header;

const int N = 1e5 + 10;
int a[N], n;

int main() {
#ifdef lol
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
#endif

	fr(n);
	for (int i = 1; i <= n; ++i)
		fr(a[i]);
	sort(a + 1, a + n + 1);
	int x = -1, y = -1;
	for (int i = n; 0 < i; --i) {
		if (a[i] == a[i - 1]) {
			y = x;
			x = a[i];
			--i;
		}
		if (y != -1)
			break;
	}
	if (x == -1)
		wt(0);
	else wt(1LL * x * y);

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n,t,temp;
    int cnt=0;
    scanf("%d",&n);
    int A[n];
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        scanf("%d",&temp);
        for(int j=0;j<n;j++){
            if(A[j]==temp){
                cnt++;
                break;
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
double a,b;
int h,m; 
int main(){
	cin>>a>>b>>h>>m;
	h%=12,m%=60;
	double jm=m/30.0*pi,jh=h/6.0*pi+m/360.0*pi;
	double jd=fabs(jm-jh);
	double len=sqrt(a*a+b*b-2*a*b*cos(jd));
	printf("%.20f",len);
	return 0;
}

Measured memory_bytes: 4212
S = input()
flg1 = flg2 = flg3 = True
if not S[0] == 'A':
    flg1 = False
if not S.count('C', 2, -1) == 1:
    flg2 = False
j = len(S) + 1
for i in range(len(S)):
    if S[i] == 'C':
        j = i
for i in range(len(S)):
    if i == 0 or i == j:
        continue
    else:
        if S[i].islower() == False:
            flg3 = False
flg = flg1 * flg2 * flg3
print('AC' if flg else 'WA')


Measured memory_bytes: 3064
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int a=0,b=0,c=0,d=0;
            int n,i,j;
            string s;
            cin>>n;
            for(i=0;i<n;++i)
            {
                cin>>s;
                if(s=="AC")
                    ++a;
                else if(s=="WA")
                    ++b;
                else if(s=="TLE")
                    ++c;
                else
                    ++d;
            }
            cout<<"AC x "<<a<<endl;
            cout<<"WA x "<<b<<endl;
            cout<<"TLE x "<<c<<endl;
            cout<<"RE x "<<d<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3672
n = int(input())
a = list(map(int, input().split()))
rbg = [0]*3
ans = 1
MOD = 1000000007

for i in a:
  count=0
  flg=True
  for j in range(3):
    if rbg[j]==i:
      count+=1
      if flg:
        rbg[j]+=1
        flg=False
  ans*=count
  ans%=MOD
print(ans)

Measured memory_bytes: 20688
#include <stdio.h>
#include <stdlib.h>
 
int binarySearch(int *, int, int);
 
main(){
  int n,q,i,count=0;
  int *sAry,*tAry;
 
  scanf("%d", &n);
  sAry = malloc(n*sizeof(int));
  for(i=0; i<n; i++) scanf("%d", sAry+i);
  scanf("%d", &q);
  tAry = malloc(q*sizeof(int));
  for(i=0; i<q; i++) scanf("%d", tAry+i);
 
  for(i=0; i<q; i++)
    count += binarySearch(sAry, n, tAry[i]);
 
  printf("%d\n", count);
 
  return 0;
}
 
binarySearch(int *ary, int n, int a){
  int right,mid,left;  //search用
 
  right=n; //右端の１つ後
  left=0; //左端
 
  while(right > left){
    mid = (right+left)/2;
    if(ary[mid] == a) return 1;
    else if(ary[mid] > a) right = mid;
    else if(ary[mid] < a) left = mid +1;
  }
  return 0;
}

Measured memory_bytes: 1184
n, m, x, y = map(int, input().split())
Xn = list(map(int, input().split()))
Yn = list(map(int, input().split()))

Z = []
for z in range(x+1, y+1):
#    print(z)
    if max(Xn) < z and z <= min(Yn):
        Z.append(z)
        print('No War')
        break
else:
    print('War')

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

int main(){
    int X,N,a=0,ans;
    cin >> X>>N;
    int p[N];
    for (int i = 0; i < N; i++)
    {
        cin>>p[i];
    }
    
    
    for (int i = 0; i < 100; i++)
    {
        a=0;
        for (int j = 0; j < N; j++)
        {
            if(X-i==p[j]) a=1;
        }

        if(a==0){
            ans=X-i;
            break;
        }
        a=0;
        for (int j = 0; j < N; j++)
        {
            if(X+i==p[j]) a=1;
        }

        if(a==0){
            ans=X+i;
            break;
        }
        
    }
    

    cout<<ans<<endl;
    
    

}

Measured memory_bytes: 3632
import fractions as f

N = int(input())
A = [int(i) for i in input().split()]
L = [A[0]]
for i in range(1, N):
    L.append(f.gcd(L[-1], A[i]))
A.reverse()
R = [A[0]]
for i in range(1, N):
    R.append(f.gcd(R[-1], A[i]))
R.reverse()
ans = 0
for i in range(N):
    if i == 0:
        ans = max(ans, R[1])
    elif i == N - 1:
        ans = max(ans, L[N - 2])
    else:
        ans = max(ans, f.gcd(L[i - 1], R[i + 1]))
print(ans)


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

long long comb0[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
long long comb1[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
long long comb2[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main()
{
    int N;
    cin >> N;
    long long M = 0, A = 0, R = 0, C = 0, H = 0;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        if (s[0] == 'M')
            M++;
        if (s[0] == 'A')
            A++;
        if (s[0] == 'R')
            R++;
        if (s[0] == 'C')
            C++;
        if (s[0] == 'H')
            H++;
    }
    long long comb[5] = {M, A, R, C, H};
    long long ans = 0;
    for (int i = 0; i < 10; i++)
    {
        ans += comb[comb0[i]] * comb[comb1[i]] * comb[comb2[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

class Point
{
public:
	int x;
	int y;

	Point(int x = 0, int y = 0) : x(x), y(y){}
	bool operator == (const Point& target)
	{
		return (this->x == target.x && this->y == target.y);
	}
};

int w, h;
int map[105][105];
Point start;
Point goal;
int n; //????????????????????°
int c; //???
int d; //??????
Point blockPoint;

void setSideways(const Point& blockPoint)
{
	//?¨??????????????????????map???????????????????????????
	//
	//	????????????	(?????????blockPoint?????????)
	//	????????????
	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			map[blockPoint.x + i][blockPoint.y + j] = c;
		}
	}
}

void setPortrait(const Point& blockPoint)
{
	//????????????????????????map???????????????????????????
	//
	//	??????	(?????????blockPoint?????????)
	//	??????
	//	??????
	//	??????
	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < 4; ++j)
		{
			map[blockPoint.x + i][blockPoint.y + j] = c;
		}
	}
}

bool dfs(Point point, int color) //color????????£????????????????????¨??????
{
	//??¢?´¢??????????????????????????¨??????????????°??????0??????????????????
	map[point.x][point.y] = 0;

	if (point == goal)
	{
		return true;
	}
	//???????????????????????????????????´????????´???????????????????????????????????????
	bool upCase = false;
	bool downCase = false;
	bool leftCase = false;
	bool rightCase = false;
	//?????¨?????°?????????????????????????????????????????°???
	Point upPoint = Point(point.x, point.y - 1);
	Point downPoint = Point(point.x, point.y + 1);
	Point leftPoint = Point(point.x - 1, point.y);
	Point rightPoint = Point(point.x + 1, point.y);

	//??????????????????????????????????????°???????????????????????????????????????????????????
	if (upPoint.y >= 1 && map[upPoint.x][upPoint.y] == color)
	{
		upCase = dfs(upPoint, color);
	}
	if (downPoint.y <= h && map[downPoint.x][downPoint.y] == color)
	{
		downCase = dfs(downPoint, color);
	}
	if (leftPoint.x >= 1 && map[leftPoint.x][leftPoint.y] == color)
	{
		leftCase = dfs(leftPoint, color);
	}
	if (rightPoint.x <= w && map[rightPoint.x][rightPoint.y] == color)
	{
		rightCase = dfs(rightPoint, color);
	}

	return (upCase || downCase || leftCase || rightCase);
}

int main()
{
	while (true)
	{
		//?????????????????????
		for (int i = 0; i < 105; ++i)
		{
			for (int j = 0; j < 105; ++j)
			{
				map[i][j] = 0;
			}
		}

		//??????????????§????????\???
		cin >> w >> h;
		if (w == 0 && h == 0) return 0;

		//??????????????°????????´????????°?????\???
		cin >> start.x >> start.y;
		cin >> goal.x >> goal.y;

		//????????????????????° n ?????\???
		cin >> n;

		//???????????????????????±??\???
		for (int i = 0; i < n; ++i)
		{
			cin >> c >> d >> blockPoint.x >> blockPoint.y;
			if (d == 0)
			{
				setSideways(blockPoint);
			}
			if (d == 1)
			{
				setPortrait(blockPoint);
			}
		}

		int startColor = map[start.x][start.y];
		if (startColor != 0 && dfs(start, startColor))
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}
	return 0;
}

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

void solve() {
  int k, x;
  cin >> k >> x;
  int left = max(0 - 1000000, x - k + 1);
  int right = min(1000000, x + k - 1);
  for(int i = left; i <= right; i++) cout << i << " ";
}

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



Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt(); int w = sc.nextInt();
            if(n==0 && w==0) break;

            int max = 0;
            int[] list = new int[n];
            for(int i=0; i<n; i++){
                list[i] = sc.nextInt();
                max = Math.max(max, list[i]);
            }
            int a = max/w + 1;
            int[] his = new int[a];
            for(int i=0; i<n; i++) his[list[i]/w]++;
            int highest = 0;
            for(int i=0; i<a; i++) highest = Math.max(highest, his[i]);

            double sum = 0.0;
            for(int i=0; i<a; i++){
                sum += (double)(a-i-1)/(a-1) * (double)his[i]/highest;
            }
            sum += 0.01;
            System.out.println(sum);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 23620
N = int(input())
X = list(map(int, input().split()))

"""
    min(X) 以上、 max(X) 以下の整数を全探索
    1 <= X[i] <= 100 なので時間計算量は O(N(Xmax - Xmin)) <= O(N^2)
"""

X.sort()
ans = 10 ** 12
for p in range(X[0], X[N - 1] + 1):
    total = 0
    for x in X:
        total += (x - p)** 2
    ans = min(ans, total)
print(ans)


Measured memory_bytes: 3064
a = int(input())
Fin = (False if a != 0 else True)
printer = []
while not Fin:
    temp, a = a, int(input())
    printer.append(temp)
    if a == 0:
        Fin = True

for i in range(len(printer)):
    print("Case "+ str(i+1) + ":", printer[i])


Measured memory_bytes: 6168
#include <stdio.h>

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int);
int extract(void);
void increseKey(int, int);
void insert(int);
void swap(int *, int *);

int main() {

  int key;
  char s[10];

  while(1) {
    scanf("%s", s);
    if( s[0] == 'e' && s[1] == 'n' ) {
      break;
    }
    if( s[0] == 'i' ) {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
   
  }
  return 0;
}

void maxHeapify(int i) {
  
  int l;
  int r;
  int largest;
  int tmp;
  
  l = 2 * i;
  r = 2 * i + 1;

  if( l<=H && A[l]>A[i] ) {
    largest = l;
  } else {
    largest = i;
  }
  
  if( r <= H && A[r]>A[largest] ) {
    largest = r;
  }
  
  if( largest != i ) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
  
  return ;
}

int extract(void) {

  int maxv;
  
  if( H < 1 ) {
    return -INFTY;
  }
  
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  
  return maxv;
}

void increaseKey(int i,int key) {
 
  if( key < A[i] ) {
    return;
  }
  A[i] = key;
  while( i > 1 && A[i/2] < A[i] ) {
    swap(&A[i],&A[i/2]);
    i = i/2;
  }

  return ;
}

void insert(int key) {
 
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);

  return ;
}

void swap(int *a,int *b) {
  
  int tmp;
 
  tmp = *a;
  *a = *b;
  *b = tmp;

  return ;
}

Measured memory_bytes: 4692
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,dp[200005],x[200005],val[200005],all,ans=-1e17;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x[i]>>val[i];
	}
	for (i=1;i<=n;i++)
	{
		dp[i]=max(dp[i-1]-(x[i]-x[i-1]),0ll)+val[i];
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		int tenThousand = -1;
		int fiveThousand = -1;
		int oneThousand = -1;
		int sum = 0;

		for (int i = 0; i <= N; i++) {
			for (int j = 0; i + j <= N; j++) {
				for (int k = 0; i + j + k <= N; k++) {
					if (i + j + k == N) {
						sum = 10000 * i + 5000 * j + 1000 * k;
						if (sum == Y) {
							tenThousand = i;
							fiveThousand = j;
							oneThousand = k;
						}
					}
				}
			}
		}
		System.out.println(tenThousand + " " + fiveThousand + " " + oneThousand);
	}
}


Measured memory_bytes: 22996
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

void solve1() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) {
		cout << C << endl;
	}
	else if (A == C)
	{
		cout << B << endl;
	}
	else
	{
		cout << A << endl;
	}
}

void solve2() {
	int H, W;
	cin >> H >> W;
	vector<string> map;
	string empty = "";
	for (int i = 0; i < W+2; i++)
	{
		empty += ".";
	}
	map.push_back(empty);

	for (int i = 0; i < H; i++)
	{
		string s;
		cin >> s;
		map.push_back("." + s + ".");
	}
	map.push_back(empty);


	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			int count = 0;
			if (map[i][j] == '#') {
				continue;
			}
			int dx[] = { -1,1,0,0,-1,-1,1,1 };
			int dy[] = { 0,0,-1,1,-1,1,-1,1 };
			for (int k = 0; k < 8; k++)
			{
				if (map[i + dx[k]][j + dy[k]] == '#') {
					count++;
				}
			}
			map[i][j] = '0' + count;
		}
	}
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cout << map[i][j];
		}
		cout << endl;
	}
}

int dfs(int& ans, vector<vector<int> >& edges, int v, int& count, int from, vector<int>& low, vector<int>& pre) {
	pre[v] = count++;
	low[v] = pre[v];
	for (int i = 0; i < edges[v].size();i++) {
		int to = edges[v][i];
		
		if (pre[to] == -1) {
			low[v] = min(low[v], dfs(ans, edges, to, count, v, low, pre));
			if (low[to] == pre[to]) {
				ans++;
			}
		}
		else {
			if (from == to) {
				continue;
			}
			low[v] = min(low[v], low[to]);
		}
	}
	return low[v];
}

void solve3() {
	int N, M;
	cin >> N >> M;
	vector<vector<int> > edges(N, vector<int>());
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		edges[a-1].push_back(b-1);
		edges[b - 1].push_back(a - 1);
	}

	vector<int> pre(N, -1);
	vector<int> low(N, -1);
	int count = 0;
	int ans = 0;
	dfs(ans, edges, 0, count, -1, low, pre);
	cout << ans << endl;
	
}

void solve4() {

}

int main() {
	//solve1();
	//solve2();
	solve3();
	//solve4();

	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

fn cost_for(a: i32, numbers: &Vec<i32>) -> i32 {
    let mut cost = 0;
    for i in numbers {
        cost += (i - a).pow(2);
    }
    cost
}

fn min_cost(numbers: &Vec<i32>) -> i32 {
    let mut min_cost = std::i32::MAX;
    for i in (-100)..101 {
        min_cost = cmp::min(min_cost, cost_for(i, numbers));
    }
    min_cost
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut iter = input.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut numbers = Vec::with_capacity(n);
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    for token in line.split_whitespace() {
        numbers.push(token.parse().unwrap());
    }
    println!("{}", min_cost(&numbers));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int nmax = sc.nextInt();
		int anum = sc.nextInt();
		int bnum = sc.nextInt();

		int nummax = 0;
		int nummin = 0;

		if(anum < bnum) {
			nummax = anum;
		}else {
			nummax = bnum;
		}
		System.out.println(nummax);

		nummin = nmax - anum - bnum;

		if (nummin > 0) {
			System.out.println(0);
		}else {
			System.out.println(Math.abs(nummin));
		}

	    sc.close();

	}

}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(N);
	makei(K);
	int ans = 1;
	rep(N)ans = min(ans * 2, ans + K);
	say(ans);
}


Measured memory_bytes: 256
function main(input) {
  const N = parseInt(input, 10);
  let ans;
  
  for (let i = 111; i <= 999; i+=111) {
    if (N <= i) {
      ans = i;
      break;
    }
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29664
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <string>
#include <bits/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;

static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;
using pint = pair<int,int>;


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

  ll b[n-1];

  ll a[n] = {};

  REP(i,n-1)
  {
    cin >> b[i];
  }


  //bi = max(Ai,Ai+1)
  a[n-1] = b[n-2];
  for(ll i = n-2; i > 0; --i)
  {
    a[i] = min(b[i],b[i-1]);
  }

  a[0] = b[0];


  ll res = 0;

  REP(i,n)
  {
    res += a[i];
  }


  cout << res <<  endl;

  return 0;
}



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

int main() {
  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> s(n);
    int suma = 0;
    for(int i = 0; i < n; i++) {
      cin >> s[i];
      suma += s[i];
    }
    double m = (double)suma / (double)n;
    double a2n = 0;
    for(int i = 0; i < n; i++) {
      a2n += ((double)s[i] - m) * ((double)s[i] - m);
    }
    double a = sqrt(a2n / (double)n);
    printf("%.7lf\n", a);
  }
}


Measured memory_bytes: 3212
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => {
  const parsedValue = parseInt(input);
  const hour = Math.floor(parsedValue / 3600);
  const minute = Math.floor((parsedValue % 3600) / 60);
  const second = parsedValue % 60
  console.log(hour + ":" + minute + ":" + second);
});


Measured memory_bytes: 17320