akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 200006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define forit(it, A) for(set<ll>::iterator it = A.begin(); it != A.end(); it++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n,  fb, ans, cursum;
deque <ll> dq, A, temp;
void solve()
{
	fb = 0, ans = 0, dq.clear();
	// sort(all(A));
	dq.pb(A[0]);
	A.pop_front();
	while(A.empty() == 0)
	{
		if(fb==0)
		{
			if(!A.empty())dq.push_front(A.back());
			if(!A.empty())A.pop_back();
			if(!A.empty())dq.push_back(A.back());
			if(!A.empty())A.pop_back();
		}
		else
		{
			if(!A.empty())dq.push_front(A.front());
			if(!A.empty())A.pop_front();
			if(!A.empty())dq.push_back(A.front());
			if(!A.empty())A.pop_front();
		}
		fb = !fb;
	}
	if(db)for(auto i  : dq)cout << i << " ";
	for(ll i = 0; i < dq.size()-1; i++)
	{
		ans += llabs(dq[i] - dq[i+1]);
	}
}
int main()
{
	cin >> n;
	for(ll i = 0 ; i < n; i++)
	{
		ll t;
		cin >> t;
		A.pb(t);
		temp.pb(t);
	}
	sort(all(A));
	sort(all(temp), greater<ll>());
	solve();
	cursum = ans;
	A.clear();
	for(auto i : temp)A.pb(i);
	solve();
	ans = max(ans, cursum);
	cout << ans << "\n";
}


Measured memory_bytes: 2688
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define gcd __gcd
// ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
// {
//   ll ans=0;
//   if(i>=n)
//     return 0;

//   if(dp[i][k]!=-1)
//     return dp[i][k];


//   if(k!=0)
//   ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
//   else
//   ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

//   return dp[i][k]=ans;

// }

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};


int temp[1000002]={0};

void sieve()
{
  temp[1]=1;
  for(int i=2;i<1000002;i++)
  {
    if(temp[i]==0)
    { temp[i]=i;
      for(int j=i*2;j<1000002;j+=i)
      { 
        if(temp[j]==0)
        temp[j]=i;
      }
    }
  }

}

int dfs(int i,vector<vector<int> > &g,vector<int>& p,vector<int>& c)
{
  int sub=1;
  for(auto x:g[i])
  {
    if(p[i]!=x)
    {
      p[x]=i;
      sub+=dfs(x,g,p,c);
    }
  }

  return c[i]=sub;
}


int main() { 


ll a,b,c,d;
cin>>a>>b>>c>>d;
ll m;

m=max(a*d,a*c);
m=max(m,b*c);
m=max(m,b*d);

cout<<m;


return 0;
}
/*
1
4
1 2
2 3
3 4
*/


