akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string S,T;
void input(){
  cin>>S>>T;
}

void solve(){
  T.pop_back();
  if (S==T) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
int main(){
  input();
  solve();
  return 0;
}
  


Measured memory_bytes: 3592
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val M = IntArray(N) { 0 }
    var min = Int.MAX_VALUE
    for (i in 0 until N) {
        if (min > A[i]) min = A[i]
        M[i] = min
    }
    var ans = 0
    for (i in 0 until N) {
        if (A[i] == M[i]) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

Measured memory_bytes: 82932
//### In The Name Of GOD ###

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000000007;
const int INF = 30 * 1000 + 20;
const int MAXN = 2600;
const int MLOG = 18;
const int NMAX = 60;

#define int ll
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define ct(x) const_cast<const int&>(x)

int find_h(int a , int log){
	int ans = 0 ;
	while(a > 0){
		ans += a % log;
		a /= log;
	}
		return ans;	
}

signed main(){
	int n, ans = INF;
	cin >> n;	
	for (int i = 0; i <= n ; i++){
		int all = 0;
		all += find_h(i, 9);
		all += find_h(n-i,6);
		ans = min(ans, all);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


str gen(int len, int num, int pw, str cur = "") {
	if (len == 0)
		return cur;
	else {
		cur += 'a' + num / pw;
		num %= pw;
		pw /= 26;
		return gen(len - 1, num, pw, cur);
	}
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	
   	int n;
   	cin >> n;	
   	--n;
   	int pw = 26;
   	int len = 1;
   	while (pw <= n) {
   		n -= pw;
   		pw *= 26;
   		++len;
   	}
   	cout << gen(len, n, pw / 26) << '\n';
}

Measured memory_bytes: 3660
N, A, B, C, D = map(int, input().split())
s = input()
a, b, c, d = A - 1, B - 1, C - 1, D - 1
if c < d:
    pattern = 1
elif c > d:
    pattern = 2
if pattern == 1:
    ans = 'Yes'
    for i in range(a, c):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
    for i in range(b, d):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
if pattern == 2:
    for i in range(b, d + 1):
        if 1 <= i + 1 <= len(s):
            tmp = s[i - 1:i + 2]
            if tmp == '...':
                ans = 'Yes'
                break
    else:
        ans = 'No'
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi cnt(3);
	REP(i, n)
	{
		int a; cin >> a;
		if (a % 4 == 0) cnt[0]++;
		else if (a % 2 == 0) cnt[1]++;
		else cnt[2]++;
	}
	bool f = true;
	int pre = 0;
	REP(i, n)
	{
		int use = -1;
		if (pre == 0)
		{
			if (cnt[2] > 0) use = 2;
			else if (cnt[1] > 0) use = 1;
			else use = 0;
		}
		else if (pre == 1)
		{
			if (cnt[1] > 0) use = 1;
			else if (cnt[0] > 0) use = 0;
			else use = -1;
		}
		else
		{
			if (cnt[0] > 0) use = 0;
			else use = -1;
		}
		if (use == -1)
		{
			f = false;
			break;
		}
		else
		{
			cnt[use]--;
			pre = use;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main()
{
    int a,x=1,b,i=0;
    scanf("%d",&a);
    int A[a];
    while(i<a){
        scanf("%d",&A[i]);
        i++;
    }
    b=A[0];
    i=1;
    while(i<a){

        if(A[i]<b)
        {
            b=A[i];
            x++;
        }
        i++;
    }
    printf("%d\n",x);
    return 0;
}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//実行部
void Main()
{
  ll n, a, b; cin >> n >> a >> b;
  ll i = 0;
  while(1)
  {
    if(i % 2 == 0)
    {
      if(a + 1 != b)
      {
        a++;
      }
      else
      {
        a--;
      }
      if(a == 0) fin("Borys");
    }
    else
    {
      if(a != b - 1)
      {
        b--;
      }
      else
      {
        b++;
      }
      if(b == n + 1) fin("Alice");
    }
    i++;
  }
  fin("Draw");
}
//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

price = math.ceil(a / 0.08)
#print(price)
price_ = math.floor(b / 0.1)
#print(price_)
if price < price_:
    start, end = price, price_
else:
    start, end = price_, price
for i in range(start, end+1):
    #print(math.floor(i * 0.08),math.floor(i * 0.1))
    #print(i)
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        print(i)
        exit()
if price == price_:
    print(price)
    exit()
print(-1)


Measured memory_bytes: 3064
//file_name:ABC42_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,k;
    scanf("%d%d",&n,&k);

    int a[10] = {};
    rep(i,k){
        int b;
        cin >> b;
        a[b]++;
    }


    ll ans = 0;

    srep(i,n,100000){
        int ii = i;
        int flag = 0;
        while(ii>0){
            if(a[ii%10]==1){
                flag = 1;
                break;
            }
            ii /= 10;
        }
        if(flag==0){
            ans = i;
            break;
        }
    }

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



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

int main()
{
	int n,b,f,r,v,i,j,k,l;
	int show[4][3][10]={};
	
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>b>>f>>r>>v;
		show[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++){
				cout<<" "<<show[i][j][k];
				}
			cout<<endl;
			}
		if(i!=3){
		for(l=0;l<20;l++)
			cout<<"#";
			cout<<endl;
			}
		}
	return 0;
}	

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
		int[] p = new int[n];
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<n; i++) p[i] = int.Parse(input[i]);
		Array.Sort(p);
		int sum = 0;
		for(int i=0; i<k; i++) sum += p[i];
		Console.WriteLine(sum);
	}
}



Measured memory_bytes: 27900
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<string>
#include<vector>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int MAXN=1e2+10;

int a[MAXN];
int b[MAXN];

int main()
{
	int n,i,j;
	int cnt;
	
	scanf("%d",&n);
	int maxn=-1e7;
	int m;
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(abs(a[i])>maxn)
		{
			maxn=abs(a[i]);
			m=i;
		}
	}
	if(a[m]==0)
	{
		printf("0\n");
		return 0;
	}
	
	cnt=0;
	
	if(a[m]<0)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]>0)
			{
				b[cnt++]=i;
			}
		}
		printf("%d\n",cnt+n-1);
		for(i=0;i<cnt;i++)printf("%d %d\n",m+1,b[i]+1);
		for(i=n-1;i>=1;i--)printf("%d %d\n",i+1,i);
	}
	else if(a[m]>0)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]<0)
			{
				b[cnt++]=i;
			}
		}
		printf("%d\n",cnt+n-1);
		for(i=0;i<cnt;i++)printf("%d %d\n",m+1,b[i]+1);
		for(i=1;i<n;i++)printf("%d %d\n",i,i+1);
	}
	
	
} 

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    char a[3];
    for(int i=0;i<3;i++){
        cin >>a[i];
    }
    for(int i=0;i<3;i++){
        if('1'==a[i]){
            cout << 9 ;
        }else{
            cout <<1 ;
        }
    }
    cout <<endl;
}


