akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

const ll MOD = 1000 * 1000 * 1000 + 7;
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;

	vi v(n); for (int i = 0; i < n; ++i) cin >> v[i];
	map<int, ll> sumasParciales;

	//Compresion
	vi vect;
	vect.push_back(v[0]);
	for (int i = 1; i < n; ++i) {
		if (v[i] != v[i - 1]) vect.push_back(v[i]);
	}

	vi aux;
	vi formas(vect.size()); formas[0] = 1;
	aux.push_back(0);
	sumasParciales.insert(mp(vect[0], 1));

	for (int i = 1; i < vect.size(); ++i) {
		if (sumasParciales.find(vect[i]) == sumasParciales.end()) {
			sumasParciales.insert(mp(vect[i], formas[i - 1]));
			formas[i] = formas[i - 1];
		}
		else {
			ll sumar = sumasParciales[vect[i]];
			sumasParciales[vect[i]] = (sumasParciales[vect[i]] + formas[i - 1]) % MOD;
			formas[i] = (formas[i - 1] + sumar) % MOD;
		}
	}

	cout << formas[vect.size() - 1] << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 15092
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[100004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);

	cin >> a;
	if (a==1)
	{
		cout << 0 << endl;
		return 0;
	}
	//for (ll i = 1; i < a; i++)
	//{
	//	if (a%i == a / i)
	//	{
	//		cout << i << endl;
	//		ans += i;
	//	}
	//}
	b = 1;
	d = sqrt(a);
	while (true)
	{
		c = a / b - 1;
		if (a/c==a%c)
		{
			ans+=c;
		}

		b++;
		if (b>1000000||b>d)
		{
			break;
		}
	}
	


	cout << ans << endl;



	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

S = input().strip()
l = len(S)
dic = {0:[-1]}
ans = 0
base = 1
mod = 0
for i in range(0, l):
    base = (10 * base) % 2019
    s = base * int(S[l-1-i]) + mod
    mod = s % 2019
    if mod in dic:
        dic[mod].append(i)
    else:
        dic[mod] = [i]

for key, val in dic.items():
    v_len = len(val)
    ans += (v_len * (v_len -1))// 2

print(ans)



Measured memory_bytes: 71304
#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MOD 1000000007

int n;
ll a[200005];
ll sum[200005];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=n;i>=1;i--)
	{
		sum[i]=(sum[i+1]+a[i])%MOD;	
	}
	for(int i=1;i<n;i++)
	{
		sum[0]=(sum[0]+a[i]*sum[i+1])%MOD;
	}
	printf("%lld\n",sum[0]%MOD);
	return 0;
} 

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  string o,e;
  cin >> o >> e;
  ll n=o.size(),m=e.size();
  for (ll i=0;i<m;i++) {
    cout << o.at(i) << e.at(i);
  }
  if (n-m==1) {
    cout << o.at(n-1);
  }
}


Measured memory_bytes: 256
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


H, W = invr()
C = []
for i in range(H):
    temp = instr()
    C.append(temp)

for i in range(2*H):
    temp = ""
    for j in range(W):
        temp += C[i//2][j]
    print(temp)


Measured memory_bytes: 3188
#include <stdio.h>
#define N 36
struct A{
  char key;
  char key2;
};
int main() {
  int i,j,n,min,flag=1;
  char c;
  struct A C1[N],C2[N],temp;
  scanf("%d%c",&n,&c);
  for(i=0;i<n;i++)scanf("%c%c%c",&C1[i].key2,&C1[i].key,&c);
  for(i=0;i<n;i++)C2[i]=C1[i];
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(C2[j].key < C2[j-1].key){
	temp=C2[j];
	C2[j]=C2[j-1];
	C2[j-1]=temp;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%c%c",C2[i].key2,C2[i].key);
  }
  printf("\nStable\n");
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(C1[j].key<C1[min].key)min=j;
    }
    temp=C1[i];
    C1[i]=C1[min];
    C1[min]=temp;
  }
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%c%c",C1[i].key2,C1[i].key);
    if(C1[i].key2!=C2[i].key2 || C1[i].key != C2[i].key)flag=0;
  }
  printf("\n");
  if(flag==0)printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}