Measured memory_bytes: 3632
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,a[N],b[N];
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n){
        cin>>a[i]>>b[i];
    }
    rep(i,1,n-2){
        if(a[i]==b[i] and a[i+1]==b[i+1] and a[i+2]==b[i+2]) return cout<<"Yes",0;
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3672
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n;

int inp[N + N];
int arr[N * 10];
int kunt[N * 10];

int main(){
  int n;
  fastScan(n);
  for(int i = 1; i <= n; i++){
    fastScan(inp[i]);
    kunt[inp[i]]++;
  }
  sort(inp + 1, inp + n + 1);
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(inp[i] == inp[i - 1]) continue;
    if(arr[inp[i]] == 0 && kunt[inp[i]] < 2){
      ans++;
    }
    if(kunt[inp[i]] )
    for(int j = inp[i]; j < N * 10; j += inp[i]){
      arr[j]++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12240
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll
//struct edge {int to,cost;};

int n;
int a[114514];

int LIS(){
    //int length=0;
    VI lis;
    lis.PB(a[0]);
    //length++;
    for(int i=1;i<n;i++){
        if(a[i]>lis[SZ(lis)-1]){
            lis.PB(a[i]);
        } else {
            *LB(ALL(lis),a[i]) = a[i];
        }
    }
    return SZ(lis);
}

signed main(){
    cin >> n;
    REP(i,n) scanf("%d",&a[i]);
    sort(a,a+n);

    printf("%d\n",LIS());
    return 0;
}


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

string S;

char A1[100010],A2[100010];

int cnt1,cnt2;

int zcnt,ocnt;


int main()
{
    cin >> S;

    size_t len = S.length();

    rep(i,len)
    {
        if(i%2==0)
        {
            A1[i]='0';
            A2[i]='1';
        }
        else
        {
            A1[i]='1';
            A2[i]='0';
        }
    }

    rep(i,len)
    {
        if(A1[i]!=S[i])
        {
            cnt1++;
        }
        if(A2[i]!=S[i])
        {
            cnt2++;
        }
    }

    cout << min(cnt1,cnt2) << endl;

    return 0;
}

Measured memory_bytes: 640
S = input()
N = len(S)
ans = 0
MOD = 10**9+7
dp = [[0]*4 for _ in range(2)]
dp[0][0] = 1

for i in range(N):
    if S[i]=='A':
        dp[(i+1)%2][0] = dp[i%2][0]
        dp[(i+1)%2][1] = dp[i%2][0]+dp[i%2][1]
        dp[(i+1)%2][2] = dp[i%2][2]
        dp[(i+1)%2][3] = dp[i%2][3]
    elif S[i]=='B':
        dp[(i+1)%2][0] = dp[i%2][0]
        dp[(i+1)%2][1] = dp[i%2][1]
        dp[(i+1)%2][2] = dp[i%2][1]+dp[i%2][2]
        dp[(i+1)%2][3] = dp[i%2][3]
    elif S[i]=='C':
        dp[(i+1)%2][0] = dp[i%2][0]
        dp[(i+1)%2][1] = dp[i%2][1]
        dp[(i+1)%2][2] = dp[i%2][2]
        dp[(i+1)%2][3] = dp[i%2][2]+dp[i%2][3]
    else:
        dp[(i+1)%2][0] = 3*dp[i%2][0]
        dp[(i+1)%2][1] = dp[i%2][0]+3*dp[i%2][1]
        dp[(i+1)%2][2] = dp[i%2][1]+3*dp[i%2][2]
        dp[(i+1)%2][3] = dp[i%2][2]+3*dp[i%2][3]

    for j in range(4):
        dp[(i+1)%2][j] %= MOD

print(dp[N%2][3])

Measured memory_bytes: 43372
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

vector<vector<int>> E;


int main(){ 
    int A, B;
    cin >> A >> B;

    A = (A + 12) % 14;
    B = (B + 12) % 14;

    if(A > B){
        cout << "Alice";
    }
    else if(B > A){
        cout << "Bob";
    }
    else{
        cout << "Draw";
    }
}



Measured memory_bytes: 764
N = int(input())
S = input()

ans = -1
for i in range(N-1):
    #print(S[0:i+1])
    #print(S[i+1:N])
    set_str = set(S[0:i+1]) & set(S[i+1:N])

    if ans < len(set_str):
        ans = len(set_str)

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
string s;
cin>>s;
int ans=0;
for(int i=0;i<s.size();i++){
  if(s[i]=='g')ans++;
}
cout<<ans-(s.size()+1)/2;
return 0;



}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF = 1e9+7;
    ll MOD = 998244353;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    #define F first
    #define S second
    #define pb(a) push_back(a)
    ///I hope I will get uprating and don't make mistakes
    ///I will never stop programming
    ///sqrt(-1) Love C++
    /// @TheofanisOrfanou Theo830
    ///AtCoder Beginner Contest 148
    int main(void){
        fastio;
        ll a,b;
        c(a);
        c(b);
        ll ans = a*b;
        ans /= __gcd(a,b);
        pl(ans);
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll X = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        X ^= a[i];
    }
    for (int i = 0; i < N; i++) {
        cout << (X^a[i]);
        if (i == N-1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 4812
//-----------------------
// author : xyqkoala
// time : 2020-08-16
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	// cout<<((-5)/2)<<endl;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	LL x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	LL cnt = (x)/d;
	// cout<<cnt<<endl;
	if(cnt>=k){
		cout<<x-k*d<<endl;
		return;
	}
	k-=cnt;
	x-=cnt*d;
	if(k%2ll){
		cout<<d-x<<endl;
	}else{
		cout<<x<<endl;
	}
	// cout<<x<<endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    deque<int> d;
    rep(i,N){
        int p = lower_bound(all(d),A[i]) - d.begin();
        if(p==0) d.push_front(A[i]);
        else d[p-1] = A[i];
    }
    cout << d.size() << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void ReadFirstInput(int *snukesNumber, int *candyTypes)
{
    //printf("Enter the number of Snukes and SnackTypes: \n");
    scanf("%d %d", snukesNumber, candyTypes);
}

void CountTricks(int *snukesArray, int *snukesNumber)
{
    int counter = 0;
    
    for(int i = 0; i < *snukesNumber; i++)
    {
        if(snukesArray[i] == 0)
        {
            counter++;
        }
    }
    printf("%d \n", counter);
}

void CreateArray(int *snukesNumber, int *candyTypes)
{
    int *dArray = (int*)malloc(250 * sizeof(int));
    int *aArray =  malloc(250 * 250 * sizeof *aArray);
    int *snukesArray = malloc(250 * sizeof(int));
    
    for(int i = 0; i < *candyTypes; i++)
    {
        scanf("%d\n", &dArray[i]);
        for(int j = 0; j < dArray[i]; j++)
        {
            scanf("%d", &aArray[i + j]);
            int snukesWithSnacks = aArray[i + j];
            snukesArray[snukesWithSnacks - 1] = 1;
        }
    }
    
    CountTricks(snukesArray, snukesNumber);
}

int main(int argc, const char * argv[])
{
    int *snukesNumber = malloc(3 * sizeof(int));
    int *candyTypes = malloc(3 * sizeof(int));
    
    ReadFirstInput(snukesNumber, candyTypes);
    CreateArray(snukesNumber, candyTypes);
    
    return 0;
}


Measured memory_bytes: 2092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int n, a, b;
   cin >> n >> a >> b;

   int ans = 0;
   for(int i = 1; i <= n; i++){
      int sum = 0;
      int i_tmp = i;
      for(int j = 0; j < 5; j++){
         sum += i_tmp % 10;
         i_tmp /= 10;
      }
      if(a <= sum && sum <= b){
         ans += i;
      }
   }

   cout<< ans << endl;

   return 0;
}

Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	cout << 1110 - n;

	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long a = 0, b = 0, c = 0, hairetu[1000] = { }, mi = 0, ma = 0, ansa = 0, ansb = 0, x = 0, y = 0;
	
	int snow=0;
		int one = 0, ten = 0, hun = 0, thou = 0,man=0;
	std::cin >>a;
	
	bool okada = true;
	for (int i = 1; i <= a; i++) {
		std::cin >> hairetu[i];
		if (mi == 0) {
			mi = hairetu[i];
		}
			if (mi > hairetu[i]) {

				mi = hairetu[i];
			
			}
		
		if (ma < hairetu[i]) {
			ma = hairetu[i];
		}
}
	std::cout << ma -mi << std::endl;

}







Measured memory_bytes: 256
#include <stdio.h>
#define N 101
#define WHITE 1
#define GRAY 2
#define BLACK 3
int n;
int adj[N][N];
int d[N];
int f[N];
int time;
int color[N];

void DFS(void);
void DFS_Visit(int);

void DFS(void){
	int i;
	for(i=1; i<=n; i++){
		color[i]=WHITE;
		time=0;
	}
	for(i=1; i<=n; i++){
		if(color[i]==WHITE){
			DFS_Visit(i);
		}
	}
}
void DFS_Visit(int u){
	int i;
	color[u]=GRAY;
	d[u]=++time;
	for(i=1; i<=n; i++){
		if(adj[u][i]==1 && color[i]==WHITE){
			DFS_Visit(i);
		}
	}
	color[u]=BLACK;
	f[u]=++time;
}
int main(void){
	int i;
	int j;
	int a, b, c;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		for(j=1; j<=n; j++){
			adj[i][j]=0;
		}
	}
	for(i=1; i<=n; i++){
		scanf("%d %d ", &a, &b);
		for(j=1;j<=b;j++){
			scanf("%d", &c);
			adj[a][c]=1;
		}
	}
	DFS();
	for(i=1; i<=n; i++){
		printf("%d %d %d\n", i, d[i], f[i]);
	}
	return 0;
}

Measured memory_bytes: 636
#!/bin/bash

read s
read t
c=0
[[ ${s:0:1} == ${t:0:1} ]] && (( c += 1 ))
[[ ${s:1:1} == ${t:1:1} ]] && (( c += 1 ))
[[ ${s:2:1} == ${t:2:1} ]] && (( c += 1 ))
echo ${c}

Measured memory_bytes: 376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int main(){
    int n ;
    cin >> n ;
    vector<vector<int> > s(n,vector<int>(n,1)) ;
    int64_t ans = 0 ;
    vector<int> p(n*n) ;
    int v[4][2] = {{1,0},{0,1},{-1,0},{0,-1}} ;
    
    for (int i = 0; i < n*n; i++)
    {
        cin >> p.at(i) ;
    }
    
    vector<vector<int> > grid(n,vector<int>(n,0)) ;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            grid.at(i).at(j) = min(min(i,n-1-i),min(j,n-1-j)) ;
        }
        
    }
    for (size_t ii = 0; ii < n*n; ii++)
    {
        int x = (p.at(ii) - 1) % n ;
        int y = (p.at(ii) - 1) / n ;
        s.at(x).at(y) = 0 ;
        ans += grid.at(x).at(y) ;
        for (size_t i = 0; i < 4; i++)
        {
            if (x+v[i][0] != -1 && x+v[i][0] != n && y+v[i][1] != -1 && y+v[i][1] != n)
            {
                grid.at(x).at(y) = min(grid.at(x).at(y),grid.at(x+v[i][0]).at(y+v[i][1])+s.at(x+v[i][0]).at(y+v[i][1])) ;
            }
            
        }
        queue<pair<int,int> > wait ;
        wait.push(make_pair(x,y)) ;
        while (wait.empty() == 0)
        {
            int nx = wait.front().first ;
            int ny = wait.front().second ;
            wait.pop() ;
            for (size_t i = 0; i < 4; i++)
            {
                int newx = nx + v[i][0] ;
                int newy = ny + v[i][1] ;
                if (newx == -1 || newx == n ||newy == -1 ||newy == n )
                {
                    continue ;
                }
                
                int judge = grid.at(nx).at(ny) + s.at(nx).at(ny) ;
                if (judge < grid.at(newx).at(newy)) 
                {
                    grid.at(newx).at(newy) = judge ;
                    wait.push(make_pair(newx,newy)) ;
                }
                
            }
            
        }
        
        
    }
    cout << ans << endl ;
    
}


