akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    for(auto&& i : a){
        cin >> i;
    }    
    sort(begin(a), end(a));
    for(int i = 1; i < n; i++){
        a[i] = (a[i] + a[i - 1]) / 2;
    }
    cout << setprecision(13) << a[n - 1] << "\n";
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

import           Control.Monad
import           Data.List

-- shiritori.hs --- Shiritori

-- author: Seong Yong-ju <sei40kr@gmail.com>

main :: IO ()
main = do
  n <- readLn
  words <- replicateM n getLine
  putStrLn $
    if (length $ nub words) == length words &&
       all (\(w1, w2) -> last w1 == w2 !! 0) (zip (init words) (tail words))
      then "Yes"
      else "No"


Measured memory_bytes: 636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		Arrays.sort(arr);
		if (arr[0] == arr[1] && arr[2] == arr[3] && arr[1] != arr[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>

int main(){
    int h, w;
    std::cin >> h >> w;

    std::string horizontalRef(w, '.');
    std::string buf;
    std::vector<std::string> matrix;
    for(int i = 0; i < h; ++i){
        std::cin >> buf;
        if(horizontalRef != buf){
            matrix.push_back(buf);
        }
    }

    int count;
    for(int i = matrix.at(0).size() - 1; i >= 0; --i){
        count = 0;
        for(int j = 0; j < matrix.size(); ++j){
            if('.' == matrix.at(j).at(i)){
                ++count;
            }
        }
        
        if(count == matrix.size()){
            for(int j = 0; j < matrix.size(); ++j){
                matrix.at(j).erase(matrix.at(j).begin() + i);
            }
        }
    }

    for(int i = 0; i < matrix.size(); ++i){
        for(int j = 0; j < matrix.at(i).size(); ++j){
            std::cout << matrix.at(i).at(j);
        }
        std::cout << std::endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    unsigned H, W, K, sum = 0, ans = 0;
    cin >> H >> W >> K;
    V<string> grid(H);
    V<int> tate(H, 0), yoko(W, 0);
    VV<int> cross(H, V<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        cin >> grid[i];
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] == '#') {
                tate[i]++;
                cross[i][j]++;
                sum++;
            }
        }
    }
    for (int i = 0; i < W; ++i) {
        for (int j = 0; j < H; ++j) {
            if (grid[j][i] == '#')yoko[i]++;
        }
    }

    for (unsigned mask1 = 0; mask1 < (1u << H); ++mask1)
        for (unsigned mask2 = 0; mask2 < (1u << W); ++mask2) {
            int cnt = 0;
            for (unsigned i = 0; i < H; i++) {
                if ((mask1 >> i) % 2)cnt += tate[i];
            }
            for (unsigned i = 0; i < W; i++) {
                if ((mask2 >> i) % 2)cnt += yoko[i];
            }
            for (unsigned i = 0; i < H; i++) {
                for (unsigned j = 0; j < W; j++) {
                    if ((mask1 >> i) % 2 && (mask2 >> j) % 2)cnt -= cross[i][j];
                }
            }
            if (sum - cnt == K) ans++;
        }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int n;
struct node
{
	int v;
	int id;
}a[maxn];
bool cmp(node va,node vb)
{
	return va.v<vb.v;
}
int cnt=0;
std::vector<int> v[maxn];
int bj[maxn];
void dfs(int i)
{
	bj[i]=1;
	if(bj[a[i].id]==1)
	{
		v[cnt].pb(a[i].id);
		cnt++;
		return ;
	}
	else
	{
		v[cnt].pb(a[i].id);
		dfs(a[i].id);
	}
}
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	ll n,m;
	ll x,y;
	cin>>n>>m>>x>>y;
	ll ans=(n-x)*(m-y);
	cout<<ans<<endl;
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

vvi Graph(100100);
vi dist(100100);
int T;

void dfs(int v,int pv,int depth = 0){
  dist.at(v) = depth;
  
  for(int nv : Graph.at(v)){
    if(nv == pv) continue;
    dfs(nv,v,depth+1);
  }
}

void dfs1(int v,int &d){
  d = max(d,dist.at(v));
  //cout << v << endl;
  for(int nv : Graph.at(v)){
    if(dist.at(nv) < dist.at(v)) continue;
    dfs1(nv,d);
  }
}

int main(){
  int n,A;
  cin >> n >> T >> A;
  T--;A--;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    Graph.at(a).push_back(b);
    Graph.at(b).push_back(a);
  }
  dist.at(0) = 0;
  dfs(A,-1);
  int diff = dist.at(T);
  int step = (diff-1)/2;
  
  int pos = T;
  rep(i,step){
    for(int nv : Graph.at(pos)){
      if(dist.at(nv) < dist.at(pos) ){
        pos = nv;
        break;
      }
    }
  }
  
  int maxd = dist.at(pos);
  dfs1(pos,maxd);
  int ans = step + maxd - dist.at(pos) + (diff % 2 == 0);
  //cout << diff << endl;
  //cout << step << endl;
  //cout << pos << endl;
  //cout << maxd << endl;
  cout << ans << endl;
}


