akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.length() == 1) {
			System.out.println(1);
			return;
		}
		long[] alpha = new long[26];
		for (int i = 0; i < s.length(); i++) {
			alpha[s.charAt(i) - 97]++;
		}
		long divide = 1;
		int odd = 0;
		for (int i = 0; i < 26; i++) {
			if (alpha[i] % 2 != 0) {
				odd++;
				if (odd > 1 || s.length() % 2 == 0) {
					System.out.println(0);
					return;
				}
			}
			if (alpha[i] != 0) {
				for (long j = 1; j <= alpha[i] / 2; j++) {
					divide *= j;
				}
			}
		}

		long ans = 1;
		for (long i = 2; i <= s.length() / 2; i++) {
			ans *= i;
		}
		ans /= divide;
		System.out.println(ans);
		sc.close();
	}
}

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

#define NMAX 200100
#define INF 2000000000

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

typedef unsigned long long ull;
typedef long long int lli;

using namespace std;

// std::ifstream cin("f.in");
// std::ofstream cout("f.out");

ull a, b;

int main()
{
    cin >> a >> b;
    ull xors = 0;

    if(b - a <= 10)
    {
        xors = a;
        for(int i = a + 1; i <= b; i++)
            xors ^= i;
        
        cout << xors << '\n';
        exit(0);
    }

    while(a & 3 && a < b)
    {
        xors ^= a;
        a++;
    }

    a = a + (b - a) / 4 * 4;
    while(a != b + 1)
    {
        xors ^= a;
        a++;
    }

    cout << xors << '\n';
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <cstring>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int main(){
    int n;
    cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];
    cout<<F[n]<<endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
using namespace std;
int num[100010];
int n, m;
int main(){
    int i, j, k;
    cin >> n;
    num[0] = 2147483647;
    for(i = 1; i <= n; ++i){
        scanf("%d",&num[i]);
        if(num[i] > num[i-1])num[i] -= 1;
        //cout << num[i] << " ";
    }
    int minn = num[1];
    //cout << endl;
    for(i = 2; i <= n; ++i){
        //cout << minn << " ";
        if(minn > num[i]){
            cout << "No" << endl;
            return 0;
        }
        if(num[i] > minn)minn = num[i];
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
P = input().split(" ")

t = 1
list = []
for i in range(N):
    list.append(int(P[i]))
    if i == 0:
        m = int(P[0])
    elif int(P[i]) < m:
        m = int(P[i])
        t = t + 1
        
print(t)

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define SZ(S) S.size()
#define vi vector<int>
#define pr pair<int,int>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define FORD(i,b,a) for(int i=(int)(b);i>=(int)(a);--i)
#define CLR(A,x) memset(A,x,sizeof(A))
#define ALL(S) S.begin(),S.end()

#define OUT(a,l,r) cout<<#a": ";FOR(i,l,r)cout<<a[i]<<" ";cout<<endl
#define PRT(a) cout<<"--> "#a" "<<a<<endl

using namespace std;
typedef unsigned long long ll;

const int N=90,INF=0x3f3f3f3f;
const ll P=1e9+7;

template<typename T>
inline void read(T& x,int f=1,char s=getchar()) {
	for(x=0;s>'9'||s<'0';s=getchar()) if(s=='-') f=-1; 
	while(s<='9'&&s>='0') x=x*10+s-'0',s=getchar();x*=f;
}

ll f[N];
int w1[]={0,1,0,-1};
int w2[]={-1,0,1,0};

int main() {
	f[0]=f[1]=1;
	REP(i,2,N) {
		f[i]=f[i-1]+f[i-2];
		//cout<<f[i]<<endl;
	}
	int T;
	read(T);
	while(T--) {
		ll x,y;
		read(x),read(y);
		if(y>x) swap(x,y);
		int now=1;
		while(f[now+2]<=x&&f[now+1]<=y) now++;
		
		if(now==1) {
			printf("%d %lld\n",now,(x*y)%P);
			continue;
		}
		
		ll a=f[now+1],b=f[now];
		ll ans=0;
		if(x>=a&&y>=b) ans=(ans+1+(x-a)/b)%P;
		if(y>=a&&x>=b) ans=(ans+1+(y-a)/b)%P;
		
		int t=0;
		//cout<<"-->"<<a<<" "<<b<<endl;
		FORD(i,now,0) {
			t=(t+1)%4;
			a+=f[i]*w1[t],b+=f[i]*w2[t];
			if(i!=now) {
				if(x>=a&&y>=b) ans=(ans+1+(x-a)/b)%P;
				if(y>=a&&x>=b) ans=(ans+1+(y-a)/b)%P;
			}
			//cout<<"-->"<<a<<" "<<b<<endl;
		}
		printf("%d %lld\n",now,ans);
	}
	return 0;
}
/*
1000000000000000000 1000000000000000000
*/

Measured memory_bytes: 3968
/*
* @Author: 王文宇
* @Date:   2017-11-24 00:48:10
* @Last Modified by:   王文宇
* @Last Modified time: 2017-11-24 00:49:57
*/
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	long long ans = 1;
	for(int i=1;i<=n;i++)
	{
		if(ans<k)ans*=2;
		else ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll inf=1e18;
const ll mod=1e9+7;
const ll maxn=1e3+10,maxp=10110;

ll a,b,c,d,ans;

int main(){
	FAST_IO;
	cin>>a>>b>>c>>d;
	ans=a*c;
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ai;
    cin>>n;
    unordered_map<int,int> a;
    for(int i=0;i<n-1;i++){
        cin>>ai;
        a[ai]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 11492
#include <iostream>
#include <string>
using namespace std;
int main()
{
   string s;
   cin>>s;
   if(s=="SUN"){
    cout << 7;
   }
   if(s=="MON"){
    cout << 6;
   }
   if(s=="TUE"){
    cout << 5;
   }
   if(s=="WED"){
    cout  <<  4;
   }
   if(s=="THU"){
    cout << 3;
   }
   if(s=="FRI"){
    cout << 2;
   }
   if(s=="SAT"){
    cout << 1;
   }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[105][100005];


void knapsack(ll *v,ll* w,ll N,ll W){
    for(ll i=0;i<=N;i++){
        for(ll j=0;j<=W;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
                continue;
            }
            if(j-w[i]<0){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
        }
    }
   cout<<dp[N][W];
}
int main()
{
    ll N,W;
    
    cin>>N>>W;
    ll v[N],w[W];
    for(ll i=1;i<=N;i++){
        cin>>w[i]>>v[i];
    }
    
   // memset(dp,-1,sizeof(dp));
    knapsack(v,w,N,W);
    return 0;
    
}

Measured memory_bytes: 82476
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll ans = 0;

void solve(string s, int idx, ll sum)
{
  if(idx == s.size()) {
    ans += sum;
    return;
  }

  for(int i = 1; i+idx <= s.size(); i++) {
    solve(s, idx+i, sum + stoll(s.substr(idx, i)));
  }
}

int main()
{
  string S;
  cin >> S;
  solve(S, 0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi a;

int main(){
	cin>>n>>m;
	a=vvi(n,vi(m));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>a[i][j];
	int t=0;
	set<int> st;
	for(int i=1;i<200;i++) st.insert(i*i);
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++){
		int tmp=0;
		for(int k=0;k<m;k++){
			int d=abs(a[i][k]-a[j][k]);
			tmp+=d*d;
		}
		if(st.find(tmp)!=st.end()) t++;
	}
	cout<<t<<endl;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;
    string s; cin >> s;

    int cntR = 0;
    int cntB = 0;
    REP(i, n) {
        if (s[i] == 'R') cntR++;
        if (s[i] == 'B') cntB++;
    }

    if (cntR > cntB) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

struct Combination {
  vector<long long> inv,finv,fac;
  Combination(int n, int kmax) : inv(kmax+1),finv(kmax+1),fac(kmax){
    if(kmax>=1){
      inv.at(1)=1;
      finv.at(1)=1;
      fac.at(0) = n;
    }
  for(int i=2; i<=kmax; i++) inv.at(i) = MOD - inv.at(MOD%i) * (MOD/i) %MOD;
  for(int i=2; i<=kmax; i++) finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  for(int i=1; i<kmax; i++) fac.at(i) = fac.at(i-1) * (n-i) % MOD;
  }
  long long comb(int k) {return (k ? fac.at(k-1) * finv.at(k) % MOD : 1 );}
};

int main(){
  
  int s; cin>>s;
  ll ans{};
  int k = s/3;
  for(int i=1; i<=k; i++){
    
    Combination c(s-3*i+i-1,i-1);
    ans += c.comb(i-1);
    //cout<<c.comb(i-1)<<endl;
    ans %= MOD;
  }
  cout<< ans<<endl;
  
}


Measured memory_bytes: 3732
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), d = sc.nextInt(), ans=0;
        int[][] x = new int[n][d];
        for(int i=0;i<n;i++)for(int j=0;j<d;j++)x[i][j]=sc.nextInt();
        for(int k=0;k<n;k++)for(int l=k+1;l<n;l++){
            int ret = 0;
            for(int m=0;m<d;m++)ret+=Math.pow((x[k][m]-x[l][m]), 2);
            if(isPerfectSquare(ret))ans+=1;
        }
        System.out.println(ans);
    }
    static boolean isPerfectSquare(double x){
        double sq = Math.sqrt(x);
        return ((sq - Math.floor(sq) == 0));
    }
}
class f{
    double ff(double d){
        return d * 2;
    }
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e17;
using P = pair<ll,ll>;

// code credit : https://github.com/niklasb/contest-algos/
// blob/master/convex_hull/dynamic.cpp
using line_t = long double;
const line_t is_query = -1e100;

struct Line {
	line_t m, b;
	mutable function<const Line*()> succ;
	bool operator<(const Line& rhs) const {
		if (rhs.b != is_query) return m < rhs.m;
		const Line* s = succ();
		if (!s) return 0;
		line_t x = rhs.m;
		return b - s->b < (s->m - m) * x;
	}
};

struct HullDynamic : public multiset<Line> { // will maintain upper hull for maximum
	bool bad(iterator y) {
		auto z = next(y);
		if (y == begin()) {
			if (z == end()) return 0;
			return y->m == z->m && y->b <= z->b;
		}
		auto x = prev(y);
		if (z == end()) return y->m == x->m && y->b <= x->b;
		return (x->b - y->b)*(z->m - y->m) >= (y->b - z->b)*(y->m - x->m);
	}
	void insert_line(line_t m, line_t b) {
		auto y = insert({ m, b });
		y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
		if (bad(y)) { erase(y); return; }
		while (next(y) != end() && bad(next(y))) erase(next(y));
		while (y != begin() && bad(prev(y))) erase(prev(y));
	}
	line_t query(line_t x) {
		Line u = { x, is_query };
		auto l = *lower_bound(u);
		return l.m * x + l.b;
	}
}* solver;

/* 使用法
solver = new HullDynamic();
solver->insert_line((long double)(value),(long double)(value));
solver->query()
*/


int main(){
  int n; ll c;
  cin >> n >> c;
  ll h[n];
  rep(i,n) cin >> h[i];
  vector<ll> dp(n);
  dp[0] = 0;
  solver = new HullDynamic();
  solver->insert_line((long double)(2*h[0]),(long double)(dp[0]-h[0]*h[0]));
  for(int i = 1; i < n; i++) {
    dp[i] = floor(solver->query((long double)h[i]) + 0.3) - h[i]*h[i] - c;
    solver->insert_line((long double)(2*h[i]),(long double)(dp[i]-h[i]*h[i]));
  }
  cout << -dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(){
	int n;
	double x[101],y[101],P1=0.0,P2=0.0,P3=0.0,P4=0.0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i<=n;i++){
		cin>>y[i];
	}
	for(int i=1;i<=n;i++){
		P1+=abs(x[i]-y[i]);
		P2+=pow(abs(x[i]-y[i]),2);
		P3+=pow(abs(x[i]-y[i]),3);
		if(P4<abs(x[i]-y[i])){
			P4=abs(x[i]-y[i]);
		}
	}
	printf("%.6lf\n%.6lf\n%.6lf\n%.6lf\n",P1,pow(P2,0.5),pow(P3,0.33333333333334),P4);
	return 0;
}

Measured memory_bytes: 3364
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
struct card {
	char ch;
	int num;
};
void SelectSort(card arr[], int n);
void BubbleSort(card arr[], int n)
{
	bool flag = true;
	for (int i = 0;flag && i < n - 1; ++i)
	{
		flag = false;
		for (int j = 0; j < n - 1 - i; ++j)
		{
			if (arr[j].num > arr[j + 1].num)
			{
				flag = true;
				swap(arr[j], arr[j + 1]);
			}
		}
	}
}
void Print(card arr[], int N)
{
	for (int i = 0; i != N - 1; ++i)
		printf("%c%d ", arr[i].ch, arr[i].num);
	printf("%c%d\n", arr[N - 1].ch, arr[N - 1].num);
}
int main(void)
{
	int N;
	card arr[105], t[105];
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	cin >> N;
	
	for (int i = 0; i != N; ++i)
		scanf(" %c%d", &arr[i].ch, &arr[i].num);
	memcpy(t, arr, sizeof(card) * N);
	BubbleSort(t, N);
	Print(t, N);
	printf("Stable\n");
	SelectSort(arr, N);
	Print(arr, N);
	bool flag = true;
	for (int i = 0; i != N; ++i)
	{
		if (arr[i].ch != t[i].ch)
		{
			flag = false;
			break;
		}
	}
	if (!flag)
		printf("Not stable\n");
	else
		printf("Stable\n");
	//system("pause");
	return 0;
}

void SelectSort(card arr[], int n)
{
	int min_idx, min_value;
	for (int i = 0; i < n - 1; ++i)
	{
		min_idx = i;
		for (int j = i + 1; j < n; ++j)
		{
			if (arr[min_idx].num > arr[j].num)
			{
				min_idx = j;
			}
		}
		if (min_idx != i)
		{
			swap(arr[i], arr[min_idx]);
		}
	}
}

Measured memory_bytes: 3260
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n : i32 = read();
    let k : i32 = read();
    println!("{}", if n % k == 0 { 0 } else { 1 });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n , k; 
	cin >> n >> k; 
	vi h(n);
	re(h);
	if(k>=n){
		cout << 0 << endl; 
		return ;
	}
	int cnt = 0 ;
	sort(all(h));
	while(k--){
		h.pop_back();
	}
	trace(h);
	cnt = accumulate(all(h),0LL);
	cout << cnt << endl ;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 4752
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
//////////////////////////////////////////////////

// 0: upper
// 1: right
// 2: bottom
// 3: left
int g[35][35][5];
int dist[35][35];
int h, w;
typedef pair<int, int> P;

int bfs (int sy, int sx) {
    queue<P> que;
    que.push(make_pair(sy, sx));
    rep(i,h) rep(j,w) dist[i][j] = -1;
    dist[sy][sx] = 0;
    while(!que.empty()) {
        P cur = que.front(); que.pop();
        int y = cur.first, x = cur.second;
        for(int i = 0; i < 4; ++i) {
            int ny = y + dy[i], nx = x + dx[i];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
            // 既に訪れていたらスキップ
            if(dist[ny][nx] != -1) continue;

            if(g[y][x][i] == 0) {
                que.push(make_pair(ny, nx));
                dist[ny][nx] = dist[y][x] + 1;
            }
        }
    }

    int res = dist[h-1][w-1];
    if (res == -1) res = 0;
    else res++;
    return res;
}

int main() {
    while (1) {
        cin >> w >> h;
        if (!w && !h) break;
        rep(i,h+1) rep(j,w+1) rep(k,4) {
            g[i][j][k] = 1;
        }
        int tmp;
        rep(i,h) {
            rep(j,w-1) {
                cin >> tmp;
                g[i][j][1] = tmp;
                g[i][j+1][3] = tmp;
            }
            if (i < h-1) {
                rep(j,w) {
                    cin >> tmp;
                    g[i][j][2] = tmp;
                    g[i+1][j][0] = tmp;
                }
            }
        }

        cout << bfs(0,0) << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let v: Vec<u64> = s.trim().split(" ").map(|n|n.parse().unwrap()).collect();
    if v[0] > v[1] {
        println!("{}", v[0] - 1);
    } else {
        println!("{}", v[0]);
    }
}

Measured memory_bytes: 4352
n = int(input())
t, a = tuple(map(int, input().split()))
h = list(map(int, input().split()))
mine = 1000
mini = 0
d=[0 for i in range(n)]
def tmp(x):
    return t - 0.006*x

for i in range(n):
    d[i] = abs( a - tmp(h[i]) )
    if mine > d[i]:
        mine = d[i]
        mini = i

print(mini+1)

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	string a,b;
	cin>>a>>b;
	int as = a.size();
	int bs = b.size();
	int ai = 0;
	int bi = 0;
	while(ai<as && bi<bs)
	{
		cout<<a[ai];
		cout<<b[bi];
		ai++;
		bi++;
	}
	while(ai<as)
	{
		cout<<a[ai];
		ai++;
	}
	while(bi<bs)
	{
		cout<<b[bi];
		bi++;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()

int main(){
  long long count=0;
  int sto=0;
  string s;
  cin >> s;
  for(int i=s.length()-1;i>=0;i--){
    if(s[i]=='B'){
       count += s.length()-1-i-sto;
      sto++;
    }
  }
  cout << count;
}


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll k,t;
    cin >> k >> t;
    vector<ll> a(t);
    for (ll i = 0;i < t;i++){
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll x = 1;
    for (ll i = 1; i < t; i++){
        x += a[i];
    }

    cout << max((a[0] - x),0LL) << endl;
}

Measured memory_bytes: 3640
/*
    author: masab hasnain
*/

/*
    Formulae:
    total number of subsegments = (n*(n+1))/2
*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b){
    return b == 0LL ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a * b) / gcd(a, b);
}
ll mod_pow(ll base, ll power, ll mod){
    base %= mod;
    ll ret = 1LL;
    while(power){
        if(power&1)
            ret = (ret * base) % mod;
        base = (base * base) % mod;
        power >>= 1;
    }
    return ret;
}
vector<ll> primes_global;
vector<ll> seive(ll _upper_bound = 10000000){//be careful when calling with a value.
    bitset<10000007> bs;
    bs.set();
    if(_upper_bound > 10000000)
        _upper_bound = 10000000;
    vector<ll> primes;
    ll _seive_size = _upper_bound ;
    bs[0] = bs[1] = 0;
    for (ll i = 2; i <= _seive_size; i++){
        if(bs[i]){
            for (ll j = i * i; j <= _seive_size; j += i)
                bs[j] = 0;
            primes.push_back(i);
        }
    }
    primes_global = primes;
    return primes;
}
bool is_prime(ll _number){
    if(primes_global.empty())
        seive();
    for (int i = 0; primes_global[i] * primes_global[i] <= _number and i < primes_global.size(); i++){
        if(_number % primes_global[i] == 0)
            return false;
    }
    return true;
}
vector<ll> prime_factors(ll _number){ //be careful about the upperbound of seive.
    if(primes_global.empty()){ //calls seive() if seive() was not called before.
        seive();
    }
    vector<ll> factors;
    ll pf_idx = 0, pf = primes_global[pf_idx];
    if(is_prime(_number)){
        factors.push_back(_number);
        return factors;
    }
    while (pf * pf <= _number )
    {
        if(_number % pf == 0){
            factors.push_back(pf);
            while(_number % pf == 0)
                _number /= pf;
        }
        
        pf = primes_global[++pf_idx];
    }
    if(_number != 1)
        factors.push_back(_number);

    return factors;
}

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

    ll x;
    cin >> x;
    ll cur = 100;
    ll ans = 0;
    while(cur< x)
    {
        ans++;
        cur += (cur * .01);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
<?php

    while(1){
        fscanf(STDIN, '%d %s %d', $a, $b, $c);
        switch ($b) {
            case '+':
                echo $a+$c;
                break;
            case '-':
                echo $a-$c;
                break;
            case '*':
                echo $a*$c;
                break;
            case '/':
                echo floor($a/$c);
                break;
            default:
                exit();
                break;
        }
        echo PHP_EOL;
    }


Measured memory_bytes: 9208
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner {stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<f64> = sc.vec(n);
    let all = a.iter().fold(1.0, |p, e| p * *e);
    let mut sum = 0.0;
    for i in 0..n {
        sum += all / a[i];
    }
    println!("{}", all / sum);

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr> (&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe{ std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let mut s: String = read();
    let s = s.pop().unwrap().to_string();
    if s == "3" {
        println!("bon");
    } else  if s == "0" || s == "1" || s == "6" || s == "8" {
        println!("pon");
    } else {
        println!("hon");
    }
}


Measured memory_bytes: 2108
a, b, c = map(int,input().split())

ans = 'NO'
if a%b == c:
  ans = 'YES'
else:
  i = 2
  while i*a % b != a%b:
    if i*a % b == c:
      ans = 'YES'
      break
    i += 1
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int n; cin >> n;
  int sum = 0;

  int i = n;
  for(int j = 1; j < 10; j++) {
    sum += i % 10;
    i /= 10;
  }

  string ans = "No";
  if(n % sum == 0) { ans = "Yes"; }
  cout << ans << endl;
}


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

int main() {
  string s;
  ll k;

  cin >> k >> s;

  if (s.size() <= k) cout << s << endl;
  else {
    rep(i,k) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X = LI()
    ans = inf
    for x in range(1, 101):
        cur_ans = 0
        for point in X:
            cur_ans += (x - point) ** 2
        ans = min(cur_ans, ans)
    print(ans)

main()



Measured memory_bytes: 66924
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b;
    cin >> a >> b;
    FOR(i, 1, 1000) {
        if ((int(i * 0.08) == a) && (int(i * 0.1) == b)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=2e5+5;
int he[N],ver[N*2],nex[N*2],tot;
void addedge(int,int);
int c[N];
int sum[N],siz[N];
ll ans[N];
void dfs(int,int);

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>c[i];
    int u,v;tot=1;
    for(int i=1;i<n;i++){
        cin>>u>>v;
        addedge(u,v);
        addedge(v,u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++){
        int t=n-sum[i];
        ans[i]+=1LL*t*(t+1)/2;
    }
    for(int i=1;i<=n;i++) cout<<1LL*n*(n+1)/2-ans[i]<<'\n';
}
void dfs(int u,int fa){
    siz[u]=1;
    int re=0;
    for(int i=he[u];i;i=nex[i]){
        int v=ver[i];
        if(v==fa) continue;
        int last=sum[c[u]];
        dfs(v,u);
        siz[u]+=siz[v];
        int t=sum[c[u]]-last;
        ans[c[u]]+=1LL*(siz[v]-t)*(siz[v]-t+1)/2;
        re+=siz[v]-t;
    }
    sum[c[u]]+=re+1;
}
void addedge(int u,int v){
    ver[tot]=v;nex[tot]=he[u];he[u]=tot++;
}


Measured memory_bytes: 26924
import java.io.*
import java.util.*

fun solve(S: String){
    if( S.get(0)!! == 'A' && S.slice(2..S.length - 2).count{ it == 'C' } == 1 && S.count{ it.toLowerCase() == it } == S.length - 2){
        println("AC")
        return
    }
    println("WA")
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    solve(S)
}



Measured memory_bytes: 31620
# encoding: utf-8
N = int(input())
a = list(map(int, input().split()))

a_sum = [0] * N
tmp = 0
for i, ai in enumerate(a):
    tmp += ai
    a_sum[i] = tmp

def diff(A, B): return A - B if A > B else B - A
    
ans = 0
ans_diff = diff(a_sum[0], a_sum[-1] - a_sum[0])
for tmp in range(1, N - 1):
    tmp_diff = diff(a_sum[tmp], a_sum[-1] - a_sum[tmp])
    if tmp_diff < ans_diff: ans, ans_diff = (tmp, tmp_diff)

print(ans_diff)


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

using namespace std;

int main() {
    
    int n;
    string s;
    cin >> n >> s;

    set<int> r,w;
    
    for (int i = 0; i < n; ++i) {
        if(s[i] == 'R') r.insert(i);
        else w.insert(i);
    }

    int ans = 0;
    while(w.size() > 0 and r.size() > 0 and *w.begin() < *r.rbegin()) {
        ans++;
        int x = *w.begin();
        int y = *r.rbegin();
        w.erase(x);
        r.erase(y);
        w.insert(y);
        r.insert(x);
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12976
s = gets.chomp.each_char
t = gets.chomp.each_char

h = Hash.new(0)
g = Hash.new(0)

loop do
  s0, t0 = s.next, t.next
  if h[s0] != g[t0]
    puts "No"
    exit
  else
    h[s0] += 1
    g[t0] += 1
  end
end

puts "Yes"

Measured memory_bytes: 2880
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        a:usize,
        b:usize,
        c:usize,
    }
    let mut count = 0;
    for i in 1..10000{
        count += a;
        if count % b == c{
            println!("YES");
            return;
        }
    }
    println!("NO");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	string c; cin >> c;
	cout << "ABC" + c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<math.h>
using namespace std;

int main() {
	int n, m,a,ans=0,b,c[100005];
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		c[i] = 0;
	}
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		c[a]++; c[b]++;
	}

	for (int i = 0; i < n; i++) {
		if (c[i] % 2 == 1) {
			ans = 1;
			break;
		}
	}
	if (ans)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int z=in.nextInt();
			if(z==0)
				return;
			int max=0;
			int Z=(int)Math.pow(z, 3);
			
			for(int x=1;x*x*x<Z;x++)
				for(int y=1;x*x*x+y*y*y<Z;y++)
				{
					max=Math.max(max,x*x*x+y*y*y);
				}
			System.out.println((int)Math.pow(z, 3)-max);
		}
	}
}

Measured memory_bytes: 19696
n = gets.to_i
a = gets.split.map(&:to_i)

swap_times = 0
for i in 0...(a.length - 1 )
  jMin=i
  for j in (i+1)...(a.length)
    if (a[j] < a[jMin])
        jMin = j;
    end
  end
  if (jMin != i)
    swap_times += 1
    temp=a[i]
    a[i]=a[jMin]
    a[jMin]=temp
  end
end

if swap_times > 1
  puts "NO"
else
  puts "YES"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

int main(){
  ll n, x;
  cin >> n;
  vector<ll> vec(n+1);
  rep(i, n+1) cin >> vec[i];
  sort(all(vec));
  ll gcd = vec[1]-vec[0];
  rep(i, n) gcd = GCD(gcd, vec[i+1]-vec[i]);
  cout << gcd << endl;
  return 0;
}
    


Measured memory_bytes: 1024
N=int(input())
T=[list(map(int,input().split())) for i in range(N)]
T.sort(key=lambda x:x[1])
time=0
err=0
for i in range(N):
    time=time+T[i][0]
    if time>T[i][1]:
        err=1
        break
if time<=T[N-1][1] and err==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 54588
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
     
int main(){
 std::string A,B;
 std::cin >> A >> B;
 long long c = std::stoll(A+B);
 for(int i=0;i<=c;i++){
  if(i*i==c){
    std::cout << "Yes" << std::endl;
    return 0;
  }
 }
 std::cout << "No" << std::endl;
}

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

using namespace std;

int main() {

	int W, H;
	int x, y;
	cin >> W >> H;
	cin >> x >> y;

	printf("%lf", double(W) * double(H) / 2.0f);
	bool isSame = ((x*2 == W && y*2 == H) ? true : false);
	cout <<" " << ((isSame) ? "1" : "0") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100005;
ll n,p,a[maxn];
vector<ll>v;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	bool flag=false;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		if(a[i]%2) {
			flag=true;
		}
	}
	if(flag) cout<<"first";
	else cout<<"second";
	return 0;
}

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

int h,w;
char c[50][51];

bool isDraw(int i,int j){
  if(i > 0){
    if(c[i-1][j] == '#'){
      return true;
    }
  }
  if(i < h-1){
    if(c[i+1][j] == '#'){
      return true;
    }
  }
  if(j > 0){
    if(c[i][j-1] == '#'){
      return true;
    }
  }
  if(j < w-1){
    if(c[i][j+1] == '#'){
      return true;
    }
  }
  return false;
}

int main(){
  cin >> h >> w;
  for(int i = 0;i < h;i++){
    cin >> c[i];
  }

  bool isDrawAll = true;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(c[i][j] == '#'){
        if(!isDraw(i,j)){
          isDrawAll = false;
          break;
        }
      }
    }
    if(!isDrawAll){
      break;
    }
  }

  if(isDrawAll){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var week = new[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            var S = ReadLine();
            for(var i=0;i< week.Length;i++)
            {
                if (S == week[i])
                {
                    WriteLine(7-i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 17428
#include<bits/stdc++.h>
using namespace std;
int ver[400010],nxt[400010],hed[400010],tot=0,vs[200010],n,m,ans=0,tt;
void add(int x,int y){
    ver[++tot]=y,nxt[tot]=hed[x],hed[x]=tot;
}
void search(int x){
	vs[x]=1,tt++;
	for(int i=hed[x];i;i=nxt[i])
		if(!vs[ver[i]])
			search(ver[i]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	memset(vs,0,sizeof(vs));
	for(int i=1;i<=n;++i){
		if(!vs[i])
			tt=0,search(i);
		ans=max(ans,tt);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 17696
N, Q = map(int,input().split())
S = list(input())
preC = [0]
for i in range(1, len(S)):
    if S[i] == 'C' and S[i-1] == 'A':
        preC += [preC[-1] + 1]
    else:
        preC += [preC[-1]]

for q in range(Q):
    l, r= map(int,input().split())
    total = preC[r - 1]
    if l == 1:
        print(total)
    else:
        total -= preC[l - 2]
        if S[l - 1] == 'C' and S[l - 2] == 'A':
            total -= 1
        print(total)        
        

'''
8 3
ACACTACG
1 3
4 7
1 8     
        
'''

Measured memory_bytes: 6872
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=998244353;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
struct pt
{
	int a,b;
	pt(int a=0,int b=0):a(a),b(b){}
};
pt operator+(const pt x,const pt y)
{
	return pt(addmod(x.a+y.a),addmod(x.b+y.b));
}
pt operator-(const pt x,const pt y)
{
	return pt(submod(x.a-y.a),submod(x.b-y.b));
}
pt operator*(const pt x,const pt y)
{
	return pt(addmod(1ll*x.a*y.a%mod+5ll*x.b*y.b%mod),addmod(1ll*x.a*y.b%mod+1ll*x.b*y.a%mod));
}
pt getinv(pt x)
{
	int nw=submod(1ll*x.a*x.a%mod-5ll*x.b*x.b%mod);
	nw=fpow(nw,mod-2);
//	printf("nw=%d\n",nw);
	return pt(1ll*x.a*nw%mod,addmod(mod-1ll*x.b*nw%mod));
}
pt pfpow(pt x,ll y)
{
	pt ans=pt(1);
	while(y)
	{
		if(y&1) ans=ans*x;
		x=x*x;
		y/=2;
	}
	return ans;
}
int n,inv2,c[1000005],pn=2e5;
ll m;
pt p,q,invp,invq,dp[200005],ans;
void print(pt x)
{
	printf("(%d,%d) ",x.a,x.b);
}
int main()
{
	inv2=fpow(2,mod-2);
	cin>>n>>m;
	c[0]=1;
	for(int i=1;i<=pn;i++)
		c[i]=1ll*c[i-1]*((m+i)%mod)%mod*fpow(i,mod-2)%mod;
	p=pt(inv2,inv2);
	q=pt(inv2,mod-inv2);
	invp=getinv(p-pt(1));
	invq=getinv(q-pt(1));
//	print(p),print(q),print(invp),print(invq);
//	printf("\n");
	//print((p-pt(1)));
//	print((p-pt(1))*invp),print((q-pt(1))*invq);
	dp[1]=pfpow(p,m);
	for(int i=2;i<=n;i++)
		dp[i]=(dp[i-1]*p-pt(c[i-2]))*invp;
	ans=dp[n];
	dp[1]=pfpow(q,m);
	for(int i=2;i<=n;i++)
		dp[i]=(dp[i-1]*q-pt(c[i-2]))*invq;
	ans=ans-dp[n];
	ans=ans*getinv(pt(0,1));
	//print(ans);
	printf("%d\n",ans.a);
	return 0;
}

Measured memory_bytes: 4352
d = {1: 1, 2: 3, 3: 1, 4: 2, 5: 1, 6: 2, 7: 1, 8: 1, 9: 2, 10: 1, 11: 2, 12: 1}
x, y = map(int, input().split())
print('YNeos'[d[x] != d[y]::2])

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

vector<int> to[200010];
int d[200010];

void dfs(int u, int prev, int val) {
    d[u] = val;
    for (int v: to[u]) {
        if (v == prev) continue;
        dfs(v, u, 3-val);
    }
}

int main() {
    int N;
    cin >> N;
    int a, b;
    for (int i=0; i<N-1; ++i) {
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0, -1, 1);

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

    int r[3] = {N/3, (N+2)/3, (N+1)/3};
    if (cnt[1] <= r[0]) {
        // 1 が N/3以下
        for (int i=0; i<N; ++i) {
            if (d[i] == 1) d[i] = 0;
        }
        r[0] -= cnt[1];
        for (int i=0; i<N; ++i) {
            if (d[i] == 2) {
                if (r[0] > 0) {
                    d[i] = 0; r[0]--;
                } else if (r[1] > 0) {
                    d[i] = 1; r[1]--;
                }
            }
        }
    } else if (cnt[2] <= r[0]) {
        // 2 が N/3以下
        for (int i=0; i<N; ++i) {
            if (d[i] == 2) d[i] = 0;
        }
        r[0] -= cnt[2];
        for (int i=0; i<N; ++i) {
            if (d[i] == 1) {
                if (r[0] > 0) {
                    d[i] = 0; r[0]--;
                } else if (r[2] > 0) {
                    d[i] = 2; r[2]--;
                }
            }
        }
    } else {
        // 1,2 とも N/3以上
        for (int i=0; i<N; ++i) {
            if (d[i] == 1 && cnt[1] > r[1]) {
                d[i] = 0; cnt[1] --;
            } else if (d[i] == 2 && cnt[2] > r[2]) {
                d[i] = 0; cnt[2] --;
            }
        }
    }

    int t[3] = {0, -2, -1};
    for (int i=0; i<N; ++i) {
        t[d[i]] += 3;
        cout << (i == 0 ? "" : " ") << t[d[i]];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
 
#define ipow(a,b)+0.5 (int)pow(a,b)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fi first
#define se second
 
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,a,b) for(int i=a;i<=b;i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
class Task
{
public:
    void solve(istream& in,ostream& out)
    {
        ll n,m;
        in>>n>>m;
 
        if(n>=m/2)
        {
            out<<m/2<<endl;
        }
        else
        {
            ll res=0;
            res+=n;
            m-=2*n;
 
            res+=m/4;
 
            out<<res<<endl;
        }
    }
};
 
 
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Task solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in,out);
	out.flush();
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

int main(){
    std::ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int i, j;
    f(i,0,3) {
	char c = i + 'a';
	f(j,0,3) {
	    if(s[j] == c) break;
	}
	if(j == 3) {cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
    return 0;
 
}

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

int n;

int main(){
	cin >> n;
	int k=100000;
	for(int i=0;i<n;i++){
		k*=1.05;
		if(k%1000 != 0){
			k-=k%1000;
			k+=1000;
		}
	}
	cout << (int)k <<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;
const int INF = 1e6;

int main()
{
  int e;
  vector<int> ans;
  while (cin >> e, e)
  {
    int nx, ny, nz;
    int m = INF;
    for (int z = 0; z <= 100; ++z)
    {
      for (int y = 0; y <= 1000; ++y)
      {
        int x = e - y * y - z * z * z;
        if (x >= 0)
          m = min(m, x + y + z);
      }
    }
    ans.push_back(m);
  }
  for (auto &v : ans)
    cout << v << endl;

  return 0;
}



Measured memory_bytes: 3108