Measured memory_bytes: 6036
#include <iostream>
#include <string>
using namespace std;
int main(){
int a;
cin >>a;
int b;
cin >>b;
int c;
cin >>c;
int d;
cin >>d;
int e;
e=a+b+c+d;
int f;
f=0;
while(e>=60){
f=f+1;
e=e-60;}
cout << f<<endl;
cout << e<<endl;}

Measured memory_bytes: 1160
m = 10**9 + 7
n = int(input())
t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
h = [t[i] if i == 0 or t[i-1] < t[i] else a[i] if i == n - 1 or a[i] > a[i+1] else -1
     for i in range(n)]
ans = 1
top = 0
for i in range(n):
    top = max(top, h[i])
    ans *= 1 if top == t[i] else 0
top = 0
for i in reversed(range(n)):
    top = max(top, h[i])
    ans *= 1 if top == a[i] else 0
prev = 0
for i in range(1, n):
    if h[i] > 0:
        ans = ans * pow(min(h[prev], h[i]), i - prev - 1, m) % m
        prev = i
print(ans)

Measured memory_bytes: 19776
from collections import deque


N = int(input())
A = [deque(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]


next_vs = [None] * N
day_finished = [0] * N
q = deque()
for i in range(N):
    q.append(i)

"""
・試合したらそいつらをキューに積む
・試合できなかったら、次はこいつと戦いたいよリストにいれる

キューを全て確認したのに、　次はこいつと戦いたいよリストが残っている/未試合の相手が残っている　状態であれば、与えられた順では試合ができない
"""

while q:
    x = q.popleft()
    opp_x = A[x].popleft()

    if next_vs[opp_x] == x:
        day_finished[x] = day_finished[opp_x] = max(day_finished[x], day_finished[opp_x]) + 1
        if A[x]:
            q.append(x)
        if A[opp_x]:
            q.append(opp_x)

    else:
        next_vs[x] = opp_x

for i in range(N):
    if A[i]:
        print(-1)
        exit()


print(max(day_finished))

Measured memory_bytes: 83932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		if(n%10 == 0) System.out.println(10);
		else {
			String nn = n+"";
			String m[] = nn.split("");
			int ans = 0;
			for(int i=0; i<m.length; i++) {
				ans += Integer.parseInt(m[i]);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
const int limit = 1e5 + 1;
const int inf = 1e7;

int main()
{
    int n;
    cin >> n;
    int a[n+1][3];
    int m[n+1][3];
    ms(m, 0);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            m[i][j] = max(m[i-1][(j+1)%3], m[i-1][(j+2)%3]) + a[i][j];
        }
    }

    cout<<max(m[n][0], max(m[n][1], m[n][2]))<<endl;

    return 0;
}

Measured memory_bytes: 2560
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))