Measured memory_bytes: 256
import java.util.*;

 // Compiler version JDK 11.0.2

  public class Main
 {
   public static void main(String args[])
   { 
     Scanner sc= new Scanner(System.in);
     int n =sc.nextInt();
     int a[]=new int[n+1];
     int k =sc.nextInt();
     while(k>0)
     {
       int d = sc.nextInt();
       for(int i=0;i<d;i++)
       {
         int b= sc.nextInt();
         a[b]++;
         
       }
       k--;
     }
     int t=0;
     for(int i =1;i<=n;i++)
     {
       if(a[i]==0)
       t++;
     }
     System.out.println(t);
   }
 }
    

Measured memory_bytes: 46436
# Problem B - K個のケーキ

# input
K, T = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
a_nums = sorted(a_nums, reverse=True)
a_max = a_nums.pop(0)
a_sum = sum(a_nums)

# calc
check = a_max - a_sum - 1
if check>=0:
    print(check)
else:
    print(0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define N 21
using namespace std;
typedef pair<int,int> P;
int w,h,G[N][N];
string mp[N];
map<P,int>M;

void bfs(P s){
  int D[N][N];
  memset(D,-1,sizeof(D));
  queue<P> Q;
  Q.push(s);
  int x=s.first,y=s.second;
  D[y][x]=0;
  while(!Q.empty()){
    P t=Q.front();Q.pop();
    x=t.first,y=t.second;
    if(mp[y][x]=='*'||mp[y][x]=='o') G[M[s]][M[t]]=D[y][x];

    int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i],cost=D[y][x]+1;
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]=='x'||D[ny][nx]!=-1)continue;
      Q.push(P(nx,ny));
      D[ny][nx]=cost;
    }
  }
}