Measured memory_bytes: 2144
import itertools
n = int(input())
query = []
for _ in range(n):
    x,y,h = map(int,input().split())
    if h != 0:
        query.append((x,y,h))
tx = query[0][0]
ty = query[0][1]
th = query[0][2]
if len(query) == 1:
    print(tx,ty,th)
    exit()
query.pop(0)
c = [i for i in range(101)]
cc = list(itertools.product(c, repeat=2))
for X,Y in cc:
    H = th + abs(tx-X) + abs(ty-Y)
    Flag = True
    for x,y,h in query:
        if max(H - abs(x-X) - abs(y-Y),0) != h:
            Flag = False
            break
    if Flag:
        print(X,Y,H)
        exit()

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    int i,j;
    int n,k;
    while(1){
        cin>>n>>k;
        if(n==0) break;
        ll sum=0;
        ll a[n];
        for(i=0;i<n;i++) cin>>a[i];
        for(i=0;i<k;i++){
            sum+=a[i];
        }   
        ll ans=sum;
        for(i=k;i<n;i++){
            sum+=a[i]-a[i-k];
            ans=max(ans,sum);
        }
        cout<<ans<<endl;
    }
}


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

ll arr[100005][3];
ll dp[100005][3];


int main(){
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>arr[i][0];
        cin>>arr[i][1];
        cin>>arr[i][2];
    }
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(ll i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


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

const int MOD=2019;
int l,r,ans=MOD;
bool all=false;

int main() {
	scanf("%d %d",&l,&r);
	if(r-l>=2019) {
		printf("0\n");
		return 0;
	}
	else {
		l%=MOD,r%=MOD;
		if(l>r) r+=MOD;
		for(int i=l;i<=r;i++)
			for(int j=l;j<=r;j++) {
				if(i==j) continue;
				ans=min(ans,(i*j)%MOD);
			}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int M = 2019;

int main(){

  int N;
  cin >> N;


  int minus_odd = 0;;
  int minus_even = 0;;

  ll min_odd = INF;
  ll min_even = INF;

  ll ans = 0;

  rep(i, N){
    ll tmp;
    cin >> tmp;
    if(i%2==0){ 
      if(tmp < 0) minus_even++;
      tmp = abs(tmp);
      ans += tmp;
      min_even = min(min_even, tmp);
    }else {
      if(tmp < 0) {
        minus_odd++;
      }
      tmp = abs(tmp);
      ans += tmp;
      min_odd = min(min_odd, tmp);
    }
  }

  if((minus_even+minus_odd) %2 == 1){
    ans -= 2 * min(min_odd, min_even);
  }

  cout << ans << endl;

}

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

using namespace std; 
 
#define int long long
#define M 1000000007

map<pair<int,int>,int > col;
vector<int> graph[100010];

void dfs(int i,int mx,int pc,int p){
	if(mx==pc){
		pc=1;
	}
	else{
		pc++;
	}
	for(int j=0;j<graph[i].size();j++){
		if(graph[i][j]!=p){
			col[make_pair(i,graph[i][j])]=pc;
			col[make_pair(graph[i][j],i)]=pc;
			dfs(graph[i][j],mx,pc,i);
			if(pc==mx){
				pc=1;
			}
			else{
				pc++;
			}
		}
	}
}
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin >> n;
	int edges[2][n-1];
	for(int i=0;i<n-1;i++){
		cin >> edges[0][i] >> edges[1][i];
		graph[edges[0][i]].push_back(edges[1][i]);
		graph[edges[1][i]].push_back(edges[0][i]);
	}
	int mx=0,ind;
	for(int i=1;i<=n;i++){
		if(mx<(int)graph[i].size()){
			mx=graph[i].size();
			ind=i;
		}
	}
	dfs(ind,mx,0,-1);
	cout << mx << endl;
	for(int i=0;i<n-1;i++){
		cout << col[make_pair(edges[0][i],edges[1][i])] << endl;
	}
}


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

int main() {
	int m, n;
	while (cin >> m >> n, m) {
		vector<int>v(m);
		iota(v.begin(), v.end(), 1);
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			string s; cin >> s;
			if (v.size() == 1)continue;
			string ans;
			if (i % 3 == 0 || i % 5 == 0) {
				if (i % 3 == 0)ans += "Fizz";
				if (i % 5 == 0)ans += "Buzz";
			}
			else ans = to_string(i);
			if (ans != s) {
				v.erase(v.begin() + cnt);
				cnt %= v.size();
			}
			else cnt = (cnt + 1) % v.size();
		}
		rep(i, v.size()) {
			cout << v[i] << (i == v.size() - 1 ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=c-a;
  int y=d-b;
  cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
  return 0;
}

Measured memory_bytes: 125568
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int ll

const int M = 998244353;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e9 + 100;
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

#define N 200000




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

	int q; cin >> q;
	while (q--)
	{
		int a, b;
		cin >> a >> b;
		if (abs(b - a) <= 1)
			cout << 2 * min(a, b) - 2 << endl;
		else
		{
			int c = (int)sqrt(a * b);
			if (c * c == a * b)
				c--;
			if (c*(c + 1) >= a * b)
				cout << 2 * c - 2;
			else
				cout << 2 * c - 1;
			cout << endl;
		}
	}




}


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

int main()
{
    // cout<<(277/51.0)<<" "<<(296/54.0)<<endl;
    // cout<<(long double)9933233/99999.0<<" "<<(long double)9933333/100000.0<<endl;
    int t=1;
    // cin>>t;
    ll n;cin>>n;
    ll arr[n],a,b;
    for(int i=0;i<n;i++) 
    {
        cin>>a>>b;
        arr[i]=(a==b);
    }
    ll good=0;
    for(int i=0;i<n-2;i++)
    {
        if(arr[i]*arr[i+1]*arr[i+2]) good=1;
    }
    if(good) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

int main(void){

  int b, f, r, v, n, i, j, k;
  int room[4][3][10];

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        room[i][j][k] = 0;
      }
    }
  }

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    room[b-1][f-1][r-1] += v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        printf(" %d", room[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3){
      printf("####################\n");
    }
  }

  return 0;

}



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

int main(void) {
	int N;
	char c;
	cin >> N;
	int date[4] = { 0 };
	for (int i = 0;i < N;i++) {
		cin >> c;
		if (c == 'P') {
			date[0]++;
		}
		if (c == 'W') {
			date[1]++;
		}
		if (c == 'G') {
			date[2]++;
		}
		if (c == 'Y') {
			date[3]++;
		}
	}
	int v = 0;
	for (int i = 0;i < 4;i++) {
		if (date[i] != 0)
			v++;
	}
	if(v ==3)
		cout << "Three"<< endl;
	if (v == 4)
		cout << "Four" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
L = []
R = []
for _ in range(N):
    l, r = rl()
    L.append(l)
    R.append(r)

max_l = max(L)
min_R = min(R)
ab = [(max(0, r - max_l + 1), max(0, min_R - l + 1)) for l, r in zip(L, R)]
ab.sort()
answer = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_R - max_l + 1)
mi = float('inf')

for i in range(N-1):
    mi = min(mi, ab[i][1])
    answer = max(answer, mi + ab[i+1][0])

print(answer)


Measured memory_bytes: 25000
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,j,k,a[n+1][3],dp[n+1][3]={0};
    
    for(i=1;i<=n;i++)
    {
        for(j=0;j<3;j++) cin>>a[i][j];
        
        if(i!=1)
        {
            for(j=0;j<3;j++) 
                for(k=0;k<3;k++) 
                    if(j!=k) 
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
        }
        else for(j=0;j<3;j++) dp[i][j]=a[i][j];
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    return 0;
}

Measured memory_bytes: 4992
import collections
def prime_factor(n):
    res = collections.Counter()
    i = 2
    while i*i <= n:
        while n % i == 0:
            res[i] += 1
            n //= i
        i += 1
    if n != 1:
        res[n] = 1
    return res

def solve(n):

    tmp = prime_factor(n)

    ans = 0
    x = 0
    for v in tmp.values():
        i = 1
        while i <= v: 
            if v - i >= 0:
                v -= i
                ans += 1
            else:
                x += 1
            i += 1
    ans += x // 2
    return ans


if __name__ == "__main__":
    n = int(input())
    print(solve(n))


Measured memory_bytes: 9464
sa = list(input().rstrip())
sb = list(input().rstrip())
sc = list(input().rstrip())

s = [sa, sb, sc]
p = ['a', 'b', 'c']
cur = 0

while len(s[cur]) != 0:
    cur = p.index(s[cur].pop(0))

print(p[cur].upper())

Measured memory_bytes: 3060
n = int(input()) + 1
a = [int(item) for item in input().split()]
MOD = 10**9 + 7

def mod_pow(x, n):
    ans = 1
    while(n != 0):
        if n & 1:
            ans = ans * x % MOD
        x = x * x % MOD
        n = n >> 1
    return ans

fac = [1] + [0] * n
inv_fac = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    inv_fac[i] = inv_fac[i-1] * mod_pow(i, MOD-2) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = inv_fac[n-r] * inv_fac[r] % MOD
    return tmp * fac[n] % MOD 

index = [-1] * (n+1)
l, r = 0, 0
for i, c in enumerate(a):
    if index[c] == -1:
        index[c] = i
    else:
        l = index[c]
        r = i

for i in range(1, n+1):
    total = mod_nCr(n, i)
    doubled = mod_nCr(n -(r-l) - 1, i-1)
    ans = total - doubled
    if ans < 0:
        ans += MOD
    print(ans)

Measured memory_bytes: 21236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_Virtual
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            string []Hs = Console.ReadLine().Split(' ');
            int[] H = new int[Hs.Length];
            for (int i = 0; i < Hs.Length; i++)
            {
                H[i] = Convert.ToInt32(Hs[i]);
            }
            int canmove = 0;
            int high = 0;
            for (int i = 0; i < H.Length-1; i++)
            {
                if (H[i] >= H[i + 1])
                {
                    canmove++;
                    if (high <= canmove)
                    {
                        high = canmove;
                    }
                }
                else
                {
                    canmove = 0;
                }
            }

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


Measured memory_bytes: 23004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    int k = (a + b) / 2;
    if (abs(a - k) == abs(b - k)) cout << k << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
f = False
for i in range(0,len(s)-1):
	if f:
		break
	if s[i] == s[i+1]:
		print(str(i+1) + ' ' + str(i+2))
		f = True
for i in range(0,len(s)-2):
	if f:
		break
	if s[i] == s[i+2]:
		print(str(i+1) + ' ' + str(i+3))
		f = True
if not f:
	print('-1 -1')	

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

main()
{
  int N, M;
  int cnt[55] = {};

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B; --A, --B;
    cnt[A]++, cnt[B]++;
  }

  for(int i = 0; i < N; i++) {
    cout << cnt[i] << endl;
  }

  return (0);
}
    


Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n;
vector< pair<double,double> > pnt(51);
const double EPS = 1e-9;