S = [A[0] % k]
for i in range(1, n):
    S.append((A[i]+S[-1]) % k)

# print(S)

D = {}
S = [0] + S
ans = 0
for i in range(len(S)):
    key = (S[i] - i) % k

    if i >= k:
        j = i-k
        key1 = (S[j] - j) % k
        D[key1] -= 1
        try:
            ans += D[key1]
            # print(i, j, D[key1])
        except:
            ans += 0

    try:
        D[key] += 1
    except:
        D[key] = 1

for j in range(max(0, len(S)-k), len(S)):
    key1 = (S[j] - j) % k
    D[key1] -= 1
    try:
        ans += D[key1]
        # print(i, j, D[key1])
    except:
        ans += 0
# print(D)
print(ans)

Measured memory_bytes: 106392
#include<stdio.h>
int main(void)
{
  int price,coin;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&price);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&coin);
  
  while(price >= 500)
  {
    price -= 500;
  }
  
  if(price <= coin)
  {
    puts("Yes");
  }else
  {
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
maze = []
for _ in range(h):
    l = [None] * w
    maze.append(l)
n = int(input())
dat = list(map(int, input().split()))

curcol = 0
curpasted = 0

for hh in range(h):
    if hh % 2 == 0:
        for ww in range(0, w):
            maze[hh][ww] = curcol + 1
            curpasted += 1
            if curpasted >= dat[curcol]:
                curcol += 1
                curpasted = 0
    else:
        for ww in range(w-1, -1, -1):
            maze[hh][ww] = curcol + 1
            curpasted += 1
            if curpasted >= dat[curcol]:
                curcol += 1
                curpasted = 0
from pprint import pprint
for i in range(h):
    print(" ".join(list(map(str, maze[i]))))


Measured memory_bytes: 40304
#define		_CRT_SECURE_NO_WARNINGS
#define		_USE_MATH_DEFINES

#include	<cstdio>
#include	<cmath>

using namespace std;

int main()
{
	int		a, b, C;
	scanf("%d %d %d", &a, &b, &C);

	double	c, S, L, h;

	S = sin(C * M_PI / 180.) * a * b / 2.;
	c = sqrt(-(cos(C * M_PI / 180.) * 2. * a * b) + a * a + b * b);
	L = c + a + b;
	h = S / a * 2;

	printf("%.8f\n", S);
	printf("%.8f\n", L);
	printf("%.8f\n", h);

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<PL> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  ll n,m;
  cin>>n>>m;
  V<tuple<ll,ll,ll>> cake;
  rep(i,n){
    ll x,y,z;
    cin>>x>>y>>z;
    cake.eb(x,y,z);
  }

  VV(ll,sum,8,n,0);
  rep(i,n){
    ll a,b,c;
    tie(a,b,c)=cake[i];
    sum[0][i]=a+b+c;
    sum[1][i]=a+b-c;
    sum[2][i]=a-b+c;
    sum[3][i]=a-b-c;
    sum[4][i]=-a+b+c;
    sum[5][i]=-a+b-c;
    sum[6][i]=-a-b+c;
    sum[7][i]=-a-b-c;
  }
  for(auto&vec:sum)sort(all(vec),greater<>());
  ll ans=0;
  for(auto&vec:sum){
    ll res=0;
    rep(i,m)res+=vec[i];
    chmax(ans,res);
  }
  out(ans);
  
  
  
  return 0;
}



Measured memory_bytes: 384
fun main(args : Array<String>) {
    val (N, A, B, C, D) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!

    var a = A - 1
    var b = B - 1
    val shouldAPassOver = D < C

    while (true) {
        if (a == (C -1) && b == (D - 1)) {
            println("Yes")
            return
        }
        val canAMove1 = if (a + 1 >= N) false else S[a + 1] == '.'
        val canAMove2 = if (a + 2 >= N) false else S[a + 2] == '.'
        val canBMove1 = if (b + 1 >= N) false else S[b + 1] == '.'
        val canBMove2 = if (b + 2 >= N) false else S[b + 2] == '.'

        // Anyone can't move
        if (!(canAMove1 || canAMove2 || canBMove1 || canBMove2)) {
            println("No")
            return
        }

        if (shouldAPassOver) {
            if (canAMove1 && a + 1 != b) {
                a += 1
            } else if (canAMove2 && a + 2 !=b ) {
                a += 2
            } else if (canBMove1) {
                b += 1
            } else {
                b += 2
            }
        } else {
            // Move B first
            if (canBMove1) {
                b += 1
            } else if (canBMove2) {
                b += 2
            } else if (canAMove1) {
                a += 1
            } else if (canAMove2) {
                a += 2
            }
        }
    }
}

Measured memory_bytes: 39616
R, G, B, N = map(int, input().split())
ans = 0
 
for Rx in range(0, N+1, R):
    for Gy in range(0, N+1, G):
        check = N - Rx - Gy
        if check % B == 0 and 0 <= check // B <= N // B:
            ans += 1
print(ans)

Measured memory_bytes: 40812
N=int(input())
C,S,F=[0]*(N-1),[0]*(N-1),[0]*(N-1)
for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())
for i in range(N-1): #一周につき一つの駅([0]..[N-2])から[N-1]までの計算
    arrivalTime=S[i]+C[i]#最初発車駅の次の駅に着く時間
    for j in range(i+1,N-1):
        leaveTime=S[j]#現在考慮中の駅から初めて発車する時間
        if arrivalTime <leaveTime:
            pass
        elif arrivalTime % F[j]==0:
            leaveTime=arrivalTime
        else:
            leaveTime=arrivalTime+F[j]- arrivalTime % F[j]
        '''
        while arrivalTime > leaveTime:
            leaveTime+=F[j]
        '''
        arrivalTime=leaveTime+C[j]
    print(arrivalTime)