Measured memory_bytes: 9984
local n, k = io.read("*n", "*n")
local t, r = {}, {}
for i = 1, n do
  t[i] = io.read("*n")
  r[i] = 0
end
local abs, min = math.abs, math.min
r[2] = abs(t[2] - t[1])
for i = 2, n do
  r[i] = r[i - 1] + abs(t[i] - t[i - 1])
  for j = 2, k do
    if i <= j then break end
    r[i] = min(r[i], r[i - j] + abs(t[i] - t[i - j]))
  end
end
print(r[n])


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





int main(){
   string s;
   cin>>s;
   ll cnt=0;
   bool b=true;
   bool bo=true;
   ll c;
   s+=s;
   ll co=1;
   rep(i,s.size()-1){
      if(i==s.size()/2) c=cnt;
      if(s[i]==s[i+1]){
         
         if(i+1==s.size()-1)b=false;
         i++;
         if(i==s.size()/2) c=cnt;
         cnt++;
         if(i>1)if(!(s[i-2]==s[i]))bo=false;else co+=2;
         else co++;
         
      }else if(i>0)if(!(s[i-1]==s[i]))bo=false;
      else co++;
   }
   ll k;
   cin>>k;
   cnt*=(int)k/2;
   if(k%2==1)cnt+=c;
   //if(bo&&s.size()%2==1)if(k%2==1)cnt+=(k-(int)k/2-1);else cnt+=(k-(int)k/2);
   //else 
   if(b&&!bo)if(s[0]==s[s.size()-1]){
      int as=1;
      int az=1;
      repr(i,s.size())if(s[i]==s[i-1]){
         as++;
         if(as==2)as=0;
         
      }else break;
      rep(i,s.size())if(s[i]==s[i+1]){
         az++;
         if(az==2)az=0;
         
      }else break;
      cnt+=(int)((as+az)/2)*((k/2)-1+k%2);
   }
   
   cout<<cnt<<endl;
   return 0;
}



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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  vector<ll> b(n);
  
  rep(i,n){
    if(i!=0)b[i]=a[i]+b[i-1];
    else b[i]=a[i];
  }
  
  ll total=b[n-1];
  ll half=(total+1)/2;
  ll ans=LINF;
  
  rep(i,n){
    ll c=total-b[i];
    if(b[i]<=c){
      chmin(ans,abs(total-c*2));
    }else{
      chmin(ans,abs(total-b[i]*2));
    }
  }
  
  cout<<ans<<endl;
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll ds(ll a, ll b) {
  if (a > b) {
    swap(a, b);
  }
  if (!a)
    return b;
  else
    return ds(b % a, a);
}

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  ll cnt = 0;
  while(true) {
    cnt++;
    if (A % 2 == 1) {
      A--;
    }
    A /= 2;
    B += A;
    if (cnt == K) {
      break;
    }
    cnt++;
    if (B % 2 == 1) {
      B--;
    }
    B /= 2;
    A += B;
    if (cnt == K) {
      break;
    }
  }
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
#define pf push_front
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
#define mp make_pair
#define pii pair<int,int>
#define T int t;cin>>t;while(t--)
#define I 
#define REP(i,k,n) for(int i=k; i<n; i++)
#define Think 
#define We 
#define Should 
typedef long long int ll;
 
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}