double g(double x,double y)
{
	double mx=0;
	rep(i,0,n) mx=max(mx,sqrt(pow(x-pnt[i].F,2)+pow(y-pnt[i].S,2)));
	return mx;
}

double f(double x)
{
	double low=0,high=1000;
	while(high-low>EPS)
	{
		double midl = low+(high-low)/3;
		double midr = high - (high-low)/3;
		if(g(x,midl)>g(x,midr)) low = midl;
		else high = midr;
	}

	return g(x,low);
}

int solve()
{
	cin>>n;
	rep(i,0,n) cin>>pnt[i].F>>pnt[i].S;
	double low=0,high=1000;
	while(high-low>EPS)
	{
		double midl = low+(high-low)/3;
		double midr = high - (high-low)/3;
		if(f(midl)>f(midr)) low = midl;
		else high = midr;
	}
	cout<<setprecision(15)<<f(low)<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int x = in.nextInt();
      out.println(x ^ 1);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 32964
import           Control.Applicative

main :: IO ()
main = do
  input <- getLine
  case eval input of
    Nothing -> pure ()
    Just n  -> print n >> main

eval :: String -> Maybe Integer
eval input = result
  where
    [a',op,b'] = words input
    a = read a'
    b = read b'
    result = case op of
      "+" -> Just $ a + b
      "-" -> Just $ a - b
      "*" -> Just $ a * b
      "/" -> Just $ a `div` b
      _   -> Nothing




Measured memory_bytes: 4052
#include <stdio.h>
#include <string.h>
char m[101][101];
int n[101][101];
void search(int i,int j,int k)
{
  char c = m[i][j];
  n[i][j] = k;
  if (m[i][j-1] == c && n[i][j-1] == 0) search(i,j-1,k);
  if (m[i][j+1] == c && n[i][j+1] == 0) search(i,j+1,k);
  if (m[i-1][j] == c && n[i-1][j] == 0) search(i-1,j,k);
  if (m[i+1][j] == c && n[i+1][j] == 0) search(i+1,j,k);
}
int main(){
  int h,w,i,j,k;
  for(;;){
    scanf("%d%d\n",&h,&w);
    if(h==0&&w==0) break;
    memset(m,0,sizeof(m));
    memset(n,0,sizeof(n));
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	scanf("%c",&m[i][j]);
      }
      scanf("\n");
    }
    k = 0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(n[i][j] == 0) search(i,j,++k);
      }
    }
    printf("%d\n",k);
  }
  return 0;
}