print(0)#[N-1]駅

Measured memory_bytes: 3064
// #include <cmath>
#include <string>
#include <vector>
// #include <numeric> /* gcd, lcm, partial_sum, reduce*/
#include <iostream>
#include <algorithm>

using namespace std;
const long long MOD = 998244353;
long long modpow(long long _a, long long _n) {
    long long a = _a;
    long long n = _n;
    long long res = 1LL;
    while (n > 0LL) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
int main(){
    long long n;
    cin >> n;
    long long d[n+1]; fill(d,d+n+1, 0LL);
    for(int i=0; i<n; i++){
        long long _d; cin >> _d; d[_d]++;
        if ( i== 0 && _d != 0LL){
            cout << 0 << endl;
            return 0;
        }
    }

    if(d[0]!=1LL){
        cout << 0 << endl;
        return 0;
    }
    if(n==1 || (n==2 && d[1]==1LL)){
        cout << 1 << endl;
        return 0;
    }

    long long ans = 1LL;
    long long cnt = 0LL;
    for(int i=0; i<=n && ans > 0LL && d[i]!=0LL; i++){
        cnt += d[i];
        ans = (ans * modpow(d[i], d[i+1])) % MOD;
    }
    if(cnt != n) ans = 0LL;
    cout << ans << endl;
    return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

vi ans;

void dfs(vector<vector<pair<int, int>>> &graph, int v)
{
    for (auto n : graph[v])
    {
        if (ans[n.first] != -1)
            continue;
        ans[n.first] = n.second % 2 == 0 ? ans[v] : 1 - ans[v];
        dfs(graph, n.first);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    int n;
    cin >> n;
    vector<vector<pair<int, int>>> graph(n);
    rep(i, n - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back(make_pair(v, w));
        graph[v].push_back(make_pair(u, w));
    }
    ans.assign(n, -1);
    ans[0] = 0;
    dfs(graph, 0);

    rep(i, n) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
ll poww(ll a, ll b)
{
    ll ans = 1, base = a;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * base;
        }
        base = base * base;
        b >>= 1;
    }
    return ans;
}
int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    ll ans = b * poww(b-1, a-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[51],r[51];
void init(){for(int i=0;i<50;i++)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}
vector<string> s,ans;
set<string> se[50];
int n,m;

void dfs(int k,int t) {
  bool f=1;
  for(int i=1; i<m; i++) if(!same(0,i)) f=0;
  if(f) {
    if(!ans.size()||ans.size()>__builtin_popcount(t)) {
      ans.clear();
      for(int i=0; i<n; i++) {
        if(t&(1<<i)) ans.push_back(s[i]);
      }
    }
    return;
  }
  if(k>=n) return;
  for(int i=k; i<n; i++) {
    if(__builtin_popcount(t|(1<<i))>5) continue;
    int l=0;
    while(l<m&&!se[l].count(s[i])) l++;
    if(l==m) continue;
    int pp[m],rr[m];
    for(int j=0; j<m; j++) pp[j]=p[j],rr[j]=r[j];
    for(int j=l+1; j<m; j++) {
      if(se[j].count(s[i])) unite(l,j);
    }
    dfs(i+1,t|(1<<i));
    for(int j=0; j<m; j++) p[j]=pp[j],r[j]=rr[j];
  }
}

int main() {
  int f=0;
  while(cin >> n >> m && n) {
    if(f) cout << endl;
    f=1;
    init();
    ans.clear();
    s.clear();
    for(int i=0; i<n; i++) {
      string t;
      cin >> t;
      s.push_back(t);
    }
    for(int i=0; i<m; i++) {
      se[i].clear();
      int k;
      cin >> k;
      for(int j=0; j<k; j++) {
        string t;
        cin >> t;
        se[i].insert(t);
      }
    }
    dfs(0,0);
    if(ans.size()) {
      cout << ans.size() << endl;
      for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;
    } else cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 3168
class Dice
	def initialize(array)
		@data = array
	end
	
	def move(dir)
		case dir.downcase
		when "e"
			tmp=@data[0]
			@data[0]=@data[3]
			@data[3]=@data[5]
			@data[5]=@data[2]
			@data[2]=tmp
		when "n"
			tmp=@data[0]
			@data[0]=@data[1]
			@data[1]=@data[5]
			@data[5]=@data[4]
			@data[4]=tmp
		when "s"
			tmp=@data[0]
			@data[0]=@data[4]
			@data[4]=@data[5]
			@data[5]=@data[1]
			@data[1]=tmp
		when "w"
			tmp=@data[0]
			@data[0]=@data[2]
			@data[2]=@data[5]
			@data[5]=@data[3]
			@data[3]=tmp
		end
	end
	
	def rotate
		tmp=@data[1]
		@data[1]=@data[2]
		@data[2]=@data[4]
		@data[4]=@data[3]
		@data[3]=tmp
	end
	
	def top
		return @data[0]
	end
	
	def front
		return @data[1]
	end
	
	def left
		return @data[3]
	end
	
	def right
		return @data[2]
	end
	
	def back
		return @data[4]
	end
	
	def bottom
		return @data[5]
	end
	
	def all
		return @data
	end
end

dice1 = Dice.new(gets.chomp.split(" ").map(&:to_i))
dice2 = Dice.new(gets.chomp.split(" ").map(&:to_i))

flg = -1

dice2.all.each{
	d2 = dice2.clone
	if dice1.top==d2.top && flg<0
		flg=0
	elsif dice1.top==d2.front && flg<1
		d2.move("N")
		flg=1
	elsif dice1.top==d2.left && flg<2
		d2.move("E")
		flg=2
	elsif dice1.top==d2.right && flg<3
		d2.move("W")
		flg=3
	elsif dice1.top==d2.back && flg<4
		d2.move("S")
		flg=4
	elsif dice1.top==d2.bottom && flg<5
		d2.move("S")
		d2.move("S")
		flg=5
	else
		puts "No"
		exit(0)
	end

	4.times {
		if dice1.front!=d2.front
			d2.rotate
		else
			break
		end
	}

	if dice1.all == d2.all
		puts "Yes"
		exit(0)
	end
}
puts "No"

Measured memory_bytes: 8752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string s; cin >> s;
    if(s[1] == 'R') s[1] = 'B';
    else s[1] = 'R';
    cout << s << endl;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,k,d,a;
set<int>S;
int main() {
    cin >> n >> k; 
    for(int i = 0;i<k;i++){
        cin >> d;
        for(int j = 0;j<d;j++){
            cin >> a;S.insert(a);
        }
    }cout << n - S.size() << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
		String b = sc.next();

		int x = Integer.parseInt(a, 16);
		int y = Integer.parseInt(b, 16);

		if(x<y) {
			System.out.println("<");
		}else if(x>y) {
			System.out.println(">");
		}else {
			System.out.println("=");
		}
	}
}


Measured memory_bytes: 22732
#include<stdio.h>

int main(){
    int W,H;
    while(1){
        scanf("%d %d",&H,&W);
        if(W==0&&H==0){
            break;
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i==0||i==H-1||j==0||j==W-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2616
/* ex7_3
   kohei_suzuki */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int row, col; //行数,列数
    int *ture_row, *ture_col; //#の有無を保存するための配列
    char **square; //入力用配列

    scanf("%d %d",&row,&col);//入力受取

    //メモリを動的確保して多次元配列を定義する
    square = (char**)calloc(row, sizeof(char*));
    if(square == NULL){
        printf("memory allocation error.\n");
        exit(1);
    }
    for(int i=0; i<row; i++){
        square[i] = (char*)calloc(col, sizeof(char));
        if(square[i] == NULL){
            printf("memory allocation error.\n");
            exit(1);
        }
    }

    //メモリを動的確保して配列を定義する
    ture_row = (int*)calloc(row, sizeof(int));
    if(ture_row == NULL){
        printf("memory allocation error.\n");
        exit(1);
    }
    
    //メモリを動的確保して配列を定義する
    ture_col = (int*)calloc(col, sizeof(int));
    if(ture_col == NULL){
        printf("memory allocation error.\n");
        exit(1);
    }

    //squareの入力受取
    for(int i=0; i<row ;i++){ 
        for(int j=0; j<col ;j++){
            scanf(" %c",&square[i][j]);
        }
    }
 
    //記録用配列の初期化
    for(int i=0; i<row; i++){ 
        ture_row[i]=0;
    }
    for(int j=0; j<col; j++){
        ture_col[j]=0;
    }

    //#があった行i,列jを記録(true_row[i]=1,true_col[j]=1とする)
    for(int i=0; i<row; i++){
        for(int j=0; j<col; j++){
            if(square[i][j]=='#'){
                ture_row[i]=1;
                ture_col[j]=1;
            }
        }
    }

    //true_row[i]=1かつtrue_col[j]=1ならばsquare[i][j]を出力
    for(int i=0; i<row; i++){
        if(ture_row[i] == 1){
            for(int j=0; j<col; j++){
                if(ture_col[j] == 1){
                    printf("%c",square[i][j]);
                }
            }
            printf("\n"); //行終わりで改行
        }
    }

    free(ture_row);
    free(ture_col);
    for(int i=0; i<row; i++){
        free(square[i]);
    }
    free(square);
    return 0;
}

Measured memory_bytes: 1644
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	a = map(parseInt, split(readline()))
	avg = sum(a)/n
	b = abs(a-avg)
	l = 1
	for i in 2:n
		if b[i] < b[l]
			l = i
		end
	end
	println(l-1)
end

main()

Measured memory_bytes: 116208
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int lax = sc.nextInt();
        int x[] = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = Math.abs(sc.nextInt() - lax);
        }
        int g;
        if (n == 1) {
            g = x[0];
        }else if (n == 2) {
            g = gcd(x[0], x[1]);
        }else{
            g = gcd(x[0], x[1]);
            for (int i = 2; i < n; i++) {
                g = gcd(g, x[i]);
            }
        }
        System.out.println(g);
    }

    public static int gcd(int x, int y){
        int nx = x;
        int ny = y;
        int tmp = nx % ny;
        while ((tmp = nx % ny) != 0) {
            nx = ny;
            ny = tmp;
        }
        return ny;
    }
}

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

const int N = 100010;

std::vector <int> e[N];
int u[N], v[N];
bool vis[N], instack[N];
std::vector <int> stack;

bool dfs(int u, int fa = -1){
    vis[u] = true;
    instack[u] = true;
    stack.emplace_back(u);
    std::vector <int> edge;
    for (auto ed : e[u]){
        if (ed == fa){
            continue;
        }
        int v = ::u[ed] ^ ::v[ed] ^ u;
        if (vis[v]){
            if (!instack[v]){
                edge.emplace_back(ed);
            }
            continue;
        }
        if (!dfs(v, ed)){
            edge.emplace_back(ed);
        }
    }
    stack.pop_back();
    instack[u] = false;
    for (auto ed : edge){
        if (::u[ed] != u){
            std::swap(::u[ed], ::v[ed]);
        }
    }
    if (edge.size() % 2 != 0){
        if (fa == -1){
            return false;
        }
        if (::u[fa] != u){
            std::swap(::u[fa], ::v[fa]);
        }
        return true;
    }
    return false;
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++ i){
        scanf("%d%d", &u[i], &v[i]);
        e[u[i]].emplace_back(i);
        e[v[i]].emplace_back(i);
    }
    if (m % 2 == 1){
        puts("-1");
        return 0;
    }
    dfs(1);
    for (int i = 0; i < m; ++ i){
        printf("%d %d\n", u[i], v[i]);
    }
    return 0;
}


Measured memory_bytes: 17784
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int dfs(int s, vector<vector<int>>& g) {
	vector<int> memo;
	for (int t : g[s]) {
		memo.emplace_back(dfs(t, g));
	}
	
	sort(memo.rbegin(), memo.rend());
	int ret = 0;
	for (int i = 0; i < memo.size(); ++i) {
		ret = max(ret, i + 1 + memo[i]);
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	vector<vector<int>> g(N);
	for (int i = 1; i < N; ++i) {
		cin >> a[i];
		--a[i];
		g[a[i]].emplace_back(i);
	}

	int ans = dfs(0, g);
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 2005;

int N;
ll dp[MX][MX];
vector<l_l> a;
ll ans = 0;

void solve() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    
    sort(a.begin(), a.end());
    
    for (int l = 0; l <= N; l++) {
        for (int r = N; r >= l; r--) {
            int ch = r - l;
            
            if (l > 0) {
                ll tmp = dp[l - 1][r];
                tmp += a[ch].first * abs(a[ch].second - (l - 1));
                chmax(dp[l][r], tmp);
            }
            
            if (r < N) {
                ll tmp = dp[l][r + 1];
                tmp += a[ch].first * abs(r - a[ch].second);
                chmax(dp[l][r], tmp);
            }
            // cout << l << " " << r << ": " << dp[l][r] << "\n";
        }
    }
    
    for (int i = 0; i <= N; i++) {
        chmax(ans, dp[i][i]);
    }
    cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 26296
#include <iostream>
using namespace std;
int main()
{
int n,step=0,maxx=0;
long long int arr[100000];
cin>>n;
for(int i=0;i<n;++i){
        cin>>arr[i];
        if(i!=0){
          if(arr[i]<=arr[i-1]) step++;

          else step=0;
        }
        if(step>maxx) maxx=step;
}
cout<<maxx;
return 0;
}


Measured memory_bytes: 1024