int n,num[11];
P start;
int calc(){
  if(M[start]!=num[0])return 1e9;
  int res=0;
  for(int i=1;i<n;i++)res+=G[num[i-1]][num[i]];
  return res;  
}

int dfs(int idx){
  if(idx==n) return calc();
  int res=1e9;
  for(int i=0;i<n;i++){
    if(num[i]!=-1)continue;
    num[i]=idx;
    res=min(res,dfs(idx+1));
    num[i]=-1;
  }
  return res;
}


int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++) cin>>mp[i];
    M.clear();
    memset(G,-1,sizeof(G));
    memset(num,-1,sizeof(num));
    n=0;
    vector<P> p;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	P t=P(j,i);
	if(mp[i][j]=='*'||mp[i][j]=='o') p.push_back(t),M[t]=n++;
	if(mp[i][j]=='o') start=t;
      }
    for(int i=0;i<n;i++)bfs(p[i]);

    bool flg=1;
    for(int i=0;i<n;i++)if(G[0][i]==-1)flg=0;
    cout <<(flg?dfs(0):-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 300020
#define M 63
#define MOD 1000000007
using namespace std;

int a[M];

int main(void)
{
    int n;
    long long x;
    int i, j, o;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
    {
        scanf("%lld", &x);
        for(j = 0; j < M; j ++)
            if(x & (1LL << j))
                a[j] ++;
    }

    for(i = o = 0; i < M; i ++)
        o = (o + (long long)(1LL << i) % MOD * a[i] % MOD * (n - a[i]) % MOD) % MOD;
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 256
N,W=list(map(int,input().split()))
v=[[],[],[],[]]
kosu=[0,0,0,0]
kr=list(map(int,input().split()))
v[0].append(kr[1])
w0=kr[0]
for i in range(1,N):
    kr=list(map(int,input().split()))
    v[kr[0]-w0].append(kr[1])
for i in range(4):
    v[i].sort()
    v[i].reverse()
kos=[len(v[0]),len(v[1]),len(v[2]),len(v[3])]
kk=[-1]*((kos[0]+1)*(kos[1]+1)*(kos[2]+1)*(kos[3]+1))
def toru(a,b,c,d,nw):
    global kk
    if kk[a+(kos[0]+1)*(b+((kos[1]+1)*(c+(kos[2]+1)*d)))]!=-1:
        return kk[a+(kos[0]+1)*(b+((kos[1]+1)*(c+(kos[2]+1)*d)))]
    max=0
    if a<kos[0] and W>=nw+w0 and max<toru(a+1,b,c,d,nw+w0)+v[0][a]:
        max=toru(a+1,b,c,d,nw+w0)+v[0][a]
    if b<kos[1] and W>=nw+w0+1 and max<toru(a,b+1,c,d,nw+w0+1)+v[1][b]:
        max=toru(a,b+1,c,d,nw+w0+1)+v[1][b]
    if c<kos[2] and W>=nw+w0+2 and max<toru(a,b,c+1,d,nw+w0+2)+v[2][c]:
        max=toru(a,b,c+1,d,nw+w0+2)+v[2][c]
    if d<kos[3] and W>=nw+w0+3 and max<toru(a,b,c,d+1,nw+w0+3)+v[3][d]:
        max=toru(a,b,c,d+1,nw+w0+3)+v[3][d]
    kk[a+(kos[0]+1)*(b+((kos[1]+1)*(c+(kos[2]+1)*d)))]=max
    return max
 
 
maxv=toru(0,0,0,0,0)
 
print(maxv)

Measured memory_bytes: 11652
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a;
    string s;

    cin >> a >> s;

    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
  
   ll a,v,b,w,t;
   cin>>a>>v>>b>>w>>t;
   ll dis = abs(a-b);
   if(w>v)
        cout<<"NO\n";
   else
   {
       ll fst = t*(v-w);
       ll sec = dis;
       if(fst>=sec)
            cout<<"YES\n";
       else cout<<"NO\n";        
   }
   
   
   return 0;        
}  
  
   

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



int main() {
    long long w, h,s,d;
    long long n;
    cin >> w >> h >> s >> d;
    cin >> n;
    s = min(min(w*4, h*2), s);
    d = min(s*2, d);
    cout << (n/2*d) + (n%2*s) << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))