Measured memory_bytes: 0
from itertools import combinations
from collections import defaultdict

N = int(input())
if N == 1:
    print(1)
    exit()

X = [-1] * N
Y = [-1] * N

counts = defaultdict(int)

for i in range(N):
    X[i], Y[i] = map(int, input().split())

# calc all combination
max_cost = N


for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x = X[i] - X[j]
        y = Y[i] - Y[j]
        counts[(x, y)] += 1

max_tmp = max(counts.values())

print(max_cost - max_tmp)

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

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

    vector<vector<int>> tree(N);
    vector<int> n_in(N);
    for (int i = 0; i < N - 1 + M; i++)
    {
        int Ai, Bi;
        cin >> Ai >> Bi;
        Ai--;
        Bi--;
        tree.at(Ai).push_back(Bi);
        n_in.at(Bi) += 1;
    }

    int r;
    for (int i = 0; i < N; i++)
    {
        if (n_in.at(i) == 0)
        {
            r = i;
            break;
        }
    }

    vector<int> l;
    queue<int> q;
    q.push(r);
    while (q.size())
    {
        int n = q.front();
        q.pop();

        l.push_back(n);
        for (auto &&e : tree.at(n))
        {
            n_in.at(e)--;
            if (n_in.at(e) == 0)
            {
                q.push(e);
            }
        }
    }

    vector<int> p(N, 0);
    for (auto &&n : l)
    {
        for (auto &&e : tree.at(n))
        {
            p.at(e) = n + 1;
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << p.at(i) << endl;
    }
}