int main(){ 
	ll n;
	ll ans = 10000000000000;
	cin>>n;
	for(int i=ceil(sqrt(n)); i>=1; i--){
		if(n%i==0){
			ans = min(ans, i-1 + n/i - 1);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

// Returns the length of the longest palin
void change(string s)
{

    // Finding the length of the string
    int n = s.length();

    // To store the number of replacement operations
    int cc = 0;

    for(int i=0;i<n/2;i++)
    {

        // If the characters at location
        // i and n-i-1 are same then
        // no change is required
        if(s[i]== s[n-i-1])
            continue;

        // Counting one change operation
        cc+= 1;

        // Changing the character with higher
        // ascii value with lower ascii value
        if(s[i]<s[n-i-1])
            s[n-i-1]= s[i] ;
        else
            s[i]= s[n-i-1] ;
    }
   cout<<cc;
}
void solve()
{
 ll i,j=0,r=200,p,q,k,d,y=0,h,flag=0,m=0,n,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c,e,ans=0;
string s;
cin>>s;
change(s);


}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int i,flg;
	char s[10],a[]="YAKI";
	cin>>s;
	flg=0;
	for(i=0;i<4;i++){
		if(s[i]!=a[i]){
			flg=1;
			break;
		}
	}
	if(flg==1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()

const int INF = (int)1e8;

using namespace std;

int main(){
	string a,b;
	cin >> a >> b;
	vector<vector<int> > dp(a.size()+1, vector<int>(b.size()+1, INF));
	for(int i = 0; i < a.size()+1; i++)dp[i][0] = i;
	for(int i = 0; i < b.size()+1; i++)dp[0][i] = i;
	for(int i = 1; i < a.size()+1; i++){
		for(int j = 1; j < b.size()+1; j++){
			//cerr << i << "," << j << "   ";
			//cerr << a[i-1] << ":" << b[j-1] << endl;
			dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]+1);
			if(a[i-1] == b[j-1]){
				dp[i][j] = min(dp[i][j], dp[i-1][j-1]);
			}
			else{
				dp[i][j] = min(dp[i][j], dp[i-1][j-1]+1);
			}
		}
	}
	//for(auto v: dp){for(auto e : v) cerr << e << " "; cerr << endl;}
	cout << dp[a.size()][b.size()] << endl;

	return 0;
}




Measured memory_bytes: 6844
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace3race4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 100005;

    int dp[N];
    int arr[N];
    
  int32_t main() 
  {
    IOS


        
        int n;
        cin >> n;
        int arr[n+1];

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

        int ans = 0;

        for(int i = 1; i <= n; i++)
        {
          for(int j = i + 1; j <= n; j++)
          {
            ans += arr[i] * arr[j];
          }
        }


     
        cout << ans;
    return 0;
      }

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
    unsigned long long N;
    cin>>N;
    if(N%2==1)
    {
        cout<<0<<endl;
        return 0;
    }

    unsigned long long sum = 0;
    unsigned long long five = 10;
    while(1)
    {
        sum+=(unsigned long long)N/five;
        five*=5;
        if(five>N)break;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, M, D[101010];
vector<vector<P>> G;


void solve() {
    map<int, vector<int>> ma;
    FOR(N) {
        ma[D[i]].eb(i);
    }

    vector<int> clr(N, -1), res(M, INF);
    for (auto& it : ma) {
        int val = it.first;
        auto vec = it.second;
        for (auto v : vec) {
            if (clr[v] != -1)
                continue;
            bool flag = false;
            for (auto e : G[v]) {
                int nxt = e.first;
                if (D[nxt] > D[v])
                    continue;
                flag = true;
                res[e.second] = val;
                if (clr[nxt] == -1) {
                    clr[v] = 0;
                    clr[nxt] = 1;
                } else {
                    clr[v] = !clr[nxt];
                }
                break;
            }
            if (!flag) {
                cout << -1 << endl;
                return;
            }
        }
    }
    FOR(N) {
        if (clr[i] == 0)
            cout << 'W';
        else
            cout << 'B';
    }
    cout << endl;
    FOR(M) {
        cout << res[i] << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FOR(N) {
        cin >> D[i];
    }
    G.resize(N);
    FOR(M) {
        itn u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].eb(v, i);
        G[v].eb(u, i);
    }
    solve();
    return 0;
}


Measured memory_bytes: 27648
#include<bits/stdc++.h>
using namespace std;
int n;
int arr[105],brr[105];
bool check() {
	for(int i=1;i<=n;i++)
		if(arr[i] != brr[i])
			return false;
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i] , brr[i] = arr[i];
	sort(brr+1,brr+1+n);
	if(check()) {
		cout << "YES" << '\n';
	}
	else {
		bool flag = false;
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++) {
				swap(arr[i],arr[j]);
				if(check())
					flag = true;
				swap(arr[i],arr[j]);
			}
		cout << (flag ? "YES" : "NO") << '\n';
	}
	return 0;
}


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

typedef struct {
	int ok;
	int ng;
} JUDGE;

int main()
{
	int n;
	while (scanf("%d", &n), n){
		JUDGE lunch = {0, 0};
		JUDGE dinner = {0, 0};
		JUDGE midnight = {0, 0};
		
		for (int i = 0; i < n; i++){
			int hh, mm, MM;
			scanf("%d%*c%d %d", &hh, &mm, &MM);
			
			if (hh >= 0 && hh <= 1){
				hh += 24;
			}
			if (MM < mm){
				MM += 60;
			}
			
			if (hh >= 11 && hh <= 14){
				if (MM - mm <= 8){
					lunch.ok++;
				}
				else {
					lunch.ng++;
				}
			}
			else if (hh >= 18 && hh <= 20){
				if (MM - mm <= 8){
					dinner.ok++;
				}
				else {
					dinner.ng++;
				}
			}
			else if (hh >= 21 && hh <= 25){
				if (MM - mm <= 8){
					midnight.ok++;
				}
				else {
					midnight.ng++;
				}
			}
		}
		
		printf("lunch ");
		if (lunch.ok + lunch.ng == 0){
			printf("no guest\n");
		}
		else {
			printf("%d\n", 100 * lunch.ok / (lunch.ok + lunch.ng));
		}
		
		printf("dinner ");
		if (dinner.ok + dinner.ng == 0){
			printf("no guest\n");
		}
		else {
			printf("%d\n", 100 * dinner.ok / (dinner.ok + dinner.ng));
		}
		
		printf("midnight ");
		if (midnight.ok + midnight.ng == 0){
			printf("no guest\n");
		}
		else {
			printf("%d\n", 100 * midnight.ok / (midnight.ok + midnight.ng));
		}
	}
	
	return 0;
}

/*
 && (hh != 14 || MM < 60)
 && (hh != 20 || MM < 60)
 && (hh != 25 || MM < 60)
*/ 

Measured memory_bytes: 1040
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(K: int, X: int):
    if 500 * K >= X:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  for(i=1;i<=n;i++){
v = A[i];
j=i-1;
while(j>=0 && A[j]>v){
A[j+1] = A[j];
j--;
A[j+1] = v;
}
trace(A,n);
}

  return 0;
}