L,R=[0]*n,[0]*n
L[0]=A[0]
for i in range(1,n):
  L[i]=gcd(L[i-1],A[i])
R[n-1]=A[n-1]
for i in range(n-2,-1,-1):
  R[i]=gcd(A[i],R[i+1])
  
L=[A[n-1]]+L
R=R+[A[0]]

ans=0
for i in range(n):
  ans=max(ans,gcd(L[i],R[i+1]))
print(ans)

Measured memory_bytes: 16124
#include <iostream>
#include<string>
#include<cstdio>
#include<string.h>
#include<vector>
#include<cmath>
using namespace std;
const int N=110;

bool pd(long long a,long long b,long long d){
    if(sqrt(a*a+b*b)<=d){
        return 1;
    }
    else return 0;
}

int main ()
{
    int n,d;
    cin>>n>>d;
    int ret=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(pd(a,b,d)){
            ret++;
        }
    }
    cout<<ret<<endl;
    return 0;
}

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

int n;
ll k;
pair<ll,ll> a[100100];
ll presum[40];

int getw(ll k){
	int s=0;
	while (k){
		k/=2;
		s++;
	}
	return s;
}

void update(int w){
	for (int i=1;i<=n;i++){
		presum[getw(a[i].first)]+=a[i].second;
		//cout<<a[i].first<<" "<<a[i].second<<endl;
	}
	for (int i=1;i<=w;i++) presum[i]+=presum[i-1];
}

int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i].first>>a[i].second;
	ll p=30;
	ll ans=0;
	while (k){
		int wk=getw(k);
		for (int i=n;a[i].first>=(ll)(1<<p) && i>0;i--){
			a[i].first-=1<<p;
		}
		sort(a+1,a+n+1);
		while (a[n].first>k) n--;
		memset(presum,0,sizeof presum);
		update(wk);
		if (presum[wk-1]>ans) ans=presum[wk-1];
		k-=1<<(wk-1);
		//cout<<k<<endl;
		p=wk-1;
	}
	int wk=getw(k);
	for (int i=n;a[i].first>=1<<p && i>0;i--) a[i].first-=1<<p;
	sort(a+1,a+n+1);
	while (a[n].first>k) n--;
	p=0;
	for (int i=1;i<=n;i++) p+=a[i].second;
	cout<<max(ans,p)<<endl;
	return 0;
} 

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {

   double w,h,x,y;
   cin >> w >> h >> x >> y;

   printf("%.9f %d\n", w * h / 2.0, w * h / (x * y) == 4.0);
	
}



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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int t = 0;
	if (a == b && b == c) {
		t = 1;
	} else if (a != b && b != c && a != c) {
		t = 3;
	} else {
		t = 2;
	}
	cout << t << endl;
}


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