Measured memory_bytes: 7544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e3 + 10;
int cnt[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	ll ans = 1;
	for(int i = 2; i <= n; ++i)
	{
		int x = i;
		for(int j = 2; j * j <= x; ++j)
			while(x % j == 0)
			{
				++cnt[j];
				x /= j;
			}
		if(x > 1)
			++cnt[x];
	}
	for(int i = 2; i < maxn; ++i)
		ans = ans * (cnt[i] + 1) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int n,h[2];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[1]);
		if(h[1]<h[0]){puts("No");return 0;}
		if(h[1]>h[0])h[1]--;
		h[0]=h[1];
	}
	puts("Yes");
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	cout << fixed << setprecision(10);
	int a, b, x;
	cin >> a >> b >> x;
	double rad;
	if (a * a * b >= 2 * x) rad = atan((double)a * b * b / 2 / x);
	else rad = atan(((double)2 * b / a) - ((double)2 * x / a / a / a));
	
	cout << rad * 180 / M_PI << endl;
    
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  set<char> se;
  rep(i,3){
    se.insert(s[i]);
  }
  if(se.size()==3) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
ans = [0]*4
resList = ["AC","WA","TLE","RE"]
res = ""
for i in range(N):
  res = str(input())
  for j in range(4):
    if res == resList[j]:
      ans[j] += 1
