akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;
char s[200];
int fun(int a,int b)
{
	
	for(int i=0;i<=(b-a)/2;i++)
	{
		//cout<<i<<"="<<a+i<<" "<<b-i<<endl;
		if(s[a+i]!=s[b-i]) return 1;
	}
	//cout<<a<<" "<<b<<endl;
	return 0;
}
int main()
{
	cin>>s;
	int n=strlen(s);
	//cout<<n-1<<endl<<(n-1)/2-1<<endl<<(n+3)/2-1<<endl;
	if(fun(0,n-1)||fun(0,(n-1)/2-1)||fun((n+3)/2-1,n-1)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[] a){Scanner s=new Scanner(System.in);List<Integer>l=new ArrayList<Integer>();int t=s.nextInt(),i=0;for(;i++<t;)l.add(i);for(t=s.nextInt(),s.nextLine();t-->0;){String[]e=s.nextLine().split(",");Collections.swap(l, new Integer(e[0])-1, new Integer(e[1])-1);}for(int e:l)System.out.println(e);}}

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

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

#define INF 1000000000
#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define foreach(v,c) for(typeof((c).begin()) v=(c).begin();v!=(c).end();++v)
#define all(a) a.begin(),a.end()
#define in(a,b) ((b).find(a)!=(b).end())
#define fill(a,v) memset(a,v,sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
#define pb push_back

int main(){
	int n;
	fastIO
	cin>>n;
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		int x;
		cin>>x;
		if(i % 2 && x % 2) cnt++;
	}
	cout<<cnt<<endl;
}

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

int main() {
	int n, a_max = 0, a_min = 1e9;
	cin >> n;
	rep(i, 0, n) {
		int a;
		cin >> a;
		a_max = max(a_max, a);
		a_min = min(a_min, a);
	}

	cout << a_max - a_min << endl;

	return 0;
}

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

int main() {
    int N; cin>>N;
    map<int,int> mp;
    for(int i=0;i<N;++i) {
        int p; cin>>p;
        mp[p]++;
    }

    int two = 0;
    for(auto x: mp) {
        if (x.second >= 2) two += x.second - 1;
    }
    int ans = mp.size();
    if (two % 2 == 1) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7828
#include <stdio.h>
#include <inttypes.h>

int64_t zettaiti(int64_t mofu) {
	return mofu < 0 ? -mofu : mofu;
}

int main(void) {
	int64_t A, V;
	int64_t B, W;
	int64_t T;
	if (scanf("%" SCNd64 "%" SCNu64, &A, &V) != 2) return 1;
	if (scanf("%" SCNd64 "%" SCNu64, &B, &W) != 2) return 1;
	if (scanf("%" SCNd64, &T) != 1) return 1;
	if (V <= W && A != B) {
		puts("NO");
	} else {
		int64_t kyori, hayasa;
		kyori = zettaiti(A - B);
		hayasa = V - W;
		puts(hayasa * T >= kyori ? "YES" : "NO");
	}
	return 0;
}


Measured memory_bytes: 1624
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    int max=1;
    int i;
    for(i=2; i<n; i++) {
        int curr=i*i;
        while(curr<=n) {
            max=MAX(max,curr);
            curr*=i;
        }    
    }
    printf("%d\n",max);

    return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())

def count(a):
  bias = a % k
  if (bias + a) % k:
    return 0
  num = (n - bias) // k 
  if bias > 0:
    num += 1
  return num ** 2

a = 1
res = 0

while(a <= n):
  res += count(a)
  a += 1

print(res)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=5000005;
const int mod=998244353;
int n,m;
int fac[maxn],ifac[maxn];