Measured memory_bytes: 2728
#include <iostream>
#include<math.h>
#include<iomanip>
 int main()
{
    double A,B,H,M;
    double r;
    std::cin>>A>>B>>H>>M;
    H=(H*60+M)*.5;
    H > M*6 ? r = H - M*6 : r = M*6 - H;
    if(r>180)
    {
        r=360-r;
    }
    r = r  * M_PI / 180.0;
    std::cout  <<std:: fixed<<std::setprecision(10)<< sqrt(A*A+B*B-2*A*B*cos(r)) << std::endl;
    return 0;
}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, k;
ll a[N];
ll fac[N], inv[N];
ll powmod(ll a, ll b)
{
	a %= mod;
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
void init()
{
	fac[0] = 1;
	for(int i=1;i<=n;i++) fac[i] = fac[i-1]*i%mod;
	inv[n] = powmod(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i] = inv[i+1]*(i+1)%mod;
}
ll comp(ll a,ll b)
{
	if(a<b||b<0) return 0;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	for(int i=1; i<=n; i++) cin >> a[i];
 	init();
 	sort(a+1, a+n+1);
 	ll ans = 0;
 	for(int i=1; i+k-1<=n; i++)
 	{
 		ll cur = comp(n-i, k-1)*a[i]%mod;
		ans = (ans - cur)%mod;
		ans = (ans + mod)%mod; 
 	}
 	reverse(a+1, a+n+1);
 	for(int i=1; i+k-1<=n; i++)
 	{
 		ll cur = comp(n-i, k-1)*a[i]%mod;
 		ans = (ans + cur)%mod;
 	}
 	ans = (ans + mod)%mod;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repR(i,a,b)for(int i=a;i>=b;i--)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define vec vector<int>
#define vecl vector<long long int>
#define sz(x) (int) (x).size()
#define f(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define el '\n'
#define c(m) cout<<"-1"<<endl
#define YY  cout<<"YES"<<endl
#define NY  cout<<"NO"<<endl
#define i(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
const int MOD=1000000007;
const int Nm=-MOD;
const int N=1000005;
typedef long long ll;
ll add(ll x, ll y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

ll inv(ll x)
{
    return binpow(x, MOD - 2);
}

ll divide(ll x, ll y)
{
    return mul(x, inv(y));
}


ll fact[N];

void precalc()//factorial
{
    fact[0] = 1;
    for(int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

ll C(ll n, ll k)//nCr
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
ll dp[101][100001];

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

    int tc;
    tc=1;
  // cin>>tc;
    while(tc--)
    {
          f(dp);
          int pre[101];
          f(pre);
          int n,k;
          cin>>n>>k;
          int a[n];
          rep(i,n)
          {
          	cin>>a[i];
          	if(i==0)
          	pre[i]=a[i];
          	else
          	pre[i]=a[i]+pre[i-1];
          	
		  }
		
		          
		  for(int i=0;i<=a[0];i++)
		  dp[0][i]=1;
		  
		  repA(i,1,n-1)
		  { 
		  	for(int j=0;j<=k;j++)
		  	{ if(j==0)
		  	  {
		  	  	dp[i][j]=1;
		  	  	continue;
				}
		  		if(j>pre[i])
		  		dp[i][j]=0;
		  		else
		  		if(j==pre[i])
		  		{
		  		
		  			dp[i][j]=1;
				  }
		  		else
		  	{
				  (dp[i][j]=dp[i-1][j]+dp[i][j-1])%MOD;
				  if(j-1>=a[i])
				  {
				  	dp[i][j] = (dp[i][j] + MOD - dp[i-1][j - 1 - a[i]]) % MOD;
				  }
				  
			}
			if(dp[i][j] >= MOD){
                dp[i][j] = dp[i][j] % MOD;
            }
			  }
		  }
		  	
		  	
		////
			cout<<dp[n-1][k];
		  
    }

	return 0;
}




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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n;
    cin >> n;

    ll l[n+1];
    l[0] = 2; l[1] = 1;
    rep(2, n+1) {
        l[i] = l[i-1] + l[i-2];
    }

    cout << l[n] << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
	"math/big"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	l := strings.Split(nextLine(), " ")
	a0, _ := strconv.ParseUint(l[0], 10, 0)
	a := new(big.Int).SetUint64(a0)
	b0, _ := strconv.ParseUint(l[1], 10, 0)
	b := new(big.Int).SetUint64(b0)
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	g := z.GCD(x, y, a, b)
	h := new(big.Int)
	h.Mul(a, b)
	i := new(big.Int)
	i.Div(h, g)
	fmt.Println(i)
}


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

vector<vector<int> > T;
void init(int i, int s, vector<int> v)
{
	if (s > 10) return;
	else if (i == 9){
		if (s == 10) T.push_back(v);
		return;
	}
	for (int j = 0; j <= 10; j++){
		v[i] = j;
		init(i + 1, s + (i + 1) * j, v);
	}
}

int n;
map<vector<int>, int> dp;

int dfs(vector<int> v, int sum)
{
	if (sum < 10) return dp[v] = 0;
	if (dp.count(v)) return dp[v];
	int res = 0;
	for (int i = 0; i < T.size(); i++){
		vector<int> vv = v;
		bool f = true;
		for (int k = 0; k < 9; k++){
			vv[k] -= T[i][k];
			if (vv[k] < 0) f = false;
		}
		if (!f) continue;
		if (sum / 10 <= res) continue;
		res = max(res, 1 + dfs(vv, sum - 10));
	}
	return dp[v] = res;
}

int main()
{
	init(0, 0, vector<int>(9));
		
	while (scanf("%d", &n), n){
		dp.clear();
		vector<int> v(9);
		
		for (int i = 0; i < n; i++){
			int a;
			scanf("%d", &a);
			v[--a]++;
		}
		
		int g = 0;
		for (int i = 0; i < 4; i++){
			int t = min(v[i], v[8 - i]);
			g += t;
			v[i] -= t;
			v[8 - i] -= t;
		}
		g += v[4] / 2;
		v[4] %= 2;
		
		int sum = 0;
		for (int i = 0; i < 9; i++){
			sum += (i + 1) * v[i];
		}
		
		printf("%d\n", g + dfs(v, sum));
	}
}

Measured memory_bytes: 1208
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T=list(input())

commands = [""]*n
ans = 0

for i, t in enumerate(T):
    if t == "p":
        command = "s"
        point = s
    elif t == "s":
        command = "r"
        point = r
    elif t == "r":
        command = "p"
        point = p

    if(i - k) >= 0 and (commands[i-k] == command):
        command = ""
        point = 0

    ans += point
    commands[i] = command
print(ans)


Measured memory_bytes: 10492
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a[200008], sum, ans;

int main(){
	cin >> n;
	sum = 0;
	for(ll i = 1; i <= n; i++){cin >> a[i]; sum += a[i];}
	for(ll i = 1; i <= n; i++){a[i] += a[i-1];}
	
	ans = abs(sum-2*a[1]);
	for(ll i = 2; i <= n-1; i++){
		ans = min(abs(sum-2*a[i]), ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
Module Module1
Sub main()
Dim S = Console.ReadLine()
If S = "RRR" Then
    Console.Write (3)
ElseIf S = "SSS" Then
    Console.Write (0)
    ElseIf S = "SRR" Or S = "RRS" Then
Console.Write (2)
Else
Console.Write (1)
End If


End Sub
End module



Measured memory_bytes: 26716
#include<cstdio>
typedef long long LL;
const int MOD=924844033;
const int N=2003;

int n,k,cnt,ans;
int f[2*N][N][2];
int g[N],A[2*N],jc[N];

int main() {
	scanf("%d %d",&n,&k);
	jc[0]=1;
	for(LL i=1;i<=n;i++)
		jc[i]=i*jc[i-1]%MOD;
	for(int i=1;i<=k;i++) {
		for(int j=i;j<=n;j+=k) A[++cnt]=(i==j);
		for(int j=i;j<=n;j+=k) A[++cnt]=(i==j);
	}//加入链 
	f[0][0][0]=1;
	for(int i=1;i<=(n<<1);i++)
		for(int j=0;j<=i&&j<=n;j++) {
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%MOD;
			if(!A[i]&&j) f[i][j][1]=f[i-1][j-1][0];
		}
	for(int i=0;i<=n;i++)
		g[i]=(f[n<<1][i][0]+f[n<<1][i][1])%MOD;
	for(LL i=0,o=1;i<=n;i++,o=-o)
		ans=(ans+o*g[i]*jc[n-i])%MOD;
	printf("%d\n",(ans+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 61312
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	public static void main(String[] args) {
		long a=scan.nextLong();
		long ans=0;
		long saisyo=a/11;
		ans+=saisyo*2;
		a-=saisyo*11;
		if(saisyo%2==0) {
			if(a>6) {
				ans+=2;
			}
			else if(a>0) {
				ans++;
			}
		}else {
			if(a>5) {
				ans+=2;
			}
			else if(a>0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
    long long N, K;
    cin >> N >> K;

    long long r_p = N % K;
    long long r_m = K - r_p;
    long long ans = min({r_p, r_m});

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

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t(q);
    vector<char> d(q);
    rep(i,q){
        cin >> t[i] >> d[i];
    }
    ll sup = -1;
    ll inf = n;
    while(inf - sup > 1){
        ll mid = (sup + inf)/2;
        ll ind = mid;
        rep(i,q){
            if(s[ind] == t[i]){
                if(d[i] == 'L') --ind;
                else ++ind;
            }
            if(ind == -1 || ind == n) break;
        }
        if(ind == -1) sup = mid;
        else inf = mid;
    }
    ll l = sup;
    sup = -1;   inf = n;
    while(inf - sup > 1){
        ll mid = (sup + inf)/2;
        ll ind = mid;
        rep(i,q){
            if(s[ind] == t[i]){
                if(d[i] == 'L') --ind;
                else ++ind;
            }
            if(ind == -1 || ind == n) break;
        }
        if(ind == n) inf = mid;
        else sup = mid;
    }
    ll r = inf;
    if(r <= l) cout << n - n << endl;
    else cout << n - (l + 1 + n - r) << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 300 + 5;
ld memo[N][N][N], cnt[3];
int n;
bool visited[N][N][N];

ld solve(int a, int b, int c)
{
	if (a + b + c == 0)
		return 0;
	if (visited[a][b][c])
		return memo[a][b][c];
	
	visited[a][b][c] = true;
	
	ld &ret = memo[a][b][c];
	ld sum = (a + b + c);

	ret = (n * 1.) / sum;
	if (a)
		ret += solve(a - 1, b, c) * a / sum;
	if (b)
		ret += solve(a + 1, b - 1, c) * b / sum;
	if (c)
		ret += solve(a, b + 1, c - 1) * c / sum;

	return ret;
}

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

	cin >> n;

	rep(i, 0, n)
	{
		int x;
		cin >> x;
		cnt[x - 1]++;
	}

	cout << fixed << setprecision(12) << solve(cnt[0], cnt[1], cnt[2]) << endl;

	return 0;
}


Measured memory_bytes: 465152
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) (int)s.size()
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=1e9+7;
const int N=(int)1e5+5;
vi adj[N];
vi vis(N);
void dfs(int u)
{
	for(auto &x:adj[u])
	{
		if(!vis[x])
		{
			vis[x]=1;
			dfs(x);
		}
	}
}

int cnt=0;
void solve()
{
fastio
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++)
{
	int x,y;
	cin>>x>>y;
	adj[x].pb(y);
	adj[y].pb(x);
}
for(int i=1;i<=n;i++)
{
	if(!vis[i])
	{
		cnt++;
		vis[i]=1;
		dfs(i);
	}
}
cout<<cnt-1;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}



Measured memory_bytes: 9604
import java.util.*;
import java.io.*;
import java.text.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        out.println((int)Math.pow(in.nextInt(),3));
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21588
#include <iostream>
using namespace std;
int main(void){
    int N,M; cin>>N>>M;
    const int nmmax=50;
    char A[nmmax][nmmax],B[nmmax][nmmax];
    for(int y=0;y<N;++y){
        for(int x=0;x<N;++x){
            cin >> A[y][x];
        }
}
    for(int y=0;y<M;++y){
        for(int x=0;x<M;++x){
            cin >> B[y][x];
        }
}
    bool exist=false;
    for(int ly=0;ly<N;++ly){
        for(int lx=0;lx<N;++lx){
            if(ly+M-1>=N or lx+M-1>=N) continue;
            bool match=true;
            for(int y=0;y<M;++y){
                for(int x=0;x<M;++x){
                    if(A[ly+y][lx+x]!=B[y][x]) match=false;
} }
            if(match) exist=true;
        }
}
    if(exist)
        cout << "Yes" << endl;
else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  char c;
  scanf("%c", &c);
  switch(c) {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o': puts("vowel"); break;
    default: puts("consonant"); break;
  }
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    char x,y;cin>>x>>y;
    if(x<y)puts("<");
    else if(x==y)puts("=");
    else puts(">");
    return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int N;
int score[1000100];
int p[1000100];
set<int> leaders;
unordered_map<int,int> lcnt;

void addLeader(int id) {
    const int offset = upper_bound(p, p+N, score[id]) - p - 1;
    const int leaderIdx = offset - lcnt[score[id]]++;
    leaders.insert(leaderIdx);
    return;
}

void removeLeader(int id) {
    const int offset = upper_bound(p, p+N, score[id]) - p - 1;
    const int leaderIdx = offset - (--lcnt[score[id]]);
    leaders.erase(leaderIdx);
    return;
}

void debug()
{
    for (int i = 0; i < N; ++i) {
        printf("%d ", p[i]);
    }
    printf("\n");
    printf("leaders : { ");
    for (int e : leaders) {
        printf("%d, ", e);
    }
    printf("}\n");
    printf("---------------------------------------\n");
}

int countHazure(int r)
{
    if (leaders.empty()) {
        return N;
    }

    vector<int> a;
    a.reserve(leaders.size());
    for (int idx : leaders) { a.push_back(idx); }

    const auto lb = [&](int v) { return lower_bound(p, p+N, v) - p; };

    int ans = N - a.back() - 1;
    ans += lb(p[a.front()] - r);

    for (int i = 1; i < a.size(); ++i) {
        ans += max<i64>(0, lb(p[a[i]] - r) - a[i-1] - 1);
    }

    return ans;
}

int solve(int X)
{
    i64 ng = -1;
    i64 ok = INF;

    while(ok - ng > 1) {
        i64 mid = (ok + ng) / 2;
        if (countHazure(mid) <= X) ok = mid;
        else ng = mid;
    }

    return ok;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int Q;

    cin >> N >> Q;
    for (int i = 0; i < N; ++i) {
        cin >> score[i];
        p[i] = score[i];
    }

    sort(p, p + N);
    for (int i = 0; i < N; ++i) {
        lcnt[p[i]] = 0;
    }

    while(Q--) {
        string com;
        int x;

        cin >> com >> x;
        if (com[0] == 'A') {
            --x;
            addLeader(x);
        }
        else if (com[0] == 'R') {
            --x;
            removeLeader(x);
        }
        else if (com[0] == 'C') {
            int ans = solve(x);
            if (ans >= INF) {
                cout << "NA" << "\n";
            } else {
                cout << ans << "\n";
            }
        }
        else if (com[0] == 'D') {
            cout << countHazure(x) << endl;
        }

        //debug();
    }

    return 0;
}

// vim: set foldmethod=marker :



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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;
constexpr int MAXN = 1e4+10;
vector<string> dp(MAXN);
int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool cmp(string& a, string& b){
  if(a.size() != b.size()){
    return a.size() > b.size();
  }
  else{
    return a > b;
  }
}
string maxs(string& a, string& b){
  if(a=="?" || a==""){
    return b;
  }
  if(cmp(a, b)){
    return a;
  }
  else{
    return b;
  }
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  REP(i, M){
    cin >> A[i];
  }
  REP(i, MAXN){
    dp[i] = "?";
  }
  dp[0] = "";
  REP(i, N){
    if(dp[i] == "?") continue;
    for(auto a : A){
      string s = dp[i] + to_string(a);
      dp[i+cost[a]] = maxs(dp[i+cost[a]], s);
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 33024
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

#include <unordered_map>

#include <cstring>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main(void) {
	int N;
	cin >> N;
	
	unordered_map<long, int> sss;
	
	REP(i, N) {
		long x;
		cin >> x;
		
		int a = sss[x];
		
		sss[x] = a+1;
	}
	
	
	long ret = 0;
	for ( auto p : sss ) {
		if ( p.second < p.first ) {
			ret += p.second;
		} else {
			ret += (long)p.second - p.first;
		}
	}
	
	cout << ret << endl;
}


Measured memory_bytes: 4260
#include <cstdio>
#include <iostream>
#include <cstring> 
using namespace std;
int main()
{
	char s[4];
	cin >> s;
	int a[28]={0};
	int flag=0;
	for (int i=0;i<strlen(s);i++)
	{
		a[s[i]-'A']++;
	}
	if(strlen(s)<4)
	{
	cout <<"No";
	return 0;
	}
	for(int i=0;i<28;i++)
	{
		if(a[i]==2)
		{
			flag++;
		}
	}
	if(flag==2)
	{
		cout << "Yes";
	}
	else
	cout << "No";
	
	
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int B = sc.nextInt();
   int count = 1;
   int x = B-N;
     while(x>0){
       x = x-(N-1);
         count++;
     }

   if(B==1) count=0;
System.out.println(count);   
   
 }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int a,b;
    cin >> a >> b;
    if(a <= b)cout << a << endl;
    else cout << a-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n; cin >> n;
    ld res = 0;
    rep(i,n){
        ld x;
        string s;
        cin >> x >> s;
        if(s == "JPY")res += x;
        else res += x *  380000.0;
    }
    cout << setprecision(15) << fixed << res << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
n,x = map(int,input().split())
xs = list(map(int,input().split()))
xt = []
for i in xs:
    xt.append(i - x)
    
if n == 1:
    ans = xt[0]
else:
    ans = gcd(*xt)
print(abs(ans))

Measured memory_bytes: 16280