for i in range(4):
  print(resList[i] + " x " + str(ans[i]))

Measured memory_bytes: 9176
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


struct edge{
    ll to,w;
};

vector<ll> dep;
vector<vector<edge>> path;

void dfs(ll s,ll par){
    for(auto e:path[s]){
        if(e.to==par) continue;
        dep[e.to]=dep[s]+e.w;
        dfs(e.to,s);
    }
}

int main(){
    ll n; cin>>n;
    path.assign(n,vector<edge>(0));
    rep(i,n-1){
        ll a,b,c; cin>>a>>b>>c;
        a--; b--;
        path[a].push_back(edge{b,c});
        path[b].push_back(edge{a,c});
    }
    dep.assign(n,0);
    ll q,k; cin>>q>>k; k--;
    dfs(k,-1);
    rep(i,q){
        ll x,y; cin>>x>>y;
        x--; y--;
        printf("%lld\n",dep[x]+dep[y]);
    }
    
}

Measured memory_bytes: 14336
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	
	int input;
	int loop, max;
	int i, j;
	int tmp;

	scanf("%d", &input);
	loop = sqrt(input);
	max = 0;
	
	for (i = 1; i<=loop; i++){
		for (j = 1; j <= loop; j++){
			
			tmp = i;
			for(int k = 1; k < j; k++) {
				tmp *= i;
			}
			
			if (tmp <= input){
				if(tmp > max) {
					//printf("%d ** %d = %d\n", i, j, tmp);
					max = tmp;
				}
			}else{
				break;
			}
			
		}
	}
	
	printf("%d\n", max);
	
	return 0;
	
}