int main() {
  int N, K; 
  double ans=0;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  ans = ceil(double(N-K)/double(K-1));
  cout << 1+ans << endl;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

typedef vector<vector<ll> > arr;

#define arr_size 60

const ll p = 1000000007;

arr array_power[arr_size];

int main(){
  ll n,k;
  cin >> n >> k;
  REP(l,arr_size){
    array_power[l].resize(n);
    REP(m,n) array_power[l][m].resize(n);
  }
  REP(i,n) REP(j,n) cin >> array_power[0][i][j];
  REP(l,arr_size-1){
    REP(i,n) REP(j,n){
      ll sum = 0;
      REP(m,n){
        sum += array_power[l][i][m]*array_power[l][m][j];
        sum %= p;
      }
      array_power[l+1][i][j] = sum;
    }
  }
  arr ans, ans2;
  ans.resize(n);
  REP(m,n) ans[m].resize(n);
  ans2.resize(n);
  REP(m,n) ans2[m].resize(n);
  REP(i,n) ans[i][i] = 1;
  REP(l,arr_size){
    if(!(k>>l&1)) continue;
    REP(i,n)REP(j,n){
      ll sum = 0;
      REP(m,n){
        sum += ans[i][m]*array_power[l][m][j];
        sum %= p;
      }
      ans2[i][j] = sum;
    }
    REP(i,n) REP(j,n) ans[i][j] = ans2[i][j];
  }
  ll ret = 0;
  REP(i,n) REP(j,n) ret += ans[i][j], ret %= p;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1536
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    int SIZE = 5 * 100_000;
    long MOD = 1_000_000_007;
    long inv[] = new long[5 * 100_000 + 1];
    long fac[] = new long[5 * 100_000 + 1];

    void solve(Scanner sc, PrintWriter pw) {
        fac[0] = 1;
        fac[1] = 1;
        inv[0] = 1;
        inv[1] = 1;
        for (int i = 2; i <= SIZE; i++) {
            fac[i] = (fac[i - 1] * i) % MOD;
            inv[i] = power(fac[i], MOD - 2);
        }
        int N = sc.nextInt();
        int M = sc.nextInt();
        long result = 0;
        for (int common = 0; common <= N; common++) {
            long positive = (common % 2) == 0 ? 1L : -1L;
            long abineFirst = abine(M , common);
            long abineSecond = abine(M - common, N - common);
            long secondPart = (abineFirst * ((abineSecond * abineSecond) % MOD)) % MOD;
            long combine = combine(N, common);
            long part = (positive * ((combine * secondPart) % MOD)) % MOD;
            result = (((result + part) % MOD) + MOD) % MOD;
            //System.out.println(String.format("a(m, i) %d, a(m- i, n - i) %d, combine %d, part %d, result %d", abineFirst, abineSecond, combine, part, result));
        }
        pw.println(result);
    }

    private long power(long l, long k) {
        if (k == 0) {
            return 1;
        }
        long half = power(l, k / 2);
        long part = (half * half) % MOD;
        if ((k % 2) == 1) {
            return (part * l) % MOD;
        } else {
            return part;
        }
    }

    long combine(int n, int k) {
        if (k == 0) {
            return 1L;
        }
        return (fac[n] * ((inv[k] * inv[n - k]) % MOD)) % MOD;
    }

    long abine(int n, int k) {
        if (k == 0) {
            return 1L;
        }
//        if (k == n) {
//            return fac[n];
//        }
        return (fac[n] * ((inv[n - k]))) % MOD;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n,m,w;
    cin>>n>>m>>w;
    char a[n][m];

    int cnt=0;
    loop(i,0,n)
    {
        loop(j,0,m)
        {
            cin>>a[i][j];
            if(a[i][j]=='#')
            {
                cnt++;
            }
        }
    }
    //cout<<cnt;
    int ans=0;
    cnt=cnt-w;
    //cout<<cnt;
    for(int i=0;i<(1LL<<n);i++)
    {
        set <int> v;
        loop(j,0,n)
        {
            if(i&(1LL<<j))
            {
                v.ins(j);
                //cout<<j<< " ";
            }
        }
        //cout<< "\n";
        loop(k,0,(1LL<<m))
        {
            set <int> v1;
            loop(t,0,m)
            {
                if(k&(1LL<<t))
                {
                      v1.ins(t);
                }
            }
            map <pair <int,int>,int> done;
        int s=0;
        loop(x,0,n)
        {
            loop(y,0,m)
            {
                if(!done[{x,y}] and a[x][y]=='#' and (v.find(x)!=v.end() or v1.find(y)!=v1.end()))
                {
                    s++;
                    done[{x,y}]++;
                }
            }
        }
        //cout<<s<< "\n";
        if(s==cnt)
        {
            ans++;
        }

        }
//        for(auto x:v)
//        {
//            cout<<x<< " ";
//        }
//        cout<< "\n";
//        for(auto x:v1)
//        {
//            cout<<x<<" ";
//        }
//        cout<< "\n";


    }
    cout<<ans;


    return 0;
}


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

#define mp make_pair
#define pb push_back

using namespace std;

int n;
int a[333][333];
long long an;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			for(int k = 1; k <= n; ++k){
				if (a[i][j] + a[j][k] < a[i][k]){
					printf("-1");
					return 0;
				}
			}
		}
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			bool ok = 1;
			for(int k = 1; k <= n; ++k) if (k != i && k != j){
				if (a[i][k] + a[k][j] == a[i][j]){
					ok = 0;
					break;
				}
			}
			if (ok) an += a[i][j];
		}
	}	
	printf("%lld",an / 2);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A,B,C=0,AB=0;
 cin >> A >> B;
 AB = A-1;
 if(B>1){
 B -= A;
 C ++;
 while(B > 0){
   B -= AB;
   C ++;
 }
}
 cout << C <<endl;
}