int C(int a,int b){
	if(a<b||a<0||b<0)return 0;
	return 1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

int main(){
	scanf("%d%d",&n,&m);
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<=3*m+n;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod;
	}
	REP(i,3*m+n)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	int ans=0;
	rep(i,min(n,m)+1){
		if((3*m-i)&1)continue;
		int cur=(3*m-i)/2;
		int tmp=(C(cur+n-1,n-1)-1LL*i*C(cur-m+n-1,n-1)%mod+mod-1LL*(n-i)*C(cur-(m+1)+n-1,n-1)%mod+mod)%mod;
		ans=(ans+1LL*C(n,i)*tmp%mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 22784
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	llong A, B, K;
	cin >> A >> B >> K;
	if(A+K-1>=B-K+1){
		for(int i=A; i<=B; ++i) cout << i << endl;
	}else{
		for(int i=A; i<=A+K-1; ++i){
			cout << i << endl;
		}
		for(int i=B-K+1; i<=B; ++i){
			cout << i << endl;
		}
	}
}

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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 301 * 1001  , MOD = 1e9 + 7 , sq = 333  ;

int a[MAXN] , b[MAXN] ;

int aa[MAXN] ;

int solve(int t1 , int p1 , int t2 , int p2 )
{
    int ans = 0 ;
    for(int i = 0 ; i <= p1 ; i ++ )
    {
        int T = t1 - 2 * i ;
        int k = i + min(T,t2-2*p2) ;
        if(T<=t2-2*p2)
        {
            ans = max(ans,k+p2) ;
            continue ;
        }
        ans = max(ans,k+p2);
        T -= t2-2*p2 ;
        if(T>=2*p2)
        {
            ans = max(ans,k+2*p2) ;
            continue ;
        }
        ans = max(ans,k+T/2+p2) ;
    }
   // cout<<ans<<'\n';
    return ans ;
}

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

   int n , m ;
   cin >> n >> m ;
   for(int i = 0 ; i < n ; i ++ )
    cin >> aa[i] , a[aa[i]%m]++;
   sort(aa,aa+n);
   for(int i = 0 ; i < n ; i ++ )
   {
       if(i&&aa[i]==aa[i-1])
       {
           b[aa[i]%m]++;
           aa[i] = -1 ;
       }
   }

   int ans = a[0] / 2  ;
   for(int i = 1 ; i < (m+1) / 2 ; i ++ )
   {
      // cout<<a[i]<<' '<<b[i]<<' '<<a[m-i]<<' '<<b[m-i]<<'\n';
        ans += solve(a[i],b[i],a[m-i],b[m-i]);
   }
   if(m%2==0)
    ans += a[m/2] / 2  ;
   cout<<ans;



}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, k;
	cin>>a>>b>>k;
	int res = 0;
	vector<int> v;
	for(int i = 1; i <= min(a, b); ++i){
		if(a % i == 0 && b % i == 0){
			v.push_back(i);
		}
	}
	//for(auto x : v)cout<<x<<" ";
	//cout<<endl;
	int n = v.size();
	res = v[n - k];
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int n;
bool b[100010];
char s[100010];
bool ans;

void dfs(int pos, bool ani) {
	if (pos == n + 1) {
		bool ans1, ans2;
		if (s[n] == 'o') {
			if (b[n]) {
				if (b[n - 1] == b[1]) {
					ans1 = true;
				}
				else {
					ans1 = false;
				}
			}
			else {
				if (b[n - 1] == b[1]) {
					ans1 = false;
				}
				else {
					ans1 = true;
				}
			}
		}
		else {
			if (b[n]) {
				if (b[n - 1] == b[1]) {
					ans1 = false;
				}
				else {
					ans1 = true;
				}
			}
			else {
				if (b[n - 1] == b[1]) {
					ans1 = true;
				}
				else {
					ans1 = false;
				}
			}
		}
		if (s[1] == 'o') {
			if (b[1]) {
				if (b[n] == b[2]) {
					ans2 = true;
				}
				else {
					ans2 = false;
				}
			}
			else {
				if (b[n] == b[2]) {
					ans2 = false;
				}
				else {
					ans2 = true;
				}
			}
		}
		else {
			if (b[1]) {
				if (b[n] == b[2]) {
					ans2 = false;
				}
				else {
					ans2 = true;
				}
			}
			else {
				if (b[n] == b[2]) {
					ans2 = true;
				}
				else {
					ans2 = false;
				}
			}
		}
		if (ans1 && ans2) {
			for (int i = 1; i <= n; ++i) {
				cout << (b[i] ? 'S' : 'W');
			}
			cout << endl;
			exit(0);
		}
		else {
			return;
		}
	}

	b[pos] = ani;

	if (pos == 1) {
		dfs(pos + 1, false);
		dfs(pos + 1, true);
	}

	if (ani) {
		if (s[pos] == 'o') {
			dfs(pos + 1, b[pos - 1]);
		}
		else {
			dfs(pos + 1, !b[pos - 1]);
		}
	}
	else {
		if (s[pos] == 'o') {
			dfs(pos + 1, !b[pos - 1]);
		}
		else {
			dfs(pos + 1, b[pos - 1]);
		}
	}
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
	}

	for (int i = 0; i < 2; ++i) {
		fill(b, b + n + 10, false);
		dfs(1, i);
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define present(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}

int main(){
	int n; cin>>n;
	ll ans=1;
	for(ll i=1;i<=n;i++){
		ans=(ans*i)%MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

long long int getpow(int x, int n)
{
	if(n == 0) return 1;
	long long int tmp = getpow(x, n / 2);
	if(n % 2 == 0) return (tmp * tmp) % mod;
	return (((tmp * tmp) % mod) * x) % mod;
}

long long int getcomb(int n, int r)
{
	long long int fact[1000001] = {};
	fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (i * fact[i - 1]) % mod;
	}
	long long int factn = fact[n];
	long long int revfactr = getpow(fact[r], mod - 2);
	long long int revfactnr = getpow(fact[n - r], mod - 2);
	return (((factn * revfactr) % mod) * revfactnr) % mod;
}

int main()
{
	int x, y;
	cin >> x >> y;
	// k回動かすとする
	// そのうちl回(i + 1, j + 2)の操作をすると仮定すると
	// コマの位置は(k + (k - l), k + l)
	// x = 2 * k - l, y = k + l;
	// x = 2 * (y - l) - l;
	// x = 2 * y - 3 * l;
	// l = (2 * y - x) / 3;
	if(2 * y - x < 0 || (2 * y - x) % 3 > 0){
		cout << 0 << endl;
		return 0;
	}
	int l = (2 * y - x) / 3;
	int k = y - l;
	if(k < l){
		cout << 0 << endl;
		return 0;
	}
	// kClが答え
	cout << getcomb(k, l) << endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define __ ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
int n,m,x,y,ans;
int main(){
__;
cin>>n>>m;
for(int i=0;i<m;i++)
{
    cin>>y; x+=y;
}
while(n-x>=0){
    cout<<n-x;return 0;
}
cout<<"-1";
}


Measured memory_bytes: 3652
#  B
import itertools

R, G, B, N = [int(x) for x in input().split()]
RGB = [R, G, B]

cnt = 0
for i in range(N//R+1):
    g_range = (N - RGB[0]*i)//RGB[1]
    for j in range((N-R*i)//G+1):
        if R*i + G*j > N:
            continue
        rem = N - R*i - G*j
        if rem % B == 0: 
            cnt += 1
print(cnt)

Measured memory_bytes: 40684
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn log10(a: u64) -> u64 {
    let mut ans = 0u64;
    let mut a = a;
    while a > 0 {
        ans += 1;
        a /= 10;
    }

    return ans;
}

fn solve() {
    input!(
        n: i64,
    );

    if n & 1 == 1 {
        println!("{}", 0);
        return;
    }

    let mut ans = 0i64;
    let mut base = 1i64;

    while base as f64 * 5.0 <= 1e18 {
        base *= 5;
        let mut b = base * 2;
        ans += n / b;
    }

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

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;
    int a[100]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i!=0){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);
//#define Local = 1;
#ifdef Local
#define debug(x) cout << __LINE__ << " " << #x <<"..." << x << endl
#define dev(x) cout << __LINE__ << " " << #x << "..." ; for(auto &it : x) cout<< it << " "; cout << endl;
#define des(x) cout << __LINE__ << " " << #x << "..." << x << endl;
#else
#define debug(x) ;
#define dev(x);
#define des(x)
#endif

const double PI = 3.141592653589793;

void solve()
{
	int n,m;
	cin >> n >> m;
	vector <int> x(m);
	for(int &it : x) cin >> it;
	sort(all(x));
	if(n>=m)
	{
		cout << "0\n";
		return ;
	}
	vector<int>dis;
	for(int i=0;i<m-1;i++)
	{
		dis.push_back(abs(x[i+1]-x[i]));
	}
	int ans = 0;
	sort(all(dis));
	for(int i=0;i<m-n;i++)
	{
		ans += dis[i];
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T = 1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> > bridge;
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    pair<int,int> P(A,B);
    bridge.push_back(P);

  }
  reverse(ALL(bridge));
  UnionFind uf(N);
  int ANS = N*(N-1)/2;
  vector<int> AA(M);
  for (int i = 0; i < M; i++)
  {
    // DEBUG(ANS);
    AA[i] = ANS;
    int A = bridge[i].first;
    int B = bridge[i].second;
    if(uf.find(A) == uf.find(B))continue;
    int X = uf.size(A);
    int Y = uf.size(B);
    uf.unite(A,B);
    ANS -= X*Y;
    ANS = max(0LL,ANS);
  }
  reverse(ALL(AA));
  for (int i = 0; i < M; i++)
  {
    cout<<AA[i]<<endl;
  }
  
  

  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 4592
#include <iostream>
#include <assert.h>

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

    int32_t N, K;
    std::cin >> N >> K;
    int32_t A[N];
    for(int32_t i = 0;i < N; i++){
        std::cin >> A[i];
    }
    int32_t res;
    if(N == K) res = 1;
    else{
        res = (N - 2) / (K - 1) + 1;
    }

    std::cout << res << std::endl;

    return 0;

}


Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . which "Yes" "No" . ( '9' `elem` )


Measured memory_bytes: 380
import sys
input = sys.stdin.readline

mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 2*10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

# 足す時は0~iまで一律に足し、返すのはi番目の値
class imosBIT():
    def __init__(self, N):
        self.N = N+1
        self.bit = [0 for _ in range(self.N+1)]
    
    def __str__(self):
        ret = []
        for i in range(1, self.N+1):
            ret.append(self.__getitem__(i))
        return "[" + ", ".join([str(a) for a in ret]) + "]"

    def __getitem__(self, i):
        i += 1
        s = 0
        while i <= self.N:
            s = (s + self.bit[i]) % mod
            i += i & -i
        return s

    def add(self, i, x):
        i += 1
        while i > 0:
            self.bit[i] = (self.bit[i] + x) % mod
            i -= i & -i
    
    # (i, N]に全てたす
    def addover(self, i, x):
        self.add(self.N-1, x)
        self.add(i, -x)

B, W = map(int, input().split())
N = B+W
Abit = imosBIT(N+1)
Bbit = imosBIT(N+1)
inv2 = pow(2, mod-2, mod)
t = inv2
for i in range(N):
    if i+1 >= W:
        Abit.addover(i, t*cmb(i, W-1)%mod)
    if i+1 >= B:
        Bbit.addover(i, t*cmb(i, B-1)%mod)
    t = t*inv2 % mod

for i in range(N):
    ans = (1 + Abit[i] - Bbit[i]) * inv2 % mod
    print(ans)

Measured memory_bytes: 92680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=100010;
int main()
{
    IOS;
    string s;cin>>s;
    string temp;
    for(int i=0;i<s.length();i++)
        if(s[i]!='x')temp+=s[i];
    bool pal=1;
    for(int i=0;i<temp.length();i++)
    {
        if(temp[i]!=temp[temp.length()-i-1]){
            pal=0;
            break;
        }
    }
    if(pal==0){
        cout<<-1<<endl;
        return 0;
    }
    int res=0;
    int l=0;
    int r=s.length()-1;
    while(l<=r)
    {
        if(s[l]==s[r])l++,r--;
        else if(s[l]=='x')l++,res++;
        else r--,res++;
    }
    cout<<res<<endl;
}








Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt<MOD>;

mint dp[3010][3010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        if(a[i] <= s) {
            dp[i + 1][a[i]] += mint(i + 1);
        }
        for(int j = 1; j < s; j++) {
            dp[i + 1][j] += dp[i][j];
            if(j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
            }
        }
    }
    mint ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += dp[i][s] * mint(n - i + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  map<pll,ll> h;
  vector<pll> p(n);
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    p[i]=mp(a,b);
  }
  sort(all(p));
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      h[pll(p[j].F-p[i].F,p[j].S-p[i].S)]++;
    }
  }
  ll cu=0;
  for(auto u:h){
    cu=max(cu,u.S);
  }
  ll ans=0;
  ans+=n-cu;
  COUT(ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int shoujun(const void* a, const void* b){return *((int*)b)-*((int*)a);}
int koujun(const void* a, const void* b){return *((int*)a)-*((int*)b);}

int main()
{
	int line;
	cin >> line;
	for(int i=1;i<=line;i++)
	{
		char dataline[10];
		cin >> dataline;
		int dataset[10];		
		for(int j = 0; j<=7;j++)dataset[j] = (int)dataline[j]-48;
		
		qsort(dataset,8,sizeof(int),shoujun);
		int largest = 0;
		for(int j = 0; j<=7;j++)largest =((largest * 10) + dataset[j]);
		int smallest = 0;
		qsort(dataset,8,sizeof(int),koujun);
		for(int j = 0; j<=7;j++)smallest =((smallest * 10) + dataset[j]);
		cout << largest - smallest << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
ll A[212345];
ll ans = 0;

int main(){
	
	cin>>N;
	REP( i, N ) scanf("%d", A+i);
	
	if( A[0] != 0 ) ans = -1;
	FOR( i, 1, N ) if( A[i] - A[i-1] > 1 ) ans = -1;
	
	if( ans != -1 ){
		ans = 0;
		FOR( i, 1, N ){
			if( A[i]-A[i-1] == 1 ) ans++;
			else{
				ans += A[i];
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <unordered_map>
#include <cassert>
#include <functional>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ld eps = 1.0e-18; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

int main(){
  int N;
  cin >> N;
  vector<int> x;
  vector<int> y;
  int x_t, y_t;
  for(int i=0; i< N; i++){
    cin >> x_t >> y_t;
    x.push_back(x_t);
    y.push_back(y_t);
  }
  double distance = 0;
    foreach_permutation(N, [&](int *indexes) {
			     //    std::cout << indexes[0] << ',' << indexes[1] << ',' << indexes[2] << std::endl;
    for(int i=1;i<N;i++){
      distance += sqrtl((double)((x[indexes[i]] - x[indexes[i-1]])*(x[indexes[i]] - x[indexes[i-1]]) + (y[indexes[i]] - y[indexes[i-1]])*(y[indexes[i]] - y[indexes[i-1]])) );
      //      cout << sqrtl((long double)((x[indexes[i]] - x[indexes[i-1]])*(x[indexes[i]] - x[indexes[i-1]]) + (y[indexes[i]] - y[indexes[i-1]])*(y[indexes[i]] - y[indexes[i-1]])) ) << endl;
      //      printf("d: %.15f\n", distance);
    }
			   });
    double fact = 1;
    for(int i=1;i<=N;i++){
      fact = fact * i;
    }
    printf("%.15f\n", distance/fact);
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

long long solve(long long N, long long M)
{
	if (N == 1 && M == 1) {
		return 1;
	}
	else if (N == 1) {
		return M - 2;
	}
	else if (M == 1) {
		return N - 2;
	}
	else {
		return (N - 2) * (M - 2);
	}
}

int main()
{
	long long N, M;
	cin >> N >> M;
	cout << solve(N, M) << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
mod=998244353
R=[]
for _ in range(k):
  l,r=map(int,input().split())
  R.append([l,r])

dp=[0 for _ in range(n+1)]
dp[1]=1
dpsum=[0 for _ in range(n+1)]
dpsum[1]=1
for i in range(2,n+1):
  for j in range(k):
    li=i-R[j][1]
    ri=i-R[j][0]
    if ri<0:
      continue
    li=max(li,1)
    dp[i]+=(dpsum[ri]-dpsum[li-1])%mod
  dpsum[i]=dpsum[i-1]+dp[i]
  dpsum[i]%=mod
print(dp[n]%mod)

Measured memory_bytes: 26780
N = int(input())
A,B = map(int,input().split())
*P, = map(int,input().split())

a = len([p for p in P if p<=A])
a = min(a,
        len([p for p in P if A<p<=B]))
a = min(a,
        len([p for p in P if B<p]))
print(a)


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
//

//
// inputs
ll A,B;
//

int main(){
//startmain
  cout << fixed << setprecision(0);
//
cin >> A >>B;
//
([&](){
    function<ll(ll)> calc;
    function<ll(ll)> log2;
    log2=[&](ll a)->ll {
        return a==0?0:1+log2(a/2);
    };
    calc=[&](ll a)->ll {
        ll r=0;
        r+=(a%4==1 || a%4==2) ? 1:0;
        for(ll i=1;i<log2(a);++i) {
            ll t=a%(1ll<<(i+1)) ;
            r+=((t>=(1ll<<i) && (t-(1ll<<i))%2==0)?1ll:0) << i;
        }
        return r;
    };
    cout << ll((calc(B)^calc(A-1))) << endl;
})();
//

//

return 0;}
//endmain
//

//


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define MN 101000

int n, a[MN];
int q[MN], t = 0;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	std::sort(a + 1, a + n + 1);
	int s = 0;
	for(int i = 2; i <= n; i++)
	{
		if(a[i] == a[i - 1]) {s ^= 1; continue;}
		if(s == 0)
		{
			if(~(a[i] - a[i - 1]) & 1)
				q[++t] = a[i - 1] + i;
		}
		else
		{
			if((a[i] - a[i - 1]) & 1)
				q[++t] = a[i - 1] - 1 + i;
		}
		s = 0;
	}
	bool ok = 0;
	for(int i = 1; i <= t; i++)
	{
		if(q[i] > n)
		{
			ok = 1; 
			if((q[i] - n) & 1) puts("First");
			else puts("Second"); 
			break;
		}
	}
	if(!ok)
	{
		if(s ^ 1 ^ (a[n] & 1)) puts("First");
		else puts("Second"); 
	}
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    s = input()
    t = input()

    ans = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 73088
/*
      author : Nishikawa
      created: 07.08.2020 21:11:04
*/

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


int main(){
    int x;
    cin >> x;
    x%=10;
    switch(x){
        case 3: cout << "bon" << endl; break;
        case 0:
        case 1:
        case 6:
        case 8: cout << "pon" << endl; break;
        default : cout << "hon" << endl; break;
    }
    return 0;
}

Measured memory_bytes: 3620
using System;

public class Program
{
    private int A, B;

    public void Solve()
    {
        var sc = new Scanner();
        A = sc.NextInt();
        B = sc.NextInt();
        if (A == B)
        {
            Console.WriteLine($"0 1");
            return;
        }
        var ans = GCD(A, B);
        Console.WriteLine($"{ans.X} {ans.Y}");
    }

    private S GCD(long a, long b)
    {
        var aa = new S(a, 1, 0);
        var bb = new S(b, 0, 1);
        while (aa.N != 0)
        {
            bb %= aa;
            if (bb.N == 0) return aa;
            aa %= bb;
        }

        return bb;
    }


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

struct S
{
    public long N;
    public long X, Y;

    public S(long n, long x, long y)
    {
        N = n;
        X = x;
        Y = y;
    }


    public static S operator %(S a, S b)
    {
        long d = a.N / b.N;
        long n = a.N - b.N * d;
        long x = a.X - b.X * d;
        long y = a.Y - b.Y * d;
        return new S(n, x, y);
    }
}

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

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

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

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 18032
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    char ch;
    int cnt[26] ={0};

    while(cin>>ch){
        if(islower(ch)){
            int num = ch - 'a';
            cnt[num]++;
        }
        else if(isupper(ch)){
            int num = ch - 'A';
            cnt[num]++;
        }
    }

    for(int i=0;i<26;i++){
        cout << char(i + 'a') << " : " << cnt[i] << endl;
    }
    return 0;
}

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

#define N 1010
#define M 1000010
#define INF 0x3f3f3f3f
int n, m;
char s[N]; 
int dist[M], used[M];
vector < vector <int> > G;
int id(int x, int y) {
	return (x - 1) * m + y;
}
int Move[][2] = {
	{-1, 0},
	{1, 0},
	{0, 1},
	{0, -1},
};
bool ok(int x, int y) {
	if (x < 1 || x > n || y < 1 || y > m) {
		return false;
	}
	return true;
}
struct node {
	int u, w;
	node () {}
	node (int u, int w) : u(u), w(w) {}
	bool operator < (const node &other) const {
		return w > other.w;
	}
};
void Dijkstra() {
	priority_queue <node> pq;
	pq.push(node(0, -1));
	while (!pq.empty()) {
		int u = pq.top().u; pq.pop();
		if (used[u]) {
			continue;
		}
		used[u] = 1;
		for (auto v : G[u]) {
			if (!used[v] && dist[v] > dist[u] + 1) {
				dist[v] = dist[u] + 1;
				pq.push(node(v, dist[v]));
			}
		}
	}
}

void init() {
	G.clear();
	G.resize(n * m + 1);
	for (int i = 1; i <= n * m; ++i) {
		dist[i] = INF;
		used[i] = 0;
	}
	used[0] = 0;
	dist[0] = -1;
}
int main() {
	while (scanf("%d%d", &n, &m) != EOF) {
		init();
		for (int i = 1; i <= n; ++i) {
			scanf("%s", s + 1);
			for (int j = 1; j <= m; ++j) {
				if (s[j] == '#') {
					G[0].push_back(id(i, j)); 
				}
				for (int k = 0; k < 4; ++k) {
					int x = i + Move[k][0];
					int y = j + Move[k][1];
					if (ok(x, y)) {
						G[id(i, j)].push_back(id(x, y));
						G[id(x, y)].push_back(id(i, j));
					}
				}
			}
		}
		Dijkstra();
		int res = 0;
		for (int i = 1; i <= n * m; ++i) {
			res = max(res, dist[i]);
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 90732
// 0028
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

vi idx;
 
int32_t main()
{
    fast;
    string s; cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    for(int i = 0; i < n;) {
        if(s.substr(i,5) == "maerd"){
			i += 5;
		}
		else if(s.substr(i,5) == "esare"){
			i += 5;
		}
		else if(s.substr(i,6) == "resare"){
			i += 6;
		}
		
		else if(s.substr(i,7) == "remaerd"){
			i += 7;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
    }
    cout << "YES" << "\n";
    
    
    
    return 0;
}

Measured memory_bytes: 3748
package main

import (
	"fmt"
)

func compare(a int, b int) string {
	if a == b {
		return "=="
	}
	if a < b {
		return "<"
	}
	return ">"
}

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Printf("a %s b\n", compare(a, b))
}



Measured memory_bytes: 1128
import math
a,b,x = map(int, input().split())

if a*a*b == x:
    print(0)
    exit()

tan = (a*a*a)/(2*(a*a*b-x))
tan_thre = a/b

if tan > tan_thre:
    ans = math.degrees(math.atan(tan))
    print(90-ans)
else:
    tan = 2*x/(a*b*b)
    ans = math.degrees(math.atan(tan))
    print(90-ans)

Measured memory_bytes: 3064
/*
problem's name:
statue:
writer:Chris
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
#define P pair<ll,ll>
#define MP(a,b) make_pair(a,b)
typedef long long ll;
using namespace std;
const ll INF=1e9;
/*------------main part------------*/
bool vis[1000005];
ll n,m,dis[1000005],head,tail,t,h[1000005];
ll cost;
priority_queue<P> q;
set<ll> in[1000005];
struct E
{
	ll v,c,next;
}g[1000005];
void ins(ll u,ll v,ll c)
{
	g[++t].v=v;
	g[t].c=c;
	g[t].next=h[u];
	h[u]=t;
}
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
	while(cin>>n>>m)
	{
		memset(dis,0x3f,sizeof(dis));
		memset(vis,0,sizeof(vis));
		memset(g,0,sizeof(g));
		memset(h,0,sizeof(h));
		tail=0;
		head=0;
		cost=0;
		t=0;
		for(ll i=0;i<=n;i++)
		{
			in[i].clear();
		}
		for(ll i=1;i<=m;++i)
		{
			ll u,v,c;
			u=read(),v=read(),c=read();
			ins(u,v,c);
			ins(v,u,c);
		}
		q.push(mp(0,1));
		dis[1]=0;
		while(!q.empty())
		{
			ll u=q.top().second;
			cost=-q.top().first;
			q.pop();
			vis[u]=1;
			if(cost>dis[u]) continue;
			for(ll j=h[u];j;j=g[j].next)
			{
				if(vis[g[j].v])
				{
					continue;
				}
				ll v=g[j].v,c=g[j].c,d=dis[u]+(!in[u].count(c));
				if(d>dis[v])
				{
					continue;
				}
				if(d<dis[v])
				{
					q.push(MP(-d,v));
					dis[v]=d;
					in[v].clear();
				}
				in[v].insert(c);
			}
		}
		printf("%d\n",(int)dis[n]==1061109567?-1:dis[n]);
	}
}


Measured memory_bytes: 97268
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll M = 1e9+7;  // 9..
const ll INF = 1e9+7;

ll n, m, done_max, ans[110000];;
vector<P> edge[110000];
ll done[110000];

void bfs(ll s) {
  queue<P> q;
  q.push(P(s, 0));
  while (q.size()) {
    P p = q.front();
    ll u = p.first;
    ll pre_color = p.second;
    q.pop();
    done[u] = true;
    ll color = 0;
    for (P p: edge[u]) {
      ll v = p.first;
      ll id = p.second;
      if (done[v]) continue;
      color++;
      if (color == pre_color) color++;
      ans[id] = color;
      done_max = max(done_max, color);
      q.push(P(v, color));
    }
  }
}

int main() {
  cin >> n;

  for (ll i = 0; i < n-1; i++) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(P(b, i));
    edge[b].push_back(P(a, i));
  }
  
  bfs(0);
  
  cout << done_max << endl;
  for (ll i = 0; i < n-1; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 9884
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N],dp[N];
main()
{   //freopen("read.inp","r",stdin);
    int n;
        cin>>n;
            for(int i=1;i<=n;i++)
            {
                cin>>a[i];
            }
            dp[1]=0;
            dp[2]=abs(a[2]-a[1]);
            for(int i=3;i<=n;i++)
            {
                dp[i]= min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
            }
            cout<<dp[n];
}


Measured memory_bytes: 4368
#include <stdio.h>
#include <string.h>

int main(){
    char s[100] = "";
    long k, ans = 0;
    int same = 1;
    int x = 0, head = 0, tail = 0;

    scanf("%s%ld", s, &k);

    if (s[0] == s[strlen(s) - 1]){
        for(int i = 0; i < strlen(s) - 1; i ++){
            if(s[i] != s[i + 1]){
                same = 0;
                break;
            }
        }

        if(same){
            printf("%ld", (strlen(s) * k) / 2);
            return 0;
        }
    }

    for(int i = 0; i < strlen(s) - 1; i ++){
        if(s[i] == s[i + 1]){
            x ++;
        }else{
            same = 0;
            ans += (x + 1) / 2;
            x = 0;
        }
    }

    if (s[0] == s[strlen(s) - 1] && same){
        printf("%ld", (strlen(s) * k) / 2);
            return 0;
    }

    ans += (x + 1) / 2;
    ans *= k;

    if(s[0] == s[strlen(s) - 1]){
        while(s[head] == s[head + 1]){
            head ++;
        }
        while(s[strlen(s) - 1 - tail] == s[strlen(s) - 1 - (tail  + 1)]){
            tail ++;
        }
        ans += ((head + 1) % 2) * ((tail + 1) % 2) * (k - 1);
    }
    printf("%ld", ans);
    return 0;
}


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

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

  int a, b, c;
  cin >> a >> b >> c;
  auto ans = b + c - a;
  ans = max (ans, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256