Measured memory_bytes: 128
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut x: Vec<i64> = (0..n).map(|_| read()).collect();

    let x_ = x.clone();
    x.sort_by_key(|&k| k);

    for x_i in x_ {
        if x_i > x[(n / 2) - 1] {
            println!("{}", x[(n / 2) - 1]);
        } else {
            println!("{}", x[n / 2]);
        }
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

const int INF = 0x7fffffff;

class SegmentTree {
private:
  int N;
  vector<int> data;

  int parent(int k) { return (k - 1) / 2; }
  int left_child(int k) { return 2 * k + 1; }
  int right_child(int k) { return 2 * k + 2; }

  int rmq(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return data[k];
    int vl = rmq(a, b, left_child(k), l, (l + r) / 2);
    int vr = rmq(a, b, right_child(k), (l + r) / 2, r);
    return min(vl, vr);
  }

public:
  SegmentTree(int n) {
    N = 1;
    while (N < n) N <<= 1; 
    data = vector<int>(2*N-1, INF);
  }

  void update(int p, int value) {
    p += N - 1;
    data[p] = value;

    while (0 < p) {
      p = parent(p);
      data[p] = min(data[left_child(p)], data[right_child(p)]);
    }
  }

  int rmq(int a, int b) {
    return rmq(a, b, 0, 0, N);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  SegmentTree st(n);
  for (int i=0; i<q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      st.update(x, y);
    }
    if (c == 1) {
      cout << st.rmq(x, y + 1) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4932
import sys
sys.setrecursionlimit(500000)

n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    dfs(u,ans[id],v)
    k+=1
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)

Measured memory_bytes: 74300
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 924844033
#define mad(a,b) a=(a+b)%mod;
#define N 2010
ll f[N],g[N],fc[N],gc[N],n,k;
void solve(ll m){
    for(int i=0;i<m-1;i++){
     lol(j,N)fc[i]=gc[i]=0;
     lol(j,N-1){
         fc[j+1]=g[j];
         gc[j]=(f[j]+g[j])%mod;
     }
     lol(j,N)f[j]=fc[j],g[j]=gc[j];
    }
    lol(j,N){
        mad(g[j],f[j]);
        f[j]=0;
    }
}
int main(){
    lol(i,N)f[i]=g[i]=0;g[0]=1;
    cin>>n>>k;
    for(ll a=0;a<k;a++){
        solve((n+k-1-a)/k);
        solve((n+k-1-a)/k);
    }
    ll fac[N]; fac[0]=1;
    for(ll i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
    ll ans=0;
    for(ll i=0;i<=n;i++){
        ll val=(i%2==0?+1:-1);
        mad(ans,val*g[i]*fac[n-i]);
    }
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
 return 0;   
}

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

int main() {
    long long int n,cnt,est,sum,atl;cin >> n;
    cnt = 0;
    sum = 0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    est = abs(a[0]);
    for(int l=1;l<n;l++){
        if(abs(a[l])<est){
            est = abs(a[l]);
        }
    }

    for(int o=0;o<n;o++){
        sum += abs(a[o]);
    }



    for(int j=0;j<n;j++){
        if(a[j]<=0)cnt++;
    }

    atl = sum;
    atl -= abs(est);
    atl -= abs(est);

    if(cnt%2==0){
        cout << sum << endl;
    }else{
        cout << atl << endl;
    }
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  
  long long int a,b,c;
  scanf("%lld%lld%lld",&a,&b,&c);
  long long d=c-a-b;
  if(4*a*b<d*d&&d>0)printf("Yes");
  else printf("No");
  return 0;
}
                      


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

int main(void)
{
	int a,b,c,d,e;
	scanf("%d %d",&a,&b);
	if(b==100){
		c=1000;
	}
	if(b<=99){
		if(b>=10){
			c=100;
		}
	}
	if(b<=9){
		c=10;
	}
	d=a*c+b;
	e=(int)sqrt((double)d);
	if(e*e==d){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import itertools

ii = lambda : int(input())
li = lambda : tuple(map(int,input().split()))

n = ii()
p = li()
q = li()

p_pos = q_pos = -1

for k,i in enumerate(itertools.permutations(range(1,n+1))):
    if(p_pos != -1) & (q_pos != -1):
        break
    if(p == i):
        p_pos = k
        
    if(q == i):
        q_pos = k
    
print(abs(p_pos-q_pos))

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int K,S;
    cin>>K>>S;

    int ans=0;
    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            int z=S-x-y;
            if(z<0||z>K)continue;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;


int main(){
	list<int> list;
	int n;
	cin >> n;

	string cmd;
	int i, arg;
	for(i = 0; i < n; i++){
		cin >> cmd;
		if(cmd == "insert"){
			cin >> arg;
			list.push_front(arg);
		}else if(cmd == "delete"){
			cin >> arg;
			int pos = 0;
			for(int tmp : list){
				if(tmp == arg)
					break;
				pos++;
			}
			if(pos != static_cast<int>(list.size()))
				list.erase(next(list.begin(), pos));
		}else if(cmd == "deleteFirst"){
			list.pop_front();
		}else if(cmd == "deleteLast"){
			list.pop_back();
		}
	}

	int size = static_cast<int>(list.size());
	if(size > 0){
		cout << list.front(); list.pop_front();
		for(i = 1; i < size; i++){
			cout << ' ' << list.front(); list.pop_front();
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 34452
import java.util.*;
public class Main {
	public static long mod;
	public static void main(String[] args) {
		mod = (long)(Math.pow(10, 9)+7);
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		//comb array
		int c[][] = new int [2005][2005];
		//make pascal's triangle
		c[0][0]=1;
		for(int i=0;i<2003;i++) {
			for(int j=0;j<2003;j++) {
				long tmp =  c[i][j]%mod;
				c[i+1][j]+=tmp;
				c[i+1][j+1]+=tmp;
			}
		}	
		for(int i=1;i<=K;i++){
			long tmp1 = c[N-K+1][i];
			long tmp2 = c[K-1][i-1];
			long ans = (tmp1%mod)*(tmp2%mod);
			ans %= mod;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 52820
import java.io.*;
 
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String input = br.readLine();
    
    int space = input.indexOf(" ");
    
    int first = Integer.parseInt(input.substring(0,space));
    int second = Integer.parseInt(input.substring(space+1));
    
    if((first*second)%2 == 0){
      System.out.println("Even");
    }
    else{
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 20564
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;

  int ans = 0;
  for (int i = 1; i <= N; i++){
    if (to_string(i).size() % 2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3764
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * (N)
    
    #Aがどのグループに属しているかを調べる
    def root(self, A):
        if self.parent[A-1] < 0:
            return A
        self.parent[A-1] = self.root(self.parent[A-1])
        return self.parent[A-1]

    #自分がいるグループのチュ点数を調べる    
    def size(self, A):
        return -1 * self.parent[self.root(A)-1]
    
    #AとBをくっ付ける
    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        if A == B:
            return False
        #大きい方(A)に小さい方(B)をくっつけたい
        #大小が逆であればひっくり返す
        if self.size(A) < self.size(B):
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1]
        self.parent[B-1] = A
        return True

ans = [0] * M
ans[M-1] = N * (N-1) //2
uni = UnionFind(N)
for i in range(M-1, 0, -1):
    if uni.root(ab[i][0]) != uni.root(ab[i][1]):
        ans[i-1] = ans[i] - uni.size(ab[i][0]) * uni.size(ab[i][1])
        uni.connect(ab[i][0], ab[i][1])
    else:
        ans[i-1] = ans[i]


for i in ans:
    print (i)



Measured memory_bytes: 33552
n = int(input())
if ( 599>=n>= 400 ):
    print("8")
elif ( 799 >= n>= 600):
    print("7")
elif ( 999 >= n>= 800):
    print("6")
elif ( 1199 >= n>= 1000):
    print("5")
elif ( 1399>= n>= 1200):
    print("4")
elif ( 1599 >= n>= 1400):
    print("3")
elif ( 1799 >= n>= 1600):
    print("2")
elif ( 1999 >= n>= 1800):
    print("1")


Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int main() {
   long long int h;
   cin>>h;
   long long int b=0,k=1;
  if(h!=1)
  {
   while(h>0)
   {
       h=h/2;
       b=b+k;
       k=k*2;
       if(h==1)
       {
           break;
       }
   }
   b=b+k;
   cout<<b;
  }
  else
  {
      cout<<1;
  }
}

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

struct card{
  char mark;
  int num;
};

int partition(card A[], int p, int r){
  int x = A[r].num;
  int i = p - 1;
  for(int j=p;j<r;j++){
    if(A[j].num <= x){
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i+1;
}

void quicksort(card A[], int p, int r){
  if(p < r){
    int q = partition(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}

const int MAX = 100001;
const int SENTINEL = 2000000000;

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

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

void mergesort(card A[], int left, int right){
  if(right - left > 1){
    int mid = (left + right) / 2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, right, mid);
  }
}

int main(){
  int n;
  cin >> n;
  card A[100001], B[100001];
  for(int i=0;i<n;i++){
    cin >> A[i].mark >> A[i].num;
    B[i].mark = A[i].mark;
    B[i].num = A[i].num;
  }
  bool stable = true;
  quicksort(A, 0, n-1);
  mergesort(B, 0, n);
  for(int i=0;i<n;i++){
    if(A[i].mark != B[i].mark) stable = false;
  }
  if(stable) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for(int i=0;i<n;i++) cout << A[i].mark << " " << A[i].num << endl;
  return 0;
}



Measured memory_bytes: 5456