Measured memory_bytes: 256
/*
    Written by Kabir Kanha Arora
    @kabirkanha
 */

import java.util.*;

public class Main {
    public static void main(String[] args) {

        // Input
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long x = scanner.nextLong();
        long m = scanner.nextLong();

        HashMap<Long, Long> map = new HashMap<>();
        map.put(x, 0L);
        long curr = x;
        boolean zeroFlag = false;
        long loopStart = 0;
        long loopSize = 1;
        long loopStartElement = x;
        long sum = x;

        for (long i = 1; i < 1e7 && i < n; ++i) {
            curr = ((curr % m) * (curr % m)) % m;
            if (curr == 0) {
                zeroFlag = true;
                System.out.println(sum);
                break;
            }
            if (map.containsKey(curr)) {
                loopStart = map.get(curr);
                loopStartElement = curr;
                loopSize = i - loopStart;
                break;
            } else {
                sum += curr;
                map.put(curr, i);
                loopSize++;
            }
        }
        if (!zeroFlag) {

            // Elements before start of loop
            sum = 0;
            curr = x;
            long i;
            if (loopStart > 0)
                sum += x;
            for (i = 1; i < loopStart; ++i) {
                curr = ((curr % m) * (curr % m)) % m;
                sum += curr;
            }

            // Sum of loop elements
            long loopSum = loopStartElement;
            curr = loopStartElement;
            for (i = 1; i < loopSize; ++i) {
                curr = ((curr % m) * (curr % m)) % m;
                loopSum += curr;
            }
            long loops = (n - loopStart) / loopSize;
            sum += loops * loopSum;


            // Sum of remaining elements
            long rem = n - (loops * loopSize) - loopStart;
            if (rem > 0)
                sum += loopStartElement;
            curr = loopStartElement;
            for (i = 1; i < rem; ++i) {
                curr = ((curr % m) * (curr % m)) % m;
                sum += curr;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 42616
import java.util.*;
class Main{

 public static void main(String args[]){
   
  try{
  int[] array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  Scanner sc = new Scanner(System.in);
   
  int a = sc.nextInt();
   
  if(a >= 1 && a <= 32){
    System.out.println(array[a-1]);
  }  
  
  }catch(Exception e){
  }  
 }
}

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

int main(){
  int N;
  cin >> N;
  string S;
  string ms="MARCH";
  map<char,long long> marches{
    {'M',0},{'A',0},{'R',0},{'C',0},{'H',0}
  };
  for (int i=0;i<N;i++){
    cin >> S;
    auto it = marches.find(S[0]);
    if(it!=marches.end()) ++marches[S[0]];
  }
  long long ans=0;
  for(auto i=ms.begin();i!=ms.end();i++){
    for(auto j=i+1;j!=ms.end();j++){
      for(auto k=j+1;k!=ms.end();k++){
//        cout << *i << *j << *k << " " << marches[*i]*marches[*j]*marches[*k] << endl;
        ans+=marches[*i]*marches[*j]*marches[*k];
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  
  int r = 0;
  int b = 0;
  
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') r++;
    else b++;
  }
  if (r <= b) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
long long mod = 1e9 + 7;
const int N = 5e5 + 500;

long long n, m, u, v, k, t, q, a, h;

string str;

int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   
   cin >> n >> k;
   k--;
   cin >> str;
   
   if (str[k] == 'A') str[k] = 'a';
   if (str[k] == 'B') str[k] = 'b';
   if (str[k] == 'C') str[k] = 'c';
   
   cout << str << endl;
   
}






Measured memory_bytes: 256
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector <ll> h(n);
    rep(i, n){
        cin>>h[i];
    }
    reverse(h.begin(), h.end());
    int num=0;
    int mx=0;
    rep(i, n-1){
        if(h[i+1]>=h[i]){
            num++;
        }
        else {
            mx=max(mx, num);
            num=0;
        }
    }
    mx=max(mx, num);
    cout<<mx<<endl;
}

Measured memory_bytes: 1024
x = int(input())

if 400 <= x and x <= 599:
  ans = 8
elif 600 <= x and x <= 799:
  ans = 7
elif 800 <= x and x <= 999:
  ans = 6
elif 1000 <= x and x <= 1199:
  ans = 5
elif 1200 <= x and x <= 1399:
  ans = 4
elif 1400 <= x and x <= 1599:
  ans = 3
elif 1600 <= x and x <= 1799:
  ans = 2
else:
  ans = 1
  
print(ans)

Measured memory_bytes: 9056
#include<iostream>
using namespace std;
int d;
bool e[1000005];
int main(void)
{
    int n;
    cin >> n;
    d=n;
    e[n]=true;
    int i;
    for(i=2;;i++)
    {
        d=(d%2 ? d*3+1 : d/2);
        if(e[d])
            break;
        e[d] = true;
    }
    cout << i;
    return 0;
}


Measured memory_bytes: 256
while (1):

    input_list = input().split(' ')
    h = int(input_list[0])
    w = int(input_list[1])

    if h == 0 and w == 0:
        break

    print('#' * w)
    for i in range(h - 2):
        print('#' + ('.' * (w - 2)) + '#')
    print('#' * w)
    print('')


Measured memory_bytes: 5616
M, N = map(int, input().split())

X = list(map(int, input().split()))
X.sort()

Y = []

for i in range(N - 1):
    Y.append((i, X[i + 1] - X[i]))
Y.sort(key=lambda y: y[1], reverse=True)
Y = Y[:M - 1]
Y.sort(key=lambda y: y[0])

p = 0
c = 0
for i, y in Y:
    c += X[i] - X[p]
    p = i + 1
c += X[-1] - X[p]

print(c)


Measured memory_bytes: 62760
#include <cstdio>
#include <algorithm>
using namespace std;
const int Maxn=50;
const int Mod=1000000007;
int f[Maxn+5][Maxn<<1|5][Maxn<<1|5];
int n;
int a[Maxn<<1|5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<(n<<1);i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+(n<<1));
	f[n][0][0]=1;
	for(int i=n;i>1;i--){
		int le=(a[i]!=a[i-1]),re=(a[(n<<1)-i]!=a[(n<<1)-i+1]);
		for(int j=0;j<=(n-i)<<1;j++){
			for(int k=0;k<=(n-i)<<1;k++){
				f[i-1][j+le][k+re]=(f[i-1][j+le][k+re]+f[i][j][k])%Mod;
				for(int l=0;l<j+le;l++){
					f[i-1][l][k+1+re]=(f[i-1][l][k+1+re]+f[i][j][k])%Mod;
				}
				for(int l=0;l<k+re;l++){
					f[i-1][j+1+le][l]=(f[i-1][j+1+le][l]+f[i][j][k])%Mod;
				}
			}
		}
	}
	int ans=0;
	for(int j=0;j<(n<<1);j++){
		for(int k=0;k<(n<<1);k++){
			ans=(ans+f[1][j][k])%Mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n;
string s;

void solve()
{
	cin>>s;
	if (s.length()==1){
		cout<<"Good";return;
	}
	rep(i,0,s.length()-1)
	{
		if (s[i+1]==s[i])
		{
			cout<<"Bad";return;
		}
	}
	cout<<"Good";

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 256
from math import fabs

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

def func(a,b,c):
    cost = 0
    cost += fabs(A_num[b]-A_num[a])
    cost += fabs(A_num[c]-A_num[b])

    return cost

print(int(min(func(0,1,2),func(0,2,1),func(1,0,2),func(1,2,0),func(2,0,1),func(2,1,0))))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
typedef long long ll;
using namespace std;

//
ll f(ll a) {
    ll b = 0;
    if ((a + 1) / 2 % 2 == 1) b = 1;
    if (a % 2 == 0) {
        return a ^ b;
    }
    else {
        return b;
    }
}

int main(){
    ll A,B;
    cin >> A >> B;
    // printf("f(%d) = %d\n",(int)A-1,(int)f(A-1));
    // printf("f(%d) = %d\n",(int)B,(int)f(B));
    if (A == B) {
        cout << A << endl;
    }
    else {
        cout << (f(A-1)^f(B)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("5 2\n5 3 1 4 2\n1 3\n5 4\n"), "2\n");
    assert_eq!(solve("3 2\n3 2 1\n1 2\n2 3\n"), "3\n");
    assert_eq!(
        solve("10 8\n5 3 6 8 7 10 9 1 2 4\n3 1\n4 1\n5 9\n2 5\n6 5\n3 5\n8 9\n7 9\n"),
        "8\n"
    );
    assert_eq!(solve("5 1\n1 2 3 4 5\n1 5\n"), "5\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let m: usize = sc.read();
    let p: Vec<usize> = (0..n).map(|_| sc.read()).collect();
    let xy: Vec<(usize, usize)> = (0..m).map(|_| (sc.read(), sc.read())).collect();
    
    let mut djs = DisjointSet::new(n);
    for &(x,y) in &xy {
        djs.unite(x-1, y-1);
    }
    let ans = (0..n).filter(|&i| {
        djs.find(i) == djs.find(p[i] - 1)
    }).count();
    
    format!("{}\n", ans)
}
struct DisjointSet {
    prt: Vec<usize>,
    rnk: Vec<usize>,
}
impl DisjointSet {
    fn new(n: usize) -> DisjointSet {
        DisjointSet {
            prt: (0..n).collect(),
            rnk: vec![0; n],
        }
    }
    fn unite(&mut self, x: usize, y: usize) {
        let x = self.find(x);
        let y = self.find(y);
        if x == y {
            return;
        }
        use std::cmp::Ordering;
        match self.rnk[x].cmp(&self.rnk[y]) {
            Ordering::Less => self.prt[x] = y,
            Ordering::Greater => self.prt[y] = x,
            Ordering::Equal => {
                self.prt[y] = x;
                self.rnk[x] += 1;
            }
        };
    }
    fn find(&mut self, x: usize) -> usize {
        if self.prt[x] == x {
            x
        } else {
            let xrt = self.prt[x];
            self.prt[x] = self.find(xrt);
            self.prt[x]
        }
    }
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 10492
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
constexpr ll MODN = 1000000007;
ll n, dp, dp_1, dp_2, dp_3;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	dp_1 = 1, dp = 1 + n;
	for (int i = 2; i <= n; ++i) {
		dp_3 = dp_2, dp_2 = dp_1, dp_1 = dp;
		dp = n * n - n + 2 + dp_3;
		dp += min(-2, -i) + 2 * dp_1 - dp_2;
		dp %= MODN;
	}
	cout << (dp - dp_1 + MODN) % MODN << endl;
	return 0;
}

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

int main()
{
	for(int i = 1; i < 10; ++i)
	{
		for(int j = 1; j < 10; ++j)
		{
			cout << i << 'x' << j << '=' << i*j << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll allg[1000000];

ll gcd(ll a, ll b){
    while(b != 0){
        ll tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}

void allg_setter(vector<ll> &array,int n){
    allg[0] = array.at(0);
    //cout << allg[0] << " ";
    for(int i=1;i<n;i++){
        allg[i] = gcd(allg[i-1],array.at(i));
        //cout << allg[i] << " ";
    }
    //cout << endl;
}

ll maxg(vector<ll> &array,int n){
    if(n == 2){
        return max(gcd(array.at(0),array.at(1)),max(gcd(array.at(1),array.at(2)),gcd(array.at(0),array.at(2))));
    }
    ll g1 = gcd(maxg(array,n-1),array.at(n));
    //cout << g1 << " " << allg[n-1] << endl;
    return max(g1,allg[n-1]);
}


int main(){
    int n;
    cin >> n;
    vector<ll> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);
    
    allg_setter(array,n);
    if(n == 2){
        cout <<  max(array.at(0),array.at(1)) << endl;
    }else{
        cout << maxg(array,n-1) << endl;
    }
    
    /*for(int i=0;i<n;i++){
        cout << allg[i] << " ";
    }*/
}

Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vl x(n);
    REP(i, n) cin >> x[i];
    SORT(x);
    ll ans = LINF;
    REP(i, n - k + 1) {
        if (x[i] < 0) {
            if (x[i + k - 1] <= 0) chmin(ans, -x[i]);
            else chmin(ans, -x[i] + x[i + k - 1] + min(-x[i], x[i + k - 1]));
        } else {
            chmin(ans, x[i + k - 1]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3980
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100000

vector<int> factor(int n){
    vector<int> ret,ret2;
    
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            
            if(i*i<n)
                ret2.push_back(n/i);
        }
    }
    
    for(int i=0;i<ret2.size();i++){
        ret.push_back(ret2[ret2.size()-1-i]);
    }
    
    return ret;
}

int main(){
    int n;
    
    scanf("%d",&n);
    
    for(int i=1;;i++){
        vector<int> vec = factor(i);
        
        if((int)vec.size()==n){
            printf("%d\n",i);
            break;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 1208